From e8f522b9769d6719a3446feb8f2cff73d702b37d Mon Sep 17 00:00:00 2001 From: Jacob Betz Date: Sat, 15 Feb 2025 17:55:21 -0800 Subject: [PATCH] Retain history of previously retrieved disk stats --- ui.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ui.go b/ui.go index 2c5a110..601afb9 100644 --- a/ui.go +++ b/ui.go @@ -327,7 +327,7 @@ func UpdateDisk(app *tview.Application, box *tview.TextView, showBorder bool) { boxText string width, height int isResized bool - //disksVirtualStr []bool + oldDisksStats []DiskStat ) box.SetDynamicColors(true) @@ -339,9 +339,12 @@ func UpdateDisk(app *tview.Application, box *tview.TextView, showBorder bool) { width, height, isResized = getInnerBoxSize(box.Box, width, height) disksStats = DisksStats() + if oldDisksStats == nil { + oldDisksStats = disksStats + } boxText = "" - for _, dsk := range disksStats { + for i, dsk := range disksStats { var diskCapacityStr string diskCapacity := ConvertBytesToGiB(dsk.Total, false) if diskCapacity < 999 { @@ -362,6 +365,13 @@ func UpdateDisk(app *tview.Application, box *tview.TextView, showBorder bool) { //boxText += "width=" + strconv.Itoa(width) + ", height=" + strconv.Itoa(height) + "\n" } + // TODO: SCROLLING TEXT - get number of new lines in the box text and then compare + // num of lines to height. Then, get the delta/difference between the height and + // number of lines. Scroll/remove 1 line at a time per second, and reset back to + // 0 when the last line is reached + + oldDisksStats = disksStats + if isResized { // Re-draw immediately if the window is resized app.QueueUpdateDraw(func() {