From 7cce7ea857321c854fc9e061edee3a32f4831d18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Berke=20Kocao=C4=9Flu?= Date: Thu, 16 Sep 2021 12:32:59 +0300 Subject: 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 Co-authored-by: Arthur Williams Co-authored-by: eylles --- .gitignore | 2 +- CHANGELOG.md | 182 +++++++++++++++++++ CONTRIBUTING.md | 23 +++ Makefile | 40 ++--- README.md | 229 ++++++------------------ TODO | 5 - TODO.md | 8 + autoreload_inotify.c | 10 +- autoreload_nop.c | 10 +- commands.c | 10 +- config.def.h | 2 +- exec/image-info | 6 +- exec/key-handler | 6 +- icon/128x128.png | Bin 542 -> 1066 bytes icon/16x16.png | Bin 178 -> 262 bytes icon/32x32.png | Bin 221 -> 421 bytes icon/48x48.png | Bin 282 -> 507 bytes icon/64x64.png | Bin 319 -> 620 bytes icon/Makefile | 4 +- image.c | 10 +- main.c | 17 +- nsxiv.1 | 487 +++++++++++++++++++++++++++++++++++++++++++++++++++ nsxiv.desktop | 8 + nsxiv.h | 460 ++++++++++++++++++++++++++++++++++++++++++++++++ options.c | 14 +- sxiv.1 | 472 ------------------------------------------------- sxiv.desktop | 8 - sxiv.h | 460 ------------------------------------------------ thumbs.c | 17 +- util.c | 10 +- window.c | 18 +- 31 files changed, 1308 insertions(+), 1210 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 CONTRIBUTING.md delete mode 100644 TODO create mode 100644 TODO.md create mode 100644 nsxiv.1 create mode 100644 nsxiv.desktop create mode 100644 nsxiv.h delete mode 100644 sxiv.1 delete mode 100644 sxiv.desktop delete mode 100644 sxiv.h diff --git a/.gitignore b/.gitignore index 17c4f3c..d2d77f1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ config.h version.h *.d *.o -sxiv +nsxiv config.mk diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..a9c2498 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,182 @@ +nsxiv +----- + +**Stable releases** + +**[v27](https://github.com/nsxiv/nsxiv/archive/v27.tar.gz)** +*(September 14, 2021)* + +Changes: + * Re-release under the name nsxiv + * Sxiv.foreground and Sxiv.background changed to Nsxiv.window.foreground and Nsxiv.window.background + * Rework the build system (#19). Now by default we'll build with only optional dependencies that are already installed +Added: + * Fill scale mode (#2) + * Configurable X window title (via `config.h` and the `-T` flag) (#23) + * Support custom bar colors via Xresources (#19) + * Toggle animation playback with Ctrl-a (#33) + * Set `_NET_WM_PID` and `WM_CLIENT_MACHINE` X properties (#13) + * Set ICCCM WM manager hints (#12) +Fixes: + * Cli flag `-G` not initially setting gamma (#31) + * Wrong keybinding description in the manpage (#14) + * .desktop entry not advertising webp support (#15) + * Prevent crash when embedded into transparent window (#3) + * Rare crash when showing some GIFs (#41) + * Rare event when nsxiv wouldn't close after window being destroyed (#53) + + +sxiv +---- + +**Stable releases** + +**[v26](https://github.com/nsxiv/nsxiv/archive/v26.tar.gz)** +*(January 16, 2020)* + + * Maintenance release + +**[v25](https://github.com/nsxiv/nsxiv/archive/v25.tar.gz)** +*(January 26, 2019)* + + * Support font fallback for missing glyphs + * Fix busy loop when built without inotify + * Use background/foreground colors from X resource database + +**[v24](https://github.com/nsxiv/nsxiv/archive/v24.tar.gz)** +*(October 27, 2017)* + + * Automatically reload the current image whenever it changes + * Support embedding into other X windows with -e (e.g. tabbed) + * New option -p prevents sxiv from creating cache and temporary files + * Simpler mouse mappings, the most basic features are accessible with the + mouse only (navigate, zoom, pan) + +**[v1.3.2](https://github.com/nsxiv/nsxiv/archive/v1.3.2.tar.gz)** +*(December 20, 2015)* + + * external key handler gets file paths on stdin, not as arguments + * Cache out-of-view thumbnails in the background + * Apply gamma correction to thumbnails + +**[v1.3.1](https://github.com/nsxiv/nsxiv/archive/v1.3.1.tar.gz)** +*(November 16, 2014)* + + * Fixed build error, caused by delayed config.h creation + * Fixed segfault when run with -c + +**[v1.3](https://github.com/nsxiv/nsxiv/archive/v1.3.tar.gz)** +*(October 24, 2014)* + + * Extract thumbnails from EXIF tags (requires libexif) + * Zoomable thumbnails, supported sizes defined in config.h + * Fixed build error with giflib version >= 5.1.0 + +**[v1.2](https://github.com/nsxiv/nsxiv/archive/v1.2.tar.gz)** +*(April 24, 2014)* + + * Added external key handler, called on keys prefixed with `Ctrl-x` + * New keybinding `{`/`}` to change gamma (by András Mohari) + * Support for slideshows, enabled with `-S` option & toggled with `s` + * Added application icon (created by 0ion9) + * Checkerboard background for alpha layer + * Option `-o` only prints files marked with `m` key + * Fixed rotation/flipping of multi-frame images (gifs) + +**[v1.1.1](https://github.com/nsxiv/nsxiv/archive/v1.1.1.tar.gz)** +*(June 2, 2013)* + + * Various bug fixes + +**[v1.1](https://github.com/nsxiv/nsxiv/archive/v1.1.tar.gz)** +*(March 30, 2013)* + + * Added status bar on bottom of window with customizable content + * New keyboard shortcuts `\`/`|`: flip image vertically/horizontally + * New keyboard shortcut `Ctrl-6`: go to last/alternate image + * Added own EXIF orientation handling, removed dependency on libexif + * Fixed various bugs + +**[v1.0](https://github.com/nsxiv/nsxiv/archive/v1.0.tar.gz)** +*(October 31, 2011)* + + * Support for multi-frame images & GIF animations + * POSIX compliant (IEEE Std 1003.1-2001) + +**[v0.9](https://github.com/nsxiv/nsxiv/archive/v0.9.tar.gz)** +*(August 17, 2011)* + + * Made key and mouse mappings fully configurable in config.h + * Complete code refactoring + +**[v0.8.2](https://github.com/nsxiv/nsxiv/archive/v0.8.2.tar.gz)** +*(June 29, 2011)* + + * POSIX-compliant Makefile; compiles under NetBSD + +**[v0.8.1](https://github.com/nsxiv/nsxiv/archive/v0.8.1.tar.gz)** +*(May 8, 2011)* + + * Fixed fullscreen under window managers, which are not fully EWMH-compliant + +**[v0.8](https://github.com/nsxiv/nsxiv/archive/v0.8.tar.gz)** +*(April 18, 2011)* + + * Support for thumbnail caching + * Ability to run external commands (e.g. jpegtran, convert) on current image + +**[v0.7](https://github.com/nsxiv/nsxiv/archive/v0.7.tar.gz)** +*(February 26, 2011)* + + * Sort directory entries when using `-r` command line option + * Hide cursor in image mode + * Full functional thumbnail mode, use Return key to switch between image and + thumbnail mode + +**[v0.6](https://github.com/nsxiv/nsxiv/archive/v0.6.tar.gz)** +*(February 16, 2011)* + + * Bug fix: Correctly display filenames with umlauts in window title + * Basic support of thumbnails + +**[v0.5](https://github.com/nsxiv/nsxiv/archive/v0.5.tar.gz)** +*(February 6, 2011)* + + * New command line option: `-r`: open all images in given directories + * New key shortcuts: `w`: resize image to fit into window; `W`: resize window + to fit to image + +**[v0.4](https://github.com/nsxiv/nsxiv/archive/v0.4.tar.gz)** +*(February 1, 2011)* + + * New command line option: `-F`, `-g`: use fixed window dimensions and apply + a given window geometry + * New key shortcut: `r`: reload current image + +**[v0.3.1](https://github.com/nsxiv/nsxiv/archive/v0.3.1.tar.gz)** +*(January 30, 2011)* + + * Bug fix: Do not set setuid bit on executable when using `make install` + * Pan image with mouse while pressing middle mouse button + +**[v0.3](https://github.com/nsxiv/nsxiv/archive/v0.3.tar.gz)** +*(January 29, 2011)* + + * New command line options: `-d`, `-f`, `-p`, `-s`, `-v`, `-w`, `-Z`, `-z` + * More mouse mappings: Go to next/previous image with left/right click, + scroll image with mouse wheel (horizontally if Shift key is pressed), + zoom image with mouse wheel if Ctrl key is pressed + +**[v0.2](https://github.com/nsxiv/nsxiv/archive/v0.2.tar.gz)** +*(January 23, 2011)* + + * Bug fix: Handle window resizes correctly + * New keyboard shortcuts: `g`/`G`: go to first/last image; `[`/`]`: go 10 + images back/forward + * Support for mouse wheel zooming (by Dave Reisner) + * Added fullscreen mode + +**[v0.1](https://github.com/nsxiv/nsxiv/archive/v0.1.tar.gz)** +*(January 21, 2011)* + + * Initial release diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..2f5c295 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,23 @@ +Contribution Guideline +---------------------- + +The scope and aim of nsxiv are: + + * Bug fixes and maintenance + * Prioritize extensibility and simplicity + * Do not make the codebase more complex, keep it simple to hack on + * Do not add extra dependency (if we do, add compile time switch to disable it) + * New features may be added if it cannot be achieved (easily) via a shell script, + doesn't break backwards compatibility and doesn't violate any of the above rules. + +When contributing, make sure: + + * Your contribution falls under nsxiv's scope and aim + * You follow the existing code style (see [.editorconfig](.editorconfig)) + * You open the pull request from a new branch, not from master + +If your contribution is not suitable for general use, it will not be included in nsxiv. +For changes that are very much up to preference, such as changing values in config.h, +please do not open a pull request unless you have an objective explanation. + +See [TODO.md](TODO.md) or the [open issues](https://github.com/nsxiv/nsxiv/issues) to find something to work on. diff --git a/Makefile b/Makefile index 23ed7b8..9b1927c 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,8 @@ ifneq (clean,$(filter clean,$(MAKECMDGOALS))) -include config.mk endif -# sxiv version -VERSION = 26 +# nsxiv version +VERSION = 27 # PREFIX for install PREFIX ?= /usr/local @@ -40,9 +40,9 @@ OBJS = autoreload_$(AUTORELOAD).o commands.o image.o main.o options.o \ .SUFFIXES: .SUFFIXES: .c .o -all: sxiv +all: nsxiv -sxiv: $(OBJS) +nsxiv: $(OBJS) @echo "LINK $@" $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS) @@ -50,7 +50,7 @@ sxiv: $(OBJS) @echo "CC $@" $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< -$(OBJS): Makefile sxiv.h commands.lst config.h config.mk +$(OBJS): Makefile nsxiv.h commands.lst config.h config.mk options.o: version.h window.o: icon/data.h @@ -73,24 +73,24 @@ version.h: Makefile .git/index echo "#define VERSION \"$${v:-$(VERSION)}\"" >$@ clean: - $(RM) *.o sxiv + $(RM) *.o nsxiv install: all - @echo "INSTALL bin/sxiv" - install -Dt $(DESTDIR)$(PREFIX)/bin sxiv - @echo "INSTALL sxiv.1" + @echo "INSTALL bin/nsxiv" + install -Dt $(DESTDIR)$(PREFIX)/bin nsxiv + @echo "INSTALL nsxiv.1" mkdir -p $(DESTDIR)$(MANPREFIX)/man1 - sed "s!PREFIX!$(PREFIX)!g; s!VERSION!$(VERSION)!g" sxiv.1 \ - >$(DESTDIR)$(MANPREFIX)/man1/sxiv.1 - chmod 644 $(DESTDIR)$(MANPREFIX)/man1/sxiv.1 - @echo "INSTALL share/sxiv/" - install -Dt $(DESTDIR)$(PREFIX)/share/sxiv/exec exec/* + sed "s!PREFIX!$(PREFIX)!g; s!VERSION!$(VERSION)!g" nsxiv.1 \ + >$(DESTDIR)$(MANPREFIX)/man1/nsxiv.1 + chmod 644 $(DESTDIR)$(MANPREFIX)/man1/nsxiv.1 + @echo "INSTALL share/nsxiv/" + install -Dt $(DESTDIR)$(PREFIX)/share/nsxiv/exec exec/* uninstall: - @echo "REMOVE bin/sxiv" - rm -f $(DESTDIR)$(PREFIX)/bin/sxiv - @echo "REMOVE sxiv.1" - rm -f $(DESTDIR)$(MANPREFIX)/man1/sxiv.1 - @echo "REMOVE share/sxiv/" - rm -rf $(DESTDIR)$(PREFIX)/share/sxiv + @echo "REMOVE bin/nsxiv" + rm -f $(DESTDIR)$(PREFIX)/bin/nsxiv + @echo "REMOVE nsxiv.1" + rm -f $(DESTDIR)$(MANPREFIX)/man1/nsxiv.1 + @echo "REMOVE share/nsxiv/" + rm -rf $(DESTDIR)$(PREFIX)/share/nsxiv diff --git a/README.md b/README.md index f2aba7a..2de6187 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,16 @@ -![sxiv](http://muennich.github.com/sxiv/img/logo.png "sxiv") +![nsxiv](https://raw.githubusercontent.com/nsxiv/nsxiv/gh-pages/img/logo.png "nsxiv") -**Simple X Image Viewer** +**Neo (or New or Not) Simple (or Small or Suckless) X Image Viewer** +-------------------------------------------------------------------- -The sole purpose of sxiv is to be the perfect image viewer for me. It is free -software so that you can use it and modify it for your needs. Please file a bug -report if something does not work as documented or expected. Contributions are -welcome but there is no guarantee that they will be incorporated. +nsxiv is a fork of now unmaintained [sxiv](https://github.com/muennich/sxiv) +with the purpose of maintaining it and adding simple, sensible features. +nsxiv is free software licensed under GPLv2 and aims to be easy to modify and customize. + +Please file a bug report if something does not work as documented or +expected in *this* repository, after making sure you are using the latest +release of nsxiv. Contributions are welcome, see [CONTRIBUTING.md](CONTRIBUTING.md) +for details. Features @@ -16,26 +21,27 @@ Features * Thumbnail mode: grid of selectable previews of all images * Ability to cache thumbnails for fast re-loading * Basic support for multi-frame images -* Load all frames from GIF files and play GIF animations +* Play GIF animations * Display image information in status bar +* Display image name/path in X title Screenshots ----------- -**Image mode:** +**Image mode: (Default colors)** -![Image](http://muennich.github.com/sxiv/img/image.png "Image mode") +![Image](https://raw.githubusercontent.com/nsxiv/nsxiv/gh-pages/img/image.png "Image mode") -**Thumbnail mode:** +**Thumbnail mode: (Custom colors)** -![Thumb](http://muennich.github.com/sxiv/img/thumb.png "Thumb mode") +![Thumb](https://raw.githubusercontent.com/nsxiv/nsxiv/gh-pages/img/thumb.png "Thumb mode") Dependencies ------------ -sxiv requires the following software to be installed: +nsxiv requires the following software to be installed: * Imlib2 * X11 @@ -46,37 +52,39 @@ sxiv requires the following software to be installed: * libexif (optional, automatically enabled if installed) Please make sure to install the corresponding development packages in case that -you want to build sxiv on a distribution with separate runtime and development -packages (e.g. *-dev on Debian). +you want to build nsxiv on a distribution with separate runtime and development +packages (e.g. \*-dev on Debian). Building -------- -sxiv is built using the commands: +nsxiv is built using the commands: $ make - # make install - -Please note, that the latter one requires root privileges. -By default, sxiv is installed using the prefix "/usr/local", so the full path -of the executable will be "/usr/local/bin/sxiv". Running make will automatically detect if libexif and libgif are available and enable them if so. CLI arguments will override any automatic detection. For example: - $ make HAVE_LIBGIF=0 + $ make HAVE_LIBGIF=0 will always disable libgif. Alternatively, they can be disabled via editing `config.mk`. -You can install sxiv into a directory of your choice by changing the second -command to: +Installing nsxiv: + + # make install + +Please note, that this requires root privileges. +By default, nsxiv is installed using the prefix "/usr/local", so the full path +of the executable will be "/usr/local/bin/nsxiv". + +You can install nsxiv into a directory of your choice by changing this command to: - # make PREFIX="/your/dir" install + $ make PREFIX="/your/dir" install -The build-time specific settings of sxiv can be found in the file *config.h*. +The build-time specific settings of nsxiv can be found in the file *config.h*. Please check and change them, so that they fit your needs. If the file *config.h* does not already exist, then you have to create it with the following command: @@ -87,167 +95,32 @@ the following command: Usage ----- -Please see the [man page](http://muennich.github.com/sxiv/sxiv.1.html) for -information on how to use sxiv. - - -Download & Changelog --------------------- - -You can [browse](https://github.com/muennich/sxiv) the source code repository -on GitHub or get a copy using git with the following command: - - git clone https://github.com/muennich/sxiv.git - -**Stable releases** - -**[v26](https://github.com/muennich/sxiv/archive/v26.tar.gz)** -*(January 16, 2020)* - - * Maintenance release - -**[v25](https://github.com/muennich/sxiv/archive/v25.tar.gz)** -*(January 26, 2019)* - - * Support font fallback for missing glyphs - * Fix busy loop when built without inotify - * Use background/foreground colors from X resource database - -**[v24](https://github.com/muennich/sxiv/archive/v24.tar.gz)** -*(October 27, 2017)* - - * Automatically reload the current image whenever it changes - * Support embedding into other X windows with -e (e.g. tabbed) - * New option -p prevents sxiv from creating cache and temporary files - * Simpler mouse mappings, the most basic features are accessible with the - mouse only (navigate, zoom, pan) - -**[v1.3.2](https://github.com/muennich/sxiv/archive/v1.3.2.tar.gz)** -*(December 20, 2015)* - - * external key handler gets file paths on stdin, not as arguments - * Cache out-of-view thumbnails in the background - * Apply gamma correction to thumbnails - -**[v1.3.1](https://github.com/muennich/sxiv/archive/v1.3.1.tar.gz)** -*(November 16, 2014)* - - * Fixed build error, caused by delayed config.h creation - * Fixed segfault when run with -c - -**[v1.3](https://github.com/muennich/sxiv/archive/v1.3.tar.gz)** -*(October 24, 2014)* - - * Extract thumbnails from EXIF tags (requires libexif) - * Zoomable thumbnails, supported sizes defined in config.h - * Fixed build error with giflib version >= 5.1.0 +Please see man page for information on how to use nsxiv. To do so, execute the +following after the installation: -**[v1.2](https://github.com/muennich/sxiv/archive/v1.2.tar.gz)** -*(April 24, 2014)* + $ man nsxiv - * Added external key handler, called on keys prefixed with `Ctrl-x` - * New keybinding `{`/`}` to change gamma (by András Mohari) - * Support for slideshows, enabled with `-S` option & toggled with `s` - * Added application icon (created by 0ion9) - * Checkerboard background for alpha layer - * Option `-o` only prints files marked with `m` key - * Fixed rotation/flipping of multi-frame images (gifs) -**[v1.1.1](https://github.com/muennich/sxiv/archive/v1.1.1.tar.gz)** -*(June 2, 2013)* - - * Various bug fixes - -**[v1.1](https://github.com/muennich/sxiv/archive/v1.1.tar.gz)** -*(March 30, 2013)* - - * Added status bar on bottom of window with customizable content - * New keyboard shortcuts `\`/`|`: flip image vertically/horizontally - * New keyboard shortcut `Ctrl-6`: go to last/alternate image - * Added own EXIF orientation handling, removed dependency on libexif - * Fixed various bugs - -**[v1.0](https://github.com/muennich/sxiv/archive/v1.0.tar.gz)** -*(October 31, 2011)* - - * Support for multi-frame images & GIF animations - * POSIX compliant (IEEE Std 1003.1-2001) - -**[v0.9](https://github.com/muennich/sxiv/archive/v0.9.tar.gz)** -*(August 17, 2011)* - - * Made key and mouse mappings fully configurable in config.h - * Complete code refactoring - -**[v0.8.2](https://github.com/muennich/sxiv/archive/v0.8.2.tar.gz)** -*(June 29, 2011)* - - * POSIX-compliant Makefile; compiles under NetBSD - -**[v0.8.1](https://github.com/muennich/sxiv/archive/v0.8.1.tar.gz)** -*(May 8, 2011)* - - * Fixed fullscreen under window managers, which are not fully EWMH-compliant - -**[v0.8](https://github.com/muennich/sxiv/archive/v0.8.tar.gz)** -*(April 18, 2011)* - - * Support for thumbnail caching - * Ability to run external commands (e.g. jpegtran, convert) on current image - -**[v0.7](https://github.com/muennich/sxiv/archive/v0.7.tar.gz)** -*(February 26, 2011)* - - * Sort directory entries when using `-r` command line option - * Hide cursor in image mode - * Full functional thumbnail mode, use Return key to switch between image and - thumbnail mode - -**[v0.6](https://github.com/muennich/sxiv/archive/v0.6.tar.gz)** -*(February 16, 2011)* - - * Bug fix: Correctly display filenames with umlauts in window title - * Basic support of thumbnails - -**[v0.5](https://github.com/muennich/sxiv/archive/v0.5.tar.gz)** -*(February 6, 2011)* - - * New command line option: `-r`: open all images in given directories - * New key shortcuts: `w`: resize image to fit into window; `W`: resize window - to fit to image - -**[v0.4](https://github.com/muennich/sxiv/archive/v0.4.tar.gz)** -*(February 1, 2011)* - - * New command line option: `-F`, `-g`: use fixed window dimensions and apply - a given window geometry - * New key shortcut: `r`: reload current image - -**[v0.3.1](https://github.com/muennich/sxiv/archive/v0.3.1.tar.gz)** -*(January 30, 2011)* +F.A.Q +----- - * Bug fix: Do not set setuid bit on executable when using `make install` - * Pan image with mouse while pressing middle mouse button +* Can I open remote urls with nsxiv?
+Yes, see [nsxiv-url](https://github.com/nsxiv/nsxiv/wiki/nsxiv-url) -**[v0.3](https://github.com/muennich/sxiv/archive/v0.3.tar.gz)** -*(January 29, 2011)* +* Can I open all the images in a directory?
+Yes, see [nsxiv-rifle](https://github.com/nsxiv/nsxiv/wiki/nsxiv-rifle) - * New command line options: `-d`, `-f`, `-p`, `-s`, `-v`, `-w`, `-Z`, `-z` - * More mouse mappings: Go to next/previous image with left/right click, - scroll image with mouse wheel (horizontally if Shift key is pressed), - zoom image with mouse wheel if Ctrl key is pressed +* Can I set default arguments for nsxiv?
+Yes, see [nsxiv-env](https://github.com/nsxiv/nsxiv/wiki/nsxiv-env) -**[v0.2](https://github.com/muennich/sxiv/archive/v0.2.tar.gz)** -*(January 23, 2011)* +* Can I pipe images into nsxiv?
+No, not yet. See https://github.com/nsxiv/nsxiv/issues/32 - * Bug fix: Handle window resizes correctly - * New keyboard shortcuts: `g`/`G`: go to first/last image; `[`/`]`: go 10 - images back/forward - * Support for mouse wheel zooming (by Dave Reisner) - * Added fullscreen mode -**[v0.1](https://github.com/muennich/sxiv/archive/v0.1.tar.gz)** -*(January 21, 2011)* +Download +-------- - * Initial release +You can [browse](https://github.com/nsxiv/nsxiv) the source code repository +on GitHub or get a copy using git with the following command: + $ git clone https://github.com/nsxiv/nsxiv.git diff --git a/TODO b/TODO deleted file mode 100644 index 36a038c..0000000 --- a/TODO +++ /dev/null @@ -1,5 +0,0 @@ -- Load all frames from TIFF files. We have to write our own loader for this to - happen--just like we did for GIF images--because Imlib2 does not support - multiple frames. Issue #241. -- Add support for more embedded thumbnail formats. Right now, sxiv seems to use - the smallest one. Issue #238. diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..a5d54ac --- /dev/null +++ b/TODO.md @@ -0,0 +1,8 @@ +To Do +----- + + * Add support for more embedded thumbnail formats. Right now, nsxiv seems to use + the smallest one. [Issue #238](https://github.com/muennich/sxiv/issues/238). + * Load all frames from TIFF files. We have to write our own loader for this to + happen--just like we did for GIF images--because Imlib2 does not support + multiple frames. [Issue #241](https://github.com/muennich/sxiv/issues/241). diff --git a/autoreload_inotify.c b/autoreload_inotify.c index 7c5b09a..7982e0d 100644 --- a/autoreload_inotify.c +++ b/autoreload_inotify.c @@ -1,22 +1,22 @@ /* Copyright 2017 Max Voit, Bert Muennich * - * This file is part of sxiv. + * This file is a part of nsxiv. * - * sxiv is free software; you can redistribute it and/or modify + * nsxiv is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * - * sxiv is distributed in the hope that it will be useful, + * nsxiv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with sxiv. If not, see . + * along with nsxiv. If not, see . */ -#include "sxiv.h" +#include "nsxiv.h" #include #include diff --git a/autoreload_nop.c b/autoreload_nop.c index a0427af..4f5702f 100644 --- a/autoreload_nop.c +++ b/autoreload_nop.c @@ -1,22 +1,22 @@ /* Copyright 2017 Max Voit * - * This file is part of sxiv. + * This file is a part of nsxiv. * - * sxiv is free software; you can redistribute it and/or modify + * nsxiv is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * - * sxiv is distributed in the hope that it will be useful, + * nsxiv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with sxiv. If not, see . + * along with nsxiv. If not, see . */ -#include "sxiv.h" +#include "nsxiv.h" void arl_init(arl_t *arl) { diff --git a/commands.c b/commands.c index f685bc0..aad2c3c 100644 --- a/commands.c +++ b/commands.c @@ -1,22 +1,22 @@ /* Copyright 2011, 2012, 2014 Bert Muennich * - * This file is part of sxiv. + * This file is a part of nsxiv. * - * sxiv is free software; you can redistribute it and/or modify + * nsxiv is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * - * sxiv is distributed in the hope that it will be useful, + * nsxiv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with sxiv. If not, see . + * along with nsxiv. If not, see . */ -#include "sxiv.h" +#include "nsxiv.h" #define _IMAGE_CONFIG #include "config.h" diff --git a/config.def.h b/config.def.h index 449f43b..0d0b6a9 100644 --- a/config.def.h +++ b/config.def.h @@ -16,7 +16,7 @@ enum { #ifdef _TITLE_CONFIG /* default title prefix */ -static const char *TITLE_PREFIX = "sxiv - "; +static const char *TITLE_PREFIX = "nsxiv - "; /* default title suffixmode, available options are: * SUFFIX_EMPTY diff --git a/exec/image-info b/exec/image-info index da610cf..f608527 100755 --- a/exec/image-info +++ b/exec/image-info @@ -1,8 +1,8 @@ #!/bin/sh -# Example for $XDG_CONFIG_HOME/sxiv/exec/image-info -# Called by sxiv(1) whenever an image gets loaded. -# The output is displayed in sxiv's status bar. +# Example for $XDG_CONFIG_HOME/nsxiv/exec/image-info +# Called by nsxiv(1) whenever an image gets loaded. +# The output is displayed in nsxiv's status bar. # Arguments: # $1: path to image file # $2: image width diff --git a/exec/key-handler b/exec/key-handler index 3b50e4c..614e1ec 100755 --- a/exec/key-handler +++ b/exec/key-handler @@ -1,11 +1,11 @@ #!/bin/sh -# Example for $XDG_CONFIG_HOME/sxiv/exec/key-handler -# Called by sxiv(1) after the external prefix key (C-x by default) is pressed. +# Example for $XDG_CONFIG_HOME/nsxiv/exec/key-handler +# Called by nsxiv(1) after the external prefix key (C-x by default) is pressed. # The next key combo is passed as its first argument. Passed via stdin are the # images to act upon, one path per line: all marked images, if in thumbnail # mode and at least one image has been marked, otherwise the current image. -# sxiv(1) blocks until this script terminates. It then checks which images +# nsxiv(1) blocks until this script terminates. It then checks which images # have been modified and reloads them. # The key combo argument has the following form: "[C-][M-][S-]KEY", diff --git a/icon/128x128.png b/icon/128x128.png index 3076cd7..d45250b 100644 Binary files a/icon/128x128.png and b/icon/128x128.png differ diff --git a/icon/16x16.png b/icon/16x16.png index c5cff99..a19074a 100644 Binary files a/icon/16x16.png and b/icon/16x16.png differ diff --git a/icon/32x32.png b/icon/32x32.png index 01a62f4..e18ccf8 100644 Binary files a/icon/32x32.png and b/icon/32x32.png differ diff --git a/icon/48x48.png b/icon/48x48.png index 0bea30c..442a96c 100644 Binary files a/icon/48x48.png and b/icon/48x48.png differ diff --git a/icon/64x64.png b/icon/64x64.png index fb509c6..3ce0d27 100644 Binary files a/icon/64x64.png and b/icon/64x64.png differ diff --git a/icon/Makefile b/icon/Makefile index bbb4786..f660cc5 100644 --- a/icon/Makefile +++ b/icon/Makefile @@ -7,6 +7,6 @@ install: for f in $(ICONS); do \ dir="$(DESTDIR)$(PREFIX)/share/icons/hicolor/$${f%.png}/apps"; \ mkdir -p "$$dir"; \ - cp "$$f" "$$dir/sxiv.png"; \ - chmod 644 "$$dir/sxiv.png"; \ + cp "$$f" "$$dir/nsxiv.png"; \ + chmod 644 "$$dir/nsxiv.png"; \ done diff --git a/image.c b/image.c index 1c1e4d2..7689c75 100644 --- a/image.c +++ b/image.c @@ -1,22 +1,22 @@ /* Copyright 2011, 2012 Bert Muennich * - * This file is part of sxiv. + * This file is a part of nsxiv. * - * sxiv is free software; you can redistribute it and/or modify + * nsxiv is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * - * sxiv is distributed in the hope that it will be useful, + * nsxiv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with sxiv. If not, see . + * along with nsxiv. If not, see . */ -#include "sxiv.h" +#include "nsxiv.h" #define _IMAGE_CONFIG #include "config.h" diff --git a/main.c b/main.c index 61f728f..52062ca 100644 --- a/main.c +++ b/main.c @@ -1,22 +1,22 @@ /* Copyright 2011-2013 Bert Muennich * - * This file is part of sxiv. + * This file is a part of nsxiv. * - * sxiv is free software; you can redistribute it and/or modify + * nsxiv is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * - * sxiv is distributed in the hope that it will be useful, + * nsxiv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with sxiv. If not, see . + * along with nsxiv. If not, see . */ -#include "sxiv.h" +#include "nsxiv.h" #define _MAPPINGS_CONFIG #include "config.h" @@ -136,7 +136,7 @@ void remove_file(int n, bool manual) if (filecnt == 1) { if (!manual) - fprintf(stderr, "sxiv: no more files to display, aborting\n"); + fprintf(stderr, "nsxiv: no more files to display, aborting\n"); exit(manual ? EXIT_SUCCESS : EXIT_FAILURE); } if (files[n].flags & FF_MARK) @@ -919,11 +919,12 @@ int main(int argc, char **argv) if (homedir != NULL) { extcmd_t *cmd[] = { &info.f, &keyhandler.f }; const char *name[] = { "image-info", "key-handler" }; + const char *s = "/nsxiv/exec/"; for (i = 0; i < ARRLEN(cmd); i++) { - n = strlen(homedir) + strlen(dsuffix) + strlen(name[i]) + 12; + n = strlen(homedir) + strlen(dsuffix) + strlen(name[i]) + strlen(s) + 1; cmd[i]->cmd = (char*) emalloc(n); - snprintf(cmd[i]->cmd, n, "%s%s/sxiv/exec/%s", homedir, dsuffix, name[i]); + snprintf(cmd[i]->cmd, n, "%s%s%s%s", homedir, dsuffix, s, name[i]); if (access(cmd[i]->cmd, X_OK) != 0) cmd[i]->err = errno; } diff --git a/nsxiv.1 b/nsxiv.1 new file mode 100644 index 0000000..5d25099 --- /dev/null +++ b/nsxiv.1 @@ -0,0 +1,487 @@ +.TH NSXIV 1 nsxiv\-VERSION +.SH NAME +nsxiv \- Simple X Image Viewer +.SH SYNOPSIS +.B nsxiv +.RB [ \-abcfhiopqrtvZ ] +.RB [ \-A +.IR FRAMERATE ] +.RB [ \-e +.IR WID ] +.RB [ \-G +.IR GAMMA ] +.RB [ \-g +.IR GEOMETRY ] +.RB [ \-N +.IR NAME ] +.RB [ \-T +.IR TITLE ] +.RB [ \-n +.IR NUM ] +.RB [ \-S +.IR DELAY ] +.RB [ \-s +.IR MODE ] +.RB [ \-z +.IR ZOOM ] +.IR FILE ... +.SH DESCRIPTION +nsxiv is a simple image viewer for X. +.P +It has two modes of operation: image and thumbnail mode. The default is image +mode, in which only the current image is shown. In thumbnail mode a grid of +small previews is displayed, making it easy to choose an image to open. +.P +Please note, that the fullscreen mode requires an EWMH/NetWM compliant window +manager. +.SH OPTIONS +.TP +.BI "\-A " FRAMERATE +Play animations with a constant frame rate set to +.IR FRAMERATE . +.TP +.B \-a +Play animations of multi-frame images. +.TP +.B \-b +Do not show info bar on bottom of window. +.TP +.B \-c +Remove all orphaned cache files from the thumbnail cache directory and exit. +.TP +.BI "\-e " WID +Embed nsxiv's window into window whose ID is +.IR WID . +.TP +.B \-f +Start in fullscreen mode. +.TP +.BI "\-G " GAMMA +Set image gamma to GAMMA (\-32..32). +.TP +.BI "\-g " GEOMETRY +Set window position and size. See section GEOMETRY SPECIFICATIONS of X(7) for +more information on GEOMETRY argument. +.TP +.BI "\-N " NAME +Set the resource name of nsxiv's X window to NAME. +.TP +.BI "\-T " TITLE +Set the window title to TITLE. Use the format `prefix:suffixmode'. Any string +literal is accepted for prefix, and the format of suffixmode is: + +.EX + Value Format + 0 Empty + 1 Basename of file + 2 Full path to file +.EE + +By defualt, prefix is set to "nsxiv - " and suffixmode is set to 1 (basename). +.TP +.BI "\-n " NUM +Start at picture number NUM. +.TP +.B \-h +Print brief usage information to standard output and exit. +.TP +.B \-i +Read names of files to open from standard input. Also done if FILE is `-'. +.TP +.B \-o +Write list of all marked files to standard output when quitting. In combination +with +.B \-i +nsxiv can be used as a visual filter/pipe. +.TP +.B \-p +Enable private mode, in which nsxiv does not write any cache or temporary files. +.TP +.B \-q +Be quiet, disable warnings to standard error stream. +.TP +.B \-r +Search the given directories recursively for images to view. +.TP +.BI "\-S " DELAY +Start in slideshow mode. Set the delay between images to +.I DELAY +seconds. +.I DELAY +may be a floating point number. +.TP +.BI "\-s " MODE +Set scale mode according to MODE character. Supported modes are: [d]own, +[f]it, [F]ill, [w]idth, [h]eight. +.TP +.B \-t +Start in thumbnail mode. +.TP +.B \-v +Print version information to standard output and exit. +.TP +.B \-Z +The same as `\-z 100'. +.TP +.BI "\-z " ZOOM +Set zoom level to ZOOM percent. +.SH KEYBOARD COMMANDS +.SS General +The following keyboard commands are available in both image and thumbnail mode: +.TP +.BR 0 \- 9 +Prefix the next command with a number (denoted via +.IR count ). +.TP +.B q +Quit nsxiv. +.TP +.B Return +Switch to thumbnail mode / open selected image in image mode. +.TP +.B f +Toggle fullscreen mode. +.TP +.B b +Toggle visibility of info bar on bottom of window. +.TP +.B Ctrl-x +Send the next key to the external key-handler. See section EXTERNAL KEY HANDLER +for more information. +.TP +.B g +Go to the first image. +.TP +.B G +Go to the last image, or image number +.IR count . +.TP +.B r +Reload image. +.TP +.B D +Remove current image from file list and go to next image. +.TP +.BR Ctrl-h ", " Ctrl-Left +Scroll left one screen width. +.TP +.BR Ctrl-j ", " Ctrl-Down +Scroll down one screen height. +.TP +.BR Ctrl-k ", " Ctrl-Up +Scroll up one screen height. +.TP +.BR Ctrl-l ", " Ctrl-Right +Scroll right one screen width. +.TP +.BR + +Zoom in. +.TP +.B \- +Zoom out. +.TP +.B m +Mark/unmark the current image. +.TP +.B M +Repeat last mark action on all images from the last marked/unmarked up to the +current one. +.TP +.B Ctrl-m +Reverse all image marks. +.TP +.B Ctrl-u +Remove all image marks. +.TP +.B N +Go +.I count +marked images forward. +.TP +.B P +Go +.I count +marked images backward. +.TP +.B { +Decrease gamma correction by +.I count +steps. +.TP +.B } +Increase gamma correction by +.I count +steps. +.TP +.B Ctrl-g +Reset gamma correction. +.SS Thumbnail mode +The following keyboard commands are only available in thumbnail mode: +.TP +.BR h ", " Left +Move selection left +.I count +times. +.TP +.BR j ", " Down +Move selection down +.I count +times. +.TP +.BR k ", " Up +Move selection up +.I count +times. +.TP +.BR l ", " Right +Move selection right +.I count +times. +.TP +.B R +Reload all thumbnails. +.SS Image mode +The following keyboard commands are only available in image mode: +.TP +Navigate image list: +.TP +.BR n ", " Space +Go +.I count +images forward. +.TP +.BR p ", " Backspace +Go +.I count +images backward. +.TP +.B [ +Go +.I count +* 10 images backward. +.TP +.B ] +Go +.I count +* 10 images forward. +.TP +Handle multi-frame images: +.TP +.B Ctrl-n +Go +.I count +frames of a multi-frame image forward. +.TP +.B Ctrl-p +Go +.I count +frames of a multi-frame image backward. +.TP +.BR Ctrl-a ", " Ctrl-Space +Play/stop animations of multi-frame images. +.TP +Panning: +.TP +.BR h ", " Left +Scroll image 1/5 of window width or +.I count +pixel left. +.TP +.BR j ", " Down +Scroll image 1/5 of window height or +.I count +pixel down. +.TP +.BR k ", " Up +Scroll image 1/5 of window height or +.I count +pixel up. +.TP +.BR l ", " Right +Scroll image 1/5 of window width or +.I count +pixel right. +.TP +.B H +Scroll to left image edge. +.TP +.B J +Scroll to bottom image edge. +.TP +.B K +Scroll to top image edge. +.TP +.B L +Scroll to right image edge. +.TP +Zooming: +.TP +.B = +Set zoom level to 100%, or +.IR count %. +.TP +.B w +Set zoom level to 100%, but fit large images into window. +.TP +.B W +Fit image to window. +.TP +.B F +Fill image to window. +.TP +.B e +Fit image to window width. +.TP +.B E +Fit image to window height. +.TP +Rotation: +.TP +.B < +Rotate image counter-clockwise by 90 degrees. +.TP +.B > +Rotate image clockwise by 90 degrees. +.TP +.B ? +Rotate image by 180 degrees. +.TP +Flipping: +.TP +.B | +Flip image horizontally. +.TP +.B _ +Flip image vertically. +.TP +Miscellaneous: +.TP +.B a +Toggle anti-aliasing. +.TP +.B A +Toggle visibility of alpha-channel, i.e. image transparency. +.TP +.B s +Toggle slideshow mode and/or set the delay between images to +.I count +seconds. +.SH MOUSE COMMANDS +The following mouse mappings are available in image mode: +.TP +General: +.TP +.B Button3 +Switch to thumbnail mode. +.TP +Navigate image list: +.TP +.B Button1 +Go to the next image if the mouse cursor is in the right part of the window or +to the previous image if it is in the left part. +.TP +Panning: +.TP +.B Button2 +Pan the image according to the mouse cursor position in the window while +keeping this button pressed down. +.TP +Zooming: +.TP +.B ScrollUp +Zoom in. +.TP +.B ScrollDown +Zoom out. +.SH CONFIGURATION +The following X resources are supported: +.TP +.B window.background +Color of the window background +.TP +.B window.foreground +Color of the window foreground +.TP +.B bar.background +Color of the bar background. Defaults to window.foreground +.TP +.B bar.foreground +Color of the bar foreground. Defaults to window.background +.TP +.B font +Name of Xft bar font +.TP +Please see xrdb(1) on how to change them. +.SH STATUS BAR +The information displayed on the left side of the status bar can be replaced +with the output of a user-provided script, which is called by nsxiv whenever an +image gets loaded. The path of this script is +.I $XDG_CONFIG_HOME/nsxiv/exec/image-info +and the arguments given to it are: 1) path to image file, 2) image width, +3) image height. +.P +There is also an example script installed together with nsxiv as +.IR PREFIX/share/nsxiv/exec/image-info . +.SH EXTERNAL KEY HANDLER +Additional external keyboard commands can be defined using a handler program +located in +.IR $XDG_CONFIG_HOME/nsxiv/exec/key-handler . +The handler is invoked by pressing +.BR Ctrl-x . +The next key combo is passed as its first argument. Passed via stdin are the +images to act upon, one path per line: all marked images, if in thumbnail mode +and at least one image has been marked, otherwise the current image. +nsxiv(1) will block until the handler terminates. It then checks which images +have been modified and reloads them. + +The key combo argument has the following form: "[C-][M-][S-]KEY", +where C/M/S indicate Ctrl/Meta(Alt)/Shift modifier states and KEY is the X +keysym as listed in /usr/include/X11/keysymdef.h without the "XK_" prefix. + +There is also an example script installed together with nsxiv as +.IR PREFIX/share/nsxiv/exec/key-handler . +.SH THUMBNAIL CACHING +nsxiv stores all thumbnails under +.IR $XDG_CACHE_HOME/nsxiv/ . +.P +Use the command line option +.I \-c +to remove all orphaned cache files. Additionally, run the following command +afterwards inside the cache directory to remove empty subdirectories: +.P +.RS +find . \-depth \-type d \-empty ! \-name '.' \-exec rmdir {} \\; +.RE +.SH ORIGINAL AUTHOR +.EX +Bert Muennich +.EE +.SH CURRENT MAINTAINERS +.EX +Anupam Ashish Minz +Berke Kocaoğlu +Guilherme Freire +Kian Kasad +N-R-K +Stein Gunnar Bakkeby +TAAPArthur +explosion-mental +eylles +qsmodo +.EE +.SH CONTRIBUTORS +.EX +Bastien Dejean +Dave Reisner +Fung SzeTat +Max Voit + +For additional contributors, run `git shortlog -s` in the nsxiv repository. +.EE +.SH HOMEPAGE +.EX +https://github.com/nsxiv/nsxiv +.EE +.SH SEE ALSO +.BR X (7), +.BR xrdb (1) diff --git a/nsxiv.desktop b/nsxiv.desktop new file mode 100644 index 0000000..1e1e611 --- /dev/null +++ b/nsxiv.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Application +Name=nsxiv +GenericName=Image Viewer +Exec=nsxiv %F +MimeType=image/bmp;image/gif;image/jpeg;image/jpg;image/png;image/tiff;image/x-bmp;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-tga;image/x-xpixmap;image/webp; +NoDisplay=true +Icon=nsxiv diff --git a/nsxiv.h b/nsxiv.h new file mode 100644 index 0000000..2c41bf7 --- /dev/null +++ b/nsxiv.h @@ -0,0 +1,460 @@ +/* Copyright 2011 Bert Muennich + * + * This file is a part of nsxiv. + * + * nsxiv is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2 of the License, + * or (at your option) any later version. + * + * nsxiv is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with nsxiv. If not, see . + */ + +#ifndef NSXIV_H +#define NSXIV_H + +#include +#include +#include +#include +#include +#include +#include + +/* + * Annotation for functions called in cleanup(). + * These functions are not allowed to call error(!0, ...) or exit(). + */ +#define CLEANUP + +#ifndef MIN +#define MIN(a,b) ((a) < (b) ? (a) : (b)) +#endif +#ifndef MAX +#define MAX(a,b) ((a) > (b) ? (a) : (b)) +#endif + +#define ARRLEN(a) (sizeof(a) / sizeof((a)[0])) + +#define STREQ(s1,s2) (strcmp((s1), (s2)) == 0) + +#define TV_DIFF(t1,t2) (((t1)->tv_sec - (t2)->tv_sec ) * 1000 + \ + ((t1)->tv_usec - (t2)->tv_usec) / 1000) + +#define TV_SET_MSEC(tv,t) { \ + (tv)->tv_sec = (t) / 1000; \ + (tv)->tv_usec = (t) % 1000 * 1000; \ +} + +#define TV_ADD_MSEC(tv,t) { \ + (tv)->tv_sec += (t) / 1000; \ + (tv)->tv_usec += (t) % 1000 * 1000; \ +} + +typedef enum { + BO_BIG_ENDIAN, + BO_LITTLE_ENDIAN +} byteorder_t; + +typedef enum { + MODE_IMAGE, + MODE_THUMB +} appmode_t; + +typedef enum { + DIR_LEFT = 1, + DIR_RIGHT = 2, + DIR_UP = 4, + DIR_DOWN = 8 +} direction_t; + +typedef enum { + DEGREE_90 = 1, + DEGREE_180 = 2, + DEGREE_270 = 3 +} degree_t; + +typedef enum { + FLIP_HORIZONTAL = 1, + FLIP_VERTICAL = 2 +} flipdir_t; + +typedef enum { + SCALE_DOWN, + SCALE_FIT, + SCALE_FILL, + SCALE_WIDTH, + SCALE_HEIGHT, + SCALE_ZOOM +} scalemode_t; + +typedef enum { + DRAG_RELATIVE, + DRAG_ABSOLUTE +} dragmode_t; + +typedef enum { + CURSOR_ARROW, + CURSOR_DRAG, + CURSOR_WATCH, + CURSOR_LEFT, + CURSOR_RIGHT, + CURSOR_NONE, + + CURSOR_COUNT +} cursor_t; + +typedef enum { + FF_WARN = 1, + FF_MARK = 2, + FF_TN_INIT = 4 +} fileflags_t; + +typedef enum { + SUFFIX_EMPTY, + SUFFIX_BASENAME, + SUFFIX_FULLPATH, +} suffixmode_t; + +typedef struct { + const char *name; /* as given by user */ + const char *path; /* always absolute */ + fileflags_t flags; +} fileinfo_t; + +/* timeouts in milliseconds: */ +enum { + TO_REDRAW_RESIZE = 75, + TO_REDRAW_THUMBS = 200, + TO_CURSOR_HIDE = 1200, + TO_DOUBLE_CLICK = 300 +}; + +typedef void (*timeout_f)(void); + +typedef struct arl arl_t; +typedef struct img img_t; +typedef struct opt opt_t; +typedef struct tns tns_t; +typedef struct win win_t; + + +/* autoreload.c */ + +struct arl { + int fd; + int wd_dir; + int wd_file; + char *filename; +}; + +void arl_init(arl_t*); +void arl_cleanup(arl_t*); +void arl_setup(arl_t*, const char* /* result of realpath(3) */); +bool arl_handle(arl_t*); + + +/* commands.c */ + +typedef int arg_t; +typedef bool (*cmd_f)(arg_t); + +#define G_CMD(c) g_##c, +#define I_CMD(c) i_##c, +#define T_CMD(c) t_##c, + +typedef enum { +#include "commands.lst" + CMD_COUNT +} cmd_id_t; + +typedef struct { + int mode; + cmd_f func; +} cmd_t; + +typedef struct { + unsigned int mask; + KeySym ksym; + cmd_id_t cmd; + arg_t arg; +} keymap_t; + +typedef struct { + unsigned int mask; + unsigned int button; + cmd_id_t cmd; + arg_t arg; +} button_t; + +extern const cmd_t cmds[CMD_COUNT]; + + +/* image.c */ + +typedef struct { + Imlib_Image im; + unsigned int delay; +} img_frame_t; + +typedef struct { + img_frame_t *frames; + int cap; + int cnt; + int sel; + bool animate; + int framedelay; + int length; +} multi_img_t; + +struct img { + Imlib_Image im; + int w; + int h; + + win_t *win; + float x; + float y; + + scalemode_t scalemode; + float zoom; + + bool checkpan; + bool dirty; + bool aa; + bool alpha; + + Imlib_Color_Modifier cmod; + int gamma; + + struct { + bool on; + int delay; + } ss; + + multi_img_t multi; +}; + +void img_init(img_t*, win_t*); +bool img_load(img_t*, const fileinfo_t*); +CLEANUP void img_close(img_t*, bool); +void img_render(img_t*); +bool img_fit_win(img_t*, scalemode_t); +bool img_zoom(img_t*, float); +bool img_zoom_in(img_t*); +bool img_zoom_out(img_t*); +bool img_pos(img_t*, float, float); +bool img_move(img_t*, float, float); +bool img_pan(img_t*, direction_t, int); +bool img_pan_edge(img_t*, direction_t); +void img_rotate(img_t*, degree_t); +void img_flip(img_t*, flipdir_t); +void img_toggle_antialias(img_t*); +bool img_change_gamma(img_t*, int); +bool img_frame_navigate(img_t*, int); +bool img_frame_animate(img_t*); + + +/* options.c */ + +struct opt { + /* file list: */ + char **filenames; + bool from_stdin; + bool to_stdout; + bool recursive; + int filecnt; + int startnum; + + /* image: */ + scalemode_t scalemode; + float zoom; + bool animate; + int gamma; + int slideshow; + int framerate; + + /* window: */ + bool fullscreen; + bool hide_bar; + long embed; + char *geometry; + char *res_name; + const char *title_prefix; + suffixmode_t title_suffixmode; + + /* misc flags: */ + bool quiet; + bool thumb_mode; + bool clean_cache; + bool private_mode; +}; + +extern const opt_t *options; + +void print_usage(void); +void print_version(void); +void parse_options(int, char**); + + +/* thumbs.c */ + +typedef struct { + Imlib_Image im; + int w; + int h; + int x; + int y; +} thumb_t; + +struct tns { + fileinfo_t *files; + thumb_t *thumbs; + const int *cnt; + int *sel; + int initnext; + int loadnext; + int first, end; + int r_first, r_end; + + win_t *win; + int x; + int y; + int cols; + int rows; + int zl; + int bw; + int dim; + + bool dirty; +}; + +void tns_clean_cache(tns_t*); +void tns_init(tns_t*, fileinfo_t*, const int*, int*, win_t*); +CLEANUP void tns_free(tns_t*); +bool tns_load(tns_t*, int, bool, bool); +void tns_unload(tns_t*, int); +void tns_render(tns_t*); +void tns_mark(tns_t*, int, bool); +void tns_highlight(tns_t*, int, bool); +bool tns_move_selection(tns_t*, direction_t, int); +bool tns_scroll(tns_t*, direction_t, bool); +bool tns_zoom(tns_t*, int); +int tns_translate(tns_t*, int, int); + + +/* util.c */ + +#include + +typedef struct { + DIR *dir; + char *name; + int d; + bool recursive; + + char **stack; + int stcap; + int stlen; +} r_dir_t; + +extern const char *progname; + +void* emalloc(size_t); +void* erealloc(void*, size_t); +char* estrdup(const char*); +void error(int, int, const char*, ...); +void size_readable(float*, const char**); +int r_opendir(r_dir_t*, const char*, bool); +int r_closedir(r_dir_t*); +char* r_readdir(r_dir_t*, bool); +int r_mkdir(char*); + + +/* window.c */ + +#include +#include + +enum { + BAR_L_LEN = 512, + BAR_R_LEN = 64 +}; + +enum { + ATOM_WM_DELETE_WINDOW, + ATOM__NET_WM_NAME, + ATOM__NET_WM_ICON_NAME, + ATOM__NET_WM_ICON, + ATOM__NET_WM_STATE, + ATOM__NET_WM_PID, + ATOM__NET_WM_STATE_FULLSCREEN, + ATOM_COUNT +}; + +typedef struct { + Display *dpy; + int scr; + int scrw, scrh; + Visual *vis; + Colormap cmap; + int depth; +} win_env_t; + +typedef struct { + size_t size; + char *p; + char *buf; +} win_bar_t; + +struct win { + Window xwin; + win_env_t env; + + XftColor win_bg; + XftColor win_fg; + XftColor bar_bg; + XftColor bar_fg; + + int x; + int y; + unsigned int w; + unsigned int h; /* = win height - bar height */ + unsigned int bw; + + struct { + int w; + int h; + Pixmap pm; + } buf; + + struct { + unsigned int h; + win_bar_t l; + win_bar_t r; + } bar; +}; + +extern Atom atoms[ATOM_COUNT]; + +void win_init(win_t*); +void win_open(win_t*); +CLEANUP void win_close(win_t*); +bool win_configure(win_t*, XConfigureEvent*); +void win_toggle_fullscreen(win_t*); +void win_toggle_bar(win_t*); +void win_clear(win_t*); +void win_draw(win_t*); +void win_draw_rect(win_t*, int, int, int, int, bool, int, unsigned long); +void win_set_title(win_t*, const char*); +void win_set_cursor(win_t*, cursor_t); +void win_cursor_pos(win_t*, int*, int*); + +#endif /* NSXIV_H */ + diff --git a/options.c b/options.c index e89b6f1..31cfa39 100644 --- a/options.c +++ b/options.c @@ -1,22 +1,22 @@ /* Copyright 2011 Bert Muennich * - * This file is part of sxiv. + * This file is a part of nsxiv. * - * sxiv is free software; you can redistribute it and/or modify + * nsxiv is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * - * sxiv is distributed in the hope that it will be useful, + * nsxiv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with sxiv. If not, see . + * along with nsxiv. If not, see . */ -#include "sxiv.h" +#include "nsxiv.h" #define _IMAGE_CONFIG #define _TITLE_CONFIG #include "config.h" @@ -31,14 +31,14 @@ const opt_t *options = (const opt_t*) &_options; void print_usage(void) { - printf("usage: sxiv [-abcfhiopqrtvZ] [-A FRAMERATE] [-e WID] [-G GAMMA] " + printf("usage: nsxiv [-abcfhiopqrtvZ] [-A FRAMERATE] [-e WID] [-G GAMMA] " "[-g GEOMETRY] [-N NAME] [-T TITLE] [-n NUM] [-S DELAY] [-s MODE] " "[-z ZOOM] FILES...\n"); } void print_version(void) { - puts("sxiv " VERSION); + puts("nsxiv " VERSION); } void parse_options(int argc, char **argv) diff --git a/sxiv.1 b/sxiv.1 deleted file mode 100644 index ed32bf2..0000000 --- a/sxiv.1 +++ /dev/null @@ -1,472 +0,0 @@ -.TH SXIV 1 sxiv\-VERSION -.SH NAME -sxiv \- Simple X Image Viewer -.SH SYNOPSIS -.B sxiv -.RB [ \-abcfhiopqrtvZ ] -.RB [ \-A -.IR FRAMERATE ] -.RB [ \-e -.IR WID ] -.RB [ \-G -.IR GAMMA ] -.RB [ \-g -.IR GEOMETRY ] -.RB [ \-N -.IR NAME ] -.RB [ \-T -.IR TITLE ] -.RB [ \-n -.IR NUM ] -.RB [ \-S -.IR DELAY ] -.RB [ \-s -.IR MODE ] -.RB [ \-z -.IR ZOOM ] -.IR FILE ... -.SH DESCRIPTION -sxiv is a simple image viewer for X. -.P -It has two modes of operation: image and thumbnail mode. The default is image -mode, in which only the current image is shown. In thumbnail mode a grid of -small previews is displayed, making it easy to choose an image to open. -.P -Please note, that the fullscreen mode requires an EWMH/NetWM compliant window -manager. -.SH OPTIONS -.TP -.BI "\-A " FRAMERATE -Play animations with a constant frame rate set to -.IR FRAMERATE . -.TP -.B \-a -Play animations of multi-frame images. -.TP -.B \-b -Do not show info bar on bottom of window. -.TP -.B \-c -Remove all orphaned cache files from the thumbnail cache directory and exit. -.TP -.BI "\-e " WID -Embed sxiv's window into window whose ID is -.IR WID . -.TP -.B \-f -Start in fullscreen mode. -.TP -.BI "\-G " GAMMA -Set image gamma to GAMMA (\-32..32). -.TP -.BI "\-g " GEOMETRY -Set window position and size. See section GEOMETRY SPECIFICATIONS of X(7) for -more information on GEOMETRY argument. -.TP -.BI "\-N " NAME -Set the resource name of sxiv's X window to NAME. -.TP -.BI "\-T " TITLE -Set the window title to TITLE. Use the format `prefix:suffixmode'. Any string -literal is accepted for prefix, and the format of suffixmode is: - -.EX - Value Format - 0 Empty - 1 Basename of file - 2 Full path to file -.EE - -By defualt, prefix is set to "sxiv - " and suffixmode is set to 1 (basename). -.TP -.BI "\-n " NUM -Start at picture number NUM. -.TP -.B \-h -Print brief usage information to standard output and exit. -.TP -.B \-i -Read names of files to open from standard input. Also done if FILE is `-'. -.TP -.B \-o -Write list of all marked files to standard output when quitting. In combination -with -.B \-i -sxiv can be used as a visual filter/pipe. -.TP -.B \-p -Enable private mode, in which sxiv does not write any cache or temporary files. -.TP -.B \-q -Be quiet, disable warnings to standard error stream. -.TP -.B \-r -Search the given directories recursively for images to view. -.TP -.BI "\-S " DELAY -Start in slideshow mode. Set the delay between images to -.I DELAY -seconds. -.I DELAY -may be a floating point number. -.TP -.BI "\-s " MODE -Set scale mode according to MODE character. Supported modes are: [d]own, -[f]it, [F]ill, [w]idth, [h]eight. -.TP -.B \-t -Start in thumbnail mode. -.TP -.B \-v -Print version information to standard output and exit. -.TP -.B \-Z -The same as `\-z 100'. -.TP -.BI "\-z " ZOOM -Set zoom level to ZOOM percent. -.SH KEYBOARD COMMANDS -.SS General -The following keyboard commands are available in both image and thumbnail mode: -.TP -.BR 0 \- 9 -Prefix the next command with a number (denoted via -.IR count ). -.TP -.B q -Quit sxiv. -.TP -.B Return -Switch to thumbnail mode / open selected image in image mode. -.TP -.B f -Toggle fullscreen mode. -.TP -.B b -Toggle visibility of info bar on bottom of window. -.TP -.B Ctrl-x -Send the next key to the external key-handler. See section EXTERNAL KEY HANDLER -for more information. -.TP -.B g -Go to the first image. -.TP -.B G -Go to the last image, or image number -.IR count . -.TP -.B r -Reload image. -.TP -.B D -Remove current image from file list and go to next image. -.TP -.BR Ctrl-h ", " Ctrl-Left -Scroll left one screen width. -.TP -.BR Ctrl-j ", " Ctrl-Down -Scroll down one screen height. -.TP -.BR Ctrl-k ", " Ctrl-Up -Scroll up one screen height. -.TP -.BR Ctrl-l ", " Ctrl-Right -Scroll right one screen width. -.TP -.BR + -Zoom in. -.TP -.B \- -Zoom out. -.TP -.B m -Mark/unmark the current image. -.TP -.B M -Repeat last mark action on all images from the last marked/unmarked up to the -current one. -.TP -.B Ctrl-m -Reverse all image marks. -.TP -.B Ctrl-u -Remove all image marks. -.TP -.B N -Go -.I count -marked images forward. -.TP -.B P -Go -.I count -marked images backward. -.TP -.B { -Decrease gamma correction by -.I count -steps. -.TP -.B } -Increase gamma correction by -.I count -steps. -.TP -.B Ctrl-g -Reset gamma correction. -.SS Thumbnail mode -The following keyboard commands are only available in thumbnail mode: -.TP -.BR h ", " Left -Move selection left -.I count -times. -.TP -.BR j ", " Down -Move selection down -.I count -times. -.TP -.BR k ", " Up -Move selection up -.I count -times. -.TP -.BR l ", " Right -Move selection right -.I count -times. -.TP -.B R -Reload all thumbnails. -.SS Image mode -The following keyboard commands are only available in image mode: -.TP -Navigate image list: -.TP -.BR n ", " Space -Go -.I count -images forward. -.TP -.BR p ", " Backspace -Go -.I count -images backward. -.TP -.B [ -Go -.I count -* 10 images backward. -.TP -.B ] -Go -.I count -* 10 images forward. -.TP -Handle multi-frame images: -.TP -.B Ctrl-n -Go -.I count -frames of a multi-frame image forward. -.TP -.B Ctrl-p -Go -.I count -frames of a multi-frame image backward. -.TP -.BR Ctrl-a ", " Ctrl-Space -Play/stop animations of multi-frame images. -.TP -Panning: -.TP -.BR h ", " Left -Scroll image 1/5 of window width or -.I count -pixel left. -.TP -.BR j ", " Down -Scroll image 1/5 of window height or -.I count -pixel down. -.TP -.BR k ", " Up -Scroll image 1/5 of window height or -.I count -pixel up. -.TP -.BR l ", " Right -Scroll image 1/5 of window width or -.I count -pixel right. -.TP -.B H -Scroll to left image edge. -.TP -.B J -Scroll to bottom image edge. -.TP -.B K -Scroll to top image edge. -.TP -.B L -Scroll to right image edge. -.TP -Zooming: -.TP -.B = -Set zoom level to 100%, or -.IR count %. -.TP -.B w -Set zoom level to 100%, but fit large images into window. -.TP -.B W -Fit image to window. -.TP -.B F -Fill image to window. -.TP -.B e -Fit image to window width. -.TP -.B E -Fit image to window height. -.TP -Rotation: -.TP -.B < -Rotate image counter-clockwise by 90 degrees. -.TP -.B > -Rotate image clockwise by 90 degrees. -.TP -.B ? -Rotate image by 180 degrees. -.TP -Flipping: -.TP -.B | -Flip image horizontally. -.TP -.B _ -Flip image vertically. -.TP -Miscellaneous: -.TP -.B a -Toggle anti-aliasing. -.TP -.B A -Toggle visibility of alpha-channel, i.e. image transparency. -.TP -.B s -Toggle slideshow mode and/or set the delay between images to -.I count -seconds. -.SH MOUSE COMMANDS -The following mouse mappings are available in image mode: -.TP -General: -.TP -.B Button3 -Switch to thumbnail mode. -.TP -Navigate image list: -.TP -.B Button1 -Go to the next image if the mouse cursor is in the right part of the window or -to the previous image if it is in the left part. -.TP -Panning: -.TP -.B Button2 -Pan the image according to the mouse cursor position in the window while -keeping this button pressed down. -.TP -Zooming: -.TP -.B ScrollUp -Zoom in. -.TP -.B ScrollDown -Zoom out. -.SH CONFIGURATION -The following X resources are supported: -.TP -.B window.background -Color of the window background -.TP -.B window.foreground -Color of the window foreground -.TP -.B bar.background -Color of the bar background. Defaults to window.foreground -.TP -.B bar.foreground -Color of the bar foreground. Defaults to window.background -.TP -.B font -Name of Xft bar font -.TP -Please see xrdb(1) on how to change them. -.SH STATUS BAR -The information displayed on the left side of the status bar can be replaced -with the output of a user-provided script, which is called by sxiv whenever an -image gets loaded. The path of this script is -.I $XDG_CONFIG_HOME/sxiv/exec/image-info -and the arguments given to it are: 1) path to image file, 2) image width, -3) image height. -.P -There is also an example script installed together with sxiv as -.IR PREFIX/share/sxiv/exec/image-info . -.SH EXTERNAL KEY HANDLER -Additional external keyboard commands can be defined using a handler program -located in -.IR $XDG_CONFIG_HOME/sxiv/exec/key-handler . -The handler is invoked by pressing -.BR Ctrl-x . -The next key combo is passed as its first argument. Passed via stdin are the -images to act upon, one path per line: all marked images, if in thumbnail mode -and at least one image has been marked, otherwise the current image. -sxiv(1) will block until the handler terminates. It then checks which images -have been modified and reloads them. - -The key combo argument has the following form: "[C-][M-][S-]KEY", -where C/M/S indicate Ctrl/Meta(Alt)/Shift modifier states and KEY is the X -keysym as listed in /usr/include/X11/keysymdef.h without the "XK_" prefix. - -There is also an example script installed together with sxiv as -.IR PREFIX/share/sxiv/exec/key-handler . -.SH THUMBNAIL CACHING -sxiv stores all thumbnails under -.IR $XDG_CACHE_HOME/sxiv/ . -.P -Use the command line option -.I \-c -to remove all orphaned cache files. Additionally, run the following command -afterwards inside the cache directory to remove empty subdirectories: -.P -.RS -find . \-depth \-type d \-empty ! \-name '.' \-exec rmdir {} \\; -.RE -.SH AUTHOR -.EX -Bert Muennich -.EE -.SH CONTRIBUTORS -.EX -Bastien Dejean -Dave Reisner -Fung SzeTat -Max Voit -.EE -.SH HOMEPAGE -.EX -https://github.com/muennich/sxiv -.EE -.SH SEE ALSO -.BR X (7), -.BR xrdb (1) diff --git a/sxiv.desktop b/sxiv.desktop deleted file mode 100644 index 46826be..0000000 --- a/sxiv.desktop +++ /dev/null @@ -1,8 +0,0 @@ -[Desktop Entry] -Type=Application -Name=sxiv -GenericName=Image Viewer -Exec=sxiv %F -MimeType=image/bmp;image/gif;image/jpeg;image/jpg;image/png;image/tiff;image/x-bmp;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-tga;image/x-xpixmap;image/webp; -NoDisplay=true -Icon=sxiv diff --git a/sxiv.h b/sxiv.h deleted file mode 100644 index 902446d..0000000 --- a/sxiv.h +++ /dev/null @@ -1,460 +0,0 @@ -/* Copyright 2011 Bert Muennich - * - * This file is part of sxiv. - * - * sxiv is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. - * - * sxiv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with sxiv. If not, see . - */ - -#ifndef SXIV_H -#define SXIV_H - -#include -#include -#include -#include -#include -#include -#include - -/* - * Annotation for functions called in cleanup(). - * These functions are not allowed to call error(!0, ...) or exit(). - */ -#define CLEANUP - -#ifndef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif -#ifndef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#endif - -#define ARRLEN(a) (sizeof(a) / sizeof((a)[0])) - -#define STREQ(s1,s2) (strcmp((s1), (s2)) == 0) - -#define TV_DIFF(t1,t2) (((t1)->tv_sec - (t2)->tv_sec ) * 1000 + \ - ((t1)->tv_usec - (t2)->tv_usec) / 1000) - -#define TV_SET_MSEC(tv,t) { \ - (tv)->tv_sec = (t) / 1000; \ - (tv)->tv_usec = (t) % 1000 * 1000; \ -} - -#define TV_ADD_MSEC(tv,t) { \ - (tv)->tv_sec += (t) / 1000; \ - (tv)->tv_usec += (t) % 1000 * 1000; \ -} - -typedef enum { - BO_BIG_ENDIAN, - BO_LITTLE_ENDIAN -} byteorder_t; - -typedef enum { - MODE_IMAGE, - MODE_THUMB -} appmode_t; - -typedef enum { - DIR_LEFT = 1, - DIR_RIGHT = 2, - DIR_UP = 4, - DIR_DOWN = 8 -} direction_t; - -typedef enum { - DEGREE_90 = 1, - DEGREE_180 = 2, - DEGREE_270 = 3 -} degree_t; - -typedef enum { - FLIP_HORIZONTAL = 1, - FLIP_VERTICAL = 2 -} flipdir_t; - -typedef enum { - SCALE_DOWN, - SCALE_FIT, - SCALE_FILL, - SCALE_WIDTH, - SCALE_HEIGHT, - SCALE_ZOOM -} scalemode_t; - -typedef enum { - DRAG_RELATIVE, - DRAG_ABSOLUTE -} dragmode_t; - -typedef enum { - CURSOR_ARROW, - CURSOR_DRAG, - CURSOR_WATCH, - CURSOR_LEFT, - CURSOR_RIGHT, - CURSOR_NONE, - - CURSOR_COUNT -} cursor_t; - -typedef enum { - FF_WARN = 1, - FF_MARK = 2, - FF_TN_INIT = 4 -} fileflags_t; - -typedef enum { - SUFFIX_EMPTY, - SUFFIX_BASENAME, - SUFFIX_FULLPATH, -} suffixmode_t; - -typedef struct { - const char *name; /* as given by user */ - const char *path; /* always absolute */ - fileflags_t flags; -} fileinfo_t; - -/* timeouts in milliseconds: */ -enum { - TO_REDRAW_RESIZE = 75, - TO_REDRAW_THUMBS = 200, - TO_CURSOR_HIDE = 1200, - TO_DOUBLE_CLICK = 300 -}; - -typedef void (*timeout_f)(void); - -typedef struct arl arl_t; -typedef struct img img_t; -typedef struct opt opt_t; -typedef struct tns tns_t; -typedef struct win win_t; - - -/* autoreload.c */ - -struct arl { - int fd; - int wd_dir; - int wd_file; - char *filename; -}; - -void arl_init(arl_t*); -void arl_cleanup(arl_t*); -void arl_setup(arl_t*, const char* /* result of realpath(3) */); -bool arl_handle(arl_t*); - - -/* commands.c */ - -typedef int arg_t; -typedef bool (*cmd_f)(arg_t); - -#define G_CMD(c) g_##c, -#define I_CMD(c) i_##c, -#define T_CMD(c) t_##c, - -typedef enum { -#include "commands.lst" - CMD_COUNT -} cmd_id_t; - -typedef struct { - int mode; - cmd_f func; -} cmd_t; - -typedef struct { - unsigned int mask; - KeySym ksym; - cmd_id_t cmd; - arg_t arg; -} keymap_t; - -typedef struct { - unsigned int mask; - unsigned int button; - cmd_id_t cmd; - arg_t arg; -} button_t; - -extern const cmd_t cmds[CMD_COUNT]; - - -/* image.c */ - -typedef struct { - Imlib_Image im; - unsigned int delay; -} img_frame_t; - -typedef struct { - img_frame_t *frames; - int cap; - int cnt; - int sel; - bool animate; - int framedelay; - int length; -} multi_img_t; - -struct img { - Imlib_Image im; - int w; - int h; - - win_t *win; - float x; - float y; - - scalemode_t scalemode; - float zoom; - - bool checkpan; - bool dirty; - bool aa; - bool alpha; - - Imlib_Color_Modifier cmod; - int gamma; - - struct { - bool on; - int delay; - } ss; - - multi_img_t multi; -}; - -void img_init(img_t*, win_t*); -bool img_load(img_t*, const fileinfo_t*); -CLEANUP void img_close(img_t*, bool); -void img_render(img_t*); -bool img_fit_win(img_t*, scalemode_t); -bool img_zoom(img_t*, float); -bool img_zoom_in(img_t*); -bool img_zoom_out(img_t*); -bool img_pos(img_t*, float, float); -bool img_move(img_t*, float, float); -bool img_pan(img_t*, direction_t, int); -bool img_pan_edge(img_t*, direction_t); -void img_rotate(img_t*, degree_t); -void img_flip(img_t*, flipdir_t); -void img_toggle_antialias(img_t*); -bool img_change_gamma(img_t*, int); -bool img_frame_navigate(img_t*, int); -bool img_frame_animate(img_t*); - - -/* options.c */ - -struct opt { - /* file list: */ - char **filenames; - bool from_stdin; - bool to_stdout; - bool recursive; - int filecnt; - int startnum; - - /* image: */ - scalemode_t scalemode; - float zoom; - bool animate; - int gamma; - int slideshow; - int framerate; - - /* window: */ - bool fullscreen; - bool hide_bar; - long embed; - char *geometry; - char *res_name; - const char *title_prefix; - suffixmode_t title_suffixmode; - - /* misc flags: */ - bool quiet; - bool thumb_mode; - bool clean_cache; - bool private_mode; -}; - -extern const opt_t *options; - -void print_usage(void); -void print_version(void); -void parse_options(int, char**); - - -/* thumbs.c */ - -typedef struct { - Imlib_Image im; - int w; - int h; - int x; - int y; -} thumb_t; - -struct tns { - fileinfo_t *files; - thumb_t *thumbs; - const int *cnt; - int *sel; - int initnext; - int loadnext; - int first, end; - int r_first, r_end; - - win_t *win; - int x; - int y; - int cols; - int rows; - int zl; - int bw; - int dim; - - bool dirty; -}; - -void tns_clean_cache(tns_t*); -void tns_init(tns_t*, fileinfo_t*, const int*, int*, win_t*); -CLEANUP void tns_free(tns_t*); -bool tns_load(tns_t*, int, bool, bool); -void tns_unload(tns_t*, int); -void tns_render(tns_t*); -void tns_mark(tns_t*, int, bool); -void tns_highlight(tns_t*, int, bool); -bool tns_move_selection(tns_t*, direction_t, int); -bool tns_scroll(tns_t*, direction_t, bool); -bool tns_zoom(tns_t*, int); -int tns_translate(tns_t*, int, int); - - -/* util.c */ - -#include - -typedef struct { - DIR *dir; - char *name; - int d; - bool recursive; - - char **stack; - int stcap; - int stlen; -} r_dir_t; - -extern const char *progname; - -void* emalloc(size_t); -void* erealloc(void*, size_t); -char* estrdup(const char*); -void error(int, int, const char*, ...); -void size_readable(float*, const char**); -int r_opendir(r_dir_t*, const char*, bool); -int r_closedir(r_dir_t*); -char* r_readdir(r_dir_t*, bool); -int r_mkdir(char*); - - -/* window.c */ - -#include -#include - -enum { - BAR_L_LEN = 512, - BAR_R_LEN = 64 -}; - -enum { - ATOM_WM_DELETE_WINDOW, - ATOM__NET_WM_NAME, - ATOM__NET_WM_ICON_NAME, - ATOM__NET_WM_ICON, - ATOM__NET_WM_STATE, - ATOM__NET_WM_PID, - ATOM__NET_WM_STATE_FULLSCREEN, - ATOM_COUNT -}; - -typedef struct { - Display *dpy; - int scr; - int scrw, scrh; - Visual *vis; - Colormap cmap; - int depth; -} win_env_t; - -typedef struct { - size_t size; - char *p; - char *buf; -} win_bar_t; - -struct win { - Window xwin; - win_env_t env; - - XftColor win_bg; - XftColor win_fg; - XftColor bar_bg; - XftColor bar_fg; - - int x; - int y; - unsigned int w; - unsigned int h; /* = win height - bar height */ - unsigned int bw; - - struct { - int w; - int h; - Pixmap pm; - } buf; - - struct { - unsigned int h; - win_bar_t l; - win_bar_t r; - } bar; -}; - -extern Atom atoms[ATOM_COUNT]; - -void win_init(win_t*); -void win_open(win_t*); -CLEANUP void win_close(win_t*); -bool win_configure(win_t*, XConfigureEvent*); -void win_toggle_fullscreen(win_t*); -void win_toggle_bar(win_t*); -void win_clear(win_t*); -void win_draw(win_t*); -void win_draw_rect(win_t*, int, int, int, int, bool, int, unsigned long); -void win_set_title(win_t*, const char*); -void win_set_cursor(win_t*, cursor_t); -void win_cursor_pos(win_t*, int*, int*); - -#endif /* SXIV_H */ - diff --git a/thumbs.c b/thumbs.c index 3aa03fb..1850f52 100644 --- a/thumbs.c +++ b/thumbs.c @@ -1,22 +1,22 @@ /* Copyright 2011 Bert Muennich * - * This file is part of sxiv. + * This file is a part of nsxiv. * - * sxiv is free software; you can redistribute it and/or modify + * nsxiv is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * - * sxiv is distributed in the hope that it will be useful, + * nsxiv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with sxiv. If not, see . + * along with nsxiv. If not, see . */ -#include "sxiv.h" +#include "nsxiv.h" #define _THUMBS_CONFIG #include "config.h" @@ -172,10 +172,11 @@ void tns_init(tns_t *tns, fileinfo_t *files, const int *cnt, int *sel, dsuffix = "/.cache"; } if (homedir != NULL) { + const char *s = "/nsxiv"; free(cache_dir); - len = strlen(homedir) + strlen(dsuffix) + 6; + len = strlen(homedir) + strlen(dsuffix) + strlen(s) + 1; cache_dir = (char*) emalloc(len); - snprintf(cache_dir, len, "%s%s/sxiv", homedir, dsuffix); + snprintf(cache_dir, len, "%s%s%s", homedir, dsuffix, s); } else { error(0, 0, "Cache directory not found"); } @@ -272,7 +273,7 @@ bool tns_load(tns_t *tns, int n, bool force, bool cache_only) ExifContent *ifd; ExifByteOrder byte_order; int tmpfd; - char tmppath[] = "/tmp/sxiv-XXXXXX"; + char tmppath[] = "/tmp/nsxiv-XXXXXX"; Imlib_Image tmpim; if ((ed = exif_data_new_from_file(file->path)) != NULL) { diff --git a/util.c b/util.c index b956fd7..fa0f0e3 100644 --- a/util.c +++ b/util.c @@ -1,22 +1,22 @@ /* Copyright 2011 Bert Muennich * - * This file is part of sxiv. + * This file is a part of nsxiv. * - * sxiv is free software; you can redistribute it and/or modify + * nsxiv is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * - * sxiv is distributed in the hope that it will be useful, + * nsxiv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with sxiv. If not, see . + * along with nsxiv. If not, see . */ -#include "sxiv.h" +#include "nsxiv.h" #include #include diff --git a/window.c b/window.c index dd17134..3cd6c4a 100644 --- a/window.c +++ b/window.c @@ -1,22 +1,22 @@ /* Copyright 2011-2013 Bert Muennich * - * This file is part of sxiv. + * This file is a part of nsxiv. * - * sxiv is free software; you can redistribute it and/or modify + * nsxiv is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 2 of the License, * or (at your option) any later version. * - * sxiv is distributed in the hope that it will be useful, + * nsxiv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with sxiv. If not, see . + * along with nsxiv. If not, see . */ -#include "sxiv.h" +#include "nsxiv.h" #define _WINDOW_CONFIG #include "config.h" #include "icon/data.h" @@ -30,7 +30,7 @@ #include #include -#define RES_CLASS "Sxiv" +#define RES_CLASS "Nsxiv" enum { H_TEXT_PAD = 5, @@ -277,11 +277,11 @@ void win_open(win_t *win) free(icon_data); /* These two atoms won't change and thus only need to be set once. */ - XStoreName(win->env.dpy, win->xwin, "sxiv"); - XSetIconName(win->env.dpy, win->xwin, "sxiv"); + XStoreName(win->env.dpy, win->xwin, "nsxiv"); + XSetIconName(win->env.dpy, win->xwin, "nsxiv"); classhint.res_class = RES_CLASS; - classhint.res_name = options->res_name != NULL ? options->res_name : "sxiv"; + classhint.res_name = options->res_name != NULL ? options->res_name : "nsxiv"; XSetClassHint(e->dpy, win->xwin, &classhint); XSetWMProtocols(e->dpy, win->xwin, &atoms[ATOM_WM_DELETE_WINDOW], 1); -- cgit v1.2.3