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.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/c_init.c b/src/c_init.c
index 1442fdb..844e4a6 100644
--- a/src/c_init.c
+++ b/src/c_init.c
@@ -61,18 +61,19 @@ int16_t
int16_t
c_read_cap(char *buf, char *line, t_caps *tcaps, t_msh *msh)
{
+ uint32_t plen;
+
+ plen = ft_strlen(msh->ps[tcaps->psx]);
if (((*((unsigned int *)buf)) == LEFT_K) ||
((*((unsigned int *)buf)) == CTRL_B))
- return (c_key_left(ft_strlen(msh->ps[tcaps->psx]), tcaps));
+ return (c_key_left(plen, tcaps));
else if (((*((unsigned int *)buf)) == RIGHT_K) ||
- ((*((unsigned int *)buf)) == CTRL_F))
- return (c_key_right(ft_strlen(line),
- ft_strlen(msh->ps[tcaps->psx]), tcaps));
+ ((*((unsigned int *)buf)) == CTRL_F))
+ return (c_key_right(ft_strlen(line), plen, tcaps));
else if ((*((unsigned int *)buf)) == HOME_K)
- return (c_key_left(ft_strlen(msh->ps[tcaps->psx]), c_home_key(tcaps));
+ return (c_home_key(plen, tcaps));
else if ((*((unsigned int *)buf)) == END_K)
- return (c_end_key(ft_strlen(line),
- ft_strlen(msh->ps[tcaps->psx]), tcaps));
+ return (c_end_key(ft_strlen(line), plen, tcaps));
else if ((*((unsigned int *)buf)) == CTRL_C)
return (c_ctrl_c(NULL, tcaps, msh));
else if ((*((unsigned int *)buf)) == CTRL_L)
@@ -98,7 +99,7 @@ static char
if ((((tcaps->cpos) + ft_strlen(msh->ps[tcaps->psx])) %
tcaps->ws.ws_col) == 0)
{
- write(1, "\n", 1);
+ write(1, "\n\r", 2);
return (NULL);
}
c_redraw_line(line, tcaps, msh);
@@ -106,6 +107,11 @@ static char
else if ((*((unsigned int *)buf)) == DEL_K)
{
c_back_slash(&line, ft_strlen(msh->ps[tcaps->psx]), tcaps);
+ if ((((tcaps->cpos) + ft_strlen(msh->ps[tcaps->psx])) %
+ tcaps->ws.ws_col) == 0)
+ {
+ return (NULL);
+ }
c_redraw_line(line, tcaps, msh);
}
else