diff options
author | salad <fmoenne-@student.le-101.fr> | 2020-12-07 15:36:45 +0100 |
---|---|---|
committer | salad <fmoenne-@student.le-101.fr> | 2020-12-07 15:36:45 +0100 |
commit | 3feb8a2f8b82a35df1f4c7e6f643bf8eaabb6f60 (patch) | |
tree | 3a65ec384f731b5e5621494f21bb2417986639f1 /src/c_init.c | |
parent | gnu c compiler compatible (diff) | |
download | 42-minishell-3feb8a2f8b82a35df1f4c7e6f643bf8eaabb6f60.tar.gz 42-minishell-3feb8a2f8b82a35df1f4c7e6f643bf8eaabb6f60.tar.bz2 42-minishell-3feb8a2f8b82a35df1f4c7e6f643bf8eaabb6f60.tar.xz 42-minishell-3feb8a2f8b82a35df1f4c7e6f643bf8eaabb6f60.tar.zst 42-minishell-3feb8a2f8b82a35df1f4c7e6f643bf8eaabb6f60.zip |
WIP
Diffstat (limited to 'src/c_init.c')
-rw-r--r-- | src/c_init.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/c_init.c b/src/c_init.c index 7a1509c..358f145 100644 --- a/src/c_init.c +++ b/src/c_init.c @@ -58,7 +58,7 @@ short } static void - c_add_char(char **line, char *buf, t_caps *tcaps, t_msh *msh) + c_add_char(char **line, char *buf, t_caps *tcaps) { *line = c_insert_char(*line, buf[0], tcaps); tcaps->cpos++; @@ -68,7 +68,7 @@ static void write(STDOUT_FILENO, "\n\r", 2); return ; } - c_redraw_line(*line, tcaps, msh); + c_redraw_line(*line, tcaps); } static short @@ -166,23 +166,26 @@ static char char *ptr; if (line == NULL) - if (!(line = ft_calloc(1, sizeof(char)))) + { + ft_printf("\r\nline is NULL\r\n"); + if (!(line = calloc(1, sizeof(char)))) return (NULL); + } if (ft_isprint(buf[0])) - c_add_char(&line, buf, tcaps, msh); + c_add_char(&line, buf, tcaps); else if (((*((unsigned int *)buf)) == UP_K) || ((*((unsigned int *)buf)) == CTRL_P)) { ptr = c_set_ptr(FALSE, -1, msh); c_key_up_down(&line, tcaps, ptr); - c_redraw_line(line, tcaps, msh); + c_redraw_line(line, tcaps); } else if (((*((unsigned int *)buf)) == DOWN_K) || ((*((unsigned int *)buf)) == CTRL_N)) { ptr = c_set_ptr(FALSE, 1, msh); c_key_up_down(&line, tcaps, ptr); - c_redraw_line(line, tcaps, msh); + c_redraw_line(line, tcaps); } else if ((*((unsigned int *)buf)) == DEL_K) { @@ -192,7 +195,7 @@ static char { return (NULL); } - c_redraw_line(line, tcaps, msh); + c_redraw_line(line, tcaps); } else if ((*((unsigned int *)buf)) == CTRL_C) return (c_ctrl_c(&line, buf, msh)); @@ -224,5 +227,6 @@ short *line = c_process_key(nread, &tcaps, msh); tputs(tgetstr("ve", NULL), 1, ft_putchar); } + ft_printf("[%s]\n", *line); return (1); } |