mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:47:34 +00:00
LibVT: Replace u8 type to u32 for code point
Replace KeyEvent text attribute usage with code_point.
This commit is contained in:
parent
53227f400c
commit
7abca30f41
3 changed files with 13 additions and 18 deletions
|
@ -1004,7 +1004,7 @@ void Terminal::emit_string(const StringView& string)
|
||||||
m_client.emit((const u8*)string.characters_without_null_termination(), string.length());
|
m_client.emit((const u8*)string.characters_without_null_termination(), string.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Terminal::handle_key_press(KeyCode key, u8 character, u8 flags)
|
void Terminal::handle_key_press(KeyCode key, u32 code_point, u8 flags)
|
||||||
{
|
{
|
||||||
bool ctrl = flags & Mod_Ctrl;
|
bool ctrl = flags & Mod_Ctrl;
|
||||||
bool alt = flags & Mod_Alt;
|
bool alt = flags & Mod_Alt;
|
||||||
|
@ -1045,7 +1045,7 @@ void Terminal::handle_key_press(KeyCode key, u8 character, u8 flags)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!character) {
|
if (!code_point) {
|
||||||
// Probably a modifier being pressed.
|
// Probably a modifier being pressed.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1058,10 +1058,10 @@ void Terminal::handle_key_press(KeyCode key, u8 character, u8 flags)
|
||||||
// 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...
|
||||||
if (ctrl) {
|
if (ctrl) {
|
||||||
if (character >= 'a' && character <= 'z') {
|
if (code_point >= 'a' && code_point <= 'z') {
|
||||||
character = character - 'a' + 1;
|
code_point = code_point - 'a' + 1;
|
||||||
} else if (character == '\\') {
|
} else if (code_point == '\\') {
|
||||||
character = 0x1c;
|
code_point = 0x1c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1069,7 +1069,10 @@ void Terminal::handle_key_press(KeyCode key, u8 character, u8 flags)
|
||||||
if (alt)
|
if (alt)
|
||||||
emit_string("\033");
|
emit_string("\033");
|
||||||
|
|
||||||
emit_string({ &character, 1 });
|
StringBuilder sb;
|
||||||
|
sb.append_codepoint(code_point);
|
||||||
|
|
||||||
|
emit_string(sb.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Terminal::unimplemented_escape()
|
void Terminal::unimplemented_escape()
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace VT {
|
||||||
|
|
||||||
class TerminalClient {
|
class TerminalClient {
|
||||||
public:
|
public:
|
||||||
virtual ~TerminalClient() { }
|
virtual ~TerminalClient() {}
|
||||||
|
|
||||||
virtual void beep() = 0;
|
virtual void beep() = 0;
|
||||||
virtual void set_window_title(const StringView&) = 0;
|
virtual void set_window_title(const StringView&) = 0;
|
||||||
|
@ -97,7 +97,7 @@ public:
|
||||||
const NonnullOwnPtrVector<Line>& history() const { return m_history; }
|
const NonnullOwnPtrVector<Line>& history() const { return m_history; }
|
||||||
|
|
||||||
void inject_string(const StringView&);
|
void inject_string(const StringView&);
|
||||||
void handle_key_press(KeyCode, u8 charatcter, u8 flags);
|
void handle_key_press(KeyCode, u32, u8 flags);
|
||||||
|
|
||||||
Attribute attribute_at(const Position&) const;
|
Attribute attribute_at(const Position&) const;
|
||||||
|
|
||||||
|
|
|
@ -231,15 +231,7 @@ void TerminalWidget::keydown_event(GUI::KeyEvent& event)
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.text().length() > 2) {
|
m_terminal.handle_key_press(event.key(), event.code_point(), event.modifiers());
|
||||||
// Unicode (likely emoji), just emit it.
|
|
||||||
write(m_ptm_fd, event.text().characters(), event.text().length());
|
|
||||||
} else {
|
|
||||||
// Ask the terminal to generate the correct character sequence and send
|
|
||||||
// it back to us via emit().
|
|
||||||
u8 character = event.text().length() == 1 ? event.text()[0] : 0;
|
|
||||||
m_terminal.handle_key_press(event.key(), character, event.modifiers());
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
||||||
m_scrollbar->set_value(m_scrollbar->max());
|
m_scrollbar->set_value(m_scrollbar->max());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue