diff options
Diffstat (limited to 'src/c_init.c')
-rw-r--r-- | src/c_init.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/c_init.c b/src/c_init.c index 0001660..59cb5fa 100644 --- a/src/c_init.c +++ b/src/c_init.c @@ -116,28 +116,18 @@ char return (p); } -/* TODO : key_up_down should manage and set the correct key */ - static char *c_process_key(char **line, char *buf, t_caps *tcaps, t_msh *msh) { - char *ptr; - if (ft_isprint(buf[0])) 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); - } - else if (((*((unsigned int *)buf)) == DOWN_K) || + ((*((unsigned int *)buf)) == CTRL_P) || + ((*((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); + tcaps->key = c_set_key(buf); + c_key_up_down(line, tcaps, msh); } else if ((*((unsigned int *)buf)) == DEL_K) { @@ -167,6 +157,8 @@ short msh->sig = 0; tcaps.plen = (unsigned int)m_plen(msh->ps[psx - 1]); *line = NULL; + if (!(*line = ft_calloc(sizeof(char), 1))) + return (-1); if (!(c_get_win_size(&tcaps.ws))) return (-1); while (!(ft_strchr(nread, '\n'))) |