diff options
author | salad <fmoenne-@student.le-101.fr> | 2020-09-20 15:31:08 +0200 |
---|---|---|
committer | salad <fmoenne-@student.le-101.fr> | 2020-09-20 15:31:08 +0200 |
commit | c6edd1b45486b187e5423c398a89b7bf0b42ac36 (patch) | |
tree | 863f68c3849078415e73ac9b374121c510fcdb96 /src/c_utils.c | |
parent | ffs (diff) | |
download | 42-minishell-c6edd1b45486b187e5423c398a89b7bf0b42ac36.tar.gz 42-minishell-c6edd1b45486b187e5423c398a89b7bf0b42ac36.tar.bz2 42-minishell-c6edd1b45486b187e5423c398a89b7bf0b42ac36.tar.xz 42-minishell-c6edd1b45486b187e5423c398a89b7bf0b42ac36.tar.zst 42-minishell-c6edd1b45486b187e5423c398a89b7bf0b42ac36.zip |
close
Diffstat (limited to 'src/c_utils.c')
-rw-r--r-- | src/c_utils.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/c_utils.c b/src/c_utils.c index 56cfbaa..724d9d5 100644 --- a/src/c_utils.c +++ b/src/c_utils.c @@ -130,21 +130,26 @@ int16_t { uint32_t i; uint32_t len; + uint32_t mod; int16_t ret; - uint32_t nlines; + int16_t nlines; i = 0; - len = ft_strlen(line); nlines = c_get_line_num(line, tcaps->cpos, ft_strlen(msh->ps[0]), tcaps); + len = ft_strlen(line); + mod = (tcaps->ws.ws_col - ft_strlen(msh->ps[0])); tputs(tgetstr("cr", NULL), 1, ft_putchar); - if (nlines > 1) + if (len >= mod && len % mod == 0) { - ft_printf("qwe"); - /* if (tcaps->lpos > 1) */ - tputs(tgetstr("up", NULL), 1, ft_putchar); - tputs(tgetstr("up", NULL), 1, ft_putchar); tputs(tgetstr("sf", NULL), 1, ft_putchar); + return (1); } + if (nlines > 1) + mod += ft_strlen(msh->ps[0]); + tputs(tgetstr("sf", NULL), 1, ft_putchar); + tputs(tgetstr("up", NULL), 1, ft_putchar); + while (--nlines > 0) + tputs(tgetstr("up", NULL), 1, ft_putchar); while (i < ft_strlen(msh->ps[0])) { tputs(tgetstr("nd", NULL), 1, ft_putchar); @@ -154,5 +159,5 @@ int16_t if (tcaps->cpos != len) while (--len > tcaps->cpos) tputs(tgetstr("le", NULL), 1, ft_putchar); - return (i); + return (ret); } |