summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsalad <fmoenne-@student.le-101.fr>2020-12-07 15:36:45 +0100
committersalad <fmoenne-@student.le-101.fr>2020-12-07 15:36:45 +0100
commit3feb8a2f8b82a35df1f4c7e6f643bf8eaabb6f60 (patch)
tree3a65ec384f731b5e5621494f21bb2417986639f1 /src
parentgnu c compiler compatible (diff)
download42-minishell-3feb8a2f8b82a35df1f4c7e6f643bf8eaabb6f60.tar.gz
42-minishell-3feb8a2f8b82a35df1f4c7e6f643bf8eaabb6f60.tar.bz2
42-minishell-3feb8a2f8b82a35df1f4c7e6f643bf8eaabb6f60.tar.xz
42-minishell-3feb8a2f8b82a35df1f4c7e6f643bf8eaabb6f60.tar.zst
42-minishell-3feb8a2f8b82a35df1f4c7e6f643bf8eaabb6f60.zip
WIP
Diffstat (limited to '')
-rw-r--r--src/c_ctrls.c2
-rw-r--r--src/c_init.c18
-rw-r--r--src/c_utils.c3
-rw-r--r--src/c_utils.h2
4 files changed, 15 insertions, 10 deletions
diff --git a/src/c_ctrls.c b/src/c_ctrls.c
index f841705..dcb51de 100644
--- a/src/c_ctrls.c
+++ b/src/c_ctrls.c
@@ -34,7 +34,7 @@ short c_ctrl_l(char *line, t_caps *tcaps, t_msh *msh)
{
tputs(tgetstr("cl", NULL), 1, ft_putchar);
m_prompt_psx(1, msh);
- c_redraw_line(line, tcaps, msh);
+ c_redraw_line(line, tcaps);
return (1);
}
diff --git a/src/c_init.c b/src/c_init.c
index 7a1509c..358f145 100644
--- a/src/c_init.c
+++ b/src/c_init.c
@@ -58,7 +58,7 @@ short
}
static void
- c_add_char(char **line, char *buf, t_caps *tcaps, t_msh *msh)
+ c_add_char(char **line, char *buf, t_caps *tcaps)
{
*line = c_insert_char(*line, buf[0], tcaps);
tcaps->cpos++;
@@ -68,7 +68,7 @@ static void
write(STDOUT_FILENO, "\n\r", 2);
return ;
}
- c_redraw_line(*line, tcaps, msh);
+ c_redraw_line(*line, tcaps);
}
static short
@@ -166,23 +166,26 @@ static char
char *ptr;
if (line == NULL)
- if (!(line = ft_calloc(1, sizeof(char))))
+ {
+ ft_printf("\r\nline is NULL\r\n");
+ if (!(line = calloc(1, sizeof(char))))
return (NULL);
+ }
if (ft_isprint(buf[0]))
- c_add_char(&line, buf, tcaps, msh);
+ 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, msh);
+ c_redraw_line(line, tcaps);
}
else if (((*((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, msh);
+ c_redraw_line(line, tcaps);
}
else if ((*((unsigned int *)buf)) == DEL_K)
{
@@ -192,7 +195,7 @@ static char
{
return (NULL);
}
- c_redraw_line(line, tcaps, msh);
+ c_redraw_line(line, tcaps);
}
else if ((*((unsigned int *)buf)) == CTRL_C)
return (c_ctrl_c(&line, buf, msh));
@@ -224,5 +227,6 @@ short
*line = c_process_key(nread, &tcaps, msh);
tputs(tgetstr("ve", NULL), 1, ft_putchar);
}
+ ft_printf("[%s]\n", *line);
return (1);
}
diff --git a/src/c_utils.c b/src/c_utils.c
index fa2eaaf..73d5a3e 100644
--- a/src/c_utils.c
+++ b/src/c_utils.c
@@ -35,7 +35,7 @@ char
if (line != NULL)
{
ret = ft_strdup(line);
- line[0] = '\0';
+ ft_memdel((void*)&line);
}
tcaps->cpos = 0;
tputs(tgetstr("cr", NULL), 1, ft_putchar);
@@ -44,6 +44,7 @@ char
{
write(1, "\n", 1);
}
+ /* ft_printf("[%s][%s]\n", ret, line); */
return (ret);
}
diff --git a/src/c_utils.h b/src/c_utils.h
index f33c961..aad51ea 100644
--- a/src/c_utils.h
+++ b/src/c_utils.h
@@ -18,6 +18,6 @@
char *c_new_line(char *line, t_caps *tcaps);
char *c_insert_char(char *str, char c, t_caps *tcaps);
char *c_delchar(char *str, unsigned short cpos);
-short c_redraw_line(char *line, t_caps *tcaps, t_msh *msh);
+short c_redraw_line(char *line, t_caps *tcaps);
#endif