Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - addtheninth

Pages: [1]
Programming / Re: Curses - Issue with init_color
« on: January 26, 2009, 10:35:13 PM »
If a terminal is capable of redefining colors, the programmer can use the routine init_color to change  the  definition  of  a  color.

keyword here being _IF_. It is not garunteed to support it. and I'd wager outside of an 256 color xterm it probably wont be supported.

init_color will return an error if its unsupported so you can always check that, if no error is returned maybe something else is wrong.

are you correctly doing init_pairs as well?

I've already tested the console to confirm that it supports redefining colors.  I'm not getting an error thrown when I try to do it.

My init_pairs are as follows:
Code: [Select]
    init_pair(0, COLOR_BLACK, COLOR_BLACK);
    init_pair(1, COLOR_RED, COLOR_BLACK);
    init_pair(2, COLOR_GREEN, COLOR_BLACK);
    init_pair(3, COLOR_YELLOW, COLOR_BLACK);
    init_pair(4, COLOR_BLUE, COLOR_BLACK);
    init_pair(5, COLOR_MAGENTA, COLOR_BLACK);
    init_pair(6, COLOR_CYAN, COLOR_BLACK);
    init_pair(7, COLOR_WHITE, COLOR_BLACK);
    init_pair(8, COLOR_GREEN, COLOR_BLACK);

I'll then use attron(COLOR_PAIR(n)); to turn on whatever color I want to use.
i.e. -
Code: [Select]
attron(COLOR_PAIR(0)); // turns on black/black

Programming / Curses - Issue with init_color
« on: January 25, 2009, 06:52:33 PM »
Hi Everyone  ;D

Firstly, I'm new to the boards, so wanted to say hi.  It's great to find a community like this.

I'm new to RL's (always wanted to make one) and have only recently started programming in C++ again (first time in 10+ years...coming from Java and IBM RPG).

I'm currently having an issue with the curse function init_color.

Per the header and all documentation I've found, this is supposed to let me manually set the RGB of a color for use.

For instance, I'm aiming for a grayish color, so am attempting to use:
init_color(COLOR_BLACK, 100, 100, 100);

However, the color's staying solid black whenever I use the new value in an init pair.  Am I missing something, or am I just using this function completely wrong?

I read somewhere about possibly recompiling my curses library to support all colors, but I'm not quite sure what parms I should be passing/how I should go about doing this.

I'm currently coding in CodeBlocks using Ming32 on a Vista system.  If anyone has any insight, I'd appreciate the help ;)


Pages: [1]