From 9c9d46675243c7ccdf7f133f4f04a6a738a0f4fc Mon Sep 17 00:00:00 2001
From: Yorhel <git@yorhel.nl>
Date: Sat, 18 Aug 2012 08:46:48 +0200
Subject: [PATCH] Make width of the scanning screen dynamic based on terminal
 width

http://dev.yorhel.nl/ncdu/bug/13
---
 src/calc.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/calc.c b/src/calc.c
index 6d404e8..5047d0a 100644
--- a/src/calc.c
+++ b/src/calc.c
@@ -299,20 +299,21 @@ static void calc_draw_progress() {
   static char antext[15] = "Calculating...";
   char ani[15];
   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",
     root->items, formatsize(root->size));
-  ncprint(3, 2, "Current dir: %s", cropstr(curpath, 43));
-  ncaddstr(8, 43, "Press q to quit");
+  ncprint(3, 2, "Current dir: %s", cropstr(curpath, width-17));
+  ncaddstr(8, width-17, "Press q to quit");
 
   /* show warning if we couldn't open a dir */
   if(lasterr[0] != '\0') {
      attron(A_BOLD);
      ncaddstr(5, 2, "Warning:");
      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");
   }
 
-- 
GitLab