summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2018-01-23 14:59:38 +0100
committerYorhel <git@yorhel.nl>2018-01-23 14:59:46 +0100
commit3e6affa73d59b0ca71b9f23f1cdda79727913eee (patch)
tree29ddfd4221f1a81bce29bff4d9df3024df19e5fa
parent1165342dcf09e7a47f76cf3ad93270c4cbf06e2d (diff)
Display extended information in the info window
It's looking a bit cramped, but I'm lazy.
-rw-r--r--src/browser.c24
-rw-r--r--src/dir_mem.c7
-rw-r--r--src/util.c24
-rw-r--r--src/util.h3
4 files changed, 52 insertions, 6 deletions
diff --git a/src/browser.c b/src/browser.c
index 0ed690e..d9a7d5e 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -28,6 +28,7 @@
#include <string.h>
#include <stdlib.h>
#include <ncurses.h>
+#include <time.h>
static int graph = 1, show_as = 0, info_show = 0, info_page = 0, info_start = 0, show_items = 0;
@@ -37,6 +38,8 @@ static char *message = NULL;
static void browse_draw_info(struct dir *dr) {
struct dir *t;
+ struct dir_ext *e = dir_ext_ptr(dr);
+ char mbuf[46];
int i;
nccreate(11, 60, "Item info");
@@ -51,15 +54,30 @@ static void browse_draw_info(struct dir *dr) {
attron(A_BOLD);
ncaddstr(2, 3, "Name:");
ncaddstr(3, 3, "Path:");
- ncaddstr(4, 3, "Type:");
+ if(!e)
+ ncaddstr(4, 3, "Type:");
+ else {
+ ncaddstr(4, 3, "Mode:");
+ ncaddstr(4, 21, "UID:");
+ ncaddstr(4, 33, "GID:");
+ ncaddstr(5, 3, "Last modified:");
+ }
ncaddstr(6, 3, " Disk usage:");
ncaddstr(7, 3, "Apparent size:");
attroff(A_BOLD);
ncaddstr(2, 9, cropstr(dr->name, 49));
ncaddstr(3, 9, cropstr(getpath(dr->parent), 49));
- ncaddstr(4, 9, dr->flags & FF_DIR ? "Directory"
- : dr->flags & FF_FILE ? "File" : "Other (link, device, socket, ..)");
+ ncaddstr(4, 9, dr->flags & FF_DIR ? "Directory" : dr->flags & FF_FILE ? "File" : "Other");
+
+ if(e) {
+ ncaddstr(4, 9, fmtmode(e->mode));
+ ncprint(4, 26, "%d", e->uid);
+ ncprint(4, 38, "%d", e->gid);
+ time_t t = (time_t)e->mtime;
+ strftime(mbuf, sizeof(mbuf), "%Y-%m-%d %H:%M:%S %z", localtime(&t));
+ ncaddstr(5, 18, mbuf);
+ }
ncmove(6, 18);
printsize(UIC_DEFAULT, dr->size);
diff --git a/src/dir_mem.c b/src/dir_mem.c
index 457678a..f3bb2fd 100644
--- a/src/dir_mem.c
+++ b/src/dir_mem.c
@@ -123,11 +123,12 @@ static int item(struct dir *dir, const char *name, struct dir_ext *ext) {
if(!root && orig)
name = orig->name;
- int extended = extended_info && (dir->flags & FF_EXT);
- item = malloc(extended ? dir_ext_memsize(name) : dir_memsize(name));
+ if(!extended_info)
+ dir->flags &= ~FF_EXT;
+ item = malloc(dir->flags & FF_EXT ? dir_ext_memsize(name) : dir_memsize(name));
memcpy(item, dir, offsetof(struct dir, name));
strcpy(item->name, name);
- if(extended)
+ if(dir->flags & FF_EXT)
memcpy(dir_ext_ptr(item), ext, sizeof(struct dir_ext));
item_add(item);
diff --git a/src/util.c b/src/util.c
index b85ac2b..fbf6e9d 100644
--- a/src/util.c
+++ b/src/util.c
@@ -121,6 +121,30 @@ char *fullsize(int64_t from) {
}
+char *fmtmode(unsigned short mode) {
+ static char buf[11];
+ unsigned short ft = mode & S_IFMT;
+ buf[0] = ft == S_IFDIR ? 'd'
+ : ft == S_IFREG ? '-'
+ : ft == S_IFLNK ? 'l'
+ : ft == S_IFIFO ? 'p'
+ : ft == S_IFSOCK ? 's'
+ : ft == S_IFCHR ? 'c'
+ : ft == S_IFBLK ? 'b' : '?';
+ buf[1] = mode & 0400 ? 'r' : '-';
+ buf[2] = mode & 0200 ? 'w' : '-';
+ buf[3] = mode & 0100 ? 'x' : '-';
+ buf[4] = mode & 0040 ? 'r' : '-';
+ buf[5] = mode & 0020 ? 'w' : '-';
+ buf[6] = mode & 0010 ? 'x' : '-';
+ buf[7] = mode & 0004 ? 'r' : '-';
+ buf[8] = mode & 0002 ? 'w' : '-';
+ buf[9] = mode & 0001 ? 'x' : '-';
+ buf[10] = 0;
+ return buf;
+}
+
+
void read_locale() {
thou_sep = '.';
#ifdef HAVE_LOCALE_H
diff --git a/src/util.h b/src/util.h
index dccfaf8..5ac47cc 100644
--- a/src/util.h
+++ b/src/util.h
@@ -137,6 +137,9 @@ void printsize(enum ui_coltype, int64_t);
/* int2string with thousand separators */
char *fullsize(int64_t);
+/* format's a file mode as a ls -l string */
+char *fmtmode(unsigned short);
+
/* read locale information from the environment */
void read_locale();