aboutsummaryrefslogtreecommitdiffstats
path: root/main.c
AgeCommit message (Collapse)Author
2022-03-27fix: thumbnail memory leak when removing file (#247)N-R-K
2022-03-17fix: close the file descriptor in get_win_title() (#245)N-R-K
this would eventually end up opening too many fds and erroring out with "too many open files".
2022-03-02always initialize window titleNRK
before if exec/win-title didn't exist then window title wouldn't be set. this patch makes it so window title is always set to something.
2022-03-02code-style: slight cleanupsNRK
* put TOP_STATUSBAR under the HAVE_LIBFONTS guard * change get_win_title param to take unsigned char ptr * init UTF8_STRING like other atoms
2022-02-23use win-title script for customizing window title (#213)N-R-K
this removes the cli flag `-T` as well as related config.h options. Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2022-02-20Add reuseable abstraction over fork/exec/dup2 (#211)N-R-K
2022-02-17declare internal variables as staticNRK
2022-02-17code-style: prefer calloc over malloc+memsetNRK
2022-02-13update copyright yearNRK
2022-01-10make thumbnail bindings configureable via config.h (#167)N-R-K
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-06fix -Wshadow related warningsNRK
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-03fix: reset statusbar after failed keyhandler (#191)N-R-K
currently if the keyhandler invocation fails, for example due to it not being present, the statusbar does not reset and stays on "getting keyhandler input" message. now the return value from run_key_handler() is used to determine if the function was successful or not. and if the function failed, we call handle_key_handler() with false which resets the statusbar. we also no longer call redraw() within run_key_handler() and instead assign it's return value to dirty which does a redraw if true.
2022-01-02fix: animation slowdown when zoomed in (#200)N-R-K
rendering is a pretty expensive operation, especially when scaling with anti-aliasing. by waiting for the image to render before setting timeout, the actual timeout ends up being (render time + actual delay). this pretty much fixes the slowdown entirely on all the images i've tested. it should also improve things noticeably even in cases where the delay between frames is shorter than how fast we can render. although on such images, the issue may not be fixed entirely. Closes: https://github.com/nsxiv/nsxiv/issues/70
2021-12-19specify func argument and related cleanup (#183)N-R-K
* 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-01fix: send implicit_mod to process_bindings (#176)N-R-K
* fix: send implicit_mod to process_bindings this solves the edge case where someone might have `ShiftMask + A` in their keybindings compared to a plain `A`. Closes: https://github.com/nsxiv/nsxiv/pull/166#issuecomment-978853136 * code-style: smuggle small style fix in win_draw_bar now mimics autoreload_nop.c functions
2021-11-24switch back to whitelisting modifers (#150)N-R-K
* 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 3234b0e521cca006a94cb135a88d146122d7f66d. 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>
2021-11-24rename: keyhandler_abort -> KEYHANDLER_ABORT (#172)N-R-K
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.)
2021-11-20mark functions and vars as static (#146)N-R-K
the goal here to mark functions and variables not used outside the translation unit as static. main reason for this is cleanliness. however as a side-effect this can help compilers optimize better as it now has guarantee that a certain function won't be called outside of that translation unit. one other side-effect of this is that accessing these vars/function from config.h is now different. if one wants to access a static var/func from different translation unit in config.h, he would have to create a wrapper function under the right ifdef. for static functions one would also need to forward declare it. here's a dummy example of accessing the function `run_key_handler` from config.h under _MAPPINGS_CONFIG ``` static void run_key_handler(const char *, unsigned); bool send_with_ctrl(arg_t key) { run_key_handler(XKeysymToString(key), ControlMask); return false; } ```
2021-11-19set env var NSXIV_USING_NULL for key-handler and update docsNRK
Co-authored-by: Berke Kocaoğlu <berke.kocaoglu@metu.edu.tr>
2021-11-19apply -0 to stdin/-i as wellNRK
while i was initially against this since it can be done via `xargs -0`. the problem with this approach is that there's a limit to how many args a command can recieve, leading to problem like this [0] when opening large (1k~) amount of images. there's no limit on how big stdin can be, so being able to read a null-separated list from stdin doesn't have this problem. [0]: https://github.com/ranger/ranger/pull/2307#issuecomment-818683515
2021-11-19use dedicated function to process key/button bindings (#166)N-R-K
Co-authored-by: Arthur Williams <taaparthur@gmail.com>
2021-11-04make width of navigation area configurable (#155)LuXu
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-10-30-0 sends NULL separated file-list to key-handlerNRK
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-28code-style: general cleanups (#137)N-R-K
* 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-28update copyright notice (#139)eylles
2021-10-24code-style: remove extra casts (#130)javad
Co-authored-by: N-R-K <79544946+N-R-K@users.noreply.github.com>
2021-10-13Add ability to bind arbitrary functions.Arthur Williams
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-13Make imgcursor a config variable.Arthur Williams
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.
2021-10-11code-style: fix consistency issues all over the codebase (#94)Berke Kocaoğlu
* 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-07add statusbar message upon key-hander activation (#98)N-R-K
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-09-29make ten_ms local to run (#101)N-R-K
ten_ms needed to be a global but after the following commit 3724d3fc17dc6135a05608cab5bdf00c6978282d this no longer holds true. it can simply be local to run, as it's not used anywhere else.
2021-09-24make keyhandler abort key configurable via config.hNRK
2021-09-24fix: unable to bind anything to XK_EscapeNRK
2021-09-20Allow any set of modifiers to be used in keybindingsArthur Williams
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>
2021-09-16Rename, Update Docs and Prepare for Release (#9)Berke Kocaoğlu
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-16Exit when window is destroyedArthur Williams
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.
2021-09-16set title based on prefix and suffix (#23)qsmodo
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>
2020-01-16Fix indentationBert Münnich
2019-07-16Do not keep track of fullscreen stateBert Münnich
There is no more need for this after the removal of the special color handling for fullscreen mode in commit 2886876.
2018-12-29Fix file list indexes when deleting last imageBert Münnich
Fixes issue #331
2018-10-15Set window title only once at startupBert Münnich
Putting image info in the title predates the info bar; it no longer seems necessary. Fixes issue #318.
2018-07-30Don't skip dot files when cleaning cacheKacper Gutowski
2018-06-09Set global markidx whenever a single img is (un)markedBert Münnich
This also sets *markidx* when using the right mouse button in thumbnail mode.
2018-06-09(Un)mark thumbnails while holding Button3 downBert Münnich
2018-06-09(Un)mark single image through generic functionBert Münnich
2018-06-09Rename variable toggledidx to markidxBert Münnich
2018-06-09Fix cg_mark_range after removing images from file listBert Münnich
2018-06-09Remove unnecessary special cases in cg_mark_rangeBert Münnich
2018-06-09Add mark range functionDaniel Lublin
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-02-18Revise waiting for child processesBert Münnich