Skip to content

Commit

Permalink
screen: Add set_screen_resize() method.
Browse files Browse the repository at this point in the history
Sets a callback to run on terminal resize. Implemented using OS
SIGWINCH signal, and thus won't work in a general case (e.g. over
a serial connection).

Also, picotui stores absolute coordinates for each widget, so, to
handle resizing, all dialogs, etc. should be recreated from scratch
with new size.
  • Loading branch information
pfalcon committed Dec 28, 2017
1 parent 48935d6 commit e958af4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions picotui/screen.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import signal

from .defs import *

Expand Down Expand Up @@ -155,3 +156,7 @@ def screen_size(cls):
@classmethod
def set_screen_redraw(cls, handler):
cls.screen_redraw = handler

@classmethod
def set_screen_resize(cls, handler):
signal.signal(signal.SIGWINCH, lambda sig, stk: handler(cls))

0 comments on commit e958af4

Please sign in to comment.