diff options
author | Benji Dial <benji6283@gmail.com> | 2021-02-16 20:38:53 -0500 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2021-02-16 20:38:53 -0500 |
commit | 47513bd32c256c4f35e3a8ced7d9fd7e15903530 (patch) | |
tree | cafdf75d52a954814726e07445063c41bb6599f9 /src/user/terminal/readline.c | |
parent | bd7facc4b5f53481dc85a15ba123361b2758655b (diff) | |
download | portland-os-47513bd32c256c4f35e3a8ced7d9fd7e15903530.tar.gz |
terminal application with ipc, shift+pause state dumper, hello world for terminal, meminfo popup program
Diffstat (limited to 'src/user/terminal/readline.c')
-rw-r--r-- | src/user/terminal/readline.c | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/src/user/terminal/readline.c b/src/user/terminal/readline.c deleted file mode 100644 index 37ef54b..0000000 --- a/src/user/terminal/readline.c +++ /dev/null @@ -1,104 +0,0 @@ -#include <terminal/terminal.h> - -#include <knob/format.h> -#include <knob/heap.h> -#include <knob/key.h> - -#include <pland/syscall.h> - -#include <stdint.h> - -//returns length of string without null terminator -//max_length doesn't include null terminator -uint32_t read_line(char *sz, uint32_t max_length, const char *prompt) { - uint32_t i = 0; - uint32_t l = 0; - - term_add_sz_no_ww(prompt); - paint_term(); - - const _window_handle_t handle = active_term->window; - struct window_action action; - while (1) { - _get_win_action(handle, &action); - switch (action.action_type) { - case NOT_READY: - _wait_for_action(); - _yield_task(); - continue; - case KEY_DOWN: - //;char *const debug_msg = format("got key 0x%2x, 0x%3x", action.as_key.key_id, action.as_key.modifiers); - // _system_log(debug_msg); - // free_block(debug_msg); - switch (action.as_key.key_id) { - case KEY_DELETE: - if (i != l) { - cursor_right(); - ++i; - } - case KEY_BSPACE: - if (!i) - continue; - --l; - --i; - for (uint8_t j = i; j < l; ++j) - sz[j] = sz[j + 1]; - sz[l] = '\0'; - cursor_left(); - uint32_t cursor_backup_x = active_term->cursor_x; - uint32_t cursor_backup_y = active_term->cursor_y; - term_add_sz_no_ww(sz + i); - term_add_char(' '); - move_cursor(cursor_backup_y, cursor_backup_x); - paint_term(); - continue; - case KEY_ENTER: - term_newline(); - paint_term(); - sz[l] = '\0'; - return l; - case KEY_HOME: - case KEY_UP_ARROW: - for (; i; --i) - cursor_left(); - paint_term(); - continue; - case KEY_END: - case KEY_DOWN_ARROW: - for (; i != l; ++i) - cursor_right(); - paint_term(); - continue; - case KEY_LEFT_ARROW: - if (i) { - cursor_left(); - paint_term(); - --i; - } - continue; - case KEY_RIGHT_ARROW: - if (i != l) { - cursor_right(); - paint_term(); - ++i; - } - continue; - default: - if (i == max_length) - continue; - char ch = key_to_char(action.as_key); - if (ch) { - term_add_char(ch); - paint_term(); - sz[i] = ch; - if (i == l) - ++l; - ++i; - } - continue; - } - default: - continue; - } - } -}
\ No newline at end of file |