From 256a92a41d1f5228c9b022d0c527747a0896992b Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Mon, 23 Nov 2009 08:40:07 -0500 Subject: [PATCH] not quite fully functional python version of "with_chgat" --- basics/with_chgat.c | 19 +++++-------------- basics/with_chgat.py | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 basics/with_chgat.py diff --git a/basics/with_chgat.c b/basics/with_chgat.c index 96e23d7..7d347c6 100644 --- a/basics/with_chgat.c +++ b/basics/with_chgat.c @@ -1,24 +1,15 @@ #include int main(int argc, char *argv[]) -{ initscr(); /* Start curses mode */ - start_color(); /* Start color functionality */ +{ + initscr(); + start_color(); init_pair(1, COLOR_CYAN, COLOR_BLACK); printw("A Big string which i didn't care to type fully "); mvchgat(0, 0, -1, A_BLINK, 1, NULL); - /* - * First two parameters specify the position at which to start - * Third parameter number of characters to update. -1 means till - * end of line - * Forth parameter is the normal attribute you wanted to give - * to the charcter - * Fifth is the color index. It is the index given during init_pair() - * use 0 if you didn't want color - * Sixth one is always NULL - */ refresh(); - getch(); - endwin(); /* End curses mode */ + getch(); + endwin(); return 0; } diff --git a/basics/with_chgat.py b/basics/with_chgat.py new file mode 100644 index 0000000..12ade54 --- /dev/null +++ b/basics/with_chgat.py @@ -0,0 +1,22 @@ +import sys +import curses + + +def with_chgat(stdscr): + curses.init_pair(1, curses.COLOR_CYAN, curses.COLOR_BLACK) + stdscr.addstr("A Big string which i didn't care to type fully ", + curses.color_pair(1)) +# stdscr.chgat(0, 0, -1, curses.A_BLINK) + stdscr.refresh() + stdscr.getch() + + +def main(): + curses.wrapper(with_chgat) + return 0 + + +if __name__ == '__main__': + sys.exit(main()) + +# vim:filetype=python