From f498e2ce0ccb04d02faf76f564bf765d00043964 Mon Sep 17 00:00:00 2001 From: hut Date: Sat, 2 Oct 2010 07:09:46 +0200 Subject: widgets.browsercolumn: display "~" when truncating filenames --- ranger/gui/widgets/browsercolumn.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index d617e64e..6ed9ce6b 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -28,6 +28,7 @@ class BrowserColumn(Pager): target = None tagged_marker = '*' last_redraw_time = -1 + ellipsis = "~" old_dir = None old_cf = None @@ -207,11 +208,24 @@ class BrowserColumn(Pager): except IndexError: break + if self.display_infostring and drawn.infostring \ + and self.settings.display_size_in_main_column: + infostring = str(drawn.infostring) + " " + else: + infostring = "" + bad_info_color = None this_color = base_color + list(drawn.mimetype_tuple) text = drawn.basename tagged = self.fm.tags and drawn.realpath in self.fm.tags + space = self.wid - len(infostring) + if self.main_column: + space -= 2 + + if len(text) > space: + text = text[:space-1] + self.ellipsis + if i == selected_i: this_color.append('selected') @@ -257,14 +271,12 @@ class BrowserColumn(Pager): else: self.addnstr(line, 0, text, self.wid) - if self.display_infostring and drawn.infostring \ - and self.settings.display_size_in_main_column: - info = drawn.infostring - x = self.wid - 1 - len(info) - if info is BAD_INFO: - bad_info_color = (x, len(str(info))) + if infostring: + x = self.wid - 1 - len(infostring) + if infostring is BAD_INFO: + bad_info_color = (x, len(infostring)) if x > 0: - self.addstr(line, x, str(info) + ' ') + self.addstr(line, x, infostring) self.color_at(line, 0, self.wid, this_color) if bad_info_color: -- cgit 1.4.1-2-gfad0