diff options
author | salad <fmoenne-@student.le-101.fr> | 2020-08-27 23:29:07 +0200 |
---|---|---|
committer | salad <fmoenne-@student.le-101.fr> | 2020-08-27 23:29:07 +0200 |
commit | 9ca75e7eb366800b3c602fb948167bcb185bed37 (patch) | |
tree | ee3af6a1489226a8bdc6c741ad0fcb7a105d6e64 /src/c_init.c | |
parent | s**** f***** (diff) | |
download | 42-minishell-9ca75e7eb366800b3c602fb948167bcb185bed37.tar.gz 42-minishell-9ca75e7eb366800b3c602fb948167bcb185bed37.tar.bz2 42-minishell-9ca75e7eb366800b3c602fb948167bcb185bed37.tar.xz 42-minishell-9ca75e7eb366800b3c602fb948167bcb185bed37.tar.zst 42-minishell-9ca75e7eb366800b3c602fb948167bcb185bed37.zip |
added init, samarche pas, peutetre go GNL
Diffstat (limited to 'src/c_init.c')
-rw-r--r-- | src/c_init.c | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/src/c_init.c b/src/c_init.c index 5cf46f3..bbf8f22 100644 --- a/src/c_init.c +++ b/src/c_init.c @@ -10,23 +10,51 @@ /* */ /* ************************************************************************** */ +#include <unistd.h> +#include <stdio.h> +#include <termios.h> +#include <stdlib.h> +#include <string.h> #include <term.h> #include <curses.h> -void u_handle_sigwinch(int dummy_signal) +#include "c_init.h" + +t_caps + *c_get_struct(int mode, t_caps *src) { - (void)dummy_signal; - tputs(LC, 1, ft_putchar); - fflush(stdout); + static t_caps *caps; + + if (mode == 1) + { + caps = src; + } + return (caps); } int16_t c_init_tcaps(void) { + t_caps tcaps; char *bp; char *term; - char *LC; + bp = NULL; term = getenv("TERM"); - tgetent(bp, term); - LC = tgetstr("lc", &term); + if (!tgetent(bp, term)) + return (-1); + tcaps.lc = tgetstr("lc", &term); + tcaps.kl = tgetstr("kl", &term); + tcaps.kr = tgetstr("kr", &term); + tcaps.pc = tgetstr("pc", &term); + tcaps.bc = tgetstr("bc", &term); + tcaps.up = tgetstr("up", &term); + tcaps.nd = tgetstr("nd", &term); + tcgetattr(STDIN_FILENO, &tcaps.tios); + + tcaps.tios.c_lflag &= ~(ECHO | ICANON); + tcaps.tios.c_cc[VMIN] = 0; + tcaps.tios.c_cc[VTIME] = 1; + tcsetattr(STDIN_FILENO, TCSAFLUSH, &tcaps.tios); + c_get_struct(1, &tcaps); + return (1); } |