commit 13d7a0cd875bf24a5fe5bf3df8aa0d7f52ab1102 parent 2d7e4573fc6b9ce6b34f97e673a469d07763ce90 Author: Hiltjo Posthuma <hiltjo@codemadness.org> Date: Thu, 24 Feb 2022 00:24:20 +0100 sfeed_curses: add keybinds for home key and home and end key in urxvt \x1b[1~ home (putty and some terminals). \x1b[7~ urxvt home. \x1b[8~ urxvt end. Refactor repeated code also. Diffstat:
M | sfeed_curses.c | | | 26 | ++++++++++++++------------ |
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/sfeed_curses.c b/sfeed_curses.c @@ -2112,23 +2112,25 @@ main(int argc, char *argv[]) case 'D': goto keyleft; /* arrow right */ case 'F': goto endpos; /* end */ case 'H': goto startpos; /* home */ + case '1': /* home */ case '4': /* end */ - if ((ch = readch()) < 0) - goto event; - if (ch == '~') - goto endpos; - continue; case '5': /* page up */ - if ((ch = readch()) < 0) - goto event; - if (ch == '~') - goto prevpage; - continue; case '6': /* page down */ + case '7': /* home: urxvt */ + case '8': /* end: urxvt */ + i = ch; if ((ch = readch()) < 0) goto event; - if (ch == '~') - goto nextpage; + 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; + } + } continue; } break;