/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* terminal.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/10/27 00:10:04 by lperrey #+# #+# */ /* Updated: 2021/10/30 14:17:16 by lperrey ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" #define CTRL_C 03 #define CTRL_D 04 #define CTRL_BACKSLASH 034 int set_terminal_attributes(struct termios *ori_termios, struct termios *interactive_termios, int *termios_changed) { tcgetattr(STDIN_FILENO, ori_termios); *interactive_termios = *ori_termios; interactive_termios->c_cc[VINTR] = CTRL_D; interactive_termios->c_cc[VEOF] = CTRL_C; //interactive_termios->c_cc[VQUIT] = CTRL_C; //interactive_termios->c_cc[VEOF] = CTRL_BACKSLASH; //interactive_termios->c_cc[VEOL] = CTRL_C; *termios_changed = 1; tcsetattr(STDIN_FILENO, TCSANOW, interactive_termios); return (1); } //printf("STDIN_FILENO = %s\n ", ttyname(STDIN_FILENO)); //printf("STDOUT_FILENO = %s\n ", ttyname(STDOUT_FILENO)); //printf("STDERR_FILENO = %s\n ", ttyname(STDERR_FILENO)); //ft_putendl_fd(ttyname(STDIN_FILENO), 1); //ft_putendl_fd(ttyname(STDOUT_FILENO), 1); //ft_putendl_fd(ttyname(STDERR_FILENO), 1); // ft_printf("BEFORE\n"); // ft_printf("i_io.c_cc[VEOF] = %i\ni_termios.c_cc[VINTR] = %i\n", (*interactive_termios)->c_cc[VEOF], (*interactive_termios)->c_cc[VINTR]); // ft_printf("o_io.c_cc[VEOF] = %i\no_termios.c_cc[VINTR] = %i\n", (*ori_termios)->c_cc[VEOF], (*ori_termios)->c_cc[VINTR]); // ft_printf("AFTER\n"); // ft_printf("i_io.c_cc[VEOF] = %i\ni_termios.c_cc[VINTR] = %i\n", (*interactive_termios)->c_cc[VEOF], (*interactive_termios)->c_cc[VINTR]); // ft_printf("o_io.c_cc[VEOF] = %i\no_termios.c_cc[VINTR] = %i\n", (*ori_termios)->c_cc[VEOF], (*ori_termios)->c_cc[VINTR]); void wip_test() { char term_desc[2048]; char *term_type; int term_width; int term_height; int ret; term_type = getenv("TERM"); if (term_type == 0) ft_putstr_fd("Specify a terminal type with `setenv TERM '.\n", 2); ret = tgetent(term_desc, term_type); if (ret < 0) ft_putstr_fd("Could not access the termcap data base.\n", 2); if (ret == 0) ft_putstr_fd("Terminal type `%s' is not defined.\n", 2); term_height = tgetnum ("li"); term_width = tgetnum ("co"); /* Extract information that termcap functions use. */ /* temp = tgetstr ("pc", BUFFADDR); PC = temp ? *temp : 0; BC = tgetstr ("le", BUFFADDR); UP = tgetstr ("up", BUFFADDR); */ }