Home | History | Annotate | Line # | Download | only in PSD.doc
ex1.c revision 1.1
      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 .\"     @(#)ex1.c	8.1 (Berkeley) 6/8/93
     33 .\"
     34 #include <sys/types.h>
     35 #include <curses.h>
     36 #include <stdio.h>
     37 #include <signal.h>
     38 
     39 
     40 #define YSIZE 10
     41 #define XSIZE 20
     42 
     43 int quit();
     44 
     45 main()
     46 {
     47 	int i, j, c;
     48 	size_t len;
     49 	char id[100];
     50 	FILE *fp;
     51 	char *s;
     52 
     53 	initscr();			/* Always call initscr() first */
     54 	signal(SIGINT, quit);		/* Make sure wou have a 'cleanup' fn */
     55 	crmode();			/* We want cbreak mode */
     56 	noecho();			/* We want to have control of chars */
     57 	delwin(stdscr);			/* Create our own stdscr */
     58 	stdscr = newwin(YSIZE, XSIZE, 10, 35);
     59 	flushok(stdscr, TRUE);		/* Enable flushing of stdout */
     60 	scrollok(stdscr, TRUE);		/* Enable scrolling */
     61 	erase();			/* Initially, clear the screen */
     62 
     63 	standout();
     64 	move(0,0);
     65 	while (1) {
     66 		c = getchar();
     67 		switch(c) {
     68 		case 'q':		/* Quit on 'q' */
     69 			quit();
     70 			break;
     71 		case 's':		/* Go into standout mode on 's' */
     72 			standout();
     73 			break;
     74 		case 'e':		/* Exit standout mode on 'e' */
     75 			standend();
     76 			break;
     77 		case 'r':		/* Force a refresh on 'r' */
     78 			wrefresh(curscr);
     79 			break;
     80 		default:		/* By default output the character */
     81 			addch(c);
     82 			refresh();
     83 		}
     84 	}
     85 }
     86 
     87 
     88 int
     89 quit()
     90 {
     91 	erase();		/* Terminate by erasing the screen */
     92 	refresh();
     93 	endwin();		/* Always end with endwin() */
     94 	delwin(curscr);		/* Return storage */
     95 	delwin(stdscr);
     96 	putchar('\n');
     97 	exit(0);
     98 }
     99 
    100 
    101 
    102 
    103