Commit Graph

131 Commits

Author SHA1 Message Date
7e957f8310
added dirchanger dmenu, dmenu search 2023-03-29 22:52:23 +02:00
NRK
f2f4903de4 apply clang-format
minus the bogus changes

Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2023-03-11 18:37:04 +06:00
NRK
2434e83807 make some changes prepping for clang-format
Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2023-03-11 18:36:26 +06:00
NRK
a051ad210d update copyright year 2023-01-28 16:29:36 +06:00
NRK
6ffc64a04e img_t: rename alpha -> alpha_layer for consistency 2023-01-28 10:23:11 +00:00
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>
2022-12-22 11:21:40 +00:00
NRK
3804b50656 compress duplicated logic into a function (#384)
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/384
Reviewed-by: TAAPArthur <taaparthur@noreply.codeberg.org>
2022-11-05 00:01:56 +01:00
NRK
8dc126194f fix: statusbar not updating when switching bar (#353)
Closes: https://codeberg.org/nsxiv/nsxiv/issues/352
Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/353
Reviewed-by: explosion-mental <explosion-mental@noreply.codeberg.org>
2022-08-08 16:13:28 +02:00
NRK
c131b1ed83 fix: -Wsign-compare warnings (#336)
mixing signed and unsigned types in comparison can end up having
unintended results. for example:

	if (-1 < 1U)
		printf("true\n");
	else
		printf("false\n");

previously we silenced these warnings, instead just fix them properly
via necessary casting, and in cases where the value cannot be negative
(e.g width/height members) make them unsigned.

Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/336
Reviewed-by: explosion-mental <explosion-mental@noreply.codeberg.org>
2022-07-15 22:46:23 +02:00
NRK
b162aee497 sort and group includes
* includes are sorted alphabetically

* their grouping and layout is the following:
  - nsxiv.h will be the first include
  - followed by any internal headers (e.g "commands.h" "config.h")
  - followed by system headers (<stdlib.h> etc)
  - followed by third party headers (X.h libwebp etc)

* also add `llvm-include-order` check to clang-tidy so that it can catch
  unsorted includes during CI.
2022-06-28 21:28:06 +02:00
NRK
6d5a04005d code-style: cleanup includes
* rm unused include <sys/types.h>
* move <sys/time.h> to main.c, it's the only file that needs it.
* move TV_* macros to main.c
* let *.c files explicitly include what they need instead of including
  them at nsxiv.h
2022-06-28 21:28:06 +02:00
NRK
810a9651a3 reduce calls to win-title
rather than calling the script unconditionally per redraw, we now have
a `title_dirty` flag and keep track of when any of the relavent
information changes.

Co-authored-by: Arthur Williams <taaparthur@gmail.com>
Partially fixes: https://github.com/nsxiv/nsxiv/issues/258
2022-06-02 08:09:51 +00:00
N-R-K
3a22e6a6c5
Declare every extern function/variable in nsxiv.h (#268)
with a couple exceptions as they cause too many -Wshadow warnings.

also moves the `extcmd_t` typedef on top for cosmetic purposes.

also enable `-Wmissing-prototypes` in the ci
2022-05-03 15:36:57 +00:00
N-R-K
591be8cecf
Add thumb-info (#265)
Closes: https://github.com/nsxiv/nsxiv/issues/88
Closes: https://github.com/nsxiv/nsxiv/pull/253
2022-05-03 15:34:23 +00:00
N-R-K
29c6b1456e
code-style: reduce some unnecessary if-elses (#261)
also change the condition inside img_frame_animate() to check for
positive value rather than comparing against 0.
2022-04-27 01:25:11 +00:00
NRK
9cdeeab9b8 update copyright year 2022-02-13 19:35:58 +03:00
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.
2022-01-15 18:51:31 -04:00
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
2022-01-10 16:52:06 +00:00
NRK
80ada33c66 fix tcc warning 2022-01-06 17:53:02 +00:00
NRK
90bec70e7f fix -Wshadow related warnings
fixes all -Wshadow related warnings (on gcc). this would allow us to use
`-Wshadow` in github workflow (https://github.com/nsxiv/nsxiv/pull/195).

i've thought about adding `-Wshadow` to our Makefile as well, but
decided against it to keep the Makefile CFLAGS barebore/minimal.
2022-01-06 17:53:02 +00:00
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>
2021-12-19 23:05:35 +06:00
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>
2021-11-04 04:20:28 +00:00
NRK
d0b5005a02 -0 sends NULL separated file-list to key-handler
with this change `-0` is turned into a more generic switch which can be
used to send NULL-separated file-list to the key-handler as well.
this also means `-0` no longer implicitly enables `-o`

Closes: https://github.com/nsxiv/nsxiv/issues/140
2021-10-29 17:45:55 -06:00
N-R-K
850bc788c3
code-style: general cleanups (#137)
* tns_clean_cache: remove unused function arg

* remove malloc casting

* improve consistency

use sizeof(T) at the end

* avoid comparing integers of different signedness

* use Window type for embed and parent

* remove unnecessary comparisons

* remove cpp style comments

* improve consistency: remove comma from the end of enumerator list

* Removed useless _IMAGE_CONFIG defines

* consistency: use the same order as snprintf

* Resolve c89 warnings


Co-authored-by: uidops <uidops@protonmail.com>
Co-authored-by: Arthur Williams <taaparthur@gmail.com>
2021-10-29 02:00:53 +06:00
eylles
5b3221cfa6
update copyright notice (#139) 2021-10-28 16:41:16 +06:00
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>
2021-10-27 09:02:07 +06:00
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
2021-10-13 06:05:00 +06:00
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>
2021-10-11 09:07:18 +06:00
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.
2021-10-07 00:37:34 +00:00
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>
2021-09-25 11:11:21 +06:00
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>
2021-09-20 23:11:47 +00:00
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>
2021-09-16 22:55:31 +03:00
Bert Münnich
1613b42411 Simplify cg_mark_range further 2018-06-10 12:39:23 +02:00
Bert Münnich
1de5f06f83 Set global markidx whenever a single img is (un)marked
This also sets *markidx* when using the right mouse button in thumbnail mode.
2018-06-09 14:07:13 +02:00
Bert Münnich
87a1ace8a1 (Un)mark single image through generic function 2018-06-09 13:12:46 +02:00
Bert Münnich
1892ed9fd7 Simplify cg_mark_range 2018-06-09 12:17:03 +02:00
Bert Münnich
a1165df878 Rename variable toggledidx to markidx 2018-06-09 11:57:42 +02:00
Bert Münnich
cc476be7cc Remove unnecessary special cases in cg_mark_range 2018-06-09 11:52:48 +02:00
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.
2018-06-09 11:44:47 +02:00
Bert Münnich
762420cdf1 Close image-info explicitly 2018-02-18 14:12:41 +01:00
phi
d5c5708110 Use argument to select between two drag methods 2018-01-22 09:46:38 +01:00
Bert Münnich
148026007c One header file for type definitions and function declarations 2017-10-16 21:10:35 +02:00
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.
2017-10-06 10:15:43 +02:00
Bert Münnich
ee908ca0a1 Simplify cursor reset in image mode
No need to give cursor name. reset_cursor() is now the only place to decide
what cursor to fall back to.
2017-10-05 13:49:11 +02:00
Bert Münnich
d81442f55d Own win method for mouse cursor location 2017-10-05 13:47:02 +02:00
Bert Münnich
e310136e02 Mouse drag translates pointer position to image area
This makes mouse panning more direct and faster.
2017-10-04 18:22:43 +02:00
Bert Münnich
ff2ce99bf7 Merge djhejna/floatdelay 2016-12-01 21:18:41 +01:00
Bert Münnich
f75fa78eca Make navigate_frame command respect a count prefix 2015-12-26 15:24:08 +01:00
Bert Münnich
d3a70a285d Revised error handling
- Functions warn() and die() replaced by GNU-like error(3) function
- Register cleanup() with atexit(3)
- Functions called by cleanup() are marked with CLEANUP and are not allowed to
  call exit(3)
2015-10-28 23:03:37 +01:00
Bert Münnich
e574a6d0dd Removed feature test macro definitions from source files 2015-10-28 21:37:45 +01:00