void startup(void) { char *term; char *tptr; char *tbufptr, *pc; tptr = (char *) alloc(1024); tbufptr = tbuf; if(!(term = getenv("TERM"))) error("Can't get TERM."); if(!strncmp(term, "5620", 4)) flags.nonull = 1; /* this should be a termcap flag */ if(tgetent(tptr, term) < 1) error("Unknown terminal type: %s.", term); if ((pc = tgetstr("pc", &tbufptr))) PC = *pc; if(!(BC = tgetstr("le", &tbufptr))) { if(!tgetflag("bs")) error("Terminal must backspace."); BC = tbufptr; tbufptr += 2; *BC = '\b'; } HO = tgetstr("ho", &tbufptr); CO = tgetnum("co"); LI = tgetnum("li"); if(CO < COLNO || LI < ROWNO+2) setclipped(); if(!(CL = tgetstr("cl", &tbufptr))) error("Hack needs CL."); ND = tgetstr("nd", &tbufptr); if(tgetflag("os")) error("Hack can't have OS."); CE = tgetstr("ce", &tbufptr); UP = tgetstr("up", &tbufptr); /* It seems that xd is no longer supported, and we should use a linefeed instead; unfortunately this requires resetting CRMOD, and many output routines will have to be modified slightly. Let's leave that till the next release. */ XD = tgetstr("xd", &tbufptr); /* not: XD = tgetstr("do", &tbufptr); */ if(!(CM = tgetstr("cm", &tbufptr))) { if(!UP && !HO) error("Hack needs CM or UP or HO."); printf("Playing hack on terminals without cm is suspect...\n"); getret(); } SO = tgetstr("so", &tbufptr); SE = tgetstr("se", &tbufptr); SG = tgetnum("sg"); /* -1: not fnd; else # of spaces left by so */ if(!SO || !SE || (SG > 0)) SO = SE = 0; CD = tgetstr("cd", &tbufptr); set_whole_screen(); /* uses LI and CD */ if(tbufptr-tbuf > sizeof(tbuf)) error("TERMCAP entry too big...\n"); free(tptr); }
static void winch() { int oldLI = LI, oldCO = CO, i; register struct WinDesc *cw; getwindowsz(); if((oldLI != LI || oldCO != CO) && ttyDisplay) { ttyDisplay->rows = LI; ttyDisplay->cols = CO; cw = wins[BASE_WINDOW]; cw->rows = ttyDisplay->rows; cw->cols = ttyDisplay->cols; if(flags.window_inited) { cw = wins[WIN_MESSAGE]; cw->curx = cw->cury = 0; tty_destroy_nhwindow(WIN_STATUS); WIN_STATUS = tty_create_nhwindow(NHW_STATUS); if(u.ux) { #ifdef CLIPPING if(CO < COLNO || LI < ROWNO+3) { setclipped(); tty_cliparound(u.ux, u.uy); } else { clipping = FALSE; clipx = clipy = 0; } #endif i = ttyDisplay->toplin; ttyDisplay->toplin = 0; docrt(); bot(); ttyDisplay->toplin = i; flush_screen(1); if(i) { addtopl(toplines); } else for(i=WIN_INVEN; i < MAXWIN; i++) if(wins[i] && wins[i]->active) { /* cop-out */ addtopl("Press Return to continue: "); break; } (void) fflush(stdout); if(i < 2) flush_screen(1); } } } }