diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Editor.cxx | 90 | ||||
-rw-r--r-- | src/Editor.h | 8 | ||||
-rw-r--r-- | src/ScintillaBase.cxx | 8 | ||||
-rw-r--r-- | src/ScintillaBase.h | 1 |
4 files changed, 77 insertions, 30 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index 504c85b41..0c100252d 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -4419,6 +4419,14 @@ void Editor::DelCharBack(bool allowLineStartDeletion) { ShowCaretAtCurrentPosition(); } +int Editor::ModifierFlags(bool shift, bool ctrl, bool alt, bool meta) { + return + (shift ? SCI_SHIFT : 0) | + (ctrl ? SCI_CTRL : 0) | + (alt ? SCI_ALT : 0) | + (meta ? SCI_META : 0); +} + void Editor::NotifyFocus(bool focus) { SCNotification scn = {}; scn.nmhdr.code = focus ? SCN_FOCUSIN : SCN_FOCUSOUT; @@ -4470,43 +4478,55 @@ void Editor::NotifyModifyAttempt() { NotifyParent(scn); } -void Editor::NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt) { +void Editor::NotifyDoubleClick(Point pt, int modifiers) { SCNotification scn = {}; scn.nmhdr.code = SCN_DOUBLECLICK; scn.line = LineFromLocation(pt); scn.position = PositionFromLocation(pt, true); - scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | - (alt ? SCI_ALT : 0); + scn.modifiers = modifiers; NotifyParent(scn); } -void Editor::NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt) { +void Editor::NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt) { + NotifyDoubleClick(pt, ModifierFlags(shift, ctrl, alt)); +} + +void Editor::NotifyHotSpotDoubleClicked(int position, int modifiers) { SCNotification scn = {}; scn.nmhdr.code = SCN_HOTSPOTDOUBLECLICK; scn.position = position; - scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | - (alt ? SCI_ALT : 0); + scn.modifiers = modifiers; NotifyParent(scn); } -void Editor::NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt) { +void Editor::NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt) { + NotifyHotSpotDoubleClicked(position, ModifierFlags(shift, ctrl, alt)); +} + +void Editor::NotifyHotSpotClicked(int position, int modifiers) { SCNotification scn = {}; scn.nmhdr.code = SCN_HOTSPOTCLICK; scn.position = position; - scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | - (alt ? SCI_ALT : 0); + scn.modifiers = modifiers; NotifyParent(scn); } -void Editor::NotifyHotSpotReleaseClick(int position, bool shift, bool ctrl, bool alt) { +void Editor::NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt) { + NotifyHotSpotClicked(position, ModifierFlags(shift, ctrl, alt)); +} + +void Editor::NotifyHotSpotReleaseClick(int position, int modifiers) { SCNotification scn = {}; scn.nmhdr.code = SCN_HOTSPOTRELEASECLICK; scn.position = position; - scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | - (alt ? SCI_ALT : 0); + scn.modifiers = modifiers; NotifyParent(scn); } +void Editor::NotifyHotSpotReleaseClick(int position, bool shift, bool ctrl, bool alt) { + NotifyHotSpotReleaseClick(position, ModifierFlags(shift, ctrl, alt)); +} + bool Editor::NotifyUpdateUI() { if (needUpdateUI) { SCNotification scn = {}; @@ -4525,19 +4545,23 @@ void Editor::NotifyPainted() { NotifyParent(scn); } -void Editor::NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt) { +void Editor::NotifyIndicatorClick(bool click, int position, int modifiers) { int mask = pdoc->decorations.AllOnFor(position); if ((click && mask) || pdoc->decorations.clickNotified) { SCNotification scn = {}; pdoc->decorations.clickNotified = click; scn.nmhdr.code = click ? SCN_INDICATORCLICK : SCN_INDICATORRELEASE; - scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0); + scn.modifiers = modifiers; scn.position = position; NotifyParent(scn); } } -bool Editor::NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt) { +void Editor::NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt) { + NotifyIndicatorClick(click, position, ModifierFlags(shift, ctrl, alt)); +} + +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++) { @@ -4548,6 +4572,8 @@ bool Editor::NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt) { 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)) { + const bool ctrl = (modifiers & SCI_CTRL) != 0; + const bool shift = (modifiers & SCI_SHIFT) != 0; int lineClick = pdoc->LineFromPosition(position); if (shift && ctrl) { FoldAll(SC_FOLDACTION_TOGGLE); @@ -4569,8 +4595,7 @@ bool Editor::NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt) { } SCNotification scn = {}; scn.nmhdr.code = SCN_MARGINCLICK; - scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | - (alt ? SCI_ALT : 0); + scn.modifiers = modifiers; scn.position = position; scn.margin = marginClicked; NotifyParent(scn); @@ -4580,6 +4605,10 @@ bool Editor::NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt) { } } +bool Editor::NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt) { + return NotifyMarginClick(pt, ModifierFlags(shift, ctrl, alt)); +} + void Editor::NotifyNeedShown(int pos, int len) { SCNotification scn = {}; scn.nmhdr.code = SCN_NEEDSHOWN; @@ -5752,9 +5781,7 @@ int Editor::KeyDownWithModifiers(int key, int modifiers, bool *consumed) { } int Editor::KeyDown(int key, bool shift, bool ctrl, bool alt, bool *consumed) { - int modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | - (alt ? SCI_ALT : 0); - return KeyDownWithModifiers(key, modifiers, consumed); + return KeyDownWithModifiers(key, ModifierFlags(shift, ctrl, alt), consumed); } void Editor::Indent(bool forwards) { @@ -6291,18 +6318,21 @@ static bool AllowVirtualSpace(int virtualSpaceOptions, bool rectangular) { || (rectangular && ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) != 0)); } -void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) { +void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers) { //Platform::DebugPrintf("ButtonDown %d %d = %d alt=%d %d\n", curTime, lastClickTime, curTime - lastClickTime, alt, inDragDrop); ptMouseLast = pt; + const bool ctrl = (modifiers & SCI_CTRL) != 0; + const bool shift = (modifiers & SCI_SHIFT) != 0; + const bool alt = (modifiers & SCI_ALT) != 0; SelectionPosition newPos = SPositionFromLocation(pt, false, false, AllowVirtualSpace(virtualSpaceOptions, alt)); newPos = MovePositionOutsideChar(newPos, sel.MainCaret() - newPos.Position()); inDragDrop = ddNone; sel.SetMoveExtends(false); - if (NotifyMarginClick(pt, shift, ctrl, alt)) + if (NotifyMarginClick(pt, modifiers)) return; - NotifyIndicatorClick(true, newPos.Position(), shift, ctrl, alt); + NotifyIndicatorClick(true, newPos.Position(), modifiers); bool inSelMargin = PointInSelMargin(pt); // In margin ctrl+(double)click should always select everything @@ -6385,9 +6415,9 @@ 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, ctrl, alt); + NotifyDoubleClick(pt, modifiers); if (PositionIsHotspot(newPos.Position())) - NotifyHotSpotDoubleClicked(newPos.Position(), shift, ctrl, alt); + NotifyHotSpotDoubleClicked(newPos.Position(), modifiers); } } else { // Single click if (inSelMargin) { @@ -6416,7 +6446,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b SetMouseCapture(true); } else { if (PointIsHotspot(pt)) { - NotifyHotSpotClicked(newPos.Position(), shift, ctrl, alt); + NotifyHotSpotClicked(newPos.Position(), modifiers); hotSpotClickPos = PositionFromLocation(pt,true,false); } if (!shift) { @@ -6461,6 +6491,10 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b ShowCaretAtCurrentPosition(); } +void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) { + return ButtonDownWithModifiers(pt, curTime, ModifierFlags(shift, ctrl, alt)); +} + bool Editor::PositionIsHotspot(int position) const { return vs.styles[pdoc->StyleAt(position) & pdoc->stylingBitsMask].hotspot; } @@ -6642,7 +6676,7 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { } if (hotSpotClickPos != INVALID_POSITION && PointIsHotspot(pt)) { hotSpotClickPos = INVALID_POSITION; - NotifyHotSpotReleaseClick(newPos.Position(), false, ctrl, false); + NotifyHotSpotReleaseClick(newPos.Position(), ctrl ? SCI_CTRL : 0); } if (HaveMouseCapture()) { if (PointInSelMargin(pt)) { @@ -6653,7 +6687,7 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { } ptMouseLast = pt; SetMouseCapture(false); - NotifyIndicatorClick(false, newPos.Position(), false, false, false); + NotifyIndicatorClick(false, newPos.Position(), 0); if (inDragDrop == ddDragging) { SelectionPosition selStart = SelectionStart(); SelectionPosition selEnd = SelectionEnd(); diff --git a/src/Editor.h b/src/Editor.h index 20877b29e..388053777 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -488,6 +488,7 @@ protected: // ScintillaBase subclass needs access to much of Editor void DelCharBack(bool allowLineStartDeletion); virtual void ClaimSelection() = 0; + static int ModifierFlags(bool shift, bool ctrl, bool alt, bool meta=false); virtual void NotifyChange() = 0; virtual void NotifyFocus(bool focus); virtual void SetCtrlID(int identifier); @@ -497,13 +498,19 @@ protected: // ScintillaBase subclass needs access to much of Editor void NotifyChar(int ch); void NotifySavePoint(bool isSavePoint); void NotifyModifyAttempt(); + virtual void NotifyDoubleClick(Point pt, int modifiers); virtual void NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt); + void NotifyHotSpotClicked(int position, int modifiers); void NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt); + void NotifyHotSpotDoubleClicked(int position, int modifiers); void NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt); + void NotifyHotSpotReleaseClick(int position, int modifiers); void NotifyHotSpotReleaseClick(int position, bool shift, bool ctrl, bool alt); bool NotifyUpdateUI(); void NotifyPainted(); + void NotifyIndicatorClick(bool click, int position, int modifiers); void NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt); + bool NotifyMarginClick(Point pt, int modifiers); bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt); void NotifyNeedShown(int pos, int len); void NotifyDwelling(Point pt, bool state); @@ -566,6 +573,7 @@ protected: // ScintillaBase subclass needs access to much of Editor void WordSelection(int pos); void DwellEnd(bool mouseMoved); void MouseLeave(); + virtual void ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers); virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt); void ButtonMoveWithModifiers(Point pt, int modifiers); void ButtonMove(Point pt); diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index b06f72836..9190cd6d5 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -463,9 +463,13 @@ void ScintillaBase::CancelModes() { Editor::CancelModes(); } -void ScintillaBase::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) { +void ScintillaBase::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers) { CancelModes(); - Editor::ButtonDown(pt, curTime, shift, ctrl, alt); + Editor::ButtonDownWithModifiers(pt, curTime, modifiers); +} + +void ScintillaBase::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) { + ButtonDownWithModifiers(pt, curTime, ModifierFlags(shift, ctrl, alt)); } #ifdef SCI_LEXER diff --git a/src/ScintillaBase.h b/src/ScintillaBase.h index 6ec06d443..59ffea41e 100644 --- a/src/ScintillaBase.h +++ b/src/ScintillaBase.h @@ -83,6 +83,7 @@ protected: virtual void AddToPopUp(const char *label, int cmd=0, bool enabled=true) = 0; void ContextMenu(Point pt); + virtual void ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers); virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt); void NotifyStyleToNeeded(int endStyleNeeded); |