Commit graph

340 commits

Author SHA1 Message Date
Nicolas Cornu ffffb53a1d Add command 'X' to remove image from disk too 2017-03-06 16:46:33 +01:00
Mark Oteiza f489b0363b Show image scale in window title 2017-02-09 20:29:41 +00:00
Harry Jeffery 9bf10aabad Merge pull request #100 from crasm/master
Store getopt() return in a signed variable
2016-12-28 10:39:12 +00:00
crasm 7b050c0184 Store getopt() return in a signed variable
On certain platforms [0] a char may be unsigned [1]. The loop for
getopt would loop forever because:

     (char)-1 => 255 and 255 != -1

A signed char also worked. I don't know what that would mean for
performance or portability. int feels simpler to me.

[0]: I'm using Arch Linux ARM on the Samsung Chromebook 2, which is
     armv7h. Not sure about other ARM platforms. With this fix, imv
     appears to work correctly.

     details: https://archlinuxarm.org/platforms/armv7/samsung/samsung-chromebook-2

[1]: http://stackoverflow.com/questions/2054939/is-char-signed-or-unsigned-by-default#2054941
2016-12-28 01:38:05 -05:00
Harry Jeffery 01466cc840 Fix indentation error 2016-12-23 18:06:34 +00:00
Harry Jeffery c6a811615b Merge pull request #99 from eXeC64/wall-of-text
Unconditionally echo build commands
2016-11-23 23:29:17 +00:00
Dmitrij D. Czarkoff 8febdbbd35 Simplify VERSION handling
Also, use default abbreviation length, so that abbreviated object name in
VERSION would match github's display of commit IDs.
2016-11-22 15:55:45 +01:00
Dmitrij D. Czarkoff f328300810 Unconditionally echo build commands 2016-11-22 15:50:49 +01:00
Dmitrij D. Czarkoff 9aea3f0dda Separate preprocessor flags from compiler flags, libs from linker flags
PR #98 hints that we were venturing into downstream's territory: compiler and
linker flags may be OS-specific, while preprocessor flags and libraries are our
responsibility.  Provide clean separation between these categories.

Downstreams may still need to provide "--std=c99" in CFLAGS though.
2016-11-22 15:48:04 +01:00
Dmitrij D. Czarkoff 34840c1148 Describe command "d" in manual
Fixes #97.
2016-11-17 08:42:49 +01:00
Harry Jeffery 8bf410744a Reset slideshow timer when image changed via 'x'
When the user hits left/right to change image, the time left until the
slideshow changes images is reset. If the user changes image by closing
the current image, the timer is not reset. This patch resolves that.
2016-11-16 22:32:29 +00:00
Dmitrij D. Czarkoff 6d8a963c9b Don't advertise hash sign usage with '-b' option
Most shells would interpret the hash sign as start of the comment, so command
with an unescaped hash sign will result in rather puzzling error message:

  $ imv -b #C0C0C0 files...
  Unknown argument 'b'. Aborting.

Although there is obvious workaround (detect 'b' in '?' case of getopt switch
and put more appropriate message), it generally makes more sense to suggest
plain hex values for input.
2016-10-23 03:41:47 +02:00
Dmitrij D. Czarkoff df6393be75 Simplify hex color parser
It is actually a trivial task for strtoul + some bit shifting, so there is no
need for two separate functions.
2016-10-23 03:32:58 +02:00
Harry Jeffery e59d0e9e12 Release v2.1.3 2016-10-22 12:35:20 +01:00
Dmitrij D. Czarkoff 311c35e3b9 Enable tests
Once cmocka is built, it is cached, so that subsequent builds only need to
install it and update linker configuration.
2016-10-22 12:37:43 +02:00
Harry Jeffery b510b04f07 Fix leak of images awaiting collection in loader 2016-10-21 20:46:41 +01:00
Harry Jeffery e594926d09 Rework thread resource leak 2016-10-21 20:37:09 +01:00
Harry Jeffery 04fb5d1083 Cap playback delta-time to 100 ms
This prevents imv from trying to "catch up" on the time that it was
asleep for by playing the gif back at high speed.
2016-10-20 21:18:57 +01:00
Dmitrij D. Czarkoff f33b1a4a96 Be more correct in read_from_stdin()
From read(2) manual page on OpenBSD:

     Error checks should explicitly test for -1.  Code such as

           while ((nr = read(fd, buf, sizeof(buf))) > 0)

     is not maximally portable, as some platforms allow for nbytes to range
     between SSIZE_MAX and SIZE_MAX - 2, in which case the return value of an
     error-free read() may appear as a negative number distinct from -1.
     Proper loops should use

           while ((nr = read(fd, buf, sizeof(buf))) != -1 && nr != 0)

