Commit Graph

812 Commits (12efa0e3b429675047cb2900d49e1f38afeb650b)
 

Author SHA1 Message Date
Arthur Williams 12efa0e3b4 Add ability to bind arbitrary functions.
Before all the predated commands where kept in an array and their
indexes were used in bindings. This meant that users couldn't add their
own functions from the config file. Now key/mouse bindings have been
changed to to store the function ptr (wrapped in a cmd_t struct to also
store the mode) directly instead.

General cleanup done in this commit:
Defined `MODE_ALL` instead of using magic number.

For example, suppose one had bindings like:
{ 0,                   XK_q,             g_quit,                     None },
{ ShitMask,            XK_q,             {quit_err},                 None }
{ ControlMask,         XK_q,             {quit_err, .mode=MODE_IMAGE}, None }

The existing binding `q` has been left unchanged and is defined the same
way. However, the new hypothetical binding `Shift-q` can be used to call
the custom function quit_err in any mode (default). `Ctrl-q` on the
other hand will be called only on image mode.

Closes #50
3 years ago
Arthur Williams 5c6947c1c6 Make imgcursor a config variable.
Previously, the value of imgcursor was determined by where a pointer
binding was set to a ci_cursor_navigate. If it was then the pointer
would change to left/right arrows depending on the position relative to
the window. Now the user has full control of over it which also allows
them to preserve the behavior in case they wrap the function.
3 years ago
miseran cd710f583f
Fix behaviour when TrueColor / 24 bit depth is not available (#114)
* Fix regression introduced in c7ca547 which made nsxiv not start in
  non-TrueColor X server.
* Introduce a new fix for embedding into tabbed-alpha. 
* Fixes a visual glitch from original sxiv when drawing transparent images in 8
  bit depth. In 8 bit PseudoColor, `.pixel` is just an index into the 256
  defined colors and thus trying to extract rgb bits from it would result in
  visual glitch. The values `.color.red` on the other hand and so on are always
  integers between 0 and 0xFFFF representing the color as expected.
* Use XColor for win_bg/fg and mrk_fg

Co-authored-by: NRK <nrk@disroot.org>
3 years ago
Berke Kocaoğlu 1449bfc5e9
code-style: fix consistency issues all over the codebase (#94)
* remove duplicate comment
* remove empty tabs and blank lines
* move macros and globals ontop
* comment to seprate function implementation
* fix alignment
* switch to *argv[] similar to other suckless code
* kill all empty last lines
* append comment to endif
* reuse existing ARRLEN macro
* comment fall through
* use while (true) everywhere

Co-authored-by: NRK <nrk@disroot.org>
3 years ago
Arthur Williams 675db4bbb6 Make statusbar optional (#95)
libXft and libfontconfig are now optional dependencies which can be
disabled via `HAVE_LIBFONTS=0`. Disabling them means disabling the
statusbar. This also does not search for freetype2 header if disabled.

Co-authored-by: NRK <nrk@disroot.org>
3 years ago
N-R-K 6ce94e3e3b
add statusbar message upon key-hander activation (#98)
Currently when running the key-handler the statusbar shows a
"Running key-handler..." message, but there's no indication of the prefix key
being pressed.

There's a slight functional benefit of this patch in the sense
that users can visually tell if the key-handler is listening on input or if the
key-handler has been aborted or not.
3 years ago
N-R-K e8d08ba67e
Rework build system v2 (#71)
* Remove non-POSIX extensions and commands
* Drop autodetection in favor of OPT_DEP_DEFAULT
* Use += for LDLIBS as some BSD distros need to add extra flags
* Change DOCPREFIX -> EGPREFIX
* Use ?= for MANPREFIX and EGPREFIX
* Update docs

With this, we should have a stable build system. No further significant
changes should be needed.
3 years ago
N-R-K 1dc936d0ee
Move over to nsxiv-extra (#100)
* change wiki links to nsxiv-extra

* add User patches section

* link to Project-Scope and Contribution-Guideline directly
3 years ago
N-R-K d3a296a0be
fix wrong bar.* defaults in manpage (#106) 3 years ago
N-R-K 065562d3c5
update outdated comment in config.def.h (#105)
we're not using 'background', 'foreground' and 'font' anymore.
see: 0b20783 and f7557c5
3 years ago
N-R-K 0c66c0e25f
make ten_ms local to run (#101)
ten_ms needed to be a global but after the following commit
3724d3fc17 this no longer holds true.
it can simply be local to run, as it's not used anywhere else.
3 years ago
N-R-K 80c5a1cd9f
fix: crashing on bad exif thumbnail (#75)
this does not need to be a fatal error.
if im is NULL we're going to load it with imlib2 anyways.

one other problem this solves is that before, due to the fatal error,
the tmpfile opened under /tmp wouldn't get cleaned up.

Closes: https://github.com/nsxiv/nsxiv/issues/69
3 years ago
N-R-K 0ee05d29f0
Clarify comment in example key-handler (#89)
currently, the key-handler will not receive the `S-` modifier if there's
a capital equivalent of that KEY.
if https://github.com/nsxiv/nsxiv/pull/78 is to be merged, then this
behaviour may change.

however as it currently stands, we should fix the comment. we can update
it later if needed.

Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
3 years ago
Lu Xu a2339e70fd Use zoom steps instead of hard-coding levels (#92)
Co-authored-by: NRK <nrk@disroot.org>
Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
3 years ago
Berke Kocaoğlu 696f68753f
Rename icon & desktop and add install-all in Makefile (#96)
* Rename in Makefile

Renamed {icon,desktop} => install-{icon,desktop}

* Add install-all in Makefile

* Added .PHONY targets and renamed icon_cleanup

Added .PHONY targets and renamed icon_cleanup to uninstall_icon

* Update README.md

Co-authored-by: TAAPArthur <taaparthur@gmail.com>
3 years ago
NRK 4ec8fd5377 make keyhandler abort key configurable via config.h 3 years ago
NRK 3bec517655 fix: unable to bind anything to XK_Escape 3 years ago
Sam Whitehead af98249b68 Add animated webp support (#20)
Co-authored-by: NRK <nrk@disroot.org>
Co-authored-by: Stein Gunnar Bakkeby <bakkeby@gmail.com>
Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
3 years ago
Berke Kocaoğlu 0e7ab7e5c3
Fix consistency in readme (#93) 3 years ago
Guilherme Rugai Freire de9a285ff2
Add desktop and icon rules to Makefile, document icon installation (#80)
Co-authored-by: NRK <nrk@disroot.org>
3 years ago
Berke Kocaoğlu 9e22f32c07
Change location of example scripts (#86)
* Use DOCPREFIX similar to MANPREFIX

Co-authored-by: NRK <nrk@disroot.org>
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
NRK ff8a8469fe move -0 to bottom in the manpage 3 years ago
NRK 1f69a05abc document new -0 option in manpage 3 years ago
N-R-K c093eae971
code-style: use constant length array (#79)
currently the code-base doesn't make use of variable length array
despite being -std=c99. it was irresponsible of me to introduce VLA in
here.

since this function will be called quite often, i did not want to make
calls to malloc and free as they have some overhead.

512 should be sufficient enough and probably is far bigger than any
window title bar can display anyways.
3 years ago
NRK 9c3310b676 better document what the optional deps do
currently the README only mentions what deps are optional but has no
info on what they do. we had an issue where a user was confused about
what libexif is used for : https://github.com/nsxiv/nsxiv/issues/58

this makes it clear what each of the optional deps do so that users can
make more informed decision on weather they want something or not.
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
Arthur Williams 3234b0e521 Allow any set of modifiers to be used in keybindings
Previous the code only allowed ShiftMask,ControlMask or Mod1Mask to be
used in keybindings and the presence of any others modifiers would be
ignored. Most problems generally allow certain modifiers to be be
ignored but not most and certainly don't allow Super-A to be treated
like A.
Now users can use any modifiers they want in keybindings and can also
ignore any modifiers they want. By default only ModMask2 (commonly
numlock is ignored)

Co-authored-by: N-R-K <79544946+N-R-K@users.noreply.github.com>
3 years ago
NRK 24e70a99e3 Stable version 27.1 3 years ago
NRK 7244e252aa fix build when not git cloned 3 years ago
Berke Kocaoğlu 3ef355bccc Fix links in changelog and readme 3 years ago
Berke Kocaoğlu a674cb07c5
Stable version 27 3 years ago
NRK f37fa0975f config.def.h: change enums to static const ints 3 years ago
NRK 25a5a54010 add .mark.foreground to Xresources
since we're already allowing both window and bar colors to be
customizable, it doesn't make sense to not allow so for mark color.
3 years ago
NRK 956faac00c cleanup docs 3 years ago
Sam Whitehead 0d8dcfd521
Fix font memory leak. (#57)
* Fix font memory leak.

This memory leak has always been present in sxiv.

The font opened on window.c:58 was never closed, so I closed it, fixing a 2kB memory leak.

* document changes

Co-authored-by: NRK <nrk@disroot.org>
3 years ago
N-R-K 0b20783164 change .font to .bar.font for consistency (#48) 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
Arthur Williams 9c73646d9c Exit when window is destroyed
If the user closed our window, the program won't automatically be die.
It may look dead as there would be no graphical indication that it was
running, but it still would be using/wasting the same resources.
Now the program will abruptly exit when its window is killed.
3 years ago
TAAPArthur 25a3114709 Rework the build system (#19)
* Added simple configure script

Added simple script to autodetect if optional dependencies are installed
and enable/disable them as needed. Note this solution uses the compiler
directly instead of an external program like pkgconfig so it doesn't
require any extra dependencies. It is intended to work with any
arbitrary compiler; it has been tested with tcc and gcc.

There are some "breaking" changes hidden here
- HAVE_GIFLIB was renamed to HAVE_LIBGIF to match HAVE_LIBEXIF
- Simply typing `make` will no longer try to build with optional
  dependencies

* use implicit RM variable

* General clean-up in configure

- Use printf instead of echo
- Format style

* honor env PREFIX, use LDLIBS

* Revert "General clean-up in configure"

This reverts commit 8683c179db.

* honor env LDFLAGS if set

* Don't set OPTIONAL_LIBS in configure

* make OBJ all caps

* follow suckless style build system

- remove configure script.
- HAVE_LIBGIF and HAVE_LIBEXIF defaults back to 1
- unload several varibales onto config.mk
- make version all-caps
- add -O2 optimization
- use CPPFLAGS for includes and defines

* Revert "follow suckless style build system"

This reverts commit 8bf75b1f68.

* Generate config.mk from make

* Inlined configure in Makefile

* update docs

* cleanups

- changes to config.mk should trigger a rebuild
- remove potentially confusing variables form Makefile

* Use install instead of mkdir/cp/chmod when sensible

* fixup! Inlined configure in Makefile

* Don't generate config.mk on rm -f *.o sxiv

* update docs and cleanups

- make config.mk silent
- mention editing config.mk in README

* fallback to 0 if user edits config.mk in unexpected way

* add comment on config.mk

* remove invalid comment

configure script is removed

* slight restructure

- make version all caps
- restructure variables that users may want to edit to top
- use CPPFLAGS for defines
- add some comments
- remove needless echos since we have verbose output now

* add echos back

Co-authored-by: NRK <nrk@disroot.org>
Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
3 years ago
whowillbellthecat cca7834e67 fix: out-of-bounds access when bg not in color map 3 years ago
eylles cbec6991c2 add an editorconfig file, closes #25 3 years ago
Aman Verma 68083784b6 Advertise Webp support in desktop file. 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
NRK 91d9b3128e change gamma on -G
Closes: https://github.com/nsxiv/nsxiv/issues/30
3 years ago
N-R-K ca692ac485 add new keybind, Ctrl-a to toggle animation (#33)
* add new keybind, Ctrl-a to toggle animation

Closes: https://github.com/nsxiv/nsxiv/issues/27

* Format consistency

This keeps in line with other actions that have multiple keybinds

Co-authored-by: eylles <ed.ylles1997@gmail.com>
Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
3 years ago
Guilherme Freire f7557c55b5 Custom bar colors (#10)
* set bar and text colors independently

* change xresources to Program.class.resource

* rename color variables to win/bar_bg/fg

* change default bar colors to match window colors
3 years ago
eylles d8ec6f91a9 Set the _NET_WM_PID and WM_CLIENT_MACHINE X properties (#13)
Set the _NET_WM_PID and WM_CLIENT_MACHINE X properties

Co-authored-by: Leon Kowarschick <lkowarschick@gmail.com>
Co-authored-by: Kian Kasad <kian@kasad.com>
Co-authored-by: NRK <nrk@disroot.org>
3 years ago
eylles 46a54c4b2d Fix documentation (#14)
* Update manpage for marking commands

* Fix hyphen-used-as-minus-sign and typo lintian warning in manpage
this fix was originally made by the debian mantainer for sxiv Daniel Echeverry <epsilon77@gmail.com>

Co-authored-by: Mihail Snitkovski <msnitkovski@gmail.com>
3 years ago