[or-cvs] r23857: {arm} Couple fixes to try making the interface more resilient to r (arm/trunk/src/util)

Damian Johnson atagar1 at gmail.com
Wed Nov 24 17:08:30 UTC 2010


Author: atagar
Date: 2010-11-24 17:08:29 +0000 (Wed, 24 Nov 2010)
New Revision: 23857

Modified:
   arm/trunk/src/util/panel.py
Log:
Couple fixes to try making the interface more resilient to resizing while popups are visible:
- abandoning text input fields when the window's resized (otherwise the input
field is filled with unprintable characters.
- skip drawing strings if doing so would cause an error



Modified: arm/trunk/src/util/panel.py
===================================================================
--- arm/trunk/src/util/panel.py	2010-11-23 21:08:22 UTC (rev 23856)
+++ arm/trunk/src/util/panel.py	2010-11-24 17:08:29 UTC (rev 23857)
@@ -242,7 +242,12 @@
     # subwindows need a single character buffer (either in the x or y 
     # direction) from actual content to prevent crash when shrank
     if self.win and self.maxX > x and self.maxY > y:
-      self.win.addstr(y, x, msg[:self.maxX - x - 1], attr)
+      try:
+        self.win.addstr(y, x, msg[:self.maxX - x - 1], attr)
+      except:
+        # this might produce a _curses.error during edge cases, for instance
+        # when resizing with visible popups
+        pass
   
   def addfstr(self, y, x, msg):
     """
@@ -413,8 +418,8 @@
     
     # draws box around the scroll bar
     self.win.vline(drawTop, 1, curses.ACS_VLINE, self.maxY - 2)
-    self.win.vline(drawBottom, 1, curses.ACS_LRCORNER, 1)
-    self.win.hline(drawBottom, 0, curses.ACS_HLINE, 1)
+    self.win.addch(drawBottom, 1, curses.ACS_LRCORNER)
+    self.win.addch(drawBottom, 0, curses.ACS_HLINE)
   
   def _resetSubwindow(self):
     """
@@ -485,6 +490,10 @@
     elif key == curses.KEY_RIGHT and x >= msgLen - 1:
       # don't move the cursor if there's no content after it
       return None
+  elif key == -1:
+    # if we're resizing the display during text entry then cancel it
+    # (otherwise the input field is filled with nonprintable characters)
+    return curses.ascii.BEL
   
   return key
 



More information about the tor-commits mailing list