From e1e3ca9c8a9adeef526b0b3e23f120f85eec6ae9 Mon Sep 17 00:00:00 2001 From: Neveda <63655535+Neved4@users.noreply.github.com> Date: Mon, 15 Jul 2024 12:29:06 +0200 Subject: [PATCH 1/2] fix: Use `self.term_window.hline()` and `curses.ACS_HLINE` for the separator line --- glances/outputs/glances_curses.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/glances/outputs/glances_curses.py b/glances/outputs/glances_curses.py index 6aed9a81cd..28e64381d7 100644 --- a/glances/outputs/glances_curses.py +++ b/glances/outputs/glances_curses.py @@ -446,13 +446,24 @@ def separator_line(self, color='SEPARATOR'): self.line -= 1 line_width = self.term_window.getmaxyx()[1] - self.column if self.line >= 0: - self.term_window.addnstr( - self.line, - self.column, - unicode_message('MEDIUM_LINE', self.args) * line_width, - line_width, - self.colors_list[color], - ) + position = [self.line, self.column] + line_color = self.colors_list[color] + + if not self.args.disable_unicode: + # Use curses.ACS_HLINE for the separator line + self.term_window.hline( + *position, + curses.ACS_HLINE, + line_width, + line_color, + ) + else: + self.term_window.addnstr( + *position, + unicode_message('MEDIUM_LINE', self.args) * line_width, + line_width, + line_color, + ) def __get_stat_display(self, stats, layer): """Return a dict of dict with all the stats display. From bfdf899615136201c3c97b071592484d07f9007d Mon Sep 17 00:00:00 2001 From: Neveda <63655535+Neved4@users.noreply.github.com> Date: Mon, 15 Jul 2024 13:43:21 +0200 Subject: [PATCH 2/2] refactor: Simplify `separator_line()` logic --- glances/outputs/glances_curses.py | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/glances/outputs/glances_curses.py b/glances/outputs/glances_curses.py index 28e64381d7..a4f8c87791 100644 --- a/glances/outputs/glances_curses.py +++ b/glances/outputs/glances_curses.py @@ -448,22 +448,14 @@ def separator_line(self, color='SEPARATOR'): if self.line >= 0: position = [self.line, self.column] line_color = self.colors_list[color] + line_type = curses.ACS_HLINE if not self.args.disable_unicode else unicode_message('MEDIUM_LINE', self.args) - if not self.args.disable_unicode: - # Use curses.ACS_HLINE for the separator line - self.term_window.hline( - *position, - curses.ACS_HLINE, - line_width, - line_color, - ) - else: - self.term_window.addnstr( - *position, - unicode_message('MEDIUM_LINE', self.args) * line_width, - line_width, - line_color, - ) + self.term_window.hline( + *position, + line_type, + line_width, + line_color, + ) def __get_stat_display(self, stats, layer): """Return a dict of dict with all the stats display.