Show modification time in detail view

This commit is contained in:
Arun Prakash Jana 2017-03-30 10:09:21 +05:30
parent 3c94193992
commit 187835c2bb
No known key found for this signature in database
GPG key ID: A75979F35C080412
2 changed files with 23 additions and 12 deletions

View file

@ -36,7 +36,7 @@ I chose to fork noice because:
- Jump to home directory
- Filter contents in current directory
- Show/hide hidden files
- Sort entries by time modified (newest to oldest)
- Sort entries by modification time (newest to oldest)
- Spawn a shell in current directory
- Run `top`
- Open a file with `vim` or `less`
@ -44,7 +44,11 @@ I chose to fork noice because:
### Fork toppings
- Behaviour and navigation
- Detail view with file type, size and number of entries in dir (default: disabled)
- Detail view (default: disabled) with:
- file type
- modification time
- human-readable file size
- number of entries in current directory
- 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)
- Sort entries by file size (largest to smallest)

27
noice.c
View file

@ -17,6 +17,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include "util.h"
@ -452,24 +453,30 @@ coolsize(off_t size)
void
printent_long(struct entry *ent, int active)
{
static char buf[18];
static struct tm *p;
p = localtime(&ent->t);
strftime(buf, 18, "%b %d %H:%M %Y", p);
if (S_ISDIR(ent->mode))
printw("%s%-32.32s D\n", active ? CURSR : EMPTY, ent->name);
printw("%s%-32.32s D %-18.18s\n", active ? CURSR : EMPTY, ent->name, buf);
else if (S_ISLNK(ent->mode))
printw("%s%-32.32s L\n", active ? CURSR : EMPTY, ent->name);
printw("%s%-32.32s L %-18.18s\n", active ? CURSR : EMPTY, ent->name, buf);
else if (S_ISSOCK(ent->mode))
printw("%s%-32.32s S\n", active ? CURSR : EMPTY, ent->name);
printw("%s%-32.32s S %-18.18s\n", active ? CURSR : EMPTY, ent->name, buf);
else if (S_ISFIFO(ent->mode))
printw("%s%-32.32s F\n", active ? CURSR : EMPTY, ent->name);
printw("%s%-32.32s F %-18.18s\n", active ? CURSR : EMPTY, ent->name, buf);
else if (S_ISBLK(ent->mode))
printw("%s%-32.32s B\n", active ? CURSR : EMPTY, ent->name);
printw("%s%-32.32s B %-18.18s\n", active ? CURSR : EMPTY, ent->name, buf);
else if (S_ISCHR(ent->mode))
printw("%s%-32.32s C\n", active ? CURSR : EMPTY, ent->name);
printw("%s%-32.32s C %-18.18s\n", active ? CURSR : EMPTY, ent->name, buf);
else if (ent->mode & S_IXUSR)
printw("%s%-32.32s E %s\n", active ? CURSR : EMPTY, ent->name,
coolsize(ent->size));
printw("%s%-32.32s E %-18.18s %s\n", active ? CURSR : EMPTY, ent->name,
buf, coolsize(ent->size));
else
printw("%s%-32.32s R %s\n", active ? CURSR : EMPTY, ent->name,
coolsize(ent->size));
printw("%s%-32.32s R %-18.18s %s\n", active ? CURSR : EMPTY, ent->name,
buf, coolsize(ent->size));
}
int