Kernel/Terminal: Add support for bracketed paste mode

This gets rid of annoying warnings when running some programs like bash
This commit is contained in:
Bananymous 2025-11-18 03:07:54 +02:00
parent 8f6cb9c057
commit db7ffcf9d5
3 changed files with 29 additions and 3 deletions

View File

@ -417,6 +417,11 @@ namespace Kernel
m_cursor_shown = (ch == 'h'); m_cursor_shown = (ch == 'h');
return reset_ansi(); return reset_ansi();
} }
if (m_ansi_state.question && m_ansi_state.nums[0] == 2004)
{
// bracketed paste mode, there is no pasting so this is a no-op
return reset_ansi();
}
reset_ansi(); reset_ansi();
dprintln_if(DEBUG_VTTY, "Unsupported ANSI CSI character {}", static_cast<char>(ch)); dprintln_if(DEBUG_VTTY, "Unsupported ANSI CSI character {}", static_cast<char>(ch));
return; return;

View File

@ -274,7 +274,13 @@ void Terminal::run()
auto clipboard = clipboard_or_error.release_value(); auto clipboard = clipboard_or_error.release_value();
if (!clipboard.empty()) if (!clipboard.empty())
{
if (m_brackted_paste_mode)
write(m_shell_info.pts_master, "\e[200~", 6);
write(m_shell_info.pts_master, clipboard.data(), clipboard.size()); write(m_shell_info.pts_master, clipboard.data(), clipboard.size());
if (m_brackted_paste_mode)
write(m_shell_info.pts_master, "\e[201~", 6);
}
m_got_key_event = true; m_got_key_event = true;
break; break;
@ -930,12 +936,26 @@ Rectangle Terminal::handle_csi(char ch)
break; break;
case 'h': case 'h':
case 'l': case 'l':
if (!m_csi_info.question || m_csi_info.fields[0] != 25) if (m_csi_info.question)
{ {
dprintln("unsupported ANSI CSI {}", ch); switch (m_csi_info.fields[0])
{
case 25:
m_cursor_shown = (ch == 'h');
break;
case 2004:
m_brackted_paste_mode = (ch == 'h');
break;
default:
dwarnln("unsupported ANSI CSI ? {} {}", m_csi_info.fields[0], ch);
break;
}
}
else
{
dwarnln("unsupported ANSI CSI {} {}", m_csi_info.fields[0], ch);
break; break;
} }
m_cursor_shown = (ch == 'h');
break; break;
case 'n': case 'n':
if (m_csi_info.fields[0] != 6) if (m_csi_info.fields[0] != 6)

View File

@ -106,6 +106,7 @@ private:
uint32_t m_selection_e_col { UINT32_MAX }; uint32_t m_selection_e_col { UINT32_MAX };
uint32_t m_selection_e_row { UINT32_MAX }; uint32_t m_selection_e_row { UINT32_MAX };
bool m_selecting { false }; bool m_selecting { false };
bool m_brackted_paste_mode { false };
bool m_cursor_shown { true }; bool m_cursor_shown { true };
bool m_cursor_blink_shown { true }; bool m_cursor_blink_shown { true };