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