summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBerke Kocaoğlu <berkekocaoglu360@gmail.com>2021-04-14 19:10:14 +0200
committerBerke Kocaoğlu <berke.kocaoglu@metu.edu.tr>2021-09-16 21:55:31 +0200
commit88f77bc59c26068ae1a5e1c9a8bd3b1b88dbe683 (patch)
treed66afc56af1d2829916555fa0308f3acf90eb4c2
parent1d28627868f5133a25a0197af21a187799ffa98e (diff)
downloadnsxiv-88f77bc59c26068ae1a5e1c9a8bd3b1b88dbe683.tar.zst
Implement fill scale mode
-rw-r--r--config.def.h1
-rw-r--r--image.c3
-rw-r--r--options.c2
-rw-r--r--sxiv.15
-rw-r--r--sxiv.h1
5 files changed, 10 insertions, 2 deletions
diff --git a/config.def.h b/config.def.h
index 9981ca3..9e30640 100644
--- a/config.def.h
+++ b/config.def.h
@@ -127,6 +127,7 @@ static const keymap_t keys[] = {
{ 0, XK_equal, i_set_zoom, 100 },
{ 0, XK_w, i_fit_to_win, SCALE_DOWN },
{ 0, XK_W, i_fit_to_win, SCALE_FIT },
+ { 0, XK_F, i_fit_to_win, SCALE_FILL },
{ 0, XK_e, i_fit_to_win, SCALE_WIDTH },
{ 0, XK_E, i_fit_to_win, SCALE_HEIGHT },
{ 0, XK_less, i_rotate, DEGREE_270 },
diff --git a/image.c b/image.c
index 9a9c531..fa10ab9 100644
--- a/image.c
+++ b/image.c
@@ -402,6 +402,9 @@ bool img_fit(img_t *img)
zh = (float) img->win->h / (float) img->h;
switch (img->scalemode) {
+ case SCALE_FILL:
+ z = MAX(zw, zh);
+ break;
case SCALE_WIDTH:
z = zw;
break;
diff --git a/options.c b/options.c
index de02407..394220f 100644
--- a/options.c
+++ b/options.c
@@ -44,7 +44,7 @@ void parse_options(int argc, char **argv)
{
int n, opt;
char *end, *s;
- const char *scalemodes = "dfwh";
+ const char *scalemodes = "dfFwh";
progname = strrchr(argv[0], '/');
progname = progname ? progname + 1 : argv[0];
diff --git a/sxiv.1 b/sxiv.1
index eff3d66..ff6f76f 100644
--- a/sxiv.1
+++ b/sxiv.1
@@ -97,7 +97,7 @@ may be a floating point number.
.TP
.BI "\-s " MODE
Set scale mode according to MODE character. Supported modes are: [d]own,
-[f]it, [w]idth, [h]eight.
+[f]it, [F]ill, [w]idth, [h]eight.
.TP
.B \-t
Start in thumbnail mode.
@@ -311,6 +311,9 @@ Set zoom level to 100%, but fit large images into window.
.B W
Fit image to window.
.TP
+.B F
+Fill image to window.
+.TP
.B e
Fit image to window width.
.TP
diff --git a/sxiv.h b/sxiv.h
index 707eba7..d80f7e5 100644
--- a/sxiv.h
+++ b/sxiv.h
@@ -88,6 +88,7 @@ typedef enum {
typedef enum {
SCALE_DOWN,
SCALE_FIT,
+ SCALE_FILL,
SCALE_WIDTH,
SCALE_HEIGHT,
SCALE_ZOOM