summaryrefslogtreecommitdiffstats
path: root/src/c_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/c_init.c')
-rw-r--r--src/c_init.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/c_init.c b/src/c_init.c
index b1e9fb2..7fb530f 100644
--- a/src/c_init.c
+++ b/src/c_init.c
@@ -185,45 +185,44 @@ static void
static char
*c_process_key(char **line, char *buf, t_caps *tcaps, t_msh *msh)
{
- static char *line = NULL;
char *ptr;
- if (line == NULL || line == (void*)0x1)
+ if (*line == NULL)
{
- if (!(line = calloc(1, sizeof(char))))
+ if (!(*line = calloc(1, sizeof(char))))
return (NULL);
}
if (ft_isprint(buf[0]))
- c_add_char(&line, buf, tcaps);
+ 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);
+ c_key_up_down(line, tcaps, ptr);
+ 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);
+ c_key_up_down(line, tcaps, ptr);
+ c_redraw_line(*line, tcaps);
}
else if ((*((unsigned int *)buf)) == DEL_K)
{
- c_back_slash(&line, tcaps->plen, tcaps);
+ c_back_slash(line, tcaps->plen, tcaps);
if ((((tcaps->cpos) + tcaps->plen) %
tcaps->ws.ws_col) == 0)
{
return (NULL);
}
- c_redraw_line(line, tcaps);
+ c_redraw_line(*line, tcaps);
}
else if ((*((unsigned int *)buf)) == CTRL_C)
- return (c_ctrl_c(&line, buf, msh));
+ return (c_ctrl_c(line, buf, msh));
else
- c_read_cap(buf, line, tcaps, msh);
- return ((buf[0] == '\n') ? c_new_line(line, tcaps) : NULL);
+ c_read_cap(buf, *line, tcaps, msh);
+ return ((buf[0] == '\n') ? c_new_line(*line, tcaps) : NULL);
}
short
@@ -238,6 +237,7 @@ short
ft_bzero(nread, 4);
msh->sig = 0;
tcaps.plen = (unsigned int)m_plen(msh->ps[psx - 1]);
+ *line = NULL;
if (!(c_get_win_size(&tcaps.ws)))
return (-1);
while (!(ft_strchr(nread, '\n')))
@@ -246,7 +246,7 @@ short
if (!(read(fd, nread, 3)))
return (0);
else
- *line = c_process_key(nread, &tcaps, msh);
+ c_process_key(line, nread, &tcaps, msh);
tputs(tgetstr("ve", NULL), 1, ft_putchar);
}
return (1);