Commit Graph

146 Commits (850bc788c3fd4bb96f425ceedfe4237754cabe46)

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>
3 years ago
eylles 5b3221cfa6
update copyright notice (#139) 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 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
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
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
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
Bert Münnich 28868767e6 Use normal win colors in fullscreen mode
Fixes issues #361 and #367
5 years ago
Bert Münnich 7b813ea06d Fix comparison broken by signedness
Warning generated on MacOS, reported in issue #350.
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
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.
6 years ago
Kacper Gutowski e6c9218319 Don't skip dot files when cleaning cache 6 years ago
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.
7 years ago
Bert Münnich 148026007c One header file for type definitions and function declarations 7 years ago
Antti Korpi ecc363ec10 Add -p flag to disable writing of cache and temporary files
Closes #285.
7 years ago
Bert Münnich 1c260e701b Fix unused-variable warnings in conditionally compiled code 8 years ago
Bert Münnich 878d97068c Only open regular files; fixes issue #252 8 years ago
Paride Legovini 86dc6860f9 Allow opening directories non-recursively 8 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 a7d39b0ab8 Simplified r_mkdir() 9 years ago
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)
9 years ago
Bert Münnich 851e4288c1 Prefix safe allocation functions with 'e' instead of 's_' 9 years ago
Bert Münnich e574a6d0dd Removed feature test macro definitions from source files 9 years ago
Bert Münnich e0e96977b3 Removed overcautious parameter checks 9 years ago
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
9 years ago
Bert Münnich 47af0dd7b5 Cache out of view thumbnails in the background 10 years ago
Bert Münnich 9b9294bae6 Use bit-field for boolean flags in fileinfo struct 10 years ago
Bert Münnich ed030fe4d3 Enforced thumbnail reloading after key handler 10 years ago
Bert Münnich 728a2d931f Limit thumbnail selection border width to 4px 10 years ago
Bert Münnich d154b9826f Do not cache thumbnails, which are smaller than the maximum size 10 years ago
Bert Münnich eb5feb4585 Discard cached & EXIF thumbnails, which are smaller than the configured maximum size 10 years ago
Bert Münnich f5f49e7a9d Fixed leakage of resources allocated by EXIF library 10 years ago
Bert Münnich 25077ac764 Fixed segfault when run with -c 10 years ago
Bert Münnich 93e2a757d4 Do not print could-not-open-warnings for files found by directory traversal 10 years ago
Bert Münnich ddd028eb3e Unified file count variable for image & thumbnail mode 10 years ago
Bert Münnich b4096c59e4 Set JPEG quality for thumbnail cache files 10 years ago
Bert Münnich 390d771e70 Fixed thumbnail creation for files with big aspect ratio factor; fixes issue #175 10 years ago
Bert Münnich 0e4db69ff5 Scale thumbnail selection border width with thumbnail size 10 years ago
Bert Münnich 39671a149c Moved thumbnail sizes array to config.def.h 10 years ago
Bert Münnich 8fa7247f69 Refactored thumbnail size dependent calculations 10 years ago
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
10 years ago
Bert Münnich b2dbd2fed3 Changed image mark in thumbnail view to small rectangle 10 years ago
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
10 years ago
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>
10 years ago
Bert Münnich 056624548a Beautified thumbnail marks and selection border 10 years ago
Bert Münnich fe3a1e326f Further simplified thumbnail marks 10 years ago