int init_shell(void) { char *name; struct termios term; t_term *t; t = ft_get_term(); if ((name = getenv("TERM")) == NULL) name = ft_strdup("xterm-256color"); if (tgetent(NULL, name) == ERR) { ft_putendl_fd("jush: tcgetent failed", 2); exit(-1); } if (tcgetattr(0, &term) == -1) return (-1); t->cpy_term = term; term.c_lflag = term.c_lflag & (~ICANON & ~ECHO); term.c_cc[VMIN] = 1; term.c_cc[VTIME] = 0; if (tcsetattr(0, 0, &term)) { ft_putendl_fd("jush: tcsetattr failed", 2); exit(-1); } return (1); }
int reset_shell(void) { t_term *t; t = ft_get_term(); if (tcsetattr(0, 0, &(t->cpy_term)) == -1) return (-1); return (0); }
void ft_sig_stop(void) { tputs(tgetstr("ve", NULL), 1, tty_putchar); tputs(tgetstr("te", NULL), 1, tty_putchar); tcsetattr(0, 1, ft_get_term()); }