From 48945a6d34cfd5ec9ca67be813b6fccfc0a1dfdf Mon Sep 17 00:00:00 2001 From: squigz Date: Wed, 3 Jan 2018 13:49:40 -0500 Subject: Add option to draw separators between columns instead of drawing boxes --- ranger/container/settings.py | 1 + ranger/gui/widgets/view_miller.py | 46 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/ranger/container/settings.py b/ranger/container/settings.py index 2f38a2b6..1dc61046 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -40,6 +40,7 @@ ALLOWED_SETTINGS = { 'display_size_in_status_bar': bool, 'display_tags_in_all_columns': bool, 'draw_borders': bool, + 'draw_separators': bool, 'draw_progress_bar_in_status_bar': bool, 'flushinput': bool, 'freeze_files': bool, diff --git a/ranger/gui/widgets/view_miller.py b/ranger/gui/widgets/view_miller.py index 1f08e1af..209978ec 100644 --- a/ranger/gui/widgets/view_miller.py +++ b/ranger/gui/widgets/view_miller.py @@ -100,6 +100,8 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta DisplayableContainer.draw(self) if self.settings.draw_borders: self._draw_borders() + if self.settings.draw_separators: + self._draw_separators() if self.draw_bookmarks: self._draw_bookmarks() elif self.draw_hints: @@ -173,6 +175,50 @@ class ViewMiller(ViewBase): # pylint: disable=too-many-ancestors,too-many-insta self.addch(self.hei - 1, right_end, curses.ACS_LRCORNER) # pylint: enable=no-member + def _draw_separators(self): + win = self.win + separators = self.settings.draw_separators + self.color('in_browser', 'border') + + left_start = 0 + right_end = self.wid - 1 + + for child in self.columns: + if not child.has_preview(): + left_start = child.x + child.wid + else: + break + + # Shift the rightmost vertical line to the left to create a padding, + # but only when padding_right is on, the preview column is collapsed + # and we did not open the pager to "zoom" in to the file. + if self.settings.padding_right and not self.pager.visible and self.is_collapsed: + right_end = self.columns[-1].x - 1 + if right_end < left_start: + right_end = self.wid - 1 + + + # Draw the vertical lines in the middle + for child in self.columns[:-1]: + if not child.has_preview(): + continue + if child.main_column and self.pager.visible: + # If we "zoom in" with the pager, we have to + # skip the between main_column and pager. + break + x = child.x + child.wid + y = self.hei - 1 + try: + # pylint: disable=no-member + win.vline(1, x, curses.ACS_VLINE, y - 1) + self.addch(0, x, curses.ACS_VLINE, 0) + self.addch(y, x, curses.ACS_VLINE, 0) + # pylint: enable=no-member + except curses.error: + # in case it's off the boundaries + pass + + def _collapse(self): # Should the last column be cut off? (Because there is no preview) if not self.settings.collapse_preview or not self.preview \ -- cgit 1.4.1-2-gfad0