diff options
-rw-r--r-- | src/ui/inputwidget.c | 30 | ||||
-rw-r--r-- | src/ui/window.c | 2 |
2 files changed, 21 insertions, 11 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c index 537afb00..fbcbd4c2 100644 --- a/src/ui/inputwidget.c +++ b/src/ui/inputwidget.c | |||
@@ -479,6 +479,21 @@ static size_t coordIndex_InputWidget_(const iInputWidget *d, iInt2 coord) { | |||
479 | return index; | 479 | return index; |
480 | } | 480 | } |
481 | 481 | ||
482 | static iBool copy_InputWidget_(iInputWidget *d, iBool doCut) { | ||
483 | if (!isEmpty_Range(&d->mark)) { | ||
484 | const iRanges m = mark_InputWidget_(d); | ||
485 | SDL_SetClipboardText(cstrCollect_String( | ||
486 | newUnicodeN_String(constAt_Array(&d->text, m.start), size_Range(&m)))); | ||
487 | if (doCut) { | ||
488 | pushUndo_InputWidget_(d); | ||
489 | deleteMarked_InputWidget_(d); | ||
490 | contentsWereChanged_InputWidget_(d); | ||
491 | } | ||
492 | return iTrue; | ||
493 | } | ||
494 | return iFalse; | ||
495 | } | ||
496 | |||
482 | static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) { | 497 | static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) { |
483 | iWidget *w = as_Widget(d); | 498 | iWidget *w = as_Widget(d); |
484 | if (isCommand_Widget(w, ev, "focus.gained")) { | 499 | if (isCommand_Widget(w, ev, "focus.gained")) { |
@@ -495,6 +510,10 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) { | |||
495 | } | 510 | } |
496 | return iFalse; | 511 | return iFalse; |
497 | } | 512 | } |
513 | else if (isFocused_Widget(d) && isCommand_UserEvent(ev, "copy")) { | ||
514 | copy_InputWidget_(d, iFalse); | ||
515 | return iTrue; | ||
516 | } | ||
498 | switch (processEvent_Click(&d->click, ev)) { | 517 | switch (processEvent_Click(&d->click, ev)) { |
499 | case none_ClickResult: | 518 | case none_ClickResult: |
500 | break; | 519 | break; |
@@ -531,16 +550,7 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) { | |||
531 | switch (key) { | 550 | switch (key) { |
532 | case 'c': | 551 | case 'c': |
533 | case 'x': | 552 | case 'x': |
534 | if (!isEmpty_Range(&d->mark)) { | 553 | copy_InputWidget_(d, key == 'x'); |
535 | const iRanges m = mark_InputWidget_(d); | ||
536 | SDL_SetClipboardText(cstrCollect_String( | ||
537 | newUnicodeN_String(constAt_Array(&d->text, m.start), size_Range(&m)))); | ||
538 | if (key == 'x') { | ||
539 | pushUndo_InputWidget_(d); | ||
540 | deleteMarked_InputWidget_(d); | ||
541 | contentsWereChanged_InputWidget_(d); | ||
542 | } | ||
543 | } | ||
544 | return iTrue; | 554 | return iTrue; |
545 | case 'v': | 555 | case 'v': |
546 | if (SDL_HasClipboardText()) { | 556 | if (SDL_HasClipboardText()) { |
diff --git a/src/ui/window.c b/src/ui/window.c index 2b2dae46..115dd04b 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -125,7 +125,7 @@ static const iMenuItem fileMenuItems[] = { | |||
125 | }; | 125 | }; |
126 | 126 | ||
127 | static const iMenuItem editMenuItems[] = { | 127 | static const iMenuItem editMenuItems[] = { |
128 | { "Copy Source Text", SDLK_c, KMOD_PRIMARY, "copy" }, | 128 | { "Copy", SDLK_c, KMOD_PRIMARY, "copy" }, |
129 | { "Copy Link to Page", SDLK_c, KMOD_PRIMARY | KMOD_SHIFT, "document.copylink" }, | 129 | { "Copy Link to Page", SDLK_c, KMOD_PRIMARY | KMOD_SHIFT, "document.copylink" }, |
130 | { "---", 0, 0, NULL }, | 130 | { "---", 0, 0, NULL }, |
131 | { "Find", SDLK_f, KMOD_PRIMARY, "focus.set id:find.input" }, | 131 | { "Find", SDLK_f, KMOD_PRIMARY, "focus.set id:find.input" }, |