summaryrefslogtreecommitdiffstats
path: root/src/c_init.c
diff options
context:
space:
mode:
authorsalad <fmoenne-@student.le-101.fr>2020-08-29 16:14:54 +0200
committersalad <fmoenne-@student.le-101.fr>2020-08-29 16:14:54 +0200
commitc9c63d523123dffa2c85a5c2f2955b20cc1d91a6 (patch)
treed975cbe206a01d5e535eee4315781a1e5b23e985 /src/c_init.c
parentHJKL LETS GOOOO (diff)
download42-minishell-c9c63d523123dffa2c85a5c2f2955b20cc1d91a6.tar.gz
42-minishell-c9c63d523123dffa2c85a5c2f2955b20cc1d91a6.tar.bz2
42-minishell-c9c63d523123dffa2c85a5c2f2955b20cc1d91a6.tar.xz
42-minishell-c9c63d523123dffa2c85a5c2f2955b20cc1d91a6.tar.zst
42-minishell-c9c63d523123dffa2c85a5c2f2955b20cc1d91a6.zip
testing for nothing
Diffstat (limited to 'src/c_init.c')
-rw-r--r--src/c_init.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/c_init.c b/src/c_init.c
index f472f47..c5fc319 100644
--- a/src/c_init.c
+++ b/src/c_init.c
@@ -39,19 +39,17 @@ void c_process_key(t_caps *tcaps) {
while ((bread = read(STDIN_FILENO, nread, sizeof(nread)) != 1)) {
if (bread == -1)
{
- printf("error on read");
+ ft_printf("error on read");
return ;
}
}
- /* printf("read : [%s] size : [%lu]\n", nread, strlen(nread)); */
- /* printf("cap : [%s] size : [%lu]\n", tcaps->kl, strlen(tcaps->kl)); */
if (*nread == 'q')
exit(0);
- else if (strncmp(nread, "l", 1) == 0)
+ else if ((strncmp(nread, "l", 1) == 0) ||
+ strncmp(nread, tcaps->kl, strlen(tcaps->kl)) == 0)
{
- /* tputs(tgoto(tcaps->nd, 1, 1), 1, putchar); */
- write(1, tcaps->nd, strlen(tcaps->nd));
+ tputs(tgoto(tcaps->nd, 1, 1), 1, putchar);
}
else if (strncmp(nread, "c", 1) == 0)
write(1, tcaps->cl, strlen(tcaps->cl));
@@ -60,12 +58,10 @@ void c_process_key(t_caps *tcaps) {
else if (strncmp(nread, "k", 1) == 0)
{
write(1, tcaps->up, strlen(tcaps->kl));
- /* tputs(tgoto(tcaps->bc, 1, 1), 1, putchar); */
}
else if (strncmp(nread, "h", 1) == 0)
{
- write(1, tcaps->le, strlen(tcaps->le));
- /* tputs(tgoto(tcaps->bc, 1, 1), 1, putchar); */
+ tputs(tgoto(tcaps->le, 1, 1), 1, putchar);
}
else
write(1, nread, 1);
@@ -84,6 +80,7 @@ int16_t c_init_tcaps(void)
tcaps.cl = tgetstr("cl", &term);
tcaps.ks = tgetstr("ks", &term);
tcaps.kl = tgetstr("kl", &term);
+ tcaps.ke = tgetstr("kr", &term);
tcaps.kr = tgetstr("kr", &term);
tcaps.pc = tgetstr("pc", &term);
tcaps.bc = tgetstr("bc", &term);
@@ -93,6 +90,8 @@ int16_t c_init_tcaps(void)
tcaps.DO = tgetstr("do", &term);
tcgetattr(STDIN_FILENO, &tcaps.tios);
+ printf("%d\n", KEY_LEFT);
+ tputs(tgoto(tcaps.ks, 1, 1), 1, putchar);
tcaps.tios.c_lflag &= ~(ECHO | ICANON);
tcaps.tios.c_cc[VMIN] = 0;
tcaps.tios.c_cc[VTIME] = 1;