1 /* 2 * Copyright (c) 1981 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)initscr.c 5.8 (Berkeley) 09/14/92"; 10 #endif /* not lint */ 11 12 #include <curses.h> 13 #include <signal.h> 14 #include <stdlib.h> 15 16 /* 17 * initscr -- 18 * Initialize the current and standard screen. 19 */ 20 WINDOW * 21 initscr() 22 { 23 register char *sp; 24 25 #ifdef DEBUG 26 __TRACE("initscr\n"); 27 #endif 28 if (My_term) { 29 if (setterm(Def_term) == ERR) 30 return (NULL); 31 } else { 32 gettmode(); 33 if ((sp = getenv("TERM")) == NULL) 34 sp = Def_term; 35 if (setterm(sp) == ERR) 36 return (NULL); 37 #ifdef DEBUG 38 __TRACE("initscr: term = %s\n", sp); 39 #endif 40 } 41 tputs(TI, 0, __cputchar); 42 tputs(VS, 0, __cputchar); 43 (void)signal(SIGTSTP, tstp); 44 if (curscr != NULL) { 45 #ifdef DEBUG 46 __TRACE("initscr: curscr = 0%o\n", curscr); 47 #endif 48 delwin(curscr); 49 } 50 #ifdef DEBUG 51 __TRACE("initscr: LINES = %d, COLS = %d\n", LINES, COLS); 52 #endif 53 if ((curscr = newwin(LINES, COLS, 0, 0)) == ERR) 54 return (NULL); 55 clearok(curscr, 1); 56 curscr->flags &= ~__FULLLINE; 57 if (stdscr != NULL) { 58 #ifdef DEBUG 59 __TRACE("initscr: stdscr = 0%o\n", stdscr); 60 #endif 61 delwin(stdscr); 62 } 63 return(stdscr = newwin(LINES, COLS, 0, 0)); 64 } 65 66