Merge branch 'win-minor' of https://rodney.nethack.org:20040/git/NHsource into win-minor
This commit is contained in:
+22
-13
@@ -419,6 +419,8 @@ curses_ext_cmd()
|
||||
ret = -1;
|
||||
}
|
||||
for (count = 0; extcmdlist[count].ef_txt; count++) {
|
||||
if (!wizard && (extcmdlist[count].flags & WIZMODECMD))
|
||||
continue;
|
||||
if (!(extcmdlist[count].flags & AUTOCOMPLETE))
|
||||
continue;
|
||||
if (strlen(extcmdlist[count].ef_txt) > (size_t) prompt_width) {
|
||||
@@ -508,6 +510,12 @@ curses_add_nhmenu_item(winid wid, int glyph, const ANY_P * identifier,
|
||||
nhmenu_item *new_item, *current_items, *menu_item_ptr;
|
||||
nhmenu *current_menu = get_menu(wid);
|
||||
|
||||
if (current_menu == NULL) {
|
||||
impossible
|
||||
("curses_add_nhmenu_item: attempt to add item to nonexistent menu");
|
||||
return;
|
||||
}
|
||||
|
||||
if (str == NULL) {
|
||||
return;
|
||||
}
|
||||
@@ -530,11 +538,6 @@ curses_add_nhmenu_item(winid wid, int glyph, const ANY_P * identifier,
|
||||
new_item->count = -1;
|
||||
new_item->next_item = NULL;
|
||||
|
||||
if (current_menu == NULL) {
|
||||
panic
|
||||
("curses_add_nhmenu_item: attempt to add item to nonexistant menu");
|
||||
}
|
||||
|
||||
current_items = current_menu->entries;
|
||||
menu_item_ptr = current_items;
|
||||
|
||||
@@ -559,12 +562,13 @@ curses_finalize_nhmenu(winid wid, const char *prompt)
|
||||
{
|
||||
int count = 0;
|
||||
nhmenu *current_menu = get_menu(wid);
|
||||
nhmenu_item *menu_item_ptr = current_menu->entries;
|
||||
|
||||
if (current_menu == NULL) {
|
||||
panic("curses_finalize_nhmenu: attempt to finalize nonexistant menu");
|
||||
impossible("curses_finalize_nhmenu: attempt to finalize nonexistent menu");
|
||||
return;
|
||||
}
|
||||
|
||||
nhmenu_item *menu_item_ptr = current_menu->entries;
|
||||
while (menu_item_ptr != NULL) {
|
||||
menu_item_ptr = menu_item_ptr->next_item;
|
||||
count++;
|
||||
@@ -590,13 +594,15 @@ curses_display_nhmenu(winid wid, int how, MENU_ITEM_P ** _selected)
|
||||
*_selected = NULL;
|
||||
|
||||
if (current_menu == NULL) {
|
||||
panic("curses_display_nhmenu: attempt to display nonexistant menu");
|
||||
impossible("curses_display_nhmenu: attempt to display nonexistent menu");
|
||||
return '\033';
|
||||
}
|
||||
|
||||
menu_item_ptr = current_menu->entries;
|
||||
|
||||
if (menu_item_ptr == NULL) {
|
||||
panic("curses_display_nhmenu: attempt to display empty menu");
|
||||
impossible("curses_display_nhmenu: attempt to display empty menu");
|
||||
return '\033';
|
||||
}
|
||||
|
||||
/* Reset items to unselected to clear out selections from previous
|
||||
@@ -631,8 +637,9 @@ curses_display_nhmenu(winid wid, int how, MENU_ITEM_P ** _selected)
|
||||
while (menu_item_ptr != NULL) {
|
||||
if (menu_item_ptr->selected) {
|
||||
if (count == num_chosen) {
|
||||
panic("curses_display_nhmenu: Selected items "
|
||||
impossible("curses_display_nhmenu: Selected items "
|
||||
"exceeds expected number");
|
||||
break;
|
||||
}
|
||||
selected[count].item = menu_item_ptr->identifier;
|
||||
selected[count].count = menu_item_ptr->count;
|
||||
@@ -642,7 +649,7 @@ curses_display_nhmenu(winid wid, int how, MENU_ITEM_P ** _selected)
|
||||
}
|
||||
|
||||
if (count != num_chosen) {
|
||||
panic("curses_display_nhmenu: Selected items less than "
|
||||
impossible("curses_display_nhmenu: Selected items less than "
|
||||
"expected number");
|
||||
}
|
||||
}
|
||||
@@ -949,7 +956,8 @@ menu_display_page(nhmenu *menu, WINDOW * win, int page_num)
|
||||
}
|
||||
|
||||
if (menu_item_ptr == NULL) { /* Page not found */
|
||||
panic("menu_display_page: attempt to display nonexistant page");
|
||||
impossible("menu_display_page: attempt to display nonexistent page");
|
||||
return;
|
||||
}
|
||||
|
||||
werase(win);
|
||||
@@ -1343,7 +1351,8 @@ menu_operation(WINDOW * win, nhmenu *menu, menu_op
|
||||
}
|
||||
|
||||
if (menu_item_ptr == NULL) { /* Page not found */
|
||||
panic("menu_display_page: attempt to display nonexistant page");
|
||||
impossible("menu_display_page: attempt to display nonexistent page");
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (menu_item_ptr != NULL) {
|
||||
|
||||
+26
-43
@@ -148,18 +148,13 @@ curses_block(boolean noscroll)
|
||||
|
||||
curses_get_window_size(MESSAGE_WIN, &height, &width);
|
||||
curses_toggle_color_attr(win, MORECOLOR, NONE, ON);
|
||||
mvwprintw(win, my, mx, iflags.msg_is_alert ? "<TAB!>" : ">>");
|
||||
mvwprintw(win, my, mx, ">>");
|
||||
curses_toggle_color_attr(win, MORECOLOR, NONE, OFF);
|
||||
if (iflags.msg_is_alert)
|
||||
curses_alert_main_borders(TRUE);
|
||||
wrefresh(win);
|
||||
while (iflags.msg_is_alert && (ret = wgetch(win) != '\t'));
|
||||
/* msgtype=stop should require space/enter rather than
|
||||
* just any key, as we want to prevent YASD from
|
||||
* riding direction keys. */
|
||||
while (!iflags.msg_is_alert && (ret = wgetch(win)) && !index(resp,(char)ret));
|
||||
if (iflags.msg_is_alert)
|
||||
curses_alert_main_borders(FALSE);
|
||||
while ((ret = wgetch(win)) && !index(resp,(char)ret));
|
||||
if (height == 1) {
|
||||
curses_clear_unhighlight_message_window();
|
||||
} else {
|
||||
@@ -298,8 +293,8 @@ curses_prev_mesg()
|
||||
}
|
||||
|
||||
|
||||
/* Shows Count: in a separate window, or at the bottom of the message
|
||||
window, depending on the user's settings */
|
||||
/* Shows Count: at the bottom of the message window,
|
||||
popup_dialog is not currently implemented for this function */
|
||||
|
||||
void
|
||||
curses_count_window(const char *count_text)
|
||||
@@ -317,43 +312,31 @@ curses_count_window(const char *count_text)
|
||||
|
||||
counting = TRUE;
|
||||
|
||||
if (iflags.wc_popup_dialog) { /* Display count in popup window */
|
||||
startx = 1;
|
||||
starty = 1;
|
||||
curses_get_window_xy(MESSAGE_WIN, &winx, &winy);
|
||||
curses_get_window_size(MESSAGE_WIN, &messageh, &messagew);
|
||||
|
||||
if (countwin == NULL) {
|
||||
countwin = curses_create_window(25, 1, UP);
|
||||
}
|
||||
|
||||
} else { /* Display count at bottom of message window */
|
||||
|
||||
curses_get_window_xy(MESSAGE_WIN, &winx, &winy);
|
||||
curses_get_window_size(MESSAGE_WIN, &messageh, &messagew);
|
||||
|
||||
if (curses_window_has_border(MESSAGE_WIN)) {
|
||||
winx++;
|
||||
winy++;
|
||||
}
|
||||
|
||||
winy += messageh - 1;
|
||||
|
||||
if (countwin == NULL) {
|
||||
pline("#");
|
||||
#ifndef PDCURSES
|
||||
countwin = newwin(1, 25, winy, winx);
|
||||
#endif /* !PDCURSES */
|
||||
}
|
||||
#ifdef PDCURSES
|
||||
else {
|
||||
curses_destroy_win(countwin);
|
||||
}
|
||||
|
||||
countwin = newwin(1, 25, winy, winx);
|
||||
#endif /* PDCURSES */
|
||||
startx = 0;
|
||||
starty = 0;
|
||||
if (curses_window_has_border(MESSAGE_WIN)) {
|
||||
winx++;
|
||||
winy++;
|
||||
}
|
||||
|
||||
winy += messageh - 1;
|
||||
|
||||
if (countwin == NULL) {
|
||||
#ifndef PDCURSES
|
||||
countwin = newwin(1, 25, winy, winx);
|
||||
#endif /* !PDCURSES */
|
||||
}
|
||||
#ifdef PDCURSES
|
||||
else {
|
||||
curses_destroy_win(countwin);
|
||||
}
|
||||
|
||||
countwin = newwin(1, 25, winy, winx);
|
||||
#endif /* PDCURSES */
|
||||
startx = 0;
|
||||
starty = 0;
|
||||
|
||||
mvwprintw(countwin, starty, startx, "%s", count_text);
|
||||
wrefresh(countwin);
|
||||
}
|
||||
|
||||
@@ -92,9 +92,9 @@ curses_toggle_color_attr(WINDOW * win, int color, int attr, int onoff)
|
||||
}
|
||||
|
||||
/* GUI color disabled */
|
||||
/* if ((!iflags.wc2_guicolor) && (win != mapwin)) {
|
||||
return;
|
||||
} */
|
||||
if ((!iflags.wc2_guicolor) && (win != mapwin)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (color == 0) { /* make black fg visible */
|
||||
# ifdef USE_DARKGRAY
|
||||
@@ -102,7 +102,6 @@ curses_toggle_color_attr(WINDOW * win, int color, int attr, int onoff)
|
||||
if (can_change_color() && (COLORS > 16)) {
|
||||
/* colorpair for black is already darkgray */
|
||||
} else { /* Use bold for a bright black */
|
||||
|
||||
wattron(win, A_BOLD);
|
||||
}
|
||||
} else
|
||||
@@ -188,8 +187,8 @@ curses_get_wid(int type)
|
||||
ret = text_wid;
|
||||
break;
|
||||
default:
|
||||
panic("curses_get_wid: unsupported window type");
|
||||
ret = -1; /* Not reached */
|
||||
impossible("curses_get_wid: unsupported window type");
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
while (curses_window_exists(ret)) {
|
||||
|
||||
+23
-12
@@ -78,9 +78,15 @@ curses_create_window(int width, int height, orient orientation)
|
||||
width += 2; /* leave room for bounding box */
|
||||
height += 2;
|
||||
|
||||
if ((width > term_cols) || (height > term_rows))
|
||||
panic("curses_create_window: Terminal too small for dialog window");
|
||||
if ((width > term_cols) || (height > term_rows)) {
|
||||
impossible("curses_create_window: Terminal too small for dialog window");
|
||||
width = term_cols;
|
||||
height = term_rows;
|
||||
}
|
||||
switch (orientation) {
|
||||
default:
|
||||
impossible("curses_create_window: Bad orientation");
|
||||
/* fall through to centre */
|
||||
case CENTER:
|
||||
startx = (term_cols / 2) - (width / 2);
|
||||
starty = (term_rows / 2) - (height / 2);
|
||||
@@ -119,9 +125,6 @@ curses_create_window(int width, int height, orient orientation)
|
||||
|
||||
starty = 0;
|
||||
break;
|
||||
default:
|
||||
panic("curses_create_window: Bad orientation");
|
||||
break;
|
||||
}
|
||||
|
||||
if (startx < 0) {
|
||||
@@ -190,7 +193,8 @@ WINDOW *
|
||||
curses_get_nhwin(winid wid)
|
||||
{
|
||||
if (!is_main_window(wid)) {
|
||||
panic("curses_get_nhwin: wid out of range. Not a main window.");
|
||||
impossible("curses_get_nhwin: wid %d out of range. Not a main window.", wid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return nhwins[wid].curwin;
|
||||
@@ -208,7 +212,8 @@ curses_add_nhwin(winid wid, int height, int width, int y, int x,
|
||||
int real_height = height;
|
||||
|
||||
if (!is_main_window(wid)) {
|
||||
panic("curses_add_nhwin: wid out of range. Not a main window.");
|
||||
impossible("curses_add_nhwin: wid %d out of range. Not a main window.", wid);
|
||||
return;
|
||||
}
|
||||
|
||||
nhwins[wid].nhwin = wid;
|
||||
@@ -300,7 +305,8 @@ curses_del_nhwin(winid wid)
|
||||
}
|
||||
|
||||
if (!is_main_window(wid)) {
|
||||
panic("curses_del_nhwin: wid out of range. Not a main window.");
|
||||
impossible("curses_del_nhwin: wid %d out of range. Not a main window.", wid);
|
||||
return;
|
||||
}
|
||||
|
||||
nhwins[wid].curwin = NULL;
|
||||
@@ -390,7 +396,10 @@ void
|
||||
curses_get_window_xy(winid wid, int *x, int *y)
|
||||
{
|
||||
if (!is_main_window(wid)) {
|
||||
panic("curses_get_window_xy: wid out of range. Not a main window.");
|
||||
impossible("curses_get_window_xy: wid %d out of range. Not a main window.", wid);
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
*x = nhwins[wid].x;
|
||||
@@ -442,8 +451,9 @@ int
|
||||
curses_get_window_orientation(winid wid)
|
||||
{
|
||||
if (!is_main_window(wid)) {
|
||||
panic
|
||||
("curses_get_window_orientation: wid out of range. Not a main window.");
|
||||
impossible
|
||||
("curses_get_window_orientation: wid %d out of range. Not a main window.", wid);
|
||||
return CENTER;
|
||||
}
|
||||
|
||||
return nhwins[wid].orientation;
|
||||
@@ -480,7 +490,8 @@ curses_puts(winid wid, int attr, const char *text)
|
||||
|
||||
if (curses_is_menu(wid) || curses_is_text(wid)) {
|
||||
if (!curses_menu_exists(wid)) {
|
||||
panic("curses_puts: Attempted write to nonexistant window!");
|
||||
impossible("curses_puts: Attempted write to nonexistant window %d!", wid);
|
||||
return;
|
||||
}
|
||||
identifier = malloc(sizeof (anything));
|
||||
identifier->a_void = NULL;
|
||||
|
||||
Reference in New Issue
Block a user