diff options
author | nyamatongwe <unknown> | 2001-03-31 10:35:47 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2001-03-31 10:35:47 +0000 |
commit | 53cbfcdfafd9d6993f0d0bb2eef55d5ca21bd60e (patch) | |
tree | f2922d4c74654d2ae7a23954a923d03b696bafbc /src | |
parent | 939b30d442e44a8ceced6e5d847218e109a4962c (diff) | |
download | scintilla-mirror-53cbfcdfafd9d6993f0d0bb2eef55d5ca21bd60e.tar.gz |
Added caret line feature.
Diffstat (limited to 'src')
-rw-r--r-- | src/Editor.cxx | 45 | ||||
-rw-r--r-- | src/Editor.h | 1 | ||||
-rw-r--r-- | src/ViewStyle.cxx | 6 | ||||
-rw-r--r-- | src/ViewStyle.h | 2 |
4 files changed, 41 insertions, 13 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index 738f25c05..afc127c07 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -876,19 +876,23 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis // is taken by an individual character - internal leading gives varying results. Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; - int marks = 0; - Colour markBack = Colour(0, 0, 0); + bool overrideBackground = false; + Colour background = Colour(0, 0, 0); + if (vsDraw.showCaretLineBackground && ll.containsCaret) { + overrideBackground = true; + background = vsDraw.caretLineBackground.allocated; + } if (vsDraw.maskInLine) { - marks = pdoc->GetMark(line) & vsDraw.maskInLine; + int marks = pdoc->GetMark(line) & vsDraw.maskInLine; if (marks) { + overrideBackground = true; for (int markBit = 0; (markBit < 32) && marks; markBit++) { if (marks & 1) { - markBack = vsDraw.markers[markBit].back.allocated; + background = vsDraw.markers[markBit].back.allocated; } marks >>= 1; } } - marks = pdoc->GetMark(line) & vsDraw.maskInLine; } bool inIndentation = true; @@ -924,8 +928,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis if (vsDraw.selforeset) textFore = vsDraw.selforeground.allocated; } else { - if (marks) - textBack = markBack; + if (overrideBackground) + textBack = background; if ((vsDraw.edgeState == EDGE_BACKGROUND) && (i >= ll.edgeColumn) && (ll.chars[i] != '\n') && (ll.chars[i] != '\r')) textBack = vsDraw.edgecolour.allocated; } @@ -1064,16 +1068,16 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis surface->FillRectangle(rcSegment, vsDraw.selbackground.allocated); else surface->FillRectangle(rcSegment, vsDraw.selbackground2.allocated); - } else if (marks) { - surface->FillRectangle(rcSegment, markBack); + } else if (overrideBackground) { + surface->FillRectangle(rcSegment, background); } else { surface->FillRectangle(rcSegment, vsDraw.styles[ll.styles[ll.numCharsInLine] & styleMask].back.allocated); } rcSegment.left = xEol + vsDraw.aveCharWidth + xStart; rcSegment.right = rcLine.right; - if (marks) { - surface->FillRectangle(rcSegment, markBack); + if (overrideBackground) { + surface->FillRectangle(rcSegment, background); } else if (vsDraw.styles[ll.styles[ll.numCharsInLine] & styleMask].eolFilled) { surface->FillRectangle(rcSegment, vsDraw.styles[ll.styles[ll.numCharsInLine] & styleMask].back.allocated); } else { @@ -1223,9 +1227,11 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { ll.selStart = SelectionStart(line); ll.selEnd = SelectionEnd(line); + ll.containsCaret = line == lineCaret; if (hideSelection) { ll.selStart = -1; ll.selEnd = -1; + ll.containsCaret = false; } // Need to fix this up so takes account of Unicode and DBCS ll.edgeColumn = theEdge; @@ -1400,7 +1406,8 @@ long Editor::FormatRange(bool draw, RangeToFormat *pfr) { // Don't show the selection when printing vsPrint.selbackset = false; vsPrint.selforeset = false; - + vsPrint.showCaretLineBackground = false; + // Set colours for printing according to users settings for (int sty = 0;sty <= STYLE_MAX;sty++) { if (printColourMode == SC_PRINT_INVERTLIGHT) { @@ -1469,6 +1476,7 @@ long Editor::FormatRange(bool draw, RangeToFormat *pfr) { LayoutLine(line, surfaceMeasure, vsPrint, ll); ll.selStart = -1; ll.selEnd = -1; + ll.containsCaret = false; // Need to fix this up so takes account of Unicode and DBCS ll.edgeColumn = theEdge; @@ -4183,6 +4191,19 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETMAXLINESTATE: return pdoc->GetMaxLineState(); + case SCI_GETCARETLINEVISIBLE: + return vs.showCaretLineBackground; + case SCI_SETCARETLINEVISIBLE: + vs.showCaretLineBackground = wParam; + InvalidateStyleRedraw(); + break; + case SCI_GETCARETLINEBACK: + return vs.caretLineBackground.desired.AsLong(); + case SCI_SETCARETLINEBACK: + vs.caretLineBackground.desired = wParam; + InvalidateStyleRedraw(); + break; + // Folding messages case SCI_VISIBLEFROMDOCLINE: diff --git a/src/Editor.h b/src/Editor.h index 73d15e340..cf3996ffa 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -42,6 +42,7 @@ public: bool highlightColumn; int selStart; int selEnd; + bool containsCaret; int edgeColumn; char chars[maxLineLength+1]; char styles[maxLineLength+1]; diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index c3d6b5008..9d19c418e 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -75,6 +75,8 @@ ViewStyle::ViewStyle(const ViewStyle &source) { selbar.desired = source.selbar.desired; selbarlight.desired = source.selbarlight.desired; caretcolour.desired = source.caretcolour.desired; + showCaretLineBackground = source.showCaretLineBackground; + caretLineBackground.desired = source.caretLineBackground.desired; edgecolour.desired = source.edgecolour.desired; edgeState = source.edgeState; caretWidth = source.caretWidth; @@ -122,8 +124,9 @@ void ViewStyle::Init() { selbarlight.desired = Platform::ChromeHighlight(); styles[STYLE_LINENUMBER].fore.desired = Colour(0, 0, 0); styles[STYLE_LINENUMBER].back.desired = Platform::Chrome(); - //caretcolour.desired = Colour(0xff, 0, 0); caretcolour.desired = Colour(0, 0, 0); + showCaretLineBackground = false; + caretLineBackground.desired = Colour(0xff, 0xff, 0); edgecolour.desired = Colour(0xc0, 0xc0, 0xc0); edgeState = EDGE_NONE; caretWidth = 1; @@ -176,6 +179,7 @@ void ViewStyle::RefreshColourPalette(Palette &pal, bool want) { pal.WantFind(selbar, want); pal.WantFind(selbarlight, want); pal.WantFind(caretcolour, want); + pal.WantFind(caretLineBackground, want); pal.WantFind(edgecolour, want); } diff --git a/src/ViewStyle.h b/src/ViewStyle.h index 63f2940c4..7528638c5 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -69,6 +69,8 @@ public: bool viewEOL; bool showMarkedLines; ColourPair caretcolour; + bool showCaretLineBackground; + ColourPair caretLineBackground; ColourPair edgecolour; int edgeState; int caretWidth; |