diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/EditView.cxx | 4 | ||||
-rw-r--r-- | src/Editor.cxx | 18 | ||||
-rw-r--r-- | src/Editor.h | 1 | ||||
-rw-r--r-- | src/MarginView.cxx | 2 | ||||
-rw-r--r-- | src/ViewStyle.cxx | 7 | ||||
-rw-r--r-- | src/ViewStyle.h | 2 |
6 files changed, 21 insertions, 13 deletions
diff --git a/src/EditView.cxx b/src/EditView.cxx index 074c23fc9..92c341d8f 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -1982,9 +1982,9 @@ long EditView::FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface, // 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 <= SC_MAX_MARGIN; margin++) { + for (size_t margin = 0; margin < vs.ms.size(); margin++) { if ((vsPrint.ms[margin].style == SC_MARGIN_NUMBER) && (vsPrint.ms[margin].width > 0)) { - lineNumberIndex = margin; + lineNumberIndex = static_cast<int>(margin); } else { vsPrint.ms[margin].width = 0; } diff --git a/src/Editor.cxx b/src/Editor.cxx index 0e686e101..9fcd01fbb 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -2426,9 +2426,9 @@ void Editor::NotifyIndicatorClick(bool click, int position, bool shift, bool ctr bool Editor::NotifyMarginClick(Point pt, int modifiers) { int marginClicked = -1; int x = vs.textStart - vs.fixedColumnWidth; - for (int margin = 0; margin <= SC_MAX_MARGIN; margin++) { + for (size_t margin = 0; margin < vs.ms.size(); margin++) { if ((pt.x >= x) && (pt.x < x + vs.ms[margin].width)) - marginClicked = margin; + marginClicked = static_cast<int>(margin); x += vs.ms[margin].width; } if ((marginClicked >= 0) && vs.ms[marginClicked].sensitive) { @@ -4289,7 +4289,7 @@ bool Editor::PointInSelMargin(Point pt) const { Window::Cursor Editor::GetMarginCursor(Point pt) const { int x = 0; - for (int margin = 0; margin <= SC_MAX_MARGIN; margin++) { + for (size_t margin = 0; margin < vs.ms.size(); 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; @@ -5569,8 +5569,8 @@ void Editor::AddStyledText(char *buffer, int appendLength) { SetEmptySelection(sel.MainCaret() + lengthInserted); } -static bool ValidMargin(uptr_t wParam) { - return wParam <= SC_MAX_MARGIN; +bool Editor::ValidMargin(uptr_t wParam) { + return wParam < vs.ms.size(); } static char *CharPtrFromSPtr(sptr_t lParam) { @@ -6897,6 +6897,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { else return 0; + case SCI_SETMARGINS: + if (wParam < 1000) + vs.ms.resize(wParam); + break; + + case SCI_GETMARGINS: + return vs.ms.size(); + case SCI_STYLECLEARALL: vs.ClearStyles(); InvalidateStyleRedraw(); diff --git a/src/Editor.h b/src/Editor.h index ee56700dd..5fdcbffb9 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -571,6 +571,7 @@ protected: // ScintillaBase subclass needs access to much of Editor void AddStyledText(char *buffer, int appendLength); virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0; + bool ValidMargin(uptr_t wParam); void StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam); sptr_t StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam); diff --git a/src/MarginView.cxx b/src/MarginView.cxx index ab8cbf4f8..3ec70f01e 100644 --- a/src/MarginView.cxx +++ b/src/MarginView.cxx @@ -193,7 +193,7 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect Point ptOrigin = model.GetVisibleOriginInMain(); FontAlias fontLineNumber = vs.styles[STYLE_LINENUMBER].font; - for (int margin = 0; margin <= SC_MAX_MARGIN; margin++) { + for (size_t margin = 0; margin < vs.ms.size(); margin++) { if (vs.ms[margin].width > 0) { rcSelMargin.left = rcSelMargin.right; diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index 33be28422..58dbf167b 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -145,9 +145,7 @@ ViewStyle::ViewStyle(const ViewStyle &source) { someStylesForceCase = false; leftMarginWidth = source.leftMarginWidth; rightMarginWidth = source.rightMarginWidth; - for (int margin=0; margin <= SC_MAX_MARGIN; margin++) { - ms[margin] = source.ms[margin]; - } + ms = source.ms; maskInLine = source.maskInLine; maskDrawInText = source.maskDrawInText; fixedColumnWidth = source.fixedColumnWidth; @@ -196,7 +194,7 @@ void ViewStyle::CalculateMarginWidthAndMask() { fixedColumnWidth = marginInside ? leftMarginWidth : 0; maskInLine = 0xffffffff; int maskDefinedMarkers = 0; - for (int margin = 0; margin <= SC_MAX_MARGIN; margin++) { + for (size_t margin = 0; margin < ms.size(); margin++) { fixedColumnWidth += ms[margin].width; if (ms[margin].width > 0) maskInLine &= ~ms[margin].mask; @@ -280,6 +278,7 @@ void ViewStyle::Init(size_t stylesSize_) { leftMarginWidth = 1; rightMarginWidth = 1; + ms.resize(SC_MAX_MARGIN + 1); ms[0].style = SC_MARGIN_NUMBER; ms[0].width = 0; ms[0].mask = 0; diff --git a/src/ViewStyle.h b/src/ViewStyle.h index 7a2c26f63..3b812693e 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -127,7 +127,7 @@ public: 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 int maskDrawInText; ///< Mask for markers that always draw in text - MarginStyle ms[SC_MAX_MARGIN+1]; + std::vector<MarginStyle> ms; int fixedColumnWidth; ///< Total width of margins bool marginInside; ///< true: margin included in text view, false: separate views int textStart; ///< Starting x position of text within the view |