mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
feat(tui): support APC queries in TermResponse (#34426)
Add support for APC sequences to libtermkey and the TermResponse autocommand event.
This commit is contained in:
@@ -4028,8 +4028,8 @@ nvim_ui_term_event({event}, {value}) *nvim_ui_term_event()*
|
|||||||
Tells Nvim when a terminal event has occurred
|
Tells Nvim when a terminal event has occurred
|
||||||
|
|
||||||
The following terminal events are supported:
|
The following terminal events are supported:
|
||||||
• "termresponse": The terminal sent an OSC or DCS response sequence to
|
• "termresponse": The terminal sent an OSC, DCS, or APC response sequence
|
||||||
Nvim. The payload is the received response. Sets |v:termresponse| and
|
to Nvim. The payload is the received response. Sets |v:termresponse| and
|
||||||
fires |TermResponse|.
|
fires |TermResponse|.
|
||||||
|
|
||||||
Attributes: ~
|
Attributes: ~
|
||||||
|
@@ -1045,7 +1045,7 @@ TermRequest When a |:terminal| child process emits an OSC,
|
|||||||
autocommand defined without |autocmd-nested|.
|
autocommand defined without |autocmd-nested|.
|
||||||
|
|
||||||
*TermResponse*
|
*TermResponse*
|
||||||
TermResponse When Nvim receives an OSC or DCS response from
|
TermResponse When Nvim receives an OSC, DCS, or APC response from
|
||||||
the host terminal. Sets |v:termresponse|. The
|
the host terminal. Sets |v:termresponse|. The
|
||||||
|event-data| is a table with the following fields:
|
|event-data| is a table with the following fields:
|
||||||
|
|
||||||
|
@@ -221,7 +221,7 @@ TREESITTER
|
|||||||
|
|
||||||
TUI
|
TUI
|
||||||
|
|
||||||
• todo
|
• |TermResponse| now supports APC query responses.
|
||||||
|
|
||||||
UI
|
UI
|
||||||
|
|
||||||
|
@@ -540,7 +540,7 @@ void nvim_ui_pum_set_bounds(uint64_t channel_id, Float width, Float height, Floa
|
|||||||
///
|
///
|
||||||
/// The following terminal events are supported:
|
/// The following terminal events are supported:
|
||||||
///
|
///
|
||||||
/// - "termresponse": The terminal sent an OSC or DCS response sequence to
|
/// - "termresponse": The terminal sent an OSC, DCS, or APC response sequence to
|
||||||
/// Nvim. The payload is the received response. Sets
|
/// Nvim. The payload is the received response. Sets
|
||||||
/// |v:termresponse| and fires |TermResponse|.
|
/// |v:termresponse| and fires |TermResponse|.
|
||||||
///
|
///
|
||||||
|
@@ -463,7 +463,8 @@ static void tk_getkeys(TermInput *input, bool force)
|
|||||||
handle_modereport(input, &key);
|
handle_modereport(input, &key);
|
||||||
} else if (key.type == TERMKEY_TYPE_UNKNOWN_CSI) {
|
} else if (key.type == TERMKEY_TYPE_UNKNOWN_CSI) {
|
||||||
handle_unknown_csi(input, &key);
|
handle_unknown_csi(input, &key);
|
||||||
} else if (key.type == TERMKEY_TYPE_OSC || key.type == TERMKEY_TYPE_DCS) {
|
} else if (key.type == TERMKEY_TYPE_OSC || key.type == TERMKEY_TYPE_DCS
|
||||||
|
|| key.type == TERMKEY_TYPE_APC) {
|
||||||
handle_term_response(input, &key);
|
handle_term_response(input, &key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -600,6 +601,9 @@ static void handle_term_response(TermInput *input, const TermKeyKey *key)
|
|||||||
case TERMKEY_TYPE_DCS:
|
case TERMKEY_TYPE_DCS:
|
||||||
kv_printf(response, "\x1bP%s", str);
|
kv_printf(response, "\x1bP%s", str);
|
||||||
break;
|
break;
|
||||||
|
case TERMKEY_TYPE_APC:
|
||||||
|
kv_printf(response, "\x1b_%s", str);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// Key type already checked for OSC/DCS in termkey_interpret_string
|
// Key type already checked for OSC/DCS in termkey_interpret_string
|
||||||
UNREACHABLE;
|
UNREACHABLE;
|
||||||
|
@@ -890,8 +890,22 @@ static TermKeyResult peekkey_ctrlstring(TermKey *tk, TermKeyCsi *csi, size_t int
|
|||||||
strncpy(csi->saved_string, (char *)tk->buffer + tk->buffstart + introlen, len); // NOLINT(runtime/printf)
|
strncpy(csi->saved_string, (char *)tk->buffer + tk->buffstart + introlen, len); // NOLINT(runtime/printf)
|
||||||
csi->saved_string[len] = 0;
|
csi->saved_string[len] = 0;
|
||||||
|
|
||||||
key->type = (CHARAT(introlen - 1) & 0x1f) == 0x10
|
char type = CHARAT(introlen - 1) & 0x1f;
|
||||||
? TERMKEY_TYPE_DCS : TERMKEY_TYPE_OSC;
|
switch (type) {
|
||||||
|
case 0x10:
|
||||||
|
key->type = TERMKEY_TYPE_DCS;
|
||||||
|
break;
|
||||||
|
case 0x1d:
|
||||||
|
key->type = TERMKEY_TYPE_OSC;
|
||||||
|
break;
|
||||||
|
case 0x1f:
|
||||||
|
key->type = TERMKEY_TYPE_APC;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Unreachable
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
key->code.number = csi->saved_string_id;
|
key->code.number = csi->saved_string_id;
|
||||||
key->modifiers = 0;
|
key->modifiers = 0;
|
||||||
|
|
||||||
@@ -918,6 +932,7 @@ TermKeyResult peekkey_csi(TermKey *tk, void *info, TermKeyKey *key, int force, s
|
|||||||
|
|
||||||
case 0x50: // ESC-prefixed DCS
|
case 0x50: // ESC-prefixed DCS
|
||||||
case 0x5d: // ESC-prefixed OSC
|
case 0x5d: // ESC-prefixed OSC
|
||||||
|
case 0x5f: // ESC-prefixed APC
|
||||||
return peekkey_ctrlstring(tk, csi, 2, key, force, nbytep);
|
return peekkey_ctrlstring(tk, csi, 2, key, force, nbytep);
|
||||||
|
|
||||||
case 0x5b: // ESC-prefixed CSI
|
case 0x5b: // ESC-prefixed CSI
|
||||||
|
@@ -182,6 +182,9 @@ static void print_key(TermKey *tk, TermKeyKey *key)
|
|||||||
case TERMKEY_TYPE_OSC:
|
case TERMKEY_TYPE_OSC:
|
||||||
fprintf(stderr, "Operating System Control");
|
fprintf(stderr, "Operating System Control");
|
||||||
break;
|
break;
|
||||||
|
case TERMKEY_TYPE_APC:
|
||||||
|
fprintf(stderr, "Application Program Command");
|
||||||
|
break;
|
||||||
case TERMKEY_TYPE_UNKNOWN_CSI:
|
case TERMKEY_TYPE_UNKNOWN_CSI:
|
||||||
fprintf(stderr, "unknown CSI\n");
|
fprintf(stderr, "unknown CSI\n");
|
||||||
break;
|
break;
|
||||||
@@ -231,7 +234,8 @@ TermKeyResult termkey_interpret_string(TermKey *tk, const TermKeyKey *key, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (key->type != TERMKEY_TYPE_DCS
|
if (key->type != TERMKEY_TYPE_DCS
|
||||||
&& key->type != TERMKEY_TYPE_OSC) {
|
&& key->type != TERMKEY_TYPE_OSC
|
||||||
|
&& key->type != TERMKEY_TYPE_APC) {
|
||||||
return TERMKEY_RES_NONE;
|
return TERMKEY_RES_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1270,6 +1274,9 @@ size_t termkey_strfkey(TermKey *tk, char *buffer, size_t len, TermKeyKey *key, T
|
|||||||
case TERMKEY_TYPE_OSC:
|
case TERMKEY_TYPE_OSC:
|
||||||
l = (size_t)snprintf(buffer + pos, len - pos, "OSC");
|
l = (size_t)snprintf(buffer + pos, len - pos, "OSC");
|
||||||
break;
|
break;
|
||||||
|
case TERMKEY_TYPE_APC:
|
||||||
|
l = (size_t)snprintf(buffer + pos, len - pos, "APC");
|
||||||
|
break;
|
||||||
case TERMKEY_TYPE_UNKNOWN_CSI:
|
case TERMKEY_TYPE_UNKNOWN_CSI:
|
||||||
l = (size_t)snprintf(buffer + pos, len - pos, "CSI %c", key->code.number & 0xff);
|
l = (size_t)snprintf(buffer + pos, len - pos, "CSI %c", key->code.number & 0xff);
|
||||||
break;
|
break;
|
||||||
|
@@ -111,6 +111,7 @@ typedef enum {
|
|||||||
TERMKEY_TYPE_MODEREPORT,
|
TERMKEY_TYPE_MODEREPORT,
|
||||||
TERMKEY_TYPE_DCS,
|
TERMKEY_TYPE_DCS,
|
||||||
TERMKEY_TYPE_OSC,
|
TERMKEY_TYPE_OSC,
|
||||||
|
TERMKEY_TYPE_APC,
|
||||||
// add other recognised types here
|
// add other recognised types here
|
||||||
|
|
||||||
TERMKEY_TYPE_UNKNOWN_CSI = -1,
|
TERMKEY_TYPE_UNKNOWN_CSI = -1,
|
||||||
|
Reference in New Issue
Block a user