3 \
Copyright (C) 1998 Lars Krueger
5 \
This file is
part of FLK.
7 \
FLK is
free software
; you
can redistribute
it and/or
8 \ modify
it under the
terms of the
GNU General Public License
9 \
as published by the
Free Software Foundation; either version
2
10 \
of the
License, or (at
your option) any later version
.
12 \
This program is
distributed in the
hope that
it will
be useful
,
13 \ but
WITHOUT ANY WARRANTY; without
even the
implied warranty
of
14 \
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 \
GNU General Public License for more
details.
17 \
You should have
received a copy
of the GNU General Public License
18 \ along
with this
program; if not
, write
to the Free Software
19 \
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 \ $
Id: flkkey_unix
.fs
,v
1.9 1998/07/13 18:08:54 root
Exp $
22 \ $
Log: flkkey_unix
.fs
,v $
23 \
Revision 1.9 1998/07/13 18:08:54 root
24 \ various
optimizations
26 \
Revision 1.8 1998/06/01 17:51:42 root
27 \
SEE shows
the sourcefile
using VIEW
29 \
Revision 1.7 1998/05/27 18:52:12 root
30 \ \
: commants
added for SEE and HELP
32 \
Revision 1.6 1998/05/23 17:52:02 root
33 \ background processing
35 \
Revision 1.5 1998/05/17 08:27:09 root
38 \
Revision 1.4 1998/05/16 16:19:24 root
39 \ direct
terminfo access
41 \
Revision 1.3 1998/05/01 18:11:25 root
42 \
GNU license
text added
45 \
Revision 1.2 1998/04/29 18:20:30 root
48 \
Revision 1.1 1998/04/07 20:10:33 root
54 127 CONSTANT KEY_BACKSPACE \
Backspace (unreliable
)
56 23 CONSTANT key
-list
-len
58 -1 , 79 , ( key_left
)
59 -1 , 83 , ( key_right
)
61 -1 , 61 , ( key_down
)
62 -1 , 76 , ( key_home
)
63 -1 , 164 , ( key_end
)
64 -1 , 81 , ( key_npage
)
65 -1 , 82 , ( key_ppage
)
79 -1 , 216 , ( key_f11
)
80 -1 , 217 , ( key_f12
)
82 CREATE (ekey
-buf
) 10 ALLOT
83 0 VALUE (ek
-cache
-cnt
)
84 0 VALUE (ek
-cache
-ind
)
86 \
Reset the flags
for the keys.
88 key
-list
key-list
-len
0 DO
93 \
Type an zero terminated
string.
106 \
List the codes
of all
keys.
108 key-list
key-list
-len
0 DO
109 CELL+ DUP @ CELLS TERM-STRING + @ \ addr str
114 0 RVALUE backgrounder
118 backgrounder
IMAGE-BASE <> IF
126 \
EKEY with background tasking
128 backgrounder
IMAGE-BASE <> IF
136 \
Checks key-list
and return number
of matches
. The case that
only one
key
137 \
string matches
but is
not ended is
expressed by n
==2 .
138 : (ek
-matches
) ( index
key -- index
{ code
1 / n
} )
139 0 key-list
key-list
-len
0 DO \ index
key n addr
140 DUP @ IF \ index
key n addr
141 DUP CELL+ @ CELLS TERM-STRING + @ \ index
key n addr str
142 ?DUP IF \ index
key n addr
143 TWIST 2DUP + C@ \
key n addr str index char
144 ROTARE TUCK = IF \ n addr str index
key
145 TWIST 1+ \ addr str index
key n
146 2SWAP TUCK \ addr
key n index str index
147 1+ + C@ 0= IF ( end ) \ addr
key n index
150 ELSE \ addr
key n index
151 ROT \ addr n index
key
152 2SWAP SWAP \ index
key addr n
154 ELSE \ n addr str index
key
155 ROT DROP \ n addr index
key
156 ROT FALSE OVER ! \ n index
key addr
157 TURN SWAP \ index
key n addr
162 LOOP \ index
key n addr
169 (ek
-cache
-ind
) (ek
-cache
-cnt
) < IF
170 (ek
-cache
-ind
) DUP (ekey
-buf
) + C@ \ ind n
171 SWAP 1+ TO (ek
-cache
-ind
)
172 ELSE ( cache
empty ) \
176 2DUP SWAP (ekey
-buf
) + C! \ index
key
177 (ek
-matches
) \ index
( code
1 / 0 / n
)
186 NIP 0 TO (ek
-cache
-cnt
)
187 1 TO (ek
-cache
-ind
) TRUE
195 256 CONSTANT KEY_LEFT
196 257 CONSTANT KEY_RIGHT
198 259 CONSTANT KEY_DOWN
199 260 CONSTANT KEY_HOME
201 262 CONSTANT KEY_NPAGE
202 263 CONSTANT KEY_PPAGE