bug-ncurses
[Top][All Lists]
Advanced

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

resizing of terminals fails


From: Folkert van Heusden
Subject: resizing of terminals fails
Date: Fri, 28 Mar 2003 22:36:30 +0100

Hi,

I wrote a program which has support for resizing of terminals (
http://www.vanheusden.com/multitail/ ).
But whatever I try, calling resizeterm with output from the ioctl ALWAYS
fails when growing the terminal.
I tried resizing vi in that terminal, and everything works fine with that!
Can you please help me?
Relevant code:

int max_y, max_x;
char terminal_changed = 0;

signal-handler:

void do_resize(int s)
{
        struct winsize size;

        if (ioctl(STDIN_FILENO, TIOCGWINSZ, &size) == 0)
        {
                terminal_changed = 1;

                max_y = size.ws_row;
                max_x = size.ws_col;
        }
        else
        {
                fprintf(stderr, "ioctl failed\n");
                exit(1);
        }

        signal(SIGWINCH, do_resize);
}

main loop:

        init_curses();

        signal(SIGWINCH, do_resize);

...
          for(;;)
          {
...
                if (terminal_changed)
                {
                        if (resizeterm(max_y, max_x) == ERR)
                        {
                                fprintf(stderr, "problem resizeing
terminal\n");
                                exit(1);
                        }

                        touchwin(stdscr);
                        endwin();
                        refresh();

                        create_windows();
                }


init_curses:
void init_curses(void)
{
        initscr();
        keypad(stdscr, TRUE);  /* enable keyboard mapping */
        cbreak();
        intrflush(stdscr, FALSE);
        leaveok(stdscr, TRUE);
        noecho();
        nonl();
        refresh();
        nodelay(stdscr, FALSE);

        max_y = LINES;
        max_x = COLS;
}


Folkert.

p.s. http://www.vanheusden.com/multitail/ contains complete source





reply via email to

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