Text mode screen size max. compatibility

Dan Nelson dnelson at allantgroup.com
Fri Jul 23 19:24:59 UTC 2010


In the last episode (Jul 23), Polytropon said:
> On Fri, 23 Jul 2010 15:44:27 -0300 (ADT), "A. Wright" <andrew at qemg.org> wrote:
> > 
> > On Fri, 23 Jul 2010, Polytropon wrote:
> > > Is there a way to easily determine the terminal output size at program
> > > startup so the program can be preconfigured for certain screen sizes,
> > > and even refuse to run if it's less than 80x25?
> > 
> > The "curses" library will do this.  The variables LINES and COLS will
> > tell you what you want.
> 
> Cool - I planned to use (n)curses anyway. But one question remains: Is
> there an "interrupt line" (or something functionally similar, a flag or
> whatever) that will give the chance for a notification if LINES or COLS
> has recently changed, e.  g.  through a window size modification?

If you haven't trapped the SIGWINCH signal (which is sent on terminal size
changes) yourself, ncurses will install its own handler.  It will queue a
virtual KEY_RESIZE keypress that you can check for in your input loop.  You
can then redraw your display to fit the new window size.

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-questions mailing list