From: John Benediktsson Date: Thu, 28 May 2020 02:49:30 +0000 (-0700) Subject: ui: better support for Emacs-style key bindings. X-Git-Tag: 0.99~3201 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=928b4c6abcb012fc8ad4963a3976ab88d0ade741 ui: better support for Emacs-style key bindings. This changes a bunch of things like Ctrl-E for edit becomes Alt-E (Cmd-E on macOS). I think that's overall nicer, but let's play with it. --- diff --git a/basis/ui/gadgets/editors/editors.factor b/basis/ui/gadgets/editors/editors.factor index 6906257453..84a2be482d 100644 --- a/basis/ui/gadgets/editors/editors.factor +++ b/basis/ui/gadgets/editors/editors.factor @@ -478,6 +478,8 @@ editor "caret-motion" f { { T{ button-down } position-caret } { T{ key-down f f "LEFT" } previous-character } { T{ key-down f f "RIGHT" } next-character } + { T{ key-down f { C+ } "b" } previous-character } + { T{ key-down f { C+ } "f" } next-character } { T{ key-down f { C+ } "LEFT" } previous-word } { T{ key-down f { C+ } "RIGHT" } next-word } { T{ key-down f f "HOME" } start-of-line } @@ -640,6 +642,8 @@ PRIVATE> multiline-editor "multiline" f { { T{ key-down f f "UP" } previous-line } { T{ key-down f f "DOWN" } next-line } + { T{ key-down f { C+ } "p" } previous-line } + { T{ key-down f { C+ } "n" } next-line } { T{ key-down f { S+ } "UP" } select-previous-line } { T{ key-down f { S+ } "DOWN" } select-next-line } { T{ key-down f f "PAGE_UP" } previous-page } @@ -650,6 +654,9 @@ multiline-editor "multiline" f { { T{ key-down f { S+ } "RET" } insert-newline } { T{ key-down f f "ENTER" } insert-newline } { T{ key-down f { C+ } "j" } com-join-lines } + { T{ key-down f { C+ } "k" } delete-to-end-of-line } + { T{ key-down f { C+ } "a" } start-of-line } + { T{ key-down f { C+ } "e" } end-of-line } } define-command-map TUPLE: source-editor < multiline-editor ; diff --git a/basis/ui/tools/debugger/debugger.factor b/basis/ui/tools/debugger/debugger.factor index 8425b9249f..b043c3023d 100644 --- a/basis/ui/tools/debugger/debugger.factor +++ b/basis/ui/tools/debugger/debugger.factor @@ -88,8 +88,8 @@ debugger "gestures" f { \ com-edit H{ { +listener+ t } } define-command debugger "toolbar" f { - { T{ key-down f { C+ } "i" } com-inspect } - { T{ key-down f { C+ } "t" } com-traceback } - { T{ key-down f { C+ } "h" } com-help } - { T{ key-down f { C+ } "e" } com-edit } + { T{ key-down f { A+ } "i" } com-inspect } + { T{ key-down f { A+ } "t" } com-traceback } + { T{ key-down f { A+ } "d" } com-help } + { T{ key-down f { A+ } "e" } com-edit } } define-command-map diff --git a/basis/ui/tools/listener/listener-docs.factor b/basis/ui/tools/listener/listener-docs.factor index 6983c0490d..22db983c1e 100644 --- a/basis/ui/tools/listener/listener-docs.factor +++ b/basis/ui/tools/listener/listener-docs.factor @@ -49,35 +49,7 @@ $nl { $operations T{ vocab-link f "kernel" } } { $command-map interactor "quotation" } { $heading "Editing commands" } -"The text editing commands are standard; see " { $link "gadgets-editors-commands" } "." -$nl -"If you want to add support for Emacs-style text entry, specifically the following:" -$nl -{ $table - { "Ctrl-k" "Delete to end of line" } - { "Ctrl-a" "Move cursor to start of line" } - { "Ctrl-e" "Move cursor to end of line" } -} -$nl -"Then you can run the following code, or add it to your " { $link ".factor-rc" } "." -$nl -{ $code - "USING: accessors assocs kernel sequences sets ui.commands -ui.gadgets.editors ui.gestures ui.tools.listener ; - -\"multiline\" multiline-editor get-command-at [ - { - { T{ key-down f { C+ } \"k\" } delete-to-end-of-line } - { T{ key-down f { C+ } \"a\" } start-of-line } - { T{ key-down f { C+ } \"e\" } end-of-line } - } append members -] change-commands drop multiline-editor update-gestures - -\"interactor\" interactor get-command-at [ - [ drop T{ key-down f { C+ } \"k\" } = ] assoc-reject -] change-commands drop interactor update-gestures" -} -$nl +"The text editing commands are standard and follow Emacs-style text entry; see " { $link "gadgets-editors-commands" } "." { $heading "Implementation" } "Listeners are instances of " { $link listener-gadget } ". The listener consists of an output area (instance of " { $link pane } ") and an input area (instance of " { $link interactor } "). Clickable presentations can also be printed to the listener; see " { $link "ui-presentations" } "." ; diff --git a/basis/ui/tools/listener/listener.factor b/basis/ui/tools/listener/listener.factor index 5ce038470b..719342314b 100644 --- a/basis/ui/tools/listener/listener.factor +++ b/basis/ui/tools/listener/listener.factor @@ -386,7 +386,7 @@ M: interactor handle-gesture interactor "interactor" f { { T{ key-down f f "RET" } evaluate-input } - { T{ key-down f { C+ } "k" } clear-editor } + { T{ key-down f { C+ } "K" } clear-editor } } define-command-map interactor "completion" f { diff --git a/basis/ui/tools/operations/operations.factor b/basis/ui/tools/operations/operations.factor index 5738baafb4..84c93c7037 100644 --- a/basis/ui/tools/operations/operations.factor +++ b/basis/ui/tools/operations/operations.factor @@ -68,14 +68,14 @@ IN: ui.tools.operations } define-operation [ pathname? ] \ edit-file H{ - { +keyboard+ T{ key-down f { C+ } "e" } } + { +keyboard+ T{ key-down f { A+ } "e" } } { +primary+ t } { +secondary+ t } { +listener+ t } } define-operation [ definition-mixin? ] \ edit H{ - { +keyboard+ T{ key-down f { C+ } "e" } } + { +keyboard+ T{ key-down f { A+ } "e" } } { +listener+ t } } define-operation @@ -100,17 +100,17 @@ IN: ui.tools.operations [ definition-mixin? ] \ com-forget H{ } define-operation [ topic? ] \ com-browse H{ - { +keyboard+ T{ key-down f { C+ } "h" } } + { +keyboard+ T{ key-down f { A+ } "d" } } { +primary+ t } } define-operation [ word? ] \ usage. H{ - { +keyboard+ T{ key-down f { C+ } "u" } } + { +keyboard+ T{ key-down f { A+ } "u" } } { +listener+ t } } define-operation [ word? ] \ fix H{ - { +keyboard+ T{ key-down f { C+ } "f" } } + { +keyboard+ T{ key-down f { A+ } "f" } } { +listener+ t } } define-operation @@ -155,24 +155,24 @@ M: word com-stack-effect 1quotation com-stack-effect ; ! Quotations [ quotation? ] \ com-stack-effect H{ - { +keyboard+ T{ key-down f { C+ } "i" } } + { +keyboard+ T{ key-down f { A+ } "i" } } { +listener+ t } } define-operation [ quotation? ] \ walk H{ - { +keyboard+ T{ key-down f { C+ } "w" } } + { +keyboard+ T{ key-down f { A+ } "w" } } { +listener+ t } } define-operation [ quotation? ] \ time H{ - { +keyboard+ T{ key-down f { C+ } "t" } } + { +keyboard+ T{ key-down f { A+ } "t" } } { +listener+ t } } define-operation : com-expand-macros ( quot -- ) expand-macros . ; [ quotation? ] \ com-expand-macros H{ - { +keyboard+ T{ key-down f { C+ } "m" } } + { +keyboard+ T{ key-down f { A+ } "m" } } { +listener+ t } } define-operation