diff options
author | hut <hut@lavabit.com> | 2010-10-02 07:09:46 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-10-02 07:09:46 +0200 |
commit | f498e2ce0ccb04d02faf76f564bf765d00043964 (patch) | |
tree | 42e607c844c1b6e165be83919e2a1b5c26438859 | |
parent | 6b9651e6e7b8dcfc094626868f49cfb8216f4945 (diff) | |
download | ranger-f498e2ce0ccb04d02faf76f564bf765d00043964.tar.gz |
widgets.browsercolumn: display "~" when truncating filenames
-rw-r--r-- | ranger/gui/widgets/browsercolumn.py | 26 |
1 files 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: |