diff options
Diffstat (limited to 'treeview.c')
| -rw-r--r-- | treeview.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/treeview.c b/treeview.c index 934761ee2049..9853a16f539a 100644 --- a/treeview.c +++ b/treeview.c @@ -1,9 +1,9 @@ /* - * $Id: treeview.c,v 1.32 2018/06/19 22:57:01 tom Exp $ + * $Id: treeview.c,v 1.43 2020/11/23 00:38:31 tom Exp $ * * treeview.c -- implements the treeview dialog * - * Copyright 2012-2016,2018 Thomas E. Dickey + * Copyright 2012-2019,2020 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 License, version 2.1 @@ -21,7 +21,7 @@ * Boston, MA 02110, USA. */ -#include <dialog.h> +#include <dlg_internals.h> #include <dlg_keys.h> #define INDENT 3 @@ -196,12 +196,11 @@ dlg_treeview(const char *title, #endif ALL_DATA all; int i, j, key2, found, x, y, cur_y, box_x, box_y; - int key = 0, fkey; + int key, fkey; int button = dialog_state.visit_items ? -1 : dlg_default_button(); int choice = dlg_default_listitem(items); int scrollamt = 0; int max_choice; - int was_mouse; int use_height; int use_width, name_width, text_width, tree_width; int result = DLG_EXIT_UNKNOWN; @@ -291,8 +290,7 @@ dlg_treeview(const char *title, * After displaying the prompt, we know how much space we really have. * Limit the list to avoid overwriting the ok-button. */ - if (use_height + MIN_HIGH > height - cur_y) - use_height = height - MIN_HIGH - cur_y; + use_height = height - MIN_HIGH - cur_y; if (use_height <= 0) use_height = 1; @@ -357,13 +355,18 @@ dlg_treeview(const char *title, dlg_draw_buttons(dialog, height - 2, 0, buttons, button, FALSE, width); dlg_trace_win(dialog); + while (result == DLG_EXIT_UNKNOWN) { + int was_mouse; + if (button < 0) /* --visit-items */ wmove(dialog, box_y + choice + 1, box_x + all.check_x + 2); key = dlg_mouse_wgetch(dialog, &fkey); - if (dlg_result_key(key, fkey, &result)) - break; + if (dlg_result_key(key, fkey, &result)) { + if (!dlg_button_key(result, &button, &key, &fkey)) + break; + } was_mouse = (fkey && is_DLGK_MOUSE(key)); if (was_mouse) @@ -520,6 +523,9 @@ dlg_treeview(const char *title, case DLGK_ENTER: result = dlg_enter_buttoncode(button); break; + case DLGK_LEAVE: + result = dlg_ok_buttoncode(button); + break; case DLGK_FIELD_PREV: button = dlg_prev_button(buttons, button); dlg_draw_buttons(dialog, height - 2, 0, buttons, button, @@ -537,10 +543,7 @@ dlg_treeview(const char *title, height = old_height; width = old_width; /* repaint */ - dlg_clear(); - dlg_del_window(dialog); - refresh(); - dlg_mouse_free_regions(); + _dlg_resize_cleanup(dialog); goto retry; #endif default: @@ -552,7 +555,7 @@ dlg_treeview(const char *title, beep(); } } - } else { + } else if (key > 0) { beep(); } } @@ -649,12 +652,11 @@ dialog_treeview(const char *title, if (show_status) { for (i = 0; i < item_no; i++) { if (listitems[i].state) { + if (dlg_need_separator()) + dlg_add_separator(); if (dialog_vars.separate_output) { dlg_add_string(listitems[i].name); - dlg_add_separator(); } else { - if (dlg_need_separator()) - dlg_add_separator(); if (flag == FLAG_CHECK) dlg_add_quoted(listitems[i].name); else @@ -662,7 +664,7 @@ dialog_treeview(const char *title, } } } - dlg_add_last_key(-1); + AddLastKey(); } dlg_free_columns(&listitems[0].text, (int) sizeof(DIALOG_LISTITEM), item_no); |
