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 <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2009-09-25 20:39:06 +04:00 committed by Ilia Maslakov
parent 100a8d02ae
commit bac7bdf293
3 changed files with 18 additions and 10 deletions

View File

@ -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)

View File

@ -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*/

View File

@ -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: