Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions man/feh.pre
Original file line number Diff line number Diff line change
Expand Up @@ -1402,22 +1402,38 @@ Scroll down.
Note that the scroll keys work without anti-aliasing for performance reasons,
hit the render key after scrolling to antialias the image.
.
.It Aq Alt+Left Bq scroll_left_page
.It P Bq scroll_up_or_prev_img
.
Scroll up or show previous image. Selects the previous image in thumbnail mode.
.
.It N Bq scroll_down_or_next_img
.
Scroll down or show next image. Selects the next image in thumbnail mode.
.
.It Ao Alt+Left Ac Bq scroll_left_page
.
Scroll to the left by one page
.
.It Aq Alt+Right Bq scroll_right_page
.It Ao Alt+Right Ac Bq scroll_right_page
.
Scroll to the right by one page
.
.It Aq Alt+Up Bq scroll_up_page
.It Ao Alt+Up Ac Bq scroll_up_page
.
Scroll up by one page
.
.It Aq Alt+Down Bq scroll_down_page
.It Ao Alt+Down Ac Bq scroll_down_page
.
Scroll down by one page
.
.It Ao Ctrl+P Ac Bq scroll_up_page_or_prev_img
.
Scroll up by one page or show previous image
.
.It Ao Ctrl+N Ac Bq scroll_down_page_or_next_img
.
Scroll down by one page or show next image
.
.It R, Ao keypad begin Ac Bq render
.
Antialias the image.
Expand Down
2 changes: 2 additions & 0 deletions src/help.raw
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,10 @@ KEYS
i Toggle --info display
k Toggle zoom/viewport freeze when switching images
m Show menu
N Move the image down or go to next image
n, <SPACE>, <RIGHT> Go to next image
o Toggle pointer visibility
P Move the image up or go to previous image
p, <BACKSPACE>, <LEFT> Go to previous image
q, <ESCAPE> Quit
r Reload image
Expand Down
66 changes: 66 additions & 0 deletions src/keyevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,14 @@ void init_keyevents(void) {
feh_set_kb(&keys.scroll_right,0,XK_KP_Right , 4, XK_Right , 0, 0);
feh_set_kb(&keys.scroll_down,0, XK_KP_Down , 4, XK_Down , 0, 0);
feh_set_kb(&keys.scroll_up , 0, XK_KP_Up , 4, XK_Up , 0, 0);
feh_set_kb(&keys.scroll_down_or_next_img, 0, XK_N, 0, 0 , 0, 0);
feh_set_kb(&keys.scroll_up_or_prev_img , 0, XK_P, 0, 0 , 0, 0);
feh_set_kb(&keys.scroll_left_page , 8, XK_Left , 0, 0 , 0, 0);
feh_set_kb(&keys.scroll_right_page, 8, XK_Right, 0, 0 , 0, 0);
feh_set_kb(&keys.scroll_down_page , 8, XK_Down , 0, 0 , 0, 0);
feh_set_kb(&keys.scroll_up_page , 8, XK_Up , 0, 0 , 0, 0);
feh_set_kb(&keys.scroll_down_page_or_next_img, 4, XK_N, 0, 0 , 0, 0);
feh_set_kb(&keys.scroll_up_page_or_prev_img , 4, XK_P, 0, 0 , 0, 0);
feh_set_kb(&keys.prev_img , 0, XK_Left , 0, XK_p , 0, XK_BackSpace);
feh_set_kb(&keys.next_img , 0, XK_Right , 0, XK_n , 0, XK_space);
feh_set_kb(&keys.jump_back , 0, XK_Page_Up , 0, XK_KP_Page_Up, 0, 0);
Expand Down Expand Up @@ -378,6 +382,10 @@ fehkey *feh_str_to_kb(char *action)
return &keys.scroll_up;
else if (!strcmp(action, "scroll_down"))
return &keys.scroll_down;
else if (!strcmp(action, "scroll_up_or_prev_img"))
return &keys.scroll_up_or_prev_img;
else if (!strcmp(action, "scroll_down_or_next_img"))
return &keys.scroll_down_or_next_img;
else if (!strcmp(action, "scroll_right_page"))
return &keys.scroll_right_page;
else if (!strcmp(action, "scroll_left_page"))
Expand All @@ -386,6 +394,10 @@ fehkey *feh_str_to_kb(char *action)
return &keys.scroll_up_page;
else if (!strcmp(action, "scroll_down_page"))
return &keys.scroll_down_page;
else if (!strcmp(action, "scroll_up_page_or_prev_img"))
return &keys.scroll_up_page_or_prev_img;
else if (!strcmp(action, "scroll_down_page_or_next_img"))
return &keys.scroll_down_page_or_next_img;
else if (!strcmp(action, "prev_img"))
return &keys.prev_img;
else if (!strcmp(action, "next_img"))
Expand Down Expand Up @@ -492,6 +504,48 @@ fehkey *feh_str_to_kb(char *action)
return NULL;
}

