Created
March 21, 2013 12:29
-
-
Save aroig/5212672 to your computer and use it in GitHub Desktop.
Fixes Issue 80
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 3319195a9de8b59cbfb90c4c630a29f0107f8b1f Mon Sep 17 00:00:00 2001 | |
From: Abdo Roig-Maranges <abdo.roig@gmail.com> | |
Date: Thu, 21 Mar 2013 13:24:36 +0100 | |
Subject: [PATCH] Fix Issue #80 that crashed ranger when resized too small | |
This fixes Issue #80 and cleans up the code a bit so this particular | |
fragment is more readable. | |
--- | |
ranger/gui/widgets/browsercolumn.py | 48 +++++++++++++++++++++---------------- | |
1 file changed, 27 insertions(+), 21 deletions(-) | |
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py | |
index a4ba7ee..d705e6b 100644 | |
--- a/ranger/gui/widgets/browsercolumn.py | |
+++ b/ranger/gui/widgets/browsercolumn.py | |
@@ -265,27 +265,33 @@ class BrowserColumn(Pager): | |
# colorscheme, to compute the curses attribute. | |
predisplay_left = [] | |
predisplay_right = [] | |
- | |
- predisplay_left += self._draw_tagged_display(tagged, tagged_marker) | |
- predisplay_right += self._draw_vcsstring_display(drawn) | |
- space = self.wid - self._total_len(predisplay_left) - \ | |
- self._total_len(predisplay_right) | |
- | |
- # If not enough space | |
- if space <= 2: | |
- del predisplay_right[:] | |
- del predisplay_left[:] | |
- | |
+ space = self.wid | |
+ | |
+ # selection mark | |
+ tagmark = self._draw_tagged_display(tagged, tagged_marker) | |
+ tagmarklen = self._total_len(tagmark) | |
+ if space - tagmarklen > 2: | |
+ predisplay_left += tagmark | |
+ space -= tagmarklen | |
+ | |
+ # vcs data | |
+ vcsstring = self._draw_vcsstring_display(drawn) | |
+ vcsstringlen = self._total_len(vcsstring) | |
+ if space - vcsstringlen > 2: | |
+ predisplay_right += vcsstring | |
+ space -= vcsstringlen | |
+ | |
+ # info string | |
infostring = self._draw_infostring_display(drawn, space) | |
- space -= self._total_len(infostring) | |
- | |
- predisplay_left += self._draw_text_display(text, space) | |
- space = self.wid - self._total_len(predisplay_left) - \ | |
- self._total_len(predisplay_right) | |
+ infostringlen = self._total_len(infostring) | |
+ if space - infostringlen > 2: | |
+ predisplay_right = infostring + predisplay_right | |
+ space -= infostringlen | |
- predisplay_right = infostring + predisplay_right | |
- space = self.wid - self._total_len(predisplay_left) - \ | |
- self._total_len(predisplay_right) | |
+ textstring = self._draw_text_display(text, space) | |
+ textstringlen = self._total_len(textstring) | |
+ predisplay_left += textstring | |
+ space -= textstringlen | |
if space > 0: | |
predisplay_left.append([' ' * space, []]) | |
@@ -314,9 +320,9 @@ class BrowserColumn(Pager): | |
def _draw_text_display(self, text, space): | |
wtext = WideString(text) | |
+ wellip = WideString(self.ellipsis[self.settings.unicode_ellipsis]) | |
if len(wtext) > space: | |
- wtext = wtext[:max(0, space - 1)] + \ | |
- self.ellipsis[self.settings.unicode_ellipsis] | |
+ wtext = wtext[:max(0, space - len(wellip))] + wellip | |
return [[str(wtext), []]] | |
-- | |
1.8.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment