diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-12 14:08:18 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-12 14:08:18 +0300 |
commit | ac3dca8a97fabc5b41695d5020e1e4f035335236 (patch) | |
tree | 058435c26c4d572343c139b12809b1cc35918623 /src | |
parent | 9a51c0d0a17b9270542fef133040a02868bbaea9 (diff) |
InputWidget: Shift-click to select a range
Diffstat (limited to 'src')
-rw-r--r-- | src/ui/inputwidget.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c index 38d025b9..5f86f5bf 100644 --- a/src/ui/inputwidget.c +++ b/src/ui/inputwidget.c | |||
@@ -985,24 +985,32 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) { | |||
985 | switch (processEvent_Click(&d->click, ev)) { | 985 | switch (processEvent_Click(&d->click, ev)) { |
986 | case none_ClickResult: | 986 | case none_ClickResult: |
987 | break; | 987 | break; |
988 | case started_ClickResult: | 988 | case started_ClickResult: { |
989 | setFocus_Widget(w); | 989 | setFocus_Widget(w); |
990 | const size_t oldCursor = d->cursor; | ||
990 | setCursor_InputWidget(d, coordIndex_InputWidget_(d, pos_Click(&d->click))); | 991 | setCursor_InputWidget(d, coordIndex_InputWidget_(d, pos_Click(&d->click))); |
991 | iZap(d->mark); | 992 | if (keyMods_Sym(modState_Keys()) == KMOD_SHIFT) { |
992 | iZap(d->initialMark); | 993 | d->mark = d->initialMark = (iRanges){ oldCursor, d->cursor }; |
993 | d->inFlags &= ~(isMarking_InputWidgetFlag | markWords_InputWidgetFlag); | 994 | d->inFlags |= isMarking_InputWidgetFlag; |
994 | if (d->click.count == 2) { | ||
995 | d->inFlags |= isMarking_InputWidgetFlag | markWords_InputWidgetFlag; | ||
996 | d->mark.start = d->mark.end = d->cursor; | ||
997 | extendRange_InputWidget_(d, &d->mark.start, -1); | ||
998 | extendRange_InputWidget_(d, &d->mark.end, +1); | ||
999 | d->initialMark = d->mark; | ||
1000 | refresh_Widget(w); | ||
1001 | } | 995 | } |
1002 | if (d->click.count == 3) { | 996 | else { |
1003 | selectAll_InputWidget(d); | 997 | iZap(d->mark); |
998 | iZap(d->initialMark); | ||
999 | d->inFlags &= ~(isMarking_InputWidgetFlag | markWords_InputWidgetFlag); | ||
1000 | if (d->click.count == 2) { | ||
1001 | d->inFlags |= isMarking_InputWidgetFlag | markWords_InputWidgetFlag; | ||
1002 | d->mark.start = d->mark.end = d->cursor; | ||
1003 | extendRange_InputWidget_(d, &d->mark.start, -1); | ||
1004 | extendRange_InputWidget_(d, &d->mark.end, +1); | ||
1005 | d->initialMark = d->mark; | ||
1006 | refresh_Widget(w); | ||
1007 | } | ||
1008 | if (d->click.count == 3) { | ||
1009 | selectAll_InputWidget(d); | ||
1010 | } | ||
1004 | } | 1011 | } |
1005 | return iTrue; | 1012 | return iTrue; |
1013 | } | ||
1006 | case aborted_ClickResult: | 1014 | case aborted_ClickResult: |
1007 | d->inFlags &= ~isMarking_InputWidgetFlag; | 1015 | d->inFlags &= ~isMarking_InputWidgetFlag; |
1008 | return iTrue; | 1016 | return iTrue; |