summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/c_init.c17
-rw-r--r--src/c_init.h1
2 files changed, 9 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;
diff --git a/src/c_init.h b/src/c_init.h
index 1fe1b80..c85f6b7 100644
--- a/src/c_init.h
+++ b/src/c_init.h
@@ -20,6 +20,7 @@ typedef struct s_caps {
char *cm_str; /*cursor mobility*/
char *nl; /*newline, returned by tgoto()*/
char *ks; /*indicate that keys transmit from now on*/
+ char *ke; /*indicate that keys transmit from now on*/
char *kl; /*Key Left Key Right*/
char *kr;
char *pc; /*padding char --> do not touch (default 0)*/