1 \ tag: terminal emulation
3 \ this code implements IEEE 1275-1994 ANNEX B
5 \ Copyright (C) 2003 Stefan Reinauer
7 \ See the file "COPYING" for further information about
8 \ the copyright and warranty status of this work.
14 : (match-number) ( x y [1|2] [1|2] -- x [z] )
24 : (esc-number) ( maxchar -- ?? ?? num )
25 >r depth >r ( R: depth maxchar )
26 0 (sequence) 2+ (escseq) 2- ( 0 seq+2 seqlen-2 )
27 \ if numerical, scan until non-numerical
51 (escseq) 1- (sequence) + c@ \ get last character in sequence
54 ascii A of \ CUU - cursor up
64 ascii B of \ CUD - cursor down
69 #lines 1- min to line#
72 ascii C of \ CUF - cursor forward
77 #columns 1- min to column#
80 ascii D of \ CUB - cursor backward
88 ascii E of \ Cursor next line (CNL)
89 \ FIXME - check agains ANSI3.64
94 #lines 1- min to line#
102 1- #columns 1- min to column#
103 1- #lines 1- min to line#
107 1- #lines 1- min to line#
120 1- #columns 1- min to column#
121 1- #lines 1- min to line#
125 1- #lines 1- min to line#
136 #columns column# - delete-characters
137 #lines line# - delete-lines
141 #columns column# - delete-characters
181 ascii p of \ normal text colors
184 false to inverse-screen?
185 inverse? 0= to inverse?
189 ascii q of \ inverse text colors
191 inverse-screen? not if
192 true to inverse-screen?
193 inverse? 0= to inverse?
198 \ Resets the display device associated with the terminal emulator.
205 : (term-emit) ( char -- )
211 ." overflow in esc" cr
215 dup ascii [ = if \ not a [
219 0 to (escseq) \ break out of ESC sequence
221 drop \ don't print breakout character
225 (sequence) (escseq) + c!
226 (escseq) 1+ to (escseq)
238 s" /screen" s" ring-bell"
239 execute-device-method
243 column# 1- to column#
248 column# dup #columns = if
251 8 + -8 and ff and to column#
272 0 to column# 0 to line#
284 \ draw character and advance position
285 column# #columns >= if
296 column# 1+ to column#
302 ['] (term-emit) to fb-emit