diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2021-10-10 02:02:10 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2021-10-10 02:02:10 +0300 |
commit | 2bcf60285e1c196bf05cd47a8e04beb150b485ef (patch) | |
tree | 1d48f8db0b5f42725998fef197bcb762a9a64fb2 /src/PositionCache.cxx | |
parent | 371b6e510e62d7d3ca5fd5133f190ef6a7bb72ff (diff) | |
download | scintilla-mirror-2bcf60285e1c196bf05cd47a8e04beb150b485ef.tar.gz |
Added Scintilla::Curses to allow for terminal drawing of the main caret.
This is the patch from scinterm/patches/02-caretstyle_curses.patch.
Diffstat (limited to 'src/PositionCache.cxx')
-rw-r--r-- | src/PositionCache.cxx | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index 6eee26113..07507a7fa 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -690,10 +690,38 @@ BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lin for (size_t r=0; r<psel->Count(); r++) { const SelectionSegment portion = psel->Range(r).Intersect(segmentLine); if (!(portion.start == portion.end)) { - if (portion.start.IsValid()) - Insert(portion.start.Position() - posLineStart); - if (portion.end.IsValid()) - Insert(portion.end.Position() - posLineStart); + if (portion.start.IsValid()) { + const bool skipFirstSelectedCharacter = pvsDraw && pvsDraw->IsMainCursesCaret(r == 0) && + psel->Range(r).caret < psel->Range(r).anchor; + if (!skipFirstSelectedCharacter) { + Insert(portion.start.Position() - posLineStart); + } else { + // On the curses platform, the terminal is drawing its own caret, so + // make sure the main selection is not drawn on its first character + // if the caret is currently on it. + // While the caret is still inside the selection, it will be at the + // end of this text segment (instead of the beginning of the next + // one), so testing against this condition allows it to be drawn + // as not selected. + const Sci::Position next = pdoc->MovePositionOutsideChar(portion.start.Position()+1, 1); + Insert(next - posLineStart); + } + } + if (portion.end.IsValid()) { + const bool skipLastSelectedCharacter = pvsDraw && pvsDraw->IsMainCursesCaret(r == 0) && + psel->Range(r).caret > psel->Range(r).anchor && pvsDraw->DrawCaretInsideSelection(false, false); + if (!skipLastSelectedCharacter) { + Insert(portion.end.Position() - posLineStart); + } else { + // On the curses platform, the terminal is drawing its own caret, so + // make sure the main selection is not drawn on its last character + // if the caret is currently on it. The caret will be its own text + // segment and at the end of said segment, so testing against this + // condition allows it to be drawn as not selected. + const Sci::Position prev = pdoc->MovePositionOutsideChar(portion.end.Position()-1, -1); + Insert(prev - posLineStart); + } + } } } } |