MiniDevil
As beautiful as a shell
Key input reading (decodes escape sequences & arrow keys) More...
#include "minishell_ui.h"
Include dependency graph for input.c:Key input reading (decodes escape sequences & arrow keys)
Definition in file input.c.
Functions | |
| int | read_key (void) |
| Read 1 keypress or escape sequence from STDIN. More... | |
| void | cmd_add_char (t_cmd *cmd, char c) |
| Append a printable character to the command buffer. More... | |
| void | cmd_del_char (t_cmd *cmd) |
| Remove the last character from the command buffer. More... | |
| static void | handle_scroll (t_ui *ui, int key) |
| Adjust the scroll offset and refresh the output panel. More... | |
| void | handle_key (t_shell *shell, int key) |
| Dispatch key code to the appropriate UI action. More... | |
| int read_key | ( | void | ) |
| void cmd_add_char | ( | t_cmd * | cmd, |
| char | c | ||
| ) |
Append a printable character to the command buffer.
Does nothing if the buffer could cause an overflow on MAX_CMD_LEN
| cmd | Command buffer |
| c | Character to append |
Definition at line 57 of file input.c.
References t_cmd::buf, t_cmd::len, and MAX_CMD_LEN.
Referenced by handle_key().
Here is the caller graph for this function:| void cmd_del_char | ( | t_cmd * | cmd | ) |
Remove the last character from the command buffer.
Does nothing if the buffer is empty
| cmd | Command buffer |
Definition at line 74 of file input.c.
References t_cmd::buf, and t_cmd::len.
Referenced by handle_key().
Here is the caller graph for this function:
|
static |
Adjust the scroll offset and refresh the output panel.
| ui | UI state |
| key | KEY_UP or KEY_DOWN |
Definition at line 92 of file input.c.
References t_out::count, KEY_DOWN, KEY_UP, t_ui::out, redraw_output_only(), and t_out::scroll.
Referenced by handle_key().
Here is the call graph for this function:
Here is the caller graph for this function:| void handle_key | ( | t_shell * | shell, |
| int | key | ||
| ) |
Dispatch key code to the appropriate UI action.
KEY_ENTER: cmd_execute()KEY_BACKSPACE: cmd_del_char()KEY_CTRL_D: stop loopKEY_CTRL_C: clear the command bufferKEY_UP / KEY_DOWN: handle_scroll()| shell | |
| key |
Definition at line 119 of file input.c.
References t_cmd::buf, t_ui::cmd, cmd_add_char(), cmd_del_char(), cmd_execute(), handle_scroll(), KEY_BACKSPACE, KEY_CTRL_C, KEY_CTRL_D, KEY_DOWN, KEY_ENTER, KEY_UP, t_cmd::len, MAX_CMD_LEN, t_ui::running, and t_shell::ui.
Referenced by ui_loop().
Here is the call graph for this function:
Here is the caller graph for this function: