sfeed

Simple RSS and Atom feed parser
git clone https://git.sinitax.com/codemadness/sfeed
Log | Files | Refs | README | LICENSE | Upstream | sfeed.txt

commit cae75cf30a64158f2120f28df0a02475fb970bcc
parent 0e26df03e5ab2387999492c2cc7c8cf379c0536d
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Wed, 16 Mar 2022 18:57:02 +0100

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.

Diffstat:
Msfeed_curses.c | 36+++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)

diff --git 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;