MiniDevil As beautiful as a shell
terminal_init.c File Reference

Terminal initialization: sets up UI state and terminal mode. More...

#include "minishell_ui.h"
+ Include dependency graph for terminal_init.c:

Detailed Description

Terminal initialization: sets up UI state and terminal mode.

Definition in file terminal_init.c.

Functions

static void init_ui_state (t_ui *ui)
 Intializes the command buffer, output state and waifu mood. 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...
 

Function Documentation

◆ init_ui_state()

static void init_ui_state ( t_ui ui)
static

Intializes the command buffer, output state and waifu mood.

  • Allocate the lines pointer array (MAX_LINES)
  • Sets running to 0 and prints to STDERR on allocation failure
  • Default waifu mood is MOOD_PROUD
Parameters
uiUI state

Definition at line 24 of file terminal_init.c.

References t_cmd::buf, t_ui::cmd, t_out::count, t_cmd::cursor, t_out::exit_code, t_cmd::len, t_out::lines, MAX_CMD_LEN, MAX_LINES, t_waifu::mood, MOOD_PROUD, t_ui::out, t_ui::running, t_out::scroll, and t_ui::waifu.

Referenced by init_term().

+ Here is the caller graph for this function:

◆ init_term()

void init_term ( t_ui ui)

Prepare the terminal and UI state for the main event.

  • Get terminal size, enable raw mode, hide cursor and clean screen
  • Call init_ui_state() to inialize the rest of the UI struct to 0
Parameters
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:

◆ cleanup_term()

void cleanup_term ( t_ui ui)

Clean up the UI terminal state and free output memory.

  • Clear the screen, restore cursor and restore original terminal mode
  • Free output lines array via out_free
Parameters
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:

Go to the source code of this file.