2017-10-20 05:05:43 +02:00
|
|
|
# RETRO
|
|
|
|
|
|
|
|
This is a set of extensions for RRE.
|
|
|
|
|
2018-11-23 21:38:46 +01:00
|
|
|
# I/O Extensions
|
|
|
|
|
2017-10-20 05:05:43 +02:00
|
|
|
# Console Input
|
|
|
|
|
|
|
|
~~~
|
2018-11-23 21:38:46 +01:00
|
|
|
{{
|
|
|
|
'io:Keyboard var
|
|
|
|
:identify
|
|
|
|
@io:Keyboard n:zero? [
|
|
|
|
#1 io:scan-for dup n:negative?
|
|
|
|
[ drop 'IO_DEVICE_TYPE_0001_NOT_FOUND s:put nl ]
|
|
|
|
[ !io:Keyboard ] choose ] if ;
|
|
|
|
---reveal---
|
|
|
|
:c:get (-c) identify @io:Keyboard io:invoke ;
|
|
|
|
}}
|
2017-10-20 05:05:43 +02:00
|
|
|
~~~
|
|
|
|
|
|
|
|
---------------------------------------------------------------
|
|
|
|
|
|
|
|
# Scripting: Command Line Arguments
|
|
|
|
|
2017-10-20 03:16:46 +02:00
|
|
|
~~~
|
2018-11-23 21:38:46 +01:00
|
|
|
{{
|
|
|
|
'io:Scripting var
|
|
|
|
:identify
|
|
|
|
@io:Scripting n:zero? [
|
|
|
|
#9 io:scan-for dup n:negative?
|
|
|
|
[ drop 'IO_DEVICE_TYPE_0009_NOT_FOUND s:put nl ]
|
|
|
|
[ !io:Scripting ] choose ] if ;
|
|
|
|
---reveal---
|
|
|
|
:sys:argc (-n) identify #0 @io:Scripting io:invoke ;
|
|
|
|
:sys:argv (n-s) s:empty swap identify #1 @io:Scripting io:invoke ;
|
|
|
|
:include (s-) identify #2 @io:Scripting io:invoke ;
|
|
|
|
}}
|
2017-10-20 03:16:46 +02:00
|
|
|
~~~
|
|
|
|
|
2017-11-15 20:57:17 +01:00
|
|
|
# Interactive Listener
|
|
|
|
|
|
|
|
~~~
|
2018-11-14 14:52:30 +01:00
|
|
|
'NoEcho var
|
2017-11-15 20:57:17 +01:00
|
|
|
|
|
|
|
{{
|
2018-05-07 18:24:36 +02:00
|
|
|
:version (-) @Version #100 /mod n:put $. c:put n:put ;
|
2017-11-15 20:57:17 +01:00
|
|
|
:eol? (c-f) [ ASCII:CR eq? ] [ ASCII:LF eq? ] [ ASCII:SPACE eq? ] tri or or ;
|
|
|
|
:valid? (s-sf) dup s:length n:-zero? ;
|
2018-11-14 14:52:30 +01:00
|
|
|
:ok (-) @NoEcho not 0; drop compiling? [ nl 'Ok_ s:put ] -if ;
|
2017-11-26 16:20:56 +01:00
|
|
|
:check-eof (c-c) dup [ #-1 eq? ] [ #4 eq? ] bi or [ 'bye d:lookup d:xt fetch call ] if ;
|
2018-04-03 22:45:55 +02:00
|
|
|
:check-bs (c-c) dup [ #8 eq? ] [ #127 eq? ] bi or [ buffer:get buffer:get drop-pair ] if ;
|
2018-05-07 18:24:36 +02:00
|
|
|
:s:get (-s) [ #1025 buffer:set
|
|
|
|
[ c:get dup buffer:add check-eof check-bs eol? ] until
|
|
|
|
buffer:start s:chop ] buffer:preserve ;
|
2017-11-15 20:57:17 +01:00
|
|
|
---reveal---
|
2018-11-14 14:52:30 +01:00
|
|
|
:banner (-) @NoEcho not 0; drop
|
|
|
|
'RETRO_12_(rx- s:put version $) c:put nl
|
2018-05-07 18:24:36 +02:00
|
|
|
EOM n:put '_MAX,_TIB_@_1025,_Heap_@_ s:put here n:put nl ;
|
2018-04-04 18:11:44 +02:00
|
|
|
:bye (-) #0 unix:exit ;
|
2017-11-15 20:57:17 +01:00
|
|
|
:listen (-)
|
2018-05-07 18:24:36 +02:00
|
|
|
ok repeat s:get valid? [ interpret ok ] [ drop ] choose again ;
|
2017-11-15 20:57:17 +01:00
|
|
|
}}
|
2019-01-13 00:30:52 +01:00
|
|
|
|
|
|
|
&listen #1 store
|
2017-11-15 20:57:17 +01:00
|
|
|
~~~
|
2017-11-27 22:53:51 +01:00
|
|
|
|
2017-12-01 03:17:11 +01:00
|
|
|
~~~
|
|
|
|
{{
|
2017-12-01 03:23:12 +01:00
|
|
|
:gather (c-)
|
|
|
|
dup [ #8 eq? ] [ #127 eq? ] bi or [ drop ] [ buffer:add ] choose ;
|
2018-05-07 18:24:36 +02:00
|
|
|
:cycle (q-qc) repeat c:get dup-pair swap call not 0; drop gather again ;
|
2017-12-01 03:17:11 +01:00
|
|
|
---reveal---
|
|
|
|
:parse-until (q-s)
|
|
|
|
[ s:empty buffer:set cycle drop-pair buffer:start ] buffer:preserve ;
|
|
|
|
}}
|
|
|
|
|
2018-05-07 18:24:36 +02:00
|
|
|
:s:get (-s) [ [ ASCII:LF eq? ] [ ASCII:CR eq? ] bi or ] parse-until ;
|
2017-12-01 03:17:11 +01:00
|
|
|
~~~
|
|
|
|
|