Show order info in filter info bar

This commit is contained in:
Arun Prakash Jana 2020-01-14 22:51:10 +05:30
parent 1b252b6ecb
commit 364399246e
No known key found for this signature in database
GPG key ID: A75979F35C080412
2 changed files with 40 additions and 27 deletions

View file

@ -26,11 +26,12 @@ It runs smoothly on the Pi, [Termux](https://www.youtube.com/watch?v=AbaauM7gUJw
## Features ## Features
- Resource sensitive - Resource sensitive
- Typically needs < 3.5MB resident memory - Typically needs less than 3.5MB resident memory
- Works with 8-bit colors - Works with 8-bit colors
- Disk-IO sensitive (few disk reads and writes) - Disk-IO sensitive (few disk reads and writes)
- No FPU usage (all integer maths, even for file size) - No FPU usage (all integer maths, even for file size)
- Minimizes screen refresh with fast line redraws - Minimizes screen refresh with fast line redraws
- Tiny binary (typically less than 100KB)
- Portable - Portable
- Minimal library deps, easily compilable, tiny binary - Minimal library deps, easily compilable, tiny binary
- No config file, minimal config with sensible defaults - No config file, minimal config with sensible defaults

View file

@ -2028,11 +2028,44 @@ static int nextsel(int presel)
return 0; return 0;
} }
static int getorderstr(char *sort)
{
int i = 0;
if (cfg.mtimeorder)
sort[0] = cfg.mtime ? 'T' : 'A';
else if (cfg.sizeorder)
sort[0] = 'S';
else if (cfg.extnorder)
sort[0] = 'E';
if (sort[i])
++i;
if (entrycmpfn == &reventrycmp) {
sort[i] = 'R';
++i;
}
if (namecmpfn == &xstrverscasecmp) {
sort[i] = 'V';
++i;
}
if (i)
sort[i] = ' ';
return i;
}
static void showfilterinfo(void) static void showfilterinfo(void)
{ {
char info[REGEX_MAX]; int i = 0;
char info[REGEX_MAX] = "\0\0\0\0";
snprintf(info, REGEX_MAX - 1, " %s [keys /\\], %s [key :]", i = getorderstr(info);
snprintf(info + i, REGEX_MAX - i - 1, " %s [keys /\\], %s [key :]",
(cfg.regex ? "regex" : "str"), (cfg.regex ? "regex" : "str"),
((fnstrstr == &strcasestr) ? "ic" : "noic")); ((fnstrstr == &strcasestr) ? "ic" : "noic"));
printinfoln(info); printinfoln(info);
@ -4230,7 +4263,6 @@ static void statusbar(char *path)
{ {
int i = 0, extnlen = 0; int i = 0, extnlen = 0;
char *ptr; char *ptr;
char sort[] = "\0\0\0\0";
char buf[24]; char buf[24];
pEntry pent = &dents[cur]; pEntry pent = &dents[cur];
@ -4239,29 +4271,6 @@ static void statusbar(char *path)
return; return;
} }
if (cfg.mtimeorder)
sort[0] = cfg.mtime ? 'T' : 'A';
else if (cfg.sizeorder)
sort[0] = 'S';
else if (cfg.extnorder)
sort[0] = 'E';
if (sort[i])
++i;
if (entrycmpfn == &reventrycmp) {
sort[i] = 'R';
++i;
}
if (namecmpfn == &xstrverscasecmp) {
sort[i] = 'V';
++i;
}
if (i)
sort[i] = ' ';
/* Get the file extension for regular files */ /* Get the file extension for regular files */
if (S_ISREG(pent->mode)) { if (S_ISREG(pent->mode)) {
i = (int)(pent->nlen - 1); i = (int)(pent->nlen - 1);
@ -4287,6 +4296,9 @@ static void statusbar(char *path)
/* Show filename as it may be truncated in directory listing */ /* Show filename as it may be truncated in directory listing */
/* Get the unescaped file name */ /* Get the unescaped file name */
char *fname = unescape(pent->name, NAME_MAX, NULL); char *fname = unescape(pent->name, NAME_MAX, NULL);
char sort[] = "\0\0\0\0";
getorderstr(sort);
/* Timestamp */ /* Timestamp */
strftime(buf, sizeof(buf), "%F %R", localtime(&pent->t)); strftime(buf, sizeof(buf), "%F %R", localtime(&pent->t));