From cfe3c049555422cbc7dcf3fd2fadad2f08487dd7 Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 29 Sep 2016 13:33:35 +1000 Subject: Margin type SC_MARGIN_COLOUR and API SCI_SETMARGINBACKN added. Allows choosing any colour for a margin. --- doc/ScintillaDoc.html | 12 ++++++++++-- doc/ScintillaHistory.html | 4 ++++ include/Scintilla.h | 3 +++ include/Scintilla.iface | 7 +++++++ src/Editor.cxx | 13 +++++++++++++ src/MarginView.cxx | 3 +++ src/ViewStyle.h | 1 + 7 files changed, 41 insertions(+), 2 deletions(-) diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index b348a68b7..3ebf00919 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -3172,6 +3172,8 @@ struct Sci_TextToFind { cursor)
SCI_GETMARGINCURSORN(int margin)
+ SCI_SETMARGINBACKN(int margin, int colour)
+ SCI_GETMARGINBACKN(int margin)
SCI_SETMARGINLEFT(<unused>, int pixels)
SCI_GETMARGINLEFT
@@ -3201,9 +3203,10 @@ struct Sci_TextToFind { A margin with application defined text may use SC_MARGIN_TEXT (4) or SC_MARGIN_RTEXT (5) to right justify the text. By convention, margin 0 is used for line numbers and the next two are used for symbols. You can - also use the constants SC_MARGIN_BACK (2) and SC_MARGIN_FORE (3) for + also use the constants SC_MARGIN_BACK (2), SC_MARGIN_FORE (3), + and SC_MARGIN_COLOUR (6) for symbol margins that set their background colour to match the STYLE_DEFAULT background and - foreground colours.

+ foreground colours or a specified colour.

SCI_SETMARGINWIDTHN(int margin, int pixelWidth)
SCI_GETMARGINWIDTHN(int margin)
@@ -3259,6 +3262,11 @@ struct Sci_TextToFind { reversed arrow with SCI_SETMARGINCURSORN(margin, SC_CURSORREVERSEARROW).

+

SCI_SETMARGINBACKN(int margin, int colour)
+ SCI_GETMARGINBACKN(int margin)
+ A margin of type SC_MARGIN_COLOUR + may have its colour set with SCI_SETMARGINBACKN.

+

SCI_SETMARGINLEFT(<unused>, int pixels)
SCI_GETMARGINLEFT
SCI_SETMARGINRIGHT(<unused>, int pixels)
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 16cad92ee..96de2872e 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -531,6 +531,10 @@ vertical edges simultaneously.

  • + Margin type SC_MARGIN_COLOUR added so that the application may + choose any colour for a margin with SCI_SETMARGINBACKN. +
  • +
  • On Win32, mouse wheel scrolling can be restricted to only occur when the mouse is within the window.
  • diff --git a/include/Scintilla.h b/include/Scintilla.h index 2d6b06b22..77f4d5c7a 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -167,6 +167,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_MARGIN_FORE 3 #define SC_MARGIN_TEXT 4 #define SC_MARGIN_RTEXT 5 +#define SC_MARGIN_COLOUR 6 #define SCI_SETMARGINTYPEN 2240 #define SCI_GETMARGINTYPEN 2241 #define SCI_SETMARGINWIDTHN 2242 @@ -177,6 +178,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETMARGINSENSITIVEN 2247 #define SCI_SETMARGINCURSORN 2248 #define SCI_GETMARGINCURSORN 2249 +#define SCI_SETMARGINBACKN 2250 +#define SCI_GETMARGINBACKN 2251 #define STYLE_DEFAULT 32 #define STYLE_LINENUMBER 33 #define STYLE_BRACELIGHT 34 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index bee9aeef8..fdc90807e 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -360,6 +360,7 @@ val SC_MARGIN_BACK=2 val SC_MARGIN_FORE=3 val SC_MARGIN_TEXT=4 val SC_MARGIN_RTEXT=5 +val SC_MARGIN_COLOUR=6 # Set a margin to be either numeric or symbolic. set void SetMarginTypeN=2240(int margin, int marginType) @@ -391,6 +392,12 @@ set void SetMarginCursorN=2248(int margin, int cursor) # Retrieve the cursor shown in a margin. get int GetMarginCursorN=2249(int margin,) +# Set the background colour of a margin. Only visible for SC_MARGIN_COLOUR. +set void SetMarginBackN=2250(int margin, colour back) + +# Retrieve the background colour of a margin +get colour GetMarginBackN=2251(int margin,) + # Styles in range 32..38 are predefined for parts of the UI and are not used as normal styles. # Style 39 is for future use. enu StylesCommon=STYLE_ diff --git a/src/Editor.cxx b/src/Editor.cxx index ee4d3947f..0e686e101 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -6884,6 +6884,19 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { else return 0; + case SCI_SETMARGINBACKN: + if (ValidMargin(wParam)) { + vs.ms[wParam].back = ColourDesired(static_cast(lParam)); + InvalidateStyleRedraw(); + } + break; + + case SCI_GETMARGINBACKN: + if (ValidMargin(wParam)) + return vs.ms[wParam].back.AsLong(); + else + return 0; + case SCI_STYLECLEARALL: vs.ClearStyles(); InvalidateStyleRedraw(); diff --git a/src/MarginView.cxx b/src/MarginView.cxx index 52a2cb2dd..ab8cbf4f8 100644 --- a/src/MarginView.cxx +++ b/src/MarginView.cxx @@ -216,6 +216,9 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect case SC_MARGIN_FORE: colour = vs.styles[STYLE_DEFAULT].fore; break; + case SC_MARGIN_COLOUR: + colour = vs.ms[margin].back; + break; default: colour = vs.styles[STYLE_LINENUMBER].back; break; diff --git a/src/ViewStyle.h b/src/ViewStyle.h index be84598f1..7a2c26f63 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -17,6 +17,7 @@ namespace Scintilla { class MarginStyle { public: int style; + ColourDesired back; int width; int mask; bool sensitive; -- cgit v1.2.3