aboutsummaryrefslogtreecommitdiffstats
path: root/noice.c
diff options
context:
space:
mode:
authorGravatar sin <sin@2f30.org>2014-10-21 14:54:32 +0100
committerGravatar sin <sin@2f30.org>2014-10-21 14:54:32 +0100
commit65b8aa2ab0df59db1e9bf92a33f1fdd5f969ba65 (patch)
treefc0abf98b7cb3e7c8af4a2318b90e162c395cc55 /noice.c
parent4919b910b992996433f617415aff1d01f9077af3 (diff)
downloadnnn-65b8aa2ab0df59db1e9bf92a33f1fdd5f969ba65.tar.gz
Add SEL_SH and bring out spawning of the shell in the main loop
Diffstat (limited to 'noice.c')
-rw-r--r--noice.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/noice.c b/noice.c
index b01961f..aad67ba 100644
--- a/noice.c
+++ b/noice.c
@@ -198,10 +198,14 @@ printerr(int ret, char *prefix)
* On movement it updates *cur
* Returns SEL_{QUIT,BACK,GOIN,FLTR} otherwise
*/
-#define SEL_QUIT 1
-#define SEL_BACK 2
-#define SEL_GOIN 3
-#define SEL_FLTR 4
+enum {
+ SEL_QUIT = 1,
+ SEL_BACK,
+ SEL_GOIN,
+ SEL_FLTR,
+ SEL_SH,
+};
+
int
nextsel(int *cur, int max)
{
@@ -253,10 +257,7 @@ nextsel(int *cur, int max)
(*cur) -= MIN((LINES - 4) / 2, *cur);
break;
case '!':
- exitcurses();
- spawn("/bin/sh", NULL);
- initcurses();
- break;
+ return SEL_SH;
}
return 0;
@@ -472,11 +473,7 @@ redraw:
}
nochange:
- if (chdir(path) == -1)
- printwarn();
ret = nextsel(&cur, n);
- if (chdir(ipath) == -1)
- printwarn();
switch (ret) {
case SEL_QUIT:
free(path);
@@ -598,6 +595,14 @@ nochange:
DPRINTF_S(filter);
cur = 0;
goto out;
+ case SEL_SH:
+ if (chdir(path) == -1)
+ printwarn();
+ exitcurses();
+ spawn("/bin/sh", NULL);
+ initcurses();
+ if (chdir(ipath) == -1)
+ printwarn();
}
}