]> gitweb.factorcode.org Git - factor.git/commitdiff
ui: better support for Emacs-style key bindings.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 28 May 2020 02:49:30 +0000 (19:49 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 28 May 2020 02:49:30 +0000 (19:49 -0700)
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.

basis/ui/gadgets/editors/editors.factor
basis/ui/tools/debugger/debugger.factor
basis/ui/tools/listener/listener-docs.factor
basis/ui/tools/listener/listener.factor
basis/ui/tools/operations/operations.factor

index 6906257453f07dec2cfd5646fb89783bd4ab6723..84a2be482d485743f1c157bbe56f9945254bfdfd 100644 (file)
@@ -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 ;
index 8425b9249fc3c3b5856831f354fe3dccb595799f..b043c3023d060589f8d8db64262bfc5dba5ee24e 100644 (file)
@@ -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
index 6983c0490d65abae9eb7ec7d85576bf2aadf2c61..22db983c1e2badd9ba24b5e96cb613caafc37f2f 100644 (file)
@@ -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" } "." ;
 
index 5ce038470ba6d4484e77bc63b178ca73b4198016..719342314be3841db2d0f1bc8819a37a23a3b992 100644 (file)
@@ -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 {
index 5738baafb47e6abd42e2fec8e438b47ab25589af..84c93c7037388a08b42becff9b68e4f77af654e9 100644 (file)
@@ -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