1 /* 2 * Copyright (c) 1981, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)initscr.c 8.2 (Berkeley) 05/04/94"; 10 #endif /* not lint */ 11 12 #include <signal.h> 13 #include <stdlib.h> 14 15 #include "curses.h" 16 17 /* 18 * initscr -- 19 * Initialize the current and standard screen. 20 */ 21 WINDOW * 22 initscr() 23 { 24 register char *sp; 25 26 #ifdef DEBUG 27 __CTRACE("initscr\n"); 28 #endif 29 __echoit = 1; 30 __pfast = __rawmode = __noqch = 0; 31 32 if (gettmode() == ERR) 33 return (NULL); 34 35 /* 36 * If My_term is set, or can't find a terminal in the environment, 37 * use Def_term. 38 */ 39 if (My_term || (sp = getenv("TERM")) == NULL) 40 sp = Def_term; 41 if (setterm(sp) == ERR) 42 return (NULL); 43 44 /* Need either homing or cursor motion for refreshes */ 45 if (!HO && !CM) 46 return (NULL); 47 48 if (curscr != NULL) 49 delwin(curscr); 50 if ((curscr = newwin(LINES, COLS, 0, 0)) == ERR) 51 return (NULL); 52 clearok(curscr, 1); 53 54 if (stdscr != NULL) 55 delwin(stdscr); 56 if ((stdscr = newwin(LINES, COLS, 0, 0)) == ERR) { 57 delwin(curscr); 58 return (NULL); 59 } 60 61 __set_stophandler(); 62 63 #ifdef DEBUG 64 __CTRACE("initscr: LINES = %d, COLS = %d\n", LINES, COLS); 65 #endif 66 __startwin(); 67 68 return (stdscr); 69 } 70