diff --git a/0014-Hide-UI-elements-on-smaller-terminals.patch b/0014-Hide-UI-elements-on-smaller-terminals.patch new file mode 100644 index 0000000..ff2cfdf --- /dev/null +++ b/0014-Hide-UI-elements-on-smaller-terminals.patch @@ -0,0 +1,89 @@ +From 16a30ece6ab4eaa9ca5d056ada94673265195e27 Mon Sep 17 00:00:00 2001 +From: Paul Wise +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..5a53ad6 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 + diff --git a/0015-Check-the-column-title-is-not-empty-before-using-it.patch b/0015-Check-the-column-title-is-not-empty-before-using-it.patch new file mode 100644 index 0000000..7b4fcdc --- /dev/null +++ b/0015-Check-the-column-title-is-not-empty-before-using-it.patch @@ -0,0 +1,49 @@ +From 529a74a28be43c04840d937c87a5ee3b81133852 Mon Sep 17 00:00:00 2001 +From: Paul Wise +Date: Thu, 4 Aug 2016 18:24:46 +0800 +Subject: [PATCH] Check the column title is not empty before using it + +Fixes crash with terminals that don't fit all titles. + +Traceback (most recent call last): + File "./iotop.py", line 12, in + main() + File "./iotop/ui.py", line 669, in main + main_loop() + File "./iotop/ui.py", line 659, in + main_loop = lambda: run_iotop(options) + File "./iotop/ui.py", line 554, in run_iotop + return curses.wrapper(run_iotop_window, options) + File "/usr/lib/python3.5/curses/__init__.py", line 94, in wrapper + return func(stdscr, *args, **kwds) + File "./iotop/ui.py", line 546, in run_iotop_window + ui.run() + File "./iotop/ui.py", line 176, in run + self.process_list.duration) + File "./iotop/ui.py", line 515, in refresh_display + self.win.addstr(len_summary, pos, title, attr) +_curses.error: addwstr() returned ERR + +Conflict: NA +Reference: https://repo.or.cz/iotop.git/commit/529a74a28be43c04840d937c87a5ee3b81133852 +--- + iotop/ui.py | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/iotop/ui.py b/iotop/ui.py +index 30efa73..a957bdd 100644 +--- a/iotop/ui.py ++++ b/iotop/ui.py +@@ -511,7 +511,8 @@ 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) ++ if title: ++ self.win.addstr(len_summary, pos, title, attr) + pos += len(title) + for i in range(num_lines): + try: +-- +2.33.0 + diff --git a/iotop.spec b/iotop.spec index baa2720..829fe4c 100644 --- a/iotop.spec +++ b/iotop.spec @@ -1,6 +1,6 @@ Name: iotop Version: 0.6 -Release: 26 +Release: 27 Summary: Simple top-like I/O monitor License: GPLv2+ URL: http://guichaz.free.fr/iotop/ @@ -23,6 +23,8 @@ Patch10: 0010-Fix-crash-due-to-syntax-error.patch Patch11: 0011-Use-monotonic-time-to-calculate-durations.patch Patch12: 0012-riscv-Add-riscv64-support.patch Patch13: 0013-loongarch64-add-loongarch64-support.patch +Patch14: 0014-Hide-UI-elements-on-smaller-terminals.patch +Patch15: 0015-Check-the-column-title-is-not-empty-before-using-it.patch %description iotop watches I/O usage information output by the Linux kernel (requires 2.6.20 or later) and @@ -60,6 +62,9 @@ This contains man files for the using of iotop %{_mandir}/man8/iotop.* %changelog +* Tue Nov 19 2024 lvyy -0.6-27 +- Fix crash when hide UI elements on smaller terminals + * Tue Jul 2 2024 cenhuilin - 0.6-26 - loongarch64: add loongarch64 support