From 0afb792291d12dc4a601cc89322159bdec39e9c1 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Sat, 1 Dec 2018 08:59:19 +0530 Subject: [PATCH] Fix #156: Support selection across directories, contexts --- README.md | 5 +++-- nnn.1 | 11 +++++------ src/nnn.c | 13 +++++++++++++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4ee622ae..2b067f10 100644 --- a/README.md +++ b/README.md @@ -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 ^K to copy the absolute path of the file under the cursor. To copy multiple absolute file paths: - press ^Y (or Y) to enter selection mode. In this mode it's possible to - - cherry-pick individual files one by one by pressing ^K on each entry; or, + - cherry-pick individual files one by one by pressing ^K on each entry (works across directories and contexts); or, - navigate to another file in the same directory to select a range of files - press ^Y (or Y) _again_ to copy the paths and exit the selection mode diff --git a/nnn.1 b/nnn.1 index 27ce89da..a2528c7d 100644 --- a/nnn.1 +++ b/nnn.1 @@ -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 ^K on each entry; or, +(1) cherry-pick individual files one by one by pressing ^K 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. diff --git a/src/nnn.c b/src/nnn.c index dbc8556d..90f8bbf4 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -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;