use ctrl_nhwindow() for menu prompt style
This implements the mechanics to use the ctrl_nhwindow() interface capability to pass down a setting change from the core to the active window port, without resorting to accessing a core global variable from within the window port, and without altering the interface.. The passed setting is honored in the tty and curses window ports. X11 and mswin receive and store the values, but no implementation to change the menu prompt style is there yet. Qt does not store the values or have an implementation. The setting change is done in allmain.c immediately after creating the WIN_INVEN window.
This commit is contained in:
@@ -1164,6 +1164,8 @@ get_menuitem_y(
|
||||
|
||||
/* Displays menu selections in the given window */
|
||||
|
||||
extern color_attr curses_menu_promptstyle; /*cursmain.c */
|
||||
|
||||
static void
|
||||
menu_display_page(
|
||||
nhmenu *menu, WINDOW *win,
|
||||
@@ -1207,9 +1209,11 @@ menu_display_page(
|
||||
|
||||
for (count = 0; count < num_lines; count++) {
|
||||
tmpstr = curses_break_str(menu->prompt, menu->width, count + 1);
|
||||
curses_toggle_color_attr(win, NO_COLOR, A_NORMAL, ON);
|
||||
curses_toggle_color_attr(win, curses_menu_promptstyle.color,
|
||||
curses_menu_promptstyle.attr, ON);
|
||||
mvwprintw(win, count + 1, 1, "%s", tmpstr);
|
||||
curses_toggle_color_attr(win, NO_COLOR, A_NORMAL, OFF);
|
||||
curses_toggle_color_attr(win, curses_menu_promptstyle.color,
|
||||
curses_menu_promptstyle.attr, OFF);
|
||||
free(tmpstr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,6 +149,7 @@ int orig_cursor; /* Preserve initial cursor state */
|
||||
WINDOW *base_term; /* underlying terminal window */
|
||||
boolean counting; /* Count window is active */
|
||||
WINDOW *mapwin, *statuswin, *messagewin; /* Main windows */
|
||||
color_attr curses_menu_promptstyle = { NO_COLOR, ATR_NONE };
|
||||
|
||||
/* Track if we're performing an update to the permanent window.
|
||||
Needed since we aren't using the normal menu functions to handle
|
||||
@@ -799,10 +800,32 @@ curses_update_inventory(int arg)
|
||||
win_request_info *
|
||||
curses_ctrl_nhwindow(
|
||||
winid window UNUSED,
|
||||
int request UNUSED,
|
||||
win_request_info *wri UNUSED)
|
||||
int request,
|
||||
win_request_info *wri)
|
||||
{
|
||||
return (win_request_info *) 0;
|
||||
int attr;
|
||||
|
||||
if (!wri)
|
||||
return (win_request_info *) 0;
|
||||
|
||||
switch (request) {
|
||||
#if 0
|
||||
case set_mode:
|
||||
case request_settings:
|
||||
break;
|
||||
#endif
|
||||
case set_menu_promptstyle:
|
||||
curses_menu_promptstyle.color = wri->fromcore.menu_promptstyle.color;
|
||||
if (curses_menu_promptstyle.color == NO_COLOR)
|
||||
curses_menu_promptstyle.color = NONE;
|
||||
attr = wri->fromcore.menu_promptstyle.attr;
|
||||
curses_menu_promptstyle.attr = curses_convert_attr(attr);;
|
||||
break;
|
||||
default:
|
||||
impossible("invalid request to ctrl_nhwindow: %d", request);
|
||||
break;
|
||||
}
|
||||
return wri;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user