diff options
author | Georgi Georgiev <chutz@gg3.net> | 2022-01-19 18:52:07 +0900 |
---|---|---|
committer | Daniel Milde <daniel@milde.cz> | 2022-01-27 16:33:04 +0100 |
commit | 89513e73efc0410779fe5c997d5f6d6f3c6621b7 (patch) | |
tree | 0696a740e162d4261d71f7cbbe33b6fc317064d6 /tui/format.go | |
parent | b1e9ea9d0e90e42d87ff8ad2fd938c4de7b40e30 (diff) |
Make the bar graph meaningful in large directories
The current bar implementation shows an empty graph in a directory with
approximately 20 files (not so uncommon) of similar size - each file
size is 5% of the total, which rounds to 0 for the bar of 10 ticks.
With directories with more items, the usefulness of the bar degrades
even faster even for objects of different sizes.
With this change, all sizes are shown relative to the largest
item which gives a better idea of how big the items are.
Diffstat (limited to 'tui/format.go')
-rw-r--r-- | tui/format.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tui/format.go b/tui/format.go index 724e814..d756bd7 100644 --- a/tui/format.go +++ b/tui/format.go @@ -8,13 +8,13 @@ import ( "github.com/rivo/tview" ) -func (ui *UI) formatFileRow(item fs.Item) string { +func (ui *UI) formatFileRow(item fs.Item, maxUsage int64, maxSize int64) string { var part int if ui.ShowApparentSize { - part = int(float64(item.GetSize()) / float64(item.GetParent().GetSize()) * 10.0) + part = int(float64(item.GetSize()) / float64(maxSize) * 10.0) } else { - part = int(float64(item.GetUsage()) / float64(item.GetParent().GetUsage()) * 10.0) + part = int(float64(item.GetUsage()) / float64(maxUsage) * 10.0) } row := string(item.GetFlag()) |