summaryrefslogtreecommitdiffstats
path: root/src/c_init.c
diff options
context:
space:
mode:
authorSalad <water_appreciator@protonmail.com>2020-10-21 18:23:04 +0200
committerSalad <water_appreciator@protonmail.com>2020-10-21 18:23:04 +0200
commita0c2a69d6c79e11c0eb25751d6c246bb164ebc31 (patch)
treec172bb09ebd52b262141aa4e5fabdbdf5e00e4f3 /src/c_init.c
parentstuff (diff)
download42-minishell-a0c2a69d6c79e11c0eb25751d6c246bb164ebc31.tar.gz
42-minishell-a0c2a69d6c79e11c0eb25751d6c246bb164ebc31.tar.bz2
42-minishell-a0c2a69d6c79e11c0eb25751d6c246bb164ebc31.tar.xz
42-minishell-a0c2a69d6c79e11c0eb25751d6c246bb164ebc31.tar.zst
42-minishell-a0c2a69d6c79e11c0eb25751d6c246bb164ebc31.zip
makeshift
Diffstat (limited to '')
-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