mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:57:44 +00:00
LibVT: Handle keydown events with multi-byte text correctly
TerminalWidget can now handle keydown events that contain multi-byte UTF-8 sequences. :^)
This commit is contained in:
parent
1bef057ec3
commit
1b78d9fa1f
1 changed files with 6 additions and 2 deletions
|
@ -260,8 +260,9 @@ void TerminalWidget::keydown_event(GUI::KeyEvent& event)
|
||||||
|
|
||||||
// Key event was not one of the above special cases,
|
// Key event was not one of the above special cases,
|
||||||
// attempt to treat it as a character...
|
// attempt to treat it as a character...
|
||||||
char ch = !event.text().is_empty() ? event.text()[0] : 0;
|
if (event.text().length() == 1) {
|
||||||
if (ch) {
|
// 1 byte input == ASCII
|
||||||
|
char ch = !event.text().is_empty() ? event.text()[0] : 0;
|
||||||
if (event.ctrl()) {
|
if (event.ctrl()) {
|
||||||
if (ch >= 'a' && ch <= 'z') {
|
if (ch >= 'a' && ch <= 'z') {
|
||||||
ch = ch - 'a' + 1;
|
ch = ch - 'a' + 1;
|
||||||
|
@ -285,6 +286,9 @@ void TerminalWidget::keydown_event(GUI::KeyEvent& event)
|
||||||
}
|
}
|
||||||
|
|
||||||
write(m_ptm_fd, &ch, 1);
|
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)
|
if (event.key() != Key_Control && event.key() != Key_Alt && event.key() != Key_Shift && event.key() != Key_Logo)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue