mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-18 22:05:25 -05:00
input: generate escape sequences for "other" keys
This corresponds to xterm's modifyOtherKeys option, though the code needs more testing and cleanup.
This commit is contained in:
parent
e88cf4c8c8
commit
3e06dca12d
1 changed files with 34 additions and 6 deletions
40
input.c
40
input.c
|
|
@ -221,14 +221,42 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
|
|||
}
|
||||
|
||||
if (count > 0) {
|
||||
if (effective_mods & alt)
|
||||
vt_to_slave(term, "\x1b", 1);
|
||||
|
||||
vt_to_slave(term, buf, count);
|
||||
#define is_control_key(x) ((x) >= 0x40 && (x) <= 0x7f)
|
||||
#define IS_CTRL(x) ((x) < 0x20 || ((x) >= 0x7f && (x) <= 0x9f))
|
||||
|
||||
if (term->grid->view != term->grid->offset) {
|
||||
term->grid->view = term->grid->offset;
|
||||
term_damage_all(term);
|
||||
if ((keymap_mods & MOD_CTRL) &&
|
||||
!is_control_key(sym) &&
|
||||
(count == 1 && !IS_CTRL(buf[0])) &&
|
||||
sym < 256)
|
||||
{
|
||||
static const int mod_param_map[16] = {
|
||||
[MOD_SHIFT] = 2,
|
||||
[MOD_ALT] = 3,
|
||||
[MOD_SHIFT | MOD_ALT] = 4,
|
||||
[MOD_CTRL] = 5,
|
||||
[MOD_SHIFT | MOD_CTRL] = 6,
|
||||
[MOD_ALT | MOD_CTRL] = 7,
|
||||
[MOD_SHIFT | MOD_ALT | MOD_CTRL] = 8,
|
||||
};
|
||||
int modify_param = mod_param_map[keymap_mods];
|
||||
assert(modify_param != 0);
|
||||
|
||||
char reply[1024];
|
||||
snprintf(reply, sizeof(reply), "\x1b[27;%d;%d~", modify_param, sym);
|
||||
vt_to_slave(term, reply, strlen(reply));
|
||||
}
|
||||
|
||||
else {
|
||||
if (effective_mods & alt)
|
||||
vt_to_slave(term, "\x1b", 1);
|
||||
|
||||
vt_to_slave(term, buf, count);
|
||||
|
||||
if (term->grid->view != term->grid->offset) {
|
||||
term->grid->view = term->grid->offset;
|
||||
term_damage_all(term);
|
||||
}
|
||||
}
|
||||
|
||||
selection_cancel(term);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue