int tty_doprev_message() { register struct WinDesc *cw = wins[WIN_MESSAGE]; if(cw->data[cw->maxcol]) redotoplin(cw->data[cw->maxcol]); else if(cw->maxcol == cw->maxrow) redotoplin(toplines); cw->maxcol--; if(cw->maxcol < 0) cw->maxcol = cw->rows-1; if(!cw->data[cw->maxcol]) cw->maxcol = cw->maxrow; return 0; }
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(); }
int doredotopl(void) { if(last_redone_topl) last_redone_topl = last_redone_topl->next_topl; if(!last_redone_topl) last_redone_topl = old_toplines; if(last_redone_topl){ strcpy(toplines, last_redone_topl->topl_text); } redotoplin(); return(0); }
int doredotopl() { if(last_redone_topl) last_redone_topl = last_redone_topl->next_topl; if(!last_redone_topl) last_redone_topl = old_toplines; if(last_redone_topl){ (void) strlcpy(toplines, last_redone_topl->topl_text, sizeof toplines); } redotoplin(); return(0); }
int doredotopl() { if(last_redone_topl != NULL) { last_redone_topl = last_redone_topl->next_topl; } if(last_redone_topl == NULL) { last_redone_topl = old_toplines; } if(last_redone_topl != NULL) { strcpy(toplines, last_redone_topl->topl_text); } redotoplin(); return 0; }
int tty_doprev_message() { register struct WinDesc *cw = wins[WIN_MESSAGE]; winid prevmsg_win; int i; if ((iflags.prevmsg_window != 's') && !ttyDisplay->inread) { /* not single */ if(iflags.prevmsg_window == 'f') { /* full */ prevmsg_win = create_nhwindow(NHW_MENU); putstr(prevmsg_win, 0, "Message History"); putstr(prevmsg_win, 0, ""); cw->maxcol = cw->maxrow; i = cw->maxcol; do { if(cw->data[i] && strcmp(cw->data[i], "") ) putstr(prevmsg_win, 0, cw->data[i]); i = (i + 1) % cw->rows; } while (i != cw->maxcol); putstr(prevmsg_win, 0, toplines); display_nhwindow(prevmsg_win, TRUE); destroy_nhwindow(prevmsg_win); } else if (iflags.prevmsg_window == 'c') { /* combination */ do { morc = 0; if (cw->maxcol == cw->maxrow) { ttyDisplay->dismiss_more = C('p'); /* <ctrl/P> allowed at --More-- */ redotoplin(toplines); cw->maxcol--; if (cw->maxcol < 0) cw->maxcol = cw->rows-1; if (!cw->data[cw->maxcol]) cw->maxcol = cw->maxrow; } else if (cw->maxcol == (cw->maxrow - 1)){ ttyDisplay->dismiss_more = C('p'); /* <ctrl/P> allowed at --More-- */ redotoplin(cw->data[cw->maxcol]); cw->maxcol--; if (cw->maxcol < 0) cw->maxcol = cw->rows-1; if (!cw->data[cw->maxcol]) cw->maxcol = cw->maxrow; } else { prevmsg_win = create_nhwindow(NHW_MENU); putstr(prevmsg_win, 0, "Message History"); putstr(prevmsg_win, 0, ""); cw->maxcol = cw->maxrow; i = cw->maxcol; do { if(cw->data[i] && strcmp(cw->data[i], "") ) putstr(prevmsg_win, 0, cw->data[i]); i = (i + 1) % cw->rows; } while (i != cw->maxcol); putstr(prevmsg_win, 0, toplines); display_nhwindow(prevmsg_win, TRUE); destroy_nhwindow(prevmsg_win); } } while (morc == C('p')); ttyDisplay->dismiss_more = 0; } else { /* reversed */ morc = 0; prevmsg_win = create_nhwindow(NHW_MENU); putstr(prevmsg_win, 0, "Message History"); putstr(prevmsg_win, 0, ""); putstr(prevmsg_win, 0, toplines); cw->maxcol=cw->maxrow-1; if(cw->maxcol < 0) cw->maxcol = cw->rows-1; do { putstr(prevmsg_win, 0, cw->data[cw->maxcol]); cw->maxcol--; if (cw->maxcol < 0) cw->maxcol = cw->rows-1; if (!cw->data[cw->maxcol]) cw->maxcol = cw->maxrow; } while (cw->maxcol != cw->maxrow); display_nhwindow(prevmsg_win, TRUE); destroy_nhwindow(prevmsg_win); cw->maxcol = cw->maxrow; ttyDisplay->dismiss_more = 0; } } else if(iflags.prevmsg_window == 's') { /* single */ ttyDisplay->dismiss_more = C('p'); /* <ctrl/P> allowed at --More-- */ do { morc = 0; if (cw->maxcol == cw->maxrow) redotoplin(toplines); else if (cw->data[cw->maxcol]) redotoplin(cw->data[cw->maxcol]); cw->maxcol--; if (cw->maxcol < 0) cw->maxcol = cw->rows-1; if (!cw->data[cw->maxcol]) cw->maxcol = cw->maxrow; } while (morc == C('p')); ttyDisplay->dismiss_more = 0; } return 0; }
void pline(char *line, ...) { char pbuf[BUFSZ]; char *bp = pbuf; char *tl; int n; int n0; if((line == NULL) || (*line == 0)) { return; } if(index(line, '%') == 0) { strcpy(pbuf, line); } else { va_list args; va_start(args, line); vsprintf(pbuf, line, args); va_end(args); } if((flags.topl == 1) && (strcmp(pbuf, toplines) == 0)) { 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.topl == 1) && (tly == 1) && (((n0 + strlen(toplines)) + 3) < TOPLSZ) && (strncmp(bp, "You ", 4) != 0)) { strcat(toplines, " "); strcat(toplines, bp); tlx +=2; return; } if(flags.topl == 1) { more(); } remember_topl(); toplines[0] = 0; while(n0 != 0) { if(n0 >= COLNO) { /* Look for appropriate cut point */ n0 = 0; for(n = 0; n < COLNO; ++n) { if(bp[n] == ' ') { n0 = n; } } if(n0 == 0) { for(n = 0; n < COLNO - 1; ++n) { if(letter(bp[n]) == 0) { n0 = n; } } } if(n0 == 0) { n0 = COLNO - 2; } } tl = eos(toplines); strncpy(tl, bp, n0); tl[n0] = 0; bp += n0; /* Remove the trailing spaces, but leave one */ while((n0 > 1) && (tl[n0 - 1] == ' ') && (tl[n0 - 2] == ' ')) { --n0; tl[n0] = 0; } n0 = strlen(bp); if((n0 != 0) && (tl[0] != 0)) { strcat(tl, "\n"); } } redotoplin(); }