Skip to content

Commit ecd7cd9

Browse files
author
inv2004
committed
show sort column
1 parent 7b9a21e commit ecd7cd9

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/ttop/tui.nim

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,14 @@ proc timeButtons(tb: var TerminalBuffer, cnt: int) =
208208
tb.write " ", HelpCol, "[]", fgNone, ",", HelpCol, "{}", fgNone, " - timeshift "
209209

210210
proc help(tui: Tui, tb: var TerminalBuffer, w, h, cnt: int) =
211-
tb.setCursorPos offset, tb.height - 1
211+
tb.setCursorPos offset - 1, tb.height - 1
212212

213-
tb.write fgNone, " order by"
213+
tb.write fgNone
214214
for x in SortField:
215215
if x == tui.sort:
216216
tb.write " ", styleBright, fgNone, $x
217217
else:
218218
tb.write " ", HelpCol, $($x)[0], fgCyan, ($x)[1..^1]
219-
# tb.setCursorXPos 0+tb.getCursorXPos()
220219

221220
if tui.group:
222221
tb.write " ", styleBright, fgNone
@@ -281,12 +280,20 @@ proc table(tui: Tui, tb: var TerminalBuffer, pi: OrderedTableRef[uint, PidInfo],
281280
statsLen: int) =
282281
var y = tb.getCursorYPos() + 1
283282
tb.write styleDim
284-
tb.write(offset, y, fmt"""{"S":1}""")
283+
tb.write(offset, y, styleDim, fmt"""{"S":1}""")
285284
if not tui.group:
285+
if tui.sort == Pid: tb.write resetStyle else: tb.write styleDim
286286
tb.write fmt""" {"PID":>6}"""
287287
else:
288288
tb.write fmt""" {"CNT":>6}"""
289-
tb.write fmt""" {"USER":<8} {"RSS":>10} {"MEM%":>5} {"CPU%":>5} {"r/w IO":>9} {"UP":>8} {"THR":>3}"""
289+
tb.write styleDim, fmt""" {"USER":<8}"""
290+
if tui.sort == Mem: tb.write resetStyle else: tb.write styleDim
291+
tb.write fmt""" {"RSS":>10} {"MEM%":>5}"""
292+
if tui.sort == Cpu: tb.write resetStyle else: tb.write styleDim
293+
tb.write fmt""" {"CPU%":>5}"""
294+
if tui.sort == IO: tb.write resetStyle else: tb.write styleDim
295+
tb.write fmt""" {"r/w IO":>9}"""
296+
tb.write styleDim, fmt""" {"UP":>8} {"THR":>3}"""
290297
if tb.width - 67 > 0:
291298
tb.write ' '.repeat(tb.width-67), bgNone
292299
inc y

0 commit comments

Comments
 (0)