Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify scroll-step, add scroll-page-step #165

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
29 changes: 24 additions & 5 deletions man/feh.pre
Original file line number Diff line number Diff line change
Expand Up @@ -531,16 +531,35 @@ When not in fullscreen: Scale images to screen size if they are too big.
.
In tiling environments, this also causes the image to be centered in the window.
.
.It Cm --scroll-step Ar count
.It Cm --scroll-step Ar percent
.
Scroll
.Ar count
pixels whenever scroll_up, scroll_down, scroll_left or scroll_right is pressed.
.Ar Percent
of window whenever scroll_up, scroll_down, scroll_left or scroll_right is pressed.
Note that this option accepts negative numbers in case you need to inverse the
scroll direction; see
.Sx KEYS CONFIG SYNTAX
to change it permanently. You can give float number to this option. If
.Ar percent
is less than 1, then it will be iterpreted as
.Ar part
of screen. I.e. .5 and 50 are the same when provided to this option.
.br
Default: 5
.
.It Cm --scroll-page-step Ar percent
.
.Ar Percent
of window whenever scroll_page_up, scroll_page_down, scroll_page_left or
scroll_page_right is pressed.
Note that this option accepts negative numbers in case you need to inverse the
scroll direction; see
.Sx KEYS CONFIG SYNTAX
to change it permanently.
Default: 20
For details about what
.Ar percent
means and how it could be interpreted see --scroll-step.
.br
Default: 90
.
.It Cm -D , --slideshow-delay Ar float
.
Expand Down
16 changes: 8 additions & 8 deletions src/keyevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,42 +480,42 @@ void feh_event_handle_keypress(XEvent * ev)
feh_thumbnail_select_prev(winwid, 1);
}
else if (feh_is_kp(&keys.scroll_right, keysym, state)) {
winwid->im_x -= opt.scroll_step;;
winwid->im_x -= opt.scroll_step * winwid->w;
winwidget_sanitise_offsets(winwid);
winwidget_render_image(winwid, 0, 1);
}
else if (feh_is_kp(&keys.scroll_left, keysym, state)) {
winwid->im_x += opt.scroll_step;
winwid->im_x += opt.scroll_step * winwid->w;
winwidget_sanitise_offsets(winwid);
winwidget_render_image(winwid, 0, 1);
}
else if (feh_is_kp(&keys.scroll_down, keysym, state)) {
winwid->im_y -= opt.scroll_step;
winwid->im_y -= opt.scroll_step * winwid->w;
winwidget_sanitise_offsets(winwid);
winwidget_render_image(winwid, 0, 1);
}
else if (feh_is_kp(&keys.scroll_up, keysym, state)) {
winwid->im_y += opt.scroll_step;
winwid->im_y += opt.scroll_step * winwid->w;
winwidget_sanitise_offsets(winwid);
winwidget_render_image(winwid, 0, 1);
}
else if (feh_is_kp(&keys.scroll_right_page, keysym, state)) {
winwid->im_x -= winwid->w;
winwid->im_x -= opt.scroll_page_step * winwid->w;
winwidget_sanitise_offsets(winwid);
winwidget_render_image(winwid, 0, 0);
}
else if (feh_is_kp(&keys.scroll_left_page, keysym, state)) {
winwid->im_x += winwid->w;
winwid->im_x += opt.scroll_page_step * winwid->w;
winwidget_sanitise_offsets(winwid);
winwidget_render_image(winwid, 0, 0);
}
else if (feh_is_kp(&keys.scroll_down_page, keysym, state)) {
winwid->im_y -= winwid->h;
winwid->im_y -= opt.scroll_page_step * winwid->h;
winwidget_sanitise_offsets(winwid);
winwidget_render_image(winwid, 0, 0);
}
else if (feh_is_kp(&keys.scroll_up_page, keysym, state)) {
winwid->im_y += winwid->h;
winwid->im_y += opt.scroll_page_step * winwid->h;
winwidget_sanitise_offsets(winwid);
winwidget_render_image(winwid, 0, 0);
}
Expand Down
13 changes: 11 additions & 2 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ void init_parse_options(int argc, char **argv)
opt.thumb_w = 60;
opt.thumb_h = 60;
opt.thumb_redraw = 10;
opt.scroll_step = 20;
opt.scroll_step = 5;
opt.scroll_page_step = 90;
opt.menu_font = estrdup(DEFAULT_MENU_FONT);
opt.font = NULL;
opt.menu_bg = estrdup(PREFIX "/share/feh/images/menubg_default.png");
Expand Down Expand Up @@ -401,6 +402,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
{"no-fehbg" , 0, 0, 236},
{"keep-zoom-vp" , 0, 0, 237},
{"scroll-step" , 1, 0, 238},
{"scroll-page-step" , 1, 0, 239},

{0, 0, 0, 0}
};
Expand Down Expand Up @@ -735,7 +737,14 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
opt.keep_zoom_vp = 1;
break;
case 238:
opt.scroll_step = atoi(optarg);
opt.scroll_step = atof(optarg);
if (opt.scroll_step > 1)
opt.scroll_step /= 100;
break;
case 239:
opt.scroll_page_step = atof(optarg);
if (opt.scroll_page_step > 1)
opt.scroll_page_step /= 100;
break;
default:
break;
Expand Down
5 changes: 3 additions & 2 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ struct __fehoptions {
int zoom_mode;
unsigned char adjust_reload;

/* signed in case someone wants to invert scrolling real quick */
int scroll_step;
/* possible to invert scrolling */
float scroll_step;
float scroll_page_step;

unsigned int min_width, min_height, max_width, max_height;

Expand Down