Show selection mode and number of selected files

This commit is contained in:
Arun Prakash Jana 2019-09-08 12:39:39 +05:30
parent cea542b515
commit 1baf284369
No known key found for this signature in database
GPG Key ID: A75979F35C080412
1 changed files with 20 additions and 15 deletions

View File

@ -277,6 +277,7 @@ static context g_ctx[CTX_MAX] __attribute__ ((aligned));
static int ndents, cur, curscroll, total_dents = ENTRY_INCR; static int ndents, cur, curscroll, total_dents = ENTRY_INCR;
static int xlines, xcols; static int xlines, xcols;
static int nselected;
static uint idle; static uint idle;
static uint idletimeout, copybufpos, copybuflen; static uint idletimeout, copybufpos, copybuflen;
static char *bmstr; static char *bmstr;
@ -3235,6 +3236,7 @@ static void redraw(char *path)
if (ndents) { if (ndents) {
char sort[] = "\0 "; char sort[] = "\0 ";
char copymode[] = "\0 ";
if (cfg.mtimeorder) if (cfg.mtimeorder)
sort[0] = cfg.mtime ? 'T' : 'A'; sort[0] = cfg.mtime ? 'T' : 'A';
@ -3243,16 +3245,19 @@ static void redraw(char *path)
else if (cfg.extnorder) else if (cfg.extnorder)
sort[0] = 'E'; sort[0] = 'E';
if (cfg.copymode)
copymode[0] = 'Y';
/* We need to show filename as it may be truncated in directory listing */ /* We need to show filename as it may be truncated in directory listing */
if (!cfg.showdetail || !cfg.blkorder) if (!cfg.showdetail || !cfg.blkorder)
mvprintw(lastln, 0, "%d/%d %s[%s]\n", cur + 1, ndents, sort, mvprintw(lastln, 0, "%d/%d (%d) %s%s[%s]\n", cur + 1, ndents, nselected,
unescape(dents[cur].name, NAME_MAX, NULL)); copymode, sort, unescape(dents[cur].name, NAME_MAX, NULL));
else { else {
xstrlcpy(buf, coolsize(dir_blocks << BLK_SHIFT), 12); xstrlcpy(buf, coolsize(dir_blocks << BLK_SHIFT), 12);
c = cfg.apparentsz ? 'a' : 'd'; c = cfg.apparentsz ? 'a' : 'd';
mvprintw(lastln, 0, "%d/%d %cu: %s (%lu files) free: %s [%s]\n", mvprintw(lastln, 0, "%d/%d (%d) %s%cu: %s (%lu files) free: %s [%s]\n",
cur + 1, ndents, c, buf, num_files, cur + 1, ndents, nselected, copymode, c, buf, num_files,
coolsize(get_fs_info(path, FREE)), coolsize(get_fs_info(path, FREE)),
unescape(dents[cur].name, NAME_MAX, NULL)); unescape(dents[cur].name, NAME_MAX, NULL));
} }
@ -3266,7 +3271,7 @@ static void browse(char *ipath)
char mark[PATH_MAX] __attribute__ ((aligned)); char mark[PATH_MAX] __attribute__ ((aligned));
char rundir[PATH_MAX] __attribute__ ((aligned)); char rundir[PATH_MAX] __attribute__ ((aligned));
char runfile[NAME_MAX + 1] __attribute__ ((aligned)); char runfile[NAME_MAX + 1] __attribute__ ((aligned));
int r = -1, fd, presel, ncp = 0, copystartid = 0, copyendid = 0, onscreen; int r = -1, fd, presel, copystartid = 0, copyendid = 0, onscreen;
enum action sel; enum action sel;
bool dir_changed = FALSE; bool dir_changed = FALSE;
struct stat sb; struct stat sb;
@ -3958,7 +3963,7 @@ nochange:
* in the copy list would be affected. However, these * in the copy list would be affected. However, these
* ops read the source file paths from the tmp file. * ops read the source file paths from the tmp file.
*/ */
if (!ncp) if (!nselected)
writecp(NULL, 0); writecp(NULL, 0);
/* Do not select if already selected */ /* Do not select if already selected */
@ -3966,7 +3971,7 @@ nochange:
r = mkpath(path, dents[cur].name, newpath); r = mkpath(path, dents[cur].name, newpath);
appendfpath(newpath, r); appendfpath(newpath, r);
++ncp; ++nselected;
dents[cur].flags |= FILE_COPIED; dents[cur].flags |= FILE_COPIED;
} }
@ -4000,13 +4005,13 @@ nochange:
} }
g_crc = crc8fast((uchar *)dents, ndents * sizeof(struct entry)); g_crc = crc8fast((uchar *)dents, ndents * sizeof(struct entry));
copystartid = cur; copystartid = cur;
ncp = 0; nselected = 0;
mvprintw(xlines - 1, 0, "selection on\n"); mvprintw(xlines - 1, 0, "selection on\n");
xdelay(); xdelay();
continue; continue;
} }
if (!ncp) { /* Handle range selection */ if (!nselected) { /* Handle range selection */
#ifndef DIR_LIMITED_COPY #ifndef DIR_LIMITED_COPY
if (g_crc != crc8fast((uchar *)dents, if (g_crc != crc8fast((uchar *)dents,
ndents * sizeof(struct entry))) { ndents * sizeof(struct entry))) {
@ -4028,19 +4033,19 @@ nochange:
cfg.copymode = 0; cfg.copymode = 0;
copybufpos = 0; copybufpos = 0;
ncp = 0; /* Override single/multi path selection */ nselected = 0; /* Override single/multi path selection */
copystartid = 0; copystartid = 0;
copyendid = ndents - 1; copyendid = ndents - 1;
} }
if ((!ncp && copystartid < copyendid) || sel == SEL_SELALL) { if ((!nselected && copystartid < copyendid) || sel == SEL_SELALL) {
for (r = copystartid; r <= copyendid; ++r) { for (r = copystartid; r <= copyendid; ++r) {
appendfpath(newpath, mkpath(path, dents[r].name, newpath)); appendfpath(newpath, mkpath(path, dents[r].name, newpath));
dents[r].flags |= FILE_COPIED; dents[r].flags |= FILE_COPIED;
} }
ncp = copyendid - copystartid + 1; nselected = copyendid - copystartid + 1;
mvprintw(xlines - 1, 0, "%d selected\n", ncp); mvprintw(xlines - 1, 0, "%d selected\n", nselected);
xdelay(); xdelay();
} }
@ -4048,8 +4053,8 @@ nochange:
writecp(pcopybuf, copybufpos - 1); /* Truncate NULL from end */ writecp(pcopybuf, copybufpos - 1); /* Truncate NULL from end */
spawn(copier, NULL, NULL, NULL, F_NOTRACE); spawn(copier, NULL, NULL, NULL, F_NOTRACE);
if (ncp) { /* Some files cherry picked */ if (nselected) { /* Some files cherry picked */
mvprintw(xlines - 1, 0, "%d selected\n", ncp); mvprintw(xlines - 1, 0, "%d selected\n", nselected);
xdelay(); xdelay();
} }
} else { } else {