screen clearing mostly working

This commit is contained in:
~d6 2023-01-23 16:26:08 -05:00
parent 7c14b78e6d
commit 31294ca6e7
2 changed files with 46 additions and 29 deletions

10
term.py
View File

@ -26,8 +26,9 @@ def main():
if pid == 0: if pid == 0:
# set TERM to something we can handle # set TERM to something we can handle
env = dict(os.environ) env = dict(os.environ)
env['TERM'] = 'dumb' #env['TERM'] = 'dumb'
os.execvpe('bash', ['bash', '--noediting', '-i'], env) env['TERM'] = 'ansi'
os.execvpe('bash', ['bash'], env)
else: else:
# set the terminal size # set the terminal size
#cols, rows = 63, 32 #cols, rows = 63, 32
@ -35,11 +36,6 @@ def main():
size = struct.pack("HHHH", rows, cols, 8, 8) size = struct.pack("HHHH", rows, cols, 8, 8)
fcntl.ioctl(fd, termios.TIOCSWINSZ, size) fcntl.ioctl(fd, termios.TIOCSWINSZ, size)
## disable terminal echo
#attr = termios.tcgetattr(fd)
#attr[3] = attr[3] & ~termios.ECHO
#termios.tcsetattr(fd, termios.TCSADRAIN, attr)
# use fd for the terminals stdin/stdout # use fd for the terminals stdin/stdout
os.dup2(fd, sys.stdin.fileno()) os.dup2(fd, sys.stdin.fileno())
os.dup2(os.dup(fd), sys.stdout.fileno()) os.dup2(os.dup(fd), sys.stdout.fileno())

View File

@ -67,14 +67,20 @@
( return ) ( return )
BRK BRK
@first-addr ( -> )
;screen JMP2r
@bol-addr ( -> addr* ) @bol-addr ( -> addr* )
.cols LDZ2 .cur-y LDZ2 MUL2 JMP2r .cols LDZ2 .cur-y LDZ2 MUL2 ;screen ADD2 JMP2r
@cur-addr ( -> addr* ) @cur-addr ( -> addr* )
;bol-addr JSR2 .cur-x LDZ2 ADD2 JMP2r ;bol-addr JSR2 .cur-x LDZ2 ADD2 JMP2r
@eol-addr ( -> addr* ) @eol-addr ( -> addr* )
.cols LDZ2 .cur-y LDZ2 INC2 MUL2 JMP2r .cols LDZ2 .cur-y LDZ2 INC2 MUL2 ;screen ADD2 JMP2r
@last-addr ( -> )
.cols LDZ2 .rows LDZ2 MUL2 ;screen ADD2 JMP2r
@min ( x* y* -> min* ) @min ( x* y* -> min* )
LTH2k JMP SWP2 POP2 JMP2r LTH2k JMP SWP2 POP2 JMP2r
@ -178,9 +184,9 @@
DUP LIT "A EQU ;exec-up JCN2 ( up ) DUP LIT "A EQU ;exec-up JCN2 ( up )
DUP LIT "B EQU ;exec-down JCN2 ( down ) DUP LIT "B EQU ;exec-down JCN2 ( down )
DUP LIT "C EQU ;exec-forward JCN2 ( forward ) DUP LIT "C EQU ;exec-forward JCN2 ( forward )
DUP LIT "D EQU ;exec-back JCN2 ( back ) DUP LIT "D EQU ;exec-back JCN2 ( back )
DUP LIT "J EQU ;exec-erase-line JCN2 ( erase line ) DUP LIT "J EQU ;exec-erase-screen JCN2 ( erase screen )
DUP LIT "K EQU ;exec-noop JCN2 ( erase screen ) DUP LIT "K EQU ;exec-erase-line JCN2 ( erase line )
POP BRK POP BRK
@exec-noop ( c^ -> ) @exec-noop ( c^ -> )
@ -212,30 +218,41 @@
DUP2 #0001 EQU2 ,&erase-from-start JCN DUP2 #0001 EQU2 ,&erase-from-start JCN
DUP2 #0002 EQU2 ,&erase-full JCN DUP2 #0002 EQU2 ,&erase-full JCN
POP2 BRK POP2 BRK
( #010f DEO BRK ( FIXME ) )
&erase-full &erase-full
POP2 ;bol-addr JSR2 ;eol-addr JSR2 ;erase JSR2 BRK POP2 ;bol-addr JSR2 ;eol-addr JSR2 ;erase JSR2 BRK
&erase-to-end &erase-to-end
POP2 ;cur-addr JSR2 INC2 ;eol-addr JSR2 ;erase JSR2 BRK POP2 ;cur-addr JSR2 ;eol-addr JSR2 ;erase JSR2 BRK
&erase-from-start &erase-from-start
POP2 ;bol-addr JSR2 ;cur-addr JSR2 INC2 ;erase JSR2 BRK POP2 ;bol-addr JSR2 ;cur-addr JSR2 ;erase JSR2 BRK
@exec-erase-screen
POP #0000 ;read-arg-1 JSR2
DUP2 #0000 EQU2 ,&erase-to-end JCN
DUP2 #0001 EQU2 ,&erase-from-start JCN
DUP2 #0002 EQU2 ,&erase-full JCN
POP2 BRK
&erase-full
POP2 ;first-addr JSR2 ;last-addr JSR2 ;erase JSR2 BRK
&erase-to-end
POP2 ;bol-addr JSR2 ;last-addr JSR2 ;erase JSR2 BRK
&erase-from-start
POP2 ;first-addr JSR2 ;eol-addr JSR2 ;erase JSR2 BRK
( TODO: needs to be smarter -- need to redraw tiles and keep x/y coords ) ( TODO: needs to be smarter -- need to redraw tiles and keep x/y coords )
@erase ( start* end* -> ) @erase ( start* end* -> )
OVR2 SWP2 SUB2 STH2 ( start* [count*] ) OVR2 SWP2 SUB2 STH2 ( start* [count=start-end*] )
#20 ROT ROT ( 20 start* [count*] ) #20 ROT ROT ( 20 start* [count*] )
&loop &loop ( 20 addr* [i*] )
STAk INC2r STAk INC2 INC2r ( 20 addr+1* [i+1*] )
STH2kr ORA ,&loop JCN ORAkr STHr ,&loop JCN ( 20 addr* [i+1*] )
POP2r POP2 POP POP2r POP2 POP ( )
#01 .dirty? STZ ( FIXME ) #01 .dirty? STZ ( ; FIXME just redraw affected tiles )
JMP2r JMP2r ( )
@exec-move ( c^ -> ) @exec-move ( c^ -> )
POP LIT2r ffff POP
#0001 ;read-arg-1 JSR2 STH2kr ADD2 ( row ) #0001 ;read-arg-1 JSR2 #0001 SUB2 ( row )
#0001 ;read-arg-2 JSR2 STH2r ADD2 ( col ) #0001 ;read-arg-2 JSR2 #0001 SUB2 ( col )
;goto JSR2 BRK ;goto JSR2 BRK
@on-read-esc ( -> ) @on-read-esc ( -> )
@ -271,7 +288,11 @@
POP JMP2r ( TODO: flash terminal ) POP JMP2r ( TODO: flash terminal )
@read-bs ( 08 -> ) @read-bs ( 08 -> )
POP JMP2r ( POP ;scroll JMP2 ) POP
;hide-cursor JSR2
#0001 ;back-n JSR2
;show-cursor JSR2
JMP2r
@read-esc ( 1b -> ) @read-esc ( 1b -> )
POP ;on-read-esc .Console/vect DEO2 BRK POP ;on-read-esc .Console/vect DEO2 BRK