Show help in less

This commit is contained in:
Arun Prakash Jana 2017-04-22 12:50:02 +05:30
parent 4f17c6bd65
commit a5dedd6c24
No known key found for this signature in database
GPG key ID: A75979F35C080412

49
nnn.c
View file

@ -945,15 +945,10 @@ show_mediainfo(const char* fpath, int full)
return system(buf); return system(buf);
} }
static void static int
show_help(void) show_help(void)
{ {
char c; char helpstr[] = ("echo \"\
clear();
scrollok(stdscr, TRUE);
printw("\
<< Key >> << Function >>\n\n\ << Key >> << Function >>\n\n\
[Up], k, ^P Previous entry\n\ [Up], k, ^P Previous entry\n\
[Down], j, ^N Next entry\n\ [Down], j, ^N Next entry\n\
@ -984,16 +979,9 @@ show_help(void)
^L Force a redraw\n\ ^L Force a redraw\n\
? Toggle help screen\n\ ? Toggle help screen\n\
q Quit\n\ q Quit\n\
Q Quit and change directory\n"); Q Quit and change directory\n\n\" | less");
/* Show exit keys */ return system(helpstr);
printw("\n << (?/q)");
while ((c = getch()))
if (c == '?' || c == 'q')
break;
scrollok(stdscr, FALSE);
return;
} }
static int static int
@ -1615,7 +1603,7 @@ nochange:
} else } else
show_stats(oldpath, dents[cur].name, &sb); show_stats(oldpath, dents[cur].name, &sb);
goto begin; break;
} }
case SEL_MEDIA: case SEL_MEDIA:
if (ndents > 0) if (ndents > 0)
@ -1624,9 +1612,11 @@ nochange:
exitcurses(); exitcurses();
r = show_mediainfo(oldpath, FALSE); r = show_mediainfo(oldpath, FALSE);
initcurses(); initcurses();
if (r < 0) if (r < 0) {
printmsg("mediainfo missing"); printmsg("mediainfo missing");
goto nochange; goto nochange;
}
break;
case SEL_FMEDIA: case SEL_FMEDIA:
if (ndents > 0) if (ndents > 0)
mkpath(path, dents[cur].name, oldpath, sizeof(oldpath)); mkpath(path, dents[cur].name, oldpath, sizeof(oldpath));
@ -1634,17 +1624,21 @@ nochange:
exitcurses(); exitcurses();
r = show_mediainfo(oldpath, TRUE); r = show_mediainfo(oldpath, TRUE);
initcurses(); initcurses();
if (r < 0) if (r < 0) {
printmsg("mediainfo missing"); printmsg("mediainfo missing");
goto nochange;
case SEL_DFB:
if (!desktop_manager)
goto nochange; goto nochange;
}
break;
case SEL_DFB:
if (!desktop_manager) {
printmsg("NNN_DE_FILE_MANAGER not set");
goto nochange;
}
exitcurses(); exitcurses();
spawn(desktop_manager, path, path, 0); spawn(desktop_manager, path, path, 0);
initcurses(); initcurses();
goto nochange; break;
case SEL_FSIZE: case SEL_FSIZE:
sizeorder = !sizeorder; sizeorder = !sizeorder;
mtimeorder = 0; mtimeorder = 0;
@ -1692,11 +1686,10 @@ nochange:
printmsg("NNN_COPIER is not set"); printmsg("NNN_COPIER is not set");
goto nochange; goto nochange;
case SEL_HELP: case SEL_HELP:
exitcurses();
show_help(); show_help();
/* Save current */ initcurses();
if (ndents > 0) break;
mkpath(path, dents[cur].name, oldpath, sizeof(oldpath));
goto begin;
case SEL_RUN: case SEL_RUN:
run = xgetenv(env, run); run = xgetenv(env, run);
exitcurses(); exitcurses();