Annotation of libaitcli/example/keys.h, revision 1.1.4.3

1.1.4.2   misho       1: #ifndef __AITCLI_H
                      2: #define __AITCLI_H
                      3: 
                      4: 
                      5: #define        K_F1            "\x1b\x4f\x50"
                      6: #define        K_F2            "\x1b\x4f\x51"
                      7: #define        K_F3            "\x1b\x4f\x52"
                      8: #define        K_F4            "\x1b\x4f\x53"
                      9: #define        K_F5            "\x1b\x5b\x31\x35\x7e"
                     10: #define        K_F6            "\x1b\x5b\x31\x37\x7e"
                     11: #define        K_F7            "\x1b\x5b\x31\x38\x7e"
                     12: #define        K_F8            "\x1b\x5b\x31\x39\x7e"
                     13: #define        K_F9            "\x1b\x5b\x32\x30\x7e"
                     14: #define        K_F10           "\x1b\x5b\x32\x31\x7e"
                     15: #define        K_F11           "\x1b\x5b\x32\x33\x7e"
                     16: #define        K_F12           "\x1b\x5b\x32\x34\x7e"
                     17: #define K_CTRL_F1      "\x1b\x5b\x6b"
                     18: #define K_CTRL_F2      "\x1b\x5b\x6c"
                     19: #define K_CTRL_F3      "\x1b\x5b\x6d"
                     20: #define K_CTRL_F4      "\x1b\x5b\x6e"
                     21: #define K_CTRL_F5      "\x1b\x5b\x6f"
                     22: #define K_CTRL_F6      "\x1b\x5b\x70"
                     23: #define K_CTRL_F7      "\x1b\x5b\x71"
                     24: #define K_CTRL_F8      "\x1b\x5b\x72"
                     25: #define K_CTRL_F9      "\x1b\x5b\x73"
                     26: #define K_CTRL_F10     "\x1b\x5b\x74"
                     27: #define K_CTRL_F11     "\x1b\x5b\x75"
                     28: #define K_CTRL_F12     "\x1b\x5b\x76"
                     29: #define K_CTRL_SH_F1   "\x1b\x5b\x77"
                     30: #define K_CTRL_SH_F2   "\x1b\x5b\x78"
                     31: #define K_CTRL_SH_F3   "\x1b\x5b\x79"
                     32: #define K_CTRL_SH_F4   "\x1b\x5b\x7a"
                     33: #define K_CTRL_SH_F5   "\x1b\x5b\x40"
                     34: #define K_CTRL_SH_F6   "\x1b\x5b\x5b"
                     35: #define K_CTRL_SH_F7   "\x1b\x5b\x5c"
                     36: #define K_CTRL_SH_F8   "\x1b\x5b\x5d"
                     37: #define K_CTRL_SH_F9   "\x1b\x5b\x5e"
                     38: #define K_CTRL_SH_F10  "\x1b\x5b\x5f"
                     39: #define K_CTRL_SH_F11  "\x1b\x5b\x60"
                     40: #define K_CTRL_SH_F12  "\x1b\x5b\x7b"
                     41: 
                     42: #define K_INS          "\x1b\x5b\x32\x7e"
                     43: #define K_DEL          "\x1b\x5b\x33\x7e"
                     44: #define K_PGUP         "\x1b\x5b\x35\x7e"
                     45: #define K_PGDN         "\x1b\x5b\x36\x7e"
                     46: #define K_HOME         "\x1b\x5b\x48"
                     47: #define K_END          "\x1b\x5b\x46"
                     48: #define K_UP           "\x1b\x5b\x41"
                     49: #define K_DOWN         "\x1b\x5b\x42"
                     50: #define K_RIGHT                "\x1b\x5b\x43"
                     51: #define K_LEFT         "\x1b\x5b\x44"
                     52: 
                     53: #define K_NULL         "\x0"
                     54: #define K_CR           "\xd"
                     55: #define K_BTAB         "\x1b\x5b\x5a"
                     56: #define K_TAB          "\x9"
                     57: #define K_ENTER                "\xa"
                     58: #define K_ESC          "\x1b"
                     59: #define K_BACKSPACE    "\x7f"
                     60: #define K_SPACE                "\x20"
                     61: 
                     62: #define K_CTRL_SPACE   K_NULL
                     63: #define K_CTRL_2       K_NULL
                     64: #define K_CTRL_A       "\x1"
                     65: #define K_CTRL_B       "\x2"
                     66: #define K_CTRL_C       "\x3"
                     67: #define K_CTRL_D       "\x4"
                     68: #define K_CTRL_E       "\x5"
                     69: #define K_CTRL_F       "\x6"
                     70: #define K_CTRL_G       "\x7"
                     71: #define K_CTRL_H       "\x8"
                     72: #define K_CTRL_I       K_TAB
                     73: #define K_CTRL_J       K_ENTER
                     74: #define K_CTRL_K       "\xb"
                     75: #define K_CTRL_L       "\xc"
                     76: #define K_CTRL_M       K_ENTER         // K_CR
                     77: #define K_CTRL_N       "\xe"
                     78: #define K_CTRL_O       "\xf"
                     79: #define K_CTRL_P       "\x10"
                     80: #define K_CTRL_Q       "\x11"
                     81: #define K_CTRL_R       "\x12"
                     82: #define K_CTRL_S       "\x13"
                     83: #define K_CTRL_T       "\x14"
                     84: #define K_CTRL_U       "\x15"
                     85: #define K_CTRL_V       "\x16"
                     86: #define K_CTRL_W       "\x17"
                     87: #define K_CTRL_X       "\x18"
                     88: #define K_CTRL_Y       "\x19"
                     89: #define K_CTRL_Z       "\x1a"
                     90: #define K_CTRL_LBRACE  "\x1b"
                     91: #define K_CTRL_PIPE    "\x1c"
                     92: #define K_CTRL_RBRACE  "\x1d"
                     93: #define K_CTRL_6       "\x1e"
                     94: #define K_CTRL__       "\x1f"
                     95: 
                     96: 
                     97: #define K_X_CTRL_INS   "\x1b\x5b\x32\x3b\x35\x7e"
                     98: #define K_X_CTRL_DEL   "\x1b\x5b\x33\x3b\x35\x7e"
                     99: #define K_X_CTRL_PGUP  "\x1b\x5b\x35\x3b\x35\x7e"
                    100: #define K_X_CTRL_PGDN  "\x1b\x5b\x36\x3b\x35\x7e"
                    101: #define K_X_CTRL_HOME  "\x1b\x5b\x31\x3b\x35\x48"
                    102: #define K_X_CTRL_END   "\x1b\x5b\x31\x3b\x35\x46"
                    103: #define K_X_CTRL_UP    "\x1b\x5b\x31\x3b\x35\x41"
                    104: #define K_X_CTRL_DOWN  "\x1b\x5b\x31\x3b\x35\x42"
                    105: #define K_X_CTRL_RIGHT "\x1b\x5b\x31\x3b\x35\x43"
                    106: #define K_X_CTRL_LEFT  "\x1b\x5b\x31\x3b\x35\x44"
                    107: 
                    108: #define K_X_ALT_INS    "\x1b\x5b\x32\x3b\x33\x7e"
                    109: #define K_X_ALT_DEL    "\x1b\x5b\x33\x3b\x33\x7e"
                    110: #define K_X_ALT_PGUP   "\x1b\x5b\x35\x3b\x33\x7e"
                    111: #define K_X_ALT_PGDN   "\x1b\x5b\x36\x3b\x33\x7e"
                    112: #define K_X_ALT_HOME   "\x1b\x5b\x31\x3b\x33\x48"
                    113: #define K_X_ALT_END    "\x1b\x5b\x31\x3b\x33\x46"
                    114: #define K_X_ALT_UP     "\x1b\x5b\x31\x3b\x33\x41"
                    115: #define K_X_ALT_DOWN   "\x1b\x5b\x31\x3b\x33\x42"
                    116: #define K_X_ALT_RIGHT  "\x1b\x5b\x31\x3b\x33\x43"
                    117: #define K_X_ALT_LEFT   "\x1b\x5b\x31\x3b\x33\x44"
                    118: 
                    119: #define K_X_CTL_A_INS  "\x1b\x5b\x32\x3b\x37\x7e"
                    120: #define K_X_CTL_A_DEL  "\x1b\x5b\x33\x3b\x37\x7e"
                    121: #define K_X_CTL_A_PGUP "\x1b\x5b\x35\x3b\x37\x7e"
                    122: #define K_X_CTL_A_PGDN "\x1b\x5b\x36\x3b\x37\x7e"
                    123: #define K_X_CTL_A_HOME "\x1b\x5b\x31\x3b\x37\x48"
                    124: #define K_X_CTL_A_END  "\x1b\x5b\x31\x3b\x37\x46"
                    125: #define K_X_CTL_A_UP   "\x1b\x5b\x31\x3b\x37\x41"
                    126: #define K_X_CTL_A_DOWN "\x1b\x5b\x31\x3b\x37\x42"
                    127: #define K_X_CTL_A_RIGHT        "\x1b\x5b\x31\x3b\x37\x43"
                    128: #define K_X_CTL_A_LEFT "\x1b\x5b\x31\x3b\x37\x44"
                    129: 
                    130: 
                    131: #define STRSIZ         256
                    132: #define MAX_BINDKEY    559
                    133: 
                    134: #define HISTORY_LINES  100
                    135: #define HISTORY_FILE   "/tmp/.CLI.history"
                    136: 
                    137: #define CLI_PROMPT     "test> "
                    138: 
                    139: #define LINEMODE_RAW   -1
                    140: #define LINEMODE_INS   0
                    141: #define LINEMODE_OVER  1
                    142: 
                    143: #define RETCODE_ERR    -1
                    144: #define RETCODE_OK     0
                    145: #define RETCODE_EOL    1
                    146: #define RETCODE_EOF    2
                    147: 
                    148: 
                    149: typedef int (*bindkey_func_t)(int idx, /*linebuffer_t **/ void * __restrict buffer);
                    150: typedef struct {
                    151:        int             key_len;
                    152:        unsigned char   key_ch[8];
                    153:        bindkey_func_t  key_func;
                    154: } bindkey_t;
                    155: 
                    156: struct tagHistory {
                    157:        int             hist_len;
                    158:        char            hist_line[BUFSIZ];
                    159: 
                    160:        TAILQ_ENTRY(tagHistory) hist_next;
                    161: };
                    162: typedef TAILQ_HEAD(tqHistoryHead, tagHistory) history_t;
                    163: 
                    164: typedef struct {
                    165:        char                    line_mode;
                    166: 
                    167:        char                    *line_prompt;
                    168: 
                    169:        int                     line_bol;
                    170:        int                     line_eol;
                    171:        int                     line_len;
                    172:        char                    *line_buf;
                    173: 
                    174:        const struct tagHistory *line_h;
                    175:        history_t               line_history;
                    176: 
                    177:        bindkey_t               *line_keys;
                    178: 
                    179:        int                     line_in;
                    180:        int                     line_out;
                    181: } linebuffer_t;
                    182: 
                    183: typedef int (*cmd_func_t)(linebuffer_t * __restrict buffer, int argc, char ** __restrict argv);
                    184: typedef struct {
                    185:        int             cmd_level;
                    186: 
                    187:        int             cmd_min;
                    188:        int             cmd_len;
                    189:        char            cmd_name[STRSIZ];
                    190: 
                    191:        char            cmd_info[STRSIZ];
                    192:        char            cmd_help[STRSIZ];
                    193: 
                    194:        cmd_func_t      *cmd_func;
                    195: } command_t;
                    196: 
                    197: 
                    198: 
                    199: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>