[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Access to echo, cbreak state without accessing SCREEN internals
From: |
Thomas Dickey |
Subject: |
Re: Access to echo, cbreak state without accessing SCREEN internals |
Date: |
Wed, 9 Aug 2023 19:40:58 -0400 |
On Wed, Aug 09, 2023 at 04:59:31PM -0400, Bill Gray wrote:
> ncurses already has some extension functions to get at internals of
> (opaque) WINDOW structs. Would you be willing to consider adding these two
> similar extension functions to get at internals of the SCREEN structure?
>
> int is_cbreak( void);
> int is_echo( void);
>
> My use case is as follows : I've written "extended" wgetn_wstr() and
> wgetnstr() functions that are outside the Curses library, but behave
> (mostly) the way the standard Curses library functions do, with add-ons
> such as allowing one to insert/delete in the middle of the text, use the
> mouse, supply default text, set the field width on-screen, and so on.
> These functions can then be used with ncurses, PDCurses, or PDCursesMod.
>
> The ncurses (and PDCurses and PDCursesMod) library implementations of
> those functions save the existing cbreak and echo states, call cbreak() and
actually it saves/restores nl, as well:
save_flags = sp->_tty_flags;
NCURSES_SP_NAME(nl) (NCURSES_SP_ARG);
NCURSES_SP_NAME(noecho) (NCURSES_SP_ARG);
if (!save_flags._raw)
NCURSES_SP_NAME(cbreak) (NCURSES_SP_ARG);
I suppose that adding is_XXX functions won't hurt.
> noecho(), and then restore the original states. Since wgetnstr() and
> friends are internal Curses functions, having them just access WINDOW and
> SCREEN structure elements directly is not a problem.
>
> But my functions are _not_ internal to Curses, and shouldn't be
> accessing SCREEN elements. And, of course, it can't if SCREEN is opaque,
> as can happen with ncurses and PDCursesMod. So I need functions to tell me
> if we're in echo and/or cbreak mode.
SCREEN's "always" opaque :-)
> I assume that in ncurses, these extensions would also lead to
>
> int is_cbreak_sp( const SCREEN *sp);
> int is_echo_sp( const SCREEN *sp);
>
> There may be other innards to which access would be helpful, but these
> are the only two I've encountered thus far.
>
> FWIW, the code where I need such functions is at
>
> https://github.com/Bill-Gray/find_orb/blob/master/getstrex.cpp#L94
>
> I currently use PDC_getcbreak() and PDC_getecho(), but these are
> PDCursesMod-only functions.
>
> Thanks! -- Bill
>
--
Thomas E. Dickey <dickey@invisible-island.net>
https://invisible-island.net
signature.asc
Description: PGP signature