LibVT: Support the DA (Device Attributes) request (final 'c')

This is used by vttest on startup to query the device for identity.
This commit is contained in:
Andreas Kling 2020-01-25 19:12:08 +01:00
parent f4e7aecec2
commit e6f5ce8285
4 changed files with 27 additions and 0 deletions

View file

@ -491,6 +491,12 @@ void Terminal::escape$L(const ParamVector& params)
m_need_full_flush = true;
}
void Terminal::escape$c(const ParamVector&)
{
// DA - Device Attributes
emit_string("\033[?1;0c");
}
void Terminal::escape$M(const ParamVector& params)
{
int count = 1;
@ -659,6 +665,9 @@ void Terminal::execute_escape_sequence(u8 final)
case 'h':
escape$h_l(false, question_param, params);
break;
case 'c':
escape$c(params);
break;
default:
dbgprintf("Terminal::execute_escape_sequence: Unhandled final '%c'\n", final);
break;
@ -867,6 +876,12 @@ void Terminal::inject_string(const StringView& str)
on_char(str[i]);
}
void Terminal::emit_string(const StringView& str)
{
for (size_t i = 0; i < str.length(); ++i)
m_client.emit_char(str[i]);
}
void Terminal::unimplemented_escape()
{
StringBuilder builder;

View file

@ -41,6 +41,7 @@ public:
virtual void set_window_title(const StringView&) = 0;
virtual void terminal_did_resize(u16 columns, u16 rows) = 0;
virtual void terminal_history_changed() = 0;
virtual void emit_char(u8) = 0;
};
struct Attribute {
@ -145,6 +146,8 @@ private:
void unimplemented_escape();
void unimplemented_xterm_escape();
void emit_string(const StringView&);
void escape$A(const ParamVector&);
void escape$B(const ParamVector&);
void escape$C(const ParamVector&);
@ -167,6 +170,7 @@ private:
void escape$T(const ParamVector&);
void escape$L(const ParamVector&);
void escape$h_l(bool, bool, const ParamVector&);
void escape$c(const ParamVector&);
TerminalClient& m_client;

View file

@ -679,6 +679,13 @@ void TerminalWidget::beep()
force_repaint();
}
void TerminalWidget::emit_char(u8 ch)
{
if (write(m_ptm_fd, &ch, 1) < 0) {
perror("emit_char: write");
}
}
void TerminalWidget::context_menu_event(GContextMenuEvent& event)
{
if (!m_context_menu) {

View file

@ -108,6 +108,7 @@ private:
virtual void set_window_title(const StringView&) override;
virtual void terminal_did_resize(u16 columns, u16 rows) override;
virtual void terminal_history_changed() override;
virtual void emit_char(u8) override;
void set_logical_focus(bool);