tAdd keybinds to move up/down - sex - libtermbox based text editor
HTML git clone git://z3bra.org/sex
DIR Log
DIR Files
DIR Refs
DIR README
---
DIR commit 3aac5bf10075d6c48b717b843bd7d3e4a14b20fb
DIR parent 9aa344e4aa1683103da76be0df09abd9b6f461c8
HTML Author: dcat <dcat@iotek.org>
Date: Sun, 3 Apr 2016 22:57:52 +0200
Add keybinds to move up/down
Diffstat:
M sex.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
---
DIR diff --git a/sex.c b/sex.c
t@@ -154,12 +154,27 @@ edit(char *path)
switch (ev.type) {
case TB_EVENT_KEY:
/* handle keys */
- if (ev.key == TB_KEY_CTRL_C)
+ switch (ev.key) {
+ case TB_KEY_CTRL_C:
return;
- break;
- case 'j':
- cur = TAILQ_NEXT(cur, entries);
- needs_redraw = 1;
+ /* NOTREACHED */
+ case 'j':
+ case TB_KEY_ARROW_DOWN:
+ if (cur == TAILQ_LAST(&head, line_s_head))
+ break;
+
+ cur = TAILQ_NEXT(cur, entries);
+ needs_redraw = 1;
+ break;
+ case 'k':
+ case TB_KEY_ARROW_UP:
+ if (cur == TAILQ_FIRST(&head))
+ break;
+
+ cur = TAILQ_PREV(cur, line_s_head, entries);
+ needs_redraw = 1;
+ break;
+ }
break;
case TB_EVENT_RESIZE:
/* handle resizing */