diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2018-10-20 20:32:57 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2018-10-20 20:32:57 +0000 |
commit | 4dccdce4191d6e2bc3ba9f782b0fe1aa46b743e3 (patch) | |
tree | 3f3f729ef0455b62fba0c60263ba2c0180f4b4ec /menubox.c | |
parent | 42c10d5d7d5ba2fde22838d594f29d2f73b3ead2 (diff) |
Notes
Diffstat (limited to 'menubox.c')
-rw-r--r-- | menubox.c | 55 |
1 files changed, 39 insertions, 16 deletions
diff --git a/menubox.c b/menubox.c index 518393e7397a..abbe11c23362 100644 --- a/menubox.c +++ b/menubox.c @@ -1,9 +1,9 @@ /* - * $Id: menubox.c,v 1.148 2013/09/02 17:15:13 tom Exp $ + * $Id: menubox.c,v 1.159 2018/06/21 23:28:56 tom Exp $ * * menubox.c -- implements the menu box * - * Copyright 2000-2012,2013 Thomas E. Dickey + * Copyright 2000-2016,2018 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public Licens, version 2.1e @@ -95,13 +95,13 @@ print_item(ALL_DATA * data, /* Clear 'residue' of last item and mark current current item */ if (is_inputmenu) { - (void) wattrset(win, (selected != Unselected) ? item_selected_attr : item_attr); + dlg_attrset(win, (selected != Unselected) ? item_selected_attr : item_attr); for (n = my_y - 1; n < my_y + INPUT_ROWS - 1; n++) { wmove(win, n, 0); wprintw(win, "%*s", my_width, " "); } } else { - (void) wattrset(win, menubox_attr); + dlg_attrset(win, menubox_attr); wmove(win, my_y, 0); wprintw(win, "%*s", my_width, " "); } @@ -131,7 +131,7 @@ print_item(ALL_DATA * data, if (selected) { dlg_item_help(item->help); } - (void) wattrset(win, save); + dlg_attrset(win, save); } /* @@ -147,7 +147,7 @@ input_menu_edit(ALL_DATA * data, char *result; int offset = 0; int key = 0, fkey = 0; - int first = TRUE; + bool first = TRUE; /* see above */ bool is_inputmenu = TRUE; int y = ItemToRow(choice); @@ -182,7 +182,7 @@ input_menu_edit(ALL_DATA * data, } } print_item(data, data->menu, items, choice, Selected, TRUE); - (void) wattrset(data->menu, save); + dlg_attrset(data->menu, save); *resultp = result; return code; @@ -245,7 +245,7 @@ print_menu(ALL_DATA * data, int choice, int scrollamt, int max_choice, bool is_i if (is_inputmenu) { int spare_lines, x_count; spare_lines = data->menu_height % INPUT_ROWS; - (void) wattrset(data->menu, menubox_attr); + dlg_attrset(data->menu, menubox_attr); for (; spare_lines; spare_lines--) { wmove(data->menu, data->menu_height - spare_lines, 0); for (x_count = 0; x_count < data->menu_width; @@ -304,7 +304,7 @@ dlg_menu(const char *title, static DLG_KEYS_BINDING binding[] = { HELPKEY_BINDINGS, ENTERKEY_BINDINGS, - DLG_KEYS_DATA( DLGK_FIELD_NEXT, ' ' ), + TOGGLEKEY_BINDINGS, DLG_KEYS_DATA( DLGK_FIELD_NEXT, KEY_RIGHT ), DLG_KEYS_DATA( DLGK_FIELD_NEXT, TAB ), DLG_KEYS_DATA( DLGK_FIELD_PREV, KEY_BTAB ), @@ -331,6 +331,8 @@ dlg_menu(const char *title, /* *INDENT-ON* */ #ifdef KEY_RESIZE + int old_LINES = LINES; + int old_COLS = COLS; int old_height = height; int old_width = width; #endif @@ -345,21 +347,36 @@ dlg_menu(const char *title, int found; int use_width, name_width, text_width, list_width; WINDOW *dialog, *menu; - char *prompt = dlg_strclone(cprompt); + char *prompt = 0; const char **buttons = dlg_ok_labels(); bool is_inputmenu = ((rename_menutext != 0) && (rename_menutext != dlg_dummy_menutext)); + DLG_TRACE(("# menubox args:\n")); + DLG_TRACE2S("title", title); + DLG_TRACE2S("message", cprompt); + DLG_TRACE2N("height", height); + DLG_TRACE2N("width", width); + DLG_TRACE2N("lheight", menu_height); + DLG_TRACE2N("llength", item_no); + /* FIXME dump the items[][] too */ + DLG_TRACE2N("current", *current_item); + DLG_TRACE2N("rename", rename_menutext != 0); + + dialog_state.plain_buttons = TRUE; + all.items = items; all.item_no = item_no; dlg_does_output(); - dlg_tab_correct_str(prompt); #ifdef KEY_RESIZE retry: #endif + prompt = dlg_strclone(cprompt); + dlg_tab_correct_str(prompt); + all.menu_height = menu_height; use_width = dlg_calc_list_width(item_no, items) + 10; use_width = MAX(26, use_width); @@ -391,7 +408,7 @@ dlg_menu(const char *title, dlg_draw_bottom_box2(dialog, border_attr, border2_attr, dialog_attr); dlg_draw_title(dialog, title); - (void) wattrset(dialog, dialog_attr); + dlg_attrset(dialog, dialog_attr); dlg_print_autowrap(dialog, prompt, height, width); all.menu_width = width - 6; @@ -642,6 +659,7 @@ dlg_menu(const char *title, dlg_draw_buttons(dialog, height - 2, 0, buttons, button, FALSE, width); break; + case DLGK_TOGGLE: case DLGK_ENTER: if (is_inputmenu) result = dlg_ok_buttoncode(button); @@ -703,14 +721,19 @@ dlg_menu(const char *title, break; #ifdef KEY_RESIZE case KEY_RESIZE: + dlg_will_resize(dialog); /* reset data */ - height = old_height; - width = old_width; - /* repaint */ +#define resizeit(name, NAME) \ + name = ((NAME >= old_##NAME) \ + ? (NAME - (old_##NAME - old_##name)) \ + : old_##name) + resizeit(height, LINES); + resizeit(width, COLS); + free(prompt); dlg_clear(); dlg_del_window(dialog); - refresh(); dlg_mouse_free_regions(); + /* repaint */ goto retry; #endif default: |