bug-ncurses
[Top][All Lists]
Advanced

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

CDK Color Support


From: Aarian P. Aleahmad
Subject: CDK Color Support
Date: Sat, 23 Jan 2016 18:23:21 +0330
User-agent: Roundcube Webmail/0.7.2

Hi there

As we know, ncurses can support up to 256 colors and 256 color pairs. While in the CDK, using initCDKColor function we have 64 color pairs made from the first 8 default colors. I tried to cheat the CDK and improve the color support by initializing color pairs using the ncurses functions themselves. It worked fine until 100 colors but after that I found a bug. The point was that "encodeAttribute" function, located in "cdk.c", only processes two digits, so a 3-digit pair code, say "</123>" will be treated equal to "</12>". I tried to fix this and improve CDK's color support to the maximum 256 possible color pairs by adding the following code to "cdk.h", Line#339:

339:   else if (isdigit (CharOf (string[from + 1])) &&
340:        isdigit (CharOf (string[from + 2])) &&
341:        isdigit (CharOf (string[from + 3])))
342:   {
343:#ifdef HAVE_START_COLOR
344: pair = DigitOf (string[from + 1]) * 100 + DigitOf (string[from + 2]) * 10 + DigitOf (string[from + 3]);
345:      *mask = (chtype)COLOR_PAIR ( (pair>255) ? 255 : pair );
346:#else
347:      *mask = A_BOLD;
348:#endif
349:      from += 3;
350:   }

But after I compiled the new code and installed it, the bug still existed. I was running this code:


for (i = j = 0; i < 256; ++i) {
                /*Calculates the Foreground Color Code*/
                d= (0xf8)|((~(i&0x07))&0x07);
                if( !(d&0x07) && (i<128) )
                        d|=0x07;

                /*Initializes the Color Pair*/
                init_pair(i, d, i);

                /*Makes the label*/
                sprintf(msg,"</%d>%3d  <!%d>",i,i,i);
                j=CDKallocStrings(&l,msg,i,j);
                
activateCDKLabel(newCDKLabel(scr,i/24*7,i%24,l+i,1,FALSE,FALSE),NULL);

I attached a screeshot of what I expect and what I recieved. The former was made through "mvprintw" function of the ncurses itself.

I would thank anyone who could help me on this issue.
Thank you

Attachment: CDK Color Bug.PNG
Description: Binary data

Attachment: Same intensity Opposite color, fixed intensity for Foreground RGB.png
Description: Binary data


reply via email to

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