static void feh_scroll_or_next(winwidget winwid, int next, int scroll_step)
{
if (next == (scroll_step > 0)) {
/* if bottom of view */
if (winwid->h < winwid->im_h && winwid->h - (winwid->im_h * winwid->zoom) != winwid->im_y) {
winwid->im_y -= scroll_step;
if (winwid->h - (winwid->im_h * winwid->zoom) > winwid->im_y) {
winwid->im_y = winwid->h - (winwid->im_h * winwid->zoom);
}
winwidget_render_image(winwid, 0, 1);
}
else if (opt.slideshow) {
slideshow_change_image(winwid, SLIDE_NEXT, 1);
if (winwid->h < winwid->im_h && winwid->im_y != 0) {
winwid->im_y = 0;
winwidget_render_image(winwid, 0, 1);
}
}
else if (winwid->type == WIN_TYPE_THUMBNAIL)
feh_thumbnail_select_next(winwid, 1);
}
else {
/* if top of view */
if (winwid->h < winwid->im_h && winwid->im_y) {
winwid->im_y += scroll_step;
if (winwid->im_y > 0) {
winwid->im_y = 0;
}
winwidget_render_image(winwid, 0, 1);
}
else if (opt.slideshow) {
slideshow_change_image(winwid, SLIDE_PREV, 1);
if (winwid->h < winwid->im_h && winwid->im_y != winwid->h - (winwid->im_h * winwid->zoom)) {
winwid->im_y = winwid->h - (winwid->im_h * winwid->zoom);
winwidget_render_image(winwid, 0, 1);
}
}
else if (winwid->type == WIN_TYPE_THUMBNAIL)
feh_thumbnail_select_prev(winwid, 1);
}
}

void feh_event_handle_generic(winwidget winwid, unsigned int state, KeySym keysym, unsigned int button) {
int curr_screen = 0;

Expand Down Expand Up @@ -522,11 +576,17 @@ void feh_event_handle_generic(winwidget winwid, unsigned int state, KeySym keysy
winwidget_sanitise_offsets(winwid);
winwidget_render_image(winwid, 0, 1);
}
else if (feh_is_kp(&keys.scroll_down_or_next_img, state, keysym, button)) {
feh_scroll_or_next(winwid, 1, opt.scroll_step);
}
else if (feh_is_kp(&keys.scroll_up, state, keysym, button)) {
winwid->im_y += opt.scroll_step;
winwidget_sanitise_offsets(winwid);
winwidget_render_image(winwid, 0, 1);
}
else if (feh_is_kp(&keys.scroll_up_or_prev_img, state, keysym, button)) {
feh_scroll_or_next(winwid, 0, opt.scroll_step);
}
else if (feh_is_kp(&keys.scroll_right_page, state, keysym, button)) {
winwid->im_x -= winwid->w;
winwidget_sanitise_offsets(winwid);
Expand All @@ -542,11 +602,17 @@ void feh_event_handle_generic(winwidget winwid, unsigned int state, KeySym keysy
winwidget_sanitise_offsets(winwid);
winwidget_render_image(winwid, 0, 0);
}
else if (feh_is_kp(&keys.scroll_down_page_or_next_img, state, keysym, button)) {
feh_scroll_or_next(winwid, 1, winwid->h);
}
else if (feh_is_kp(&keys.scroll_up_page, state, keysym, button)) {
winwid->im_y += winwid->h;
winwidget_sanitise_offsets(winwid);
winwidget_render_image(winwid, 0, 0);
}
else if (feh_is_kp(&keys.scroll_up_page_or_prev_img, state, keysym, button)) {
feh_scroll_or_next(winwid, 0, winwid->h);
}
else if (feh_is_kp(&keys.jump_back, state, keysym, button)) {
if (opt.slideshow)
slideshow_change_image(winwid, SLIDE_JUMP_BACK, 1);
Expand Down
4 changes: 4 additions & 0 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,14 @@ struct __fehkb {
struct __fehkey next_img;
struct __fehkey scroll_up;
struct __fehkey scroll_down;
struct __fehkey scroll_up_or_prev_img;
struct __fehkey scroll_down_or_next_img;
struct __fehkey scroll_right_page;
struct __fehkey scroll_left_page;
struct __fehkey scroll_up_page;
struct __fehkey scroll_down_page;
struct __fehkey scroll_up_page_or_prev_img;
struct __fehkey scroll_down_page_or_next_img;
struct __fehkey jump_back;
struct __fehkey quit;
struct __fehkey jump_fwd;
Expand Down