From ca3cc66deebc4dc5ac52b14ed099c05f416ccc7f Mon Sep 17 00:00:00 2001 From: salad Date: Wed, 9 Sep 2020 14:10:09 +0200 Subject: insert a char try it --- src/c_init.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/c_init.c') diff --git a/src/c_init.c b/src/c_init.c index ad18d92..effcc7d 100644 --- a/src/c_init.c +++ b/src/c_init.c @@ -21,6 +21,7 @@ #include "c_input.h" #include "c_utils.h" #include "s_struct.h" +#include "m_prompt.h" static char *ft_strjoin_m(char *s1, @@ -84,6 +85,8 @@ int16_t return (1); } +/* c_insert_char */ + int16_t c_process_key(char *buf, t_caps *tcaps, @@ -98,7 +101,10 @@ int16_t return (0); if (ft_isprint(buf[0])) { - line = ft_strjoin_m(line, buf); + if (tcaps->cpos == ft_strlen(line)) + line = ft_strjoin_m(line, buf); + else + line = c_insert_char(line, buf[0], tcaps); c_redraw_line(line, tcaps->cpos, msh); tcaps->cpos++; } @@ -140,6 +146,7 @@ int16_t tcaps.cpos = 0; c_set_term_raw(1); c_get_struct(1, &tcaps); + m_prompt_psx(1, msh); if (!(c_get_win_size(&tcaps.ws))) return (-1); while (1) -- cgit v1.2.3