mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-14 08:21:27 -04:00
input: implement metaSendsEscape and eightBitMeta
This commit is contained in:
parent
4e87426712
commit
a3d919a90d
5 changed files with 101 additions and 34 deletions
21
csi.c
21
csi.c
|
|
@ -927,8 +927,16 @@ csi_dispatch(struct terminal *term, uint8_t final)
|
||||||
term->mouse_reporting = MOUSE_URXVT;
|
term->mouse_reporting = MOUSE_URXVT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 1034:
|
||||||
|
/* smm */
|
||||||
|
LOG_DBG("enabling 8-bit meta mode");
|
||||||
|
term->meta.eight_bit = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case 1036:
|
case 1036:
|
||||||
/* metaSendsEscape - we always send escape */
|
/* metaSendsEscape */
|
||||||
|
LOG_DBG("enabling meta-sends-escape");
|
||||||
|
term->meta.esc_prefix = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
@ -1037,9 +1045,16 @@ csi_dispatch(struct terminal *term, uint8_t final)
|
||||||
term->alt_scrolling = false;
|
term->alt_scrolling = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 1034:
|
||||||
|
/* rmm */
|
||||||
|
LOG_DBG("disabling 8-bit meta mode");
|
||||||
|
term->meta.eight_bit = false;
|
||||||
|
break;
|
||||||
|
|
||||||
case 1036:
|
case 1036:
|
||||||
/* metaSendsEscape - we always send escape */
|
/* metaSendsEscape */
|
||||||
LOG_WARN("unimplemented: meta does *not* send escape");
|
LOG_DBG("disabling meta-sends-escape");
|
||||||
|
term->meta.esc_prefix = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
||||||
|
|
@ -221,6 +221,7 @@ foot+base|foot base fragment,
|
||||||
rmcup=\E[?1049l\E[23;0t,
|
rmcup=\E[?1049l\E[23;0t,
|
||||||
rmir=\E[4l,
|
rmir=\E[4l,
|
||||||
rmkx=\E[?1l\E>,
|
rmkx=\E[?1l\E>,
|
||||||
|
rmm=\E[?1034l,
|
||||||
rmso=\E[27m,
|
rmso=\E[27m,
|
||||||
rmul=\E[24m,
|
rmul=\E[24m,
|
||||||
rmxx=\E[29m,
|
rmxx=\E[29m,
|
||||||
|
|
@ -235,6 +236,7 @@ foot+base|foot base fragment,
|
||||||
smcup=\E[?1049h\E[22;0t,
|
smcup=\E[?1049h\E[22;0t,
|
||||||
smir=\E[4h,
|
smir=\E[4h,
|
||||||
smkx=\E[?1h\E=,
|
smkx=\E[?1h\E=,
|
||||||
|
smm=\E[?1034h,
|
||||||
smso=\E[7m,
|
smso=\E[7m,
|
||||||
smul=\E[4m,
|
smul=\E[4m,
|
||||||
smxx=\E[9m,
|
smxx=\E[9m,
|
||||||
|
|
|
||||||
40
input.c
40
input.c
|
|
@ -484,9 +484,47 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
if (effective_mods & alt)
|
if (effective_mods & alt) {
|
||||||
|
/*
|
||||||
|
* When the alt modifier is pressed, we do one out of three things:
|
||||||
|
*
|
||||||
|
* 1. we prefix the output bytes with ESC
|
||||||
|
* 2. we set the 8:th bit in the output byte
|
||||||
|
* 3. we ignore the alt modifier
|
||||||
|
*
|
||||||
|
* #1 is configured with \E[?1036, and is on by default
|
||||||
|
*
|
||||||
|
* If #1 has been disabled, we use #2, *if* it's a single
|
||||||
|
* byte we're emitting. Since this is an UTF-8 terminal,
|
||||||
|
* we then UTF8-encode the 8-bit character. #2 is
|
||||||
|
* configured with \E[?1034, and is on by default.
|
||||||
|
*
|
||||||
|
* Lastly, if both #1 and #2 have been disabled, the alt
|
||||||
|
* modifier is ignored.
|
||||||
|
*/
|
||||||
|
if (term->meta.esc_prefix) {
|
||||||
term_to_slave(term, "\x1b", 1);
|
term_to_slave(term, "\x1b", 1);
|
||||||
|
term_to_slave(term, buf, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (term->meta.eight_bit && count == 1) {
|
||||||
|
const wchar_t wc = 0x80 | buf[0];
|
||||||
|
|
||||||
|
char utf8[8];
|
||||||
|
mbstate_t ps = {0};
|
||||||
|
size_t chars = wcrtomb(utf8, wc, &ps);
|
||||||
|
|
||||||
|
if (chars != (size_t)-1)
|
||||||
|
term_to_slave(term, utf8, chars);
|
||||||
|
else
|
||||||
|
term_to_slave(term, buf, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
/* Alt ignored */
|
||||||
|
term_to_slave(term, buf, count);
|
||||||
|
}
|
||||||
|
} else
|
||||||
term_to_slave(term, buf, count);
|
term_to_slave(term, buf, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -652,6 +652,10 @@ term_init(const struct config *conf, struct fdm *fdm, struct wayland *wayl,
|
||||||
.normal = {.damage = tll_init(), .scroll_damage = tll_init()},
|
.normal = {.damage = tll_init(), .scroll_damage = tll_init()},
|
||||||
.alt = {.damage = tll_init(), .scroll_damage = tll_init()},
|
.alt = {.damage = tll_init(), .scroll_damage = tll_init()},
|
||||||
.grid = &term->normal,
|
.grid = &term->normal,
|
||||||
|
.meta = {
|
||||||
|
.esc_prefix = true,
|
||||||
|
.eight_bit = true,
|
||||||
|
},
|
||||||
.tab_stops = tll_init(),
|
.tab_stops = tll_init(),
|
||||||
.wl = wayl,
|
.wl = wayl,
|
||||||
.render = {
|
.render = {
|
||||||
|
|
@ -1032,6 +1036,9 @@ term_reset(struct terminal *term, bool hard)
|
||||||
selection_cancel(term);
|
selection_cancel(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
term->meta.esc_prefix = true;
|
||||||
|
term->meta.eight_bit = true;
|
||||||
|
|
||||||
if (!hard)
|
if (!hard)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -283,6 +283,11 @@ struct terminal {
|
||||||
|
|
||||||
struct font *fonts[4];
|
struct font *fonts[4];
|
||||||
|
|
||||||
|
struct {
|
||||||
|
bool esc_prefix;
|
||||||
|
bool eight_bit;
|
||||||
|
} meta;
|
||||||
|
|
||||||
tll(int) tab_stops;
|
tll(int) tab_stops;
|
||||||
|
|
||||||
struct wayland *wl;
|
struct wayland *wl;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue