summaryrefslogtreecommitdiffstats
path: root/src/c_init.c
diff options
context:
space:
mode:
authorSalad <water_appreciator@protonmail.com>2020-10-19 17:32:53 +0200
committerSalad <water_appreciator@protonmail.com>2020-10-19 17:32:53 +0200
commit35ea2d4a8a529c8680891cd1aae8cfe0088dd284 (patch)
tree465f5be4e8900152151f384adeacb188e0b9c03a /src/c_init.c
parentqsd (diff)
download42-minishell-35ea2d4a8a529c8680891cd1aae8cfe0088dd284.tar.gz
42-minishell-35ea2d4a8a529c8680891cd1aae8cfe0088dd284.tar.bz2
42-minishell-35ea2d4a8a529c8680891cd1aae8cfe0088dd284.tar.xz
42-minishell-35ea2d4a8a529c8680891cd1aae8cfe0088dd284.tar.zst
42-minishell-35ea2d4a8a529c8680891cd1aae8cfe0088dd284.zip
FIX ALL NIG
Diffstat (limited to '')
-rw-r--r--src/c_init.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/c_init.c b/src/c_init.c
index 9196d51..0e48b2f 100644
--- a/src/c_init.c
+++ b/src/c_init.c
@@ -65,20 +65,20 @@ c_read_cap(char *buf,
t_caps *tcaps,
t_msh *msh)
{
- if (((*((unsigned int *)buf)) == LEFT_K) || ((*((unsigned int *)buf)) == CTRL_B))
- return (c_key_left(ft_strlen(msh->ps[tcaps->psx]), 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));
- else if ((*((unsigned int *)buf)) == HOME_K)
- return (c_home_key(tcaps));
- else if ((*((unsigned int *)buf)) == END_K)
- return (c_end_key(ft_strlen(line), tcaps));
- else if ((*((unsigned int *)buf)) == CTRL_C)
- return (c_ctrl_c(NULL, tcaps, msh));
- else if ((*((unsigned int *)buf)) == CTRL_L)
- return (c_ctrl_l(line, tcaps, msh));
- else
- return (0);
+ if (((*((unsigned int *)buf)) == LEFT_K) || ((*((unsigned int *)buf)) == CTRL_B))
+ return (c_key_left(ft_strlen(msh->ps[tcaps->psx]), 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));
+ else if ((*((unsigned int *)buf)) == HOME_K)
+ return (c_home_key(tcaps));
+ else if ((*((unsigned int *)buf)) == END_K)
+ return (c_end_key(ft_strlen(line), tcaps));
+ else if ((*((unsigned int *)buf)) == CTRL_C)
+ return (c_ctrl_c(NULL, tcaps, msh));
+ else if ((*((unsigned int *)buf)) == CTRL_L)
+ return (c_ctrl_l(line, tcaps, msh));
+ else
+ return (0);
}
static char
@@ -98,8 +98,14 @@ static char
if (ft_isprint(buf[0]))
{
line = c_insert_char(line, buf[0], tcaps);
- c_redraw_line(line, tcaps, msh);
tcaps->cpos++;
+ if ((((tcaps->cpos) + ft_strlen(msh->ps[tcaps->psx])) %
+ tcaps->ws.ws_col) == 0)
+ {
+ write(1, "\n", 1);
+ return (NULL);
+ }
+ c_redraw_line(line, tcaps, msh);
}
else if ((*((unsigned int *)buf)) == DEL_K)
{