From c07a594e1ab090357ea47bf89264f9fde3f72d8a Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Thu, 4 Jun 2020 10:39:59 -0400 Subject: [PATCH] Begin working on a Visual Editor --- blk/001 | 2 +- blk/030 | 1 - blk/048 | 2 -- blk/056 | 4 ---- blk/062 | 1 - blk/064 | 2 -- blk/120 | 16 ++++++++++++++++ blk/121 | 13 +++++++++++++ blk/125 | 2 ++ blk/126 | 14 ++++++++++++++ blk/127 | 7 +++++++ blk/158 | 2 ++ blk/307 | 1 - blk/496 | 1 - tools/blkpack.c | 4 ++++ 15 files changed, 59 insertions(+), 13 deletions(-) create mode 100644 blk/120 create mode 100644 blk/121 create mode 100644 blk/125 create mode 100644 blk/126 create mode 100644 blk/127 create mode 100644 blk/158 diff --git a/blk/001 b/blk/001 index 1f12acb..159ec9f 100644 --- a/blk/001 +++ b/blk/001 @@ -2,7 +2,7 @@ MASTER INDEX 3 Usage 30 Dictionary 70 Implementation notes 100 Block editor -150 Extra words +120 Visual Editor 150 Extra words 200 Z80 assembler 260 Cross compilation 280 Z80 boot code 350 Core words 410 PS/2 keyboard subsystem 420 Bootstrap guide diff --git a/blk/030 b/blk/030 index 919a99d..debe75a 100644 --- a/blk/030 +++ b/blk/030 @@ -14,4 +14,3 @@ and Extra words (B150). - diff --git a/blk/048 b/blk/048 index e9505ac..b1f1ad2 100644 --- a/blk/048 +++ b/blk/048 @@ -14,5 +14,3 @@ J -- n Copy RS third item to PS - - diff --git a/blk/056 b/blk/056 index 5e28f9b..75b66b7 100644 --- a/blk/056 +++ b/blk/056 @@ -14,7 +14,3 @@ NOT f -- f Push the logical opposite of f - - - - diff --git a/blk/062 b/blk/062 index 64dcb0d..55bb2cd 100644 --- a/blk/062 +++ b/blk/062 @@ -14,4 +14,3 @@ a newline. - diff --git a/blk/064 b/blk/064 index 4fd980a..ef739d0 100644 --- a/blk/064 +++ b/blk/064 @@ -14,5 +14,3 @@ LOADR+ n1 n2 -- Relative ranged load. WIPE -- Empties current block - - diff --git a/blk/120 b/blk/120 new file mode 100644 index 0000000..5816624 --- /dev/null +++ b/blk/120 @@ -0,0 +1,16 @@ +Visual Editor + +This editor, unlike the Block Editor (B100), is grid-based +instead of being command-based. It requires the AT-XY, COLS +and LINES words to be implemented. + +It is loaded with "125 LOAD" and invoked with "VE". + +This editor uses 17 lines. The top line is the status line and +the 16 others are contents lines. The content shown is that +of the currently selected block. + +All keystrokes are directly interpreted by VE and have the +effect described below. + + (cont.) diff --git a/blk/121 b/blk/121 new file mode 100644 index 0000000..a053c0d --- /dev/null +++ b/blk/121 @@ -0,0 +1,13 @@ +Pressing a 0-9 digit accumulates that digit into what is named +the "modifier". That modifier affects the behavior of many +keystokes described below. The modifier starts at zero, but +most commands interpret a zero as a 1 so that they can have an +effect. + +'G' selects the block specified by the modifier as the current +block. Any change madde to the previously selected block is +saved beforehand. + +'[' and ']' advance the selected block by modifier. + +'Return' resets the modifier diff --git a/blk/125 b/blk/125 new file mode 100644 index 0000000..8ede59e --- /dev/null +++ b/blk/125 @@ -0,0 +1,2 @@ +'? UPPER NOT [IF] 33 LOAD+ [THEN] DROP ( B158 ) +1 2 LOADR+ diff --git a/blk/126 b/blk/126 new file mode 100644 index 0000000..b91546f --- /dev/null +++ b/blk/126 @@ -0,0 +1,14 @@ +CREATE CMD 2 C, '$' C, 0 C, +VARIABLE ACC +: 0acc 0 ACC ! ; +: num ACC @ SWAP _pdacc IF DROP ELSE ACC ! THEN ; +: nspcs ( n -- , spit n space ) 0 DO SPC LOOP ; +: aty 0 SWAP AT-XY ; +: clrln DUP aty COLS nspcs aty ; +: clrscr LINES 0 DO I clrln LOOP ; +: status 0 clrln ." BLK" SPC BLK> ? SPC ACC ? ; +: contents 1 aty BLK> @ LIST ; +: selblk BLK@ 0acc contents ; +: $G ACC @ selblk ; +: $[ BLK> @ ACC @ 1 MAX - selblk ; +: $] BLK> @ ACC @ 1 MAX + selblk ; diff --git a/blk/127 b/blk/127 new file mode 100644 index 0000000..638da77 --- /dev/null +++ b/blk/127 @@ -0,0 +1,7 @@ +: handle ( c -- f ) + UPPER DUP '0' '9' =><= IF num 0 EXIT THEN + DUP CMD 2+ C! CMD FIND IF EXECUTE ELSE DROP THEN + 'Q' = ; +: VE clrscr 0acc contents + BEGIN status KEY handle UNTIL 18 aty ; + diff --git a/blk/158 b/blk/158 new file mode 100644 index 0000000..921d50a --- /dev/null +++ b/blk/158 @@ -0,0 +1,2 @@ +: LOWER DUP 'A' 'Z' =><= IF 32 + THEN ; +: UPPER DUP 'a' 'z' =><= IF 32 - THEN ; diff --git a/blk/307 b/blk/307 index 1d1afe5..8950e0c 100644 --- a/blk/307 +++ b/blk/307 @@ -14,4 +14,3 @@ CODE ?DUP CODE DROP HL POPqq, ;CODE - diff --git a/blk/496 b/blk/496 index 9789f06..20b776c 100644 --- a/blk/496 +++ b/blk/496 @@ -14,4 +14,3 @@ CODE @GET ( a -- c f ) 0x28 RSTn, PUSHA, PUSHZ, ;CODE - diff --git a/tools/blkpack.c b/tools/blkpack.c index b1bcfdc..b42126f 100644 --- a/tools/blkpack.c +++ b/tools/blkpack.c @@ -54,6 +54,10 @@ int main(int argc, char *argv[]) } strncpy(buf+(blkid*1024)+(i*64), line, cnt-1); } + ssize_t cnt = getline(&line, &n, fp); + if (cnt > 0) { + fprintf(stderr, "blk %s has more than 16 lines\n", ep->d_name); + } free(line); } fwrite(buf, 1024, blkcnt, stdout);