mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Key A to invert selection
This commit is contained in:
parent
7f605ab995
commit
b4b3ee4868
31
src/nnn.c
31
src/nnn.c
|
@ -4617,9 +4617,10 @@ static void show_help(const char *path)
|
||||||
"cz Archive%-17ce Edit file\n"
|
"cz Archive%-17ce Edit file\n"
|
||||||
"c* Toggle exe%-14c> Export list\n"
|
"c* Toggle exe%-14c> Export list\n"
|
||||||
"5Space ^J (Un)select%-7cm ^Space Mark range/clear sel\n"
|
"5Space ^J (Un)select%-7cm ^Space Mark range/clear sel\n"
|
||||||
"9p ^P Copy sel here%-11ca Select all\n"
|
"ca Select all%-14cA Invert sel\n"
|
||||||
"9v ^V Move sel here%-8cw ^W Cp/mv sel as\n"
|
"9p ^P Copy sel here%-8cw ^W Cp/mv sel as\n"
|
||||||
"9x ^X Delete%-18cE Edit sel\n"
|
"9v ^V Move sel here%-11cE Edit sel\n"
|
||||||
|
"9x ^X Delete\n"
|
||||||
"1MISC\n"
|
"1MISC\n"
|
||||||
"8Alt ; Select plugin%-11c= Launch app\n"
|
"8Alt ; Select plugin%-11c= Launch app\n"
|
||||||
"9! ^] Shell%-19c] Cmd prompt\n"
|
"9! ^] Shell%-19c] Cmd prompt\n"
|
||||||
|
@ -6615,8 +6616,9 @@ nochange:
|
||||||
clearselection();
|
clearselection();
|
||||||
break;
|
break;
|
||||||
} // fallthrough
|
} // fallthrough
|
||||||
case SEL_SELALL:
|
case SEL_SELALL: // fallthrough
|
||||||
if (sel == SEL_SELALL) {
|
case SEL_SELINV:
|
||||||
|
if (sel == SEL_SELALL || sel == SEL_SELINV) {
|
||||||
if (!ndents)
|
if (!ndents)
|
||||||
goto nochange;
|
goto nochange;
|
||||||
|
|
||||||
|
@ -6628,8 +6630,22 @@ nochange:
|
||||||
selendid = ndents - 1;
|
selendid = ndents - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sel == SEL_SELINV) {
|
||||||
|
/* Toggle selection status */
|
||||||
|
for (r = selstartid; r <= selendid; ++r) {
|
||||||
|
pdents[r].flags ^= FILE_SELECTED;
|
||||||
|
pdents[r].flags & FILE_SELECTED ? ++nselected : --nselected;
|
||||||
|
}
|
||||||
|
|
||||||
|
selbufpos = lastappendpos;
|
||||||
|
if (nselected) {
|
||||||
|
updateselbuf(path, newpath);
|
||||||
|
writesel(pselbuf, selbufpos - 1); /* Truncate NULL from end */
|
||||||
|
} else
|
||||||
|
writesel(NULL, 0);
|
||||||
|
} else {
|
||||||
/* Remember current selection buffer position */
|
/* Remember current selection buffer position */
|
||||||
for (r = selstartid; r <= selendid; ++r)
|
for (r = selstartid; r <= selendid; ++r) {
|
||||||
if (!(pdents[r].flags & FILE_SELECTED)) {
|
if (!(pdents[r].flags & FILE_SELECTED)) {
|
||||||
/* Write the path to selection file to avoid flush */
|
/* Write the path to selection file to avoid flush */
|
||||||
appendfpath(newpath, mkpath(path, pdents[r].name, newpath));
|
appendfpath(newpath, mkpath(path, pdents[r].name, newpath));
|
||||||
|
@ -6637,8 +6653,11 @@ nochange:
|
||||||
pdents[r].flags |= FILE_SELECTED;
|
pdents[r].flags |= FILE_SELECTED;
|
||||||
++nselected;
|
++nselected;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
writesel(pselbuf, selbufpos - 1); /* Truncate NULL from end */
|
writesel(pselbuf, selbufpos - 1); /* Truncate NULL from end */
|
||||||
|
}
|
||||||
|
|
||||||
if (cfg.x11)
|
if (cfg.x11)
|
||||||
plugscript(utils[UTIL_CBCP], F_NOWAIT | F_NOTRACE);
|
plugscript(utils[UTIL_CBCP], F_NOWAIT | F_NOTRACE);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -87,6 +87,7 @@ enum action {
|
||||||
SEL_SEL,
|
SEL_SEL,
|
||||||
SEL_SELMUL,
|
SEL_SELMUL,
|
||||||
SEL_SELALL,
|
SEL_SELALL,
|
||||||
|
SEL_SELINV,
|
||||||
SEL_SELEDIT,
|
SEL_SELEDIT,
|
||||||
SEL_CP,
|
SEL_CP,
|
||||||
SEL_MV,
|
SEL_MV,
|
||||||
|
@ -215,6 +216,8 @@ static struct key bindings[] = {
|
||||||
{ CONTROL(' '), SEL_SELMUL },
|
{ CONTROL(' '), SEL_SELMUL },
|
||||||
/* Select all files in current dir */
|
/* Select all files in current dir */
|
||||||
{ 'a', SEL_SELALL },
|
{ 'a', SEL_SELALL },
|
||||||
|
/* Invert selection in current dir */
|
||||||
|
{ 'A', SEL_SELINV },
|
||||||
/* List, edit selection */
|
/* List, edit selection */
|
||||||
{ 'E', SEL_SELEDIT },
|
{ 'E', SEL_SELEDIT },
|
||||||
/* Copy from selection buffer */
|
/* Copy from selection buffer */
|
||||||
|
|
Loading…
Reference in a new issue