duskos

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

commit 2cae7099c132e76bedbec799a65fc76fdda0ced0
parent cfd89506b99e9b005ee7788275101cce8d8f25ad
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sat, 21 Jan 2023 15:54:36 -0500

text/ged: first baby steps

Gotta take baby steps. May I remind you I'm writing this with text/ed?

Diffstat:
Mfs/doc/text/ed.txt | 2+-
Afs/doc/text/ged.txt | 23+++++++++++++++++++++++
Afs/text/ged.fs | 17+++++++++++++++++
3 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/fs/doc/text/ed.txt b/fs/doc/text/ed.txt @@ -3,7 +3,7 @@ Prerequisites: sys/io, sys/file, lib/alloc, lib/context This line based text editor lives at text/ed.fs and allows the examination and -modification of text contents. +modification of text contents. The Grid-based editor is text/ged. The central structure of this unit is Edbuf (editor buffer) and its API is described below. You will typically only want one copy of this structure and diff --git a/fs/doc/text/ged.txt b/fs/doc/text/ged.txt @@ -0,0 +1,23 @@ +# Grid Text Editor + +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. + +The basic idea is that text around current Edbuf selection is always displayed +using the whole grid except for the bottom line (the status line). There are +quick one letter keybindings for frequent and simple movements and +manipulations, but for fancier operations, you go in command mode with ":", +which simply prompts for a line to interpret (in which you'll probably use +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 + +q Quit +All others: select next line down and refresh page. diff --git a/fs/text/ged.fs b/fs/text/ged.fs @@ -0,0 +1,16 @@ +require /sys/grid.fs +?f<< /text/ed.fs + +: nspcs ( n -- ) >r begin SPC grid :putc next ; +: _spitline ( pos line -- ) + swap grid :spiton + dup Line cnt grid COLS min ( line n ) + dup if swap Line ptr over grid :write else nip then ( n ) + grid COLS -^ ?dup if nspcs then grid :spitoff ; + +: _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 ; + +: ged begin _spitpage 1 edbuf :godown key 'q' = until ; +\ No newline at end of file