aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/ScintillaDoc.html3
-rw-r--r--include/Scintilla.h1
-rw-r--r--include/Scintilla.iface2
-rw-r--r--src/Editor.cxx10
-rw-r--r--src/ViewStyle.cxx8
-rw-r--r--src/ViewStyle.h3
6 files changed, 15 insertions, 12 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index 8d429f95e..290ab474a 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -2814,7 +2814,8 @@ struct Sci_TextToFind {
<h2 id="Margins">Margins</h2>
- <p>There may be up to five margins to the left of the text display, plus a gap either side of
+ <p>There may be up to five margins, numbered 0 to <code>SC_MAX_MARGIN</code> (4)
+ to the left of the text display, plus a gap either side of
the text. Each margin can be set to display only symbols, line numbers, or text with <a
class="message" href="#SCI_SETMARGINTYPEN"><code>SCI_SETMARGINTYPEN</code></a>.
Textual margins may also display symbols.
diff --git a/include/Scintilla.h b/include/Scintilla.h
index 717a6895f..15a86682e 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -148,6 +148,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_MARKERDEFINEPIXMAP 2049
#define SCI_MARKERADDSET 2466
#define SCI_MARKERSETALPHA 2476
+#define SC_MAX_MARGIN 4
#define SC_MARGIN_SYMBOL 0
#define SC_MARGIN_NUMBER 1
#define SC_MARGIN_BACK 2
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index f66324572..cb6c0e632 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -326,6 +326,8 @@ fun void MarkerAddSet=2466(int line, int set)
# Set the alpha used for a marker that is drawn in the text area, not the margin.
set void MarkerSetAlpha=2476(int markerNumber, int alpha)
+val SC_MAX_MARGIN=4
+
enu MarginType=SC_MARGIN_
val SC_MARGIN_SYMBOL=0
val SC_MARGIN_NUMBER=1
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 0c1336aa0..e5c997cf4 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -1775,7 +1775,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
PRectangle rcSelMargin = rcMargin;
rcSelMargin.right = rcMargin.left;
- for (int margin = 0; margin < vs.margins; margin++) {
+ for (int margin = 0; margin <= SC_MAX_MARGIN; margin++) {
if (vs.ms[margin].width > 0) {
rcSelMargin.left = rcSelMargin.right;
@@ -3727,7 +3727,7 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) {
// Modify the view style for printing as do not normally want any of the transient features to be printed
// Printing supports only the line number margin.
int lineNumberIndex = -1;
- for (int margin = 0; margin < ViewStyle::margins; margin++) {
+ for (int margin = 0; margin <= SC_MAX_MARGIN; margin++) {
if ((vsPrint.ms[margin].style == SC_MARGIN_NUMBER) && (vsPrint.ms[margin].width > 0)) {
lineNumberIndex = margin;
} else {
@@ -4455,7 +4455,7 @@ void Editor::NotifyIndicatorClick(bool click, int position, bool shift, bool ctr
bool Editor::NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt) {
int marginClicked = -1;
int x = 0;
- for (int margin = 0; margin < ViewStyle::margins; margin++) {
+ for (int margin = 0; margin <= SC_MAX_MARGIN; margin++) {
if ((pt.x >= x) && (pt.x < x + vs.ms[margin].width))
marginClicked = margin;
x += vs.ms[margin].width;
@@ -6122,7 +6122,7 @@ bool Editor::PointInSelMargin(Point pt) {
Window::Cursor Editor::GetMarginCursor(Point pt) {
int x = 0;
- for (int margin = 0; margin < ViewStyle::margins; margin++) {
+ for (int margin = 0; margin <= SC_MAX_MARGIN; margin++) {
if ((pt.x >= x) && (pt.x < x + vs.ms[margin].width))
return static_cast<Window::Cursor>(vs.ms[margin].cursor);
x += vs.ms[margin].width;
@@ -7056,7 +7056,7 @@ void Editor::AddStyledText(char *buffer, int appendLength) {
}
static bool ValidMargin(unsigned long wParam) {
- return wParam < ViewStyle::margins;
+ return wParam <= SC_MAX_MARGIN;
}
static char *CharPtrFromSPtr(sptr_t lParam) {
diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx
index b9284c05e..f316d264e 100644
--- a/src/ViewStyle.cxx
+++ b/src/ViewStyle.cxx
@@ -193,8 +193,8 @@ ViewStyle::ViewStyle(const ViewStyle &source) {
someStylesForceCase = false;
leftMarginWidth = source.leftMarginWidth;
rightMarginWidth = source.rightMarginWidth;
- for (int i=0; i < margins; i++) {
- ms[i] = source.ms[i];
+ for (int margin=0; margin <= SC_MAX_MARGIN; margin++) {
+ ms[margin] = source.ms[margin];
}
maskInLine = source.maskInLine;
fixedColumnWidth = source.fixedColumnWidth;
@@ -308,7 +308,7 @@ void ViewStyle::Init(size_t stylesSize_) {
ms[2].mask = 0;
fixedColumnWidth = leftMarginWidth;
maskInLine = 0xffffffff;
- for (int margin=0; margin < margins; margin++) {
+ for (int margin=0; margin <= SC_MAX_MARGIN; margin++) {
fixedColumnWidth += ms[margin].width;
if (ms[margin].width > 0)
maskInLine &= ~ms[margin].mask;
@@ -389,7 +389,7 @@ void ViewStyle::Refresh(Surface &surface) {
fixedColumnWidth = leftMarginWidth;
maskInLine = 0xffffffff;
- for (int margin=0; margin < margins; margin++) {
+ for (int margin=0; margin <= SC_MAX_MARGIN; margin++) {
fixedColumnWidth += ms[margin].width;
if (ms[margin].width > 0)
maskInLine &= ~ms[margin].mask;
diff --git a/src/ViewStyle.h b/src/ViewStyle.h
index 5a623986b..ddcc64312 100644
--- a/src/ViewStyle.h
+++ b/src/ViewStyle.h
@@ -104,11 +104,10 @@ public:
bool hotspotUnderline;
bool hotspotSingleLine;
/// Margins are ordered: Line Numbers, Selection Margin, Spacing Margin
- enum { margins=5 };
int leftMarginWidth; ///< Spacing margin on left of text
int rightMarginWidth; ///< Spacing margin on right of text
int maskInLine; ///< Mask for markers to be put into text because there is nowhere for them to go in margin
- MarginStyle ms[margins];
+ MarginStyle ms[SC_MAX_MARGIN+1];
int fixedColumnWidth;
int zoomLevel;
WhiteSpaceVisibility viewWhitespace;