diff options
-rw-r--r-- | include/Scintilla.h | 1 | ||||
-rw-r--r-- | include/Scintilla.iface | 3 | ||||
-rw-r--r-- | src/Document.cxx | 10 | ||||
-rw-r--r-- | src/Document.h | 2 | ||||
-rw-r--r-- | src/Editor.cxx | 19 | ||||
-rw-r--r-- | src/ViewStyle.cxx | 2 | ||||
-rw-r--r-- | src/ViewStyle.h | 1 |
7 files changed, 28 insertions, 10 deletions
diff --git a/include/Scintilla.h b/include/Scintilla.h index 85d592c9d..d1ec2fb53 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -534,6 +534,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETHOTSPOTACTIVEFORE 2410 #define SCI_SETHOTSPOTACTIVEBACK 2411 #define SCI_SETHOTSPOTACTIVEUNDERLINE 2412 +#define SCI_SETHOTSPOTSINGLELINE 2421 #define SCI_PARADOWN 2413 #define SCI_PARADOWNEXTEND 2414 #define SCI_PARAUP 2415 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index e2424b78f..38c979d13 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -1440,6 +1440,9 @@ set void SetHotspotActiveBack=2411(bool useSetting, colour back) # Enable / Disable underlining active hotspots. set void SetHotspotActiveUnderline=2412(bool underline,) +# Limit hotspots to single line so hotspots on two lines don't merge. +set void SetHotspotSingleLine=2421(bool singleLine,) + # Move caret between paragraphs (delimited by empty lines) fun void ParaDown=2413(,) fun void ParaDownExtend=2414(,) diff --git a/src/Document.cxx b/src/Document.cxx index 3f14335c0..7f4893711 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -1335,14 +1335,18 @@ int Document::WordPartRight(int pos) { return pos; } -int Document::ExtendStyleRange(int pos, int delta) { +bool IsLineEndChar(char c) { + return (c == '\n' || c == '\r'); +} + +int Document::ExtendStyleRange(int pos, int delta, bool singleLine) { int sStart = cb.StyleAt(pos); if (delta < 0) { - while (pos > 0 && (cb.StyleAt(pos) == sStart)) + while (pos > 0 && (cb.StyleAt(pos) == sStart) && (!singleLine || !IsLineEndChar(cb.CharAt(pos))) ) pos--; pos++; } else { - while (pos < (Length()) && (cb.StyleAt(pos) == sStart)) + while (pos < (Length()) && (cb.StyleAt(pos) == sStart) && (!singleLine || !IsLineEndChar(cb.CharAt(pos))) ) pos++; } return pos; diff --git a/src/Document.h b/src/Document.h index bcdbe00ca..4b44655f3 100644 --- a/src/Document.h +++ b/src/Document.h @@ -220,7 +220,7 @@ public: bool IsWordPartSeparator(char ch); int WordPartLeft(int pos); int WordPartRight(int pos); - int ExtendStyleRange(int pos, int delta); + int ExtendStyleRange(int pos, int delta, bool singleLine = false); int ParaUp(int pos); int ParaDown(int pos); diff --git a/src/Editor.cxx b/src/Editor.cxx index c764344b7..56acd900c 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -1963,7 +1963,7 @@ ColourAllocated Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackgroun (i >= ll->edgeColumn) && !IsEOLChar(ll->chars[i])) return vsDraw.edgecolour.allocated; - if (inHotspot) + if (inHotspot && vsDraw.hotspotBackgroundSet) return vsDraw.hotspotBackground.allocated; if (overrideBackground) return background; @@ -4567,7 +4567,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b //Platform::DebugPrintf("Double click: %d - %d\n", anchor, currentPos); if (doubleClick) { NotifyDoubleClick(pt, shift); - if (PositionIsHotspot(newPos)) + if (PointIsHotspot(newPos)) NotifyHotSpotDoubleClicked(newPos, shift, ctrl, alt); } } else { // Single click @@ -4599,7 +4599,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b SetMouseCapture(true); selectionType = selLine; } else { - if (PositionIsHotspot(newPos)) { + if (PointIsHotspot(pt)) { NotifyHotSpotClicked(newPos, shift, ctrl, alt); } if (!shift) { @@ -4633,7 +4633,9 @@ bool Editor::PositionIsHotspot(int position) { } bool Editor::PointIsHotspot(Point pt) { - int pos = PositionFromLocation(pt); + int pos = PositionFromLocationClose(pt); + if(pos == INVALID_POSITION) + return false; return PositionIsHotspot(pos); } @@ -4644,8 +4646,8 @@ void Editor::SetHotSpotRange(Point *pt) { // If we don't limit this to word characters then the // range can encompass more than the run range and then // the underline will not be drawn properly. - int hsStart_ = pdoc->ExtendStyleRange(pos, -1); - int hsEnd_ = pdoc->ExtendStyleRange(pos, 1); + int hsStart_ = pdoc->ExtendStyleRange(pos, -1, vs.hotspotSingleLine); + int hsEnd_ = pdoc->ExtendStyleRange(pos, 1, vs.hotspotSingleLine); // Only invalidate the range if the hotspot range has changed... if (hsStart_ != hsStart || hsEnd_ != hsEnd) { @@ -6532,6 +6534,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { InvalidateStyleRedraw(); break; + case SCI_SETHOTSPOTSINGLELINE: + vs.hotspotSingleLine = wParam != 0; + InvalidateStyleRedraw(); + break; + default: return DefWndProc(iMessage, wParam, lParam); } diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index eb8e54f2f..e2a65e09e 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -84,6 +84,7 @@ ViewStyle::ViewStyle(const ViewStyle &source) { hotspotBackgroundSet = source.hotspotBackgroundSet; hotspotBackground.desired = source.hotspotBackground.desired; hotspotUnderline = source.hotspotUnderline; + hotspotSingleLine = source.hotspotSingleLine; whitespaceForegroundSet = source.whitespaceForegroundSet; whitespaceForeground.desired = source.whitespaceForeground.desired; @@ -164,6 +165,7 @@ void ViewStyle::Init() { hotspotBackgroundSet = false; hotspotBackground.desired = ColourDesired(0xff, 0xff, 0xff); hotspotUnderline = true; + hotspotSingleLine = true; leftMarginWidth = 1; rightMarginWidth = 1; diff --git a/src/ViewStyle.h b/src/ViewStyle.h index ff38efef2..5f27cc08c 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -68,6 +68,7 @@ public: bool hotspotBackgroundSet; ColourPair hotspotBackground; bool hotspotUnderline; + bool hotspotSingleLine; /// Margins are ordered: Line Numbers, Selection Margin, Spacing Margin enum { margins=3 }; int leftMarginWidth; ///< Spacing margin on left of text |