On Tue, 18 Mar 2008, Simon Kuhnle wrote:
On Tue, Mar 18, 2008 at 09:38:48AM +0100, Markus Hennecke wrote:
On Sun, 16 Mar 2008, Simon Kuhnle wrote:
I don't know if I'm the only one with that problem but net/mcabber
doesn't resize correctly if I resize my xterm or rxvt. I hit ctrl-L, and
it refreshes the screen but the size is not correct to the terminal size
it's in.
I asked on the mcabber MUC and it seems that under Linux this isn't a
problem.
So is it possible that mcabber uses an ncurses function to resize that
OpenBSD doesn't know?
This is because OpenBSDs ncurses is compiled without SIGWINCH support.
See src/lib/libcurses/ncurses_cfg.h, the commented define for USE_SIGWINCH.
mcabber relies on the curses implementation to inject a KEY_RESIZE into the
key buffer, this is only done if that curses handles SIGWINCH.
Thank you for the explanation, Markus.
But why is this the case? Is it insecure? Or does it fail on some
platforms? I wasn't able to find an answer for this.
Neither did I find an answer, but if you look into the history of the
ncurses config file then you will see that it was never enabled.
I attach a rather brute script to force resizing mcabber (which works
for me, with hitting ctrl-l). But perhaps someones know a more clever
solution?
You could manually enable it for your system in that file, but I don't know
what else could break. Another solution would be to handle SIGWINCH in
mcabber itself. I think I will take a look into that.
How hard would it be to do that?
It would be nice to have a somewhat cleaner approach to this problem
than my patch does it ;-)
Could you take a look at the attached patch file and try the port with
the patch applied? For me it will fix the resizing issues. All it does
is to act on the SIGWINCH, read the terminal size via ioctl and tell the
ncurses lib the new terminal size. Keycodes for KEY_RESIZE and ctrl-l
are injected so that the screen is redrawn. I don't think that this hack
will make it upstream, but it is something to start with.
Kind regards
Markus
$OpenBSD$
--- src/main.c.orig Sun Jan 13 11:36:27 2008
+++ src/main.c Tue Mar 18 18:23:14 2008
@@ -27,6 +27,8 @@
#include <signal.h>
#include <termios.h>
#include <getopt.h>
+#include <util.h>
+#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <glib.h>
@@ -210,6 +212,13 @@ void sig_handler(int signum)
mcabber_terminate("Killed by SIGTERM");
} else if (signum == SIGINT) {
mcabber_terminate("Killed by SIGINT");
+ } else if (signum == SIGWINCH) {
+ struct winsize size;
+ if (ioctl(STDIN_FILENO, TIOCGWINSZ, &size) != -1) {
+ resizeterm(size.ws_row, size.ws_col);
+ }
+ ungetch(KEY_RESIZE);
+ ungetch(12);
} else {
scr_LogPrint(LPRINT_LOGNORM, "Caught signal: %d", signum);
}
@@ -364,6 +373,7 @@ int main(int argc, char **argv)
signal(SIGTERM, sig_handler);
signal(SIGINT, sig_handler);
signal(SIGCHLD, sig_handler);
+ signal(SIGWINCH, sig_handler);
signal(SIGPIPE, SIG_IGN);
/* Parse command line options */