/* MS-Kermit terminal setup for CRISP.
   Requires the kermit keys to be rebound.
   by David MacKenzie */

#include "tty.h"

(macro _init
    (
	/* Set characters used for extended graphics support when
	   drawing windows. */
	(set_term_characters
	    213		; Top left of window.
	    184		; Top right of window.
	    212		; Bottom left of window.
	    190		; Bottom right of window.
	    179		; Vertical bar for window sides.
	    205		; Top and bottom horizontal bar for window.
	    NULL	; Top join.
	    NULL	; Bottom join.
	    NULL	; Window 4-way intersection.
	    NULL	; Left hand join.
	    NULL	; Right hand join.
	    )

	/* Define escape sequences used for special optimisations on output. */
	(set_term_features
	    NULL	; Sequence to clear 'n' spaces.
	    "%c"	; Sequence to print characters with top bit set.
	    NULL	; Insert-mode cursor.
	    NULL	; Overwrite-mode cursor.
	    NULL	; Insert-mode cursor (on virtual space).
	    NULL	; Overwrite-mode cursor (on virtual space).
	    NULL	; Print ESCAPE character graphically.
	    NULL	; Escape sequence to repeat last character.
	    FALSE	; TRUE if ESC [0m resets color.
	    TRUE	; TRUE if terminal supports color.
	    "\x1B[%dC"	; Move cursor multiple columns (termcap lacks).
	    )

	/* Define keyboard layout for non-ASCII characters. */
	(set_term_keyboard
	    F1-F12
	    (quote_list "\x1BOP" "\x1BOQ" "\x1BOR" "\x1BOS" "\x1BOT"
			"\x1BOU" "\x1BOV" "\x1BOW" "\x1BOX" "\x1BOY"
			"\x1BOZ" "\x1BO[")

	    SHIFT-F1-F12
	    (quote_list "\x1BOp" "\x1BOq" "\x1BOr" "\x1BOs" "\x1BOt"
			"\x1BOu" "\x1BOv" "\x1BOw" "\x1BOx" "\x1BOy"
			"\x1BOz" "\x1BO{")
	    CTRL-F1-F12
	    (quote_list "\x1BO\x10" "\x1BO\x11" "\x1BO\x12" "\x1BO\x13"
			"\x1BO\x14"  "\x1BO\x15" "\x1BO\x16" "\x1BO\x17"
			"\x1BO\x18" "\x1BO\x19" "\x1BO\x1a" "\x1BO\x1B")
	    ALT-A-Z
	    (quote_list	"\x1BNa" "\x1BNb" "\x1BNc" "\x1BNd" "\x1BNe"
			"\x1BNf" "\x1BNg" "\x1BNh" "\x1BNi" "\x1BNj"
			"\x1BNk" "\x1BNl" "\x1BNm" "\x1BNn" "\x1BNo"
			"\x1BNp" "\x1BNq" "\x1BNr" "\x1BNs" "\x1BNt"
			"\x1BNu" "\x1BNv" "\x1BNw" "\x1BNx" "\x1BNy" "\x1BNz")
	    KEYPAD-0-9
	    (quote_list "\x1B[@" "\x1B[Y" "\x1B[B" "\x1B[U" "\x1B[D"
			"\x1B[G" "\x1B[C" "\x1B[H" "\x1B[A" "\x1B[V")
	    CTRL-KEYPAD-0-9 ; Not sent by MS-Kermit.
	    (quote_list "\x1B?0" "\x1B?1" "\x1B?2" "\x1B?3" "\x1B?4"
			"\x1B?5" "\x1B?6" "\x1B?7" "\x1B?8" "\x1B?9")
	    ALT-0-9
	    (quote_list "\x1BN0" "\x1BN1" "\x1BN2" "\x1BN3" "\x1BN4"
			"\x1BN5" "\x1BN6" "\x1BN7" "\x1BN8" "\x1BN9")
	    CUT		"\x1B[S"	; keypad -
	    COPY	"\x1B[T"	; keypad +
	    BACK-TAB	"\x1B[Z"	; shift-tab
	)

	(assign_to_key "#127" "backspace")
    )
)

/* Macro called if `-mono' is part of the suffix list of BTERM.
   This is called after _init. */
(macro mono
    (
	/* Define escape sequences used for special optimisations on output. */
	(set_term_features
	    NULL	; Sequence to clear 'n' spaces.
	    "%c"	; Sequence to print characters with top bit set.
	    NULL	; Insert-mode cursor.
	    NULL	; Overwrite-mode cursor.
	    NULL	; Insert-mode cursor (on virtual space).
	    NULL	; Overwrite-mode cursor (on virtual space).
	    NULL	; Print ESCAPE character graphically.
	    NULL	; Escape sequence to repeat last character.
	    FALSE	; TRUE if ESC [0m resets color.
	    FALSE	; TRUE if terminal supports color.
	    "\x1B[%dC"	; Move cursor multiple columns (termcap lacks).
	    )
    )
)
