bug-ncurses
[Top][All Lists]
Advanced

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

Re: ncurses, OS X and terminal size


From: Folkert van Heusden
Subject: Re: ncurses, OS X and terminal size
Date: Sun, 19 Mar 2006 00:22:07 +0100
User-agent: Mutt/1.5.10i

What I do in my code, which is verified to work with macosx 10.2 is the
following:

void determine_terminal_size(int *max_y, int *max_x)
{
        struct winsize size;

        *max_x = *max_y = 0;

        /* changed from 'STDIN_FILENO' as that is incorrect: we're
         * outputting to stdout!
         */
        if (ioctl(1, TIOCGWINSZ, &size) == 0)
        {
                *max_y = size.ws_row;
                *max_x = size.ws_col;
        }

        if (!*max_x || !*max_y)
        {
                char *dummy = getenv("COLUMNS");
                if (dummy)
                        *max_x = atoi(dummy);
                else
                        *max_x = 80;

                dummy = getenv("LINES");
                if (dummy)
                        *max_x = atoi(dummy);
                else
                        *max_x = 24;
        }
}

I run it especially when I get a SIGWINCH signal.


Folkert van Heusden

-- 
www.vanheusden.com/multitail - multitail is tail on steroids. multiple
               windows, filtering, coloring, anything you can think of
----------------------------------------------------------------------
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com




reply via email to

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