summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lepus.uberspace.de>2014-04-23 20:40:19 +0200
committerhut <hut@lepus.uberspace.de>2014-04-23 20:40:19 +0200
commit7c869ebddb5148a6b5f62be8d2c871ce0f03da07 (patch)
tree1990182047ca11eeb2cbce92e69c04a8d29f57c7
parent0ba6150eefe3572af00f801534228ad83c8f625c (diff)
downloadranger-7c869ebddb5148a6b5f62be8d2c871ce0f03da07.tar.gz
Workaround in py3.4.0 for swapped x/y in curses addch()
See http://bugs.python.org/issue21088,
https://github.com/hut/ranger/issues/122
-rw-r--r--ranger/gui/curses_shortcuts.py5
-rw-r--r--ranger/gui/widgets/browserview.py4
2 files changed, 7 insertions, 2 deletions
diff --git a/ranger/gui/curses_shortcuts.py b/ranger/gui/curses_shortcuts.py
index bc07f837..e75205d6 100644
--- a/ranger/gui/curses_shortcuts.py
+++ b/ranger/gui/curses_shortcuts.py
@@ -4,10 +4,13 @@
 
 import curses
 import _curses
+import sys
 
 from ranger.gui.color import get_color
 from ranger.core.shared import SettingsAware
 
+REVERSE_ADDCH_ARGS = sys.version[0:5] == '3.4.0'
+
 def _fix_surrogates(args):
     return [isinstance(arg, str) and arg.encode('utf-8', 'surrogateescape')
             .decode('utf-8', 'replace') or arg for arg in args]
@@ -43,6 +46,8 @@ class CursesShortcuts(SettingsAware):
                     pass
 
     def addch(self, *args):
+        if REVERSE_ADDCH_ARGS and len(args) >= 3:
+            args = [args[1], args[0]] + list(args[2:])
         try:
             self.win.addch(*args)
         except:
diff --git a/ranger/gui/widgets/browserview.py b/ranger/gui/widgets/browserview.py
index 1f2dd457..618d15a8 100644
--- a/ranger/gui/widgets/browserview.py
+++ b/ranger/gui/widgets/browserview.py
@@ -163,8 +163,8 @@ class BrowserView(Widget, DisplayableContainer):
             y = self.hei - 1
             try:
                 win.vline(1, x, curses.ACS_VLINE, y - 1)
-                win.addch(0, x, curses.ACS_TTEE, 0)
-                win.addch(y, x, curses.ACS_BTEE, 0)
+                self.addch(0, x, curses.ACS_TTEE, 0)
+                self.addch(y, x, curses.ACS_BTEE, 0)
             except:
                 # in case it's off the boundaries
                 pass