summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--doc/ranger.pod6
-rw-r--r--ranger/config/rc.conf4
-rw-r--r--ranger/container/settings.py1
-rw-r--r--ranger/gui/widgets/browsercolumn.py17
4 files changed, 26 insertions, 2 deletions
diff --git a/doc/ranger.pod b/doc/ranger.pod
index 8599a1a6..a4e782b3 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -968,6 +968,12 @@ Abbreviate $HOME with ~ in the titlebar (first line) of ranger?
 
 Use a unicode "..." character instead of "~" to mark cut-off filenames?
 
+=item bidi_support [bool]
+
+Try to properly display file names in RTL languages (Hebrew, Arabic) by using
+a BIDI algorithm to reverse the relevant parts of the text.
+Requires the python-bidi pip package.
+
 =item update_title [bool]
 
 Set a window title?
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index fe00c7c0..5a7a9a6d 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -101,6 +101,10 @@ set iterm2_font_height 11
 # Use a unicode "..." character to mark cut-off filenames?
 set unicode_ellipsis false
 
+# BIDI support - try to properly display file names in RTL languages (Hebrew, Arabic).
+# Requires the python-bidi pip package
+set bidi_support false
+
 # Show dotfiles in the bookmark preview box?
 set show_hidden_bookmarks true
 
diff --git a/ranger/container/settings.py b/ranger/container/settings.py
index 9f54f24d..9603401f 100644
--- a/ranger/container/settings.py
+++ b/ranger/container/settings.py
@@ -27,6 +27,7 @@ ALLOWED_SETTINGS = {
     'automatically_count_files': bool,
     'autosave_bookmarks': bool,
     'autoupdate_cumulative_size': bool,
+    'bidi_support': bool,
     'cd_bookmarks': bool,
     'cd_tab_case': str,
     'cd_tab_fuzzy': bool,
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py
index b3272cbc..b38595c1 100644
--- a/ranger/gui/widgets/browsercolumn.py
+++ b/ranger/gui/widgets/browsercolumn.py
@@ -10,6 +10,12 @@ 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
 
@@ -410,9 +416,16 @@ 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)
+        else:
+            return text
+
     def _draw_text_display(self, text, space):
-        wtext = WideString(text)
-        wext = WideString(splitext(text)[1])
+        bidi_text = self._bidi_transpose(text)
+        wtext = WideString(bidi_text)
+        wext = WideString(splitext(bidi_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
327099a61f8b16d5ba50abf3'>ff16e04f ^
2b250717 ^
ff16e04f ^





a7c3f156 ^


734eef7c ^
23d3a022 ^
dff1abb2 ^




a7c3f156 ^



734eef7c ^
a7c3f156 ^
734eef7c ^
a7c3f156 ^
734eef7c ^
dff1abb2 ^
2b250717 ^
dff1abb2 ^

78c50205 ^
734eef7c ^
dff1abb2 ^

ff16e04f ^
2b250717 ^
ff16e04f ^





a7c3f156 ^


734eef7c ^
23d3a022 ^
dff1abb2 ^







734eef7c ^
dff1abb2 ^
734eef7c ^
dff1abb2 ^
734eef7c ^
dff1abb2 ^
2b250717 ^
dff1abb2 ^

dff1abb2 ^
734eef7c ^
dff1abb2 ^

10bbca64 ^
2b250717 ^
ff16e04f ^





10bbca64 ^



dff1abb2 ^


734eef7c ^
dff1abb2 ^





10bbca64 ^
dff1abb2 ^

10bbca64 ^
dff1abb2 ^






10bbca64 ^




dff1abb2 ^
fda86efe ^
dff1abb2 ^



10bbca64 ^
dff1abb2 ^

f4eee01a ^
f2043a73 ^
dff1abb2 ^

734eef7c ^
dff1abb2 ^
734eef7c ^
dff1abb2 ^
734eef7c ^
dff1abb2 ^
2b250717 ^
dff1abb2 ^

dff1abb2 ^
734eef7c ^
dff1abb2 ^

a621ef95 ^

dff1abb2 ^

ff16e04f ^
2b250717 ^
ff16e04f ^

dff1abb2 ^


734eef7c ^
dff1abb2 ^






















734eef7c ^
dff1abb2 ^
734eef7c ^
dff1abb2 ^
734eef7c ^
dff1abb2 ^
2b250717 ^
dff1abb2 ^

dff1abb2 ^
734eef7c ^
dff1abb2 ^

ff16e04f ^
2b250717 ^
ff16e04f ^


2b250717 ^
ff16e04f ^

dff1abb2 ^


734eef7c ^
dff1abb2 ^




a7c3f156 ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225