summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-01-25 19:12:08 +0100
committerAndreas Kling <kling@serenityos.org>2020-01-25 19:12:08 +0100
commite6f5ce82852f6f88d5f6296ef469963244b34f17 (patch)
treeb144c00ec30305d75dc1bff19e76bbf32665fd3a /Libraries
parentf4e7aecec24d1aa910e22a782f169efdfdfd564b (diff)
downloadserenity-e6f5ce82852f6f88d5f6296ef469963244b34f17.zip
LibVT: Support the DA (Device Attributes) request (final 'c')
This is used by vttest on startup to query the device for identity.
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibVT/Terminal.cpp15
-rw-r--r--Libraries/LibVT/Terminal.h4
-rw-r--r--Libraries/LibVT/TerminalWidget.cpp7
-rw-r--r--Libraries/LibVT/TerminalWidget.h1
4 files changed, 27 insertions, 0 deletions
diff --git a/Libraries/LibVT/Terminal.cpp b/Libraries/LibVT/Terminal.cpp
index fe191c1872..4241392053 100644
--- a/Libraries/LibVT/Terminal.cpp
+++ b/Libraries/LibVT/Terminal.cpp
@@ -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;
diff --git a/Libraries/LibVT/Terminal.h b/Libraries/LibVT/Terminal.h
index 48418957d2..7679eb6fa7 100644
--- a/Libraries/LibVT/Terminal.h
+++ b/Libraries/LibVT/Terminal.h
@@ -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;
diff --git a/Libraries/LibVT/TerminalWidget.cpp b/Libraries/LibVT/TerminalWidget.cpp
index 7f0a256291..50e9f2ec13 100644
--- a/Libraries/LibVT/TerminalWidget.cpp
+++ b/Libraries/LibVT/TerminalWidget.cpp
@@ -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) {
diff --git a/Libraries/LibVT/TerminalWidget.h b/Libraries/LibVT/TerminalWidget.h
index 9d9744cafd..fcd4adeedb 100644
--- a/Libraries/LibVT/TerminalWidget.h
+++ b/Libraries/LibVT/TerminalWidget.h
@@ -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);