summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--src/c_init.c42
-rw-r--r--src/c_init.h20
-rw-r--r--src/m_loop.c1
4 files changed, 55 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 0524861..bff54cc 100644
--- a/Makefile
+++ b/Makefile
@@ -87,7 +87,7 @@ ifeq (${OS}, FreeBSD)
CC = /usr/bin/cc
endif
ifeq (${OS}, Linux)
-CC = clang
+CC = clang-8
endif
ifeq (${OS}, Darwin)
CC = clang
@@ -100,6 +100,7 @@ CFLAGS += -pedantic
#------------------------------------------------------------------------------#
LDFLAGS = -L${LFT_DIR}
LDFLAGS += -lft
+LDFLAGS += -lncurses
#==============================================================================#
#--------------------------------- UNIX ---------------------------------------#
#==============================================================================#
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);
}
diff --git a/src/c_init.h b/src/c_init.h
index da3d549..69d626a 100644
--- a/src/c_init.h
+++ b/src/c_init.h
@@ -13,7 +13,23 @@
#ifndef U_INIT_H
#define U_INIT_H
-int c_init_tcaps(void);
-void u_handle_sigwinch(int dummy_signal);
+#include <termios.h>
+
+typedef struct s_caps {
+ struct termios tios;
+ char *cm_str; /*cursor mobility*/
+ char *nl; /*newline, returned by tgoto()*/
+ char *ks; /*indicate that keys transmit from now on*/
+ char *kl; /*Key Left Key Right*/
+ char *kr;
+ char *pc; /*padding char --> do not touch (default 0)*/
+ char *bc; /*left one char*/
+ char *up; /*up one line*/
+ char *nd; /*right one char*/
+ char *lc; /*line clear*/
+
+} t_caps;
+
+int16_t c_init_tcaps(void);
#endif
diff --git a/src/m_loop.c b/src/m_loop.c
index ed92fd5..75b8e3e 100644
--- a/src/m_loop.c
+++ b/src/m_loop.c
@@ -39,7 +39,6 @@ uint8_t
int8_t gnl;
c_init_tcaps();
- signal(SIGWINCH, u_handle_sigwinch);
gnl = 1;
while (gnl > 0)
{