diff options
author | Zufu Liu <unknown> | 2024-05-16 21:49:11 +1000 |
---|---|---|
committer | Zufu Liu <unknown> | 2024-05-16 21:49:11 +1000 |
commit | 8d4e03d3e827540d1f60e96091c0c71973910ff5 (patch) | |
tree | 965e76688da4d730e62c4d145e657ecc000e8323 | |
parent | 6d8ede848cc9d55d2632b66017979889a5280225 (diff) | |
download | scintilla-mirror-8d4e03d3e827540d1f60e96091c0c71973910ff5.tar.gz |
Feature [feature-requests:#1516]. Access SpecialRepresentations through a
unique_ptr. Reduces executable size.
-rw-r--r-- | src/EditModel.cxx | 1 | ||||
-rw-r--r-- | src/EditModel.h | 2 | ||||
-rw-r--r-- | src/EditView.cxx | 12 | ||||
-rw-r--r-- | src/Editor.cxx | 16 |
4 files changed, 16 insertions, 15 deletions
diff --git a/src/EditModel.cxx b/src/EditModel.cxx index dd441322e..13b3da5b0 100644 --- a/src/EditModel.cxx +++ b/src/EditModel.cxx @@ -77,6 +77,7 @@ EditModel::EditModel() : braces{} { hotspotSingleLine = true; hoverIndicatorPos = Sci::invalidPosition; wrapWidth = LineLayout::wrapWidthInfinite; + reprs = std::make_unique<SpecialRepresentations>(); pdoc = new Document(DocumentOption::Default); pdoc->AddRef(); pcs = ContractionStateCreate(pdoc->IsLarge()); diff --git a/src/EditModel.h b/src/EditModel.h index f62c28b1f..025c54389 100644 --- a/src/EditModel.h +++ b/src/EditModel.h @@ -27,7 +27,7 @@ public: int xOffset; ///< Horizontal scrolled amount in pixels bool trackLineWidth; - SpecialRepresentations reprs; + std::unique_ptr<SpecialRepresentations> reprs; Caret caret; SelectionPosition posDrag; Sci::Position braces[2]; diff --git a/src/EditView.cxx b/src/EditView.cxx index 7070bc60f..bae7ab233 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -480,7 +480,7 @@ void EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewSt bool lastSegItalics = false; std::vector<TextSegment> segments; - BreakFinder bfLayout(ll, nullptr, Range(0, numCharsInLine), posLineStart, 0, BreakFinder::BreakFor::Text, model.pdoc, &model.reprs, nullptr); + BreakFinder bfLayout(ll, nullptr, Range(0, numCharsInLine), posLineStart, 0, BreakFinder::BreakFor::Text, model.pdoc, model.reprs.get(), nullptr); while (bfLayout.More()) { segments.push_back(bfLayout.Next()); } @@ -611,7 +611,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') { @@ -1007,12 +1007,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->stringRep; @@ -1666,7 +1666,7 @@ void DrawBackground(Surface *surface, const EditModel &model, const ViewStyle &v const XYPOSITION xStartVisible = subLineStart - xStart; const BreakFinder::BreakFor breakFor = selBackDrawn ? BreakFinder::BreakFor::Selection : BreakFinder::BreakFor::Text; - BreakFinder bfBack(ll, &model.sel, lineRange, posLineStart, xStartVisible, breakFor, model.pdoc, &model.reprs, &vsDraw); + BreakFinder bfBack(ll, &model.sel, lineRange, posLineStart, xStartVisible, breakFor, model.pdoc, model.reprs.get(), &vsDraw); const bool drawWhitespaceBackground = vsDraw.WhitespaceBackgroundDrawn() && !background; @@ -2137,7 +2137,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi // Foreground drawing loop const BreakFinder::BreakFor breakFor = (((phasesDraw == PhasesDraw::One) && selBackDrawn) || vsDraw.SelectionTextDrawn()) ? BreakFinder::BreakFor::ForegroundAndSelection : BreakFinder::BreakFor::Foreground; - BreakFinder bfFore(ll, &model.sel, lineRange, posLineStart, xStartVisible, breakFor, model.pdoc, &model.reprs, &vsDraw); + BreakFinder bfFore(ll, &model.sel, lineRange, posLineStart, xStartVisible, breakFor, model.pdoc, model.reprs.get(), &vsDraw); while (bfFore.More()) { diff --git a/src/Editor.cxx b/src/Editor.cxx index 12076e003..f27c19aa5 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -217,7 +217,7 @@ void Editor::Finalise() { } void Editor::SetRepresentations() { - reprs.SetDefaultRepresentations(pdoc->dbcsCodePage); + reprs->SetDefaultRepresentations(pdoc->dbcsCodePage); } void Editor::DropGraphics() noexcept { @@ -8436,11 +8436,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.c_str()); @@ -8449,7 +8449,7 @@ 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: @@ -8457,11 +8457,11 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { 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( + const Representation *repr = reprs->RepresentationFromCharacter( ConstCharPtrFromUPtr(wParam)); if (repr) { return static_cast<sptr_t>(repr->appearance); @@ -8469,11 +8469,11 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { return 0; } case Message::SetRepresentationColour: - reprs.SetRepresentationColour(ConstCharPtrFromUPtr(wParam), ColourRGBA(static_cast<int>(lParam))); + reprs->SetRepresentationColour(ConstCharPtrFromUPtr(wParam), ColourRGBA(static_cast<int>(lParam))); break; case Message::GetRepresentationColour: { - const Representation *repr = reprs.RepresentationFromCharacter( + const Representation *repr = reprs->RepresentationFromCharacter( ConstCharPtrFromUPtr(wParam)); if (repr) { return repr->colour.AsInteger(); |