Display extended information in the info window
It's looking a bit cramped, but I'm lazy.
Этот коммит содержится в:
родитель
1165342dcf
Коммит
3e6affa73d
@ -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);
|
||||
|
@ -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);
|
||||
|
24
src/util.c
24
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
|
||||
|
@ -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();
|
||||
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user