1 /* HCONSOLE.H (c) Copyright "Fish" (David B. Trout), 2009 */ 2 /* Hercules console panel support functions header file */ 3 4 ////////////////////////////////////////////////////////////////////////////////////////// 5 // (c) Copyright "Fish" (David B. Trout), 2009. Released under the Q Public License 6 // (http://www.hercules-390.org/herclic.html) as modifications to Hercules. 7 ////////////////////////////////////////////////////////////////////////////////////////// 8 9 #ifndef _HCONSOLE_H 10 #define _HCONSOLE_H 11 12 //----------------------------------------------------------------------------- 13 // 14 // VT100 User Guide 15 // 16 // Table 3-6 Cursor Control Key Codes 17 // 18 // Cursor Key VT52 ANSI and Cursor Key Mode ANSI and Cursor Key Mode 19 // (Arrow) Mode Reset (Normal mode) Set (Application mode) 20 // 21 // Up ESC A ESC [ A ESC O A 22 // Down ESC B ESC [ B ESC O B 23 // Right ESC C ESC [ C ESC O C 24 // Left ESC D ESC [ D ESC O D 25 // 26 //----------------------------------------------------------------------------- 27 28 #define ANSI_RESET_ALL_ATTRIBUTES "\x1B[0m" 29 30 #define KBD_HOME "\x1B[1~" 31 #define KBD_INSERT "\x1B[2~" 32 #define KBD_DELETE "\x1B[3~" 33 #define KBD_END "\x1B[4~" 34 #define KBD_PAGE_UP "\x1B[5~" 35 #define KBD_PAGE_DOWN "\x1B[6~" 36 37 #define KBD_UP_ARROW "\x1B[A" 38 #define KBD_DOWN_ARROW "\x1B[B" 39 #define KBD_RIGHT_ARROW "\x1B[C" 40 #define KBD_LEFT_ARROW "\x1B[D" 41 42 #define KBD_UP_ARROW2 "\x1BOA" 43 #define KBD_DOWN_ARROW2 "\x1BOB" 44 #define KBD_RIGHT_ARROW2 "\x1BOC" 45 #define KBD_LEFT_ARROW2 "\x1BOD" 46 47 // Does anyone know what the actual escape sequence that 48 // gets generated actually is on Linux for "Alt+UpArrow" 49 // and "Alt+DownArrow", etc?? Thanks! -- Fish 50 51 #define KBD_ALT_UP_ARROW KBD_UP_ARROW2 52 #define KBD_ALT_DOWN_ARROW KBD_DOWN_ARROW2 53 #define KBD_ALT_RIGHT_ARROW KBD_RIGHT_ARROW2 54 #define KBD_ALT_LEFT_ARROW KBD_LEFT_ARROW2 55 56 #define KBD_CTRL_HOME "\x1B""w" // (is this right??) 57 #define KBD_CTRL_END "\x1B""u" // (is this right??) 58 59 #define KBD_CTRL_UP_ARROW "\x1B""D" // (is this right??) 60 #define KBD_CTRL_DOWN_ARROW "\x1B""M" // (is this right??) 61 //efine KBD_CTRL_RIGHT_ARROW "???????" // (luckily we don't need it right now) 62 //efine KBD_CTRL_LEFT_ARROW "???????" // (luckily we don't need it right now) 63 64 #define KBD_ASK_CURSOR_POS "\x1B[6n" // Return value is the string "\x1B[n;mR" 65 // returned in the keyboard buffer where 66 // n = decimal row, m = decimal column. 67 68 // Hercules console color codes... 69 70 #define COLOR_BLACK 0 71 #define COLOR_RED 1 72 #define COLOR_GREEN 2 73 #define COLOR_BLUE 3 74 #define COLOR_CYAN 4 75 #define COLOR_MAGENTA 5 76 #define COLOR_YELLOW 6 77 #define COLOR_DARK_GREY 7 78 #define COLOR_LIGHT_GREY 8 79 #define COLOR_LIGHT_RED 9 80 #define COLOR_LIGHT_GREEN 10 81 #define COLOR_LIGHT_BLUE 11 82 #define COLOR_LIGHT_CYAN 12 83 #define COLOR_LIGHT_MAGENTA 13 84 #define COLOR_LIGHT_YELLOW 14 85 #define COLOR_WHITE 15 86 #define COLOR_DEFAULT_FG 16 87 #define COLOR_DEFAULT_BG 17 88 #define COLOR_DEFAULT_LIGHT 18 89 90 extern int set_screen_color ( FILE* confp, short herc_fore, short herc_back ); 91 92 // screen positions are 1-based; row 1 == top line; col 1 == leftmost column 93 94 extern int set_screen_pos ( FILE* confp, short rowY1, short colX1 ); 95 96 extern int clear_screen ( FILE* confp ); 97 extern int erase_to_eol ( FILE* confp ); 98 99 // 'save_and_set' = 1 --> just what it says; 0 --> restore from saved value. 100 extern int set_or_reset_console_mode ( int keybrd_fd, short save_and_set ); 101 102 extern void translate_keystroke( char kbbuf[], int* pkblen ); 103 104 extern int console_beep( FILE* confp ); 105 extern int get_console_dim( FILE* confp, int* rows, int* cols ); 106 #ifdef OPTION_EXTCURS 107 extern int get_cursor_pos( int keybrd_fd, FILE* confp, short* row, short* col ); 108 #endif // OPTION_EXTCURS 109 extern int set_console_cursor_shape( FILE* confp, int ins ); 110 111 #if defined( _MSVC_ ) 112 extern int w32_set_console_title( char* pszTitle ); 113 #endif 114 115 #endif // _HCONSOLE_H 116