Krolyxon
Commit 88f77bc

Branches

Refs →

nsxiv88f77bc

Implement fill scale mode

Author
Berke Kocaoğlu
Date
2021-04-14 20:10 +0300
Committer
Berke Kocaoğlu · 2021-09-16 22:55 +0300
Parent
1d28627
Commit
88f77bc59c26068ae1a5e1c9a8bd3b1b88dbe683

+10 −2

5 files changed

  1. M config.def.h +1 −0
  2. M image.c +3 −0
  3. M options.c +1 −1
  4. M sxiv.1 +4 −1
  5. M sxiv.h +1 −0
M config.def.h View
@@ -127,6 +127,7 @@ static const keymap_t keys[] = {
127127 { 0, XK_equal, i_set_zoom, 100 },
128128 { 0, XK_w, i_fit_to_win, SCALE_DOWN },
129129 { 0, XK_W, i_fit_to_win, SCALE_FIT },
130+ { 0, XK_F, i_fit_to_win, SCALE_FILL },
130131 { 0, XK_e, i_fit_to_win, SCALE_WIDTH },
131132 { 0, XK_E, i_fit_to_win, SCALE_HEIGHT },
132133 { 0, XK_less, i_rotate, DEGREE_270 },
M image.c View
@@ -402,6 +402,9 @@ bool img_fit(img_t *img)
402402 zh = (float) img->win->h / (float) img->h;
403403
404404 switch (img->scalemode) {
405+ case SCALE_FILL:
406+ z = MAX(zw, zh);
407+ break;
405408 case SCALE_WIDTH:
406409 z = zw;
407410 break;
M options.c View
@@ -44,7 +44,7 @@ void parse_options(int argc, char **argv)
4444 {
4545 int n, opt;
4646 char *end, *s;
47− const char *scalemodes = "dfwh";
47+ const char *scalemodes = "dfFwh";
4848
4949 progname = strrchr(argv[0], '/');
5050 progname = progname ? progname + 1 : argv[0];
M sxiv.1 View
@@ -97,7 +97,7 @@ may be a floating point number.
9797 .TP
9898 .BI "\-s " MODE
9999 Set scale mode according to MODE character. Supported modes are: [d]own,
100−[f]it, [w]idth, [h]eight.
100+[f]it, [F]ill, [w]idth, [h]eight.
101101 .TP
102102 .B \-t
103103 Start in thumbnail mode.
@@ -311,6 +311,9 @@ Set zoom level to 100%, but fit large images into window.
311311 .B W
312312 Fit image to window.
313313 .TP
314+.B F
315+Fill image to window.
316+.TP
314317 .B e
315318 Fit image to window width.
316319 .TP
M sxiv.h View
@@ -88,6 +88,7 @@ typedef enum {
8888 typedef enum {
8989 SCALE_DOWN,
9090 SCALE_FIT,
91+ SCALE_FILL,
9192 SCALE_WIDTH,
9293 SCALE_HEIGHT,
9394 SCALE_ZOOM