mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-27 01:50:24 +00:00
Add support for keyboard arrow keys.
Also have them send the appropriate escape sequences in Terminal. Basic history browsing now works in bash. How nice! :^)
This commit is contained in:
parent
f176af7cd1
commit
56b6fb198a
Notes:
sideshowbarker
2024-07-19 15:54:53 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/56b6fb198ab
2 changed files with 49 additions and 6 deletions
|
@ -42,12 +42,26 @@ static KeyCode unshifted_key_map[0x80] =
|
|||
Key_Return, // 28
|
||||
Key_Control, // 29
|
||||
Key_A, Key_S, Key_D, Key_F, Key_G, Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Apostrophe, Key_Backtick,
|
||||
Key_Shift,
|
||||
Key_Shift, // 42
|
||||
Key_Backslash,
|
||||
Key_Z, Key_X, Key_C, Key_V, Key_B, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash,
|
||||
Key_Alt,
|
||||
Key_Alt, // 54
|
||||
Key_Invalid, Key_Invalid,
|
||||
Key_Space
|
||||
Key_Space, // 57
|
||||
Key_Invalid, Key_Invalid,
|
||||
Key_Invalid, // 60
|
||||
Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid,
|
||||
Key_Invalid, // 70
|
||||
Key_Invalid,
|
||||
Key_Up,
|
||||
Key_Invalid,
|
||||
Key_Invalid,
|
||||
Key_Left,
|
||||
Key_Invalid,
|
||||
Key_Right, // 77
|
||||
Key_Invalid,
|
||||
Key_Invalid,
|
||||
Key_Down, // 80
|
||||
};
|
||||
|
||||
static KeyCode shifted_key_map[0x100] =
|
||||
|
@ -64,10 +78,23 @@ static KeyCode shifted_key_map[0x100] =
|
|||
Key_Z, Key_X, Key_C, Key_V, Key_B, Key_N, Key_M, Key_LessThan, Key_GreaterThan, Key_QuestionMark,
|
||||
Key_Alt,
|
||||
Key_Invalid, Key_Invalid,
|
||||
Key_Space
|
||||
Key_Space,
|
||||
Key_Invalid, Key_Invalid,
|
||||
Key_Invalid, // 60
|
||||
Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid, Key_Invalid,
|
||||
Key_Invalid, // 70
|
||||
Key_Invalid,
|
||||
Key_Up,
|
||||
Key_Invalid,
|
||||
Key_Invalid,
|
||||
Key_Left,
|
||||
Key_Invalid,
|
||||
Key_Right, // 77
|
||||
Key_Invalid,
|
||||
Key_Invalid,
|
||||
Key_Down, // 80
|
||||
};
|
||||
|
||||
|
||||
void Keyboard::key_state_changed(byte raw, bool pressed)
|
||||
{
|
||||
Event event;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <sys/select.h>
|
||||
#include <LibC/gui.h>
|
||||
#include "Terminal.h"
|
||||
#include <Kernel/KeyCode.h>
|
||||
|
||||
static void make_shell(int ptm_fd)
|
||||
{
|
||||
|
@ -128,7 +129,22 @@ int main(int, char**)
|
|||
ch = 0x1c;
|
||||
}
|
||||
}
|
||||
write(ptm_fd, &ch, 1);
|
||||
switch (event.key.key) {
|
||||
case KeyCode::Key_Up:
|
||||
write(ptm_fd, "\033[A", 3);
|
||||
break;
|
||||
case KeyCode::Key_Down:
|
||||
write(ptm_fd, "\033[B", 3);
|
||||
break;
|
||||
case KeyCode::Key_Left:
|
||||
write(ptm_fd, "\033[C", 3);
|
||||
break;
|
||||
case KeyCode::Key_Right:
|
||||
write(ptm_fd, "\033[D", 3);
|
||||
break;
|
||||
default:
|
||||
write(ptm_fd, &ch, 1);
|
||||
}
|
||||
} else if (event.type == GUI_Event::Type::WindowActivated) {
|
||||
terminal.set_in_active_window(true);
|
||||
} else if (event.type == GUI_Event::Type::WindowDeactivated) {
|
||||
|
|
Loading…
Reference in a new issue