catpoint

Catpoint simple presenting software.
git clone git://r-36.net/catpoint
Log | Files | Refs | LICENSE

commit 68ef54b661d4e28bb74d67b1bdf81d997abb08db
parent cd4fd87b2fc9d10ac71b55d9b1ea503fdad037b0
Author: Christoph Lohmann <20h@r-36.net>
Date:   Mon, 28 Dec 2020 15:08:19 +0100

Introduce a hint to only slide file if needed.

Diffstat:
catpoint.c | 20++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/catpoint.c b/catpoint.c @@ -17,6 +17,8 @@ char *currentslidep, **slidefiles; /* the slides */ int nslides, currentslide, currentslidelen, exitstatus = 1; +volatile sig_atomic_t slidechanged = 1; + void unloadcurrentslide(void) { @@ -64,6 +66,11 @@ reloadcurrentslide(int sig) if (raise(SIGWINCH) < 0) err(1, "raise"); } + + /* + * Keep this out of SIGHUP, in case this is used somewhere else. + */ + slidechanged = 1; } void @@ -112,8 +119,11 @@ main(int argc, char *argv[]) curs_set(FALSE); /* hide cursor */ show: - /* display slide */ - loadcurrentslide(slidefiles, currentslide); + /* display slide if changed */ + if (slidechanged) { + slidechanged = 0; + loadcurrentslide(slidefiles, currentslide); + } clear(); refresh(); printw("%.*s", currentslidelen, currentslidep); @@ -135,6 +145,7 @@ again: case KEY_DOWN: case KEY_NPAGE: if (currentslide < nslides - 1) { + slidechanged = 1; currentslide++; goto show; } @@ -147,6 +158,7 @@ again: case KEY_UP: case KEY_PPAGE: if (currentslide > 0) { + slidechanged = 1; currentslide--; goto show; } @@ -157,11 +169,15 @@ again: case 'u': case KEY_BEG: case KEY_HOME: + if (currentslide != 0) + slidechanged = 1; currentslide = 0; goto show; /* last */ case 'i': case KEY_END: + if (currentslide != (nslides - 1)) + slidechanged = 1; currentslide = nslides - 1; goto show; /* reload */