summaryrefslogtreecommitdiff
path: root/Libraries/LibVT
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-05-17 21:48:43 +0200
committerAndreas Kling <kling@serenityos.org>2020-05-17 22:35:25 +0200
commit1b78d9fa1f8fecf46fd094636f049cd157e21d29 (patch)
tree860d6a3b0256c10a7e06db6435a30ee861035397 /Libraries/LibVT
parent1bef057ec3cd652f059dedd59eba40a0c3e67e10 (diff)
downloadserenity-1b78d9fa1f8fecf46fd094636f049cd157e21d29.zip
LibVT: Handle keydown events with multi-byte text correctly
TerminalWidget can now handle keydown events that contain multi-byte UTF-8 sequences. :^)
Diffstat (limited to 'Libraries/LibVT')
-rw-r--r--Libraries/LibVT/TerminalWidget.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/Libraries/LibVT/TerminalWidget.cpp b/Libraries/LibVT/TerminalWidget.cpp
index 97cb2c8544..d068c90c09 100644
--- a/Libraries/LibVT/TerminalWidget.cpp
+++ b/Libraries/LibVT/TerminalWidget.cpp
@@ -260,8 +260,9 @@ void TerminalWidget::keydown_event(GUI::KeyEvent& event)
// Key event was not one of the above special cases,
// attempt to treat it as a character...
- char ch = !event.text().is_empty() ? event.text()[0] : 0;
- if (ch) {
+ if (event.text().length() == 1) {
+ // 1 byte input == ASCII
+ char ch = !event.text().is_empty() ? event.text()[0] : 0;
if (event.ctrl()) {
if (ch >= 'a' && ch <= 'z') {
ch = ch - 'a' + 1;
@@ -285,6 +286,9 @@ void TerminalWidget::keydown_event(GUI::KeyEvent& event)
}
write(m_ptm_fd, &ch, 1);
+ } else if (event.text().length() > 1) {
+ // 2+ byte input == Unicode
+ write(m_ptm_fd, event.text().characters(), event.text().length());
}
if (event.key() != Key_Control && event.key() != Key_Alt && event.key() != Key_Shift && event.key() != Key_Logo)