Thread: How to set user-defined colours on a command line screen?
i on ubuntu 10.04.
want make simple user interface c/c++ supports simple menus , drop-downlist/panes command line processing.
have tried curses/ncurses , works, there 8 colours (black,red, green, brown, blue, magenta, cyan, white).
these awful when used in lists , panes. curses spec mentions init_color(paletteindex, r,g,b) changes colour associated palettindex. however, capability enquiry function can_change_color() returns false.
wrote functions use escape sequences , 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 ;
}
val parameter in mysetcol typically specifies text or background colour, same 8 colours available via curses; otherwise myxxx routines work fine.
there way change 8-colour palette can different colours curses or myxxx functions? or there other palette e.g 256 colour palette may able use perhaps without making changes?
want change colours on fly in command line program only, not permanently terminal.
ken
as far know it's not possible change palette. but, there couple more colors can use: 90 - 99 foreground , 100 - 109 background in escape codes give brighter colors.
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk How to set user-defined colours on a command line screen?
Ubuntu
Comments
Post a Comment