duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit e4e5ea454140c90a6a00c26f0185728a6b524283
parent 192caafde2748553181171609681d6022cc16ced
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sat, 21 Jan 2023 21:06:08 -0500

text/ged: add grid cursor updates

That thing is getting actually useful. For example, you can use "ged" to quickly
get where you want, quit, use "ed" commands to edit, go back to "ged", move, and
so on.

Diffstat:
Mfs/doc/sys/grid.txt | 3+++
Mfs/doc/text/ged.txt | 4++++
Mfs/text/ged.fs | 9++++++---
3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/fs/doc/sys/grid.txt b/fs/doc/sys/grid.txt @@ -54,6 +54,9 @@ its methods, namely: :pcell! ( c self -- ) Set content of the cell at current pos to character "c". +:pos! ( pos self -- ) + Set current pos to "pos" and update cursor position. + :clrline ( ln self -- ) Set all cells in line number "ln" to spaces. diff --git a/fs/doc/text/ged.txt b/fs/doc/text/ged.txt @@ -20,7 +20,11 @@ enters the grid keybindings loop. ## Keybindings 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 diff --git a/fs/text/ged.fs b/fs/text/ged.fs @@ -12,15 +12,18 @@ require /sys/grid.fs : _spitpage ( -- ) grid LINES 1- >r 0 edbuf sel begin ( lineno line ) dup if over grid COLS * over _spitline else over grid :clrline then - dup if llnext then swap 1+ swap next 2drop ; + dup if llnext then swap 1+ swap next 2drop + edbuf cpos grid :pos! ; -S" qhjkl[]" const KEYS +S" qhjklHL[]" const KEYS KEYS c@ wordtbl handlers -'w quit +:w grid LINES 1- dup grid :clrline grid COLS * grid :pos! quit ; :w 1 edbuf :goleft ; :w 1 edbuf :godown ; :w 1 edbuf :goup ; :w 1 edbuf :goright ; +:w $ffff edbuf :goleft ; +:w $ffff edbuf :goright ; :w pagesz edbuf :goup ; :w pagesz edbuf :godown ;