mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-11 05:33:55 -04:00
csi: implement CSI ? 1007 h/l - alternateScroll
When enabled, mouse scrolls in the alternate screen are converted to up/down key presses.
This commit is contained in:
parent
9029478e8c
commit
4168f91d40
3 changed files with 31 additions and 6 deletions
8
csi.c
8
csi.c
|
|
@ -713,6 +713,10 @@ csi_dispatch(struct terminal *term, uint8_t final)
|
||||||
term->mouse_reporting = MOUSE_SGR;
|
term->mouse_reporting = MOUSE_SGR;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 1007:
|
||||||
|
term->alt_scrolling = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case 1015:
|
case 1015:
|
||||||
term->mouse_reporting = MOUSE_URXVT;
|
term->mouse_reporting = MOUSE_URXVT;
|
||||||
break;
|
break;
|
||||||
|
|
@ -802,6 +806,10 @@ csi_dispatch(struct terminal *term, uint8_t final)
|
||||||
term->focus_events = false;
|
term->focus_events = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 1007:
|
||||||
|
term->alt_scrolling = false;
|
||||||
|
break;
|
||||||
|
|
||||||
case 1036:
|
case 1036:
|
||||||
/* metaSendsEscape - we always send escape */
|
/* metaSendsEscape - we always send escape */
|
||||||
LOG_WARN("unimplemented: meta does *not* send escape");
|
LOG_WARN("unimplemented: meta does *not* send escape");
|
||||||
|
|
|
||||||
28
input.c
28
input.c
|
|
@ -158,10 +158,10 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
|
||||||
key += 8;
|
key += 8;
|
||||||
xkb_keysym_t sym = xkb_state_key_get_one_sym(term->kbd.xkb_state, key);
|
xkb_keysym_t sym = xkb_state_key_get_one_sym(term->kbd.xkb_state, key);
|
||||||
|
|
||||||
#if 0
|
#if 1
|
||||||
char foo[100];
|
char foo[100];
|
||||||
xkb_keysym_get_name(sym, foo, sizeof(foo));
|
xkb_keysym_get_name(sym, foo, sizeof(foo));
|
||||||
LOG_ERR("%s", foo);
|
LOG_INFO("%s", foo);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
xkb_compose_state_feed(term->kbd.xkb_compose_state, sym);
|
xkb_compose_state_feed(term->kbd.xkb_compose_state, sym);
|
||||||
|
|
@ -504,11 +504,27 @@ mouse_scroll(struct terminal *term, int amount)
|
||||||
|
|
||||||
amount = abs(amount);
|
amount = abs(amount);
|
||||||
|
|
||||||
for (int i = 0; i < amount; i++)
|
if ((button == BTN_BACK || button == BTN_FORWARD) &&
|
||||||
term_mouse_down(term, button, term->mouse.row, term->mouse.col,
|
term->grid == &term->alt && term->alt_scrolling)
|
||||||
term->kbd.shift, term->kbd.alt, term->kbd.ctrl);
|
{
|
||||||
|
/*
|
||||||
|
* alternateScroll/faux scrolling - translate mouse
|
||||||
|
* "back"/"forward" to up/down keys
|
||||||
|
*/
|
||||||
|
|
||||||
scrollback(term, amount);
|
xkb_keycode_t key = xkb_keymap_key_by_name(
|
||||||
|
term->kbd.xkb_keymap, button == BTN_BACK ? "UP" : "DOWN");
|
||||||
|
|
||||||
|
for (int i = 0; i < amount; i++)
|
||||||
|
keyboard_key(term, NULL, term->input_serial, 0, key - 8, XKB_KEY_DOWN);
|
||||||
|
keyboard_key(term, NULL, term->input_serial, 0, key - 8, XKB_KEY_UP);
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < amount; i++)
|
||||||
|
term_mouse_down(term, button, term->mouse.row, term->mouse.col,
|
||||||
|
term->kbd.shift, term->kbd.alt, term->kbd.ctrl);
|
||||||
|
|
||||||
|
scrollback(term, amount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
|
|
@ -246,6 +246,7 @@ struct terminal {
|
||||||
bool insert_mode;
|
bool insert_mode;
|
||||||
bool bracketed_paste;
|
bool bracketed_paste;
|
||||||
bool focus_events;
|
bool focus_events;
|
||||||
|
bool alt_scrolling;
|
||||||
enum mouse_tracking mouse_tracking;
|
enum mouse_tracking mouse_tracking;
|
||||||
enum mouse_reporting mouse_reporting;
|
enum mouse_reporting mouse_reporting;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue