From 60d5880785647a9c4c8fbee760fac4ef4179ec30 Mon Sep 17 00:00:00 2001 From: Marcel Partap Date: Thu, 9 Apr 2015 13:19:48 +0200 Subject: Show file extension for cut-off filenames. If still too long, trunca… MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Somewhat goes against the code logic to let os.path.foo() operate on a "text" object, but. --- ranger/gui/widgets/browsercolumn.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index b38d0b5b..0dc39a9b 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -7,6 +7,7 @@ import curses import stat from time import time +from os.path import splitext from . import Widget from .pager import Pager @@ -342,7 +343,11 @@ class BrowserColumn(Pager): def _draw_text_display(self, text, space): wtext = WideString(text) + wext = WideString(splitext(text)[1]) wellip = WideString(self.ellipsis[self.settings.unicode_ellipsis]) + if len(wtext) > space: + wtext = wtext[:max(1, space - len(wext) - len(wellip))] + wellip + wext + # Truncate again if still too long. if len(wtext) > space: wtext = wtext[:max(0, space - len(wellip))] + wellip -- cgit 1.4.1-2-gfad0