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

version 1.5, 2001/10/26 11:53:21 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 120  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 210  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.5  
changed lines
  Added in v.1.8


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