mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
Use reverse video in detail view
1. Highlight the currently selected item in reverse video. 2. Fix: remember the current item when toggling detail view.
This commit is contained in:
parent
187835c2bb
commit
055439f23e
|
@ -49,6 +49,7 @@ I chose to fork noice because:
|
||||||
- modification time
|
- modification time
|
||||||
- human-readable file size
|
- human-readable file size
|
||||||
- number of entries in current directory
|
- number of entries in current directory
|
||||||
|
- current item in reverse video
|
||||||
- Case-insensitive alphabetic content listing instead of upper case first
|
- Case-insensitive alphabetic content listing instead of upper case first
|
||||||
- Roll over at the first and last entries of a directory (with Up/Down keys)
|
- Roll over at the first and last entries of a directory (with Up/Down keys)
|
||||||
- Sort entries by file size (largest to smallest)
|
- Sort entries by file size (largest to smallest)
|
||||||
|
|
28
noice.c
28
noice.c
|
@ -42,6 +42,7 @@
|
||||||
#define TOUPPER(ch) \
|
#define TOUPPER(ch) \
|
||||||
(((ch) >= 'a' && (ch) <= 'z') ? ((ch) - 'a' + 'A') : (ch))
|
(((ch) >= 'a' && (ch) <= 'z') ? ((ch) - 'a' + 'A') : (ch))
|
||||||
#define MAX_LEN 1024
|
#define MAX_LEN 1024
|
||||||
|
#define cur(flag) (flag ? CURSR : EMPTY)
|
||||||
|
|
||||||
struct assoc {
|
struct assoc {
|
||||||
char *regex; /* Regex to match on filename */
|
char *regex; /* Regex to match on filename */
|
||||||
|
@ -454,29 +455,35 @@ void
|
||||||
printent_long(struct entry *ent, int active)
|
printent_long(struct entry *ent, int active)
|
||||||
{
|
{
|
||||||
static char buf[18];
|
static char buf[18];
|
||||||
static struct tm *p;
|
const static struct tm *p;
|
||||||
|
|
||||||
p = localtime(&ent->t);
|
p = localtime(&ent->t);
|
||||||
strftime(buf, 18, "%b %d %H:%M %Y", p);
|
strftime(buf, 18, "%b %d %H:%M %Y", p);
|
||||||
|
|
||||||
|
if (active)
|
||||||
|
attron(A_REVERSE);
|
||||||
|
|
||||||
if (S_ISDIR(ent->mode))
|
if (S_ISDIR(ent->mode))
|
||||||
printw("%s%-32.32s D %-18.18s\n", active ? CURSR : EMPTY, ent->name, buf);
|
printw("%s%-32.32s D %-18.18s\n", cur(active), ent->name, buf);
|
||||||
else if (S_ISLNK(ent->mode))
|
else if (S_ISLNK(ent->mode))
|
||||||
printw("%s%-32.32s L %-18.18s\n", active ? CURSR : EMPTY, ent->name, buf);
|
printw("%s%-32.32s L %-18.18s\n", cur(active), ent->name, buf);
|
||||||
else if (S_ISSOCK(ent->mode))
|
else if (S_ISSOCK(ent->mode))
|
||||||
printw("%s%-32.32s S %-18.18s\n", active ? CURSR : EMPTY, ent->name, buf);
|
printw("%s%-32.32s S %-18.18s\n", cur(active), ent->name, buf);
|
||||||
else if (S_ISFIFO(ent->mode))
|
else if (S_ISFIFO(ent->mode))
|
||||||
printw("%s%-32.32s F %-18.18s\n", active ? CURSR : EMPTY, ent->name, buf);
|
printw("%s%-32.32s F %-18.18s\n", cur(active), ent->name, buf);
|
||||||
else if (S_ISBLK(ent->mode))
|
else if (S_ISBLK(ent->mode))
|
||||||
printw("%s%-32.32s B %-18.18s\n", active ? CURSR : EMPTY, ent->name, buf);
|
printw("%s%-32.32s B %-18.18s\n", cur(active), ent->name, buf);
|
||||||
else if (S_ISCHR(ent->mode))
|
else if (S_ISCHR(ent->mode))
|
||||||
printw("%s%-32.32s C %-18.18s\n", active ? CURSR : EMPTY, ent->name, buf);
|
printw("%s%-32.32s C %-18.18s\n", cur(active), ent->name, buf);
|
||||||
else if (ent->mode & S_IXUSR)
|
else if (ent->mode & S_IXUSR)
|
||||||
printw("%s%-32.32s E %-18.18s %s\n", active ? CURSR : EMPTY, ent->name,
|
printw("%s%-32.32s E %-18.18s %s\n", cur(active), ent->name,
|
||||||
buf, coolsize(ent->size));
|
buf, coolsize(ent->size));
|
||||||
else
|
else
|
||||||
printw("%s%-32.32s R %-18.18s %s\n", active ? CURSR : EMPTY, ent->name,
|
printw("%s%-32.32s R %-18.18s %s\n", cur(active), ent->name,
|
||||||
buf, coolsize(ent->size));
|
buf, coolsize(ent->size));
|
||||||
|
|
||||||
|
if (active)
|
||||||
|
attroff(A_REVERSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -845,6 +852,9 @@ nochange:
|
||||||
case SEL_DETAIL:
|
case SEL_DETAIL:
|
||||||
showdetail = !showdetail;
|
showdetail = !showdetail;
|
||||||
showdetail ? (printptr = &printent_long) : (printptr = &printent);
|
showdetail ? (printptr = &printent_long) : (printptr = &printent);
|
||||||
|
/* Save current */
|
||||||
|
if (ndents > 0)
|
||||||
|
mkpath(path, dents[cur].name, oldpath, sizeof(oldpath));
|
||||||
goto begin;
|
goto begin;
|
||||||
case SEL_FSIZE:
|
case SEL_FSIZE:
|
||||||
sizeorder = !sizeorder;
|
sizeorder = !sizeorder;
|
||||||
|
|
Loading…
Reference in a new issue