diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-01-30 21:18:13 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-01-30 21:18:13 +0100 |
commit | 56b6fb198ab7bf77664da54c2f1bcaa322037317 (patch) | |
tree | 5ec860a43ec4546b635516274b19708ada0ad8d6 /Terminal | |
parent | f176af7cd1ff978e6444b273fa1a81fa9998c83f (diff) | |
download | serenity-56b6fb198ab7bf77664da54c2f1bcaa322037317.zip |
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! :^)
Diffstat (limited to 'Terminal')
-rw-r--r-- | Terminal/main.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/Terminal/main.cpp b/Terminal/main.cpp index 98b29047dd..2fee6aaa4c 100644 --- a/Terminal/main.cpp +++ b/Terminal/main.cpp @@ -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) { |