aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/tui/input.c7
-rw-r--r--src/nvim/tui/tui.c36
2 files changed, 36 insertions, 7 deletions
diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c
index 840e472a1c..f1594dfcb9 100644
--- a/src/nvim/tui/input.c
+++ b/src/nvim/tui/input.c
@@ -553,6 +553,13 @@ static void handle_term_response(TermInput *input, const TermKeyKey *key)
if (termkey_interpret_string(input->tk, key, &str) == TERMKEY_RES_KEY) {
assert(str != NULL);
+ // Handle DECRQSS SGR response for the query from tui_query_extended_underline().
+ // Some terminals include "0" in the attribute list unconditionally; others don't.
+ if (key->type == TERMKEY_TYPE_DCS
+ && (strnequal(str, S_LEN("1$r4:3m")) || strnequal(str, S_LEN("1$r0;4:3m")))) {
+ tui_enable_extended_underline(input->tui_data);
+ }
+
// Send an event to nvim core. This will update the v:termresponse variable
// and fire the TermResponse event
MAXSIZE_TEMP_ARRAY(args, 2);
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 96054cf5cb..aaa2369e29 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -225,6 +225,26 @@ void tui_handle_term_mode(TUIData *tui, TermMode mode, TermModeState state)
}
}
+/// Query the terminal emulator to see if it supports extended underline.
+static void tui_query_extended_underline(TUIData *tui)
+{
+ // Try to set an undercurl using an SGR sequence, followed by a DECRQSS SGR query.
+ // Reset attributes first, as other code may have set attributes.
+ out(tui, S_LEN("\x1b[0m\x1b[4:3m\x1bP$qm\x1b\\"));
+ tui->print_attr_id = -1;
+}
+
+void tui_enable_extended_underline(TUIData *tui)
+{
+ if (tui->unibi_ext.set_underline_style == -1) {
+ tui->unibi_ext.set_underline_style = (int)unibi_add_ext_str(tui->ut, "ext.set_underline_style",
+ "\x1b[4:%p1%dm");
+ }
+ // Only support colon syntax. #9270
+ tui->unibi_ext.set_underline_color = (int)unibi_add_ext_str(tui->ut, "ext.set_underline_color",
+ "\x1b[58:2::%p1%d:%p2%d:%p3%dm");
+}
+
/// Query the terminal emulator to see if it supports Kitty's keyboard protocol.
///
/// Write CSI ? u followed by a primary device attributes request (CSI c). If
@@ -306,6 +326,7 @@ static void terminfo_start(TUIData *tui)
tui->unibi_ext.reset_scroll_region = -1;
tui->unibi_ext.set_cursor_style = -1;
tui->unibi_ext.reset_cursor_style = -1;
+ tui->unibi_ext.set_underline_style = -1;
tui->unibi_ext.set_underline_color = -1;
tui->unibi_ext.sync = -1;
tui->out_fd = STDOUT_FILENO;
@@ -390,6 +411,11 @@ static void terminfo_start(TUIData *tui)
// mode 2026
tui_request_term_mode(tui, kTermModeSynchronizedOutput);
+ if (tui->unibi_ext.set_underline_style == -1) {
+ // Query the terminal to see if it supports extended underline.
+ tui_query_extended_underline(tui);
+ }
+
// Query the terminal to see if it supports Kitty's keyboard protocol
tui_query_kitty_keyboard(tui);
@@ -2331,14 +2357,10 @@ static void augment_terminfo(TUIData *tui, const char *term, int vte_version, in
if (vte_version >= 5102 || konsolev >= 221170
|| (ext_bool_Su != -1 && unibi_get_ext_bool(ut, (size_t)ext_bool_Su))
|| (weztermv != NULL && strcmp(weztermv, "20210203-095643") > 0)) {
- tui->unibi_ext.set_underline_style = (int)unibi_add_ext_str(ut, "ext.set_underline_style",
- "\x1b[4:%p1%dm");
+ tui_enable_extended_underline(tui);
}
- }
- if (tui->unibi_ext.set_underline_style != -1) {
- // Only support colon syntax. #9270
- tui->unibi_ext.set_underline_color = (int)unibi_add_ext_str(ut, "ext.set_underline_color",
- "\x1b[58:2::%p1%d:%p2%d:%p3%dm");
+ } else {
+ tui_enable_extended_underline(tui);
}
if (!kitty && (vte_version == 0 || vte_version >= 5400)) {