diff options
author | Ethan Kiang <chocopuff298@gmail.com> | 2019-12-06 19:02:54 -0500 |
---|---|---|
committer | toonn <toonn@toonn.io> | 2020-11-18 18:38:48 +0100 |
commit | 8a9b020ee597f9b388c5aa6fca159cfdc7f9e163 (patch) | |
tree | 0ef2a5b5c1f224804922cf06d14759e376b49ed6 /ranger | |
parent | 476f9703592259969b1f194ca5924edf9753b87d (diff) | |
download | ranger-8a9b020ee597f9b388c5aa6fca159cfdc7f9e163.tar.gz |
created floating style borders for multipane
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/container/settings.py | 2 | ||||
-rw-r--r-- | ranger/gui/widgets/view_multipane.py | 71 |
2 files changed, 42 insertions, 31 deletions
diff --git a/ranger/container/settings.py b/ranger/container/settings.py index 677ea3b8..b38b31b5 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -104,7 +104,7 @@ ALLOWED_SETTINGS = { ALLOWED_VALUES = { 'cd_tab_case': ['sensitive', 'insensitive', 'smart'], 'confirm_on_delete': ['multiple', 'always', 'never'], - 'draw_borders': ['none', 'both', 'outline', 'separators'], + 'draw_borders': ['none', 'both', 'outline', 'separators', 'floating'], 'line_numbers': ['false', 'absolute', 'relative'], 'nested_ranger_warning': ['true', 'false', 'error'], 'one_indexed': [False, True], diff --git a/ranger/gui/widgets/view_multipane.py b/ranger/gui/widgets/view_multipane.py index 0ff849c9..7e8108a6 100644 --- a/ranger/gui/widgets/view_multipane.py +++ b/ranger/gui/widgets/view_multipane.py @@ -66,52 +66,63 @@ class ViewMultipane(ViewBase): # pylint: disable=too-many-ancestors elif self.draw_info: self._draw_info(self.draw_info) + def _draw_border_rectangle(self, left_start, right_end): + win = self.win + win.hline(0, left_start, curses.ACS_HLINE, right_end - left_start) + win.hline(self.hei - 1, left_start, curses.ACS_HLINE, right_end - left_start) + win.vline(1, left_start, curses.ACS_VLINE, self.hei - 2) + win.vline(1, right_end, curses.ACS_VLINE, self.hei - 2) + # Draw the four corners + self.addch(0, left_start, curses.ACS_ULCORNER) + self.addch(self.hei - 1, left_start, curses.ACS_LLCORNER) + self.addch(0, right_end, curses.ACS_URCORNER) + self.addch(self.hei - 1, right_end, curses.ACS_LRCORNER) + def _draw_borders(self, border_types): # Referenced from ranger.gui.widgets.view_miller win = self.win - self.color('in_browser', 'border') left_start = 0 right_end = self.wid - 1 # Draw the outline borders - if 'outline' in border_types: - try: - win.hline(0, left_start, curses.ACS_HLINE, right_end - left_start) - win.hline(self.hei - 1, left_start, curses.ACS_HLINE, right_end - left_start) - win.vline(1, left_start, curses.ACS_VLINE, self.hei - 2) - win.vline(1, right_end, curses.ACS_VLINE, self.hei - 2) - # Draw the four corners - self.addch(0, left_start, curses.ACS_ULCORNER) - self.addch(self.hei - 1, left_start, curses.ACS_LLCORNER) - self.addch(0, right_end, curses.ACS_URCORNER) - self.addch(self.hei - 1, right_end, curses.ACS_LRCORNER) - except curses.error: - pass - - # Draw the column separators - if 'separators' in border_types: - for child in self.columns[:-1]: - x = child.x + child.wid - y = self.hei - 1 + if 'floating' not in border_types: + if 'outline' in border_types: try: - win.vline(1, x, curses.ACS_VLINE, y - 1) - if 'outline' in border_types: - self.addch(0, x, curses.ACS_TTEE, 0) - self.addch(y, x, curses.ACS_BTEE, 0) - else: - self.addch(0, x, curses.ACS_VLINE, 0) - self.addch(y, x, curses.ACS_VLINE, 0) + self._draw_border_rectangle(left_start, right_end) except curses.error: - # boundary out of index safety pass + # Draw the column separators + if 'separators' in border_types: + for child in self.columns[:-1]: + x = child.x + child.wid + y = self.hei - 1 + try: + win.vline(1, x, curses.ACS_VLINE, y - 1) + if 'outline' in border_types: + self.addch(0, x, curses.ACS_TTEE, 0) + self.addch(y, x, curses.ACS_BTEE, 0) + else: + self.addch(0, x, curses.ACS_VLINE, 0) + self.addch(y, x, curses.ACS_VLINE, 0) + except curses.error: + pass + else: + bordered_column = self.main_column + left_start = max(bordered_column.x, 0) + right_end = min(left_start + bordered_column.wid, self.wid - 1) + try: + self._draw_border_rectangle(left_start, right_end) + except curses.error: + pass + def resize(self, y, x, hei=None, wid=None): ViewBase.resize(self, y, x, hei, wid) border_type = self.settings.draw_borders.lower() - if border_type in ['outline', 'both', 'true']: + if border_type in ['outline', 'both', 'true', 'floating']: # 'true' for backwards compat., no height pad needed for 'separators' pad = 1 else: @@ -123,4 +134,4 @@ class ViewMultipane(ViewBase): # pylint: disable=too-many-ancestors column.resize(top + pad, left, hei - pad * 2, max(1, column_width)) left += column_width + 1 column.need_redraw = True - self.need_redraw = True + self.need_redraw = True \ No newline at end of file |