1
- /* Sets the termbox input mode. Termbox has two input modes:
2
- * 1. Esc input mode.
3
- * When ESC sequence is in the buffer and it doesn't match any known
4
- * ESC sequence => ESC means TB_KEY_ESC.
5
- * 2. Alt input mode.
6
- * When ESC sequence is in the buffer and it doesn't match any known
7
- * sequence => ESC enables TB_MOD_ALT modifier for the next keyboard event.
8
- *
9
- * If 'mode' is TB_INPUT_CURRENT, it returns the current input mode.
10
- */
11
- int tb_select_input_mode (int mode);
12
- /* Possible values for mode. */
13
- #define TB_INPUT_CURRENT 0x0
14
- #define TB_INPUT_ESC 0x1
15
- #define TB_INPUT_ALT 0x2
16
- #define TB_INPUT_MOUSE 0x4
17
-
18
1
// if s1 starts with s2 returns true, else false
19
2
// len is the length of s1
20
3
// s2 should be null-terminated
@@ -78,7 +61,7 @@ static int parse_escape_seq(struct tb_event *event, const char *buf, int len)
78
61
return 0 ;
79
62
}
80
63
81
- static bool extract_event (struct tb_event *event, struct bytebuffer *inbuf, int inputmode )
64
+ static bool extract_event (struct tb_event *event, struct bytebuffer *inbuf)
82
65
{
83
66
const char *buf = inbuf->buf ;
84
67
const int len = inbuf->len ;
@@ -96,25 +79,11 @@ static bool extract_event(struct tb_event *event, struct bytebuffer *inbuf, int
96
79
bytebuffer_truncate (inbuf, n);
97
80
return success;
98
81
} else {
99
- // it's not escape sequence, then it's ALT or ESC,
100
- // check inputmode
101
- if (inputmode&TB_INPUT_ESC) {
102
- // if we're in escape mode, fill ESC event, pop
103
- // buffer, return success
104
- event->ch = 0 ;
105
- event->key = TB_KEY_ESC;
106
- event->mod = 0 ;
107
- bytebuffer_truncate (inbuf, 1 );
108
- return true ;
109
- }
110
- if (inputmode&TB_INPUT_ALT) {
111
- // if we're in alt mode, set ALT modifier to
112
- // event and redo parsing
113
- event->mod = TB_MOD_ALT;
114
- bytebuffer_truncate (inbuf, 1 );
115
- return extract_event (event, inbuf, inputmode);
116
- }
117
- assert (!" never got here" );
82
+ // it's not escape sequence; assume it's esc
83
+ event->ch = 0 ;
84
+ event->key = TB_KEY_ESC;
85
+ bytebuffer_truncate (inbuf, 1 );
86
+ return true ;
118
87
}
119
88
}
120
89
0 commit comments