| 414 | recent messages. */ |
| 415 | |
| 416 | void |
| 417 | curses_last_messages(void) |
| 418 | { |
| 419 | nhprev_mesg *mesg; |
| 420 | int i, height, width; |
| 421 | int border = curses_window_has_border(MESSAGE_WIN) ? 1 : 0; |
| 422 | WINDOW *win = curses_get_nhwin(MESSAGE_WIN); |
| 423 | |
| 424 | curses_set_wid_colors(MESSAGE_WIN, NULL); |
| 425 | curses_get_window_size(MESSAGE_WIN, &height, &width); |
| 426 | werase(win); |
| 427 | mx = my = border; |
| 428 | |
| 429 | /* |
| 430 | * FIXME! |
| 431 | * This shouldn't be relying on a naive line count to decide where |
| 432 | * to start and stop because curses_message_win_puts() combines short |
| 433 | * lines. So we can end up with blank lines at bottom of the message |
| 434 | * window, missing out on one or more older messages which could have |
| 435 | * been included at the top. Also long messages might wrap and take |
| 436 | * more than one line apiece. |
| 437 | * |
| 438 | * 3.6.2 showed oldest available N-1 lines (by starting at |
| 439 | * num_mesages - 1 and working back toward 0 until window height was |
| 440 | * reached [via index 'j' which is gone now]) plus the latest line |
| 441 | * (via toplines[]), rather than most recent N (start at height - 1 |
| 442 | * and work way up through 0). So it showed wrong subset of lines |
| 443 | * even if 'N lines' had been the right way to handle this. |
| 444 | */ |
| 445 | ++last_messages; |
| 446 | for (i = min(height, num_messages) - 1; i > 0; --i) { |
| 447 | mesg = get_msg_line(TRUE, i); |
| 448 | if (mesg && mesg->str && *mesg->str) |
| 449 | curses_message_win_puts(mesg->str, TRUE); |
| 450 | } |
| 451 | curses_message_win_puts(gt.toplines, TRUE); |
| 452 | --last_messages; |
| 453 | |
| 454 | if (border) |
| 455 | box(win, 0, 0); |
| 456 | wrefresh(win); |
| 457 | } |
| 458 | |
| 459 | |
| 460 | /* Initialize list for message history */ |
no test coverage detected