bug-ncurses
[Top][All Lists]
Advanced

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

Re: Recommended way to distinguish between pads and windows?


From: Thomas Dickey
Subject: Re: Recommended way to distinguish between pads and windows?
Date: Sun, 6 Sep 2009 09:50:45 -0400 (EDT)

On Sun, 6 Sep 2009, Mark Dickinson wrote:


Hi all,

I'm trying to fix Python's interface to ncurses (the 'curses' module), which
seems to be broken with ncurses 5.7, and I wanted to ask your advice:

The problem is that Python's source repeatedly uses C code like the
following to distinguish windows and pads (where self->win has
type WINDOW):

 if (self->win->_flags & _ISPAD)
   /* use pechochar here */
 else
   /* use wechochar instead */

but with ncurses 5.7, the internals of WINDOW are hidden, so the

hmm - that's actually a configure option (not "always" hidden, but can
be made so).  Which package/distribution is turning this on?

attempted access to _flags fails with a gcc 'dereferencing pointer
to incomplete type' error.  What's the recommended solution for
this type of problem?  We could just #define NCURSES_OPAQUE
to 0, but that seems risky:  presumably these internals are hidden
for a good reason.  Is there some public method of determining
whether something of type WINDOW is actually a pad,
or should Python try to keep track independently of which objects
are windows and which are pads?

We're talking about these bits:

/* values for the _flags member */
#define _SUBWIN         0x01    /* is this a sub-window? */
#define _ENDLINE        0x02    /* is the window flush right? */
#define _FULLWIN        0x04    /* is the window full-screen? */
#define _SCROLLWIN      0x08    /* bottom edge is at screen bottom? */
#define _ISPAD          0x10    /* is this window a pad? */
#define _HASMOVED       0x20    /* has cursor moved since last refresh? */
#define _WRAPPED        0x40    /* cursor was just wrappped */

I didn't think of adding an is_pad(), but for other features, see
the ncurses "opaque" manpage, e.g.,

       bool is_cleared(const WINDOW *win);
...
       WINDOW * wgetparent(const WINDOW *win);

Not exactly what you want, but a pad wouldn't have a parent window.
(subwin's and derwin's would have one, but not plain newwin's).

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net




reply via email to

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