Commit Graph

146 Commits

Author SHA1 Message Date
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
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>
2021-10-11 23:46:35 +00: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
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>
2021-10-10 02:17:50 +06:00
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
2021-09-29 06:44:46 +03:00
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.
2021-09-17 02:32:11 +06: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
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>
2021-09-16 22:55:31 +03:00
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
2021-09-16 22:55:31 +03:00
Bert Münnich 28868767e6 Use normal win colors in fullscreen mode
Fixes issues #361 and #367
2019-07-16 19:18:13 +02:00
Bert Münnich 7b813ea06d Fix comparison broken by signedness
Warning generated on MacOS, reported in issue #350.
2019-03-15 13:04:15 +01:00
Bert Münnich 919ada1123 Align compile-time color options with X resource colors
Two colors are more than enough!
2019-01-23 21:21:15 +01:00
Kacper Gutowski e648c11899 Respect updated path format when cleaning cache
Since d8114e8 the file name is used for caching as-is without adding
.jpg at the end, but sxiv -c still expected old format causing it to
remove all fresh thumbnails.
2018-07-30 10:33:23 +02:00
Kacper Gutowski e6c9218319 Don't skip dot files when cleaning cache 2018-07-30 10:28:35 +02:00
Bert Münnich f02661879f Reject text files resembling TGA images
Fixes issue #295

The imlib2 TGA loader returns an imlib image handle without any actual data
when given a text file like this:

    T
    Content-Type: application/javascript
    Content-Length: 3836
    Last-Modified: Wed, 23 Sep 2015 12:25:47 GMT
    Etag: "56029a4b-efc"
    Expires: Sat, 20 Aug 2016 15:14:33 GMT
    Cache-Control: max-age=604800, public
    Accept-Ranges: bytes

Fortunately, `imlib_image_get_data()` returns NULL in this case, so that we can
use it as an additional check when opening files.
2017-11-23 14:35:34 +01:00
Bert Münnich 148026007c One header file for type definitions and function declarations 2017-10-16 21:10:35 +02:00
Antti Korpi ecc363ec10 Add -p flag to disable writing of cache and temporary files
Closes #285.
2017-09-08 22:04:44 +02:00
Bert Münnich 1c260e701b Fix unused-variable warnings in conditionally compiled code 2016-12-28 19:18:16 +01:00
Bert Münnich 878d97068c Only open regular files; fixes issue #252 2016-10-20 10:21:55 +02:00
Paride Legovini 86dc6860f9 Allow opening directories non-recursively 2016-09-28 19:27:48 +02:00
Bert Münnich c280129cef Use Xft for font loading and text drawing 2016-08-06 15:27:58 +02:00
Bert Münnich de4649fc28 Build-time option for default thumbnail size; fixes issue #207 2015-12-20 13:10:39 +01:00
Bert Münnich a7d39b0ab8 Simplified r_mkdir() 2015-10-28 23:21:12 +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 851e4288c1 Prefix safe allocation functions with 'e' instead of 's_' 2015-10-28 22:29:01 +01:00
Bert Münnich e574a6d0dd Removed feature test macro definitions from source files 2015-10-28 21:37:45 +01:00
Bert Münnich e0e96977b3 Removed overcautious parameter checks 2015-10-28 21:01:24 +01:00
Bert Münnich d8114e841c Thumbnail cache file format depending on existance of alpha layer
Use PNG if image has alpha layer, JPG if not. Fixes issue #209
2015-07-22 21:08:00 +02:00
Bert Münnich 47af0dd7b5 Cache out of view thumbnails in the background 2015-01-04 21:24:43 +01:00
Bert Münnich 9b9294bae6 Use bit-field for boolean flags in fileinfo struct 2015-01-04 21:24:43 +01:00
Bert Münnich ed030fe4d3 Enforced thumbnail reloading after key handler 2014-11-27 22:24:18 +01:00
Bert Münnich 728a2d931f Limit thumbnail selection border width to 4px 2014-11-27 22:23:14 +01:00
Bert Münnich d154b9826f Do not cache thumbnails, which are smaller than the maximum size 2014-10-31 10:41:33 +01:00
Bert Münnich eb5feb4585 Discard cached & EXIF thumbnails, which are smaller than the configured maximum size 2014-10-31 10:41:30 +01:00
Bert Münnich f5f49e7a9d Fixed leakage of resources allocated by EXIF library 2014-10-31 10:37:35 +01:00
Bert Münnich 25077ac764 Fixed segfault when run with -c 2014-10-29 14:20:54 +01:00
Bert Münnich 93e2a757d4 Do not print could-not-open-warnings for files found by directory traversal 2014-10-24 11:14:01 +02:00
Bert Münnich ddd028eb3e Unified file count variable for image & thumbnail mode 2014-09-30 21:54:17 +02:00
Bert Münnich b4096c59e4 Set JPEG quality for thumbnail cache files 2014-09-29 14:06:24 +02:00
Bert Münnich 390d771e70 Fixed thumbnail creation for files with big aspect ratio factor; fixes issue #175 2014-09-29 14:05:04 +02:00
Bert Münnich 0e4db69ff5 Scale thumbnail selection border width with thumbnail size 2014-09-29 09:36:43 +02:00
Bert Münnich 39671a149c Moved thumbnail sizes array to config.def.h 2014-09-29 09:02:29 +02:00
Bert Münnich 8fa7247f69 Refactored thumbnail size dependent calculations 2014-09-29 08:47:01 +02:00
Bert Münnich 7b91e10f22 Added thumbnail zooming...
- Key mappings +/- are now general commands
- Use JPG as thumbnail cache file format instead of PNG
- Fixes issue #161
2014-09-28 00:28:50 +02:00
Bert Münnich b2dbd2fed3 Changed image mark in thumbnail view to small rectangle 2014-09-27 22:05:21 +02:00
Bert Münnich eaa269b6cb Revised thumbnail loading...
- Only load the thumbnails that are currently visible in the window
- Unload thumbnails that are leaving the visible area
- Much less memory needed, but scrolling is now slower
- This also unintentionally fixes issue #86
2014-09-26 10:31:03 +02:00
Markus Elfring 0f6cb93a09 Bug #165: Deletion of unnecessary null pointer checks
The function "free" performs input parameter validation.
http://pubs.opengroup.org/onlinepubs/9699919799/functions/free.html

It is therefore not needed to check a passed pointer before this function call.
A corresponding update suggestion was generated by the software "Coccinelle"
from the following semantic patch approach.
http://coccinelle.lip6.fr/

@Remove_unnecessary_pointer_checks1@
expression x;
@@
-if (x != \(0 \| NULL\))
    free(x);

@Remove_unnecessary_pointer_checks2@
expression x;
@@
-if (x != \(0 \| NULL\)) {
    free(x);
    x = \(0 \| NULL\);
-}

@Remove_unnecessary_pointer_checks3@
expression a, b;
@@
-if (a != \(0 \| NULL\) && b != \(0 \| NULL\))
+if (a)
    free(b);

@Remove_unnecessary_pointer_checks4@
expression a, b;
@@
-if (a != \(0 \| NULL\) && b != \(0 \| NULL\)) {
+if (a) {
    free(b);
    b = \(0 \| NULL\);
 }

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
2014-08-22 19:24:08 +02:00
Bert Münnich 056624548a Beautified thumbnail marks and selection border 2014-08-18 15:42:10 +02:00
Bert Münnich fe3a1e326f Further simplified thumbnail marks 2014-08-18 12:45:32 +02:00