mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 13:51:31 +00:00
multi-cp: show number of cherrypicked files
This commit is contained in:
parent
c8a431841c
commit
c6f9af931f
33
nnn.c
33
nnn.c
|
@ -640,7 +640,7 @@ writecp(const char *buf, const size_t buflen)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
appendfilepath(const char *path, const size_t len)
|
appendfpath(const char *path, const size_t len)
|
||||||
{
|
{
|
||||||
if ((copybufpos >= copybuflen) || ((len + 3) > (copybuflen - copybufpos))) {
|
if ((copybufpos >= copybuflen) || ((len + 3) > (copybuflen - copybufpos))) {
|
||||||
copybuflen += PATH_MAX;
|
copybuflen += PATH_MAX;
|
||||||
|
@ -2422,7 +2422,7 @@ browse(char *ipath, char *ifilter)
|
||||||
static char oldname[NAME_MAX + 1] __attribute__ ((aligned));
|
static char oldname[NAME_MAX + 1] __attribute__ ((aligned));
|
||||||
char *dir, *tmp, *run = NULL, *env = NULL;
|
char *dir, *tmp, *run = NULL, *env = NULL;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
int r, fd, presel, copystartid = 0, copyendid = 0;
|
int r, fd, presel, ncp, copystartid = 0, copyendid = 0;
|
||||||
enum action sel = SEL_RUNARG + 1;
|
enum action sel = SEL_RUNARG + 1;
|
||||||
bool dir_changed = FALSE;
|
bool dir_changed = FALSE;
|
||||||
|
|
||||||
|
@ -2985,8 +2985,9 @@ nochange:
|
||||||
else if (ndents) {
|
else if (ndents) {
|
||||||
if (cfg.copymode) {
|
if (cfg.copymode) {
|
||||||
r = mkpath(path, dents[cur].name, newpath, PATH_MAX);
|
r = mkpath(path, dents[cur].name, newpath, PATH_MAX);
|
||||||
if (!appendfilepath(newpath, r))
|
if (!appendfpath(newpath, r))
|
||||||
goto nochange;
|
goto nochange;
|
||||||
|
++ncp;
|
||||||
printmsg(newpath);
|
printmsg(newpath);
|
||||||
} else if (cfg.quote) {
|
} else if (cfg.quote) {
|
||||||
g_buf[0] = '\'';
|
g_buf[0] = '\'';
|
||||||
|
@ -3020,15 +3021,11 @@ nochange:
|
||||||
g_crc = crc8fast((uchar *)dents, ndents * sizeof(struct entry));
|
g_crc = crc8fast((uchar *)dents, ndents * sizeof(struct entry));
|
||||||
copystartid = cur;
|
copystartid = cur;
|
||||||
copybufpos = 0;
|
copybufpos = 0;
|
||||||
|
ncp = 0;
|
||||||
printmsg("multi-copy on");
|
printmsg("multi-copy on");
|
||||||
DPRINTF_S("copymode on");
|
DPRINTF_S("copymode on");
|
||||||
} else {
|
} else {
|
||||||
static size_t len;
|
if (!ncp) { /* Handle range selection */
|
||||||
len = 0;
|
|
||||||
|
|
||||||
/* Handle range selection */
|
|
||||||
if (copybufpos == 0) {
|
|
||||||
|
|
||||||
if (cur < copystartid) {
|
if (cur < copystartid) {
|
||||||
copyendid = copystartid;
|
copyendid = copystartid;
|
||||||
copystartid = cur;
|
copystartid = cur;
|
||||||
|
@ -3036,24 +3033,26 @@ nochange:
|
||||||
copyendid = cur;
|
copyendid = cur;
|
||||||
|
|
||||||
if (copystartid < copyendid) {
|
if (copystartid < copyendid) {
|
||||||
for (r = copystartid; r <= copyendid; ++r) {
|
for (r = copystartid; r <= copyendid; ++r)
|
||||||
len = mkpath(path, dents[r].name, newpath, PATH_MAX);
|
if (!appendfpath(newpath, mkpath(path, dents[r].name, newpath, PATH_MAX)))
|
||||||
if (!appendfilepath(newpath, len))
|
goto nochange;
|
||||||
goto nochange;;
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(newpath, PATH_MAX, "%d files copied", copyendid - copystartid + 1);
|
snprintf(newpath, PATH_MAX, "%d files copied", copyendid - copystartid + 1);
|
||||||
printmsg(newpath);
|
printmsg(newpath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (copybufpos) {
|
if (copybufpos) { /* File path(s) written to the buffer */
|
||||||
if (cfg.noxdisplay)
|
if (cfg.noxdisplay)
|
||||||
writecp(pcopybuf, copybufpos - 1); /* Truncate NULL from end */
|
writecp(pcopybuf, copybufpos - 1); /* Truncate NULL from end */
|
||||||
else
|
else
|
||||||
spawn(copier, pcopybuf, NULL, NULL, F_NOTRACE);
|
spawn(copier, pcopybuf, NULL, NULL, F_NOTRACE);
|
||||||
if (!len)
|
|
||||||
printmsg("files copied");
|
if (ncp) /* Some files cherry picked */
|
||||||
|
{
|
||||||
|
snprintf(newpath, PATH_MAX, "%d files copied", ncp);
|
||||||
|
printmsg(newpath);
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
printmsg("multi-copy off");
|
printmsg("multi-copy off");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue