From 4af3e0c5a96567d476570924a76527f82156ff6c Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Mon, 11 Jun 2018 13:04:40 +0200 Subject: menuconfig: Support starting a search from the info dialog It's annoying to have to leave the information dialog just to do a search related to something you saw in the information dialog. Stay in the information dialog if the search is canceled. --- menuconfig.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/menuconfig.py b/menuconfig.py index be65e98..83fd9eb 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -1406,6 +1406,12 @@ def _draw_frame(win, title): win.attroff(_DIALOG_FRAME_STYLE) def _jump_to_dialog(): + # Implements the jump-to dialog, where symbols can be looked up via + # incremental search and jumped to. + # + # Returns True if the user jumped to a symbol, and False if the dialog was + # canceled. + # Search text s = "" # Previous search text @@ -1525,11 +1531,11 @@ def _jump_to_dialog(): if matches: _jump_to(matches[sel_node_i]) _safe_curs_set(0) - return + return True if c == "\x1B": # \x1B = ESC _safe_curs_set(0) - return + return False if c == curses.KEY_RESIZE: @@ -1755,6 +1761,18 @@ def _info_dialog(node): if scroll > 0: scroll -= 1 + elif c == "/": + # Support starting a search from within the information dialog + + if _jump_to_dialog(): + # Jumped to a symbol. Cancel the information dialog. + return + + # Stay in the information dialog if the jump-to dialog was + # canceled. Resize it in case the terminal was resized while the + # fullscreen jump-to dialog was open. + _resize_info_dialog(top_line_win, text_win, bot_sep_win, help_win) + elif c in (curses.KEY_LEFT, curses.KEY_BACKSPACE, _ERASE_CHAR, "\x1B", # \x1B = ESC "q", "Q", "h", "H"): -- cgit v1.2.3