diff --git a/src/screen.cpp b/src/screen.cpp index 7ef17100b..bc06f50d3 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -189,6 +189,7 @@ static bool is_two_byte_escape_seq(const wchar_t *code, size_t *resulting_length /// Generic VT100 CSI-style sequence. , followed by zero or more ASCII characters NOT in /// the range [@,_], followed by one character in that range. +/// This will also catch color sequences. static bool is_csi_style_escape_seq(const wchar_t *code, size_t *resulting_length) { if (code[1] != L'[') { return false; @@ -214,37 +215,6 @@ static bool is_csi_style_escape_seq(const wchar_t *code, size_t *resulting_lengt return true; } -/// Detect whether the escape sequence sets foreground/background color. Note that 24-bit color -/// sequences are detected by `is_csi_style_escape_seq()` if they use the ANSI X3.64 pattern for -/// such sequences. This function only handles those escape sequences for setting color that rely on -/// the terminfo definition and which might use a different pattern. -static bool is_color_escape_seq(const wchar_t *code, size_t *resulting_length) { - if (!cur_term) return false; - - // Detect these terminfo color escapes with parameter value up to max_colors, all of which - // don't move the cursor. - const char *const esc[] = { - set_a_foreground, - set_a_background, - set_foreground, - set_background, - }; - - for (auto p : esc) { - if (!p) continue; - - for (int k = 0; k < max_colors; k++) { - size_t esc_seq_len = try_sequence(tparm(const_cast(p), k), code); - if (esc_seq_len) { - *resulting_length = esc_seq_len; - return true; - } - } - } - - return false; -} - /// Detect whether the escape sequence sets one of the terminal attributes that affects how text is /// displayed other than the color. static bool is_visual_escape_seq(const wchar_t *code, size_t *resulting_length) { @@ -285,9 +255,6 @@ maybe_t escape_code_length(const wchar_t *code) { if (!found) found = is_three_byte_escape_seq(code, &esc_seq_len); if (!found) found = is_csi_style_escape_seq(code, &esc_seq_len); if (!found) found = is_two_byte_escape_seq(code, &esc_seq_len); - // Colors are the hardest to match, so we try last. - // (also tparm is *slow*, we should try to find a better replacement) - if (!found) found = is_color_escape_seq(code, &esc_seq_len); return found ? maybe_t{esc_seq_len} : none(); }