summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2018-07-24 18:03:16 +0200
committerYorhel <git@yorhel.nl>2018-07-24 18:03:18 +0200
commit9f2350bbc9ac9ef8a4629f50c2fc6a82f55b9f8e (patch)
treeda880878004dc12f61a7821b476df8c0d59c6a19
parentcbe24d6c8f901560bcd168525c67cc4236374d16 (diff)
Display larger file counts in browser UI
Implements https://dev.yorhel.nl/ncdu/bug/43
-rw-r--r--src/browser.c23
1 files 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');
}
}