Source Code File 09-04_touch
09-04_touch.c
#include <ncurses.h>
int main()
{
WINDOW *second;
initscr();
start_color();
/* configure colors */
init_pair(1,COLOR_WHITE,COLOR_BLUE);
init_pair(2,COLOR_WHITE,COLOR_RED);
/* create the second window */
second = newwin(0,0,0,0);
if(second == NULL)
{
endwin();
puts("Unable to create window");
return 1;
}
wbkgd(second,COLOR_PAIR(2));
waddstr(second,"This is the second window\n");
/* standard screen */
bkgd(COLOR_PAIR(1));
addstr("This is the standard screen\n");
addstr("Press Enter");
refresh();
getch();
/* show second window */
wrefresh(second);
getch();
/* show standard screen again */
touchwin(stdscr);
refresh();
getch();
endwin();
return 0;
}
Output Screenshot

(Click to cycle images.)
Notes
* The addition of the touchwin() statement at Line 35 is what forces the standard screen to appear again.
* The output screen shot cycles three times. The first and third image are similar, though the cursor location changes.
Copyright © 1997-2025 by QPBC.
All rights reserved
