Make key return -1 on EOF.
This commit is contained in:
@ -104,7 +104,7 @@ decimal
|
||||
|
||||
( Hookup I/O )
|
||||
: stdout-write ( a n -- ) stdout -rot write drop ;
|
||||
: stdin-key ( -- n ) 0 >r stdin rp@ 1 read drop r> ;
|
||||
: stdin-key ( -- n ) 0 >r stdin rp@ 1 read 0= if rdrop -1 exit then r> ;
|
||||
|
||||
also forth definitions
|
||||
: default-type stdout-write ;
|
||||
|
||||
@ -62,7 +62,8 @@ variable console-mode
|
||||
;
|
||||
|
||||
: win-type ( a n -- ) init-console stdout -rot NULL NULL WriteFile drop ;
|
||||
: raw-key ( -- n ) 0 >r stdin rp@ 1 NULL NULL ReadFile drop r> ;
|
||||
: raw-key ( -- n )
|
||||
0 >r stdin rp@ 1 NULL NULL ReadFile 0= if rdrop -1 exit then r> ;
|
||||
: win-key? ( -- f ) stdin 0 WaitForSingleObject 0= ;
|
||||
: win-key ( -- n ) raw-key dup 13 = if drop nl then ;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user