summaryrefslogtreecommitdiffstats
path: root/src/c_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/c_init.c')
-rw-r--r--src/c_init.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/c_init.c b/src/c_init.c
index bbf8f22..0c77224 100644
--- a/src/c_init.c
+++ b/src/c_init.c
@@ -32,6 +32,38 @@ t_caps
return (caps);
}
+void c_process_key(t_caps *tcaps) {
+ char nread[64] = {0};
+ int bread;
+
+ while ((bread = read(STDIN_FILENO, nread, sizeof(nread)) != 1)) {
+ if (bread == -1)
+ {
+ 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)
+ {
+ tputs(tgoto(tcaps->nd, 1, 1), 1, putchar);
+ /* write(1, tcaps->nd, strlen(tcaps->nd)); */
+ }
+ else if (strncmp(nread, tcaps->cl, strlen(tcaps->cl)) == 0)
+ write(1, tcaps->cl, strlen(tcaps->cl));
+ else if (strncmp(nread, "k", 1) == 0)
+ {
+ write(1, tcaps->bc, strlen(tcaps->nd));
+ /* tputs(tgoto(tcaps->bc, 1, 1), 1, putchar); */
+ }
+ else
+ write(1, nread, 1);
+}
+
int16_t c_init_tcaps(void)
{
t_caps tcaps;
@@ -42,7 +74,8 @@ int16_t c_init_tcaps(void)
term = getenv("TERM");
if (!tgetent(bp, term))
return (-1);
- tcaps.lc = tgetstr("lc", &term);
+ tcaps.cl = tgetstr("cl", &term);
+ tcaps.ks = tgetstr("ks", &term);
tcaps.kl = tgetstr("kl", &term);
tcaps.kr = tgetstr("kr", &term);
tcaps.pc = tgetstr("pc", &term);
@@ -56,5 +89,9 @@ int16_t c_init_tcaps(void)
tcaps.tios.c_cc[VTIME] = 1;
tcsetattr(STDIN_FILENO, TCSAFLUSH, &tcaps.tios);
c_get_struct(1, &tcaps);
+ while (1)
+ {
+ c_process_key(&tcaps);
+ }
return (1);
}