| \ ekey etc. |
\ ekey etc. |
| |
|
| \ Copyright (C) 1999 Free Software Foundation, Inc. |
\ Copyright (C) 1999,2002 Free Software Foundation, Inc. |
| |
|
| \ This file is part of Gforth. |
\ This file is part of Gforth. |
| |
|
| : ekey>char ( u -- u false | c true ) \ facility-ext e-key-to-char |
: ekey>char ( u -- u false | c true ) \ facility-ext e-key-to-char |
| dup 256 u< ; |
dup 256 u< ; |
| |
|
| : esc? ( -- flag ) recursive |
' key? alias ekey? ( -- flag ) |
| key? 0= |
|
| if |
|
| false exit |
|
| then |
|
| key ekey-buffered char-append-buffer |
|
| ekey-buffered 2@ esc-sequences search-wordlist |
|
| if |
|
| ['] esc-prefix = |
|
| if |
|
| esc? exit |
|
| then |
|
| then |
|
| true ; |
|
| |
|
| : ekey? ( -- flag ) \ facility-ext e-key-question |
\ : esc? ( -- flag ) recursive |
| \G Return @code{true} if a keyboard event is available (use |
\ key? 0= |
| \G @code{ekey} to receive the event), @code{false} otherwise. |
\ if |
| key? |
\ false exit |
| if |
\ then |
| key dup #esc = |
\ key ekey-buffered char-append-buffer |
| if |
\ ekey-buffered 2@ esc-sequences search-wordlist |
| clear-ekey-buffer esc? |
\ if |
| ekey-buffered 2@ unkeys |
\ ['] esc-prefix = |
| else |
\ if |
| true |
\ esc? exit |
| then |
\ then |
| swap unkey |
\ then |
| else |
\ true ; |
| false |
|
| then ; |
\ : ekey? ( -- flag ) \ facility-ext e-key-question |
| |
\ \G Return @code{true} if a keyboard event is available (use |
| |
\ \G @code{ekey} to receive the event), @code{false} otherwise. |
| |
\ key? |
| |
\ if |
| |
\ key dup #esc = |
| |
\ if |
| |
\ clear-ekey-buffer esc? |
| |
\ ekey-buffered 2@ unkeys |
| |
\ else |
| |
\ true |
| |
\ then |
| |
\ swap unkey |
| |
\ else |
| |
\ false |
| |
\ then ; |
| |
|
| \ : test-ekey? |
\ : test-ekey? |
| \ begin |
\ begin |