| 248 | } |
| 249 | |
| 250 | void |
| 251 | update_topl(const char *bp) |
| 252 | { |
| 253 | char *tl, *otl; |
| 254 | int n0; |
| 255 | int notdied = 1; |
| 256 | struct WinDesc *cw = wins[WIN_MESSAGE]; |
| 257 | boolean skip = (cw->flags & (WIN_STOP | WIN_NOSTOP)) == WIN_STOP; |
| 258 | |
| 259 | /* If there is room on the line, print message on same line */ |
| 260 | /* But messages like "You die..." deserve their own line */ |
| 261 | n0 = strlen(bp); |
| 262 | if ((ttyDisplay->toplin == TOPLINE_NEED_MORE || skip) |
| 263 | && cw->cury == 0 |
| 264 | && n0 + (int) strlen(gt.toplines) + 3 < CO - 8 /* room for --More-- */ |
| 265 | && (notdied = strncmp(bp, "You die", 7)) != 0) { |
| 266 | Strcat(gt.toplines, " "); |
| 267 | Strcat(gt.toplines, bp); |
| 268 | cw->curx += 2; |
| 269 | if (!skip) |
| 270 | addtopl(bp); |
| 271 | return; |
| 272 | } else if (!skip) { |
| 273 | if (ttyDisplay->toplin == TOPLINE_NEED_MORE) { |
| 274 | more(); |
| 275 | } else if (cw->cury) { /* for toplin==TOPLINE_NON_EMPTY && cury > 1 */ |
| 276 | docorner(1, cw->cury + 1, 0); /* reset cury = 0 if redraw screen */ |
| 277 | cw->curx = cw->cury = 0; /* from home--cls() & docorner(1,n,0) */ |
| 278 | } |
| 279 | } |
| 280 | remember_topl(); |
| 281 | (void) strncpy(gt.toplines, bp, TBUFSZ); |
| 282 | gt.toplines[TBUFSZ - 1] = 0; |
| 283 | |
| 284 | for (tl = gt.toplines; n0 >= CO; ) { |
| 285 | otl = tl; |
| 286 | for (tl += CO - 1; tl != otl; --tl) |
| 287 | if (*tl == ' ') |
| 288 | break; |
| 289 | if (tl == otl) { |
| 290 | /* Eek! A huge token. Try splitting after it. */ |
| 291 | tl = strchr(otl, ' '); |
| 292 | if (!tl) |
| 293 | break; /* No choice but to spit it out whole. */ |
| 294 | } |
| 295 | *tl++ = '\n'; |
| 296 | n0 = strlen(tl); |
| 297 | } |
| 298 | if (!notdied) /* double negative => "You die"; avoid suppressing mesg */ |
| 299 | cw->flags &= ~WIN_STOP, skip = FALSE; |
| 300 | if (!skip) |
| 301 | redotoplin(gt.toplines); |
| 302 | } |
| 303 | |
| 304 | static void |
| 305 | topl_putsym(char c) |
no test coverage detected