aboutsummaryrefslogtreecommitdiffstats
path: root/options.c
AgeCommit message (Collapse)Author
2022-09-28improve error message on bad cli argument (#371)NRK
currently the error messages have the shortopt hardcoded in them, even when the user actually entered a longopt: $ ./nsxiv --framerate v nsxiv: Invalid argument for option -A: v and as far as I see, there's no way to *reliably* tell weather we're processing a longopt or a shortopt. perhaps we can do some shenanigangs with `optind` but that seems finicky at best. and it seems like other coreutils which support longopt has similar issues: $ xargs --max-procs=z xargs: invalid number "z" for -P option utils like `grep` and `head` seems to work-around it by not mentioning the flag: $ head --lines=z head: invalid number of lines: ‘z’ $ grep --max-count=l grep: invalid max count this patch does the same thing as `grep/head` and omits the flag from the error message. Closes: https://codeberg.org/nsxiv/nsxiv/issues/368 Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/371 Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2022-09-14fix potential truncation of cli arguments (#367)NRK
strtol() returns a `long`, but we're storing the result in an `int` which might end up getting truncated. change `n` to `long` and guard against >INT_MAX arguments in cases where it matters. use a float for storing argument of `-S` change `opt.slideshow` to `unsigned` similar to `img.ss.delay` Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr> Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/367 Reviewed-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr> Reviewed-by: explosion-mental <explosion-mental@noreply.codeberg.org>
2022-09-10rename: aa -> anti_aliasNRK
2022-09-10allow disabling anti-aliasing via cli flagNRK
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
2022-09-05remove some hardcoded "nsxiv", use progname insteadNRK
2022-09-05don't assume positive argcNRK
handle a rare, but possible case of argc being 0, in which case argv[0] would be null. note that both POSIX and ISO C standard allow argc to be 0 and in practice this can be triggered via calling `exec(3)` family of functions with NULL as the first `argv`.
2022-08-16code-style: don't indent switch cases (#358)explosion-mental
The suckless coding style [^0] and the linux coding style [^1] both recommends not indenting switch cases. And it helps out people with lower resolution monitors. [^0]: https://suckless.org/coding_style/ [^1]: https://www.kernel.org/doc/html/v5.10/process/coding-style.html#indentation Co-authored-by: explosion-mental <explosion0mental@gmail.com> Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/358 Reviewed-by: NRK <nrk@disroot.org> Co-authored-by: explosion-mental <explosion-mental@noreply.codeberg.org> Co-committed-by: explosion-mental <explosion-mental@noreply.codeberg.org>
2022-08-16add support for long-opts (#332)NRK
Uses [optparse] to add support for long-opts. optparse is posix compliant with getopt(3) and thus would be backwards compatible. It does not have any dependency (not even the c standard library!) and is C89 compatible and thus fits our current code-style. [optparse]: https://github.com/skeeto/optparse Note that we're using a couple `pragma`-s to silence some harmless warnings. This should be portable because these pragma-s don't change the behavior of the program. Furthermore, C standard mandates that unknown pragma's should be ignored by the compiler and thus would not result in build failure on compilers which do not recognize them. Closes: https://codeberg.org/nsxiv/nsxiv/issues/328 Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/332 Reviewed-by: eylles <eylles@noreply.codeberg.org>
2022-06-28sort and group includesNRK
* includes are sorted alphabetically * their grouping and layout is the following: - nsxiv.h will be the first include - followed by any internal headers (e.g "commands.h" "config.h") - followed by system headers (<stdlib.h> etc) - followed by third party headers (X.h libwebp etc) * also add `llvm-include-order` check to clang-tidy so that it can catch unsorted includes during CI.
2022-06-28code-style: cleanup includesNRK
* rm unused include <sys/types.h> * move <sys/time.h> to main.c, it's the only file that needs it. * move TV_* macros to main.c * let *.c files explicitly include what they need instead of including them at nsxiv.h
2022-06-15Release version 30v30NRK
Co-authored-by: NRK <nrk@disroot.org> Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2022-02-23use win-title script for customizing window title (#213)N-R-K
this removes the cli flag `-T` as well as related config.h options. Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2022-02-13update copyright yearNRK
2021-11-20mark functions and vars as static (#146)N-R-K
the goal here to mark functions and variables not used outside the translation unit as static. main reason for this is cleanliness. however as a side-effect this can help compilers optimize better as it now has guarantee that a certain function won't be called outside of that translation unit. one other side-effect of this is that accessing these vars/function from config.h is now different. if one wants to access a static var/func from different translation unit in config.h, he would have to create a wrapper function under the right ifdef. for static functions one would also need to forward declare it. here's a dummy example of accessing the function `run_key_handler` from config.h under _MAPPINGS_CONFIG ``` static void run_key_handler(const char *, unsigned); bool send_with_ctrl(arg_t key) { run_key_handler(XKeysymToString(key), ControlMask); return false; } ```
2021-10-30-0 sends NULL separated file-list to key-handlerNRK
with this change `-0` is turned into a more generic switch which can be used to send NULL-separated file-list to the key-handler as well. this also means `-0` no longer implicitly enables `-o` Closes: https://github.com/nsxiv/nsxiv/issues/140
2021-10-28code-style: general cleanups (#137)N-R-K
* tns_clean_cache: remove unused function arg * remove malloc casting * improve consistency use sizeof(T) at the end * avoid comparing integers of different signedness * use Window type for embed and parent * remove unnecessary comparisons * remove cpp style comments * improve consistency: remove comma from the end of enumerator list * Removed useless _IMAGE_CONFIG defines * consistency: use the same order as snprintf * Resolve c89 warnings Co-authored-by: uidops <uidops@protonmail.com> Co-authored-by: Arthur Williams <taaparthur@gmail.com>
2021-10-28update copyright notice (#139)eylles
2021-09-21switch -0 to bottom in options.cNRK
2021-09-21add 0 to print_usageNRK
2021-09-21add -0 for outputting null-terminated list (#68)N-R-K
* add -0 for outputting null-terminated list this doesn't add much, if any, additional complexity to the codebase and can be quite handy for scripting purposes. Closes: https://github.com/nsxiv/nsxiv/issues/67 * Fix typo Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2021-09-16Rename, Update Docs and Prepare for Release (#9)Berke Kocaoğlu
Co-authored-by: Guilherme Rugai Freire <41879254+GRFreire@users.noreply.github.com> Co-authored-by: N-R-K <79544946+N-R-K@users.noreply.github.com> Co-authored-by: NRK <nrk@disroot.org> Co-authored-by: Arthur Williams <taaparthur@gmail.com> Co-authored-by: eylles <ed.ylles1997@gmail.com>
2021-09-16set title based on prefix and suffix (#23)qsmodo
Co-authored-by: Guilherme Rugai Freire <41879254+GRFreire@users.noreply.github.com> Co-authored-by: NRK <nrk@disroot.org> Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2021-09-16Implement fill scale modeBerke Kocaoğlu
2018-06-09New version schemeBert Münnich
VERSION string between releases is last release suffixed with '+'. Additionally, use output of git-describe instead of VERSION string, if it is not empty.
2017-10-16One header file for type definitions and function declarationsBert Münnich
2017-09-08Add -p flag to disable writing of cache and temporary filesAntti Korpi
Closes #285.
2016-12-01Merge djhejna/floatdelayBert Münnich
2016-11-28Merge dwminer/framerateBert Münnich
2016-11-28Support for DELAY as a floating point number including less than 1Don Hejna
second while maintaining backward compatibiitiy with integer arguments.
2016-11-27Add -A option to force framerate on animated imagesdwminer
2016-10-30Use -e for X window embeddingBert Münnich
2016-10-29added support for XEMBED into other windows (ie tabbed) with -wshuall
2015-10-28Revised error handlingBert Münnich
- Functions warn() and die() replaced by GNU-like error(3) function - Register cleanup() with atexit(3) - Functions called by cleanup() are marked with CLEANUP and are not allowed to call exit(3)
2015-10-28Removed feature test macro definitions from source filesBert Münnich
2014-07-25Revised handling of GIF animationsBert Münnich
- New option `-a`: Play animations at startup - Ctrl-Space toggles animation for all GIF files - Infinite loop for all animations
2014-02-05Removed command line option -FBert Münnich
2014-02-04Set scale mode at startup via argument to -s optionBert Münnich
2014-02-04Revised scale mode and zoom level handlingBert Münnich
- Scale mode is not reset to default value upon image loading anymore - New default key binding to change mode to scale-down - Removed scale mode setting from config.h - Removed -d command line option, as this is now the default at startup
2014-01-15Fixed -z option argument parsing; fixes issue #127Bert Münnich
2014-01-04Slideshow mode is back, in a simplified versionBert Münnich
2013-11-14Refactored remote changesBert Münnich
2013-11-13Add support for changing the gamma valueAndrás Mohari
2013-08-22Added options for anti-alias & alpha layer coloring to config.def.hBert Münnich
Also removed now obsolete -p command line option; fixes issue #98
2013-03-19New options: -[io], read/write files from/to stdin/outBert Münnich
Fixes issue #84
2013-02-08Refactored function definitions to use dangling braceBert Münnich
2013-02-08Updated/corrected license headerBert Münnich
2012-10-29New option: -N, set X window resource nameBert Münnich
2012-02-16Added option -b: disable barBert Münnich
2012-02-15Already in the year 2012Bert Münnich
2012-02-11Removed exif support; made gif support non-optionalBert Münnich