commit e441f43aa3896fa24ee0627eb9cea9f0a755887f
parent 2e3878859326350f490372b188b9f0bc188d9fd4
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Sat, 28 Jan 2023 10:20:14 -0500
text/ged: add "i f n o O" keybindings
Diffstat:
2 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/fs/doc/text/ged.txt b/fs/doc/text/ged.txt
@@ -2,8 +2,6 @@
Prerequisites: text/ed, sys/grid
-TODO: work in progress. Extremely rudimentary at the moment
-
The Grid text editor sits on text/ed and adds a visual and interactive interface
through the Grid.
@@ -22,13 +20,14 @@ quickly enter fancier commands (example "i hello").
## Keybindings
+Some key bindings map directly to their the text/ed convenience word of the same
+name, with the same behavior. Those are:
+
+ h j k l H L i f n o O
+
+Others have this behavior:
+
q Quit
-h move 1 character left
-j move 1 line down
-k move 1 line up
-l move 1 character right
-H move to the beginning of the line
-L move to the end of the line
] move 1 page down
[ move 1 page up
: enter a single line of command that will be interpreted as forth
diff --git a/fs/text/ged.fs b/fs/text/ged.fs
@@ -31,8 +31,12 @@ grid LINES 1- const _height
: _statusclr _height grid :clrline ;
: _statusline _statusclr _height grid COLS * grid :pos! ;
+: _typeline _statusline rdln :typeline ( f ) ;
+\ 1- is to remove ending LF from rdln :range
+: _rdln[] rdln :range 1- ;
+: _pagerefresh _top _top! ;
-S" qhjklHL[]:" const KEYS
+S" qhjklHLifnoO[]:" const KEYS
KEYS c@ wordtbl handlers
:w _statusline quit ;
:w 1 edbuf :goleft ;
@@ -41,10 +45,14 @@ KEYS c@ wordtbl handlers
:w 1 edbuf :goright ;
:w $ffff edbuf :goleft ;
:w $ffff edbuf :goright ;
+:w _typeline if _rdln[] edbuf :write then _pagerefresh ;
+:w _typeline if _rdln[] []>str edbuf :find then ;
+:w edbuf :findnext ;
+:w _typeline if edbuf :appendline _rdln[] edbuf :write then _pagerefresh ;
+:w _typeline if edbuf :insertline _rdln[] edbuf :write then _pagerefresh ;
:w pagesz edbuf :goup ;
:w pagesz edbuf :godown ;
-:w _statusline rdln :typeline _statusline
- if rdln :interpret then _top _top! ;
+:w _typeline _statusline if rdln :interpret then _pagerefresh ;
: ged 0 to _top begin
_refresh key KEYS c@+ [c]? ( idx )