\ The most recent entry is put at the beginning,
\ older entries are shifted up.
-4 constant KH_LINE_EXTRA_SIZE ( 2 count bytes plus 2 size bytes )
+4 constant KH_LINE_EXTRA_SIZE ( 2 count bytes plus 2 line_number bytes )
: KH-END ( -- addr , end of history buffer )
kh-history kh_history_size +
ENDCASE
;
-
: KH.SPECIAL.KEY ( char -- true | false , handle fkeys or arrows, true if handled )
true >r
CASE
$ 05 constant ASCII_CTRL_E
$ 18 constant ASCII_CTRL_X
-\ ANSI Terminal Control
+\ ANSI arrow key sequences
+\ ESC [ 0x41 is UP
+\ ESC [ 0x42 is DOWN
+\ ESC [ 0x43 is RIGHT
+\ ESC [ 0x44 is LEFT
+
+\ ANSI terminal control
+\ ESC [ 2J is clear screen
+\ ESC [ {n} D is move left
+\ ESC [ {n} C is move right
+\ ESC [ K is erase to end of line
+
: ESC[ ( send ESCAPE and [ )
ASCII_ESCAPE emit
ascii [ emit
ascii K emit
;
-
: BELL ( -- , ring the terminal bell )
7 emit
;