summaryrefslogtreecommitdiff
path: root/tcvt.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2013-06-02 15:36:11 +0200
committerHelmut Grohne <helmut@subdivi.de>2013-06-02 15:36:11 +0200
commit70228ca2e5af1968f3b4d3277212008c15875980 (patch)
tree9a9498eff599ee080e653cf0266b7e3a3ac6a9b2 /tcvt.py
parentccf38158e6e7fefd2b7bdbde243da98ffff79270 (diff)
downloadtcvt-70228ca2e5af1968f3b4d3277212008c15875980.tar.gz
fix WINCH handling
* The switch to single column on WINCH was a bad idea. * The new window would get old dimensions, because we would reinitialize windows before curses noticed the new dimensions.
Diffstat (limited to 'tcvt.py')
-rwxr-xr-xtcvt.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/tcvt.py b/tcvt.py
index 4393cfb..9252bad 100755
--- a/tcvt.py
+++ b/tcvt.py
@@ -111,14 +111,19 @@ class Simple:
def inch(self):
return self.screen.inch()
+class BadWidth(Exception):
+ pass
+
class Columns:
def __init__(self, curseswindow, numcolumns=2):
self.screen = curseswindow
self.height, width = self.screen.getmaxyx()
- assert numcolumns > 1
+ if numcolumns < 1:
+ raise BadWidth("need at least two columns")
self.numcolumns = numcolumns
self.columnwidth = (width - (numcolumns - 1)) // numcolumns
- assert self.columnwidth > 0
+ if self.columnwidth <= 0:
+ raise BadWidth("resulting column width too small")
self.windows = []
for i in range(numcolumns):
window = self.screen.derwin(self.height, self.columnwidth,
@@ -311,8 +316,12 @@ class Terminal:
self.screen.refresh()
def resized(self):
- self.screen = Simple(self.realscreen)
+ # The refresh call causes curses to notice the new dimensions.
self.screen.refresh()
+ try:
+ self.screen = Columns(self.realscreen, self.columns)
+ except BadWidth:
+ self.screen = Simple(self.realscreen)
def resizepty(self, ptyfd):
ym, xm = self.screen.getmaxyx()