diff options
Diffstat (limited to '')
-rw-r--r-- | src/c_init.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/c_init.c b/src/c_init.c index 9196d51..0e48b2f 100644 --- a/src/c_init.c +++ b/src/c_init.c @@ -65,20 +65,20 @@ c_read_cap(char *buf, t_caps *tcaps, t_msh *msh) { - if (((*((unsigned int *)buf)) == LEFT_K) || ((*((unsigned int *)buf)) == CTRL_B)) - return (c_key_left(ft_strlen(msh->ps[tcaps->psx]), tcaps)); - else if (((*((unsigned int *)buf)) == RIGHT_K) || ((*((unsigned int *)buf)) == CTRL_F)) - return (c_key_right(ft_strlen(line), ft_strlen(msh->ps[tcaps->psx]), tcaps)); - else if ((*((unsigned int *)buf)) == HOME_K) - return (c_home_key(tcaps)); - else if ((*((unsigned int *)buf)) == END_K) - return (c_end_key(ft_strlen(line), tcaps)); - else if ((*((unsigned int *)buf)) == CTRL_C) - return (c_ctrl_c(NULL, tcaps, msh)); - else if ((*((unsigned int *)buf)) == CTRL_L) - return (c_ctrl_l(line, tcaps, msh)); - else - return (0); + if (((*((unsigned int *)buf)) == LEFT_K) || ((*((unsigned int *)buf)) == CTRL_B)) + return (c_key_left(ft_strlen(msh->ps[tcaps->psx]), tcaps)); + else if (((*((unsigned int *)buf)) == RIGHT_K) || ((*((unsigned int *)buf)) == CTRL_F)) + return (c_key_right(ft_strlen(line), ft_strlen(msh->ps[tcaps->psx]), tcaps)); + else if ((*((unsigned int *)buf)) == HOME_K) + return (c_home_key(tcaps)); + else if ((*((unsigned int *)buf)) == END_K) + return (c_end_key(ft_strlen(line), tcaps)); + else if ((*((unsigned int *)buf)) == CTRL_C) + return (c_ctrl_c(NULL, tcaps, msh)); + else if ((*((unsigned int *)buf)) == CTRL_L) + return (c_ctrl_l(line, tcaps, msh)); + else + return (0); } static char @@ -98,8 +98,14 @@ static char if (ft_isprint(buf[0])) { line = c_insert_char(line, buf[0], tcaps); - c_redraw_line(line, tcaps, msh); tcaps->cpos++; + if ((((tcaps->cpos) + ft_strlen(msh->ps[tcaps->psx])) % + tcaps->ws.ws_col) == 0) + { + write(1, "\n", 1); + return (NULL); + } + c_redraw_line(line, tcaps, msh); } else if ((*((unsigned int *)buf)) == DEL_K) { |