diff options
-rw-r--r-- | doc/ScintillaDoc.html | 9 | ||||
-rw-r--r-- | include/Scintilla.h | 2 | ||||
-rw-r--r-- | include/Scintilla.iface | 2 | ||||
-rw-r--r-- | src/Editor.cxx | 33 | ||||
-rw-r--r-- | src/ViewStyle.cxx | 12 | ||||
-rw-r--r-- | src/ViewStyle.h | 2 |
6 files changed, 40 insertions, 20 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 8f73a0705..a3fc400fa 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -2272,7 +2272,10 @@ struct TextToFind { These two routines set and get the type of a margin. The margin argument should be 0, 1, 2, 3 or 4. You can use the predefined constants <code>SC_MARGIN_SYMBOL</code> (0) and <code>SC_MARGIN_NUMBER</code> (1) to set a margin as either a line number or a symbol margin. - By convention, margin 0 is used for line numbers and the next two are used for symbols.</p> + By convention, margin 0 is used for line numbers and the next two are used for symbols. You can + also use the constants <code>SC_MARGIN_BACK</code> (2) and <code>SC_MARGIN_FORE</code> (3) for + symbol margins that set their background colour to match the STYLE_DEFAULT background and + foreground colours.</p> <p><b id="SCI_SETMARGINWIDTHN">SCI_SETMARGINWIDTHN(int margin, int pixelWidth)</b><br /> <b id="SCI_GETMARGINWIDTHN">SCI_GETMARGINWIDTHN(int margin)</b><br /> @@ -2405,8 +2408,8 @@ struct TextToFind { <code>codePage</code> set to the code page number to set Scintilla to use code page information to ensure double byte characters are treated as one character rather than two. This also stops the caret from moving between the two bytes in a double byte character. - Do not use this message to choose between different single byte character sets: it doesn't do that. - Call with + Do not use this message to choose between different single byte character sets: it doesn't do that. + Call with <code>codePage</code> set to zero to disable DBCS support. The default is <code>SCI_SETCODEPAGE(0)</code>.</p> diff --git a/include/Scintilla.h b/include/Scintilla.h index 5d2adb218..426c8d4e6 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -141,6 +141,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_MARKERSETALPHA 2476 #define SC_MARGIN_SYMBOL 0 #define SC_MARGIN_NUMBER 1 +#define SC_MARGIN_BACK 2 +#define SC_MARGIN_FORE 3 #define SCI_SETMARGINTYPEN 2240 #define SCI_GETMARGINTYPEN 2241 #define SCI_SETMARGINWIDTHN 2242 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 9a0795f72..c3e5b56fe 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -322,6 +322,8 @@ fun void MarkerSetAlpha=2476(int markerNumber, int alpha) enu MarginType=SC_MARGIN_ val SC_MARGIN_SYMBOL=0 val SC_MARGIN_NUMBER=1 +val SC_MARGIN_BACK=2 +val SC_MARGIN_FORE=3 # Set a margin to be either numeric or symbolic. set void SetMarginTypeN=2240(int margin, int marginType) diff --git a/src/Editor.cxx b/src/Editor.cxx index 66d1b6a35..33479e6ba 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -1721,7 +1721,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { rcSelMargin.left = rcSelMargin.right; rcSelMargin.right = rcSelMargin.left + vs.ms[margin].width; - if (vs.ms[margin].symbol) { + if (vs.ms[margin].style != SC_MARGIN_NUMBER) { /* alternate scheme: if (vs.ms[margin].mask & SC_MASK_FOLDERS) surface->FillRectangle(rcSelMargin, vs.styles[STYLE_DEFAULT].back.allocated); @@ -1732,8 +1732,21 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { if (vs.ms[margin].mask & SC_MASK_FOLDERS) // Required because of special way brush is created for selection margin surface->FillRectangle(rcSelMargin, *pixmapSelPattern); - else - surface->FillRectangle(rcSelMargin, vs.styles[STYLE_LINENUMBER].back.allocated); + else { + ColourAllocated colour; + switch (vs.ms[margin].style) { + case SC_MARGIN_BACK: + colour = vs.styles[STYLE_DEFAULT].back.allocated; + break; + case SC_MARGIN_FORE: + colour = vs.styles[STYLE_DEFAULT].fore.allocated; + break; + default: + colour = vs.styles[STYLE_LINENUMBER].back.allocated; + break; + } + surface->FillRectangle(rcSelMargin, colour); + } } else { surface->FillRectangle(rcSelMargin, vs.styles[STYLE_LINENUMBER].back.allocated); } @@ -1840,7 +1853,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { PRectangle rcMarker = rcSelMargin; rcMarker.top = yposScreen; rcMarker.bottom = yposScreen + vs.lineHeight; - if (!vs.ms[margin].symbol) { + if (vs.ms[margin].style == SC_MARGIN_NUMBER) { char number[100]; number[0] = '\0'; if (firstSubLine) @@ -2131,7 +2144,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou continue; } if (p > 0) { - if (wrapState == eWrapChar){ + if (wrapState == eWrapChar) { lastGoodBreak = pdoc->MovePositionOutsideChar(p + posLineStart, -1) - posLineStart; p = pdoc->MovePositionOutsideChar(p + 1 + posLineStart, 1) - posLineStart; @@ -2210,7 +2223,7 @@ void Editor::DrawWrapMarker(Surface *surface, PRectangle rcPlace, surface->LineTo(xBase + xDir * xRelative, yBase + yDir * yRelative); } }; - Relative rel = {surface, x0, xStraight?1:-1, y0, yStraight?1:-1}; + Relative rel = {surface, x0, xStraight ? 1 : -1, y0, yStraight ? 1 : -1}; // arrow head rel.MoveTo(xa, y); @@ -3114,7 +3127,7 @@ long Editor::FormatRange(bool draw, RangeToFormat *pfr) { // Printing supports only the line number margin. int lineNumberIndex = -1; for (int margin = 0; margin < ViewStyle::margins; margin++) { - if ((!vsPrint.ms[margin].symbol) && (vsPrint.ms[margin].width > 0)) { + if ((vsPrint.ms[margin].style == SC_MARGIN_NUMBER) && (vsPrint.ms[margin].width > 0)) { lineNumberIndex = margin; } else { vsPrint.ms[margin].width = 0; @@ -6357,7 +6370,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return pdoc->ExtendWordSelect(wParam, 1, lParam != 0); case SCI_SETWRAPMODE: - switch(wParam){ + switch (wParam) { case SC_WRAP_WORD: wrapState = eWrapWord; break; @@ -6603,14 +6616,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETMARGINTYPEN: if (ValidMargin(wParam)) { - vs.ms[wParam].symbol = (lParam == SC_MARGIN_SYMBOL); + vs.ms[wParam].style = lParam; InvalidateStyleRedraw(); } break; case SCI_GETMARGINTYPEN: if (ValidMargin(wParam)) - return vs.ms[wParam].symbol ? SC_MARGIN_SYMBOL : SC_MARGIN_NUMBER; + return vs.ms[wParam].style; else return 0; diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index 3de85c6be..b4da30ace 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -17,7 +17,7 @@ #include "ViewStyle.h" MarginStyle::MarginStyle() : - symbol(false), width(0), mask(0), sensitive(false) { + style(SC_MARGIN_SYMBOL), width(0), mask(0), sensitive(false) { } // A list of the fontnames - avoids wasting space in each style @@ -175,13 +175,13 @@ void ViewStyle::Init() { leftMarginWidth = 1; rightMarginWidth = 1; - ms[0].symbol = false; + ms[0].style = SC_MARGIN_NUMBER; ms[0].width = 0; ms[0].mask = 0; - ms[1].symbol = true; + ms[1].style = SC_MARGIN_SYMBOL; ms[1].width = 16; ms[1].mask = ~SC_MASK_FOLDERS; - ms[2].symbol = true; + ms[2].style = SC_MARGIN_SYMBOL; ms[2].width = 0; ms[2].mask = 0; fixedColumnWidth = leftMarginWidth; @@ -189,7 +189,7 @@ void ViewStyle::Init() { maskInLine = 0xffffffff; for (int margin=0; margin < margins; margin++) { fixedColumnWidth += ms[margin].width; - symbolMargin = symbolMargin || ms[margin].symbol; + symbolMargin = symbolMargin || (ms[margin].style != SC_MARGIN_NUMBER); if (ms[margin].width > 0) maskInLine &= ~ms[margin].mask; } @@ -260,7 +260,7 @@ void ViewStyle::Refresh(Surface &surface) { maskInLine = 0xffffffff; for (int margin=0; margin < margins; margin++) { fixedColumnWidth += ms[margin].width; - symbolMargin = symbolMargin || ms[margin].symbol; + symbolMargin = symbolMargin || (ms[margin].style != SC_MARGIN_NUMBER); if (ms[margin].width > 0) maskInLine &= ~ms[margin].mask; } diff --git a/src/ViewStyle.h b/src/ViewStyle.h index 892fdc59d..75f899d97 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -12,7 +12,7 @@ */ class MarginStyle { public: - bool symbol; + int style; int width; int mask; bool sensitive; |