(console.tal) Added input type port to example
This commit is contained in:
parent
fbba9b304d
commit
a9527fbd95
|
@ -1,7 +1,7 @@
|
|||
( Console:
|
||||
( usage: uxncli console.rom arg1 arg2 arg3
|
||||
Prints Hello Uxn!, and listens for incoming stdin events on enter. )
|
||||
|
||||
|10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $1
|
||||
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
|
||||
|
||||
|00
|
||||
|
||||
|
@ -10,38 +10,72 @@
|
|||
|0100 ( -> )
|
||||
|
||||
( set vector )
|
||||
;on-console .Console/vector DEO2
|
||||
;on-argument .Console/vector DEO2
|
||||
( print hello )
|
||||
;hello-txt print-str
|
||||
;hello-txt pstr
|
||||
|
||||
BRK
|
||||
|
||||
@on-console ( -> )
|
||||
@on-argument ( -> )
|
||||
|
||||
.Console/read DEI .buf skey ?eval
|
||||
.Console/type DEI ?&no-argend
|
||||
;on-stdin .Console/vector DEO2
|
||||
BRK
|
||||
&no-argend
|
||||
.Console/read DEI .buf skey ?&eval
|
||||
|
||||
BRK
|
||||
|
||||
@eval ( -> )
|
||||
&eval ( -> )
|
||||
|
||||
;buf
|
||||
DUP2 ;quit-txt scmp ?quit
|
||||
|
||||
;yousaid-txt print-str
|
||||
print-type
|
||||
;yousent-txt pstr
|
||||
LIT "" #18 DEO
|
||||
DUP2 print-str
|
||||
;buf pstr
|
||||
LIT "" #18 DEO #0a18 DEO
|
||||
sclr
|
||||
;buf sclr
|
||||
|
||||
.Console/type DEI #04 NEQ ?&no-close
|
||||
;argend-txt pstr
|
||||
;on-stdin .Console/vector DEO2
|
||||
&no-close
|
||||
|
||||
BRK
|
||||
|
||||
@on-stdin ( -> )
|
||||
|
||||
.Console/read DEI .buf skey ?&eval
|
||||
|
||||
BRK
|
||||
|
||||
&eval ( -> )
|
||||
|
||||
print-type
|
||||
;buf ;quit-txt scmp ?quit
|
||||
;yousaid-txt pstr
|
||||
LIT "" #18 DEO
|
||||
;buf pstr
|
||||
LIT "" #18 DEO #0a18 DEO
|
||||
;buf sclr
|
||||
|
||||
BRK
|
||||
|
||||
@print-type ( -- )
|
||||
|
||||
[ LIT2 00 -Console/type ] DEI #01 GTH DUP ADD ;types ADD2 LDA2
|
||||
|
||||
!pstr
|
||||
|
||||
@quit ( buf* -> )
|
||||
|
||||
POP2 #010f DEO
|
||||
|
||||
BRK
|
||||
|
||||
@print-str ( str* -- )
|
||||
(
|
||||
@|stdlib )
|
||||
|
||||
@pstr ( str* -- )
|
||||
|
||||
&while
|
||||
LDAk #18 DEO
|
||||
|
@ -55,8 +89,20 @@ JMP2r
|
|||
@scap ( str* -- end* ) LDAk ?&w JMP2r &w INC2 LDAk ?&w JMP2r
|
||||
@sput ( chr str* -- ) scap INC2k #00 ROT ROT STA STA JMP2r
|
||||
@scmp ( a* b* -- f ) STH2 &l LDAk LDAkr STHr ANDk #00 EQU ?&e NEQk ?&e POP2 INC2 INC2r !&l &e NIP2 POP2r EQU JMP2r
|
||||
@phex ( short* -- ) SWP phex/b &b ( byte -- ) DUP #04 SFT phex/c &c ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO JMP2r
|
||||
|
||||
(
|
||||
@|assets )
|
||||
|
||||
@types
|
||||
=std-txt
|
||||
=arg-txt
|
||||
|
||||
@hello-txt "Welcome 20 "to 20 "Uxn! 0a $1
|
||||
@yousaid-txt "You 20 "said: 20 $1
|
||||
@yousent-txt "You 20 "sent: 20 $1
|
||||
@std-txt "(std) $1
|
||||
@arg-txt "(arg) $1
|
||||
@quit-txt "quit $1
|
||||
@argend-txt "(argend) 0a $1
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ main(int argc, char **argv)
|
|||
for(i = 2; i < argc; i++) {
|
||||
char *p = argv[i];
|
||||
while(*p) console_input(&u, *p++, CONSOLE_ARG);
|
||||
console_input(&u, '\n', CONSOLE_EOA);
|
||||
console_input(&u, '\n', i == argc-1 ? CONSOLE_END : CONSOLE_EOA);
|
||||
}
|
||||
while(!u.dev[0x0f]) {
|
||||
int c = fgetc(stdin);
|
||||
|
|
Loading…
Reference in New Issue