Commit Graph

100 Commits (master)

Author SHA1 Message Date
NRK e1b851c488 remove legacy multi-frame loaders
this removes the legacy gif and webp loaders. moving forward
multi-frame/animated images will be loaded by imlib2 itself.

Closes: https://codeberg.org/nsxiv/nsxiv/issues/397
8 months ago
NRK 1fc28278b5 add option to update cache in a background process
the cli flag is undocumented for now, since it's experimental.

Closes: https://codeberg.org/nsxiv/nsxiv/issues/416
Closes: https://codeberg.org/nsxiv/nsxiv/pulls/425
Co-authored-by: explosion-mental <explosion0mental@gmail.com>
8 months ago
NRK 9b122c82fa add compiled features into --version output (#462)
a lot of application which allow selecting features at build time seem
to output the build config with `--version` or similar (e.g ffmpeg).

aside from giving the user information about the feature set the binary
was compiled with (in case the user didn't compile it themselves, e.g on
a binary distro) it can also (possibly) help when submitting bug
reports.

Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/462
Reviewed-by: explosion-mental <explosion-mental@noreply.codeberg.org>
11 months ago
NRK f2f4903de4 apply clang-format
minus the bogus changes

Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
1 year ago
NRK cc9b24f36b remove deprecated -T flag 1 year ago
NRK a051ad210d update copyright year 1 year ago
NRK 1f788a318b add cli flag --alpha-layer
now that we have long-opts, we don't have to worry about exhausting the
alphabet list for short-opts. so adding a cli flag to set/unset the
checker background makes sense.

ref: https://codeberg.org/nsxiv/nsxiv/issues/404
1 year ago
NRK 85fffbb277 improve error message on bad cli argument (#371)
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>
2 years ago
NRK daee34477a fix potential truncation of cli arguments (#367)
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>
2 years ago
NRK e356add07c rename: aa -> anti_alias 2 years ago
NRK 88a480c938 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
2 years ago
NRK 7e3e6008fe remove some hardcoded "nsxiv", use progname instead 2 years ago
NRK fbe186e79d don't assume positive argc
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`.
2 years ago
explosion-mental 0f0c49a630 code-style: don't indent switch cases (#358)
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>
2 years ago
NRK 216f312578 add support for long-opts (#332)
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>
2 years ago
NRK b162aee497 sort and group includes
* 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.
2 years ago
NRK 6d5a04005d code-style: cleanup includes
* 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
2 years ago
NRK 33a5d54cae Release version 30
Co-authored-by: NRK <nrk@disroot.org>
Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2 years ago
N-R-K e26c81fe9a
use win-title script for customizing window title (#213)
this removes the cli flag `-T` as well as related config.h options.

Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2 years ago
NRK 9cdeeab9b8 update copyright year 2 years ago
N-R-K c6275374b0
mark functions and vars as static (#146)
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;
}
```
3 years ago
NRK d0b5005a02 -0 sends NULL separated file-list to key-handler
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
3 years ago
N-R-K 850bc788c3
code-style: general cleanups (#137)
* 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>
3 years ago
eylles 5b3221cfa6
update copyright notice (#139) 3 years ago
NRK 915a7fd384 switch -0 to bottom in options.c 3 years ago
NRK 09d4b70349 add 0 to print_usage 3 years ago
N-R-K 63972db743
add -0 for outputting null-terminated list (#68)
* 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>
3 years ago
Berke Kocaoğlu 7cce7ea857 Rename, Update Docs and Prepare for Release (#9)
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>
3 years ago
qsmodo 156a53780c set title based on prefix and suffix (#23)
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>
3 years ago
Berke Kocaoğlu 88f77bc59c Implement fill scale mode 3 years ago
Bert Münnich 8bf1adcd9a New version scheme
VERSION string between releases is last release suffixed with '+'.
Additionally, use output of git-describe instead of VERSION string, if it is
not empty.
6 years ago
Bert Münnich 148026007c One header file for type definitions and function declarations 7 years ago
Antti Korpi ecc363ec10 Add -p flag to disable writing of cache and temporary files
Closes #285.
7 years ago
Bert Münnich ff2ce99bf7 Merge djhejna/floatdelay 8 years ago
Bert Münnich c1ba841783 Merge dwminer/framerate 8 years ago
Don Hejna 27bbaab976 Support for DELAY as a floating point number including less than 1
second while maintaining backward compatibiitiy with integer
arguments.
8 years ago
dwminer 2c566c5320 Add -A option to force framerate on animated images 8 years ago
Bert Münnich c772d3c3f3 Use -e for X window embedding 8 years ago
shuall 0b758e08f2 added support for XEMBED into other windows (ie tabbed) with -w 8 years ago
Bert Münnich d3a70a285d Revised error handling
- 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)
9 years ago
Bert Münnich e574a6d0dd Removed feature test macro definitions from source files 9 years ago
Bert Münnich 5e481912ec Revised handling of GIF animations
- New option `-a`: Play animations at startup
- Ctrl-Space toggles animation for all GIF files
- Infinite loop for all animations
10 years ago
Bert Münnich 72f1b1ca6f Removed command line option -F 10 years ago
Bert Münnich 997c8518c5 Set scale mode at startup via argument to -s option 10 years ago
Bert Münnich 43a04c4757 Revised scale mode and zoom level handling
- 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
10 years ago
Bert Münnich 03b1d7cf7a Fixed -z option argument parsing; fixes issue #127 11 years ago
Bert Münnich 6a0fa2507c Slideshow mode is back, in a simplified version 11 years ago
Bert Münnich 50f9ad14de Refactored remote changes 11 years ago
András Mohari 0353e6eea2 Add support for changing the gamma value 11 years ago
Bert Münnich 26a624a543 Added options for anti-alias & alpha layer coloring to config.def.h
Also removed now obsolete -p command line option; fixes issue #98
11 years ago