summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-07-31 04:45:02 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-07-31 04:45:02 +0200
commit55daf9d49df4a0e0774b27acd33735abf80f80dd (patch)
tree334987b1e41d973d1a6a7c7000271446daa58237 /src/core
parent0da967850dc24a69d4e521484cc85691ab31b167 (diff)
downloadpoezio-55daf9d49df4a0e0774b27acd33735abf80f80dd.tar.gz
poezio-55daf9d49df4a0e0774b27acd33735abf80f80dd.tar.bz2
poezio-55daf9d49df4a0e0774b27acd33735abf80f80dd.tar.xz
poezio-55daf9d49df4a0e0774b27acd33735abf80f80dd.zip
Make the resize work, using an ugly workaround
It seems efficient (more than the curses.endwin(); stdscr.refresh() stuf, which is slow and really really ugly) and it doesn't break my lovely main loop, so it’s all good (except that it uses shutil…)
Diffstat (limited to 'src/core')
-rw-r--r--src/core/core.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/core/core.py b/src/core/core.py
index c2996b5d..446cc9f0 100644
--- a/src/core/core.py
+++ b/src/core/core.py
@@ -11,6 +11,7 @@ log = logging.getLogger(__name__)
import asyncio
import collections
+import shutil
import curses
import os
import pipes
@@ -482,6 +483,27 @@ class Core(object):
pass
sys.__excepthook__(typ, value, trace)
+ def sigwinch_handler(self):
+ """A work-around for ncurses resize stuff, which sucks. Normally, ncurses
+ catches SIGWINCH itself. In its signal handler, it updates the
+ windows structures (for example the size, etc) and it
+ ungetch(KEY_RESIZE). That way, the next time we call getch() we know
+ that a resize occured and we can act on it. BUT poezio doesn’t call
+ getch() until it knows it will return something. The problem is we
+ can’t know that, because stdin is not affected by this KEY_RESIZE
+ value (it is only inserted in a ncurses internal fifo that we can’t
+ access).
+
+ The (ugly) solution is to handle SIGWINCH ourself, trigger the
+ change of the internal windows sizes stored in ncurses module, using
+ sizes that we get using shutil, ungetch the KEY_RESIZE value and
+ then call getch to handle the resize on poezio’s side properly.
+ """
+ size = shutil.get_terminal_size()
+ curses.resizeterm(size.lines, size.columns)
+ curses.ungetch(curses.KEY_RESIZE)
+ self.on_input_readable()
+
def on_input_readable(self):
"""
main loop waiting for the user to press a key
@@ -562,8 +584,8 @@ class Core(object):
self.do_command(replace_line_breaks(char), False)
else:
self.do_command(''.join(char_list), True)
- self.doupdate()
self.xmpp.plugin['xep_0012'].begin_idle(jid=self.xmpp.boundjid)
+ self.doupdate()
def save_config(self):
"""