27 ui = ft_calloc(1,
sizeof(
t_ui));
30 ft_putendl_fd(
"Error: UI allocation failed", STDERR_FILENO);
72 while (shell->
ui->running)
97 if (!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO))
99 if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == -1)
101 ft_putstr_fd(
"Error: failed to get terminal size\n", STDERR_FILENO);
106 ft_putstr_fd(
"Error: terminal too small for UI mode\n", STDERR_FILENO);
void redraw_cmd_only(t_ui *ui)
Redraws only the command input line.
void draw_ui(t_ui *ui)
Clear the screen and redraw the UI from scratch.
UI mode structures, macros & function prototypes.
void add_welcome_msg(t_ui *ui)
Fill the output buffer w/ an introductory welcome banner.
volatile sig_atomic_t g_signal
The single global variable.
struct s_ui * ui
UI state (NULL if off)
int ui_mode
1 if UI mode (–ui)
int running
Event loop flag.
void print_goodbye(void)
Print the exit banner to STDOUT.
void get_term_size(t_term *term)
Get the terinal dimensions via ioctl and store them.
void init_term(t_ui *ui)
Prepare the terminal and UI state for the main event.
void cleanup_term(t_ui *ui)
Clean up the UI terminal state and free output memory.
static void check_resize(t_shell *shell)
Handle a SIGWINCH signal (get new terminal dimensions and redraw)
static void ui_loop(t_shell *shell)
Run the main loop.
static void init_ui(t_shell *shell)
Allocate and initialize the t_ui struct and attach it to shell.
void run_ui_mode(t_shell *shell)
Entry point for UI mode.
void setup_ui_signals(void)
Set up SIGWINCH and SIGINT handlers for the UI loop.
void draw_welcome(void)
Draw complete welcome animation sequence and clean up.
void ft_msleep(int ms)
Sleep for approximately ms millisecondes using a little trick.