| 559 | popup_dialog is not currently implemented for this function. */ |
| 560 | |
| 561 | void |
| 562 | curses_count_window(const char *count_text) |
| 563 | { |
| 564 | static WINDOW *countwin = NULL; |
| 565 | int winx, winy; |
| 566 | int messageh, messagew, border; |
| 567 | |
| 568 | if (!count_text) { |
| 569 | if (countwin) |
| 570 | delwin(countwin), countwin = NULL; |
| 571 | counting = FALSE; |
| 572 | return; |
| 573 | } |
| 574 | |
| 575 | /* position of message window, not current position within message window |
| 576 | (so <0,0> for align_message:Top but will vary for other alignings) */ |
| 577 | curses_get_window_xy(MESSAGE_WIN, &winx, &winy); |
| 578 | /* size of message window, with space for borders already subtracted */ |
| 579 | curses_get_window_size(MESSAGE_WIN, &messageh, &messagew); |
| 580 | |
| 581 | /* decide where to put the one-line counting window */ |
| 582 | border = curses_window_has_border(MESSAGE_WIN) ? 1 : 0; |
| 583 | winx += border; /* first writeable message column */ |
| 584 | winy += border + (messageh - 1); /* last writable message line */ |
| 585 | |
| 586 | /* if most recent message (probably prompt leading to this instance of |
| 587 | counting window) is going to be covered up, scroll mesgs up a line */ |
| 588 | if (!counting && my == border + (messageh - 1) && mx > border) { |
| 589 | scroll_window(MESSAGE_WIN); |
| 590 | if (messageh > 1) { |
| 591 | /* handling for next message will behave as if we're currently |
| 592 | positioned at the end of next to last line of message window */ |
| 593 | my = border + (messageh - 1) - 1; |
| 594 | mx = border + (messagew - 1); /* (0 + 80 - 1) or (1 + 78 - 1) */ |
| 595 | } else { |
| 596 | /* for a one-line window, use beginning of only line instead */ |
| 597 | my = mx = border; /* 0 or 1 */ |
| 598 | } |
| 599 | /* wmove(curses_get_nhwin(MESSAGE_WIN), my, mx); -- not needed */ |
| 600 | } |
| 601 | /* in case we're being called from clear_nhwindow(MESSAGE_WIN) |
| 602 | which gets called for every command keystroke; it sends an |
| 603 | empty string to get the scroll-up-one-line effect above and |
| 604 | we want to avoid the curses overhead for the operations below... */ |
| 605 | if (!*count_text) |
| 606 | return; |
| 607 | |
| 608 | counting = TRUE; |
| 609 | #ifdef PDCURSES |
| 610 | if (countwin) |
| 611 | curses_destroy_win(countwin), countwin = NULL; |
| 612 | #endif /* PDCURSES */ |
| 613 | /* this used to specify a width of 25; that was adequate for 'Count: 123' |
| 614 | but not for dolook's autodescribe when it refers to a named monster */ |
| 615 | if (!countwin) |
| 616 | countwin = newwin(1, messagew, winy, winx); |
| 617 | curses_set_wid_colors(MESSAGE_WIN, NULL); |
| 618 | werase(countwin); |
no test coverage detected