aboutsummaryrefslogtreecommitdiffstats
path: root/noice.c
diff options
context:
space:
mode:
authorlostd <lostd@2f30.org>2014-10-07 11:37:23 +0000
committerlostd <>2014-10-07 11:37:23 +0000
commitfdf42ec50293a27f70f89ceddc84a98fe0e1d599 (patch)
tree808fff825b592e8b6da8b3a0ccac3fb3d93e9b81 /noice.c
parent4e818a3980ac2331d507773b51e7d0c8cfc899b5 (diff)
downloadnoice-fdf42ec50293a27f70f89ceddc84a98fe0e1d599.tar.gz
Exit curses mode while programs run
Diffstat (limited to 'noice.c')
-rw-r--r--noice.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/noice.c b/noice.c
index 062e26b..91a6a89 100644
--- a/noice.c
+++ b/noice.c
@@ -42,8 +42,8 @@
int die = 0;
struct assoc {
- char *ext;
- char *bin;
+ char *ext; /* Extension */
+ char *bin; /* Program */
} assocs[] = {
{ "avi", "mplayer" },
{ "mp4", "mplayer" },
@@ -88,6 +88,25 @@ dentcmp(const void *va, const void *vb)
return strcmp(a->d_name, b->d_name);
}
+void
+initcurses(void)
+{
+ initscr();
+ cbreak();
+ noecho();
+ nonl();
+ intrflush(stdscr, FALSE);
+ keypad(stdscr, TRUE);
+ curs_set(FALSE); /* Hide cursor */
+}
+
+void
+exitcurses(void)
+{
+ endwin(); /* Restore terminal */
+}
+
+
/* Warning shows up at the bottom */
void
printwarn(char *prefix)
@@ -318,6 +337,8 @@ nochange:
DPRINTF_S(ext);
DPRINTF_S(bin);
+ exitcurses();
+
/* Run program */
pid = fork();
if (pid == 0)
@@ -325,6 +346,8 @@ nochange:
else
waitpid(pid, NULL, 0);
+ initcurses();
+
free(file);
/* Screen may be messed up */
@@ -360,18 +383,11 @@ main(int argc, char *argv[])
/* Set locale before curses setup */
setlocale(LC_ALL, "");
- /* Init curses */
- initscr();
- cbreak();
- noecho();
- nonl();
- intrflush(stdscr, FALSE);
- keypad(stdscr, TRUE);
- curs_set(FALSE); /* Hide cursor */
+ initcurses();
browse(ipath);
- endwin(); /* Restore terminal */
+ exitcurses();
return 0;
}
Un proyecto texto-plano.xyz