From b972b54f5808c052e6e7f316dce0fb6b398f765e Mon Sep 17 00:00:00 2001 From: d6 Date: Mon, 30 Jan 2023 10:59:52 -0500 Subject: [PATCH] more improvements --- term.tal | 91 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 36 deletions(-) diff --git a/term.tal b/term.tal index 26faa57..62f8885 100644 --- a/term.tal +++ b/term.tal @@ -32,19 +32,20 @@ ( erase from current line to top: ESC [ 1 J ) ( erase screen: ESC [ 2 J ) ( ) -( NOT SUPPORTED YET: ) -( show cursor: ESC [ ? 25 h ) -( hide cursor: ESC [ ? 25 l ) -( insert lines: ESC [ $n L ) -( ESC lpar ) -( ESC 7 ) +( insert lines: ESC [ $n L ) +( delete n characters: ESC [ $n P ) +( insert n blank characters: ESC [ $n @ ) ( ) -( set bracketed paste mode (xterm): ESC [ ? 2004 h ) -( reset bracketed paste mode (xterm): ESC [ ? 2004 l ) -( end alt charset ESC [ 10 m ) -( end alt charset ESC [ 11 m ) -( delete n characters: ESC [ n P ) -( insert n blank characters: ESC [ n @ ) +( NOT SUPPORTED YET: ) +( show cursor: ESC [ ? 25 h ) +( hide cursor: ESC [ ? 25 l ) +( ??? ESC lpar ) +( ??? ESC 7 ) +( set bracketed paste mode (xterm): ESC [ ? 2004 h ) +( reset bracketed paste mode (xterm): ESC [ ? 2004 l ) +( end alt charset ESC [ 10 m ) +( end alt charset ESC [ 11 m ) +( cursor forward n tab stops ESC [ $n I ) |00 @System [ &vect $2 &pad $6 &r $2 &g $2 &b $2 ] |10 @Console [ &vect $2 &r $1 &pad $5 &w $1 ] @@ -53,18 +54,18 @@ |a0 @File [ &vect $2 &ok $2 &stat $2 &del $1 &append $1 &name $2 &len $2 &r $2 &w $2 ] |0000 - @tint $1 ( draw mode. 01=regular, 04=inverted ) - @attr $1 ( 5 bits: RxxxBBFF ) - @dirty? $1 ( screen needs redraw? ) - @lastkey $1 ( last button press ) - @rows $2 ( height in characters ) - @cols $2 ( width in characters ) - @cur-x $2 ( cursor x: 0 <= cur-x < cols ) - @cur-y $2 ( cursor y: 0 <= cur-y < rows ) - @max-x $2 ( cols-1 ) - @max-y $2 ( rows-1 ) - @col-bytes $2 ( 2*cols ) - @debug $1 ( use debug log? ) + @tint $1 ( draw mode. 01=regular, 04=inverted ) + @attr $1 ( 5 bits: RxxxBBFF ) + @dirty? $1 ( screen needs redraw? ) + @lastkey $1 ( last button press ) + @rows $2 ( height in characters ) + @cols $2 ( width in characters ) + @cur-x $2 ( cursor x: 0 <= cur-x < cols ) + @cur-y $2 ( cursor y: 0 <= cur-y < rows ) + @max-x $2 ( cols-1 ) + @max-y $2 ( rows-1 ) + @col-bytes $2 ( 2*cols ) + @debug $1 ( use debug log? ) ( terminal settings ) @irm $1 ( 01: insert and move right, 00: replace and overwrite ) @@ -116,7 +117,7 @@ ;on-read .Console/vect DEO2 ( set up stdin ) ( set to 01 to enable debug log ) - #00 .debug STZ + #01 .debug STZ .debug LDZ ,&continue JCN BRK &continue #99 #010e DEO @@ -326,7 +327,7 @@ @end-arg ( c^ -> ) ;on-read .Console/vect DEO2 - DUP ,debug-csi JSR +( DUP ,debug-csi JSR ) DUP LIT "d EQU ;exec-move-row JCN2 ( move cursor to row ) DUP LIT "h EQU ;exec-set-mode JCN2 ( enable line wrap ) DUP LIT "l EQU ;exec-reset-mode JCN2 ( disable line wrap ) @@ -339,12 +340,14 @@ DUP LIT "D EQU ;exec-back JCN2 ( back ) DUP LIT "G EQU ;exec-move-col JCN2 ( move cursor to col ) DUP LIT "H EQU ;exec-move JCN2 ( move cursor ) + DUP LIT "I EQU ;exec-forward-tabs JCN2 ( forward by tab stops ) DUP LIT "J EQU ;exec-erase-screen JCN2 ( erase screen ) DUP LIT "K EQU ;exec-erase-line JCN2 ( erase line ) DUP LIT "L EQU ;exec-insert-lines JCN2 ( insert blank lines ) DUP LIT "M EQU ;exec-delete-lines JCN2 ( delete n lines ) DUP LIT "P EQU ;exec-delete-chars JCN2 ( delete n chars ) - POP BRK + ;debug-csi JSR2 BRK +( POP BRK ) @exec-noop ( c^ -> ) POP BRK @@ -408,6 +411,8 @@ @exec-insert-blanks POP ;insert-n-spaces ;exec1 JMP2 @exec-delete-lines POP ;delete-n-lines ;exec1 JMP2 @exec-delete-chars POP ;delete-n-chars ;exec1 JMP2 +@exec-insert-lines POP ;insert-n-lines ;exec1 JMP2 +@exec-forward-tabs POP ;forward-n-tabs ;exec1 JMP2 @exec-erase-line POP #0000 ;read-arg-1 JSR2 @@ -466,12 +471,6 @@ #0001 ;read-arg-2 JSR2 #0001 SUB2 ( col ) ;goto JSR2 BRK -@exec-insert-lines ( c^ -> ) - POP - #0001 ;read-arg-1 JSR2 ( n ) - POP2 ( TODO: shift ;screen from bol forward by n*cols bytes ) - BRK - @debug-esc ( c^ -> ) .debug LDZ ,&continue JCN POP JMP2r &continue ;scratch STH2 @@ -608,6 +607,25 @@ &replace ( cell* ) ;cur-addr JSR2 STA2 JMP2r ( ) +@forward-n-tabs ( n* -> ) + #0001 SUB2 #0008 MUL2 ( i=(n-1)8* ) + #0008 .cur-x LDZ2 #0007 AND2 SUB2 ( i* 8-cur%8* ) + ADD2 ;forward-n JMP2 ( ) + +@insert-n-lines ( n* -> ) + .col-bytes LDZ2 MUL2 STH2 ( [i*] ) + ;bol-addr JSR2 ( bound* [i*] ) + ;limit-addr JSR2 STH2kr ( bound* limit* i* [i*] ) + INC2 INC2 SUB2 ( bound* start=limit-i-2* [i*] ) + &loop ( bound* pos* [i*] ) + LDA2k OVR2 STH2kr ADD2 ( bound* pos* x* pos+i* [i*] ) + STA2 ( bound* pos* [i*] ; pos+i<-x ) + #4220 OVR2 STA2 ( bound* pos* [i*] ; pos<-4220 ) + #0002 SUB2 ( bound* pos-2* [i*] ) + GTH2k #00 EQU ,&loop JCN ( bound* pos-2* [i*] ) + POP2 POP2 POP2r ( ) + #01 .dirty? STZ JMP2r ( ) + @insert-n-spaces ( n* -> ) STH2 ( [n*] ) .irm LDZ #00 EQU ,&replace JCN ( [n*] ) @@ -645,9 +663,10 @@ ( starts below current line ) @delete-n-lines ( n* -> ) -( ;limit-addr JSR2 ;eol-addr JSR2 ) - POP2 - JMP2r + .col-bytes LDZ2 MUL2 STH2 ( [n*] ) + ;limit-addr JSR2 STH2kr SUB2 ( limit* [n*] ) + ;eol-addr JSR2 ( limit* start* [n*] ) + ,delete-n-chars/loop JMP @scroll ;limit-addr JSR2 STH2