From 330017a99cd7619c9eb1fe5fccbb02f5d9e7f6c5 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Mon, 11 Jun 2018 13:33:47 +0200 Subject: menuconfig: Support viewing symbol info from within the jump-to dialog Ctrl-F (Ctrl-H clashes with backspace) brings up the information dialog for the selected item in the jump-to dialog. Since it's now possible to jump directly from the information dialog to the jump-to dialog and vice versa, recursive invocation becomes possible. Work around it with a flag to _info_dialog() that makes '/' return if the information dialog was launched from within the jump-to dialog. (Recursive invocations work code-wise, but act in a confusing way.) --- menuconfig.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/menuconfig.py b/menuconfig.py index 83fd9eb..7d6a064 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -150,7 +150,8 @@ _JUMP_TO_HELP_LINES = """ Type text to narrow the search. Regexes are supported (via Python's 're' module). The up/down cursor keys step in the list. [Enter] jumps to the selected symbol. [ESC] aborts the search. Type multiple space-separated -strings/regexes to find entries that match all of them. +strings/regexes to find entries that match all of them. Type Ctrl-F to +view the help of the selected item without leaving the dialog. """[1:-1].split("\n") def _init_styles(): @@ -504,7 +505,7 @@ def _menuconfig(stdscr): _resize_main() elif c == "?": - _info_dialog(_shown[_sel_node_i]) + _info_dialog(_shown[_sel_node_i], False) # The terminal might have been resized while the fullscreen info # dialog was open _resize_main() @@ -1546,6 +1547,15 @@ def _jump_to_dialog(): edit_box, matches_win, bot_sep_win, help_win, sel_node_i, scroll) + elif c == "\x06": # \x06 = Ctrl-F + _safe_curs_set(0) + _info_dialog(matches[sel_node_i], True) + _safe_curs_set(1) + + scroll = _resize_jump_to_dialog( + edit_box, matches_win, bot_sep_win, help_win, + sel_node_i, scroll) + elif c == curses.KEY_DOWN: select_next_match() @@ -1704,8 +1714,13 @@ def _draw_jump_to_dialog(edit_box, matches_win, bot_sep_win, help_win, edit_box.noutrefresh() -def _info_dialog(node): - # Shows a fullscreen window with information about 'node' +def _info_dialog(node, from_jump_to_dialog): + # Shows a fullscreen window with information about 'node'. + # + # If 'from_jump_to_dialog' is True, the information dialog was opened from + # within the jump-to-dialog. In this case, we make '/' from within the + # information dialog just return, to avoid a confusing recursive invocation + # of the jump-to-dialog. # Top row, with title and arrows point up top_line_win = _styled_win(_SEPARATOR_STYLE) @@ -1764,6 +1779,10 @@ def _info_dialog(node): elif c == "/": # Support starting a search from within the information dialog + if from_jump_to_dialog: + # Avoid recursion + return + if _jump_to_dialog(): # Jumped to a symbol. Cancel the information dialog. return -- cgit v1.2.3