home · contact · privacy
New client: Handle window resizing.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 25 Sep 2015 02:11:25 +0000 (04:11 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 25 Sep 2015 02:11:25 +0000 (04:11 +0200)
client_prototype.py

index 55ff80278e90865fee3126f83e23fc9c56e87be8..cdbe616dad24157b40594f51c7800ae2867dfcd1 100644 (file)
@@ -1,4 +1,5 @@
 import curses
 import curses
+import signal
 
 
 def set_window_geometries():
 
 
 def set_window_geometries():
@@ -69,6 +70,10 @@ def set_window_geometries():
                         break
                     win_test = win_high
 
                         break
                     win_test = win_high
 
+    global screen_size, stdscr
+    curses.endwin()
+    stdscr = curses.initscr()
+    screen_size = stdscr.getmaxyx()
     for win in windows:
         set_window_size()
         place_window()
     for win in windows:
         set_window_size()
         place_window()
@@ -123,6 +128,7 @@ def draw_screen():
                             and x_in_screen < screen_size[1]):
                         stdscr.addch(y_in_screen, x_in_screen, cell)
 
                             and x_in_screen < screen_size[1]):
                         stdscr.addch(y_in_screen, x_in_screen, cell)
 
+    stdscr.clear()
     draw_window_border_lines()
     draw_window_border_corners()
     draw_window_contents()
     draw_window_border_lines()
     draw_window_border_corners()
     draw_window_contents()
@@ -133,12 +139,13 @@ def main(stdscr):
     curses.noecho()
     curses.curs_set(False)
     # stdscr.keypad(True)
     curses.noecho()
     curses.curs_set(False)
     # stdscr.keypad(True)
+    signal.signal(signal.SIGWINCH,
+        lambda ignore_1, ignore_2: set_window_geometries())
     set_window_geometries()
     while True:
         draw_screen()
         stdscr.getch()
 
     set_window_geometries()
     while True:
         draw_screen()
         stdscr.getch()
 
-
 def foo():
     winmap = ['.', 'o', '.', 'o', 'O', 'o', '.', 'o', '.', 'x', 'y', 'x']
     size = [4, 3]
 def foo():
     winmap = ['.', 'o', '.', 'o', 'O', 'o', '.', 'o', '.', 'x', 'y', 'x']
     size = [4, 3]
@@ -155,7 +162,7 @@ windows = [
 ]
 
 sep_size = 1  # Width of inter-window borders and title bars.
 ]
 
 sep_size = 1  # Width of inter-window borders and title bars.
-stdscr = curses.initscr()
-screen_size = stdscr.getmaxyx()
+stdscr = None
+screen_size = [0,0]
 
 curses.wrapper(main)
 
 curses.wrapper(main)