aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-07-10 09:21:28 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-07-10 09:21:52 +0530
commit41fcbd9b2f62668038b1ab31ce63d55062e31a2f (patch)
tree3ab531783186c259feedf9e4d8a0ba902daff715 /src
parentd03ff4dc916dc8fe35c92f008aa64f6ebf7dd71e (diff)
downloadnnn-41fcbd9b2f62668038b1ab31ce63d55062e31a2f.tar.gz
Fix #304
Diffstat (limited to 'src')
-rw-r--r--src/nnn.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 5f06843..6fa3d9c 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -809,18 +809,19 @@ static size_t selectiontofd(int fd, uint *pcount)
return pos;
}
-static void showcplist(void)
+/* List selection from selection buffer */
+static bool showcplist(void)
{
int fd;
size_t pos;
if (!copybufpos)
- return;
+ return FALSE;
fd = create_tmp_file();
if (fd == -1) {
DPRINTF_S("mkstemp failed!");
- return;
+ return FALSE;
}
pos = selectiontofd(fd, NULL);
@@ -829,6 +830,26 @@ static void showcplist(void)
if (pos && pos == copybufpos)
spawn(pager, g_tmpfpath, NULL, NULL, F_CLI);
unlink(g_tmpfpath);
+
+ return TRUE;
+}
+
+/* List selection from selection file (another instance) */
+static bool showcpfile(void)
+{
+ struct stat sb;
+
+ if (stat(g_cppath, &sb) == -1)
+ return FALSE;
+
+ /* Nothing selected if file size is 0 */
+ if (!sb.st_size)
+ return FALSE;
+
+ snprintf(g_buf, CMD_LEN_MAX, "cat %s | tr \'\\0\' \'\\n\'", g_cppath);
+ spawn("sh", "-c", g_buf, NULL, F_NORMAL | F_CMD);
+
+ return TRUE;
}
static bool cpsafe(void)
@@ -3923,8 +3944,7 @@ nochange:
}
continue;
case SEL_COPYLIST:
- if (copybufpos) {
- showcplist();
+ if (showcplist() || showcpfile()) {
if (cfg.filtermode)
presel = FILTER;
break;