Distingushing between error and eof would also help for debugging.
2016-10-09 03:14:37 +02:00
Harry Jeffery e4ded04c39 Fix thread resource leak in loader 2016-09-28 00:14:45 +01:00
Harry Jeffery 10e71e07e4 Fix minor memory leak in load_font() 2016-09-27 23:55:08 +01:00
Harry Jeffery b697fcd58a Fix GetWidth/GetHeight typo in main.c 2016-09-27 23:45:07 +01:00
Harry Jeffery 8323eb1dbe Merge pull request #96 from gktrk/test-linking-fix
Fix the linking order of tests in the Makefile for --as-needed
2016-05-27 15:27:04 +01:00
Göktürk Yüksek 07f61719e7
Fix the linking order of tests in the Makefile for --as-needed
When '--as-needed' linker flag is added to LDFLAGS, linker strips out
the symbols from the libraries needed for the tests due to the order
in which the libraries appear on the command line. List the source
files before the libraries to fix the linking issue.

For more information, see:
https://wiki.gentoo.org/wiki/Project:Quality_Assurance/As-needed#Importance_of_linking_order

Signed-off-by: Göktürk Yüksek <gokturk@gentoo.org>
2016-05-25 08:31:55 -04:00
Harry Jeffery 3e6402456b Release v2.1.2 2016-05-15 23:36:46 +01:00
Dmitrij D. Czarkoff 8e9c6f5e57 Fix build of imv on GNU libc
Previously imv used -std=gnu11 flag which activated GNU "extensions" of C11
standard.  This masked a portability issue in imv: strduo(3) should not have
been visible in `src/loader.c` without inclusion of `<string.h>` header.  This
have been fixed.  To remidy GNU libc's stange choice to hide X/Open interfaces
in C99 code by default _XOPEN_SOURCE macro was also set.  (This should have no
effect on most other platforms.)
2016-05-13 06:30:52 +02:00
Dmitrij D. Czarkoff aac1d79e77 Remove "-std=gnu11" from .travis.yml
This reverts commit 9e3db8bdaa.  The effort was
futile.
2016-05-13 06:30:51 +02:00
Dmitrij D. Czarkoff 9e3db8bdaa Continue to use -std=gnu11 for Travis
This way we may continue using strict flags for detecting issues while still
allowing old compiler versions elsewhere.
2016-05-13 01:00:30 +02:00
Dmitrij D. Czarkoff 7353178d6d Release v2.1.1 2016-05-13 00:43:36 +02:00
Dmitrij D. Czarkoff 6dad3c7bbf Fix compatibility with older gcc versions 2016-05-12 14:27:17 +02:00
Dmitrij D. Czarkoff 0e1d18a2d0 Make imv_navigator_add() return an integer value
In case of error return non-zero value instead of cleaning up navigator.  This
way main loop may do some more cleanup, or maybe even act differently.
2016-05-01 14:40:54 +02:00
Dmitrij D. Czarkoff aaab6d54a4 Remove buf_size from struct imv_navigator
Implementation details should not leak to other parts of the code.

