sex

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

commit 0be9b43d16db039c11d2b28652a064039b192675
parent 1c558c8e5d2f22d1afec3650f434ec266779753c
Author: z3bra <willyatmailoodotorg>
Date:   Wed Apr  6 08:27:23 2016

Allow scrolling with hjkl

Diffstat:
 sex.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sex.c b/sex.c @@ -66,6 +66,7 @@ init_termbox(void) if (r) err(1, "tb_init()"); } + void open_file(char *path) { @@ -183,7 +184,6 @@ ui_init(struct ui_s *ui) void scroll(struct ui_s *window, direction dir) { - switch (dir) { case UP: if (window->pos.y == 0) { @@ -238,25 +238,29 @@ ui_edit(char *path) switch (ev.type) { case TB_EVENT_KEY: /* handle keys */ - switch (ev.key) { + switch (ev.key | ev.ch) { case TB_KEY_CTRL_C: return; /* NOTREACHED */ case TB_KEY_CTRL_L: needs_redraw = 1; break; + case 'k': case TB_KEY_ARROW_UP: scroll(&window, UP); needs_redraw = 1; break; + case 'j': case TB_KEY_ARROW_DOWN: scroll(&window, DOWN); needs_redraw = 1; break; + case 'l': case TB_KEY_ARROW_RIGHT: scroll(&window, RIGHT); needs_redraw = 1; break; + case 'h': case TB_KEY_ARROW_LEFT: scroll(&window, LEFT); needs_redraw = 1;