[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: why terminal resize changes size of windows?
From: |
Thomas Dickey |
Subject: |
Re: why terminal resize changes size of windows? |
Date: |
Mon, 14 Feb 2022 18:57:02 -0500 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
On Fri, Feb 11, 2022 at 07:08:28PM +0100, Pavel Stehule wrote:
> pá 11. 2. 2022 v 11:07 odesílatel Thomas Dickey <dickey@his.com> napsal:
>
> > On Fri, Feb 11, 2022 at 09:21:13AM +0100, Leon Winter wrote:
> > > Hi Pavel,
> > >
> > > this is how I do it:
> > >
> > > void ignore_handler (int)
> > > {
> > > }
> >
> > well, you _can_ do that, but then (n)curses is of no use in optimizing the
> > screen after SIGWINCH.
> >
> > In dialog, I re-layout the screen on reading KEY_RESIZE,
> > which works well enough.
> >
>
> I do the same thing. But you can see in your code too, so this feature
> increases complexity. If the resize handler doesn't change, then you don't
> need to store the original size in aux variables.
>
> With the possibility to pin corners to left, right, upper, lower terminal
> borders then you don't need to do a lot of work in application.
that's a possibility - but only by adding onto the WINDOW structure.
> But anyway, maybe I had a bigger problem with this feature, because it is
> not well described, or I badly searched.
agreed - the manpage should mention that the resizing is recursive,
and explain that the goal is to keep windows from extending off-screen.
>
> Regards
>
> Pavel
>
>
> > > // somewhere else before initscr ()
> > > struct sigaction ignore;
> > > memset (&ignore, 0, sizeof ignore);
> > > ignore.sa_handler = ignore_handler;
> > > sigaction (SIGWINCH, &ignore, 0);
> > >
> > > Regards,
> > > Leon
> > >
> > > On Fri, Feb 11, 2022 at 03:55:04AM +0100, Pavel Stehule wrote:
> > > > pá 11. 2. 2022 v 3:34 odesílatel Pavel Stehule <
> > pavel.stehule@gmail.com>
> > > > napsal:
> > > >
> > > > >
> > > > >
> > > > > pá 11. 2. 2022 v 1:35 odesílatel Thomas Dickey <dickey@his.com>
> > napsal:
> > > > >
> > > > >> On Thu, Feb 10, 2022 at 11:54:00AM +0100, Pavel Stehule wrote:
> > > > >> > 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.
> > > > >>
> > > > >> As I pointed out here:
> > > > >>
> > > > >>
> > https://lists.gnu.org/archive/html/bug-ncurses/2020-08/msg00011.html
> > > > >>
> > > > >> windows don't extend outside the screen.
> > > > >>
> > > > >> When ncurses is handling SIGWINCH, it shrinks windows to fit in the
> > > > >> screen.
> > > > >>
> > > > >
> > > > >
> > > > Is it possible to disable this feature? Maybe in the future, by some
> > > > setting? I am author or pspg https://github.com/okbob/pspg
> > > >
> > > > and this feature was probably the biggest issue when I worked on it.
> > The
> > > > user of pspg can resize the terminal at any moment. And after resizing
> > I
> > > > need to recheck all windows if they are the correct size. I
> > understand, so
> > > > the signal handler can shrink some windows, but what is strange, it can
> > > > extend some windows too. Maybe the shrinking can be replaced by some
> > flags
> > > > that can be detected from applications like fully visible, partially
> > > > visible, invisible. But the size of the window can be immutable.
> > > >
> > > > Regards
> > > >
> > > > Pavel
> > > >
> > > >
> > > >
> > > > > ok
> > > > >
> > > > > Thank you for info
> > > > >
> > > > > Regards
> > > > >
> > > > > Pavel
> > > > >
> > > > >>
> > > > >> >
> > > > >> > 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
> > > > >>
> > > > >>
> > > > >>
> > > > >>
> > > > >>
> > > > >> --
> > > > >> Thomas E. Dickey <dickey@invisible-island.net>
> > > > >> https://invisible-island.net
> > > > >> ftp://ftp.invisible-island.net
> > > > >>
> > > > >
> > >
> >
> > --
> > Thomas E. Dickey <dickey@invisible-island.net>
> > https://invisible-island.net
> > ftp://ftp.invisible-island.net
> >
--
Thomas E. Dickey <dickey@invisible-island.net>
https://invisible-island.net
ftp://ftp.invisible-island.net
signature.asc
Description: PGP signature