]> code.delx.au - offlineimap/commitdiff
/offlineimap/head: changeset 363
authorjgoerzen <jgoerzen>
Thu, 13 Mar 2003 23:47:09 +0000 (00:47 +0100)
committerjgoerzen <jgoerzen>
Thu, 13 Mar 2003 23:47:09 +0000 (00:47 +0100)
Fixed ability to resize windows under Curses.

offlineimap/head/offlineimap/ui/Curses.py

index 360787b256b25ed0bc11c835e8f497bcc7caa58b..df409b0efcda2ae6e666225aaa3873eb7401ff5d 100644 (file)
 #    along with this program; if not, write to the Free Software
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+DEBUGLOG = open("/tmp/debug", "wt")
+
 from Blinkenlights import BlinkenBase
 from UIBase import UIBase
 from threading import *
-import thread, time, sys, os
+import thread, time, sys, os, signal, time
 from offlineimap import version, threadutil
 from offlineimap.threadutil import MultiLock
 
@@ -121,8 +123,14 @@ class CursesUtil:
         del self.stdscr
 
     def reset(self):
+        DEBUGLOG.write("  in reset...\n")
+        DEBUGLOG.flush()
         self.stop()
+        DEBUGLOG.write("  stop done...\n")
+        DEBUGLOG.flush()
         self.start()
+        DEBUGLOG.write("  start done...\n")
+        DEBUGLOG.flush()
 
 class CursesAccountFrame:
     def __init__(s, master, accountname):
@@ -318,6 +326,46 @@ class Blinkenlights(BlinkenBase, UIBase):
         s.gettf().setcolor('red')
         s._msg(version.banner)
         s.inputhandler.set_bgchar(s.keypress)
+        signal.signal(signal.SIGWINCH, s.resizehandler)
+        s.resizelock = Lock()
+        s.resizecount = 0
+
+    def resizehandler(s, signum, frame):
+        s.resizeterm()
+
+    def resizeterm(s, dosleep = 1):
+        DEBUGLOG.write("\nResizeterm called...\n")
+        DEBUGLOG.write("pid: %d\n" % os.getpid())
+        if not s.resizelock.acquire(0):
+            s.resizecount += 1
+            DEBUGLOG.write("Already resizing; aborting.\n")
+            return
+        else:
+            DEBUGLOG.write("Got the lock\n")
+        signal.signal(signal.SIGWINCH, signal.SIG_IGN)
+        s.aflock.acquire()
+        s.c.lock()
+        DEBUGLOG.write("locks acquired...\n")
+        s.resizecount += 1
+        DEBUGLOG.write("at top of try\n")
+        while s.resizecount:
+            DEBUGLOG.write("in while loop\n")
+            s.c.reset()
+            DEBUGLOG.write("reset done...\n")
+            DEBUGLOG.write("sleep done...\n")
+            DEBUGLOG.flush()
+            s.setupwindows()
+            DEBUGLOG.write("setupwindows done...\n")
+            s.resizecount -= 1
+        DEBUGLOG.write("exiting while loop...\n")
+        DEBUGLOG.write("in finally section...\n")
+        s.c.unlock()
+        s.aflock.release()
+        s.resizelock.release()
+        signal.signal(signal.SIGWINCH, s.resizehandler)
+        if dosleep:
+            time.sleep(1)
+            s.resizeterm(0)
 
     def isusable(s):
         # Not a terminal?  Can't use curses.