summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2022-03-16 18:57:02 +0100
committerHiltjo Posthuma <hiltjo@codemadness.org>2022-03-19 12:08:22 +0100
commitcae75cf30a64158f2120f28df0a02475fb970bcc (patch)
treedfdca5ec59b82a628a9bcbbee763b6a92fd4f012
parent0e26df03e5ab2387999492c2cc7c8cf379c0536d (diff)
sfeed_curses: refactor DEC function key parsing
First it expected a single digit number, but this way it makes it more easy and logical to add Sun function keys: ESC [ num z For archive/reference Sun function keys relevant to sfeed_curses: num = 214: home 216: page up 220: end 222: page down Noticed on OpenIndiana/Illumos.
-rw-r--r--sfeed_curses.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/sfeed_curses.c b/sfeed_curses.c
index d0ca7dd..484593b 100644
--- a/sfeed_curses.c
+++ b/sfeed_curses.c
@@ -2114,24 +2114,26 @@ main(int argc, char *argv[])
case 'D': goto keyleft; /* arrow left */
case 'F': goto endpos; /* end */
case 'H': goto startpos; /* home */
- case '1': /* home */
- case '4': /* end */
- case '5': /* page up */
- case '6': /* page down */
- case '7': /* home: urxvt */
- case '8': /* end: urxvt */
- i = ch;
- if ((ch = readch()) < 0)
- goto event;
- if (ch == '~') {
- switch (i) {
- case '1': goto startpos;
- case '4': goto endpos;
- case '5': goto prevpage;
- case '6': goto nextpage;
- case '7': goto startpos;
- case '8': goto endpos;
+ default:
+ if (!(ch >= '0' && ch <= '9'))
+ break;
+ for (i = ch - '0'; ;) {
+ if ((ch = readch()) < 0) {
+ goto event;
+ } else if (ch >= '0' && ch <= '9') {
+ i = (i * 10) + (ch - '0');
+ continue;
+ } else if (ch == '~') { /* DEC: ESC [ num ~ */
+ switch (i) {
+ case 1: goto startpos; /* home */
+ case 4: goto endpos; /* end */
+ case 5: goto prevpage; /* page up */
+ case 6: goto nextpage; /* page down */
+ case 7: goto startpos; /* home: urxvt */
+ case 8: goto endpos; /* end: urxvt */
+ }
}
+ break;
}
}
break;