summaryrefslogtreecommitdiffstats
path: root/src/c_init.c
diff options
context:
space:
mode:
authorsalad <fmoenne-@student.le-101.fr>2020-10-01 16:24:51 +0200
committersalad <fmoenne-@student.le-101.fr>2020-10-01 16:24:51 +0200
commit730d58157c26bd551bcd0c06047a95f4f9e3d358 (patch)
treed52f5b030dd1b3dff02cce60b3e7eded02407daf /src/c_init.c
parentcall a plumber (diff)
download42-minishell-730d58157c26bd551bcd0c06047a95f4f9e3d358.tar.gz
42-minishell-730d58157c26bd551bcd0c06047a95f4f9e3d358.tar.bz2
42-minishell-730d58157c26bd551bcd0c06047a95f4f9e3d358.tar.xz
42-minishell-730d58157c26bd551bcd0c06047a95f4f9e3d358.tar.zst
42-minishell-730d58157c26bd551bcd0c06047a95f4f9e3d358.zip
lessgo
Diffstat (limited to '')
-rw-r--r--src/c_init.c20
1 files changed, 6 insertions, 14 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);