diff options
author | hut <hut@lavabit.com> | 2010-05-17 20:18:57 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-05-17 20:18:57 +0200 |
commit | a23a3649948fd001f1d0fd6a932408c7d982fc14 (patch) | |
tree | b0fbf49bd91d1963e6aa5e746041bf5744f167bd | |
parent | c184e88b5caa66e1cda90019e6e74e0036a24959 (diff) | |
download | ranger-a23a3649948fd001f1d0fd6a932408c7d982fc14.tar.gz |
gui.*: failsafe addstrs
-rw-r--r-- | ranger/gui/curses_shortcuts.py | 11 | ||||
-rw-r--r-- | ranger/gui/widgets/browsercolumn.py | 8 | ||||
-rw-r--r-- | ranger/gui/widgets/browserview.py | 13 | ||||
-rw-r--r-- | ranger/gui/widgets/titlebar.py | 2 |
4 files changed, 21 insertions, 13 deletions
diff --git a/ranger/gui/curses_shortcuts.py b/ranger/gui/curses_shortcuts.py index 84df5930..3df45700 100644 --- a/ranger/gui/curses_shortcuts.py +++ b/ranger/gui/curses_shortcuts.py @@ -66,6 +66,17 @@ class CursesShortcuts(SettingsAware): except (_curses.error, TypeError): pass + def addch(self, *args): + try: + self.win.addch(*args) + except (_curses.error, TypeError): + pass + except UnicodeEncodeError: + try: + self.win.addch(*(ascii_only(obj) for obj in args)) + except (_curses.error, TypeError): + pass + def color(self, *keys): """Change the colors from now on.""" keys = flatten(keys) diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index 1e24e2dd..3909c8a2 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -195,7 +195,7 @@ class BrowserColumn(Pager): """Draw a preview of the file, if the settings allow it""" self.win.move(0, 0) if not self.target.accessible: - self.win.addnstr("not accessible", self.wid) + self.addnstr("not accessible", self.wid) Pager.close(self) return @@ -223,7 +223,7 @@ class BrowserColumn(Pager): if not self.target.content_loaded: self.color(base_color) - self.win.addnstr("...", self.wid) + self.addnstr("...", self.wid) self.color_reset() return @@ -232,13 +232,13 @@ class BrowserColumn(Pager): if not self.target.accessible: self.color(base_color, 'error') - self.win.addnstr("not accessible", self.wid) + self.addnstr("not accessible", self.wid) self.color_reset() return if self.target.empty(): self.color(base_color, 'empty') - self.win.addnstr("empty", self.wid) + self.addnstr("empty", self.wid) self.color_reset() return diff --git a/ranger/gui/widgets/browserview.py b/ranger/gui/widgets/browserview.py index a90231f2..c80e4885 100644 --- a/ranger/gui/widgets/browserview.py +++ b/ranger/gui/widgets/browserview.py @@ -144,7 +144,7 @@ class BrowserView(Widget, DisplayableContainer): if maxlen < self.wid: self.win.vline(0, maxlen, curses.ACS_VLINE, line+1) - self.win.addch(line+1, maxlen, curses.ACS_LRCORNER) + self.addch(line+1, maxlen, curses.ACS_LRCORNER) def _draw_borders(self): win = self.win @@ -188,13 +188,10 @@ class BrowserView(Widget, DisplayableContainer): # in case it's off the boundaries pass - win.addch(0, left_start, curses.ACS_ULCORNER) - win.addch(self.hei - 1, left_start, curses.ACS_LLCORNER) - win.addch(0, right_end, curses.ACS_URCORNER) - try: - win.addch(self.hei - 1, right_end, curses.ACS_LRCORNER) - except: - pass + self.addch(0, left_start, curses.ACS_ULCORNER) + self.addch(self.hei - 1, left_start, curses.ACS_LLCORNER) + self.addch(0, right_end, curses.ACS_URCORNER) + self.addch(self.hei - 1, right_end, curses.ACS_LRCORNER) def _collapse(self): # Should the last column be cut off? (Because there is no preview) diff --git a/ranger/gui/widgets/titlebar.py b/ranger/gui/widgets/titlebar.py index 17da7748..35e2e3d9 100644 --- a/ranger/gui/widgets/titlebar.py +++ b/ranger/gui/widgets/titlebar.py @@ -52,7 +52,7 @@ class TitleBar(Widget): self._print_result(self.result) if self.wid > 2: self.color('in_titlebar', 'throbber') - self.win.addnstr(self.y, self.wid - 2 - self.tab_width, + self.addnstr(self.y, self.wid - 2 - self.tab_width, self.throbber, 1) def click(self, event): |