screen clearing mostly working
This commit is contained in:
parent
7c14b78e6d
commit
31294ca6e7
10
term.py
10
term.py
|
@ -26,8 +26,9 @@ def main():
|
|||
if pid == 0:
|
||||
# set TERM to something we can handle
|
||||
env = dict(os.environ)
|
||||
env['TERM'] = 'dumb'
|
||||
os.execvpe('bash', ['bash', '--noediting', '-i'], env)
|
||||
#env['TERM'] = 'dumb'
|
||||
env['TERM'] = 'ansi'
|
||||
os.execvpe('bash', ['bash'], env)
|
||||
else:
|
||||
# set the terminal size
|
||||
#cols, rows = 63, 32
|
||||
|
@ -35,11 +36,6 @@ def main():
|
|||
size = struct.pack("HHHH", rows, cols, 8, 8)
|
||||
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
|
||||
os.dup2(fd, sys.stdin.fileno())
|
||||
os.dup2(os.dup(fd), sys.stdout.fileno())
|
||||
|
|
65
term.tal
65
term.tal
|
@ -67,14 +67,20 @@
|
|||
( return )
|
||||
BRK
|
||||
|
||||
@first-addr ( -> )
|
||||
;screen JMP2r
|
||||
|
||||
@bol-addr ( -> addr* )
|
||||
.cols LDZ2 .cur-y LDZ2 MUL2 JMP2r
|
||||
.cols LDZ2 .cur-y LDZ2 MUL2 ;screen ADD2 JMP2r
|
||||
|
||||
@cur-addr ( -> addr* )
|
||||
;bol-addr JSR2 .cur-x LDZ2 ADD2 JMP2r
|
||||
|
||||
@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* )
|
||||
LTH2k JMP SWP2 POP2 JMP2r
|
||||
|
@ -178,9 +184,9 @@
|
|||
DUP LIT "A EQU ;exec-up JCN2 ( up )
|
||||
DUP LIT "B EQU ;exec-down JCN2 ( down )
|
||||
DUP LIT "C EQU ;exec-forward JCN2 ( forward )
|
||||
DUP LIT "D EQU ;exec-back JCN2 ( back )
|
||||
DUP LIT "J EQU ;exec-erase-line JCN2 ( erase line )
|
||||
DUP LIT "K EQU ;exec-noop JCN2 ( erase screen )
|
||||
DUP LIT "D EQU ;exec-back JCN2 ( back )
|
||||
DUP LIT "J EQU ;exec-erase-screen JCN2 ( erase screen )
|
||||
DUP LIT "K EQU ;exec-erase-line JCN2 ( erase line )
|
||||
POP BRK
|
||||
|
||||
@exec-noop ( c^ -> )
|
||||
|
@ -212,30 +218,41 @@
|
|||
DUP2 #0001 EQU2 ,&erase-from-start JCN
|
||||
DUP2 #0002 EQU2 ,&erase-full JCN
|
||||
POP2 BRK
|
||||
( #010f DEO BRK ( FIXME ) )
|
||||
&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
|
||||
POP2 ;cur-addr JSR2 INC2 ;eol-addr JSR2 ;erase JSR2 BRK
|
||||
POP2 ;cur-addr JSR2 ;eol-addr JSR2 ;erase JSR2 BRK
|
||||
&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 )
|
||||
|
||||
@erase ( start* end* -> )
|
||||
OVR2 SWP2 SUB2 STH2 ( start* [count*] )
|
||||
#20 ROT ROT ( 20 start* [count*] )
|
||||
&loop
|
||||
STAk INC2r
|
||||
STH2kr ORA ,&loop JCN
|
||||
POP2r POP2 POP
|
||||
#01 .dirty? STZ ( FIXME )
|
||||
JMP2r
|
||||
OVR2 SWP2 SUB2 STH2 ( start* [count=start-end*] )
|
||||
#20 ROT ROT ( 20 start* [count*] )
|
||||
&loop ( 20 addr* [i*] )
|
||||
STAk INC2 INC2r ( 20 addr+1* [i+1*] )
|
||||
ORAkr STHr ,&loop JCN ( 20 addr* [i+1*] )
|
||||
POP2r POP2 POP ( )
|
||||
#01 .dirty? STZ ( ; FIXME just redraw affected tiles )
|
||||
JMP2r ( )
|
||||
|
||||
@exec-move ( c^ -> )
|
||||
POP LIT2r ffff
|
||||
#0001 ;read-arg-1 JSR2 STH2kr ADD2 ( row )
|
||||
#0001 ;read-arg-2 JSR2 STH2r ADD2 ( col )
|
||||
POP
|
||||
#0001 ;read-arg-1 JSR2 #0001 SUB2 ( row )
|
||||
#0001 ;read-arg-2 JSR2 #0001 SUB2 ( col )
|
||||
;goto JSR2 BRK
|
||||
|
||||
@on-read-esc ( -> )
|
||||
|
@ -271,7 +288,11 @@
|
|||
POP JMP2r ( TODO: flash terminal )
|
||||
|
||||
@read-bs ( 08 -> )
|
||||
POP JMP2r ( POP ;scroll JMP2 )
|
||||
POP
|
||||
;hide-cursor JSR2
|
||||
#0001 ;back-n JSR2
|
||||
;show-cursor JSR2
|
||||
JMP2r
|
||||
|
||||
@read-esc ( 1b -> )
|
||||
POP ;on-read-esc .Console/vect DEO2 BRK
|
||||
|
|
Loading…
Reference in New Issue