summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSalad <water_appreciator@protonmail.com>2020-10-05 17:37:55 +0200
committerSalad <water_appreciator@protonmail.com>2020-10-05 17:37:55 +0200
commitf5eb08c14ccaa5e7a0e35364668ba28433459f9d (patch)
treee00b36d7c0bc787b41d07e56a3b0e08cbc002939
parentalmost there : norme + miltiligne (diff)
download42-minishell-f5eb08c14ccaa5e7a0e35364668ba28433459f9d.tar.gz
42-minishell-f5eb08c14ccaa5e7a0e35364668ba28433459f9d.tar.bz2
42-minishell-f5eb08c14ccaa5e7a0e35364668ba28433459f9d.tar.xz
42-minishell-f5eb08c14ccaa5e7a0e35364668ba28433459f9d.tar.zst
42-minishell-f5eb08c14ccaa5e7a0e35364668ba28433459f9d.zip
some changes, need MORE
-rw-r--r--src/c_init.c4
-rw-r--r--src/c_input.c4
-rw-r--r--src/c_keys.c6
-rw-r--r--src/c_keys.h2
-rw-r--r--src/c_utils.c19
-rw-r--r--src/c_utils.h2
6 files changed, 18 insertions, 19 deletions
diff --git a/src/c_init.c b/src/c_init.c
index 66e0541..de10dfa 100644
--- a/src/c_init.c
+++ b/src/c_init.c
@@ -66,7 +66,7 @@ c_read_cap(char *buf,
t_msh *msh)
{
if ((*((unsigned int *)buf)) == LEFT_K)
- return (c_key_left(ft_strlen(line), ft_strlen(msh->ps[tcaps->psx]), tcaps));
+ return (c_key_left(ft_strlen(msh->ps[tcaps->psx]), tcaps));
else if ((*((unsigned int *)buf)) == RIGHT_K)
return (c_key_right(ft_strlen(line), ft_strlen(msh->ps[tcaps->psx]), tcaps));
else if ((*((unsigned int *)buf)) == HOME_K)
@@ -106,7 +106,7 @@ static char
else
c_read_cap(buf, line, tcaps, msh);
if (buf[0] == '\n')
- return (c_new_line(line, tcaps, msh));
+ return (c_new_line(line, tcaps));
return (NULL);
}
diff --git a/src/c_input.c b/src/c_input.c
index 1cc8814..19d2ef3 100644
--- a/src/c_input.c
+++ b/src/c_input.c
@@ -63,7 +63,7 @@ c_get_line_num(char *line,
line_num = 0;
tcaps->lpos = 1;
len = ft_strlen(line);
- if (len < (tcaps->ws.ws_col - plen))
+ if ((len) < (tcaps->ws.ws_col - plen))
return (1);
while (it < len)
{
@@ -109,6 +109,6 @@ int16_t
(void)tcaps;
(void)line;
msh->ret = 130;
- c_new_line(NULL, tcaps, msh);
+ c_new_line(NULL, tcaps);
return (1);
}
diff --git a/src/c_keys.c b/src/c_keys.c
index 8232521..a5b90fb 100644
--- a/src/c_keys.c
+++ b/src/c_keys.c
@@ -87,7 +87,7 @@ int16_t
uint32_t plen,
t_caps *tcaps)
{
- if (((tcaps->cpos + plen + 1) % (tcaps->ws.ws_col)) == 0
+ if ((((tcaps->cpos + plen + 1) % (tcaps->ws.ws_col)) == 0)
&& tcaps->cpos < len)
{
tputs(tgetstr("do", NULL), 1, ft_putchar);
@@ -103,12 +103,10 @@ int16_t
}
int16_t
- c_key_left(uint32_t len,
- uint32_t plen,
+ c_key_left(uint32_t plen,
t_caps *tcaps)
{
int32_t pos;
- (void)len;
pos = -1;
if (((tcaps->cpos + plen) % (tcaps->ws.ws_col)) == 0
diff --git a/src/c_keys.h b/src/c_keys.h
index d261824..250b297 100644
--- a/src/c_keys.h
+++ b/src/c_keys.h
@@ -14,7 +14,7 @@
#define C_KEYS_H
int16_t c_key_right(uint32_t len, uint32_t plen, t_caps *tcaps);
-int16_t c_key_left(uint32_t len, uint32_t plen, t_caps *tcaps);
+int16_t c_key_left(uint32_t plen, t_caps *tcaps);
int16_t c_home_key(t_caps *tcaps);
int16_t c_end_key(uint16_t size, t_caps *tcaps);
int16_t c_ctrl_l(char *line, t_caps *tcaps, t_msh *msh);
diff --git a/src/c_utils.c b/src/c_utils.c
index 8a142cf..a62e3f9 100644
--- a/src/c_utils.c
+++ b/src/c_utils.c
@@ -25,17 +25,16 @@
** TODO:
** delchar MOVE
** NORME
+** c_redraw_next TOUJOURS CALL --> DLA MERDE
** C-c globul pid
*/
char
*c_new_line(char *line,
- t_caps *tcaps,
- t_msh *msh)
+ t_caps *tcaps)
{
char *ret;
- (void)msh;
ret = NULL;
write(1, "\n", 1);
tputs(tgetstr("cr", NULL), 1, ft_putchar);
@@ -120,16 +119,18 @@ static int16_t
while (--j > tcaps->lpos)
tputs(tgetstr("up", NULL), 1, ft_putchar);
tputs(tgetstr("up", NULL), 1, ft_putchar);
- tputs(tgetstr("cr", NULL), 1, ft_putchar); /* cr, cpos mauvaise col, bonne ligne */
+ tputs(tgetstr("cr", NULL), 1, ft_putchar);
while (i <= (tcaps->cpos + plen))
{
- tputs(tgetstr("nd", NULL), 1, ft_putchar); /* cr, cpos mauvaise col, bonne ligne */
+ tputs(tgetstr("nd", NULL), 1, ft_putchar);
i++;
}
}
else
while (--len > tcaps->cpos)
+ {
tputs(tgetstr("le", NULL), 1, ft_putchar);
+ }
return (len);
}
@@ -143,13 +144,13 @@ int16_t
tcaps->nlines = c_get_line_num(line, tcaps->cpos,
ft_strlen(msh->ps[tcaps->psx]), tcaps);
- j = tcaps->lpos;
i = 0;
+ j = tcaps->lpos;
tputs(tgetstr("cr", NULL), 1, ft_putchar);
- if (((tcaps->cpos + ft_strlen(msh->ps[tcaps->psx])) % tcaps->ws.ws_col) == 0)
+ if ((((tcaps->cpos - 1) + ft_strlen(msh->ps[tcaps->psx])) %
+ tcaps->ws.ws_col) == 0)
{
tputs(tgetstr("sf", NULL), 1, ft_putchar);
- return (1);
}
while (--j > 0)
{
@@ -160,7 +161,7 @@ int16_t
while (i++ < ft_strlen(msh->ps[tcaps->psx]))
tputs(tgetstr("nd", NULL), 1, ft_putchar);
ft_printf("%s", line);
- return ((tcaps->cpos != ft_strlen(line)) ?
+ return (((tcaps->cpos) != ft_strlen(line)) ?
c_redraw_next(ft_strlen(msh->ps[tcaps->psx]), ft_strlen(line), tcaps) :
ft_strlen(line));
}
diff --git a/src/c_utils.h b/src/c_utils.h
index e6410a3..6aebca8 100644
--- a/src/c_utils.h
+++ b/src/c_utils.h
@@ -15,7 +15,7 @@
#include "s_struct.h"
-char *c_new_line(char *line, t_caps *tcaps, t_msh *msh);
+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, uint16_t cpos);
int16_t c_redraw_line(char *line, t_caps *tcaps, t_msh *msh);