hi...
im trying to code in ncurses.. but i cant seem to make this
to print out in colorz... if anyone here knowz now to code in ncurses
please help me figure this out.. thanx
here is the code...
#include int main()
{
initscr();
noecho();
cbreak();
start_color();
refresh();
init_pair(2, COLOR_RED, COLOR_RED);
attron(COLOR_PAIR(2));
printf("hello colorz");
attroff(COLOR_PAIR(2));
sleep(3);
endwin();
return 0;
}
Comments
:
: im trying to code in ncurses.. but i cant seem to make this
: to print out in colorz... if anyone here knowz now to code in ncurses
: please help me figure this out.. thanx
:
: here is the code...
:
:
: #include
:
: int main()
: {
:
: initscr();
: noecho();
: cbreak();
: start_color();
: refresh();
:
: init_pair(2, COLOR_RED, COLOR_RED);
: attron(COLOR_PAIR(2));
////// This is wrong !!! //////////
: ///// printf("hello colorz"); ////
////////////////////////////////////
: attroff(COLOR_PAIR(2));
:
:
: sleep(3);
: endwin();
: return 0;
:
: }
/////////////////////////////////////////
You can not !!! use stdio functions like printf and scanf etc. with curses. They have their own in/output set of functions. This code is OK, you just have to change printf() to printw().
There is very good help on CURSES on
http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/
also I used few books:
"Programming with Curses" O'Reilly ISBN: 0-937175-02-1. ( Not the best )
"Unix Curses Explained" Berny Goodheart ISBN: 0-13-931957-3( Very Good )
:
:
:
: :
: : im trying to code in ncurses.. but i cant seem to make this
: : to print out in colorz... if anyone here knowz now to code in ncurses
: : please help me figure this out.. thanx
: :
: : here is the code...
: :
: :
: : #include
: :
: : int main()
: : {
: :
: : initscr();
: : noecho();
: : cbreak();
: : start_color();
: : refresh();
: :
: : init_pair(2, COLOR_RED, COLOR_RED);
: : attron(COLOR_PAIR(2));
: ////// This is wrong !!! //////////
: : ///// printf("hello colorz"); ////
: ////////////////////////////////////
[red]printw("Hello colorz");[/red]
: : attroff(COLOR_PAIR(2));
[red]refresh();[/red]
: :
: :
: : sleep(3);
: : endwin();
: : return 0;
: :
: : }
: /////////////////////////////////////////
: You can not !!! use stdio functions like printf and scanf etc. with curses. They have their own in/output set of functions. This code is OK, you just have to change printf() to printw().
:You have to update the screen to post the changes by usinf refresh();
: There is very good help on CURSES on
: http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/
: also I used few books:
: "Programming with Curses" O'Reilly ISBN: 0-937175-02-1. ( Not the best )
: "Unix Curses Explained" Berny Goodheart ISBN: 0-13-931957-3( Very Good )
: :[hr]
: :
: :
:
: