about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2013-02-21 23:36:57 +0100
committerhut <hut@lavabit.com>2013-02-21 23:44:38 +0100
commitcb5c9a51c28a77f981a109e109bbf14874f62009 (patch)
tree1903c2602d201f4d21ae251e79e574f765d14854
parent38a7bfc454752cc458243365e9431fc60504d6da (diff)
downloadranger-cb5c9a51c28a77f981a109e109bbf14874f62009.tar.gz
widgets.browserview: fix border drawing in all corner cases
Border drawing depends on many things:
- is the preview column collapsed?
- is padding_right on?
- is preview_files on?
- is preview_directories on?
- is the pager opened? ("i" key)
- does the current file have a preview?

This commit should fix border drawing in all of the mentioned cases.
-rw-r--r--ranger/gui/widgets/browserview.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/ranger/gui/widgets/browserview.py b/ranger/gui/widgets/browserview.py
index e0a2275e..bfdf9ea9 100644
--- a/ranger/gui/widgets/browserview.py
+++ b/ranger/gui/widgets/browserview.py
@@ -131,15 +131,17 @@ class BrowserView(Widget, DisplayableContainer):
                 left_start = child.x + child.wid
             else:
                 break
-        if not self.pager.visible:
-            for child in reversed(self.columns):
-                if not child.has_preview():
-                    right_end = child.x - 1
-                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 horizontal lines and the leftmost vertical line
         try:
             win.hline(0, left_start, curses.ACS_HLINE, right_end - left_start)
             win.hline(self.hei - 1, left_start, curses.ACS_HLINE,
@@ -148,11 +150,13 @@ class BrowserView(Widget, DisplayableContainer):
         except _curses.error:
             pass
 
-        for child in self.columns:
+        # 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:
-                win.vline(1, right_end, curses.ACS_VLINE, self.hei - 2)
+                # 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
@@ -164,6 +168,12 @@ class BrowserView(Widget, DisplayableContainer):
                 # in case it's off the boundaries
                 pass
 
+        # Draw the last vertical line
+        try:
+            win.vline(1, right_end, curses.ACS_VLINE, self.hei - 2)
+        except _curses.error:
+            pass
+
         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)