From 12d6ead7fcbdd139a9a95c32600507ed91dbceb8 Mon Sep 17 00:00:00 2001 From: Mooffie Date: Mon, 24 Apr 2017 08:02:27 +0300 Subject: [PATCH] Ticket #3815: Factor out is_cmdline_mute(). Signed-off-by: Mooffie --- src/filemanager/midnight.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/filemanager/midnight.c b/src/filemanager/midnight.c index 6fd10fd7f..24aec5741 100644 --- a/src/filemanager/midnight.c +++ b/src/filemanager/midnight.c @@ -1400,6 +1400,26 @@ midnight_execute_cmd (Widget * sender, long command) /* --------------------------------------------------------------------------------------------- */ +/** + * Whether the command-line should not respond to key events. + * + * This is TRUE if a QuickView has the focus, as it's going to consume + * some keys and there's no sense in passing to the command-line just + * the leftovers. + */ +static gboolean +is_cmdline_mute (void) +{ + /* When one of panels is other than view_listing, + current_panel points to view_listing panel all time independently of + it's activity. Thus, we can't use get_current_type() here. + current_panel should point to actualy current active panel + independently of it's type. */ + return (current_panel->active == 0 && get_other_type () == view_quick); +} + +/* --------------------------------------------------------------------------------------------- */ + static cb_ret_t midnight_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { @@ -1455,20 +1475,10 @@ midnight_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void if (widget_get_state (WIDGET (the_menubar), WST_FOCUSED)) return MSG_NOT_HANDLED; - if (parm == '\n') + if (parm == '\n' && !is_cmdline_mute ()) { size_t i; - /* HACK: don't execute command in the command line if Enter was pressed - in the quick viewer panel. */ - /* TODO: currently, when one of panels is other than view_listing, - current_panel points to view_listing panel all time independently of - it's activity. Thus, we can't use get_current_type() here. - current_panel should point to actualy current active panel - independently of it's type. */ - if (current_panel->active == 0 && get_other_type () == view_quick) - return MSG_NOT_HANDLED; - for (i = 0; cmdline->buffer[i] != '\0' && whitespace (cmdline->buffer[i]); i++) ; -- 2.11.4.GIT