MiniDevil
As beautiful as a shell
UI mode structures, macros & function prototypes. More...
#include <sys/ioctl.h>#include <termios.h>#include "structs.h"#include "libft.h"#include "ft_printf.h"#include "signals.h"
Include dependency graph for minishell_ui.h:
This graph shows which files directly or indirectly include this file:UI mode structures, macros & function prototypes.
Definition in file minishell_ui.h.
Macros | |
| #define | ESC_SEQ "\033[" |
| #define | CLEAR_SCREEN "\033[2J\033[H" |
| #define | CLEAR_LINE "\033[2K" |
| #define | CURSOR_HIDE "\033[?25l" |
| #define | CURSOR_SHOW "\033[?25h" |
| #define | SAVE_CURSOR "\033[s" |
| #define | RESTORE_CURSOR "\033[u" |
| #define | RESET "\033[0m" |
| #define | BOLD "\033[1m" |
| #define | DIM "\033[2m" |
| #define | CYAN "\033[38;5;51m" |
| #define | PURPLE "\033[38;5;141m" |
| #define | GREEN "\033[38;5;47m" |
| #define | RED "\033[38;5;196m" |
| #define | YELLOW "\033[38;5;226m" |
| #define | WHITE "\033[38;5;231m" |
| #define | GRAY "\033[38;5;240m" |
| #define | C_FIRE1 "\033[38;5;196m" |
| #define | C_FIRE2 "\033[38;5;202m" |
| #define | C_FIRE3 "\033[38;5;208m" |
| #define | C_FIRE4 "\033[38;5;214m" |
| #define | C_FIRE5 "\033[38;5;220m" |
| #define | C_BLOOD1 "\033[38;5;52m" |
| #define | C_BLOOD2 "\033[38;5;88m" |
| #define | C_BLOOD3 "\033[38;5;124m" |
| #define | C_BLOOD4 "\033[38;5;160m" |
| #define | C_BLOOD5 "\033[38;5;196m" |
| #define | BOX_TL "╭" |
| #define | BOX_TR "╮" |
| #define | BOX_BL "╰" |
| #define | BOX_BR "╯" |
| #define | BOX_H "─" |
| #define | BOX_V "│" |
| #define | CMD_BOX_HEIGHT 3 |
| #define | WAIFU_BOX_W 24 |
| #define | EXIT_BOX_H 3 |
| #define | MIN_WIDTH 80 |
| #define | MIN_HEIGHT 24 |
| #define | MAX_CMD_LEN 1024 |
| #define | MAX_LINES 1000 |
| #define | BUF_SIZE 4096 |
| #define | MINISHELL_PATH "./minishell" |
| #define | KEY_ESC 27 |
| #define | KEY_ENTER 10 |
| #define | KEY_BACKSPACE 127 |
| #define | KEY_CTRL_D 4 |
| #define | KEY_CTRL_C 3 |
| #define | KEY_UP 1001 |
| #define | KEY_DOWN 1002 |
| #define | KEY_LEFT 1003 |
| #define | KEY_RIGHT 1004 |
| #define | MOOD_HAPPY 0 |
| #define | MOOD_UPSET 1 |
| #define | MOOD_PROUD 2 |
Functions | |
| void | run_ui_mode (t_shell *shell) |
| Entry point for UI mode. More... | |
| void | init_term (t_ui *ui) |
| Prepare the terminal and UI state for the main event. More... | |
| void | cleanup_term (t_ui *ui) |
| Clean up the UI terminal state and free output memory. More... | |
| void | get_term_size (t_term *term) |
| Get the terinal dimensions via ioctl and store them. More... | |
| void | set_raw_mode (t_term *term) |
| Switch the terminal into non canonical and no echo mode. More... | |
| void | restore_term_mode (t_term *term) |
| Restore the terminal to the saved settings. More... | |
| void | print_goodbye (void) |
| Print the exit banner to STDOUT. More... | |
| void | setup_ui_signals (void) |
| Set up SIGWINCH and SIGINT handlers for the UI loop. More... | |
| void | out_add_line (t_out *out, const char *line) |
| Append a duplicate of a line to the output buffer. More... | |
| void | out_clear (t_out *out) |
| Free stored output lines and reset the scroll state. More... | |
| void | out_free (t_out *out) |
| Clear all output lines and free the lines pointer array. More... | |
| void | add_welcome_msg (t_ui *ui) |
| Fill the output buffer w/ an introductory welcome banner. More... | |
| void | update_waifu_mood (t_ui *ui, int mood) |
| Set the waifu mood. More... | |
| void | draw_waifu_box (t_ui *ui) |
| Draw the waifu panel in the right sidebar. More... | |
| void | print_at (int row, int col, const char *str) |
| Move the terminal cursor to [row, col] and write str. More... | |
| void | draw_hline (int width, const char *color) |
| Draw a horizontal line of dashes with optional color. More... | |
| char * | truncate_line (const char *line, int max_w) |
| Copy up to max_width visible characters into a static buffer. More... | |
| int | visual_strlen (const char *s) |
| Calculate the visual display width of a UTF-8 string in terminal cols. More... | |
| void | draw_box (t_box *b) |
| Draw a complete box. More... | |
| void | draw_box_title (t_box *b, const char *title) |
| Draw the top border of a box with title in the center. More... | |
| void | draw_box_sides (t_box *b) |
| Draw the left and right borders of a box. More... | |
| void | draw_box_bottom (t_box *b) |
| Draw the bottom border of a box. More... | |
| void | draw_ui (t_ui *ui) |
| Clear the screen and redraw the UI from scratch. More... | |
| void | draw_cmd_box (t_ui *ui) |
| Draw the command input box (top left of the UI) More... | |
| void | draw_exit_box (t_ui *ui) |
| Draw the exit code status box (right sidebare, below waifu) More... | |
| void | redraw_cmd_only (t_ui *ui) |
| Redraws only the command input line. More... | |
| void | draw_out_line (t_ui *ui, int y, int i, int w) |
| Draw one raw inside the output box (including the side borders) More... | |
| void | draw_out_box (t_ui *ui) |
| Draw the full output box with title and borders. More... | |
| void | redraw_output_only (t_ui *ui) |
| Redraw only the output box interior rows without borders nor title. More... | |
| 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... | |
| void | handle_key (t_shell *shell, int key) |
| Dispatch key code to the appropriate UI action. More... | |
| void | cmd_execute (t_shell *shell) |
| Execute the current command buffer & reset it. More... | |
| void | execute_minishell_cmd (t_shell *shell) |
| Fork a child to execute a minishell command & capture its output. More... | |
| void | read_output_from_fd (t_ui *ui, int fd) |
| Read all available bytes from fd and split into output lines. More... | |
| int | process_ui_input (char *input, t_shell *shell) |
| Full pipeline inside the UI. More... | |
| void | ft_msleep (int ms) |
| Sleep for approximately ms millisecondes using a little trick. More... | |
| void | draw_welcome (void) |
| Draw complete welcome animation sequence and clean up. More... | |
| void | draw_happy (int y, int x) |
| Draw happy Neko chan ASCII art. More... | |
| void | draw_upset (int y, int x) |
| Draw upset Neko chan ASCII art. More... | |
| void | draw_proud (int y, int x) |
| Draw proud Neko chan ASCII art. More... | |
| #define ESC_SEQ "\033[" |
Definition at line 28 of file minishell_ui.h.
| #define CLEAR_SCREEN "\033[2J\033[H" |
Definition at line 29 of file minishell_ui.h.
| #define CLEAR_LINE "\033[2K" |
Definition at line 30 of file minishell_ui.h.
| #define CURSOR_HIDE "\033[?25l" |
Definition at line 31 of file minishell_ui.h.
| #define CURSOR_SHOW "\033[?25h" |
Definition at line 32 of file minishell_ui.h.
| #define SAVE_CURSOR "\033[s" |
Definition at line 33 of file minishell_ui.h.
| #define RESTORE_CURSOR "\033[u" |
Definition at line 34 of file minishell_ui.h.
| #define RESET "\033[0m" |
Definition at line 37 of file minishell_ui.h.
| #define BOLD "\033[1m" |
Definition at line 38 of file minishell_ui.h.
| #define DIM "\033[2m" |
Definition at line 39 of file minishell_ui.h.
| #define CYAN "\033[38;5;51m" |
Definition at line 42 of file minishell_ui.h.
| #define PURPLE "\033[38;5;141m" |
Definition at line 43 of file minishell_ui.h.
| #define GREEN "\033[38;5;47m" |
Definition at line 44 of file minishell_ui.h.
| #define RED "\033[38;5;196m" |
Definition at line 45 of file minishell_ui.h.
| #define YELLOW "\033[38;5;226m" |
Definition at line 46 of file minishell_ui.h.
| #define WHITE "\033[38;5;231m" |
Definition at line 47 of file minishell_ui.h.
| #define GRAY "\033[38;5;240m" |
Definition at line 48 of file minishell_ui.h.
| #define C_FIRE1 "\033[38;5;196m" |
Definition at line 51 of file minishell_ui.h.
| #define C_FIRE2 "\033[38;5;202m" |
Definition at line 52 of file minishell_ui.h.
| #define C_FIRE3 "\033[38;5;208m" |
Definition at line 53 of file minishell_ui.h.
| #define C_FIRE4 "\033[38;5;214m" |
Definition at line 54 of file minishell_ui.h.
| #define C_FIRE5 "\033[38;5;220m" |
Definition at line 55 of file minishell_ui.h.
| #define C_BLOOD1 "\033[38;5;52m" |
Definition at line 58 of file minishell_ui.h.
| #define C_BLOOD2 "\033[38;5;88m" |
Definition at line 59 of file minishell_ui.h.
| #define C_BLOOD3 "\033[38;5;124m" |
Definition at line 60 of file minishell_ui.h.
| #define C_BLOOD4 "\033[38;5;160m" |
Definition at line 61 of file minishell_ui.h.
| #define C_BLOOD5 "\033[38;5;196m" |
Definition at line 62 of file minishell_ui.h.
| #define BOX_TL "╭" |
Definition at line 68 of file minishell_ui.h.
| #define BOX_TR "╮" |
Definition at line 69 of file minishell_ui.h.
| #define BOX_BL "╰" |
Definition at line 70 of file minishell_ui.h.
| #define BOX_BR "╯" |
Definition at line 71 of file minishell_ui.h.
| #define BOX_H "─" |
Definition at line 72 of file minishell_ui.h.
| #define BOX_V "│" |
Definition at line 73 of file minishell_ui.h.
| #define CMD_BOX_HEIGHT 3 |
Definition at line 79 of file minishell_ui.h.
| #define WAIFU_BOX_W 24 |
Definition at line 80 of file minishell_ui.h.
| #define EXIT_BOX_H 3 |
Definition at line 81 of file minishell_ui.h.
| #define MIN_WIDTH 80 |
Definition at line 82 of file minishell_ui.h.
| #define MIN_HEIGHT 24 |
Definition at line 83 of file minishell_ui.h.
| #define MAX_CMD_LEN 1024 |
Definition at line 84 of file minishell_ui.h.
| #define MAX_LINES 1000 |
Definition at line 85 of file minishell_ui.h.
| #define BUF_SIZE 4096 |
Definition at line 86 of file minishell_ui.h.
| #define MINISHELL_PATH "./minishell" |
Definition at line 89 of file minishell_ui.h.
| #define KEY_ESC 27 |
Definition at line 92 of file minishell_ui.h.
| #define KEY_ENTER 10 |
Definition at line 93 of file minishell_ui.h.
| #define KEY_BACKSPACE 127 |
Definition at line 94 of file minishell_ui.h.
| #define KEY_CTRL_D 4 |
Definition at line 95 of file minishell_ui.h.
| #define KEY_CTRL_C 3 |
Definition at line 96 of file minishell_ui.h.
| #define KEY_UP 1001 |
Definition at line 97 of file minishell_ui.h.
| #define KEY_DOWN 1002 |
Definition at line 98 of file minishell_ui.h.
| #define KEY_LEFT 1003 |
Definition at line 99 of file minishell_ui.h.
| #define KEY_RIGHT 1004 |
Definition at line 100 of file minishell_ui.h.
| #define MOOD_HAPPY 0 |
Definition at line 103 of file minishell_ui.h.
| #define MOOD_UPSET 1 |
Definition at line 104 of file minishell_ui.h.
| #define MOOD_PROUD 2 |
Definition at line 105 of file minishell_ui.h.
| void run_ui_mode | ( | t_shell * | shell | ) |
Entry point for UI mode.
Return silently if shell is NULL, not a tty or terminal is too small
| shell | Shell state |
Definition at line 91 of file ui_main.c.
References cleanup_term(), init_ui(), MIN_HEIGHT, MIN_WIDTH, print_goodbye(), t_shell::ui, ui_loop(), and t_shell::ui_mode.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| void init_term | ( | t_ui * | ui | ) |
Prepare the terminal and UI state for the main event.
| ui |
Definition at line 51 of file terminal_init.c.
References CLEAR_SCREEN, CURSOR_HIDE, get_term_size(), init_ui_state(), set_raw_mode(), and t_ui::term.
Referenced by init_ui().
Here is the call graph for this function:
Here is the caller graph for this function:| void cleanup_term | ( | t_ui * | ui | ) |
Clean up the UI terminal state and free output memory.
| ui |
Definition at line 68 of file terminal_init.c.
References CLEAR_SCREEN, CURSOR_SHOW, t_ui::out, out_free(), restore_term_mode(), and t_ui::term.
Referenced by run_ui_mode().
Here is the call graph for this function:
Here is the caller graph for this function:| void get_term_size | ( | t_term * | term | ) |
Get the terinal dimensions via ioctl and store them.
Fallback is 80x24 (default) in case ioctl fails
| term | Terminal state to fill with width and height |
Definition at line 22 of file terminal.c.
References t_term::height, and t_term::width.
Referenced by check_resize(), and init_term().
Here is the caller graph for this function:| void set_raw_mode | ( | t_term * | term | ) |
Switch the terminal into non canonical and no echo mode.
| term | Terminal state (original is saved before modification) |
Definition at line 46 of file terminal.c.
References t_term::orig.
Referenced by init_term().
Here is the caller graph for this function:| void restore_term_mode | ( | t_term * | term | ) |
Restore the terminal to the saved settings.
| term | Terminal state (holds the saved orig termios) |
Definition at line 63 of file terminal.c.
References t_term::orig.
Referenced by cleanup_term().
Here is the caller graph for this function:| void print_goodbye | ( | void | ) |
Print the exit banner to STDOUT.
Definition at line 71 of file terminal.c.
References BOLD, PURPLE, and RESET.
Referenced by run_ui_mode().
Here is the caller graph for this function:| void setup_ui_signals | ( | void | ) |
Set up SIGWINCH and SIGINT handlers for the UI loop.
Definition at line 31 of file ui_signals.c.
References handle_ui_sigwinch().
Referenced by init_ui().
Here is the call graph for this function:
Here is the caller graph for this function:| void out_add_line | ( | t_out * | out, |
| const char * | line | ||
| ) |
Append a duplicate of a line to the output buffer.
Do nothing if the buffers already reached MAX_LINES
| out | Output to append to |
| line | String to store |
Definition at line 23 of file output.c.
References t_out::count, t_out::lines, and MAX_LINES.
Referenced by add_welcome_msg(), handle_fork_error(), init_pipe_and_fds(), process_output_char(), and read_output_from_fd().
Here is the caller graph for this function:| void out_clear | ( | t_out * | out | ) |
Free stored output lines and reset the scroll state.
| out | Output state to clear |
Definition at line 37 of file output.c.
References t_out::count, t_out::lines, and t_out::scroll.
Referenced by cmd_execute(), exec_ui_builtin(), and out_free().
Here is the caller graph for this function:| void out_free | ( | t_out * | out | ) |
Clear all output lines and free the lines pointer array.
| out | Output to release |
Definition at line 57 of file output.c.
References t_out::lines, and out_clear().
Referenced by cleanup_term(), and exec_child().
Here is the call graph for this function:
Here is the caller graph for this function:| void add_welcome_msg | ( | t_ui * | ui | ) |
Fill the output buffer w/ an introductory welcome banner.
| ui | UI state for which output buffer receives the banner |
Definition at line 68 of file output.c.
References t_ui::out, and out_add_line().
Referenced by ui_loop().
Here is the call graph for this function:
Here is the caller graph for this function:| void update_waifu_mood | ( | t_ui * | ui, |
| int | mood | ||
| ) |
Set the waifu mood.
| ui | UI state |
| mood | New mood value |
Definition at line 21 of file waifu.c.
References t_waifu::mood, and t_ui::waifu.
Referenced by cmd_execute(), exec_parent(), execute_minishell_cmd(), handle_fork_error(), and init_pipe_and_fds().
Here is the caller graph for this function:| void draw_waifu_box | ( | t_ui * | ui | ) |
Draw the waifu panel in the right sidebar.
| ui | UI state |
Definition at line 48 of file waifu.c.
References C_FIRE4, t_box::color, draw_box_bottom(), draw_box_sides(), draw_box_title(), t_box::h, render_waifu_mood(), t_ui::term, t_box::w, WAIFU_BOX_W, t_term::width, t_box::x, and t_box::y.
Referenced by draw_ui().
Here is the call graph for this function:
Here is the caller graph for this function:| void print_at | ( | int | row, |
| int | col, | ||
| const char * | str | ||
| ) |
Move the terminal cursor to [row, col] and write str.
| row | Target row (starting at 1) |
| col | Target colum (starting at 1) |
| str | String to print |
Definition at line 22 of file drawing_utils.c.
Referenced by draw_box_bottom(), draw_box_sides(), draw_box_title(), draw_box_top(), draw_cmd_box(), draw_exit_box(), draw_happy(), draw_out_line(), draw_proud(), draw_upset(), and redraw_cmd_only().
Here is the caller graph for this function:| void draw_hline | ( | int | width, |
| const char * | color | ||
| ) |
Draw a horizontal line of dashes with optional color.
| width | Number of dash characters to write |
| color | ANSI color escape string to apply |
Definition at line 33 of file drawing_utils.c.
References RESET.
Referenced by draw_box_bottom(), draw_box_title(), and draw_box_top().
Here is the caller graph for this function:| char* truncate_line | ( | const char * | line, |
| int | max_width | ||
| ) |
Copy up to max_width visible characters into a static buffer.
Handles UTF-8 sequences
| line | Source string to truncate (could be NULL) |
| max_width | Maximum number to include |
Definition at line 42 of file drawing_text.c.
References BUF_SIZE, and utf8_byte_len().
Referenced by draw_line_content().
Here is the call graph for this function:
Here is the caller graph for this function:| int visual_strlen | ( | const char * | s | ) |
Calculate the visual display width of a UTF-8 string in terminal cols.
4 byte (emoji range) are counted as 2 columns, the others as 1
| s | UTF-8 string (NULL terminated) |
Definition at line 75 of file drawing_text.c.
References utf8_byte_len().
Referenced by draw_box_title().
Here is the call graph for this function:
Here is the caller graph for this function:| void draw_box | ( | t_box * | b | ) |
Draw a complete box.
| b | Box descriptor (with position, width and colors) |
Definition at line 70 of file drawing_box.c.
References draw_box_bottom(), draw_box_sides(), and draw_box_top().
Referenced by draw_exit_box().
Here is the call graph for this function:
Here is the caller graph for this function:| void draw_box_title | ( | t_box * | b, |
| const char * | title | ||
| ) |
Draw the top border of a box with title in the center.
| b | Box descriptor (with position, width and colors) |
| title | Label string to embed in the border |
Definition at line 83 of file drawing_box.c.
References BOLD, BOX_TL, BOX_TR, t_box::color, draw_hline(), print_at(), RESET, visual_strlen(), t_box::w, t_box::x, and t_box::y.
Referenced by draw_cmd_box(), draw_out_box(), and draw_waifu_box().
Here is the call graph for this function:
Here is the caller graph for this function:| void draw_box_sides | ( | t_box * | b | ) |
Draw the left and right borders of a box.
| b | Box descriptor (with position, width and colors) |
Definition at line 48 of file drawing_box.c.
References BOX_V, t_box::color, print_at(), RESET, t_box::w, t_box::x, and t_box::y.
Referenced by draw_box(), draw_cmd_box(), and draw_waifu_box().
Here is the call graph for this function:
Here is the caller graph for this function:| void draw_box_bottom | ( | t_box * | b | ) |
Draw the bottom border of a box.
| b | Box descriptor (with position, width and colors) |
Definition at line 34 of file drawing_box.c.
References BOX_BL, BOX_BR, t_box::color, draw_hline(), t_box::h, print_at(), RESET, t_box::w, t_box::x, and t_box::y.
Referenced by draw_box(), draw_cmd_box(), draw_out_box(), and draw_waifu_box().
Here is the call graph for this function:
Here is the caller graph for this function:| void draw_ui | ( | t_ui * | ui | ) |
Clear the screen and redraw the UI from scratch.
Draw all 4 panels: command box, waifu, exit box and output box
| ui | UI state |
Definition at line 76 of file drawing.c.
References CLEAR_SCREEN, draw_cmd_box(), draw_exit_box(), draw_out_box(), and draw_waifu_box().
Referenced by check_resize(), and ui_loop().
Here is the call graph for this function:
Here is the caller graph for this function:| void draw_cmd_box | ( | t_ui * | ui | ) |
Draw the command input box (top left of the UI)
Render a titled box with a block cursor
| ui | UI state |
Definition at line 22 of file drawing.c.
References BOLD, t_cmd::buf, C_FIRE3, C_FIRE4, t_ui::cmd, t_box::color, draw_box_bottom(), draw_box_sides(), draw_box_title(), t_box::h, t_cmd::len, print_at(), RESET, t_ui::term, t_box::w, WAIFU_BOX_W, t_term::width, t_box::x, and t_box::y.
Referenced by draw_ui().
Here is the call graph for this function:
Here is the caller graph for this function:| void draw_exit_box | ( | t_ui * | ui | ) |
Draw the exit code status box (right sidebare, below waifu)
Colours the exit code green on success and red on failure
| ui | UI state |
Definition at line 50 of file drawing.c.
References BOLD, C_FIRE1, C_FIRE2, C_FIRE5, t_box::color, draw_box(), EXIT_BOX_H, t_out::exit_code, t_box::h, t_ui::out, print_at(), RESET, t_ui::term, t_box::w, WAIFU_BOX_W, t_term::width, t_box::x, and t_box::y.
Referenced by draw_ui().
Here is the call graph for this function:
Here is the caller graph for this function:| void redraw_cmd_only | ( | t_ui * | ui | ) |
Redraws only the command input line.
| ui | UI state |
Definition at line 90 of file drawing.c.
References BOLD, t_cmd::buf, C_FIRE4, t_ui::cmd, t_cmd::len, print_at(), RESET, t_ui::term, WAIFU_BOX_W, and t_term::width.
Referenced by ui_loop().
Here is the call graph for this function:
Here is the caller graph for this function:| void draw_out_line | ( | t_ui * | ui, |
| int | y, | ||
| int | i, | ||
| int | w | ||
| ) |
Draw one raw inside the output box (including the side borders)
| ui | UI state |
| y | Top row of the output box |
| i | Row index within the box (0 based) |
| w | Width of the output box |
Definition at line 57 of file drawing_output.c.
References BOX_V, C_FIRE2, draw_line_content(), t_ui::out, print_at(), RESET, and t_out::scroll.
Referenced by draw_out_box(), and redraw_output_only().
Here is the call graph for this function:
Here is the caller graph for this function:| void draw_out_box | ( | t_ui * | ui | ) |
Draw the full output box with title and borders.
THe box grows to fill the terminal from row 5 to the last 2 rows
| ui | UI state |
Definition at line 79 of file drawing_output.c.
References C_FIRE2, t_box::color, draw_box_bottom(), draw_box_title(), draw_out_line(), t_box::h, t_term::height, t_ui::term, t_box::w, WAIFU_BOX_W, t_term::width, t_box::x, and t_box::y.
Referenced by draw_ui().
Here is the call graph for this function:
Here is the caller graph for this function:| void redraw_output_only | ( | t_ui * | ui | ) |
Redraw only the output box interior rows without borders nor title.
Used after scroll events in order to refresh content without full redraw
| ui | UI state |
Definition at line 106 of file drawing_output.c.
References draw_out_line(), t_term::height, t_ui::term, WAIFU_BOX_W, and t_term::width.
Referenced by handle_scroll().
Here is the call graph for this function:
Here is the caller graph for this function:| 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:| 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:| void cmd_execute | ( | t_shell * | shell | ) |
Execute the current command buffer & reset it.
| shell | Shell state |
Definition at line 52 of file command.c.
References t_cmd::buf, t_ui::cmd, exec_ui_builtin(), execute_minishell_cmd(), t_cmd::len, MAX_CMD_LEN, MOOD_HAPPY, t_ui::out, out_clear(), t_shell::ui, and update_waifu_mood().
Referenced by handle_key().
Here is the call graph for this function:
Here is the caller graph for this function:| void execute_minishell_cmd | ( | t_shell * | shell | ) |
Fork a child to execute a minishell command & capture its output.
Creates a pipe, forks, runs exec_child() in the child and exec_parent() in the parent
| shell | Shell state (contains command buffer and UI output) |
Definition at line 137 of file execute.c.
References exec_child(), exec_parent(), handle_fork_error(), init_pipe_and_fds(), MOOD_HAPPY, t_shell::ui, and update_waifu_mood().
Referenced by cmd_execute().
Here is the call graph for this function:
Here is the caller graph for this function:| void read_output_from_fd | ( | t_ui * | ui, |
| int | fd | ||
| ) |
Read all available bytes from fd and split into output lines.
Reads in chunks of BUF_SIZE and any unterminated line is flushed after EOF
| ui | UI states |
| fd | File descriptor to read from (pipe read end) |
Definition at line 53 of file execute_utils.c.
References BUF_SIZE, t_ui::out, out_add_line(), and process_output_char().
Referenced by exec_parent().
Here is the call graph for this function:
Here is the caller graph for this function:| int process_ui_input | ( | char * | input, |
| t_shell * | shell | ||
| ) |
Full pipeline inside the UI.
tokenize -> expand_all_tokens -> parse -> collect_heredocs -> executor
| input | Command string to execute |
| shell | Shell state (provides environment and execution context) |
Definition at line 88 of file execute_utils.c.
References collect_heredocs(), executor(), expand_all_tokens(), free_ast(), free_token_list(), parse(), and tokenize().
Referenced by exec_child().
Here is the call graph for this function:
Here is the caller graph for this function:| void ft_msleep | ( | int | ms | ) |
Sleep for approximately ms millisecondes using a little trick.
| ms | Milliseconds to sleep |
Definition at line 28 of file welcome_utils.c.
Referenced by animate_demon(), animate_loading(), animate_quote(), animate_title(), cleanup_screen(), draw_border_effect(), draw_welcome(), flash_demon_eyes(), print_quote_lines(), and ui_loop().
Here is the caller graph for this function:| void draw_welcome | ( | void | ) |
| void draw_happy | ( | int | y, |
| int | x | ||
| ) |
Draw happy Neko chan ASCII art.
| y | Top row of the first line |
| x | Left col of the first art line |
Definition at line 21 of file waifu_art.c.
References print_at().
Referenced by render_waifu_mood().
Here is the call graph for this function:
Here is the caller graph for this function:| void draw_upset | ( | int | y, |
| int | x | ||
| ) |
Draw upset Neko chan ASCII art.
| y | Top row of the first line |
| x | Left col of the first art line |
Definition at line 38 of file waifu_art.c.
References print_at().
Referenced by render_waifu_mood().
Here is the call graph for this function:
Here is the caller graph for this function:| void draw_proud | ( | int | y, |
| int | x | ||
| ) |
Draw proud Neko chan ASCII art.
| y | Top row of the first line |
| x | Left col of the first art line |
Definition at line 55 of file waifu_art.c.
References print_at().
Referenced by render_waifu_mood().
Here is the call graph for this function:
Here is the caller graph for this function: