eel

formatter for ii(1) logs
Log | Files | Refs | README

commit 5e1ef8dcd57898a67b8baf8bfca230a53d34cdca
parent 4dec36477580e9eb3c5da0afc9949f0917121536
Author: Josuah Demangeon <mail@josuah.net>
Date:   Wed, 20 Jun 2018 23:34:02 +0200

let UTF-8 chars pass through

Diffstat:
Mshuntty.c | 72++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------
1 file changed, 52 insertions(+), 20 deletions(-)

diff --git a/shuntty.c b/shuntty.c @@ -88,39 +88,70 @@ cmd_backspace(char *input, ssize_t *end) } void +cmd_suppr(void) +{ +} + +void cmd_addkey(char *input, ssize_t *end, ssize_t len, int k) { - if (*end < len - 1 && isprint(k)) { + if (*end < len - 1 && !iscntrl(k)) { input[(*end)++] = k; input[(*end)] = '\0'; } } +void +cmd_left(void) +{ +} + +void +cmd_right(void) +{ +} + +void +cmd_up(void) +{ +} + +void +cmd_down(void) +{ +} + +void +cmd_pgup(void) +{ +} + +void +cmd_pgdn(void) +{ +} + ssize_t key(char *input, ssize_t end, ssize_t len) { int k; - switch (k = getkey()) { -top: - case CTL('C'): - return -1; + k = getkey(); + +top: switch (k) { + case CTL('C'): return -1; case 127: - case CTL('H'): /* backspace */ - cmd_backspace(input, &end); - break; - case CSI('A'): /* up */ - case CSI('B'): /* down */ - break; - case CSI('5'): /* page up */ - case CSI('6'): /* page down */ - if (getkey() != '~') - break; - break; - case CTL('J'): /* enter */ - case CTL('M'): - cmd_enter(input, &end); - break; + case CTL('H'): cmd_backspace(input, &end); break; + case CSI('A'): cmd_up(); break; + case CSI('B'): cmd_down(); break; + case CSI('D'): cmd_left(); break; + case CSI('C'): cmd_right(); break; + case CSI('5'): if (getkey() == '~') cmd_pgdn(); break; + case CSI('6'): if (getkey() == '~') cmd_pgdn(); break; + case CSI('P'): cmd_suppr(); break; + case CTL('J'): cmd_enter(input, &end); break; + case CTL('M'): cmd_enter(input, &end); break; + case ALT('['): k = CSI(getkey()); goto top; @@ -198,6 +229,7 @@ main(int argc, char **argv) } fputc('\n', stderr); term_reset(); + printf("%d\n", CTL('H')); return 0; }