Results 1 to 1 of 1
I am on Ubuntu 10.04.
I want to make a simple user interface for C/C++ that supports simple menus and drop-downlist/panes for command line processing.
I have tried curses/ncurses and ...
- 06-28-2011 #1Just Joined!
- Join Date
- Feb 2010
- Posts
- 4
How to set user-defined colours on a command line screen?
I am on Ubuntu 10.04.
I want to make a simple user interface for C/C++ that supports simple menus and drop-downlist/panes for command line processing.
I have tried curses/ncurses and that works, but there are only eight colours available (black,red, green, brown, blue, magenta, cyan, white).
These look awful when used in lists and panes. The curses spec mentions init_color(paletteindex, r,g,b) that changes the colour associated with palettinex. However, the capability enquiry function can_change_color() returns false.
I also wrote a few functions that use escape sequences and console codes, e.g.
static void myreset ( )
{
printf("\033[0m" );
fflush(stdout);
}
static void mysetcol ( int val )
{
printf("\033[%dm", val );
fflush(stdout);
}
static void mygotoxy(int x, int y)
{
printf("\033[%d;%df", y, x);
fflush(stdout);
}
used like:
int main( )
{
mygotoxy ( 3 , 4 ) ;
mysetcol ( 33 ) ; // text
mysetcol ( 44 ) ; // backgound
printf ( "Testing only") ;
getch ( ) ;
return 0 ;
}
The val parameter in mysetcol typically specifies a text or background colour, but only the eight colours available via curses; otherwise the myxxx routines work fine.
Is there a way to change the 8-colour palette so I can get different colours for curses or the myxxx functions? OR is there some other palette e.g a 256 colour palette that I may be able to use without making any changes?
I want the change the colours on the fly in the command line program only, not permanently for the Terminal.
Ken


Reply With Quote