mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
Add SEL_SH and bring out spawning of the shell in the main loop
This commit is contained in:
parent
4919b910b9
commit
65b8aa2ab0
29
noice.c
29
noice.c
|
@ -198,10 +198,14 @@ printerr(int ret, char *prefix)
|
||||||
* On movement it updates *cur
|
* On movement it updates *cur
|
||||||
* Returns SEL_{QUIT,BACK,GOIN,FLTR} otherwise
|
* Returns SEL_{QUIT,BACK,GOIN,FLTR} otherwise
|
||||||
*/
|
*/
|
||||||
#define SEL_QUIT 1
|
enum {
|
||||||
#define SEL_BACK 2
|
SEL_QUIT = 1,
|
||||||
#define SEL_GOIN 3
|
SEL_BACK,
|
||||||
#define SEL_FLTR 4
|
SEL_GOIN,
|
||||||
|
SEL_FLTR,
|
||||||
|
SEL_SH,
|
||||||
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
nextsel(int *cur, int max)
|
nextsel(int *cur, int max)
|
||||||
{
|
{
|
||||||
|
@ -253,10 +257,7 @@ nextsel(int *cur, int max)
|
||||||
(*cur) -= MIN((LINES - 4) / 2, *cur);
|
(*cur) -= MIN((LINES - 4) / 2, *cur);
|
||||||
break;
|
break;
|
||||||
case '!':
|
case '!':
|
||||||
exitcurses();
|
return SEL_SH;
|
||||||
spawn("/bin/sh", NULL);
|
|
||||||
initcurses();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -472,11 +473,7 @@ redraw:
|
||||||
}
|
}
|
||||||
|
|
||||||
nochange:
|
nochange:
|
||||||
if (chdir(path) == -1)
|
|
||||||
printwarn();
|
|
||||||
ret = nextsel(&cur, n);
|
ret = nextsel(&cur, n);
|
||||||
if (chdir(ipath) == -1)
|
|
||||||
printwarn();
|
|
||||||
switch (ret) {
|
switch (ret) {
|
||||||
case SEL_QUIT:
|
case SEL_QUIT:
|
||||||
free(path);
|
free(path);
|
||||||
|
@ -598,6 +595,14 @@ nochange:
|
||||||
DPRINTF_S(filter);
|
DPRINTF_S(filter);
|
||||||
cur = 0;
|
cur = 0;
|
||||||
goto out;
|
goto out;
|
||||||
|
case SEL_SH:
|
||||||
|
if (chdir(path) == -1)
|
||||||
|
printwarn();
|
||||||
|
exitcurses();
|
||||||
|
spawn("/bin/sh", NULL);
|
||||||
|
initcurses();
|
||||||
|
if (chdir(ipath) == -1)
|
||||||
|
printwarn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue