void curses_message_win_puts(const char *message, boolean recursed) { int height, width, linespace; char *tmpstr; WINDOW *win = curses_get_nhwin(MESSAGE_WIN); boolean border = curses_window_has_border(MESSAGE_WIN); int message_length = strlen(message); int border_space = 0; static long suppress_turn = -1; if (strncmp("Count:", message, 6) == 0) { curses_count_window(message); return; } if (suppress_turn == moves) { return; } curses_get_window_size(MESSAGE_WIN, &height, &width); if (border) { border_space = 1; if (mx < 1) { mx = 1; } if (my < 1) { my = 1; } } linespace = ((width + border_space) - 3) - mx; if (strcmp(message, "#") == 0) /* Extended command or Count: */ { if ((strcmp(toplines, "#") != 0) && (my >= (height - 1 + border_space)) && (height != 1)) /* Bottom of message window */ { scroll_window(MESSAGE_WIN); mx = width; my--; strcpy(toplines, message); } return; } if (!recursed) { strcpy(toplines, message); mesg_add_line((char *) message); } if (linespace < message_length) { if (my >= (height - 1 + border_space)) /* bottom of message win */ { if ((turn_lines > height) || (height == 1)) { /* Pause until key is hit - Esc suppresses any further messages that turn */ if (curses_more() == '\033') { suppress_turn = moves; return; } } else { scroll_window(MESSAGE_WIN); turn_lines++; } } else { if (mx != border_space) { my++; mx = border_space; } } } if (height > 1) { curses_toggle_color_attr(win, NONE, A_BOLD, ON); } if ((mx == border_space) && ((message_length + 2) > width)) { tmpstr = curses_break_str(message, (width - 2), 1); mvwprintw(win, my, mx, "%s", tmpstr); mx += strlen(tmpstr); if (strlen(tmpstr) < (width - 2)) { mx++; } free(tmpstr); if (height > 1) { curses_toggle_color_attr(win, NONE, A_BOLD, OFF); } wrefresh(win); curses_message_win_puts(curses_str_remainder(message, (width - 2), 1), TRUE); } else { mvwprintw(win, my, mx, "%s", message); curses_toggle_color_attr(win, NONE, A_BOLD, OFF); mx += message_length + 1; } wrefresh(win); }
void curses_message_win_puts(const char *message, boolean recursed) { int height, width, linespace, count; char *tmpstr; WINDOW *win = curses_get_nhwin(MESSAGE_WIN); boolean border = curses_window_has_border(MESSAGE_WIN); int message_length = strlen(message); int border_space = 0; if (!recursed) { strcpy(toplines, message); mesg_add_line((char *) message); } curses_get_window_size(MESSAGE_WIN, &height, &width); if (border) { border_space = 1; if (mx < 1) { mx = 1; } if (my < 1) { my = 1; } } linespace = ((width + border_space) - 3) - mx; if (linespace < message_length) { if (my >= (height - 1 + border_space)) /* bottom of message win */ { if (turn_lines == height) { curses_more(); } else { scroll_window(MESSAGE_WIN); turn_lines++; } } else { if (mx != border_space) { my++; mx = border_space; } } } if (height > 1) { curses_toggle_color_attr(win, NONE, ATR_BOLD, ON); } if ((mx == border_space) && ((message_length + 2) > width)) { tmpstr = curses_break_str(message, (width - 2), 1); mvwprintw(win, my, mx, tmpstr); mx += strlen(tmpstr); free(tmpstr); if (height > 1) { curses_toggle_color_attr(win, NONE, ATR_BOLD, OFF); } wrefresh(win); curses_message_win_puts(curses_str_remainder(message, (width - 2), 1), TRUE); } else { mvwprintw(win, my, mx, message); curses_toggle_color_attr(win, NONE, ATR_BOLD, OFF); } wrefresh(win); mx += message_length + 1; }