1 04/15/88 "WINDOW" EXAMPLE
2
3 /* WINDOW. Displays inputed commands,
4 */ using multiple windows.
5
6 #include <curses.h>
7
8 WINDOW *cmdwin;
9
10 main
11
12 int i c;
13 char buf120;
14
15 initscr;
16 nonl;
17 noecho;
18 cbreak;
19
20
21 cmdwin = newwin3 COLS 00; /* top 3 lines */
22 for i=0; i<LINES; i ++
23 mvprintwi0 "This is line %d of stdscr" i;
24
25
26 for ;;
27 refresh;
28 c = getch;
29 switch c
30 case 'c' : /* Enter command from keyboard */
31 werasecmdwin;
32 wprintwcmdwin "Enter command:";
33 wmovecmdwin 20;
34 for i=0; i<COLS; i++
35 waddchcmdwin '-' ;
36
37
38 wmovecmdwin 10;
39 touchwincmdwin;
40 echo;
41 wrefreshcmdwin;
42 wgetstrcmdwin buf;
43 noecho;
44 touchwinstdscr;
45
46 /*
47 * The command is now in buf.
48 * It should be processed here.
49 */
50
51 systembuf;
52 sleep5;
53 clearokcurscr;
54 refresh;
55
56 break;
57 case 'q' :
58 erase;
59 refresh;
60 endwin;
61 exit0;
62 default :
63
64 flash;
65 mvaddstr230"Sorry no such command. Only cq are
66 valid";
67
68
69
70