This commit is contained in:
~d6 2023-01-25 23:37:56 -05:00
parent 53241a06a2
commit 68505fcadf
3 changed files with 113 additions and 12 deletions

1
BUGS
View File

@ -5,3 +5,4 @@
5. line editing after M-a has issues
6. log more control codes
7. shift text to right when inserting
8. when running links (duckduckgo -> varvara), return stack underflow

29
term.c Normal file
View File

@ -0,0 +1,29 @@
#include <pty.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <unistd.h>
int main(int argc, char **argv) {
if (argc < 2) {
printf("usage: %s ROM\n", argv[0]);
return 1;
}
char *rom = argv[1];
int fd = -1;
pid_t pid = forkpty(&fd, NULL, NULL, NULL);
if (pid == 0) {
// child
setenv("TERM", "ansi", 1);
execlp("bash", "bash");
} else {
// parent
char *argp = {0, 40, 0, 79, 0, 8, 0, 8}; // HHHH: height, width, 8, 8
ioctl(fd, TIOCSWINSZ, argp);
dup2(fd, STDIN);
dup2(dup(fd), STDOUT);
execlp("uxnemu", "uxnemu", rom);
}
}

View File

@ -3,6 +3,9 @@
( 2. support attributes (inverse, bold, dim) )
( 3. add more ansi control seqs )
( 4. log ESC [ ? x ; ... $c )
( 5. need draw-line word, and need to use it more )
( a. on delete, CSI-P )
( b. on insert )
( ANSI sequences )
( )
@ -31,8 +34,15 @@
( show cursor: ESC [ ? 25 h )
( hide cursor: ESC [ ? 25 l )
( insert lines: ESC [ $n L )
( ESC \) )
( 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 )
( delete n characters: ESC [ n P )
( insert n blank characters: ESC [ n @ )
|00 @System [ &vect $2 &pad $6 &r $2 &g $2 &b $2 ]
|10 @Console [ &vect $2 &r $1 &pad $5 &w $1 ]
@ -90,9 +100,10 @@
;on-key .Controller/vect DEO2 ( set up keyboard )
;on-read .Console/vect DEO2 ( set up stdin )
( ( set up debug log )
#99 #010e DEO
( set up debug log )
;debug .File/name DEO2
#01 .File/append DEO )
#01 .File/append DEO
BRK
@ -233,6 +244,7 @@
BRK
@on-read-csi ( -> )
#010e DEO
.Console/r DEI
DUP LIT "? EQU ;start-priv JCN2
DUP LIT "; EQU ;next-arg JCN2
@ -240,8 +252,39 @@
DUP LIT "9 GTH ;end-arg JCN2
;add-to-arg JMP2
@debug-arg ( n* -> )
&short SWP ,&byte JSR
&byte DUP #04 SFT ,&char JSR
&char #0f AND DUP #09 GTH #27 MUL ADD #30 ADD ;scratch-write JSR2
JMP2r
@debug-args ( -> )
;args/pos LDA2 ;args
&loop
#20 ;scratch-write JSR2
LDA2k ;debug-arg/short JSR2 INC2 INC2
LTH2k ,&done JCN ,&loop JMP
&done POP2 POP2 JMP2r
@debug-priv ( c^ -> )
;scratch STH2
;reset-scratch JSR2
;scratch-write STH2
LIT "1 STH2kr JSR2
LIT "b STH2kr JSR2
#20 STH2kr JSR2
LIT "[ STH2kr JSR2
#20 STH2kr JSR2
LIT "? STH2kr JSR2
;debug-args JSR2
#20 STH2kr JSR2
STH2kr JSR2
#0a STH2r JSR2
;scratch-len JSR2 .File/len DEO2
;scratch .File/w DEO2
JMP2r
( ;scratch STH2
LIT "1 STH2kr STA INC2r
LIT "b STH2kr STA INC2r
#20 STH2kr STA INC2r
@ -254,16 +297,29 @@
#0a STH2r STA
#0009 .File/len DEO2
;scratch .File/w DEO2
JMP2r
JMP2r )
@end-arg-priv ( c^ -> )
;on-read .Console/vect DEO2
( DUP ,debug-priv JSR )
DUP ,debug-priv JSR
( TODO: handle these )
POP BRK
@debug-csi ( c^ -> )
;scratch STH2
;reset-scratch JSR2
;scratch-write STH2
LIT "1 STH2kr JSR2
LIT "b STH2kr JSR2
#20 STH2kr JSR2
LIT "[ STH2kr JSR2
;debug-args JSR2
#20 STH2kr JSR2
STH2kr JSR2
#0a STH2r JSR2
;scratch-len JSR2 .File/len DEO2
;scratch .File/w DEO2
JMP2r
( ;scratch STH2
LIT "1 STH2kr STA INC2r
LIT "b STH2kr STA INC2r
#20 STH2kr STA INC2r
@ -273,14 +329,14 @@
#0a STH2r STA
#0007 .File/len DEO2
;scratch .File/w DEO2
JMP2r
JMP2r )
@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-noop JCN2 ( enable line wrap )
DUP LIT "l EQU ;exec-noop JCN2 ( disable line wrap )
DUP LIT "h EQU ;exec-set-mode JCN2 ( enable line wrap )
DUP LIT "l EQU ;exec-reset-mode JCN2 ( disable line wrap )
DUP LIT "m EQU ;exec-set-attr JCN2 ( set attr )
DUP LIT "n EQU ;exec-status JCN2 ( get status )
DUP LIT "A EQU ;exec-up JCN2 ( up )
@ -297,6 +353,13 @@
@exec-noop ( c^ -> )
POP BRK
( set mode )
( TODO: insert/replace, line wrap, etc. )
@exec-set-mode ( c^ -> )
POP BRK
@exec-reset-mode ( c^ -> )
POP BRK
@read-attr ( attr* -> )
DUP2 #0000 NEQ2 ,&!0 JCN #02 .attr STZ ,&done JMP ( reset )
&!0 DUP2 #0001 NEQ2 ,&!1 JCN #03 ,&set-fg JMP ( bright )
@ -415,7 +478,7 @@
@on-read-esc ( -> )
.Console/r DEI LIT "[ EQU ;start-csi JCN2
( .Console/r DEI ,debug-esc JSR )
.Console/r DEI ,debug-esc JSR
;on-read .Console/vect DEO2
;on-read JMP2
@ -589,7 +652,15 @@
POPr POP2 POP2 JMP2r
@debug "debug_term.log 00
@scratch $40
@scratch $40 &pos $2
@scratch-write ( c^ -> )
;scratch/pos LDA2 STA
;scratch/pos LDA2k INC2 SWP2 STA2 JMP2r
@scratch-len ( -> n* )
;scratch/pos LDA2 ;scratch SUB2 JMP2r
@reset-scratch
;scratch ;scratch/pos STA2 JMP2r
( store up to 8 arguments for control sequences )
@args $10 &pos $2