mirror of https://github.com/MidnightCommander/mc
added new keybindings (F3, F4) in history list.
Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
This commit is contained in:
parent
3e7b2c49dc
commit
87428aa8ea
|
@ -57,6 +57,9 @@ int num_history_items_recorded = 60;
|
|||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
#define B_VIEW (B_USER + 1)
|
||||
#define B_EDIT (B_USER + 2)
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
typedef struct
|
||||
|
@ -114,6 +117,28 @@ history_dlg_reposition (WDialog * dlg_head)
|
|||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static inline cb_ret_t
|
||||
history_handle_key (WDialog * h, int key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case KEY_F (3):
|
||||
h->ret_value = B_VIEW;
|
||||
dlg_stop (h);
|
||||
return MSG_HANDLED;
|
||||
|
||||
case KEY_F (4):
|
||||
h->ret_value = B_EDIT;
|
||||
dlg_stop (h);
|
||||
return MSG_HANDLED;
|
||||
|
||||
default:
|
||||
return MSG_NOT_HANDLED;
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static cb_ret_t
|
||||
history_dlg_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
|
@ -122,6 +147,9 @@ history_dlg_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, v
|
|||
case MSG_RESIZE:
|
||||
return history_dlg_reposition (DIALOG (w));
|
||||
|
||||
case MSG_UNHANDLED_KEY:
|
||||
return history_handle_key (DIALOG (w), parm);
|
||||
|
||||
default:
|
||||
return dlg_default_callback (w, sender, msg, parm, data);
|
||||
}
|
||||
|
@ -285,7 +313,7 @@ history_save (mc_config_t * cfg, const char *name, GList * h)
|
|||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
char *
|
||||
history_show (GList ** history, Widget * widget, int current)
|
||||
history_show (GList ** history, Widget * widget, int current, int *action)
|
||||
{
|
||||
GList *z, *hlist = NULL, *hi;
|
||||
size_t maxlen, count = 0;
|
||||
|
@ -293,6 +321,7 @@ history_show (GList ** history, Widget * widget, int current)
|
|||
WDialog *query_dlg;
|
||||
WListbox *query_list;
|
||||
history_dlg_data hist_data;
|
||||
int dlg_ret;
|
||||
|
||||
if (*history == NULL)
|
||||
return NULL;
|
||||
|
@ -356,10 +385,26 @@ history_show (GList ** history, Widget * widget, int current)
|
|||
listbox_select_entry (query_list, current);
|
||||
}
|
||||
|
||||
if (dlg_run (query_dlg) != B_CANCEL)
|
||||
dlg_ret = dlg_run (query_dlg);
|
||||
if (dlg_ret != B_CANCEL)
|
||||
{
|
||||
char *q;
|
||||
|
||||
if (action != NULL)
|
||||
{
|
||||
switch (dlg_ret)
|
||||
{
|
||||
case B_EDIT:
|
||||
*action = CK_Edit;
|
||||
break;
|
||||
case B_VIEW:
|
||||
*action = CK_View;
|
||||
break;
|
||||
default:
|
||||
*action = CK_CdChild;
|
||||
}
|
||||
}
|
||||
|
||||
listbox_get_current (query_list, &q, NULL);
|
||||
r = g_strdup (q);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ GList *history_load (mc_config_t * cfg, const char *name);
|
|||
void history_save (mc_config_t * cfg, const char *name, GList * h);
|
||||
/* for repositioning of history dialog we should pass widget to this
|
||||
* function, as position of history dialog depends on widget's position */
|
||||
char *history_show (GList ** history, Widget * widget, int current);
|
||||
char *history_show (GList ** history, Widget * widget, int current, int *action);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ do_show_hist (WInput * in)
|
|||
len = get_history_length (in->history.list);
|
||||
|
||||
r = history_show (&in->history.list, WIDGET (in),
|
||||
g_list_position (in->history.list, in->history.list));
|
||||
g_list_position (in->history.list, in->history.list), NULL);
|
||||
if (r != NULL)
|
||||
{
|
||||
input_assign_text (in, r);
|
||||
|
|
|
@ -1014,6 +1014,7 @@ show_editor_history_list (void)
|
|||
GList *file_list = NULL;
|
||||
char *s;
|
||||
WPanel *panel = current_panel;
|
||||
int act;
|
||||
|
||||
/* open file with positions */
|
||||
fn = mc_config_get_full_path (MC_FILEPOS_FILE);
|
||||
|
@ -1035,15 +1036,37 @@ show_editor_history_list (void)
|
|||
fclose (f);
|
||||
|
||||
file_list = g_list_last (file_list);
|
||||
s = history_show (&file_list, WIDGET (panel));
|
||||
s = history_show (&file_list, WIDGET (panel), 0, &act);
|
||||
|
||||
if (s != NULL)
|
||||
{
|
||||
vfs_path_t *s_vpath;
|
||||
|
||||
s_vpath = vfs_path_from_str (s);
|
||||
switch (act)
|
||||
{
|
||||
case CK_Edit:
|
||||
s_vpath = vfs_path_from_str (s);
|
||||
edit_file_at_line (s_vpath, use_internal_edit, 0);
|
||||
break;
|
||||
|
||||
case CK_View:
|
||||
s_vpath = vfs_path_from_str (s);
|
||||
view_file (s_vpath, use_internal_view, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
char *d;
|
||||
|
||||
d = g_path_get_dirname (s);
|
||||
s_vpath = vfs_path_from_str (d);
|
||||
do_cd (s_vpath, cd_exact);
|
||||
try_to_select (current_panel, s);
|
||||
g_free (d);
|
||||
}
|
||||
}
|
||||
|
||||
g_free (s);
|
||||
do_edit_at_line (s_vpath, use_internal_edit, 0);
|
||||
vfs_path_free (s_vpath);
|
||||
}
|
||||
|
||||
|
|
|
@ -3355,7 +3355,7 @@ directory_history_list (WPanel * panel)
|
|||
|
||||
pos = g_list_position (panel->dir_history_current, panel->dir_history);
|
||||
|
||||
s = history_show (&panel->dir_history, WIDGET (panel), pos);
|
||||
s = history_show (&panel->dir_history, WIDGET (panel), pos, NULL);
|
||||
if (s != NULL)
|
||||
{
|
||||
vfs_path_t *s_vpath;
|
||||
|
|
Loading…
Reference in New Issue