diff options
-rw-r--r-- | ranger/gui/displayable.py | 11 | ||||
-rw-r--r-- | ranger/gui/widgets/browsercolumn.py | 13 | ||||
-rw-r--r-- | ranger/gui/widgets/titlebar.py | 6 |
3 files changed, 16 insertions, 14 deletions
diff --git a/ranger/gui/displayable.py b/ranger/gui/displayable.py index 23ac43c7..67128f30 100644 --- a/ranger/gui/displayable.py +++ b/ranger/gui/displayable.py @@ -8,6 +8,12 @@ import curses from ranger.core.shared import FileManagerAware from ranger.gui.curses_shortcuts import CursesShortcuts +try: + from bidi.algorithm import get_display # pylint: disable=import-error + HAVE_BIDI = True +except ImportError: + HAVE_BIDI = False + class Displayable( # pylint: disable=too-many-instance-attributes FileManagerAware, CursesShortcuts): @@ -209,6 +215,11 @@ class Displayable( # pylint: disable=too-many-instance-attributes def __str__(self): return self.__class__.__name__ + def bidi_transpose(self, text): + if self.settings.bidi_support and HAVE_BIDI: + return get_display(text) + return text + class DisplayableContainer(Displayable): """DisplayableContainers are Displayables which contain other Displayables. diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index 491a5fa4..3d68f017 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -10,12 +10,6 @@ import stat from time import time from os.path import splitext -try: - from bidi.algorithm import get_display # pylint: disable=import-error - HAVE_BIDI = True -except ImportError: - HAVE_BIDI = False - from ranger.ext.widestring import WideString from ranger.core import linemode @@ -424,13 +418,8 @@ class BrowserColumn(Pager): # pylint: disable=too-many-instance-attributes def _total_len(predisplay): return sum([len(WideString(s)) for s, _ in predisplay]) - def _bidi_transpose(self, text): - if self.settings.bidi_support and HAVE_BIDI: - return get_display(text) - return text - def _draw_text_display(self, text, space): - bidi_text = self._bidi_transpose(text) + bidi_text = self.bidi_transpose(text) wtext = WideString(bidi_text) wext = WideString(splitext(bidi_text)[1]) wellip = WideString(self.ellipsis[self.settings.unicode_ellipsis]) diff --git a/ranger/gui/widgets/titlebar.py b/ranger/gui/widgets/titlebar.py index 765c1248..e9eb1b8b 100644 --- a/ranger/gui/widgets/titlebar.py +++ b/ranger/gui/widgets/titlebar.py @@ -114,12 +114,14 @@ class TitleBar(Widget): else: clr = 'directory' - bar.add(path.basename, clr, directory=path) + bidi_basename = self.bidi_transpose(path.basename) + bar.add(bidi_basename, clr, directory=path) bar.add('/', clr, fixed=True, directory=path) if self.fm.thisfile is not None and \ self.settings.show_selection_in_titlebar: - bar.add(self.fm.thisfile.relative_path, 'file') + bidi_file_path = self.bidi_transpose(self.fm.thisfile.relative_path) + bar.add(bidi_file_path, 'file') def _get_right_part(self, bar): # TODO: fix that pressed keys are cut off when chaining CTRL keys |