--- gforth/ekey.fs 2000/12/28 11:33:02 1.4 +++ gforth/ekey.fs 2004/12/28 21:09:46 1.10 @@ -1,6 +1,6 @@ \ ekey etc. -\ Copyright (C) 1999 Free Software Foundation, Inc. +\ Copyright (C) 1999,2002,2003 Free Software Foundation, Inc. \ This file is part of Gforth. @@ -58,20 +58,20 @@ keycode k9 keycode k10 keycode k11 \ not in pfe keycode k12 \ not in pfe -\ shifted function/keypad keys have the same key sequences (in xterm) -\ and pfe gives the same keycodes; so what are these keycodes good for? -\ keycode s-k1 -\ keycode s-k2 -\ keycode s-k3 -\ keycode s-k4 -\ keycode s-k5 -\ keycode s-k6 -\ keycode s-k7 -\ keycode s-k8 -\ keycode s-k9 -\ keycode s-k10 -\ keycode s-k11 \ not in pfe -\ keycode s-k12 \ not in pfe +\ shifted fuinction keys (don't work in xterm (same as unshifted, but +\ s-k1..s-k8 work in the Linux console) +keycode s-k1 +keycode s-k2 +keycode s-k3 +keycode s-k4 +keycode s-k5 +keycode s-k6 +keycode s-k7 +keycode s-k8 +keycode s-k9 +keycode s-k10 +keycode s-k11 \ not in pfe +keycode s-k12 \ not in pfe \ helper word \ print a key sequence: @@ -117,16 +117,17 @@ table constant esc-sequences \ and prefi create ekey-buffer 8 chars allot 2variable ekey-buffered -27 constant #esc +[IFUNDEF] #esc 27 Constant #esc [THEN] : esc-prefix ( -- u ) - key ekey-buffered char-append-buffer - ekey-buffered 2@ esc-sequences search-wordlist - if - execute exit - else - ekey-buffered 2@ unkeys #esc - then ; + key? if + key ekey-buffered char-append-buffer + ekey-buffered 2@ esc-sequences search-wordlist + if + execute exit + endif + endif + ekey-buffered 2@ unkeys #esc ; : esc-sequence ( xt addr u -- ; name execution: -- u ) recursive \ define key "name" and all prefixes @@ -185,6 +186,15 @@ get-current esc-sequences set-current ' k-home s" [1~" esc-sequence ' k-end s" [4~" esc-sequence +' s-k1 s" [25~" esc-sequence +' s-k2 s" [26~" esc-sequence +' s-k3 s" [28~" esc-sequence +' s-k4 s" [29~" esc-sequence +' s-k5 s" [31~" esc-sequence +' s-k6 s" [32~" esc-sequence +' s-k7 s" [33~" esc-sequence +' s-k8 s" [34~" esc-sequence + set-current [ENDIF] @@ -201,37 +211,39 @@ set-current : ekey>char ( u -- u false | c true ) \ facility-ext e-key-to-char dup 256 u< ; -: esc? ( -- flag ) recursive - 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 ; +' key? alias ekey? ( -- flag ) -: 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 ; +\ : esc? ( -- flag ) recursive +\ 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 +\ \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? \ begin