summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-02-08 10:20:09 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-02-08 10:20:09 +0200
commitf48da214d434b9c0788b633ea1ed0912592163e2 (patch)
treeea53bb9d1eea15f9012cbfbc4b3ccf940e2b5219
parentd2fa8aa3b6adad0cc15b7840966e7e622d7f61cb (diff)
parentf7a7e6a6c318d232d95833fd04e0a9c0093c29a8 (diff)
Merge commit 'pullrequests/ThomasAdam/ta/shift-ins' into dev
-rw-r--r--src/ui/inputwidget.c49
1 files changed, 29 insertions, 20 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index 2d767152..45214d60 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -540,6 +540,29 @@ static iBool copy_InputWidget_(iInputWidget *d, iBool doCut) {
540 return iFalse; 540 return iFalse;
541} 541}
542 542
543static void process_Paste_(iInputWidget *d) {
544 if (SDL_HasClipboardText()) {
545 pushUndo_InputWidget_(d);
546 deleteMarked_InputWidget_(d);
547 char *text = SDL_GetClipboardText();
548 iString *paste = collect_String(newCStr_String(text));
549 /* Url decoding. */
550 if (d->inFlags & isUrl_InputWidgetFlag) {
551 if (prefs_App()->decodeUserVisibleURLs) {
552 paste = collect_String(urlDecode_String(paste));
553 }
554 else {
555 urlEncodePath_String(paste);
556 }
557 }
558 SDL_free(text);
559 iConstForEach(String, i, paste) {
560 insertChar_InputWidget_(d, i.value);
561 }
562 contentsWereChanged_InputWidget_(d);
563 }
564}
565
543static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) { 566static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
544 iWidget *w = as_Widget(d); 567 iWidget *w = as_Widget(d);
545 if (isCommand_Widget(w, ev, "focus.gained")) { 568 if (isCommand_Widget(w, ev, "focus.gained")) {
@@ -606,26 +629,7 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
606 copy_InputWidget_(d, key == 'x'); 629 copy_InputWidget_(d, key == 'x');
607 return iTrue; 630 return iTrue;
608 case 'v': 631 case 'v':
609 if (SDL_HasClipboardText()) { 632 process_Paste_(d);
610 pushUndo_InputWidget_(d);
611 deleteMarked_InputWidget_(d);
612 char *text = SDL_GetClipboardText();
613 iString *paste = collect_String(newCStr_String(text));
614 /* Url decoding. */
615 if (d->inFlags & isUrl_InputWidgetFlag) {
616 if (prefs_App()->decodeUserVisibleURLs) {
617 paste = collect_String(urlDecode_String(paste));
618 }
619 else {
620 urlEncodePath_String(paste);
621 }
622 }
623 SDL_free(text);
624 iConstForEach(String, i, paste) {
625 insertChar_InputWidget_(d, i.value);
626 }
627 contentsWereChanged_InputWidget_(d);
628 }
629 return iTrue; 633 return iTrue;
630 case 'z': 634 case 'z':
631 if (popUndo_InputWidget_(d)) { 635 if (popUndo_InputWidget_(d)) {
@@ -637,6 +641,11 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
637 } 641 }
638 d->lastCursor = d->cursor; 642 d->lastCursor = d->cursor;
639 switch (key) { 643 switch (key) {
644 case SDLK_INSERT:
645 if (mods == KMOD_SHIFT) {
646 process_Paste_(d);
647 }
648 return iTrue;
640 case SDLK_RETURN: 649 case SDLK_RETURN:
641 case SDLK_KP_ENTER: 650 case SDLK_KP_ENTER:
642 d->inFlags |= enterPressed_InputWidgetFlag; 651 d->inFlags |= enterPressed_InputWidgetFlag;