summaryrefslogtreecommitdiffstats
path: root/src/c_utils.c
diff options
context:
space:
mode:
authorsalad <fmoenne-@student.le-101.fr>2020-09-11 11:54:03 +0200
committersalad <fmoenne-@student.le-101.fr>2020-09-11 11:54:03 +0200
commit1692db53ad552b34db7f321e603c32ca7453b253 (patch)
treee214bc4fc9223e9287c726a32a8897940185dfbc /src/c_utils.c
parentLITERALLY C89 (diff)
download42-minishell-1692db53ad552b34db7f321e603c32ca7453b253.tar.gz
42-minishell-1692db53ad552b34db7f321e603c32ca7453b253.tar.bz2
42-minishell-1692db53ad552b34db7f321e603c32ca7453b253.tar.xz
42-minishell-1692db53ad552b34db7f321e603c32ca7453b253.tar.zst
42-minishell-1692db53ad552b34db7f321e603c32ca7453b253.zip
might finish today, ctrl + a few bugs
Diffstat (limited to 'src/c_utils.c')
-rw-r--r--src/c_utils.c40
1 files changed, 32 insertions, 8 deletions
diff --git a/src/c_utils.c b/src/c_utils.c
index 8433d40..09fda4f 100644
--- a/src/c_utils.c
+++ b/src/c_utils.c
@@ -24,15 +24,35 @@
/*
** TODO:
-** cursor on char insert
+** term(0) on exit
+** cursor on char insert DONE
** quotes
-** MAKE IT WORK ON XTERM FFS (arrows + reset term)
** leaks
-** cleanup DONE
-** prompt on beginning DONE
-** c_set_term(0) on command DONE
*/
+int16_t
+ c_init_keys(t_caps *tcaps)
+{
+ if (tcaps)
+ {
+ tcaps->KL[0] = 27;
+ tcaps->KL[1] = 91;
+ tcaps->KL[2] = 68;
+ tcaps->KL[3] = 0;
+ tcaps->KR[0] = 27;
+ tcaps->KR[1] = 91;
+ tcaps->KR[2] = 67;
+ tcaps->KR[3] = 0;
+ tcaps->CL[0] = 12;
+ tcaps->CL[1] = 0;
+ tcaps->CL[2] = 0;
+ tcaps->CL[3] = 0;
+ return (1);
+ }
+ else
+ return (-1);
+}
+
uint16_t
c_get_win_size(struct winsize *ws)
{
@@ -58,7 +78,7 @@ char
i = 0;
j = 0;
- len = ft_strlen(str) + 2;
+ len = (ft_strlen(str) + 2);
if (!(dst = (char*)malloc((len) * sizeof(char))))
return (NULL);
while (i < len)
@@ -72,8 +92,7 @@ char
j++;
}
}
- tcaps->cpos++;
- dst[len] = '\0';
+ dst[i] = '\0';
ft_memdel((void*)&str);
return (dst);
}
@@ -110,6 +129,7 @@ int16_t
t_msh *msh)
{
uint32_t i;
+ uint32_t len;
int16_t ret;
i = 0;
@@ -121,5 +141,9 @@ int16_t
i++;
}
ret = ft_printf("%s", line) + ft_strlen(msh->ps[0]);
+ len = ft_strlen(line);
+ if (cpos != len)
+ while (--len > cpos)
+ tputs(tgetstr("le", NULL), 1, ft_putchar);
return (ret);
}