Now you know enough features to write a good curses program, with all bells and whistles. There are some miscellaneous functions which are useful in various cases. Let's go headlong into some of those.
This function can be used to make the cursor invisible. The parameter to this function should be
0 : invisible or 1 : normal or 2 : very visible. |
Some times you may want to get back to cooked mode (normal line buffering mode) temporarily. In such a case you will first need to save the tty modes with a call to def_prog_mode() and then call endwin() to end the curses mode. This will leave you in the original tty mode. To get back to curses once you are done, call reset_prog_mode() . This function returns the tty to the state stored by def_prog_mode(). Then do refresh(), and you are back to the curses mode. Here is an example showing the sequence of things to be done.
Example 12. Temporarily Leaving Curses Mode
/* File Path: basics/temp_leave.c */ #include <ncurses.h> int main() { initscr(); /* Start curses mode */ printw("Hello World !!!\n"); /* Print Hello World */ refresh(); /* Print it on to the real screen */ def_prog_mode(); /* Save the tty modes */ endwin(); /* End curses mode temporarily */ system("/bin/sh"); /* Do whatever you like in cooked mode */ reset_prog_mode(); /* Return to the previous tty mode*/ /* stored by def_prog_mode() */ refresh(); /* Do refresh() to restore the */ /* Screen contents */ printw("Another String\n"); /* Back to curses use the full */ refresh(); /* capabilities of curses */ endwin(); /* End curses mode */ return 0; } |