1 /* 2 * Copyright (c) 1981 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 */ 17 18 #ifndef lint 19 static char sccsid[] = "@(#)initscr.c 5.3 (Berkeley) 06/30/88"; 20 #endif /* not lint */ 21 22 # include "curses.ext" 23 # include <signal.h> 24 25 extern char *getenv(); 26 27 /* 28 * This routine initializes the current and standard screen. 29 * 30 */ 31 WINDOW * 32 initscr() { 33 34 reg char *sp; 35 int tstp(); 36 int nfd; 37 38 # ifdef DEBUG 39 fprintf(outf, "INITSCR()\n"); 40 # endif 41 if (My_term) 42 setterm(Def_term); 43 else { 44 for (_tty_ch = 0; _tty_ch < nfd; _tty_ch++) 45 if (isatty(_tty_ch)) 46 break; 47 gettmode(); 48 if ((sp = getenv("TERM")) == NULL) 49 sp = Def_term; 50 setterm(sp); 51 # ifdef DEBUG 52 fprintf(outf, "INITSCR: term = %s\n", sp); 53 # endif 54 } 55 _puts(TI); 56 _puts(VS); 57 # ifdef SIGTSTP 58 signal(SIGTSTP, tstp); 59 # endif 60 if (curscr != NULL) { 61 # ifdef DEBUG 62 fprintf(outf, "INITSCR: curscr = 0%o\n", curscr); 63 # endif 64 delwin(curscr); 65 } 66 # ifdef DEBUG 67 fprintf(outf, "LINES = %d, COLS = %d\n", LINES, COLS); 68 # endif 69 if ((curscr = newwin(LINES, COLS, 0, 0)) == ERR) 70 return ERR; 71 clearok(curscr, TRUE); 72 curscr->_flags &= ~_FULLLINE; 73 if (stdscr != NULL) { 74 # ifdef DEBUG 75 fprintf(outf, "INITSCR: stdscr = 0%o\n", stdscr); 76 # endif 77 delwin(stdscr); 78 } 79 stdscr = newwin(LINES, COLS, 0, 0); 80 return stdscr; 81 } 82