tech-userlevel archive

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

Re: curses: create panel from stdscr?

On Mon, Nov 06, 2017 at 12:19:51 +0100, Thomas Klausner wrote:

> "The NetBSD curses library in NetBSD 8 provides the panel extension.
> compatible with ncurses.

It's intended to be compatible with Extended Terminal Interface (ETI).
When I wrote it I looked at Solaris and SCO documentation from early
90s.  E.g.  calling top_panel() on a hidden panel behaves differently.
ETI says it's an error, ncurses shows the panel.  There may be other
differences as well.

> There seems to be a difference in libpanel compared to ncurses: A
> panel cannot be created from stdscr.

Panels basically just add Z-order to curses windows.  What would be
meaningful operations on a panel that corresponds to stdscr?  It must
always be visible, it must always be at the bottom, it cannot be
moved, etc, etc.  What's worse is that it will probably introduce
consistency problems into the API.

To quote the SCO's "User Interfaces Guide" from 1991:

| Panels have depth only in relation to other panels and stdscr, which
| lies beneath all panels.
| Recall that panels are always above stdscr, the standard screen.
| When a panel is moved or deleted, stdscr is updated along with the
| visible panels to ensure that it appears beneath all panels.
| Although stdscr has depth relative to other panels, it is not a
| panel, because panel operations like top_panel() and bottom_panel()
| do not apply.  However, because stdscr rests beneath the deck of
| panels, you should always call update_panels() when you work with
| panels and change stdscr, even if you do not change any panels.

A panel object for stdscr actually does (almost) always exists
internally in my implementation but it's never exposed to the user.

> This causes failing two tests in test_curses. These tests were added
> not long time ago, and there are not reasons to create panels from
> stdscr instead of other windows.

What do these two tests test exactly?

> Hence the proposed PR just makes these two tests creating panels
> from new windows, as in other two tests."

This sounds to me like someone wrote some some code without real
understanding of what's actually going on and used stdscr simply
because it already exists: yay, we can avoid creating a new window!


Home | Main Index | Thread Index | Old Index