1 /* 2 * Copyright (c) 1992, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * 6 * %sccs.include.redist.c% 7 */ 8 9 #ifndef lint 10 static char copyright[] = 11 "@(#) Copyright (c) 1992, 1993\n\ 12 The Regents of the University of California. All rights reserved.\n"; 13 #endif /* not lint */ 14 15 #ifndef lint 16 static char sccsid[] = "@(#)ex1.c 8.1 (Berkeley) 06/04/93"; 17 #endif /* not lint */ 18 #include <sys/types.h> 19 #include <curses.h> 20 #include <stdio.h> 21 #include <signal.h> 22 23 24 #define YSIZE 10 25 #define XSIZE 20 26 27 int quit(); 28 29 main() 30 { 31 int i, j, c; 32 size_t len; 33 char id[100]; 34 FILE *fp; 35 char *s; 36 37 initscr(); /* Always call initscr() first */ 38 signal(SIGINT, quit); /* Make sure wou have a 'cleanup' fn */ 39 crmode(); /* We want cbreak mode */ 40 noecho(); /* We want to have control of chars */ 41 delwin(stdscr); /* Create our own stdscr */ 42 stdscr = newwin(YSIZE, XSIZE, 10, 35); 43 flushok(stdscr, TRUE); /* Enable flushing of stdout */ 44 scrollok(stdscr, TRUE); /* Enable scrolling */ 45 erase(); /* Initially, clear the screen */ 46 47 standout(); 48 move(0,0); 49 while (1) { 50 c = getchar(); 51 switch(c) { 52 case 'q': /* Quit on 'q' */ 53 quit(); 54 break; 55 case 's': /* Go into standout mode on 's' */ 56 standout(); 57 break; 58 case 'e': /* Exit standout mode on 'e' */ 59 standend(); 60 break; 61 case 'r': /* Force a refresh on 'r' */ 62 wrefresh(curscr); 63 break; 64 default: /* By default output the character */ 65 addch(c); 66 refresh(); 67 } 68 } 69 } 70 71 72 int 73 quit() 74 { 75 erase(); /* Terminate by erasing the screen */ 76 refresh(); 77 endwin(); /* Always end with endwin() */ 78 delwin(curscr); /* Return storage */ 79 delwin(stdscr); 80 putchar('\n'); 81 exit(0); 82 } 83 84 85 86 87