|
|
1.1 ! root 1: /* @(#) miniinit.c: 1.1 10/15/83 (1.5 3/16/83) */ ! 2: ! 3: # include "curses.ext" ! 4: # include <signal.h> ! 5: ! 6: char *calloc(); ! 7: extern char *getenv(); ! 8: ! 9: static WINDOW *makenew(); ! 10: ! 11: struct screen *m_newterm(); ! 12: ! 13: /* ! 14: * This routine initializes the current and standard screen. ! 15: * ! 16: * 3/5/81 (Berkeley) @(#)initscr.c 1.2 ! 17: */ ! 18: ! 19: WINDOW * ! 20: m_initscr() { ! 21: reg char *sp; ! 22: ! 23: # ifdef DEBUG ! 24: if (outf == NULL) { ! 25: outf = fopen("trace", "w"); ! 26: if (outf == NULL) { ! 27: perror("trace"); ! 28: exit(-1); ! 29: } ! 30: } ! 31: #endif ! 32: ! 33: if (isatty(2)) { ! 34: if ((sp = getenv("TERM")) == NULL) ! 35: sp = Def_term; ! 36: # ifdef DEBUG ! 37: if(outf) fprintf(outf, "INITSCR: term = %s\n", sp); ! 38: # endif ! 39: } ! 40: else { ! 41: sp = Def_term; ! 42: } ! 43: (void) m_newterm(sp, stdout, stdin); ! 44: return stdscr; ! 45: } ! 46: ! 47: struct screen * ! 48: m_newterm(type, outfd, infd) ! 49: char *type; ! 50: FILE *outfd, *infd; ! 51: { ! 52: int m_tstp(); ! 53: struct screen *scp; ! 54: struct screen *_new_tty(); ! 55: extern int _endwin; ! 56: ! 57: #ifdef DEBUG ! 58: if(outf) fprintf(outf, "NEWTERM() isatty(2) %d, getenv %s\n", ! 59: isatty(2), getenv("TERM")); ! 60: # endif ! 61: SP = (struct screen *) calloc(1, sizeof (struct screen)); ! 62: SP->term_file = outfd; ! 63: SP->input_file = infd; ! 64: savetty(); ! 65: scp = _new_tty(type, outfd); ! 66: # ifdef SIGTSTP ! 67: signal(SIGTSTP, m_tstp); ! 68: # endif ! 69: ! 70: LINES = lines; ! 71: COLS = columns; ! 72: # ifdef DEBUG ! 73: if(outf) fprintf(outf, "LINES = %d, COLS = %d\n", LINES, COLS); ! 74: # endif ! 75: curscr = makenew(LINES, COLS, 0, 0); ! 76: stdscr = makenew(LINES, COLS, 0, 0); ! 77: # ifdef DEBUG ! 78: if(outf) fprintf(outf, "SP %x, stdscr %x, curscr %x\n", SP, stdscr, curscr); ! 79: # endif ! 80: SP->std_scr = stdscr; ! 81: SP->cur_scr = curscr; ! 82: _endwin = FALSE; ! 83: return scp; ! 84: } ! 85: ! 86: /* ! 87: * Low level interface, for compatibility with old curses. ! 88: */ ! 89: setterm(type) ! 90: char *type; ! 91: { ! 92: setupterm(type, 1, 0); ! 93: } ! 94: ! 95: gettmode() ! 96: { ! 97: /* No-op included only for upward compatibility. */ ! 98: } ! 99: ! 100: /* ! 101: * This routine sets up a _window buffer and returns a pointer to it. ! 102: */ ! 103: static WINDOW * ! 104: makenew(num_lines, num_cols, begy, begx) ! 105: int num_lines, num_cols, begy, begx; ! 106: { ! 107: reg WINDOW *win; ! 108: char *calloc(); ! 109: ! 110: # ifdef DEBUG ! 111: if(outf) fprintf(outf, "MAKENEW(%d, %d, %d, %d)\n", num_lines, num_cols, begy, begx); ! 112: # endif ! 113: if ((win = (WINDOW *) calloc(1, sizeof (WINDOW))) == NULL) ! 114: return NULL; ! 115: # ifdef DEBUG ! 116: if(outf) fprintf(outf, "MAKENEW: num_lines = %d\n", num_lines); ! 117: # endif ! 118: win->_cury = win->_curx = 0; ! 119: win->_maxy = num_lines; ! 120: win->_maxx = num_cols; ! 121: win->_begy = begy; ! 122: win->_begx = begx; ! 123: win->_scroll = win->_leave = win->_use_idl = FALSE; ! 124: return win; ! 125: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.