diff --git a/term.tal b/term.tal index 8b589f0..69fb391 100644 --- a/term.tal +++ b/term.tal @@ -121,8 +121,8 @@ ( user configuration ) @debug $1 ( use debug log? ) @show-banner $1 ( show banner on startup? ) - @visual-bell $1 ( flash visual bell? otherwise do nothing ) - @border-pad $2 ( use border? should be 0000 or 0010 ) + @visual-bell $1 ( use visual belL? 01: visual bell, 00: do nothing ) + @border-pad $2 ( use border? must be either 0000 or 0010 ) |0100 ( metadata ) @@ -132,7 +132,6 @@ ( user configuration defaults ) #00 .debug STZ #01 .show-banner STZ -( #0010 .border-pad STZ2 ) #0000 .border-pad STZ2 #01 .visual-bell STZ @@ -183,8 +182,7 @@ @reset-terminal ( -> ) ( set initial cursor ) - #0000 .cur-x STZ2 - #0000 .cur-y STZ2 + #0000 DUP2 .cur-x STZ2 .cur-y STZ2 ( confirm no buttons pressed yet ) #00 .lastkey STZ @@ -193,8 +191,7 @@ update-dimensions ( set starting tint: reverse=0, bg=0, fg=2 ) - #02 .attr STZ - update-tint + #02 .attr STZ update-tint ( set initial modes ) #00 .irm STZ ( insert and move right ) @@ -202,11 +199,8 @@ #01 .tcem STZ ( show cursor ) #00 .paste STZ ( bracketed paste is off ) - ( prepare for initial draw ) - init-screen - - ( draw border ) - .border-pad LDZ2 ORA ?draw-border + init-screen ( ; prepare for initial draw ) + draw-border ( ; draw border ) JMP2r @update-dimensions ( -> ) @@ -290,6 +284,7 @@ .Screen/y DEO2 JMP2r ( ; s/y<-y ) @draw-border ( -> ) + .border-pad LDZ2 ORA ?{ JMP2r } ;cp437/space .Screen/addr DEO2 #04 .Screen/sprite #0000 draw-border/row @@ -752,41 +747,51 @@ @end-arg ( c^ -> BRK ) ;on-read .Console/vect DEO2 DUP debug-csi - DUP LIT "@ EQU ?exec-ich ( insert blank characters ) - DUP LIT "A EQU ?exec-cuu ( up ) - DUP LIT "B EQU ?exec-cud ( down ) - DUP LIT "C EQU ?exec-cuf ( forward ) - DUP LIT "D EQU ?exec-cub ( back ) - DUP LIT "E EQU ?exec-cnl ( next line $n times ) - DUP LIT "F EQU ?exec-cpl ( prev line $n times ) - DUP LIT "G EQU ?exec-cha ( move cursor to col ) - DUP LIT "H EQU ?exec-cup ( move cursor ) - DUP LIT "I EQU ?exec-cht ( forward by tab stops ) - DUP LIT "J EQU ?exec-ed ( erase screen ) - DUP LIT "K EQU ?exec-el ( erase line ) - DUP LIT "L EQU ?exec-il ( insert blank lines ) - DUP LIT "M EQU ?exec-dl ( delete n lines ) - DUP LIT "P EQU ?exec-dch ( delete n chars ) - DUP LIT "S EQU ?exec-su ( scroll up ) - DUP LIT "T EQU ?exec-sd ( scroll down ) - DUP LIT "X EQU ?exec-ech ( erase $n characters ) - DUP LIT "Z EQU ?exec-cbt ( backward by tab stops ) - DUP LIT "` EQU ?exec-hpa ( char pos abs col=$n ) - DUP LIT "a EQU ?exec-hpr ( char pos rel col=$n ) - DUP LIT "d EQU ?exec-vpa ( move cursor to row ) - DUP LIT "e EQU ?exec-vpr ( line pos rel row+=$n ) - DUP LIT "g EQU ?exec-tbc ( clear tab stops ) - DUP LIT "h EQU ?exec-sm ( set mode ) - DUP LIT "l EQU ?exec-rm ( reset mode ) - DUP LIT "m EQU ?exec-sgr ( set graphical rendering ) - DUP LIT "n EQU ?exec-dsr ( device status reports ) - DUP LIT "r EQU ?exec-set-scrolling-region - DUP LIT "s EQU ?exec-scosc ( saved current cursor position ) - DUP LIT "u EQU ?exec-scorc ( restore saved cursor position ) + DUP LIT "@ EQU ?exec-ich ( ICH: insert blank characters ) + ( TODO ($n-sp-@) SL: shift left $n cols ) + DUP LIT "A EQU ?exec-cuu ( CUU: up ) + ( TODO ($n-sp-A) SR: shift right $n cols ) + DUP LIT "B EQU ?exec-cud ( CUD: down ) + DUP LIT "C EQU ?exec-cuf ( CUF: forward ) + DUP LIT "D EQU ?exec-cub ( CUB: back ) + DUP LIT "E EQU ?exec-cnl ( CNL: next line $n times ) + DUP LIT "F EQU ?exec-cpl ( CPL: prev line $n times ) + DUP LIT "G EQU ?exec-cha ( CHA: move cursor to abs col ) + DUP LIT "H EQU ?exec-cup ( CUP: move cursor [row;col] ) + DUP LIT "I EQU ?exec-cht ( CHT: forward by tab stops ) + DUP LIT "J EQU ?exec-ed ( ED: erase display ) + DUP LIT "K EQU ?exec-el ( EL: erase line ) + DUP LIT "L EQU ?exec-il ( IL: insert $n blank lines ) + DUP LIT "M EQU ?exec-dl ( DL: delete $n lines ) + DUP LIT "P EQU ?exec-dch ( DCH: delete n chars ) + DUP LIT "S EQU ?exec-su ( SU: scroll up ) + DUP LIT "T EQU ?exec-sd ( SD: scroll down ) + DUP LIT "X EQU ?exec-ech ( ECH: erase $n characters ) + DUP LIT "Z EQU ?exec-cbt ( CBT: backward by tab stops ) + DUP LIT "` EQU ?exec-hpa ( HPA: char pos abs col=$n ) + DUP LIT "a EQU ?exec-hpr ( HPR: char pos rel col=$n ) + ( TODO: b - REP: repeat previous graphic char $n times ) + ( TODO: c - DA: send device attributes ) + DUP LIT "d EQU ?exec-vpa ( VPA: move cursor to row ) + DUP LIT "e EQU ?exec-vpr ( VPR: line pos rel row+=$n ) + ( TODO: $r;$c f - HVP: horizontal/vertical position ) + DUP LIT "g EQU ?exec-tbc ( TBC: clear tab stops ) + DUP LIT "h EQU ?exec-sm ( SM: set mode ) + ( TODO: ?-$n-h - DECSET: set dec options ) + DUP LIT "l EQU ?exec-rm ( RM: reset mode ) + ( TODO: ?-$n-l - DECRST: reset dec options ) + DUP LIT "m EQU ?exec-sgr ( SGR: set graphical rendering ) + DUP LIT "n EQU ?exec-dsr ( DSR: device status reports ) + ( TODO: ?-$n-n - dec device status ) + ( TODO: $n-q - DECLL: load leds ) + DUP LIT "r EQU ?exec-set-scrolling-region ( [$top;$bot] DECSTM: set scrolling reg ) + DUP LIT "s EQU ?exec-scosc ( SCOSC: saved current cursor position ) + DUP LIT "u EQU ?exec-scorc ( SCORC: restore saved cursor position ) ( = 0 C - normal cursor ) ( = 1 C - bold cursor ) debug-csi BRK +( TODO ) @exec-set-scrolling-region ( c^ -> BRK ) POP BRK @exec-tbc ( c^ -> BRK ) POP BRK @@ -950,18 +955,24 @@ @on-read-esc ( -> BRK ) .Console/r DEI DUP debug-esc - DUP LIT "D EQU ?exec-ind - DUP LIT "E EQU ?exec-nel - DUP LIT "H EQU ?exec-hts - DUP LIT "M EQU ?exec-ri - DUP LIT "P EQU ?exec-dcs - DUP LIT "[ EQU ?start-csi - DUP LIT "] EQU ?start-osc - DUP LIT "c EQU ?exec-ris + &after + ( TODO: SP-F, SP-G, SP-L, SP-M, SP-N ) + ( TODO: #-3, #-4, #-5, #-6, #-8 ) + ( TODO: %-@, %-G ) + DUP LIT "D EQU ?exec-ind ( IND: index ) + DUP LIT "E EQU ?exec-nel ( NEL: next line ) + DUP LIT "H EQU ?exec-hts ( HTS: tab set ) + DUP LIT "M EQU ?exec-ri ( RI: reverse index ) + DUP LIT "P EQU ?exec-dcs ( DCS: device control string ) + DUP LIT "[ EQU ?start-csi ( CSI: control sequence introducer ) + DUP LIT "] EQU ?start-osc ( OSC: operating system command ) + DUP LIT "c EQU ?exec-ris ( RIS: full reset ) DUP LIT "( EQU ?start-charset DUP LIT ") EQU ?start-charset - DUP LIT "7 EQU ?&skip ( save cursor ) - DUP LIT "8 EQU ?&skip ( restore cursor ) + DUP LIT "7 EQU ?&skip ( DECSC: save cursor ) + DUP LIT "8 EQU ?&skip ( DECRC: restore cursor ) + DUP LIT "> EQU ?&skip ( DECKPNM: normal keypad ) + DUP LIT "~ EQU ?&skip ( LS1R: invoke G1 charset as GR ) debug-esc ;on-read .Console/vect DEO2 !on-read @@ -981,10 +992,10 @@ ;on-read .Console/vect DEO2 BRK -( '(' = designate G0 charset ) -( ')' = designate G1 charset ) -( '*' = designate G2 charset ) -( '+' = designate G3 charset ) +( preceeded by '(' [G0] or ')' [G1] ) +( "A" -> UK ) +( "B" -> USASCII ) +( "0" -> DEC special character, line drawing ) @start-charset ( c^ -> BRK ) POP ;on-read-skip .Console/vect DEO2 BRK @@ -994,8 +1005,12 @@ @start-osc ( c^ -> BRK ) POP reset-args ;on-read-osc .Console/vect DEO2 BRK +( TODO: 8-bit input not ready for prime time yet ) @on-read ( -> BRK ) - .Console/r DEI read BRK + .Console/r DEI ( DUP #7f GTH ?read-8bit ) read BRK + +@read-8bit ( c^ -> BRK ) + DUP debug-esc #80 SUB !on-read-esc/after @read ( c^ -> ) DUP debug-read @@ -1011,21 +1026,25 @@ clear-cursor !forward @read-ctrl ( c^ -> ) + DUP #05 EQU ?&skip ( ENQ - return terminal status ) DUP #07 EQU ?read-bel DUP #08 EQU ?read-bs - DUP #09 EQU ?read-tab - DUP #0a EQU ?read-lf - DUP #0b EQU ?read-lf - DUP #0c EQU ?read-lf - DUP #0d EQU ?read-cr + DUP #09 EQU ?read-tab ( HT ) + DUP #0a EQU ?read-lf ( NL - LF ) + DUP #0b EQU ?read-lf ( VT - treated as LF ) + DUP #0c EQU ?read-lf ( FF - treated as LF ) + DUP #0d EQU ?read-cr ( CR ) +( DUP #0e EQU ?&skip ( TODO: SO - shift out; G0 charset ) ) +( DUP #0f EQU ?&skip ( TODO: SI - shift in; G1 charset ) ) DUP #1b EQU ?read-esc - POP JMP2r + &skip POP JMP2r @read-bel ( 07 -> ) POP .visual-bell LDZ #00 EQU ?&done #06 .flash STZ #01 .dirty STZ &done JMP2r +( TODO: handle reverse wrap-around and dec auto-wrap ) @read-bs ( 08 -> ) POP clear-cursor #0001 !back-n @@ -1035,6 +1054,7 @@ @read-del ( 7f -> ) POP JMP2r +( TODO: respect tab stops ) @read-tab ( 09 -> ) POP .cur-x LDZ2 ( x* )