bug-ncurses
[Top][All Lists]
Advanced

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

Re: Question: How does ncurses store and handle "wide" characters?


From: Thomas Dickey
Subject: Re: Question: How does ncurses store and handle "wide" characters?
Date: Wed, 2 Jun 2021 04:07:45 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Wed, Jun 02, 2021 at 12:59:40AM -0400, pjfarley3@earthlink.net wrote:
> 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>

that's in the manual page (which is a good starting place).

> 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".

actually you're telling me that PDCurses has an unnecessary deviation
from X/Open Curses.  Bill's comment was by the way referring to
a source-file in PDCurses, not relevant to IBM curses.  Just as well -
AIX curses has its own problems...

X/Open Curses states clearly enough that the wide-character definitions
aren't available by default.
 
> 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?

ncurses does that (python is unable to do this by itself).

again, the header file is the place to look (along with term.h,
and the release notes for ncurses 6.1, etc).
 
> 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
> 
> 
> 

-- 
Thomas E. Dickey <dickey@invisible-island.net>
https://invisible-island.net
ftp://ftp.invisible-island.net

Attachment: signature.asc
Description: PGP signature


reply via email to

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