summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSalad <water_appreciator@protonmail.com>2020-09-23 18:02:50 +0200
committerSalad <water_appreciator@protonmail.com>2020-09-23 18:02:50 +0200
commit5666e9b6ab9d47a1c1a7f55e164044543bfe713d (patch)
treececfb41ff598648219cb3ed43fc17807f2e2c66f /src
parentnorme this motherrfucker (diff)
download42-minishell-5666e9b6ab9d47a1c1a7f55e164044543bfe713d.tar.gz
42-minishell-5666e9b6ab9d47a1c1a7f55e164044543bfe713d.tar.bz2
42-minishell-5666e9b6ab9d47a1c1a7f55e164044543bfe713d.tar.xz
42-minishell-5666e9b6ab9d47a1c1a7f55e164044543bfe713d.tar.zst
42-minishell-5666e9b6ab9d47a1c1a7f55e164044543bfe713d.zip
home improvement
Diffstat (limited to 'src')
-rw-r--r--src/c_keys.c19
-rw-r--r--src/c_utils.c2
2 files changed, 16 insertions, 5 deletions
diff --git a/src/c_keys.c b/src/c_keys.c
index 6496525..47d9c93 100644
--- a/src/c_keys.c
+++ b/src/c_keys.c
@@ -31,13 +31,24 @@ int16_t
int16_t
c_home_key(t_caps *tcaps)
{
- uint16_t i;
+ int16_t i;
+ int16_t j;
i = tcaps->cpos;
- while (i > 0)
+ j = (tcaps->lpos - 1);
+ if (tcaps->cpos > 0 && j > 0)
{
- tputs(tgetstr("le", NULL), 1, ft_putchar);
- i--;
+ i = 0;
+ while (--j >= 0)
+ tputs(tgetstr("up", NULL), 1, ft_putchar);
+ tputs(tgetstr("cr", NULL), 1, ft_putchar);
+ while ((uint32_t)++i <= 13)
+ tputs(tgetstr("nd", NULL), 1, ft_putchar);
+ }
+ else
+ {
+ while (--i >= 0)
+ tputs(tgetstr("le", NULL), 1, ft_putchar);
}
tcaps->cpos = 0;
return (1);
diff --git a/src/c_utils.c b/src/c_utils.c
index 16ed4f0..de71ef3 100644
--- a/src/c_utils.c
+++ b/src/c_utils.c
@@ -157,7 +157,7 @@ int16_t
}
nlines = c_get_line_num(line, tcaps->cpos, ft_strlen(msh->ps[0]), tcaps);
ret = ft_printf("%s", line);
- i = 0;
+ i = (nlines == (tcaps->lpos)) ? 0 : tcaps->ws.ws_col * (tcaps->lpos - 1);
if (tcaps->cpos != len)
{
if (nlines != tcaps->lpos)