/* * Remove the bindings for a given window. */ void dlg_unregister_window(WINDOW *win) { LIST_BINDINGS *p, *q; for (p = all_bindings, q = 0; p != 0; p = p->link) { if (p->win == win) { if (q != 0) { q->link = p->link; } else { all_bindings = p->link; } /* the user-defined and buttons-bindings all are length=1 */ if (p->binding[1].is_function_key < 0) free(p->binding); free(p); dlg_unregister_window(win); break; } q = p; } }
static int pause_for_ok(WINDOW *dialog, int height, int width) { /* *INDENT-OFF* */ static DLG_KEYS_BINDING binding[] = { HELPKEY_BINDINGS, ENTERKEY_BINDINGS, TRAVERSE_BINDINGS, END_KEYS_BINDING }; /* *INDENT-ON* */ int button; int key = 0, fkey; int result = DLG_EXIT_UNKNOWN; const char **buttons = dlg_ok_label(); int check; int save_nocancel = dialog_vars.nocancel; bool redraw = TRUE; dialog_vars.nocancel = TRUE; button = dlg_default_button(); dlg_register_window(dialog, "progressbox", binding); dlg_register_buttons(dialog, "progressbox", buttons); dlg_draw_bottom_box2(dialog, border_attr, border2_attr, dialog_attr); mouse_mkbutton(height - 2, width / 2 - 4, 6, '\n'); while (result == DLG_EXIT_UNKNOWN) { if (redraw) { redraw = FALSE; if (button < 0) button = 0; dlg_draw_buttons(dialog, height - 2, 0, buttons, button, FALSE, width); } key = dlg_mouse_wgetch(dialog, &fkey); if (dlg_result_key(key, fkey, &result)) break; if (!fkey && (check = dlg_char_to_button(key, buttons)) >= 0) { result = dlg_ok_buttoncode(check); break; } if (fkey) { switch (key) { case DLGK_FIELD_NEXT: button = dlg_next_button(buttons, button); redraw = TRUE; break; case DLGK_FIELD_PREV: button = dlg_prev_button(buttons, button); redraw = TRUE; break; case DLGK_ENTER: result = dlg_ok_buttoncode(button); break; default: if (is_DLGK_MOUSE(key)) { result = dlg_ok_buttoncode(key - M_EVENT); if (result < 0) result = DLG_EXIT_OK; } else { beep(); } break; } } else { beep(); } } dlg_unregister_window(dialog); dialog_vars.nocancel = save_nocancel; return result; }