Skip to content

Commit

Permalink
Retain history of previously retrieved disk stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Euheimr committed Feb 16, 2025
1 parent f80136f commit e8f522b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand All @@ -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() {
Expand Down

0 comments on commit e8f522b

Please sign in to comment.