allow disabling anti-aliasing via cli flag
simply running nsxiv with `--anti-alias` will enable anti-aliasing, and running it with `--anti-alias=no` will disable it. the cli flag will overwrite the config.h default. Closes: https://codeberg.org/nsxiv/nsxiv/issues/349
This commit is contained in:
parent
7e3e6008fe
commit
88a480c938
13
config.def.h
13
config.def.h
|
@ -42,11 +42,6 @@ static const int GAMMA_RANGE = 32;
|
||||||
/* command i_scroll pans image 1/PAN_FRACTION of screen width/height */
|
/* command i_scroll pans image 1/PAN_FRACTION of screen width/height */
|
||||||
static const int PAN_FRACTION = 5;
|
static const int PAN_FRACTION = 5;
|
||||||
|
|
||||||
/* if false, pixelate images at zoom level != 100%,
|
|
||||||
* toggled with 'a' key binding
|
|
||||||
*/
|
|
||||||
static const bool ANTI_ALIAS = true;
|
|
||||||
|
|
||||||
/* if true, use a checkerboard background for alpha layer,
|
/* if true, use a checkerboard background for alpha layer,
|
||||||
* toggled with 'A' key binding
|
* toggled with 'A' key binding
|
||||||
*/
|
*/
|
||||||
|
@ -64,6 +59,14 @@ static const int CACHE_SIZE_MEM_PERCENTAGE = 3; /* use 3% of total memo
|
||||||
static const int CACHE_SIZE_LIMIT = 256 * 1024 * 1024; /* but not above 256MiB */
|
static const int CACHE_SIZE_LIMIT = 256 * 1024 * 1024; /* but not above 256MiB */
|
||||||
static const int CACHE_SIZE_FALLBACK = 32 * 1024 * 1024; /* fallback to 32MiB if we can't determine total memory */
|
static const int CACHE_SIZE_FALLBACK = 32 * 1024 * 1024; /* fallback to 32MiB if we can't determine total memory */
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#ifdef INCLUDE_OPTIONS_CONFIG
|
||||||
|
|
||||||
|
/* if false, pixelate images at zoom level != 100%,
|
||||||
|
* toggled with 'a' key binding (overwritten via `--anti-alias` option)
|
||||||
|
*/
|
||||||
|
static const bool ANTI_ALIAS = true;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef INCLUDE_THUMBS_CONFIG
|
#ifdef INCLUDE_THUMBS_CONFIG
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,11 @@ Set zoom level to ZOOM percent.
|
||||||
.B "\-0, \-\-null"
|
.B "\-0, \-\-null"
|
||||||
Use NULL-separator. With this option, output of \-o and file-list sent to the
|
Use NULL-separator. With this option, output of \-o and file-list sent to the
|
||||||
key-handler and the input of \-i will be separated by a NULL character.
|
key-handler and the input of \-i will be separated by a NULL character.
|
||||||
|
.TP
|
||||||
|
.BI "\-\-anti\-alias" [=no]
|
||||||
|
Enables anti-aliasing, when given
|
||||||
|
.I no
|
||||||
|
as an argument, disables it instead.
|
||||||
.SH KEYBOARD COMMANDS
|
.SH KEYBOARD COMMANDS
|
||||||
.SS General
|
.SS General
|
||||||
The following keyboard commands are available in both image and thumbnail modes:
|
The following keyboard commands are available in both image and thumbnail modes:
|
||||||
|
|
2
image.c
2
image.c
|
@ -80,7 +80,7 @@ void img_init(img_t *img, win_t *win)
|
||||||
img->zoom = MIN(img->zoom, ZOOM_MAX);
|
img->zoom = MIN(img->zoom, ZOOM_MAX);
|
||||||
img->checkpan = false;
|
img->checkpan = false;
|
||||||
img->dirty = false;
|
img->dirty = false;
|
||||||
img->aa = ANTI_ALIAS;
|
img->aa = options->aa;
|
||||||
img->alpha = ALPHA_LAYER;
|
img->alpha = ALPHA_LAYER;
|
||||||
img->multi.cap = img->multi.cnt = 0;
|
img->multi.cap = img->multi.cnt = 0;
|
||||||
img->multi.animate = options->animate;
|
img->multi.animate = options->animate;
|
||||||
|
|
1
nsxiv.h
1
nsxiv.h
|
@ -237,6 +237,7 @@ struct opt {
|
||||||
scalemode_t scalemode;
|
scalemode_t scalemode;
|
||||||
float zoom;
|
float zoom;
|
||||||
bool animate;
|
bool animate;
|
||||||
|
bool aa;
|
||||||
int gamma;
|
int gamma;
|
||||||
int slideshow;
|
int slideshow;
|
||||||
int framerate;
|
int framerate;
|
||||||
|
|
13
options.c
13
options.c
|
@ -19,8 +19,11 @@
|
||||||
|
|
||||||
#include "nsxiv.h"
|
#include "nsxiv.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#define INCLUDE_OPTIONS_CONFIG
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -63,6 +66,9 @@ static void print_version(void)
|
||||||
|
|
||||||
void parse_options(int argc, char **argv)
|
void parse_options(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
enum { /* ensure these can't be represented in a single byte */
|
||||||
|
OPT_AA = UCHAR_MAX + 1
|
||||||
|
};
|
||||||
static const struct optparse_long longopts[] = {
|
static const struct optparse_long longopts[] = {
|
||||||
{ "framerate", 'A', OPTPARSE_REQUIRED },
|
{ "framerate", 'A', OPTPARSE_REQUIRED },
|
||||||
{ "animate", 'a', OPTPARSE_NONE },
|
{ "animate", 'a', OPTPARSE_NONE },
|
||||||
|
@ -88,6 +94,7 @@ void parse_options(int argc, char **argv)
|
||||||
{ "zoom-100", 'Z', OPTPARSE_NONE },
|
{ "zoom-100", 'Z', OPTPARSE_NONE },
|
||||||
{ "zoom", 'z', OPTPARSE_REQUIRED },
|
{ "zoom", 'z', OPTPARSE_REQUIRED },
|
||||||
{ "null", '0', OPTPARSE_NONE },
|
{ "null", '0', OPTPARSE_NONE },
|
||||||
|
{ "anti-alias", OPT_AA, OPTPARSE_OPTIONAL },
|
||||||
{ 0 }, /* end */
|
{ 0 }, /* end */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -106,6 +113,7 @@ void parse_options(int argc, char **argv)
|
||||||
|
|
||||||
_options.scalemode = SCALE_DOWN;
|
_options.scalemode = SCALE_DOWN;
|
||||||
_options.zoom = 1.0;
|
_options.zoom = 1.0;
|
||||||
|
_options.aa = ANTI_ALIAS;
|
||||||
_options.animate = false;
|
_options.animate = false;
|
||||||
_options.gamma = 0;
|
_options.gamma = 0;
|
||||||
_options.slideshow = 0;
|
_options.slideshow = 0;
|
||||||
|
@ -233,6 +241,11 @@ void parse_options(int argc, char **argv)
|
||||||
case '0':
|
case '0':
|
||||||
_options.using_null = true;
|
_options.using_null = true;
|
||||||
break;
|
break;
|
||||||
|
case OPT_AA:
|
||||||
|
if (op.optarg != NULL && !STREQ(op.optarg, "no"))
|
||||||
|
error(EXIT_FAILURE, 0, "Invalid argument for option --anti-alias: %s", op.optarg);
|
||||||
|
_options.aa = op.optarg == NULL;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue