diff options
Diffstat (limited to '')
-rw-r--r-- | src/c_init.c | 20 | ||||
-rw-r--r-- | src/c_init.h | 2 | ||||
-rw-r--r-- | src/c_input.c | 3 | ||||
-rw-r--r-- | src/m_loop.c | 2 |
4 files changed, 11 insertions, 16 deletions
diff --git a/src/c_init.c b/src/c_init.c index d50daf4..7296a2b 100644 --- a/src/c_init.c +++ b/src/c_init.c @@ -14,7 +14,6 @@ #include <stdlib.h> #include <term.h> #include <libft.h> -#include <signal.h> #include "c_init.h" #include "c_input.h" @@ -91,7 +90,7 @@ char int i; i = -1; - if (line == NULL || line[0] == '\0') + if (line == NULL) { if (!(line = ft_calloc(1, sizeof(char)))) return (NULL); @@ -103,23 +102,18 @@ char tcaps->cpos++; } else if ((*((unsigned int *)buf)) == DEL_K) - { c_back_slash(&line, ft_strlen(msh->ps[0]), tcaps); - } else if (buf[0] == '\n') - { return (c_new_line(line, tcaps, msh)); - } else - { c_read_cap(buf, line, tcaps, msh); - } - return (line); + return (NULL); } int16_t - c_init_tcaps(char **line, - t_msh *msh) +c_init_tcaps(int32_t fd, + char **line, + t_msh *msh) { t_caps tcaps; char *term; @@ -128,19 +122,17 @@ int16_t term = getenv("TERM"); if (!tgetent(NULL, term)) return (-1); - c_set_term_raw(1); c_get_struct(1, &tcaps); c_init_line(&tcaps); tputs(tgetstr("cr", NULL), 1, ft_putchar); m_prompt_psx(1, msh); - signal(SIGINT, SIG_IGN); ft_bzero(nread, 5); if (!(c_get_win_size(&tcaps.ws))) return (-1); while (!(ft_strchr(nread, '\n'))) { ft_bzero(nread, 5); - if (!(read(STDIN_FILENO, nread, 4))) + if (!(read(fd, nread, 4))) return (0); else *line = c_process_key(nread, &tcaps, msh); diff --git a/src/c_init.h b/src/c_init.h index 1614b5e..db448cf 100644 --- a/src/c_init.h +++ b/src/c_init.h @@ -38,7 +38,7 @@ typedef struct s_caps uint32_t nlines; /*cursor position (line)*/ } t_caps; -int16_t c_init_tcaps(char **line, t_msh *msh); +int16_t c_init_tcaps(int32_t fd, char **line, t_msh *msh); int16_t c_set_term_raw(uint8_t mode); #endif diff --git a/src/c_input.c b/src/c_input.c index 7c6d351..d3360cd 100644 --- a/src/c_input.c +++ b/src/c_input.c @@ -13,6 +13,7 @@ #include <libft.h> #include <term.h> #include <unistd.h> +#include <signal.h> #include "c_init.h" #include "c_input.h" @@ -25,6 +26,8 @@ int16_t { if (tcaps) { + c_set_term_raw(1); + signal(SIGINT, SIG_IGN); tcaps->cpos = 0; tcaps->lpos = 0; return (1); diff --git a/src/m_loop.c b/src/m_loop.c index d4bc665..f1fc80d 100644 --- a/src/m_loop.c +++ b/src/m_loop.c @@ -44,7 +44,7 @@ uint8_t /* if (fd == STDIN_FILENO) */ /* m_prompt_psx(1, msh); */ /* gnl = get_next_line(fd, &line); */ - gnl = c_init_tcaps(&line, msh); + gnl = c_init_tcaps(fd, &line, msh); if (line[0] != '\0') { line = m_check_multi_backslash(fd, line, msh); |