While at it, clean up initialization and destruction of navigator.
2016-05-01 14:37:16 +02:00
Dmitrij D. Czarkoff 30db614d32 Fix uninitialized use of "last_time"
Set "last_time" to current time at declaration time, so that it holds at least
something by the time it is used.
2016-04-29 16:31:49 +02:00
Dmitrij D. Czarkoff ff5029b867 Remember files' modification times, not their directories' 2016-04-29 16:31:40 +02:00
Dmitrij D. Czarkoff 70a5b9aa6f Use single buffer for title and overlay
This allows to drop extra printing steps and memory allocations.
2016-04-29 16:31:40 +02:00
Harry Jeffery 0e8205237e Release v2.1.0 2016-04-27 12:08:01 +01:00
Dmitrij D. Czarkoff fe10d9d38f Reimplement '-x' flag
This change effectively backs out f1737ddd06,
implementing the same functionality in a simpler and more correct way.

Implementation details:

 * imv_navigator.wrapped - a new field that has value "0" by default; once
   navigator wraps around the list, this field recieves value "1".
 * imv_navigator_wrapped(&nav) - a new function that returns non-zero value iff
   navigator wrapped around the list.  Currently just returns value of
   imv_navigator.wrapped.

While at it, expanded "test_navigator_remove" and merged it with
"test_navigator_add".  Resulting test is called "test_navigator_add_remove".

Fixes #94.
2016-04-26 22:07:02 +02:00
Dmitrij D. Czarkoff 4d2f36a98b Fix segmentation violation
When non-cycling mode prevents navigator from wrapping to the other end of list,
undo change to nav->cur_path.  Otherwise it will remain out-of-bounds, so that
subsequent calls to navigator functions may produce unexpected results, up to
segmentation violation.

Fixes #93
2016-04-26 20:30:58 +02:00
Dmitrij D. Czarkoff 42fe047e73 Testcase for removal from navigator
Test that removing items leads to predictable results.  Right now test is fairly
incomplete, because it does not cover moving in reversed direction.
2016-04-26 19:27:18 +02:00
Dmitrij D. Czarkoff 34a37303bf Fix reporting image change
Apparently bg_next_frame() functions marked first frames of gifs old before
imv_loader_get_image() had a chance to report them to the main loop.  Move
unsetting of ldr->out_is_new_image to imv_loader_get_image().

Fixes #81.
2016-04-26 18:04:15 +02:00
Dmitrij D. Czarkoff b4c14b1932 Indent fix 2016-04-26 16:09:04 +02:00
Dmitrij D. Czarkoff 98ca878b7e Add vim modelines 2016-04-26 14:19:59 +02:00
Dmitrij D. Czarkoff 9d50ed2333 Conditionally ignore key repeat
For the following actions:

 * reset scaling ('s'),
 * redraw ('r'),
 * scale to actual size ('a'),
 * center image ('c'),
 * remove selection ('x'),
 * toggle fullscreen ('f'),
 * toggle playing (space),
 * print selection ('p'),
 * toggle overlay ('d')

repeating action when key is held does not make sense.  After acting upon these
events ignore them until key is released or another key is pressed.
2016-04-26 13:02:44 +02:00
Dmitrij D. Czarkoff 9ecdf4d258 Include git commit hash in version number
When operating in git repo, build system will include abbreviated git hash in
imv version number.  If there is no git repo around (eg. building from tarball),
fall back to version number in Makefile.

Fixes #90
2016-04-25 21:13:50 +02:00
Harry Jeffery 7e6a8d4db1 Merge pull request #89 from czarkoff/plus
Make '+' work on all layouts
2016-04-25 12:41:36 +01:00
Dmitrij D. Czarkoff b0af8b3d25 Make '+' work on all layouts
Key handling code obuses the fact that plus sign is shifted key for equals sign
on US keyboard.  Add '+' as a control for layouts where this is not the case.
2016-04-25 12:53:02 +02:00
Harry Jeffery 080104cbc0 Merge pull request #86 from ShanaXXII/master
fixed comment typo in loader.h
2016-04-23 16:01:36 +01:00
ShanaXXII 98543fecfb fixed comment typo in loader.h 2016-04-22 18:02:29 -04:00
Harry Jeffery 7febfc4676 Merge pull request #85 from whatevsz/wip-cycle
Add -x switch to exit imv when reaching end of file list.
2016-04-03 14:16:35 +01:00
Hannes Koerber f1737ddd06 Add -x switch to exit imv when reaching end of file list. 2016-04-02 12:12:12 +02:00