diff options
author | Zufu Liu <unknown> | 2021-10-24 21:05:52 +1100 |
---|---|---|
committer | Zufu Liu <unknown> | 2021-10-24 21:05:52 +1100 |
commit | 83b67c1d70ac48dd242e7a7d6d248e26cddc69e4 (patch) | |
tree | 5e89ea486d175e77bc00a902d97e1c0f664feb40 /src | |
parent | 42c72b79878ae99c45532e46f12642b4e21affee (diff) | |
download | scintilla-mirror-83b67c1d70ac48dd242e7a7d6d248e26cddc69e4.tar.gz |
Avoid extra breaks introduced by revision 8993.
Diffstat (limited to 'src')
-rw-r--r-- | src/EditView.cxx | 10 | ||||
-rw-r--r-- | src/PositionCache.cxx | 8 | ||||
-rw-r--r-- | src/PositionCache.h | 8 |
3 files changed, 17 insertions, 9 deletions
diff --git a/src/EditView.cxx b/src/EditView.cxx index 30db6fb0d..444fb3283 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -464,7 +464,7 @@ void EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewSt ll->positions[0] = 0; bool lastSegItalics = false; - BreakFinder bfLayout(ll, nullptr, Range(0, numCharsInLine), posLineStart, 0, false, model.pdoc, &model.reprs, nullptr); + BreakFinder bfLayout(ll, nullptr, Range(0, numCharsInLine), posLineStart, 0, BreakFinder::BreakFor::Text, model.pdoc, &model.reprs, nullptr); while (bfLayout.More()) { const TextSegment ts = bfLayout.Next(); @@ -1762,7 +1762,8 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi // Does not take margin into account but not significant const XYPOSITION xStartVisible = static_cast<XYPOSITION>(subLineStart-xStart); - BreakFinder bfBack(ll, &model.sel, lineRange, posLineStart, xStartVisible, selBackDrawn, model.pdoc, &model.reprs, &vsDraw); + 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); const bool drawWhitespaceBackground = vsDraw.WhitespaceBackgroundDrawn() && !background; @@ -1980,8 +1981,9 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi const XYPOSITION xStartVisible = static_cast<XYPOSITION>(subLineStart-xStart); // Foreground drawing loop - BreakFinder bfFore(ll, &model.sel, lineRange, posLineStart, xStartVisible, - (((phasesDraw == PhasesDraw::One) && selBackDrawn) || vsDraw.SelectionTextDrawn()), model.pdoc, &model.reprs, &vsDraw); + 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); while (bfFore.More()) { diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index 587ffdd3b..bedc843df 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -662,7 +662,7 @@ void BreakFinder::Insert(Sci::Position val) { } BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lineRange_, Sci::Position posLineStart_, - XYPOSITION xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_, const ViewStyle *pvsDraw) : + XYPOSITION xStart, BreakFor breakFor, const Document *pdoc_, const SpecialRepresentations *preprs_, const ViewStyle *pvsDraw) : ll(ll_), lineRange(lineRange_), posLineStart(posLineStart_), @@ -683,7 +683,7 @@ BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lin nextBreak--; } - if (breakForSelection) { + if (FlagSet(breakFor, BreakFor::Selection)) { const SelectionPosition posStart(posLineStart); const SelectionPosition posEnd(posLineStart + lineRange.end); const SelectionSegment segmentLine(posStart, posEnd); @@ -699,7 +699,7 @@ BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lin // On the curses platform, the terminal is drawing its own caret, so add breaks around the // caret in the main selection in order to help prevent the selection from being drawn in // the caret's cell. - if (pvsDraw && FlagSet(pvsDraw->caret.style, CaretStyle::Curses) && !psel->RangeMain().Empty()) { + if (FlagSet(pvsDraw->caret.style, CaretStyle::Curses) && !psel->RangeMain().Empty()) { const Sci::Position caretPos = psel->RangeMain().caret.Position(); const Sci::Position anchorPos = psel->RangeMain().anchor.Position(); if (caretPos < anchorPos) { @@ -712,7 +712,7 @@ BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lin } } } - if (pvsDraw && pvsDraw->indicatorsSetFore) { + if (FlagSet(breakFor, BreakFor::Foreground) && pvsDraw->indicatorsSetFore) { for (const IDecoration *deco : pdoc->decorations->View()) { if (pvsDraw->indicators[deco->Indicator()].OverridesTextFore()) { Sci::Position startPos = deco->EndRun(posLineStart); diff --git a/src/PositionCache.h b/src/PositionCache.h index 4ee501841..1cbc94495 100644 --- a/src/PositionCache.h +++ b/src/PositionCache.h @@ -251,8 +251,14 @@ public: enum { lengthStartSubdivision = 300 }; // Try to make each subdivided run lengthEachSubdivision or shorter. enum { lengthEachSubdivision = 100 }; + enum class BreakFor { + Text = 0, + Selection = 1, + Foreground = 2, + ForegroundAndSelection = 3, + }; BreakFinder(const LineLayout *ll_, const Selection *psel, Range lineRange_, Sci::Position posLineStart_, - XYPOSITION xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_, const ViewStyle *pvsDraw); + XYPOSITION xStart, BreakFor breakFor, const Document *pdoc_, const SpecialRepresentations *preprs_, const ViewStyle *pvsDraw); // Deleted so BreakFinder objects can not be copied. BreakFinder(const BreakFinder &) = delete; BreakFinder(BreakFinder &&) = delete; |