bug-ncurses
[Top][All Lists]
Advanced

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

Re: attr_get


From: Thomas Dickey
Subject: Re: attr_get
Date: Sat, 06 Dec 2008 17:31:01 -0500
User-agent: Mutt/1.5.18 (2008-05-17)

On Fri, Dec 05, 2008 at 11:48:58PM -0800, Mike Gran wrote:
> When calling attr_get(&attrs,&pair,NULL), the color pair value shows up both
> in the returned pair and in the returned attrs value.  Is this expected?

...yes.  Technically it should not (or need not - there's a distinction).

It need not since it's part of the X/Open extensions over SVR4 curses
which provides for extended color support.  That's why there's a
separate parameter for the color pair.

The description here is so vague that it covers lots of possibilities:

        http://www.opengroup.org/onlinepubs/007908799/xcurses/attr_get.html

However, this (in ncurses) was implemented early (mid-1995), even before
there were any implementations to compare against (1997-1998) and (a
while later...) notice that they provided for more than 8 colors (at
least in the data structures - I've had poor results from _using_ the
vendor unix curses libraries for extended colors).

When I implemented the extended-colors in 2005, I retained the combined
color+attribute in the attribute field, as long as it fits, and provided
for keeping application compability for anything _using_ attr_get and
attr_set.

A really portable X/Open curses application shouldn't really care (much)
since it would only test the video-attribute bits from the attribute
parameter, and would look for the color pair in the pair parameter.

> Running this code snippet....
> 
> int main()
> {
>   attr_t attrs;
>   short pair;
> 
>   initscr ();
>   attr_set (WA_UNDERLINE, 1, NULL);
>   attr_get (&attrs, &pair, NULL); 
>   endwin();
>   printf ("INPUT: %x %d\n", WA_UNDERLINE, 1);
>   printf ("OUTPUT: %x %d\n", attrs, pair);
> 
>   return 0;
> }
> 
> 
> .... returns
> 
> INPUT: 20000 1
> OUTPUT: 20100 1
> 
> The "100" in the "20100" value is COLOR_PAIR(1).
> 
> Thanks,
> 
> Mike Gran
> 
> 
> 
> _______________________________________________
> Bug-ncurses mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/bug-ncurses

-- 
Thomas E. Dickey <address@hidden>
http://invisible-island.net
ftp://invisible-island.net

Attachment: signature.asc
Description: Digital signature


reply via email to

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