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;
}
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;
{
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++;
*_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;
}
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;
}
/* Reset items to unselected to clear out selections from previous
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;
}
if (count != num_chosen) {
- panic("curses_display_nhmenu: Selected items less than "
+ impossible("curses_display_nhmenu: Selected items less than "
"expected number");
}
}
}
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);
}
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) {
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)) {
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);
starty = 0;
break;
- default:
- panic("curses_create_window: Bad orientation");
- break;
}
if (startx < 0) {
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;
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;
}
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;
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;
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;
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;