sex

simple editor extended using libtermbox
git clone git://z3bra.org/sex
Log | Files | Refs | README

commit 3aac5bf10075d6c48b717b843bd7d3e4a14b20fb
parent 9aa344e4aa1683103da76be0df09abd9b6f461c8
Author: dcat <dcat@iotek.org>
Date:   Sun Apr  3 22:57:52 2016

Add keybinds to move up/down

Diffstat:
 sex.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/sex.c b/sex.c @@ -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 */