Skip to content
Snippets Groups Projects
Commit 42ca4997 authored by Yorhel's avatar Yorhel
Browse files

Allow drawing the browser frame when there's no directory structure

parent e079026a
No related branches found
No related tags found
No related merge requests found
...@@ -236,16 +236,24 @@ int browse_draw() { ...@@ -236,16 +236,24 @@ int browse_draw() {
mvhline(winrows-1, 0, ' ', wincols); mvhline(winrows-1, 0, ' ', wincols);
mvprintw(0,0,"%s %s ~ Use the arrow keys to navigate, press ? for help", PACKAGE_NAME, PACKAGE_VERSION); mvprintw(0,0,"%s %s ~ Use the arrow keys to navigate, press ? for help", PACKAGE_NAME, PACKAGE_VERSION);
strcpy(tmp, formatsize(cur->parent->size)); if(cur) {
mvprintw(winrows-1, 0, " Total disk usage: %s Apparent size: %s Items: %d", strcpy(tmp, formatsize(cur->parent->size));
tmp, formatsize(cur->parent->asize), cur->parent->items); mvprintw(winrows-1, 0, " Total disk usage: %s Apparent size: %s Items: %d",
tmp, formatsize(cur->parent->asize), cur->parent->items);
} else
mvaddstr(winrows-1, 0, " No items to display.");
attroff(A_REVERSE); attroff(A_REVERSE);
mvhline(1, 0, '-', wincols); mvhline(1, 0, '-', wincols);
mvaddch(1, 3, ' '); if(cur) {
getpath(cur, tmp); mvaddch(1, 3, ' ');
mvaddstr(1, 4, cropstr(tmp, wincols-8)); getpath(cur, tmp);
mvaddch(1, 4+((int)strlen(tmp) > wincols-8 ? wincols-8 : (int)strlen(tmp)), ' '); mvaddstr(1, 4, cropstr(tmp, wincols-8));
mvaddch(1, 4+((int)strlen(tmp) > wincols-8 ? wincols-8 : (int)strlen(tmp)), ' ');
}
if(!cur)
return 0;
/* TODO: don't sort when it's not necessary */ /* TODO: don't sort when it's not necessary */
cur = browse_dir = browse_sort(cur); cur = browse_dir = browse_sort(cur);
...@@ -437,18 +445,10 @@ int browse_key(int ch) { ...@@ -437,18 +445,10 @@ int browse_key(int ch) {
void browse_init(struct dir *cur) { void browse_init(struct dir *cur) {
if(cur == NULL || cur->parent == NULL) {
if(cur == NULL || cur->sub == NULL) {
erase();
refresh();
endwin();
printf("No items to display...\n");
exit(0);
} else
browse_dir = cur->sub;
} else
browse_dir = cur;
pstate = ST_BROWSE; pstate = ST_BROWSE;
if(cur != NULL && cur->parent == NULL)
browse_dir = cur->sub;
else
browse_dir = cur;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment