[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Question: How does ncurses store and handle "wide" characters?
From: |
pjfarley3 |
Subject: |
RE: Question: How does ncurses store and handle "wide" characters? |
Date: |
Wed, 2 Jun 2021 00:59:40 -0400 |
Responding to both Bill and Thomas, the header file may be the logical place to
document such things, but the picture provided by the PDCursesMod text file
makes it crystal clear for newbies, while the header alone requires making up
your own picture (either in your mind or spelled out in written form on the
side), neither of which is easy when you can't even FIND things like stddef.h
in an *ix system without significant time invested in reading whole bunches of
OTHER headers AND remembering which #defines control which path(s) you are
following. It really is a rats maze of things not meant for a human to
navigate by reading alone.
I finally figured out to use a tiny c source with nothing but this:
#define NCURSES_WIDECHAR
#include <ncurses.h>
Then I processed that file with a "gcc -E whatami.c" command to find out what
all is really generated.
That should not be necessary, nor is it sufficient. IMHO PDCursesMod does a
better job of assisting potential bug fixers and contributors by starting out
with clear, basic text information showing the data structures that are
manipulated by the code. IBM mainframe (non-*ix) operating system
documentation has done this superbly for multiple decades, extracted (as Bill
says that his documentation is) mostly mechanically from the mainframe
equivalent of "headers".
But at least now I have my answer. Wide text in ncurses is a struct with two
fields, an attribute int and an array of 5 "wide character" int's.
I do understand Thomas's comment about how changing the number or position of
attribute flags and/or the size of the color-pair value for wide characters
only would break or greatly complicate large amounts of existing code.
BTDTGTTS in other areas of my professional programing life. "If it ain't broke
don't fix it" happens everywhere, usually with pretty good reasons.
However, when running a simple python curses script in an *ix environment that
is using the ncurses library, I get this display for the values of
curses.COLOR_PAIRS and curses.COLORS:
pairs=65536, colors=256
Is that the python curses implementation providing 65536 color pairs (an
unsigned short int's worth) or is the ncurses library providing that many? If
the ncurses library is providing 65536 (presumably distinct) color pairs, how
is it accomplished with only a one-byte color-pair storage in both wide and
narrow "character" structures?
Peter
> -----Original Message-----
> From: Bug-ncurses <bug-ncurses-bounces+pjfarley3=earthlink.net@gnu.org> On
> Behalf Of Bill Gray
> Sent: Monday, May 31, 2021 12:31 PM
> To: bug-ncurses@gnu.org
> Subject: Re: Question: How does ncurses store and handle "wide" characters?
>
> On 5/31/21 9:45 AM, Thomas Dickey wrote:
>
> > I haven't found it necessary to show the bit layout, since the header
> > file is commented well enough :-)
>
> The MANUAL.md text Peter cites was automatically extracted from the
> PDCursesMod curses.h header. As you suggest, the header file is the logical
> place to document such things.
>
> >> By default, a 64-bit chtype is used [in PDCursesMod] :
> >
> > ...which doesn't allow for combining-characters :-)
>
> Au contraire. Combining characters _are_ handled in PDCursesMod, though
> using a scheme very different from the ncurses one :
>
> https://github.com/Bill-
> Gray/PDCursesMod/blob/master/pdcurses/addch.c#L281
>
> See, e.g., the next-to-bottom line in the screen shot at
>
> https://www.projectpluto.com/win32a.htm
>
> I did consider the "array of wchar_t" approach (or more likely, win_t to
> get
> around Microsoft's 16-bit wchar_ts), and that would have been straightforward
> enough in some ways. But I'd really have had to rip a lot of code apart to do
> that in PDCursesMod.
>
> -- Bill
- RE: Question: How does ncurses store and handle "wide" characters?,
pjfarley3 <=