From dd0b763dab6ff13e8d6c44ae75af731e4fd9d6ab Mon Sep 17 00:00:00 2001 From: Andrew Hamilton Date: Fri, 20 Jul 2018 08:57:18 +1000 Subject: [PATCH] Change the default background of scrollbars. - Also hacked the cursor row highlighting to not highlight the scrollbar. Highlighting the widget inside the view widget is much more difficult. --- tests/fill3_test.py | 3 ++- vigil/__main__.py | 5 +++-- vigil/fill3.py | 22 +++++++++++++--------- vigil/termstr.py | 1 + 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/tests/fill3_test.py b/tests/fill3_test.py index 767199d..292f4fa 100755 --- a/tests/fill3_test.py +++ b/tests/fill3_test.py @@ -74,7 +74,8 @@ class WidgetTests(unittest.TestCase): def assert_string2(self, appearance, expected_string): self.assertEqual( ("\n".join(line.data for line in appearance), - "".join("i" if style.fg_color==termstr.Color.black else " " + "".join("i" if style.fg_color== + fill3.ScrollBar.DEFAULT_BACKGROUND_COLOR else " " for line in appearance for style in line.style)), expected_string) diff --git a/vigil/__main__.py b/vigil/__main__.py index c4954b8..592290d 100755 --- a/vigil/__main__.py +++ b/vigil/__main__.py @@ -346,8 +346,9 @@ class Summary: def _highlight_cursor_row(self, appearance, cursor_y): scroll_x, scroll_y = self._view_widget.position highlighted_y = cursor_y - scroll_y - appearance[highlighted_y] = highlight_str( - appearance[highlighted_y], termstr.Color.white, 0.85) + appearance[highlighted_y] = (highlight_str( + appearance[highlighted_y][:-1], termstr.Color.white, 0.85) + + appearance[highlighted_y][-1]) return appearance def appearance(self, dimensions): diff --git a/vigil/fill3.py b/vigil/fill3.py index a9f10a1..4a5d873 100644 --- a/vigil/fill3.py +++ b/vigil/fill3.py @@ -181,27 +181,31 @@ class ScrollBar: _HORIZONTAL_CHARS = [" ", "▏", "▎", "▍", "▌", "▋", "▊", "▉"] _VERTICAL_CHARS = ["█", "▇", "▆", "▅", "▄", "▃", "▂", "▁"] + DEFAULT_BAR_COLOR = termstr.Color.grey_100 + DEFAULT_BACKGROUND_COLOR = termstr.Color.grey_30 - def __init__(self, is_horizontal, interval=(0, 0), - bar_color=termstr.Color.grey_100, - background_color=termstr.Color.black): + def __init__(self, is_horizontal, interval=(0, 0), bar_color=None, + background_color=None): self._is_horizontal = is_horizontal self.interval = interval - self.bar_color = bar_color - self.background_color = background_color + bar_color = (ScrollBar.DEFAULT_BAR_COLOR if bar_color is None + else bar_color) + background_color = (ScrollBar.DEFAULT_BACKGROUND_COLOR + if background_color is None + else background_color) self.bar_char = termstr.TermStr("█").fg_color(bar_color) self.background_char = termstr.TermStr(" ").bg_color(background_color) self.start_h_chars = [termstr.TermStr(char).fg_color( - self.background_color).bg_color(self.bar_color) + background_color).bg_color(bar_color) for char in self._HORIZONTAL_CHARS] self.end_h_chars = [termstr.TermStr(char).fg_color( - self.bar_color).bg_color(self.background_color) + bar_color).bg_color(background_color) for char in self._HORIZONTAL_CHARS] self.start_v_chars = [termstr.TermStr(char).fg_color( - self.bar_color).bg_color(self.background_color) + bar_color).bg_color(background_color) for char in self._VERTICAL_CHARS] self.end_v_chars = [termstr.TermStr(char).fg_color( - self.background_color).bg_color(self.bar_color) + background_color).bg_color(bar_color) for char in self._VERTICAL_CHARS] def appearance(self, dimensions): diff --git a/vigil/termstr.py b/vigil/termstr.py index 2144e0b..f35117e 100644 --- a/vigil/termstr.py +++ b/vigil/termstr.py @@ -49,6 +49,7 @@ class Color: blue = (0, 135, 189) lime = (0, 255, 0) yellow = (255, 211, 0) + grey_30 = (30, 30, 30) grey_50 = (50, 50, 50) grey_100 = (100, 100, 100) grey_150 = (150, 150, 150)