From 9f2350bbc9ac9ef8a4629f50c2fc6a82f55b9f8e Mon Sep 17 00:00:00 2001
From: Yorhel <git@yorhel.nl>
Date: Tue, 24 Jul 2018 18:03:16 +0200
Subject: [PATCH] Display larger file counts in browser UI

Implements https://dev.yorhel.nl/ncdu/bug/43
---
 src/browser.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/browser.c b/src/browser.c
index 2ca739d..97132ba 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -169,18 +169,29 @@ static void browse_draw_graph(struct dir *n, int *x) {
 
 static void browse_draw_items(struct dir *n, int *x) {
   enum ui_coltype c = n->flags & FF_BSEL ? UIC_SEL : UIC_DEFAULT;
+  enum ui_coltype cn = c == UIC_SEL ? UIC_NUM_SEL : UIC_NUM;
 
   if(!show_items)
     return;
   *x += 7;
 
-  if(n->items > 99999) {
-    addstrc(c, "> ");
-    addstrc(c == UIC_SEL ? UIC_NUM_SEL : UIC_NUM, "100");
-    addchc(c, 'k');
-  } else if(n->items) {
-    uic_set(c == UIC_SEL ? UIC_NUM_SEL : UIC_NUM);
+  if(!n->items)
+    return;
+  else if(n->items < 100*1000) {
+    uic_set(cn);
     printw("%6s", fullsize(n->items));
+  } else if(n->items < 1000*1000) {
+    uic_set(cn);
+    printw("%5.1f", n->items / 1000.0);
+    addstrc(c, "k");
+  } else if(n->items < 1000*1000*1000) {
+    uic_set(cn);
+    printw("%5.1f", n->items / 1e6);
+    addstrc(c, "M");
+  } else {
+    addstrc(c, "  > ");
+    addstrc(cn, "1");
+    addchc(c, 'B');
   }
 }
 
-- 
GitLab