Minor refactor

This commit is contained in:
Arun Prakash Jana 2019-10-15 03:47:57 +05:30
parent 9469479c0a
commit 8ac4a834ad
No known key found for this signature in database
GPG key ID: A75979F35C080412
2 changed files with 14 additions and 20 deletions

View file

@ -55,7 +55,7 @@ Add to that an awesome [Wiki](https://github.com/jarun/nnn/wiki)!
- SSHFS mounts (needs sshfs) - SSHFS mounts (needs sshfs)
- Cross-directory file selection, all/range selection - Cross-directory file selection, all/range selection
- Batch rename selection or dir entries - Batch rename selection or dir entries
- Copy, move, delete, archive, link selection - Copy (as), move (as), delete, archive, link selection
- Create, rename, duplicate files and directories - Create, rename, duplicate files and directories
- Spawn a shell, run apps, run commands, execute file - Spawn a shell, run apps, run commands, execute file
- Lock terminal (needs a locker) - Lock terminal (needs a locker)
@ -195,8 +195,8 @@ The list below is from the **dev branch**. Press <kbd>?</kbd> in `nnn` to see th
NAVIGATION NAVIGATION
↑ k Up PgUp ^U Scroll up ↑ k Up PgUp ^U Scroll up
↓ j Down PgDn ^D Scroll down ↓ j Down PgDn ^D Scroll down
← h Parent dir ~ ` @ - HOME, /, start, last ← h Parent ~ ` @ - HOME, /, start, last
↵ → l Open file/dir . Toggle show hidden ↵ → l Open . Toggle show hidden
g ^A First entry G ^E Last entry g ^A First entry G ^E Last entry
b Pin current dir ^B Go to pinned dir b Pin current dir ^B Go to pinned dir
(Sh)Tab Cycle context d Toggle detail view (Sh)Tab Cycle context d Toggle detail view
@ -213,7 +213,7 @@ The list below is from the **dev branch**. Press <kbd>?</kbd> in `nnn` to see th
a Select all K Edit selection a Select all K Edit selection
P Copy selection w Copy selection as P Copy selection w Copy selection as
V Move selection W Move selection as V Move selection W Move selection as
X Delete selection ^X Delete entry X Del selection ^X Del entry
f Create archive T Mount archive f Create archive T Mount archive
^F Extract archive F List archive ^F Extract archive F List archive
e Edit in EDITOR p Open in PAGER e Edit in EDITOR p Open in PAGER

View file

@ -908,7 +908,7 @@ static void clearselection(void)
writesel(NULL, 0); writesel(NULL, 0);
} }
static bool seledit(void) static bool editselection(void)
{ {
bool ret = FALSE; bool ret = FALSE;
int fd, lines = 0; int fd, lines = 0;
@ -1338,11 +1338,8 @@ static bool cpmv_rename(const char *path, const char *cmd)
lines = lines_in_file(fd, buf, sizeof(buf)); lines = lines_in_file(fd, buf, sizeof(buf));
DPRINTF_U(count); DPRINTF_U(count);
DPRINTF_U(lines); DPRINTF_U(lines);
if (!lines) if (!lines || (2 * count != lines)) {
goto finish; DPRINTF_S("num mismatch");
if (2 * count != lines) {
DPRINTF_S("cannot delete files");
goto finish; goto finish;
} }
@ -1409,10 +1406,7 @@ static bool batch_rename(const char *path)
lines = lines_in_file(fd2, buf, sizeof(buf)); lines = lines_in_file(fd2, buf, sizeof(buf));
DPRINTF_U(count); DPRINTF_U(count);
DPRINTF_U(lines); DPRINTF_U(lines);
if (!lines) if (!lines || (count != lines)) {
goto finish;
if (count != lines) {
DPRINTF_S("cannot delete files"); DPRINTF_S("cannot delete files");
goto finish; goto finish;
} }
@ -3054,8 +3048,8 @@ static void show_help(const char *path)
"1NAVIGATION\n" "1NAVIGATION\n"
"a↑ k Up PgUp ^U Scroll up\n" "a↑ k Up PgUp ^U Scroll up\n"
"a↓ j Down PgDn ^D Scroll down\n" "a↓ j Down PgDn ^D Scroll down\n"
"a← h Parent dir ~ ` @ - HOME, /, start, last\n" "a← h Parent ~ ` @ - HOME, /, start, last\n"
"8↵ → l Open file/dir . Toggle show hidden\n" "8↵ → l Open . Toggle show hidden\n"
"9g ^A First entry G ^E Last entry\n" "9g ^A First entry G ^E Last entry\n"
"cb Pin current dir ^B Go to pinned dir\n" "cb Pin current dir ^B Go to pinned dir\n"
"6(Sh)Tab Cycle context d Toggle detail view\n" "6(Sh)Tab Cycle context d Toggle detail view\n"
@ -3070,9 +3064,9 @@ static void show_help(const char *path)
"9⎵ ^J Select entry r Batch rename\n" "9⎵ ^J Select entry r Batch rename\n"
"9m ^K Sel range, clear M List selection\n" "9m ^K Sel range, clear M List selection\n"
"ca Select all K Edit selection\n" "ca Select all K Edit selection\n"
"cP Copy selection w Copy selection as\n" "cP Copy selection w Copy selection as\n"
"cV Move selection W Move selection as\n" "cV Move selection W Move selection as\n"
"cX Delete selection ^X Delete entry\n" "cX Del selection ^X Del entry\n"
"cf Create archive T Mount archive\n" "cf Create archive T Mount archive\n"
"b^F Extract archive F List archive\n" "b^F Extract archive F List archive\n"
"ce Edit in EDITOR p Open in PAGER\n" "ce Edit in EDITOR p Open in PAGER\n"
@ -4389,7 +4383,7 @@ nochange:
printwait(messages[NONE_SELECTED], &presel); printwait(messages[NONE_SELECTED], &presel);
goto nochange; goto nochange;
case SEL_SELEDIT: case SEL_SELEDIT:
if (!seledit()){ if (!editselection()){
printwait(messages[OPERATION_FAILED], &presel); printwait(messages[OPERATION_FAILED], &presel);
goto nochange; goto nochange;
} }