diff options
-rw-r--r-- | src/c_init.c | 13 | ||||
-rw-r--r-- | src/m_loop.c | 2 | ||||
-rw-r--r-- | src/m_loop.h | 1 |
3 files changed, 12 insertions, 4 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); } diff --git a/src/m_loop.c b/src/m_loop.c index 232919d..600758d 100644 --- a/src/m_loop.c +++ b/src/m_loop.c @@ -23,7 +23,7 @@ #include "s_line.h" #include "c_init.h" -static void +void m_parse_and_run_line(char *line, t_msh *msh) { p_line(line, msh); diff --git a/src/m_loop.h b/src/m_loop.h index 3f95a5e..2fcacf2 100644 --- a/src/m_loop.h +++ b/src/m_loop.h @@ -17,6 +17,7 @@ #include "s_struct.h" +void m_parse_and_run_line(char *line, t_msh *msh); uint8_t m_loop(int32_t fd, t_msh *msh); #endif |