From 9ca75e7eb366800b3c602fb948167bcb185bed37 Mon Sep 17 00:00:00 2001 From: salad Date: Thu, 27 Aug 2020 23:29:07 +0200 Subject: added init, samarche pas, peutetre go GNL --- src/c_init.c | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) (limited to 'src/c_init.c') 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 +#include +#include +#include +#include #include #include -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); } -- cgit v1.2.3