commit 2899c17528a28ed6413509d1ba3f25ee0f8b7190
parent 13e9a5643e2d0f9a108a15ef395d07e6c42bf27e
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Fri, 27 Jan 2023 10:04:30 -0500
text/ged: add ":" keybinding
Diffstat:
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/fs/doc/text/ged.txt b/fs/doc/text/ged.txt
@@ -17,6 +17,9 @@ commands from text/ed, but you can also use others).
To use it, you load your EdBuf with some contents and then run "ged", which
enters the grid keybindings loop.
+Keybindings are rudimentary, but you have the ":" binding allowing you to
+quickly enter fancier commands (example "i hello").
+
## Keybindings
q Quit
@@ -28,3 +31,4 @@ 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
@@ -1,8 +1,12 @@
+require /sys/rdln.fs
require /sys/grid.fs
?f<< /text/ed.fs
?f<< /lib/wordtbl.fs
: nspcs ( n -- ) >r begin SPC grid :putc next ;
+
+grid LINES 1- const _height
+
: _spitline ( pos line -- )
swap grid :spiton
dup Line cnt grid COLS min ( line n )
@@ -10,23 +14,27 @@ require /sys/grid.fs
grid COLS -^ ?dup if nspcs then grid :spitoff ;
: _spitpage ( fromline -- )
- grid LINES 1- >r 0 swap begin ( lineno line )
+ _height >r 0 swap begin ( lineno line )
dup if over grid COLS * over _spitline else over grid :clrline then
dup if llnext then swap 1+ swap next 2drop ;
0 value _top
: _top! ( lineno -- )
dup to _top edbuf lines Line :itern nip _spitpage ;
+
: _zoom ( -- )
_top edbuf lpos tuck > if _top! else ( lpos )
- grid LINES 1- - max0 _top over <= if _top! else drop then then ;
+ _height 1- - max0 _top over <= if _top! else drop then then ;
: _refresh ( -- )
_zoom edbuf lpos _top - grid COLS * edbuf cpos + grid :pos! ;
-S" qhjklHL[]" const KEYS
+: _statusclr _height grid :clrline ;
+: _statusline _statusclr _height grid COLS * grid :pos! ;
+
+S" qhjklHL[]:" const KEYS
KEYS c@ wordtbl handlers
-:w grid LINES 1- dup grid :clrline grid COLS * grid :pos! quit ;
+:w _statusline quit ;
:w 1 edbuf :goleft ;
:w 1 edbuf :godown ;
:w 1 edbuf :goup ;
@@ -35,7 +43,8 @@ KEYS c@ wordtbl handlers
:w $ffff edbuf :goright ;
:w pagesz edbuf :goup ;
:w pagesz edbuf :godown ;
+:w _statusline rdln :readline _statusline rdln :interpret _top _top! ;
-: ged begin
+: ged 0 to _top begin
_refresh key KEYS c@+ [c]? ( idx )
dup 0>= if handlers swap wexec else drop then again ;
\ No newline at end of file