Skip to content

Commit

Permalink
Change SpecialRepresentations reprs field to unique_ptr.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed May 16, 2024
1 parent c98921e commit a4c927b
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 21 deletions.
1 change: 1 addition & 0 deletions scintilla/src/EditModel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ EditModel::EditModel() : durationWrapOneUnit(0.01 / 64), durationWrapOneThread(0
hotspotSingleLine = true;
hoverIndicatorPos = Sci::invalidPosition;
wrapWidth = LineLayout::wrapWidthInfinite;
reprs = std::make_unique<SpecialRepresentations>();
// before setting a lexer, style buffer is useless.
pdoc = new Document(DocumentOption::StylesNone);
pdoc->AddRef();
Expand Down
2 changes: 1 addition & 1 deletion scintilla/src/EditModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class EditModel {
bool primarySelection;
int xOffset; ///< Horizontal scrolled amount in pixels

SpecialRepresentations reprs;
std::unique_ptr<SpecialRepresentations> reprs;
Caret caret;
SelectionPosition posDrag;
Sci::Position braces[2];
Expand Down
6 changes: 3 additions & 3 deletions scintilla/src/EditView.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ void EditView::UpdateBidiData(const EditModel &model, const ViewStyle &vstyle, L

for (int charsInLine = 0; charsInLine < ll->numCharsInLine; charsInLine++) {
const int charWidth = UTF8DrawBytes(&ll->chars[charsInLine], ll->numCharsInLine - charsInLine);
const Representation *repr = model.reprs.RepresentationFromCharacter(std::string_view(&ll->chars[charsInLine], charWidth));
const Representation *repr = model.reprs->RepresentationFromCharacter(std::string_view(&ll->chars[charsInLine], charWidth));

ll->bidiData->widthReprs[charsInLine] = 0.0f;
if (repr && ll->chars[charsInLine] != '\t') {
Expand Down Expand Up @@ -1197,12 +1197,12 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle
std::string_view ctrlChar;
Sci::Position widthBytes = 1;
RepresentationAppearance appearance = RepresentationAppearance::Blob;
const Representation *repr = model.reprs.RepresentationFromCharacter(std::string_view(&ll->chars[eolPos], ll->numCharsInLine - eolPos));
const Representation *repr = model.reprs->RepresentationFromCharacter(std::string_view(&ll->chars[eolPos], ll->numCharsInLine - eolPos));
if (repr) {
// Representation of whole text
widthBytes = ll->numCharsInLine - eolPos;
} else {
repr = model.reprs.RepresentationFromCharacter(std::string_view(&ll->chars[eolPos], 1));
repr = model.reprs->RepresentationFromCharacter(std::string_view(&ll->chars[eolPos], 1));
}
if (repr) {
ctrlChar = repr->GetStringRep();
Expand Down
16 changes: 8 additions & 8 deletions scintilla/src/Editor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void Editor::Finalise() noexcept {
}

void Editor::SetRepresentations() {
reprs.SetDefaultRepresentations(pdoc->dbcsCodePage);
reprs->SetDefaultRepresentations(pdoc->dbcsCodePage);
}

void Editor::DropGraphics() noexcept {
Expand Down Expand Up @@ -8268,11 +8268,11 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
return vs.controlCharSymbol;

case Message::SetRepresentation:
reprs.SetRepresentation(ConstCharPtrFromUPtr(wParam), ConstCharPtrFromSPtr(lParam));
reprs->SetRepresentation(ConstCharPtrFromUPtr(wParam), ConstCharPtrFromSPtr(lParam));
break;

case Message::GetRepresentation: {
const Representation *repr = reprs.RepresentationFromCharacter(
const Representation *repr = reprs->RepresentationFromCharacter(
ConstCharPtrFromUPtr(wParam));
if (repr) {
return StringResult(lParam, repr->stringRep);
Expand All @@ -8281,31 +8281,31 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
}

case Message::ClearRepresentation:
reprs.ClearRepresentation(ConstCharPtrFromUPtr(wParam));
reprs->ClearRepresentation(ConstCharPtrFromUPtr(wParam));
break;

case Message::ClearAllRepresentations:
SetRepresentations();
break;

case Message::SetRepresentationAppearance:
reprs.SetRepresentationAppearance(ConstCharPtrFromUPtr(wParam), static_cast<RepresentationAppearance>(lParam));
reprs->SetRepresentationAppearance(ConstCharPtrFromUPtr(wParam), static_cast<RepresentationAppearance>(lParam));
break;

case Message::GetRepresentationAppearance: {
const Representation *repr = reprs.RepresentationFromCharacter(ConstCharPtrFromUPtr(wParam));
const Representation *repr = reprs->RepresentationFromCharacter(ConstCharPtrFromUPtr(wParam));
if (repr) {
return static_cast<sptr_t>(repr->appearance);
}
return 0;
}

case Message::SetRepresentationColour:
reprs.SetRepresentationColour(ConstCharPtrFromUPtr(wParam), ColourRGBA(static_cast<unsigned int>(lParam)));
reprs->SetRepresentationColour(ConstCharPtrFromUPtr(wParam), ColourRGBA(static_cast<unsigned int>(lParam)));
break;

case Message::GetRepresentationColour: {
const Representation *repr = reprs.RepresentationFromCharacter(ConstCharPtrFromUPtr(wParam));
const Representation *repr = reprs->RepresentationFromCharacter(ConstCharPtrFromUPtr(wParam));
if (repr) {
return repr->colour.AsInteger();
}
Expand Down
8 changes: 4 additions & 4 deletions scintilla/src/PositionCache.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lin
saeNext(0),
pdoc(model.pdoc),
encodingFamily(pdoc->CodePageFamily()),
reprs(model.reprs) {
reprs(model.reprs.get()) {

// Search for first visible break
// First find the first visible character
Expand Down Expand Up @@ -1123,12 +1123,12 @@ TextSegment BreakFinder::Next() {
// }
//}
repr = nullptr;
if (reprs.MayContains(ch)) {
if (reprs->MayContains(ch)) {
// Special case \r\n line ends if there is a representation
if (ch == '\r' && reprs.ContainsCrLf() && chars[1] == '\n') {
if (ch == '\r' && reprs->ContainsCrLf() && chars[1] == '\n') {
charWidth = 2;
}
repr = reprs.GetRepresentation(std::string_view(chars, charWidth));
repr = reprs->GetRepresentation(std::string_view(chars, charWidth));
}
if (((nextBreak > 0) && (ll->styles[nextBreak] != ll->styles[nextBreak - 1])) ||
repr ||
Expand Down
2 changes: 1 addition & 1 deletion scintilla/src/PositionCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class BreakFinder {
int saeNext;
const Document *pdoc;
const EncodingFamily encodingFamily;
const SpecialRepresentations &reprs;
const SpecialRepresentations *reprs;
void Insert(Sci::Position val);
public:
// If a whole run is longer than lengthStartSubdivision then subdivide
Expand Down
8 changes: 4 additions & 4 deletions scintilla/win32/PlatWin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ class SurfaceD2D final : public Surface {
int PixelDivisions() const noexcept override;
int DeviceHeightFont(int points) const noexcept override;
void SCICALL LineDraw(Point start, Point end, Stroke stroke) override;
static ID2D1PathGeometry *Geometry(const Point *pts, size_t npts, D2D1_FIGURE_BEGIN figureBegin) noexcept;
static ID2D1PathGeometry *GeometricFigure(const Point *pts, size_t npts, D2D1_FIGURE_BEGIN figureBegin) noexcept;
void SCICALL PolyLine(const Point *pts, size_t npts, Stroke stroke) override;
void SCICALL Polygon(const Point *pts, size_t npts, FillStroke fillStroke) override;
void SCICALL RectangleDraw(PRectangle rc, FillStroke fillStroke) override;
Expand Down Expand Up @@ -1696,7 +1696,7 @@ void SurfaceD2D::LineDraw(Point start, Point end, Stroke stroke) {
ReleaseUnknown(pStrokeStyle);
}

ID2D1PathGeometry *SurfaceD2D::Geometry(const Point *pts, size_t npts, D2D1_FIGURE_BEGIN figureBegin) noexcept {
ID2D1PathGeometry *SurfaceD2D::GeometricFigure(const Point *pts, size_t npts, D2D1_FIGURE_BEGIN figureBegin) noexcept {
ID2D1PathGeometry *geometry = nullptr;
HRESULT hr = pD2DFactory->CreatePathGeometry(&geometry);
if (SUCCEEDED(hr) && geometry) {
Expand All @@ -1722,7 +1722,7 @@ void SurfaceD2D::PolyLine(const Point *pts, size_t npts, Stroke stroke) {
return;
}

ID2D1PathGeometry *geometry = Geometry(pts, npts, D2D1_FIGURE_BEGIN_HOLLOW);
ID2D1PathGeometry *geometry = GeometricFigure(pts, npts, D2D1_FIGURE_BEGIN_HOLLOW);
PLATFORM_ASSERT(geometry);
if (!geometry) {
return;
Expand Down Expand Up @@ -1752,7 +1752,7 @@ void SurfaceD2D::PolyLine(const Point *pts, size_t npts, Stroke stroke) {
void SurfaceD2D::Polygon(const Point *pts, size_t npts, FillStroke fillStroke) {
PLATFORM_ASSERT(pRenderTarget && (npts > 2));
if (pRenderTarget) {
ID2D1PathGeometry *geometry = Geometry(pts, npts, D2D1_FIGURE_BEGIN_FILLED);
ID2D1PathGeometry *geometry = GeometricFigure(pts, npts, D2D1_FIGURE_BEGIN_FILLED);
PLATFORM_ASSERT(geometry);
if (geometry) {
D2DPenColourAlpha(fillStroke.fill.colour);
Expand Down

0 comments on commit a4c927b

Please sign in to comment.