bug-ncurses
[Top][All Lists]
Advanced

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

why terminal resize changes size of windows?


From: Pavel Stehule
Subject: why terminal resize changes size of windows?
Date: Thu, 10 Feb 2022 11:54:00 +0100

Hi

I found an interesting issue. When I resize the terminal, so some windows are partially out of screen, the window size is reduced. From this moment, the window lost original size, and the size of window is related to size of screen.

It can be easy demonstrated by example:

#include <ncurses.h>

int
main()
{
    int     c;
    WINDOW *win;

    initscr();

    clear();
    noecho();
    cbreak();
    curs_set(0);
    keypad(stdscr, TRUE);

    win = newwin(20, 40, 15,15);

    timeout(250);

    while (c != 'q')
    {
        int lines, cols;

        clear();

        /* termina size */
        mvprintw(10, 10, "terminal: %d, %d", LINES, COLS);
        clrtoeol();

        /* stdscr size */
        getmaxyx(stdscr, lines, cols);
        mvprintw(11, 10, "stdscr: %d, %d", lines, cols);
        clrtoeol();

        /* win size */
        getmaxyx(win, lines, cols);
        mvprintw(12, 10, "win: %d, %d", lines, cols);
        clrtoeol();

        refresh();

        wclear(win);
        box(win, 0,0);
        wrefresh(win);

        c = getch();
    }

    endwin();
}

when running, try to reduce terminal size to 20 lines, 40 cols. After increasing terminal size, the size of window win is increased too.

What is the reason for this behaviour?

Regards

Pavel Stehule

Attachment: Snímek z 2022-02-10 11-52-58.png
Description: PNG image

Attachment: Snímek z 2022-02-10 11-52-51.png
Description: PNG image

Attachment: Snímek z 2022-02-10 11-53-05.png
Description: PNG image


reply via email to

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