Make width of the scanning screen dynamic based on terminal width

http://dev.yorhel.nl/ncdu/bug/13
This commit is contained in:
Yorhel 2012-08-18 08:46:48 +02:00
parent 8a55c05e7d
commit 9c9d466752

View file

@ -299,20 +299,21 @@ static void calc_draw_progress() {
static char antext[15] = "Calculating..."; static char antext[15] = "Calculating...";
char ani[15]; char ani[15];
int i; int i;
int width = wincols-5;
nccreate(10, 60, !orig ? "Calculating..." : "Recalculating..."); nccreate(10, width, !orig ? "Calculating..." : "Recalculating...");
ncprint(2, 2, "Total items: %-8d size: %s", ncprint(2, 2, "Total items: %-8d size: %s",
root->items, formatsize(root->size)); root->items, formatsize(root->size));
ncprint(3, 2, "Current dir: %s", cropstr(curpath, 43)); ncprint(3, 2, "Current dir: %s", cropstr(curpath, width-17));
ncaddstr(8, 43, "Press q to quit"); ncaddstr(8, width-17, "Press q to quit");
/* show warning if we couldn't open a dir */ /* show warning if we couldn't open a dir */
if(lasterr[0] != '\0') { if(lasterr[0] != '\0') {
attron(A_BOLD); attron(A_BOLD);
ncaddstr(5, 2, "Warning:"); ncaddstr(5, 2, "Warning:");
attroff(A_BOLD); attroff(A_BOLD);
ncprint(5, 11, "could not open %-32s", cropstr(lasterr, 32)); ncprint(5, 11, "could not open %-32s", cropstr(lasterr, width-28));
ncaddstr(6, 3, "some directory sizes may not be correct"); ncaddstr(6, 3, "some directory sizes may not be correct");
} }