aboutsummaryrefslogtreecommitdiffstats
path: root/noice.c
diff options
context:
space:
mode:
authorGravatar sin <sin@2f30.org>2015-11-20 14:14:58 +0000
committerGravatar sin <sin@2f30.org>2015-11-20 14:20:10 +0000
commit756b50be2760c840eeb4dd556b847dd296064ada (patch)
tree1d72384e5337358749ceaaf8bacae121fcea7dfd /noice.c
parentebaa637b0b30d7fa70fdd4ca61f8b1149e60e819 (diff)
downloadnnn-756b50be2760c840eeb4dd556b847dd296064ada.tar.gz
Restore screensaver mode
Disable timeout when in filter or type mode.
Diffstat (limited to 'noice.c')
-rw-r--r--noice.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/noice.c b/noice.c
index f44f8f9..12de74a 100644
--- a/noice.c
+++ b/noice.c
@@ -82,6 +82,7 @@ struct entry *dents;
int n, cur;
char *path, *oldpath;
char *fltr;
+int idle;
/*
* Layout:
@@ -259,6 +260,7 @@ initcurses(void)
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
curs_set(FALSE); /* Hide cursor */
+ timeout(1000); /* One second */
}
void
@@ -314,6 +316,10 @@ nextsel(char **run)
int c, i;
c = getch();
+ if (c == -1)
+ idle++;
+ else
+ idle = 0;
for (i = 0; i < LEN(bindings); i++)
if (c == bindings[i].sym) {
@@ -329,12 +335,14 @@ readln(void)
{
char ln[LINE_MAX];
+ timeout(-1);
echo();
curs_set(TRUE);
memset(ln, 0, sizeof(ln));
wgetnstr(stdscr, ln, sizeof(ln) - 1);
noecho();
curs_set(FALSE);
+ timeout(1000);
return strlen(ln) ? strdup(ln) : NULL;
}
@@ -349,6 +357,7 @@ readmore(char **str)
int i;
char *ln = *str;
+ timeout(-1);
if (ln != NULL)
i = strlen(ln);
else
@@ -384,6 +393,7 @@ readmore(char **str)
curs_set(FALSE);
*str = ln;
+ timeout(1000);
return ret;
}
@@ -842,6 +852,13 @@ moretyping:
initcurses();
break;
}
+ /* Screensaver */
+ if (idletimeout != 0 && idle == idletimeout) {
+ idle = 0;
+ exitcurses();
+ spawn(idlecmd, NULL, NULL);
+ initcurses();
+ }
}
}