2023-12-01 20:29:21 -05:00
|
|
|
|00 @System [
|
|
|
|
&vector $2 &expansion $2 &title $2 &metadata $2
|
|
|
|
&red $2 &green $2 &blue $2 &debug $1 &exit $1 ]
|
|
|
|
|
2023-12-01 12:19:26 -05:00
|
|
|
|10 @Console [
|
|
|
|
&vector $2 &stdin $1 &pad1 $1 &proc-get $1 &host-get $1 &pad2 $1 &type $1
|
2023-12-01 20:29:21 -05:00
|
|
|
&stdout $1 &stderr $1 &proc-put $1 &pad3 $1 ¶m $2 &opts $1 &host-put $1 ]
|
2023-12-01 12:19:26 -05:00
|
|
|
|
|
|
|
|0100 ( -- BRK )
|
|
|
|
;on-console .Console/vector DEO2 ( ; set up console vector callback )
|
|
|
|
BRK ( ; do other initialization )
|
|
|
|
|
|
|
|
@on-console ( -- BRK )
|
|
|
|
.Console/type DEI #81 EQU ?on-exit ( ; 0x41 signals child 1's exit )
|
|
|
|
.Console/type DEI #01 EQU ?on-stdin ( ; handle stdin )
|
|
|
|
BRK ( ; handle other console input )
|
|
|
|
|
|
|
|
@on-exit ( -- BRK )
|
|
|
|
.Console/host-get DEI ( ; read child 1's exit code )
|
|
|
|
?{ display-success-msg BRK } ( ; zero exit code means success )
|
|
|
|
display-failure-msg BRK ( ; non-zero exit code means failure )
|
|
|
|
|
2023-12-01 20:29:21 -05:00
|
|
|
@on-stdin
|
|
|
|
.Console/stdin DEI DUP #0a NEQ ?parse ( c^ ; parse input char if not newline )
|
|
|
|
POP LIT [ &q $1 ] ?exit ( ; exit if last char was 'q' )
|
|
|
|
;make-cmd .Console/param DEO2 ( ; set up make to run )
|
|
|
|
#01 .Console/opts DEO ( ; use child 1 without pipelines )
|
|
|
|
#01 .Console/host-put DEO BRK ( ; run the command now and return )
|
|
|
|
|
|
|
|
@parse ( c^ -> BRK )
|
|
|
|
LIT "q EQU ,on-stdin/q STR BRK
|
|
|
|
|
|
|
|
@exit ( -> BRK )
|
|
|
|
#80 .System/exit DEO BRK
|
2023-12-01 12:19:26 -05:00
|
|
|
|
2023-12-01 20:29:21 -05:00
|
|
|
@make-cmd "make 00 ( ; buffer containing cmd to run )
|
2023-12-01 12:19:26 -05:00
|
|
|
|
|
|
|
@display-success-msg
|
|
|
|
LIT ". .Console/stdout DEO
|
|
|
|
#0a .Console/stdout DEO JMP2r
|
|
|
|
|
|
|
|
@display-failure-msg
|
|
|
|
LIT "! .Console/stdout DEO
|
|
|
|
#0a .Console/stdout DEO JMP2r
|