Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

NCURSES

xlordtxlordt Member Posts: 2
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

  • ignatandrignatandr Member Posts: 10
    : 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));
    ////// 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 )
    :
    :
    :

  • ignatandrignatandr Member Posts: 10
    : : 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));
    : ////// 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]
    : :
    : :
    :
    :

  • Justin BibJustin Bib USAMember Posts: 0

    ______ [ http://forcoder.org ] free video tutorials and ebooks about [ Delphi, Perl, C, Objective-C, Visual Basic, Java, JavaScript, C#, C++, Assembly, Go, PL/SQL, Ruby, Python, Visual Basic .NET, Scratch, Swift, MATLAB, R, PHP LabVIEW, Lisp, ABAP, COBOL, Hack, Julia, Transact-SQL, FoxPro, Alice, Awk, Dart, Logo, ML, Bash, D, Fortran, Kotlin, VBScript, Crystal, Prolog, Rust, Clojure, Scheme, Scala, SAS, Apex, Erlang, F#, Ada, Lua ] _________

Sign In or Register to comment.