LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Colors in NCurses (https://www.linuxquestions.org/questions/programming-9/colors-in-ncurses-50429/)

Mohsen 03-18-2003 08:17 AM

Colors in NCurses
 
In the name of God
Hi all,
I can not change color in the screen using NCurses. There are some functions for this mean, none of them change color : attrset, initpair, start_color,....
Help please/

sidey 03-18-2003 09:17 AM

#include <ncurses.h>
int main() {

initscr();
noecho();
crbreak();
start_color();
init_pair(1, COLOR_RED, COLOR_BLACK);

attron(COLOR_PAIR(1));
printw("Hey,i'm in colour");
attroff(COLOR_PAIR(1));
getch();
endwin();
}

any more help needed try

http://www.linuxselfhelp.com/HOWTO/N...WTO/color.html

jhorvath 03-18-2003 06:19 PM

just a correction....

line 6 :
crbreak();

should be :
cbreak();


Other than that it works...

Mohsen 03-19-2003 06:19 AM

Thanks.
I'll check, BTW what does cbreak do?
I have an NCurses manual (about 200kb HTML) but it has very few discriptions, is any more compelete manual available on the net?

Mohsen 03-19-2003 11:20 PM

?

sidey 03-20-2003 05:10 AM

from the howto i posted in the first post.....

4.2. raw() and cbreak()
Normally the terminal driver buffers the characters a user types until a new line or carriage return is encountered. But most programs require that the characters be available as soon as the user types them. The above two functions are used to disable line buffering. The difference between these two functions is in the way control characters like suspend (CTRL-Z), interrupt and quit (CTRL-C) are passed to the program. In the raw() mode these characters are directly passed to the program without generating a signal. In the cbreak() mode these control characters are interpreted as any other character by the terminal driver. I personally prefer to use raw() as I can exercise greater control over what the user does.

:)

Mohsen 03-20-2003 07:07 AM

Thancks Sidey,
Where is this Howto?

sidey 03-20-2003 08:40 AM

its at the start of the thread but here again just in case :)


http://www.linuxselfhelp.com/HOWTO/...OWTO/color.html


All times are GMT -5. The time now is 04:45 AM.