MiniDevil As beautiful as a shell
terminal.c File Reference

Terminal control: dimensions, raw mode, cursor management. More...

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

Detailed Description

Terminal control: dimensions, raw mode, cursor management.

Definition in file terminal.c.

Functions

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...
 

Function Documentation

◆ get_term_size()

void get_term_size ( t_term term)

Get the terinal dimensions via ioctl and store them.

Fallback is 80x24 (default) in case ioctl fails

Parameters
termTerminal 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:

◆ set_raw_mode()

void set_raw_mode ( t_term term)

Switch the terminal into non canonical and no echo mode.

  • Save original termios settings in term->orig for later
  • Disable ECHO and ICANON & set VMIN = 1 and VTIME = 0
Parameters
termTerminal 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:

◆ restore_term_mode()

void restore_term_mode ( t_term term)

Restore the terminal to the saved settings.

Parameters
termTerminal 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:

◆ print_goodbye()

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:

Go to the source code of this file.