diff options
author | Zufu Liu <unknown> | 2021-08-24 11:14:20 +1000 |
---|---|---|
committer | Zufu Liu <unknown> | 2021-08-24 11:14:20 +1000 |
commit | 02914e8e53c3e72e9fc3a05f8e75078cad4eb0f6 (patch) | |
tree | b7894f557a313bad18445d13eca2b82039b8c9f9 /src | |
parent | 3ef8c4b037c622f910a0d13bba91657df1f78d9d (diff) | |
download | scintilla-mirror-02914e8e53c3e72e9fc3a05f8e75078cad4eb0f6.tar.gz |
Feature [feature-requests:#841] SCI_SETCARETLINEHIGHLIGHTSUBLINE enables
highlighting just the subline with the caret when wrapping is on.
Diffstat (limited to 'src')
-rw-r--r-- | src/EditView.cxx | 16 | ||||
-rw-r--r-- | src/Editor.cxx | 7 | ||||
-rw-r--r-- | src/ViewStyle.cxx | 1 | ||||
-rw-r--r-- | src/ViewStyle.h | 2 |
4 files changed, 18 insertions, 8 deletions
diff --git a/src/EditView.cxx b/src/EditView.cxx index e32e791ec..8a303faea 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -951,19 +951,19 @@ static void DrawCaretLineFramed(Surface *surface, const ViewStyle &vsDraw, const // Avoid double drawing the corners by removing the left and right sides when drawing top and bottom borders const PRectangle rcWithoutLeftRight = rcLine.Inset(Point(width, 0.0)); - if (subLine == 0 || ll->wrapIndent == 0 || vsDraw.caretLine.layer != Layer::Base) { + if (subLine == 0 || ll->wrapIndent == 0 || vsDraw.caretLine.layer != Layer::Base || vsDraw.caretLine.subLine) { // Left surface->FillRectangleAligned(Side(rcLine, Edge::left, width), colourFrame); } - if (subLine == 0) { + if (subLine == 0 || vsDraw.caretLine.subLine) { // Top surface->FillRectangleAligned(Side(rcWithoutLeftRight, Edge::top, width), colourFrame); } - if (subLine == ll->lines - 1 || vsDraw.caretLine.layer != Layer::Base) { + if (subLine == ll->lines - 1 || vsDraw.caretLine.layer != Layer::Base || vsDraw.caretLine.subLine) { // Right surface->FillRectangleAligned(Side(rcLine, Edge::right, width), colourFrame); } - if (subLine == ll->lines - 1) { + if (subLine == ll->lines - 1 || vsDraw.caretLine.subLine) { // Bottom surface->FillRectangleAligned(Side(rcWithoutLeftRight, Edge::bottom, width), colourFrame); } @@ -2340,10 +2340,9 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan const int screenLinePaintFirst = static_cast<int>(rcArea.top) / vsDraw.lineHeight; const int xStart = vsDraw.textStart - model.xOffset + static_cast<int>(ptOrigin.x); - SelectionPosition posCaret = model.sel.RangeMain().caret; - if (model.posDrag.IsValid()) - posCaret = model.posDrag; + const SelectionPosition posCaret = model.posDrag.IsValid() ? model.posDrag : model.sel.RangeMain().caret; const Sci::Line lineCaret = model.pdoc->SciLineFromPosition(posCaret.Position()); + const int caretOffset = static_cast<int>(posCaret.Position() - model.pdoc->LineStart(lineCaret)); PRectangle rcTextArea = rcClient; if (vsDraw.marginInside) { @@ -2410,7 +2409,8 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan durLayout += ep.Duration(true); #endif if (ll) { - ll->containsCaret = !hideSelection && (lineDoc == lineCaret); + ll->containsCaret = !hideSelection && (lineDoc == lineCaret) + && (ll->lines == 1 || !vsDraw.caretLine.subLine || ll->InLine(caretOffset, subLine)); ll->hotspot = model.GetHotSpotRange(); PRectangle rcLine = rcTextArea; diff --git a/src/Editor.cxx b/src/Editor.cxx index b4031c8f1..341165776 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -7325,6 +7325,13 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { InvalidateStyleRedraw(); break; + case Message::GetCaretLineHighlightSubLine: + return vs.caretLine.subLine; + case Message::SetCaretLineHighlightSubLine: + vs.caretLine.subLine = wParam != 0; + InvalidateStyleRedraw(); + break; + case Message::GetCaretLineFrame: return vs.caretLine.frame; case Message::SetCaretLineFrame: diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index 47f76d357..366151cee 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -265,6 +265,7 @@ void ViewStyle::Init(size_t stylesSize_) { elementColours.erase(Element::CaretLineBack); elementAllowsTranslucent.insert(Element::CaretLineBack); caretLine.alwaysShow = false; + caretLine.subLine = false; caretLine.layer = Layer::Base; caretLine.frame = 0; diff --git a/src/ViewStyle.h b/src/ViewStyle.h index 8b9f125bd..66a853848 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -63,6 +63,8 @@ struct CaretLineAppearance { Scintilla::Layer layer; // Also show when non-focused bool alwaysShow; + // highlight sub line instead of whole line + bool subLine; // Non-0: draw a rectangle around line instead of filling line. Value is pixel width of frame int frame; }; |