diff options
author | Neil <nyamatongwe@gmail.com> | 2016-10-26 08:27:35 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2016-10-26 08:27:35 +1100 |
commit | 7ee60fc25a08dac31ccdfb77068aae852860cc37 (patch) | |
tree | aade0daf566683251555bed0cc5af545664e92c0 | |
parent | acb772397633f7c46d31b12f96321a2a2f26d80b (diff) | |
download | scintilla-mirror-7ee60fc25a08dac31ccdfb77068aae852860cc37.tar.gz |
Moved location to margin code from Editor to ViewStyle.
-rw-r--r-- | src/Editor.cxx | 8 | ||||
-rw-r--r-- | src/ViewStyle.cxx | 11 | ||||
-rw-r--r-- | src/ViewStyle.h | 1 |
3 files changed, 13 insertions, 7 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index f721c4361..62bc60a09 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -2424,13 +2424,7 @@ 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 (size_t margin = 0; margin < vs.ms.size(); margin++) { - if ((pt.x >= x) && (pt.x < x + vs.ms[margin].width)) - marginClicked = static_cast<int>(margin); - x += vs.ms[margin].width; - } + const int marginClicked = vs.MarginFromLocation(pt); if ((marginClicked >= 0) && vs.ms[marginClicked].sensitive) { int position = pdoc->LineStart(LineFromLocation(pt)); if ((vs.ms[marginClicked].mask & SC_MASK_FOLDERS) && (foldAutomatic & SC_AUTOMATICFOLD_CLICK)) { diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index 58dbf167b..e12620c96 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -445,6 +445,17 @@ int ViewStyle::ExternalMarginWidth() const { return marginInside ? 0 : fixedColumnWidth; } +int ViewStyle::MarginFromLocation(Point pt) const { + int margin = -1; + int x = textStart - fixedColumnWidth; + for (size_t i = 0; i < ms.size(); i++) { + if ((pt.x >= x) && (pt.x < x + ms[i].width)) + margin = static_cast<int>(i); + x += ms[i].width; + } + return margin; +} + bool ViewStyle::ValidStyle(size_t styleIndex) const { return styleIndex < styles.size(); } diff --git a/src/ViewStyle.h b/src/ViewStyle.h index 3b812693e..82c176c87 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -184,6 +184,7 @@ public: void SetStyleFontName(int styleIndex, const char *name); bool ProtectionActive() const; int ExternalMarginWidth() const; + int MarginFromLocation(Point pt) const; bool ValidStyle(size_t styleIndex) const; void CalcLargestMarkerHeight(); ColourOptional Background(int marksOfLine, bool caretActive, bool lineContainsCaret) const; |