1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation.
3 * Copyright (c) 2009, Olivier MATZ <zer0@droids-corp.org>
7 #ifndef _CMDLINE_VT100_H_
8 #define _CMDLINE_VT100_H_
16 #define vt100_bell "\007"
17 #define vt100_bs "\010"
18 #define vt100_bs_clear "\010 \010"
19 #define vt100_tab "\011"
20 #define vt100_crnl "\012\015"
21 #define vt100_clear_right "\033[0K"
22 #define vt100_clear_left "\033[1K"
23 #define vt100_clear_down "\033[0J"
24 #define vt100_clear_up "\033[1J"
25 #define vt100_clear_line "\033[2K"
26 #define vt100_clear_screen "\033[2J"
27 #define vt100_up_arr "\033\133\101"
28 #define vt100_down_arr "\033\133\102"
29 #define vt100_right_arr "\033\133\103"
30 #define vt100_left_arr "\033\133\104"
31 #define vt100_multi_right "\033\133%uC"
32 #define vt100_multi_left "\033\133%uD"
33 #define vt100_suppr "\033\133\063\176"
34 #define vt100_home "\033M\033E"
35 #define vt100_word_left "\033\142"
36 #define vt100_word_right "\033\146"
38 /* Result of parsing : it must be synchronized with
39 * cmdline_vt100_commands[] in vt100.c */
40 #define CMDLINE_KEY_UP_ARR 0
41 #define CMDLINE_KEY_DOWN_ARR 1
42 #define CMDLINE_KEY_RIGHT_ARR 2
43 #define CMDLINE_KEY_LEFT_ARR 3
44 #define CMDLINE_KEY_BKSPACE 4
45 #define CMDLINE_KEY_RETURN 5
46 #define CMDLINE_KEY_CTRL_A 6
47 #define CMDLINE_KEY_CTRL_E 7
48 #define CMDLINE_KEY_CTRL_K 8
49 #define CMDLINE_KEY_CTRL_Y 9
50 #define CMDLINE_KEY_CTRL_C 10
51 #define CMDLINE_KEY_CTRL_F 11
52 #define CMDLINE_KEY_CTRL_B 12
53 #define CMDLINE_KEY_SUPPR 13
54 #define CMDLINE_KEY_TAB 14
55 #define CMDLINE_KEY_CTRL_D 15
56 #define CMDLINE_KEY_CTRL_L 16
57 #define CMDLINE_KEY_RETURN2 17
58 #define CMDLINE_KEY_META_BKSPACE 18
59 #define CMDLINE_KEY_WLEFT 19
60 #define CMDLINE_KEY_WRIGHT 20
61 #define CMDLINE_KEY_HELP 21
62 #define CMDLINE_KEY_CTRL_W 22
63 #define CMDLINE_KEY_CTRL_P 23
64 #define CMDLINE_KEY_CTRL_N 24
65 #define CMDLINE_KEY_META_D 25
66 #define CMDLINE_KEY_BKSPACE2 26
68 extern const char *cmdline_vt100_commands[];
70 enum cmdline_vt100_parser_state {
73 CMDLINE_VT100_ESCAPE_CSI
76 #define CMDLINE_VT100_BUF_SIZE 8
77 struct cmdline_vt100 {
79 char buf[CMDLINE_VT100_BUF_SIZE];
80 enum cmdline_vt100_parser_state state;
86 void vt100_init(struct cmdline_vt100 *vt);
89 * Input a new character.
90 * Return -1 if the character is not part of a control sequence
91 * Return -2 if c is not the last char of a control sequence
92 * Else return the index in vt100_commands[]
94 int vt100_parser(struct cmdline_vt100 *vt, char c);