C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
Screen IO Support

Provides Terminal Settings for C-MENU Applications and Restores Terminal State on Exit. More...

Functions

bool capture_shell_tioctl ()
 capture_shell_tioctl() - capture shell terminal settings
bool restore_shell_tioctl ()
 restore_shell_tioctl() - restore shell terminal settings
bool capture_curses_tioctl ()
 capture_curses_tioctl() - capture curses terminal settings
bool restore_curses_tioctl ()
 restore_curses_tioctl() - restore curses terminal settings
bool set_sane_tioctl (struct termios *t_p)
 set_sane_tioctl() - set terminal to sane settings for C-MENU
bool mk_raw_tioctl (struct termios *t_p)
 mk_raw_tioctl() - set terminal to raw mode
char di_getch ()
 sget single character from terminal in raw mode

Detailed Description

Provides Terminal Settings for C-MENU Applications and Restores Terminal State on Exit.

Terminal Handling

Function Documentation

◆ capture_curses_tioctl()

bool capture_curses_tioctl ( )

capture_curses_tioctl() - capture curses terminal settings

Returns
- true on success
Note
- captures terminal settings for stdin, stdout, and stderr

Definition at line 68 of file scriou.c.

68 {
70 return true;
71 tcgetattr(0, &curses_in_tioctl);
72 tcgetattr(1, &curses_out_tioctl);
73 tcgetattr(2, &curses_err_tioctl);
75 return true;
76}
bool f_have_curses_tioctl
Definition scriou.c:25
struct termios shell_out_tioctl curses_out_tioctl
Definition scriou.c:36
struct termios shell_in_tioctl curses_in_tioctl
Definition scriou.c:35
struct termios shell_err_tioctl curses_err_tioctl
Definition scriou.c:37

References curses_err_tioctl, curses_in_tioctl, curses_out_tioctl, and f_have_curses_tioctl.

Referenced by fork_exec(), and main().

Here is the caller graph for this function:

◆ capture_shell_tioctl()

bool capture_shell_tioctl ( )

capture_shell_tioctl() - capture shell terminal settings

Returns
- true on success
Note
- captures terminal settings for stdin, stdout, and stderr

Definition at line 43 of file scriou.c.

43 {
45 return true;
46 tcgetattr(0, &shell_in_tioctl);
47 tcgetattr(1, &shell_out_tioctl);
48 tcgetattr(2, &shell_err_tioctl);
50 return true;
51}
bool f_have_shell_tioctl
Definition scriou.c:24

References f_have_shell_tioctl.

Referenced by main().

Here is the caller graph for this function:

◆ di_getch()

char di_getch ( )

sget single character from terminal in raw mode

Returns
- the character read from terminal
Note
restores terminal settings

Definition at line 139 of file scriou.c.

139 {
140 struct termios org_tioctl, new_tioctl;
141 char buf;
142
143 if (tcgetattr(2, &org_tioctl) == -1) {
144 fprintf(stderr, "\ndi_getch: tcgetattr failed\n");
145 return (0);
146 }
147 new_tioctl = org_tioctl;
148 new_tioctl.c_lflag &= ~(ECHO | ICANON);
149 new_tioctl.c_cc[VMIN] = 1;
150 new_tioctl.c_cc[VTIME] = 0;
151 tcsetattr(2, TCSAFLUSH, &new_tioctl);
152 read(2, &buf, 1);
153 tcsetattr(2, TCSAFLUSH, &org_tioctl);
154 return (buf);
155}

Referenced by nf_error().

Here is the caller graph for this function:

◆ mk_raw_tioctl()

bool mk_raw_tioctl ( struct termios * t_p)

mk_raw_tioctl() - set terminal to raw mode

Parameters
t_p- pointer to termios structure to modify
Returns
- true on success
Note
- unlike cfmakeraw(), this leaves ISIG enabled.
- cfmakeraw() disables ISIG, which prevents C-MENU from handling signals like Ctrl-C. Instead of using cfmakeraw(), we manually set the terminal to raw mode while leaving ISIG enabled.
- the following code is equivalent to cfmakeraw() but with ISIG left enabled:
t_p->c_iflag &= ~(IGNBRK | BRKINT | PARMRK | INPCK | ISTRIP | INLCR |
IGNCR | ICRNL | IXON | IXOFF);
t_p->c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN);
t_p->c_cflag &= ~(CSIZE | PARENB);
t_p->c_cflag |= CS8 | CLOCAL;

Definition at line 126 of file scriou.c.

126 {
127 tcgetattr(0, t_p);
128 t_p->c_lflag |= ISIG;
129 t_p->c_lflag &= ~(ECHO | ICANON);
130 t_p->c_cc[VMIN] = 1;
131 t_p->c_cc[VTIME] = 0;
132 tcsetattr(0, TCSAFLUSH, t_p);
133 return true;
134}

Referenced by main(), and xwgetch().

Here is the caller graph for this function:

◆ restore_curses_tioctl()

bool restore_curses_tioctl ( )

restore_curses_tioctl() - restore curses terminal settings

Returns
- true on success
Note
- restores terminal settings for stdin, stdout, and stderr

Definition at line 81 of file scriou.c.

81 {
83 return false;
84 tcsetattr(0, TCSANOW, &curses_in_tioctl);
85 tcsetattr(1, TCSANOW, &curses_out_tioctl);
86 tcsetattr(2, TCSANOW, &curses_err_tioctl);
87
88 return true;
89}

References curses_err_tioctl, curses_in_tioctl, curses_out_tioctl, and f_have_curses_tioctl.

Referenced by exec_objects(), fork_exec(), init_pick(), and xwgetch().

Here is the caller graph for this function:

◆ restore_shell_tioctl()

bool restore_shell_tioctl ( )

restore_shell_tioctl() - restore shell terminal settings

Returns
- true on success
Note
- restores terminal settings for stdin, stdout, and stderr

Definition at line 56 of file scriou.c.

56 {
58 return false;
59 tcsetattr(0, TCSANOW, &shell_in_tioctl);
60 tcsetattr(1, TCSANOW, &shell_out_tioctl);
61 tcsetattr(2, TCSANOW, &shell_err_tioctl);
62 return true;
63}

References f_have_shell_tioctl.

Referenced by abend(), destroy_curses(), fork_exec(), handle_signal(), and main().

Here is the caller graph for this function:

◆ set_sane_tioctl()

bool set_sane_tioctl ( struct termios * t_p)

set_sane_tioctl() - set terminal to sane settings for C-MENU

Parameters
t_p- pointer to termios structure to modify
Returns
- true on success
Note
- sets terminal to sane settings for C-MENU applications

Definition at line 95 of file scriou.c.

95 {
96 tcgetattr(0, t_p);
97 t_p->c_iflag &= ~(IGNBRK | BRKINT | PARMRK | INPCK | ISTRIP | INLCR |
98 IGNCR | ICRNL | IXON | IXOFF);
99 t_p->c_iflag |= IUTF8;
100 t_p->c_oflag |= OPOST | ONLCR;
101 t_p->c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN);
102 t_p->c_lflag |= (ISIG | ICANON | IEXTEN | ECHO | ECHOE | ECHOK);
103 t_p->c_cflag &= ~(CSIZE | PARENB);
104 t_p->c_cflag |= CS8 | CLOCAL | CREAD;
105 tcsetattr(0, TCSANOW, t_p);
106 return true;
107}

Referenced by signal_handler().

Here is the caller graph for this function: