Fix #156: Support selection across directories, contexts

This commit is contained in:
Arun Prakash Jana 2018-12-01 08:59:19 +05:30
parent 50a4449417
commit 0afb792291
No known key found for this signature in database
GPG key ID: A75979F35C080412
3 changed files with 21 additions and 8 deletions

View file

@ -103,7 +103,8 @@ It runs on Linux, OS X, Raspberry Pi, Cygwin, Linux subsystem for Windows and Te
- Media information (needs mediainfo/exiftool)
- Convenience
- Create, rename files and directories
- Select multiple files; copy, move, delete selection
- Select files across directories
- Copy, move, delete selection
- Batch rename/move/delete (needs vidir)
- Show directories in custom color (default: blue)
- Spawn a subshell in the current directory
@ -374,7 +375,7 @@ Use <kbd>^K</kbd> to copy the absolute path of the file under the cursor.
To copy multiple absolute file paths:
- press <kbd>^Y</kbd> (or <kbd>Y</kbd>) to enter selection mode. In this mode it's possible to
- cherry-pick individual files one by one by pressing <kbd>^K</kbd> on each entry; or,
- cherry-pick individual files one by one by pressing <kbd>^K</kbd> on each entry (works across directories and contexts); or,
- navigate to another file in the same directory to select a range of files
- press <kbd>^Y</kbd> (or <kbd>Y</kbd>) _again_ to copy the paths and exit the selection mode

11
nnn.1
View file

@ -253,7 +253,7 @@ NNN_COPIER is set (see ENVIRONMENT section below).
To copy multiple file paths the selection mode should be enabled using \fI^Y\fR.
In this mode it's possible to
.Pp
(1) cherry-pick individual files one by one by pressing <kbd>^K</kbd> on each entry; or,
(1) cherry-pick individual files one by one by pressing <kbd>^K</kbd> on each entry (works across directories and contexts); or,
.br
(2) navigate to another file in the same directory to select a range of files.
.Pp
@ -263,7 +263,10 @@ be copied, moved or removed using respective keyboard shortcuts.
To list the file paths copied to memory press \fIy\fR.
.Sh ENVIRONMENT
The SHELL, EDITOR (VISUAL, if defined) and PAGER environment variables take precedence
when dealing with the !, e and p commands respectively.
when dealing with the !, e and p commands respectively. A single combination to arguments is supported, e.g.:
.Bd -literal
export EDITOR='vim -xR'
.Ed
.Pp
\fBNNN_BMS:\fR bookmark string as \fIkey_char:location\fR pairs (max 10) separated by
\fI;\fR:
@ -277,10 +280,6 @@ when dealing with the !, e and p commands respectively.
files.
.Bd -literal
export NNN_USE_EDITOR=1
NOTE: Arguments to the editor should be combined together, e.g.,
export EDITOR='vim -xR'
.Ed
.Pp
\fBNNN_IDLE_TIMEOUT:\fR set idle timeout (in seconds) to invoke terminal locker.

View file

@ -2397,11 +2397,14 @@ static void redraw(char *path)
/* Clear screen */
erase();
#ifdef DIR_LIMITED_COPY
if (cfg.copymode)
if (g_crc != crc8fast((uchar *)dents, ndents * sizeof(struct entry))) {
cfg.copymode = 0;
DPRINTF_S("selection off");
}
#endif
/* Fail redraw if < than 11 columns, context info prints 10 chars */
if (COLS < 11) {
@ -2823,7 +2826,9 @@ nochange:
if (cfg.curctx == r)
continue;
#ifdef DIR_LIMITED_COPY
g_crc = 0;
#endif
/* Save current context */
xstrlcpy(g_ctx[cfg.curctx].c_name, dents[cur].name, NAME_MAX + 1);
@ -3072,6 +3077,14 @@ nochange:
}
if (!ncp) { /* Handle range selection */
#ifndef DIR_LIMITED_COPY
if (g_crc != crc8fast((uchar *)dents, ndents * sizeof(struct entry))) {
cfg.copymode = 0;
printmsg("range error: dir/content changed");
DPRINTF_S("range error: dir/content changed");
goto nochange;
}
#endif
if (cur < copystartid) {
copyendid = copystartid;
copystartid = cur;