summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-05-09 10:38:57 +0200
committerAndreas Kling <kling@serenityos.org>2020-05-09 12:02:22 +0200
commit283bd1a95c4260a7e613de34f5a0f5e41e534b48 (patch)
tree8ed25a9c4152b4b5ddd8599e9641af344fc43076 /Libraries
parentb1fee139046e2b65739ea550dc7e8c6103518f6b (diff)
downloadserenity-283bd1a95c4260a7e613de34f5a0f5e41e534b48.zip
LibVT: Respond to DSR 0 (device status)
Also emit query responses in a single write() syscall instead of going character-at-a-time.
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibVT/Terminal.cpp23
-rw-r--r--Libraries/LibVT/Terminal.h4
-rw-r--r--Libraries/LibVT/TerminalWidget.cpp6
-rw-r--r--Libraries/LibVT/TerminalWidget.h2
4 files changed, 19 insertions, 16 deletions
diff --git a/Libraries/LibVT/Terminal.cpp b/Libraries/LibVT/Terminal.cpp
index b9e6806c0b..690b0fd1d3 100644
--- a/Libraries/LibVT/Terminal.cpp
+++ b/Libraries/LibVT/Terminal.cpp
@@ -705,10 +705,7 @@ void Terminal::execute_escape_sequence(u8 final)
HVP(params);
break;
case 'n':
- if (params.size() == 1 && params[0] == 6)
- DSR();
- else
- dbg() << "Unknown CSIxn command";
+ DSR(params);
break;
default:
dbgprintf("Terminal::execute_escape_sequence: Unhandled final '%c'\n", final);
@@ -812,10 +809,17 @@ void Terminal::RI()
CUU({});
}
-void Terminal::DSR()
+void Terminal::DSR(const ParamVector& params)
{
- // Device Status Report (cursor position query)
- emit_string(String::format("\033[%d;%dR", m_cursor_row + 1, m_cursor_column + 1));
+ if (params.size() == 1 && params[0] == 5) {
+ // Device status
+ emit_string("\033[0n"); // Terminal status OK!
+ } else if (params.size() == 1 && params[0] == 6) {
+ // Cursor position query
+ emit_string(String::format("\033[%d;%dR", m_cursor_row + 1, m_cursor_column + 1));
+ } else {
+ dbg() << "Unknown DSR";
+ }
}
void Terminal::on_char(u8 ch)
@@ -962,10 +966,9 @@ void Terminal::inject_string(const StringView& str)
on_char(str[i]);
}
-void Terminal::emit_string(const StringView& str)
+void Terminal::emit_string(const StringView& string)
{
- for (size_t i = 0; i < str.length(); ++i)
- m_client.emit_char(str[i]);
+ m_client.emit((const u8*)string.characters_without_null_termination(), string.length());
}
void Terminal::unimplemented_escape()
diff --git a/Libraries/LibVT/Terminal.h b/Libraries/LibVT/Terminal.h
index 91fd74dc89..4d704da89b 100644
--- a/Libraries/LibVT/Terminal.h
+++ b/Libraries/LibVT/Terminal.h
@@ -41,7 +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;
+ virtual void emit(const u8*, size_t) = 0;
};
struct Attribute {
@@ -178,7 +178,7 @@ private:
void NEL();
void IND();
void RI();
- void DSR();
+ void DSR(const ParamVector&);
TerminalClient& m_client;
diff --git a/Libraries/LibVT/TerminalWidget.cpp b/Libraries/LibVT/TerminalWidget.cpp
index 1b47bd923a..a3ade54cff 100644
--- a/Libraries/LibVT/TerminalWidget.cpp
+++ b/Libraries/LibVT/TerminalWidget.cpp
@@ -711,10 +711,10 @@ void TerminalWidget::beep()
force_repaint();
}
-void TerminalWidget::emit_char(u8 ch)
+void TerminalWidget::emit(const u8* data, size_t size)
{
- if (write(m_ptm_fd, &ch, 1) < 0) {
- perror("emit_char: write");
+ if (write(m_ptm_fd, data, size) < 0) {
+ perror("TerminalWidget::emit: write");
}
}
diff --git a/Libraries/LibVT/TerminalWidget.h b/Libraries/LibVT/TerminalWidget.h
index c62c54cba2..6eb99a74a4 100644
--- a/Libraries/LibVT/TerminalWidget.h
+++ b/Libraries/LibVT/TerminalWidget.h
@@ -108,7 +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;
+ virtual void emit(const u8*, size_t) override;
void set_logical_focus(bool);