diff options
Diffstat (limited to 'src/c_init.c')
-rw-r--r-- | src/c_init.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/c_init.c b/src/c_init.c index f4b130d..0044f98 100644 --- a/src/c_init.c +++ b/src/c_init.c @@ -103,13 +103,15 @@ int16_t exit(0); } line = ft_strjoin_m(line, buf); - c_redraw_line(line, msh); + c_redraw_line(line, tcaps->cpos, msh); + tcaps->cpos++; } else { if (strncmp(buf, tgetstr("kr", NULL), ft_strlen(tgetstr("kr", NULL))) == 0) { tputs(tgetstr("nd", NULL), 1, ft_putchar); + tcaps->cpos++; return (1); } else if (buf[0] == '\n') @@ -118,6 +120,7 @@ int16_t tputs(tgetstr("cr", NULL), 1, ft_putchar); m_parse_and_run_line(line, msh); line = NULL; + tcaps->cpos = 0; tputs(tgetstr("cr", NULL), 1, ft_putchar); m_prompt_psx(1, msh); return (1); @@ -125,11 +128,12 @@ int16_t else if (strncmp(buf, tgetstr("kl", NULL), ft_strlen(tgetstr("kl", NULL))) == 0) { tputs(tgetstr("le", NULL), 1, ft_putchar); + tcaps->cpos--; return (1); } else if (strncmp(buf, tgetstr("kb", NULL), ft_strlen(tgetstr("kb", NULL))) == 0) { - c_delchar(line, tcaps); + line = c_delchar(line, tcaps->cpos); tputs(tgetstr("le", NULL), 1, ft_putchar); tputs(tgetstr("dc", NULL), 1, ft_putchar); return (1); @@ -150,10 +154,12 @@ int16_t c_init_tcaps(t_msh *msh) term = getenv("TERM"); if (!tgetent(bp, term)) return (-1); - + tcaps.cpos = 0; ft_printf("my term is %s", term); c_set_term_raw(1); c_get_struct(1, &tcaps); + if (!(c_get_win_size(&tcaps.ws))) + return (-1); while (1) { ft_bzero(nread, 5); |