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); } } } }
void vpline(const char *line, va_list ap) { char pbuf[BUFSZ]; char *bp = pbuf, *tl; int n,n0; if(!line || !*line) return; (void) vsnprintf(pbuf, sizeof pbuf, line, ap); if(flags.toplin == 1 && !strcmp(pbuf, toplines)) return; nscr(); /* %% */ /* If there is room on the line, print message on same line */ /* But messages like "You die..." deserve their own line */ n0 = strlen(bp); if(flags.toplin == 1 && tly == 1 && n0 + strlen(toplines) + 3 < CO-8 && /* leave room for --More-- */ strncmp(bp, "You ", 4)) { (void) strlcat(toplines, " ", sizeof toplines); (void) strlcat(toplines, bp, sizeof toplines); tlx += 2; addtopl(bp); return; } if(flags.toplin == 1) more(); remember_topl(); toplines[0] = 0; while(n0){ if(n0 >= CO){ /* look for appropriate cut point */ n0 = 0; for(n = 0; n < CO; n++) if(bp[n] == ' ') n0 = n; if(!n0) for(n = 0; n < CO-1; n++) if(!letter(bp[n])) n0 = n; if(!n0) n0 = CO-2; } (void) strncpy((tl = eos(toplines)), bp, n0); tl[n0] = '\0'; bp += n0; /* remove trailing spaces, but leave one */ while(n0 > 1 && tl[n0-1] == ' ' && tl[n0-2] == ' ') tl[--n0] = 0; n0 = strlen(bp); if(n0 && tl[0]) (void) strlcat(tl, "\n", toplines + sizeof toplines - tl); } redotoplin(); }