From bac7bdf2930ece0b8d9676ad643afacceb0eb84a Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Fri, 25 Sep 2009 20:39:06 +0400 Subject: [PATCH] Added new WIDGET_COMMAND message. Handle WIDGET_COMMAND message in WInput widget. Use this message to show the command line history. Signed-off-by: Andrew Borodin --- src/cmd.c | 10 +++++----- src/dialog.h | 1 + src/widget.c | 17 ++++++++++++----- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/cmd.c b/src/cmd.c index d3fd807a1..58a22dfaa 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -51,9 +51,10 @@ #include "../src/tty/key.h" /* ALT() macro */ #include "../src/tty/win.h" /* do_enter_ca_mode() */ -#include "../src/search/search.h" - #include "../src/mcconfig/mcconfig.h" +#include "../src/search/search.h" +#include "../src/viewer/mcviewer.h" +#include "../src/filehighlight/fhl.h" /* MC_FHL_INI_FILE */ #include "cmd.h" /* Our definitions */ #include "fileopctx.h" @@ -79,8 +80,7 @@ #include "history.h" #include "strutil.h" #include "dir.h" -#include "../src/viewer/mcviewer.h" -#include "../src/filehighlight/fhl.h" /* MC_FHL_INI_FILE */ +#include "cmddef.h" /* CK_InputHistoryShow */ #ifndef MAP_FILE # define MAP_FILE 0 @@ -888,7 +888,7 @@ void history_cmd (void) { /* show the history of command line widget */ - send_message (&cmdline->widget, WIDGET_KEY, ALT ('h')); + send_message (&cmdline->widget, WIDGET_COMMAND, CK_InputHistoryShow); } void swap_cmd (void) diff --git a/src/dialog.h b/src/dialog.h index 4cb2bda70..79ab902fb 100644 --- a/src/dialog.h +++ b/src/dialog.h @@ -41,6 +41,7 @@ typedef enum { WIDGET_DRAW, /* Sent to widget to draw themselves */ WIDGET_KEY, /* Sent to widgets on key press */ WIDGET_HOTKEY, /* Sent to widget to catch preprocess key */ + WIDGET_COMMAND, /* Send to widget to handle command */ WIDGET_DESTROY, /* Sent to widget at destruction time */ WIDGET_CURSOR, /* Sent to widget to position the cursor */ WIDGET_IDLE, /* Sent to widgets with options & W_WANT_IDLE*/ diff --git a/src/widget.c b/src/widget.c index 7ce5aa2c4..c577dc80d 100644 --- a/src/widget.c +++ b/src/widget.c @@ -1726,10 +1726,10 @@ port_region_marked_for_delete (WInput *in) in->charpoint = 0; } -static void -input_execute_cmd (WInput *in, int command, int key) +static cb_ret_t +input_execute_cmd (WInput *in, int command) { - (void) key; + cb_ret_t res = MSG_HANDLED; switch (command) { case CK_InputBol: @@ -1801,7 +1801,11 @@ input_execute_cmd (WInput *in, int command, int key) case CK_InputComplete: complete (in); break; + default: + res = MSG_NOT_HANDLED; } + + return res; } /* This function is a test for a special input key used in complete.c */ @@ -1814,7 +1818,7 @@ is_in_input_map (WInput *in, int key) for (i = 0; input_map[i].key; i++) { if (key == input_map[i].key) { - input_execute_cmd (in, input_map[i].command, key); + input_execute_cmd (in, input_map[i].command); if (input_map[i].command == CK_InputComplete) return 2; else @@ -1844,7 +1848,7 @@ handle_char (WInput *in, int key) if (key == input_map[i].key) { if (input_map[i].command != CK_InputComplete) { free_completions (in); - input_execute_cmd (in, input_map[i].command, key); + input_execute_cmd (in, input_map[i].command); update_input (in, 1); v = MSG_HANDLED; break; @@ -1920,6 +1924,9 @@ input_callback (Widget *w, widget_msg_t msg, int parm) return handle_char (in, parm); + case WIDGET_COMMAND: + return input_execute_cmd (in, parm); + case WIDGET_FOCUS: case WIDGET_UNFOCUS: case WIDGET_DRAW: -- 2.11.4.GIT