diff options
author | salad <fmoenne-@student.le-101.fr> | 2020-09-03 11:27:01 +0200 |
---|---|---|
committer | salad <fmoenne-@student.le-101.fr> | 2020-09-03 11:27:01 +0200 |
commit | c04d5d7a22528d407f4346d91b9d051f6eaf9088 (patch) | |
tree | e5a5184b72d0dd88db46cae9adf4c3280ac9593d /src/c_init.c | |
parent | enter and keys, cat line until enter pressed inc (diff) | |
download | 42-minishell-c04d5d7a22528d407f4346d91b9d051f6eaf9088.tar.gz 42-minishell-c04d5d7a22528d407f4346d91b9d051f6eaf9088.tar.bz2 42-minishell-c04d5d7a22528d407f4346d91b9d051f6eaf9088.tar.xz 42-minishell-c04d5d7a22528d407f4346d91b9d051f6eaf9088.tar.zst 42-minishell-c04d5d7a22528d407f4346d91b9d051f6eaf9088.zip |
somewhere
Diffstat (limited to 'src/c_init.c')
-rw-r--r-- | src/c_init.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/c_init.c b/src/c_init.c index beccf8a..5d07ed1 100644 --- a/src/c_init.c +++ b/src/c_init.c @@ -19,6 +19,7 @@ #include "c_init.h" #include "m_prompt.h" +#include "m_loop.h" #include "s_struct.h" static char @@ -88,7 +89,6 @@ int16_t int i; static char *line; - (void)msh; i = -1; if (line == NULL) if (!(line = ft_calloc(2, sizeof(char)))) @@ -96,7 +96,10 @@ int16_t if (ft_isprint(buf[0])) { if (*buf == 'q') + { + tputs(tgetstr("ve", NULL), 1, ft_putchar); exit(0); + } else if (*buf == '\n') tputs(tgetstr("nl", NULL), 1, ft_putchar); line = ft_strjoin_m(line, buf); @@ -112,8 +115,11 @@ int16_t else if (buf[0] == '\n') { write(1, buf, ft_strlen(buf)); - m_prompt_psx(1, msh); tputs(tgetstr("cr", NULL), 1, ft_putchar); + m_parse_and_run_line(line, msh); + tputs(tgetstr("cr", NULL), 1, ft_putchar); + ft_memdel((void**)&line); + m_prompt_psx(1, msh); return (1); } else if (strncmp(buf, tgetstr("kl", NULL), ft_strlen(tgetstr("kl", NULL))) == 0) @@ -151,8 +157,9 @@ int16_t c_init_tcaps(t_msh *msh) ft_bzero(nread, 5); if (!(read(STDIN_FILENO, nread, 4))) return (0); + tputs(tgetstr("vi", NULL), 1, ft_putchar); ret = c_process_key(msh, nread); + tputs(tgetstr("ve", NULL), 1, ft_putchar); } - ft_printf("%d\n", ret); return (1); } |