Curses: implement the windowcolors option

Allow changing the curses windows foreground and background colors,
for example:

OPTIONS=windowcolor:menu #8000F0/20F080 message grey/blue
This commit is contained in:
Pasi Kallinen
2024-03-17 18:41:52 +02:00
parent 9dbab97a1e
commit 4030ef13a0
17 changed files with 214 additions and 32 deletions
+8
View File
@@ -7,6 +7,7 @@
#include "hack.h"
#include "wincurs.h"
#include "cursmesg.h"
#include "curswins.h"
#include <ctype.h>
/* defined in sys/<foo>/<foo>tty.c or cursmain.c as last resort;
@@ -106,6 +107,7 @@ curses_message_win_puts(const char *message, boolean recursed)
return; /* user has typed ESC to avoid seeing remaining messages. */
}
curses_set_wid_colors(MESSAGE_WIN, NULL);
curses_get_window_size(MESSAGE_WIN, &height, &width);
border_space = (border ? 1 : 0);
if (mx < border_space)
@@ -322,6 +324,7 @@ curses_block(
}
moreattr = !iflags.wc2_guicolor ? (int) A_REVERSE : NONE;
curses_toggle_color_attr(win, MORECOLOR, moreattr, ON);
curses_set_wid_colors(MESSAGE_WIN, NULL);
if (blink) {
wattron(win, A_BLINK);
mvwprintw(win, my, mx, ">"), mx += 1;
@@ -331,6 +334,7 @@ curses_block(
mvwprintw(win, my, mx, ">>"), mx += 2;
}
curses_toggle_color_attr(win, MORECOLOR, moreattr, OFF);
curses_set_wid_colors(MESSAGE_WIN, NULL);
wrefresh(win);
/* cancel mesg suppression; all messages will have had chance to be read */
@@ -379,6 +383,7 @@ curses_clear_unhighlight_message_window(void)
WINDOW *win = curses_get_nhwin(MESSAGE_WIN);
turn_lines = 0;
curses_set_wid_colors(MESSAGE_WIN, NULL);
curses_get_window_size(MESSAGE_WIN, &mh, &mw);
if (mh == 1) {
@@ -413,6 +418,7 @@ curses_last_messages(void)
int border = curses_window_has_border(MESSAGE_WIN) ? 1 : 0;
WINDOW *win = curses_get_nhwin(MESSAGE_WIN);
curses_set_wid_colors(MESSAGE_WIN, NULL);
curses_get_window_size(MESSAGE_WIN, &height, &width);
werase(win);
mx = my = border;
@@ -605,6 +611,7 @@ curses_count_window(const char *count_text)
but not for dolook's autodescribe when it refers to a named monster */
if (!countwin)
countwin = newwin(1, messagew, winy, winx);
curses_set_wid_colors(MESSAGE_WIN, NULL);
werase(countwin);
mvwprintw(countwin, 0, 0, "%s", count_text);
@@ -880,6 +887,7 @@ directional_scroll(winid wid, int nlines)
boolean border = curses_window_has_border(wid);
WINDOW *win = curses_get_nhwin(wid);
curses_set_wid_colors(wid, NULL);
curses_get_window_size(wid, &wh, &ww);
if (wh == 1) {
curses_clear_nhwin(wid);