Skip to content

Commit 721b8e3

Browse files
author
inv2004
committed
do not trim hist chart +1.5.5
1 parent 72d3ae8 commit 721b8e3

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

aur/PKGBUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pkgname=ttop
2-
pkgver=1.5.4
2+
pkgver=1.5.5
33
pkgrel=1
44
pkgdesc="System monitoring tool with historical data service, triggers and top-like TUI"
55
url="https://github.com/inv2004/ttop"

src/ttop/tui.nim

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,19 @@ proc header(tui: Tui, tb: var TerminalBuffer, info: FullInfoRef, cnt: int,
155155
tb.write fgCyan, k, fgColor, " ", formatS(net.netInDiff,
156156
net.netOutDiff)
157157

158-
proc graphData(stats: seq[StatV2], sort: SortField, width: int): seq[float] =
158+
proc graphData(stats, live: seq[StatV2], sort: SortField, width: int, isLive: bool): seq[float] =
159+
let data = if isLive: live else: stats
160+
159161
case sort:
160-
of Cpu: result = stats.mapIt(it.cpu)
161-
of Mem: result = stats.mapIt(int(it.memTotal - it.memAvailable).formatSPair()[0])
162-
of Io: result = stats.mapIt(float(it.io))
163-
else: result = stats.mapIt(float(it.prc))
162+
of Cpu: result = data.mapIt(it.cpu)
163+
of Mem: result = data.mapIt(int(it.memTotal - it.memAvailable).formatSPair()[0])
164+
of Io: result = data.mapIt(float(it.io))
165+
else: result = data.mapIt(float(it.prc))
164166

165167
if result.len < width:
166168
let diff = width - stats.len
167169
result.insert(float(0).repeat(diff), 0)
168-
elif result.len > width:
170+
elif isLive and result.len > width:
169171
result = result[^width..^1]
170172

171173
proc graph(tui: Tui, tb: var TerminalBuffer, stats, live: seq[StatV2],
@@ -175,9 +177,7 @@ proc graph(tui: Tui, tb: var TerminalBuffer, stats, live: seq[StatV2],
175177
tb.setCursorPos offset, y
176178
let w = terminalWidth()
177179
let graphWidth = w - 12
178-
let data =
179-
if tui.forceLive or stats.len == 0: graphData(live, tui.sort, graphWidth)
180-
else: graphData(stats, tui.sort, 0)
180+
let data = graphData(stats, live, tui.sort, graphWidth, tui.forceLive or stats.len == 0)
181181
try:
182182
let gLines = plot(data, width = graphWidth, height = 4).split("\n")
183183
y += 5 - gLines.len

ttop.nimble

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Package
22

3-
version = "1.5.4"
3+
version = "1.5.5"
44
author = "inv2004"
55
description = "Monitoring tool with historical snapshots and alerts"
66
license = "MIT"

0 commit comments

Comments
 (0)