Fixes of button bar handling.

Implemented handling of mouse actions in button bar.
Fixed vertical size of Diff Viewer widget.
DiffHelp action was added. F1 button was assigned for it.
Fixed some key bindings.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2010-04-08 11:15:19 +04:00 committed by Ilia Maslakov
parent 3f11aecb74
commit f356d83972
5 changed files with 33 additions and 22 deletions

View File

@ -392,6 +392,7 @@ DiffPageDown = pgdn
DiffPageUp = pgup
DiffHome = home
DiffEnd = end
DiffQuit = q; shift-q; ctrl-g; esc
DiffHelp = f1
DiffQuit = f10; q; shift-q; ctrl-g; esc
ShowCommandLine = ctrl-o
SelectCodepage = alt-e

View File

@ -397,6 +397,7 @@ DiffPageDown = pgdn
DiffPageUp = pgup
DiffHome = home
DiffEnd = end
DiffQuit = q; shift-q; ctrl-g; esc
DiffHelp = f1
DiffQuit = f10; q; shift-q; ctrl-g; esc
ShowCommandLine = ctrl-o
SelectCodepage = alt-e

View File

@ -443,6 +443,7 @@
#define CK_DiffHome 9031
#define CK_DiffEnd 9032
#define CK_DiffQuit 9033
#define CK_DiffHelp 9034
/*
Process a block through a shell command: CK_Pipe_Block(i) executes shell_cmd[i].

View File

@ -2953,6 +2953,9 @@ dview_execute_cmd (WDiff * dview, unsigned long command)
switch (command)
{
case CK_DiffHelp:
interactive_display (NULL, "[Diff Viewer]");
break;
case CK_DiffDisplaySymbols:
dview->display_symbols ^= 1;
dview->new_frame = 1;
@ -3117,28 +3120,21 @@ dview_callback (Widget * w, widget_msg_t msg, int parm)
dview_update (dview);
return MSG_HANDLED;
case WIDGET_CURSOR:
return MSG_HANDLED;
case WIDGET_KEY:
i = dview_handle_key (dview, parm);
if (dview->view_quit)
dlg_stop (h);
else
{
dview_update (dview);
}
return i;
case WIDGET_IDLE:
return MSG_HANDLED;
case WIDGET_FOCUS:
dview_labels (dview);
return MSG_HANDLED;
case WIDGET_DESTROY:
return MSG_HANDLED;
case WIDGET_COMMAND:
i = dview_execute_cmd (dview, parm);
if (dview->view_quit)
dlg_stop (h);
else
dview_update (dview);
return i;
default:
return default_proc (msg, parm);
@ -3156,7 +3152,7 @@ dview_adjust_size (Dlg_head * h)
/* Look up the viewer and the buttonbar, we assume only two widgets here */
dview = (WDiff *) find_widget_type (h, dview_callback);
bar = find_buttonbar (h);
widget_set_size (&dview->widget, 0, 0, LINES, COLS);
widget_set_size (&dview->widget, 0, 0, LINES - 1, COLS);
widget_set_size ((Widget *) bar, LINES - 1, 0, 1, COLS);
dview_compute_areas (dview);
@ -3167,12 +3163,18 @@ dview_adjust_size (Dlg_head * h)
static cb_ret_t
dview_dialog_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
{
WDiff *dview = (WDiff *) data;
switch (msg)
{
case DLG_RESIZE:
dview_adjust_size (h);
return MSG_HANDLED;
case DLG_ACTION:
/* command from buttonbar */
return send_message ((Widget *) dview, WIDGET_COMMAND, parm);
default:
return default_dlg_callback (h, sender, msg, parm, data);
}
@ -3196,15 +3198,15 @@ diff_view (const char *file1, const char *file2, const char *label1, const char
dview = g_new0 (WDiff, 1);
init_widget (&dview->widget, 0, 0, LINES, COLS,
init_widget (&dview->widget, 0, 0, LINES - 1, COLS,
(callback_fn) dview_callback, (mouse_h) dview_event);
widget_want_cursor (dview->widget, 0);
bar = buttonbar_new (1);
add_widget (dview_dlg, bar);
add_widget (dview_dlg, dview);
add_widget (dview_dlg, bar);
error = dview_init (dview, "-a", file1, file2, label1, label2, DATA_SRC_MEM); /* XXX binary diff? */

View File

@ -479,6 +479,7 @@ static name_keymap_t command_names[] = {
{ "DiffHome", CK_DiffHome},
{ "DiffEnd", CK_DiffEnd},
{ "DiffQuit", CK_DiffQuit},
{ "DiffHelp", CK_DiffHelp},
{ "SelectCodepage", CK_SelectCodepage},
{ NULL, CK_Ignore_Key }
@ -966,9 +967,6 @@ const global_keymap_t default_diff_keymap[] = {
{ 'p', CK_DiffPrevHunk, "p" },
{ 'g', CK_DiffGoto, "g" },
{ 'G', CK_DiffGoto, "G" },
{ KEY_F (4), CK_DiffEditCurrent, "F4" },
{ KEY_F (14), CK_DiffEditOther, "S-F4" },
{ KEY_F (17), CK_DiffSearch, "S-F7" },
{ KEY_M_CTRL | KEY_HOME, CK_DiffBOF, "C-Home" },
{ KEY_M_CTRL | KEY_END, CK_DiffEOF, "C-End" },
{ KEY_DOWN, CK_DiffDown, "Down" },
@ -985,6 +983,14 @@ const global_keymap_t default_diff_keymap[] = {
{ 'Q', CK_DiffQuit, "Q" },
{ XCTRL ('g'), CK_DiffQuit, "C-g" },
{ ESC_CHAR, CK_DiffQuit, "Esc" },
{ KEY_F (1), CK_DiffHelp, "F1" },
{ KEY_F (4), CK_DiffEditCurrent, "F4" },
{ KEY_F (7), CK_DiffSearch, "F7" },
{ KEY_F (10), CK_DiffQuit, "F10" },
{ KEY_F (14), CK_DiffEditOther, "S-F4" },
{ 0, CK_Ignore_Key, "" }
};
static int