summaryrefslogtreecommitdiffstats
path: root/src/c_init.c
diff options
context:
space:
mode:
authorsalad <fmoenne-@student.le-101.fr>2020-09-09 14:10:09 +0200
committersalad <fmoenne-@student.le-101.fr>2020-09-09 14:10:09 +0200
commitca3cc66deebc4dc5ac52b14ed099c05f416ccc7f (patch)
tree4737eb8d8523c682eb13e491ab3f85dad5d86af0 /src/c_init.c
parentclean, ca fait ziz (diff)
download42-minishell-ca3cc66deebc4dc5ac52b14ed099c05f416ccc7f.tar.gz
42-minishell-ca3cc66deebc4dc5ac52b14ed099c05f416ccc7f.tar.bz2
42-minishell-ca3cc66deebc4dc5ac52b14ed099c05f416ccc7f.tar.xz
42-minishell-ca3cc66deebc4dc5ac52b14ed099c05f416ccc7f.tar.zst
42-minishell-ca3cc66deebc4dc5ac52b14ed099c05f416ccc7f.zip
insert a char try it
Diffstat (limited to '')
-rw-r--r--src/c_init.c9
1 files changed, 8 insertions, 1 deletions
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)