ocaml-tmk-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Ocaml-tmk-devel] Handling xterm resizing


From: Erik de Castro Lopo
Subject: Re: [Ocaml-tmk-devel] Handling xterm resizing
Date: Mon, 1 Nov 2010 11:00:13 +1100

Richard Jones wrote:

> Actually I have no clue.  How does it work in C?  It
> likely works the same way in ocaml-curses.

In C, resize events result in the program getting a KEY_RESIZE
from getch(). This is default behaviour, I do not need to do
anything with SIGWINCH. From the ncurses(3) man pahe on Debian:

   The  ncurses  library  includes facilities for responding to window
   resizing events, e.g., when running in an xterm.  See the resizeterm
   (3NCURSES) and wresize(3NCURSES) manual pages for details.  In
   addition, the library may be configured with a SIGWINCH handler.

Since I don't have to supply a SIGWINCH handler in my C code I
suspect that ncurses on Debian is configured to provide is own.

For the Ocaml curses bindings, I notice that ml_curses.c defines
a SIGWINCH handler as:

    static void winch_handler(int n)
    {
      signal(n,winch_handler);
      ungetch(KEY_RESIZE);
    }

and that handler is installed when I call winch_handler_on() from
Ocaml code.

The odd thing is that when I don't call winch_handler_on(), my 
program aborts when the window is resized. This is strange, because
I expected it to default to the same behaviour as my C program.

Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]