Commit Graph

99 Commits (master)

Author SHA1 Message Date
NRK 6185bcb441 config.h: allow all values to be NULL
might as well make things consistent instead of having certain values
that can be NULL and certain that cannot.

some of the default values are still kept in config.h for example
reasons.
12 months ago
explosion-mental 3097037624 make xresources class name configurable in config.h 12 months ago
eylles 733916ad70 add a pick quit keybind (#432)
The last time[0] this was discussed, no-one was against it but no-one
was confident in it either and so it was added to nsxiv-extra as a
patch.

But now that enough time has passed, it seems like there's a pretty high
demand for something like this because there's plenty of use-cases that
use nsxiv as a "picker" where it's meant to quickly pick a single file.

And so add this as a convenient default key-bind.

[0]: https://codeberg.org/nsxiv/nsxiv-record/pulls/42

Co-authored-by: eylles <ed.ylles1997@gmail.com>
Co-authored-by: NRK <nrk@disroot.org>
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/432
Reviewed-by: NRK <nrk@disroot.org>
Co-authored-by: eylles <eylles@noreply.codeberg.org>
Co-committed-by: eylles <eylles@noreply.codeberg.org>
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
Berke Kocaoğlu 95bc9b463b add brightness and contrast (#396)
* Imlib2 supports modifying gamma, brightness and contrast directly
  while sxiv only supports gamma. Makes sense to extend it to brightness
  and contrast as well.

* Since color corrections need to be aware of each other, they have been
  refactored into one centralized function.

* This also makes the code more hackable as it makes it easier to add
  more color correction functions without them interfering with each
  other.

Co-authored-by: 0ion9 <finticemo@gmail.com>
Co-authored-by: NRK <nrk@disroot.org>
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/396
Reviewed-by: NRK <nrk@disroot.org>
Reviewed-by: TAAPArthur <taaparthur@noreply.codeberg.org>
Co-authored-by: Berke Kocaoğlu <kberke@metu.edu.tr>
Co-committed-by: Berke Kocaoğlu <kberke@metu.edu.tr>
1 year 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 becf1cc858 fix: build failure when _SC_PHYS_PAGES is not defined
_SC_PHYS_PAGES isn't POSIX and might not be defined. in such case, just
return back `CACHE_SIZE_FALLBACK`.

NOTE: POSIX says the `names` in `sysconf()` are "symbolic constants" not
necessarily macros. So we might end up returning the fallback in some
cases where `_SC_PHYS_PAGES` *was* available, but not defined as a
macro. which is not ideal, but nothing fatal.

in practice, this shouldn't be an issue since most systems seems to
define them to be macros, i've checked Glibc, Musl, OpenBSD, FreeBSD and
Haiku.

also add a (useful) comment on `config.h` describing the effect higher
cache size has.

Closes: https://codeberg.org/nsxiv/nsxiv/issues/354
2 years ago
NRK b28449e10c fix: don't use reserved identifiers
identifiers beginning with an underscore is reserved by the C standard.
2 years ago
NRK bdd9521bf3 code-style: slight cleanups
* put TOP_STATUSBAR under the HAVE_LIBFONTS guard
* change get_win_title param to take unsigned char ptr
* init UTF8_STRING like other atoms
2 years ago
N-R-K bda70867ac
add config.h option for top statusbar (#231)
Closes: https://github.com/nsxiv/nsxiv/issues/230
Co-authored-by: mamg22 <45301823+mamg22@users.noreply.github.com>
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
Nick Hanley 2ac44709bd
Add keybind to scroll to image center (#203)
There are keybinds for scrolling to the edges of an image but there's no way back to the center. This is particularly annoying while zooming.
2 years ago
N-R-K 7a75c42b37
make thumbnail bindings configureable via config.h (#167)
this allows for configuring thumbnail mode mouse bindings similar to
image mode bindings.

however we can't put the thumbnails bindings into the existing buttons[]
array due to fallthrough. For example M3 would switch mode and then end
up selecting an image.

which is why thumbnail bindings have been put into it's own array
`buttons_tns[]` and `buttons[]` has been renamed to `buttons_img[]` for
consistency.

Closes: https://github.com/nsxiv/nsxiv/issues/131
2 years ago
MahouShoujoMivutilde e777adf985
Allow setting cache size based on memory percentage (#184)
The problem:

1. For the most people imlib2's default 4MiB is unreasonably low;

2. Hardcoding cache size to ~256MiB has performance benefits and doesn't
   increase RAM usage too much on relatively modern systems;

3. But we can't do that, because that would be detrimental to low spec systems
   that (apparently) not (?) building nsxiv from source, as been discussed
   #171

Solution:

Calculate cache size based on total memory.

Default is set as 3%, which means:
* ~245MiB for 8GiB
* ~30MiB for 1GiB
* and so on

CACHE_SIZE_LIMIT (256MiB by default) sets the highest possible value. And in
case we cannot determine the total memory (e.g since _SC_PHYS_PAGES isn't
POSIX) use CACHE_SIZE_FALLBACK (32MiB by default) instead.

Co-authored-by: NRK <nrk@disroot.org>
2 years ago
N-R-K 1a691d42f6
fix: broken compilation when using HAVE_LIBFONTS=0 (#194)
compilation currently fails with `make HAVE_LIBFONTS=0` due to
`EXIT_SUCCESS` not being defined. I assume Xft.h includes stdlib.h which
is why compilation works with HAVE_LIBFONTS=1

this switches to using 0 as cg_quit argument in keybindings. if my
interpretation of the C99 standard is correct, then 0 and EXIT_SUCCESS
means the same thing.

> If the value of status is zero or EXIT_SUCCESS, an
> implementation-defined form of the status successful termination is
> returned.
2 years ago
N-R-K ff88908531
specify func argument and related cleanup (#183)
* specifies the function argument type in commands.h compared to leaving
  it unspecified. all the functions in cmd_t must have arg_t as it's
  argument.
* changes to commands.h will now trigger a rebuild - this restores old
  behavior prior to 12efa0e
* cg_quit now uses it's argument as exit status
* DestroyNotify invokes cg_quit rather than calling exit directly.
* Explicitly pass EXIT_SUCCESS to cgquit in keybinding

Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
3 years ago
N-R-K 79b8fefcc4
bring back zoom_levels (#156)
this still keeps the shorter zoom logic, but adds back the zoom_levels
array so that stay close to sxiv.

for users who would like to have the zoom step behavior see:
https://github.com/nsxiv/nsxiv/pull/156#issuecomment-975182631
3 years ago
N-R-K 0639047dde allow configuring imlib2's cache size (#171)
by default imlib2 uses a 4mb cache, which is quite small. this allows
users who have more memory to spare to set a bigger cache size and avoid
reloading an already viewed image if it fits into the cache.

Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
3 years ago
N-R-K 4396031233
switch back to whitelisting modifers (#150)
* Revert "Allow any set of modifiers to be used in keybindings"

this keeps things equal with sxiv while giving users possibility to
customize USED_MODMASK if they wish.

This reverts commit 3234b0e521.

Closes: https://github.com/nsxiv/nsxiv/issues/149
Closes: https://github.com/nsxiv/nsxiv/issues/123

Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
3 years ago
N-R-K 0262988671
rename: keyhandler_abort -> KEYHANDLER_ABORT (#172)
with the exception of arrays, all other var names in config.h are in ALL
CAPS. since keyhandler_abort is an unreleased feature, it should be okay
to rename it for consistency.

though.. in the future we should be more careful about naming when
adding new vars to config.h (or the codebase in general.)
3 years ago
LuXu 36f42081d0
make width of navigation area configurable (#155)
this allows users to configure navigation width from config.h. it also
allows disabling the navigation function entirely by using a 0 width.

one extra functionality this adds is being able to define an absolute
width (in pixels) instead of just percentage via `NAV_IS_REL`.

Co-authored-by: NRK <nrk@disroot.org>
3 years ago
Arthur Williams 8934744c60 Add colors and fonts to config.h (#115)
Adds a set of config vars to control window fg/bg, bar fg/bg, mark
color and bar font. This allows everything that can be done from
.Xresources to be configurable from config.h.

Co-authored-by: N-R-K <79544946+N-R-K@users.noreply.github.com>
3 years ago
LuXu 57754572bc Add default key-binding for DRAG_RELATIVE (#117)
Ctrl-Button1 now has a relative drag using the XC_fleur cursor.
XC_fleur is normally the cursor for "size all" action, which has 4
arrows pointing to 4 directions.

Co-authored-by: NRK <nrk@disroot.org>
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
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
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
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
NRK 4ec8fd5377 make keyhandler abort key configurable via config.h 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 f37fa0975f config.def.h: change enums to static const ints 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
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
Berke Kocaoğlu 88f77bc59c Implement fill scale mode 3 years ago
Bert Münnich 7bde7e618a Change colors and font only via X resources 5 years ago
vxid 4407a3de54 Add Xresources font support 5 years ago
Bert Münnich 24cce54ea0 New colors 5 years ago
Bert Münnich d5b8242706 Mention X resource properties in build-time color config 5 years ago
Bert Münnich 919ada1123 Align compile-time color options with X resource colors
Two colors are more than enough!
5 years ago
Bert Münnich 9d244da512 Simplify X resource retrieval
Also makes the color names in config.def.h constant again.
5 years ago
noamcore 4853e17b83 Add Xresources capability 5 years ago
Bert Münnich 7efcf55a5f Change default key-bindings of mark commands
*Shift-m* feels much more natural for *mark_range* and *Ctrl-u* is decent
enough for *unmark_all*.
6 years ago
Daniel Lublin 6e696ba98c Add mark range function
Sets the marked state of all images ranging from the latest marked/unmarked
image to the current image, to the state of that latest toggled image.
6 years ago
phi d5c5708110 Use argument to select between two drag methods 6 years ago
Bert Münnich 8081cbebf3 Improve mouse support
None of the mouse mappings uses a keyboard modifier, making it possible to
access the most basic features by only using the mouse.

Next/previous image with left button depending on cursor position, middle
button for dragging, right button for switching to thumnail mode and wheel for
zooming.

Users can keep the old behaviour by simply not adapting the changes to the
buttons array in config.def.h to their config.h file.
7 years ago
jcalve ec545a6b6c Make pan fraction configurable 7 years ago
Bert Münnich c280129cef Use Xft for font loading and text drawing 8 years ago
Bert Münnich de4649fc28 Build-time option for default thumbnail size; fixes issue #207 9 years ago
Bert Münnich 5dc7993478 Simplified command arguments 10 years ago
Bert Münnich 47e6cd0669 Apply gamma value on thumbnails too; fixes issue #193 10 years ago