iotop/0014-Hide-UI-elements-on-smaller-terminals.patch

90 lines
3.6 KiB
Diff

From 16a30ece6ab4eaa9ca5d056ada94673265195e27 Mon Sep 17 00:00:00 2001
From: Paul Wise <pabs3@bonedaddy.net>
Date: Thu, 4 Aug 2016 18:00:29 +0800
Subject: [PATCH] Hide UI elements on smaller terminals
This helps usability on smaller terminals.
Hide the status bar first, then the summary and then the titles,
since that is the approximate order of usefulness.
Conflict: Adapt patch Context
Reference: https://repo.or.cz/iotop.git/commit/16a30ece6ab4eaa9ca5d056ada94673265195e27
---
iotop/ui.py | 39 +++++++++++++++++++++++++++------------
1 file changed, 27 insertions(+), 12 deletions(-)
diff --git a/iotop/ui.py b/iotop/ui.py
index abd6b79..b2ac8fb 100644
--- a/iotop/ui.py
+++ b/iotop/ui.py
@@ -410,8 +410,6 @@ class IOTopUI(object):
stats_lambda = lambda p: p.stats_delta
processes.sort(key=lambda p: key(p, stats_lambda(p)),
reverse=self.sorting_reverse)
- if not self.options.batch:
- del processes[self.height - 2:]
return list(map(format, processes))
def refresh_display(self, first_time, total, actual, duration):
@@ -448,10 +446,33 @@ class IOTopUI(object):
sys.stdout.flush()
else:
self.win.erase()
+
+ if Stats.has_blkio_delay_total:
+ status_msg = None
+ else:
+ status_msg = ('CONFIG_TASK_DELAY_ACCT not enabled in kernel, '
+ 'cannot determine SWAPIN and IO %')
+
+ len_summary = len(summary)
+ len_titles = int(bool(titles))
+ len_status_msg = int(bool(status_msg))
+ max_lines = self.height - len_summary - len_titles - len_status_msg
+ if max_lines < 5:
+ titles = []
+ len_titles = 0
+ if max_lines < 6:
+ summary = []
+ len_summary = 0
+ if max_lines < 7:
+ status_msg = None
+ len_status_msg = 0
+ max_lines = self.height - len_summary - len_titles - len_status_msg
+ num_lines = min(len(lines), max_lines)
+
for i, s in enumerate(summary):
self.win.addstr(i, 0, s[:self.width])
- self.win.hline(len(summary), 0, ord(' ') | curses.A_REVERSE,
- self.width)
+ if titles:
+ self.win.hline(len_summary, 0, ord(' ') | curses.A_REVERSE, self.width)
pos = 0
remaining_cols = self.width
for i in range(len(titles)):
@@ -464,18 +485,12 @@ class IOTopUI(object):
title += self.sorting_reverse and '>' or '<'
title = title[:remaining_cols]
remaining_cols -= len(title)
- self.win.addstr(len(summary), pos, title, attr)
+ self.win.addstr(len_summary, pos, title, attr)
pos += len(title)
- if Stats.has_blkio_delay_total:
- status_msg = None
- else:
- status_msg = ('CONFIG_TASK_DELAY_ACCT not enabled in kernel, '
- 'cannot determine SWAPIN and IO %')
- num_lines = min(len(lines), self.height - 2 - int(bool(status_msg)))
for i in range(num_lines):
try:
def print_line(line):
- self.win.addstr(i + len(summary) + 1, 0, line)
+ self.win.addstr(i + len_summary + len_titles, 0, line)
try:
print_line(lines[i])
except UnicodeEncodeError:
--
2.33.0