1 .\" Copyright (c) 1992, 1993 2 .\" The Regents of the University of California. All rights reserved. 3 .\" 4 .\" Redistribution and use in source and binary forms, with or without 5 .\" modification, are permitted provided that the following conditions 6 .\" are met: 7 .\" 1. Redistributions of source code must retain the above copyright 8 .\" notice, this list of conditions and the following disclaimer. 9 .\" 2. Redistributions in binary form must reproduce the above copyright 10 .\" notice, this list of conditions and the following disclaimer in the 11 .\" documentation and/or other materials provided with the distribution. 12 .\" 3. All advertising materials mentioning features or use of this software 13 .\" must display the following acknowledgement: 14 .\" This product includes software developed by the University of 15 .\" California, Berkeley and its contributors. 16 .\" 4. Neither the name of the University nor the names of its contributors 17 .\" may be used to endorse or promote products derived from this software 18 .\" without specific prior written permission. 19 .\" 20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 .\" SUCH DAMAGE. 31 .\" 32 .\" from: @(#)ex1.c 8.1 (Berkeley) 6/8/93 33 .\" $Id: ex1.c,v 1.2 1993/11/09 04:09:30 cgd Exp $ 34 .\" 35 #include <sys/types.h> 36 #include <curses.h> 37 #include <stdio.h> 38 #include <signal.h> 39 40 41 #define YSIZE 10 42 #define XSIZE 20 43 44 int quit(); 45 46 main() 47 { 48 int i, j, c; 49 size_t len; 50 char id[100]; 51 FILE *fp; 52 char *s; 53 54 initscr(); /* Always call initscr() first */ 55 signal(SIGINT, quit); /* Make sure wou have a 'cleanup' fn */ 56 crmode(); /* We want cbreak mode */ 57 noecho(); /* We want to have control of chars */ 58 delwin(stdscr); /* Create our own stdscr */ 59 stdscr = newwin(YSIZE, XSIZE, 10, 35); 60 flushok(stdscr, TRUE); /* Enable flushing of stdout */ 61 scrollok(stdscr, TRUE); /* Enable scrolling */ 62 erase(); /* Initially, clear the screen */ 63 64 standout(); 65 move(0,0); 66 while (1) { 67 c = getchar(); 68 switch(c) { 69 case 'q': /* Quit on 'q' */ 70 quit(); 71 break; 72 case 's': /* Go into standout mode on 's' */ 73 standout(); 74 break; 75 case 'e': /* Exit standout mode on 'e' */ 76 standend(); 77 break; 78 case 'r': /* Force a refresh on 'r' */ 79 wrefresh(curscr); 80 break; 81 default: /* By default output the character */ 82 addch(c); 83 refresh(); 84 } 85 } 86 } 87 88 89 int 90 quit() 91 { 92 erase(); /* Terminate by erasing the screen */ 93 refresh(); 94 endwin(); /* Always end with endwin() */ 95 delwin(curscr); /* Return storage */ 96 delwin(stdscr); 97 putchar('\n'); 98 exit(0); 99 } 100 101 102 103 104