beh

X11 image viewer
git clone https://git.porkepik.fr/beh
Log | Files | Refs | README | LICENSE

commit 5bb27b95c4671d2ffd2e5ea8bf97960f57e2bf8f
parent bcf569b32c90042b40c2fcf0708ca2bef755be75
Author: Thomas Philippe <dev@porkepik.fr>
Date:   Fri, 26 Jun 2020 22:07:09 +0200

add go to page

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

diff --git a/beh.c b/beh.c @@ -1,9 +1,6 @@ /* - Not finished. Much refactoring needed. Get out of here while you can. - TODO - handle archives - - go to page - set window title - display filename, res, file size */ @@ -266,7 +263,9 @@ event_loop() XConfigureEvent xce; int tmp_x, tmp_y, left_mouse_hold, hold_x, hold_y; int imgid, status; + char gotobuf[10]; + memset(gotobuf, 0, 10); left_mouse_hold = imgid = 0; while (1) { @@ -288,9 +287,25 @@ event_loop() case KeyPress: keysym = XkbKeycodeToKeysym(dpy, ev.xkey.keycode, 0, ev.xkey.state & ShiftMask ? 1 : 0); - if (keysym == XK_q || keysym == XK_Escape) + if (keysym == XK_q || keysym == XK_Escape) { goto quit; - else if (keysym == XK_m) { + } else if (keysym >= XK_0 && keysym <= XK_9) { + if (gotobuf[9] == '\0') { + char tmp[2]; + printf("%lu\n", keysym - 48); + strcat(gotobuf, tmp); + } + } else if (keysym == XK_g) { + int newid = atoi(gotobuf) - 1; + memset(gotobuf, 0, 10); + if (newid < 0 || newid > nimgs - 1) + break; + free_img(); + if (init_img(filepaths[newid]) != 0) + init_img(filepaths[imgid]); + imgid = newid; + set_zoom(NO_ZOOM); + } else if (keysym == XK_m) { set_zoom(MAX); } else if (keysym == XK_l) { set_zoom(FILL);