Diff for /gforth/ekey.fs between versions 1.3 and 1.8

version 1.3, 2000/09/23 15:46:52 version 1.8, 2003/03/09 15:16:47
Line 1 Line 1
 \ 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.
   
Line 41  keycode k-up Line 41  keycode k-up
 keycode k-down  keycode k-down
 keycode k-home  keycode k-home
 keycode k-end  keycode k-end
 \ keycode k-prior \ note: captured by xterm  keycode k-prior \ note: captured by xterm
 \ keycode k-next \ note: captured by xterm  keycode k-next \ note: captured by xterm
 keycode k-insert \ not in pfe  keycode k-insert \ not in pfe
   127 constant k-delete \ not an escape sequence on my xterm, so use ASCII code
 \ function/keypad keys  \ function/keypad keys
 keycode k1  keycode k1
 keycode k2  keycode k2
Line 57  keycode k9 Line 58  keycode k9
 keycode k10  keycode k10
 keycode k11 \ not in pfe  keycode k11 \ not in pfe
 keycode k12 \ not in pfe  keycode k12 \ not in pfe
 \ shifted function/keypad keys have the same key sequences (in xterm)  \ shifted fuinction keys (don't work in xterm (same as unshifted, but
 \ and pfe gives the same keycodes; so what are these keycodes good for?  \ s-k1..s-k8 work in the Linux console)
 \ keycode s-k1  keycode s-k1
 \ keycode s-k2  keycode s-k2
 \ keycode s-k3  keycode s-k3
 \ keycode s-k4  keycode s-k4
 \ keycode s-k5  keycode s-k5
 \ keycode s-k6  keycode s-k6
 \ keycode s-k7  keycode s-k7
 \ keycode s-k8  keycode s-k8
 \ keycode s-k9  keycode s-k9
 \ keycode s-k10  keycode s-k10
 \ keycode s-k11 \ not in pfe  keycode s-k11 \ not in pfe
 \ keycode s-k12 \ not in pfe  keycode s-k12 \ not in pfe
   
 \ helper word  \ helper word
 \ print a key sequence:  \ print a key sequence:
Line 119  create ekey-buffer 8 chars allot Line 120  create ekey-buffer 8 chars allot
 27 constant #esc  27 constant #esc
   
 : esc-prefix ( -- u )  : esc-prefix ( -- u )
     key ekey-buffered char-append-buffer      key? if
     ekey-buffered 2@ esc-sequences search-wordlist          key ekey-buffered char-append-buffer
     if          ekey-buffered 2@ esc-sequences search-wordlist
         execute exit          if
     else              execute exit
         ekey-buffered 2@ unkeys #esc          endif
     then ;      endif
       ekey-buffered 2@ unkeys #esc ;
   
 : esc-sequence ( xt addr u -- ; name execution: -- u ) recursive  : esc-sequence ( xt addr u -- ; name execution: -- u ) recursive
     \ define key "name" and all prefixes      \ define key "name" and all prefixes
Line 156  get-current esc-sequences set-current Line 158  get-current esc-sequences set-current
 ' k-down        s" [B"  esc-sequence  ' k-down        s" [B"  esc-sequence
 ' k-home        s" [H"  esc-sequence  ' k-home        s" [H"  esc-sequence
 ' k-end         s" [F"  esc-sequence  ' k-end         s" [F"  esc-sequence
 \ ' k-prior     s" [5~" esc-sequence \ from linux console  ' k-prior       s" [5~" esc-sequence
 \ ' k-next      s" [6~" esc-sequence \ from linux console  ' k-next        s" [6~" esc-sequence
 ' k-insert      s" [2~" esc-sequence  ' k-insert      s" [2~" esc-sequence
   
 ' k1    s" OP"  esc-sequence  ' k1    s" OP"  esc-sequence
Line 173  get-current esc-sequences set-current Line 175  get-current esc-sequences set-current
 ' k11   s" [23~" esc-sequence  ' k11   s" [23~" esc-sequence
 ' k12   s" [24~" esc-sequence  ' k12   s" [24~" esc-sequence
   
   \ esc sequences from Linux console:
   
   ' k1       s" [[A" esc-sequence
   ' k2       s" [[B" esc-sequence
   ' k3       s" [[C" esc-sequence
   ' k4       s" [[D" esc-sequence
   ' k5       s" [[E" esc-sequence
   ' k-delete s" [3~" esc-sequence
   ' 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  set-current
 [ENDIF]  [ENDIF]
   
Line 189  set-current Line 211  set-current
 : 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

Removed from v.1.3  
changed lines
  Added in v.1.8


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>