mcviewer: support file history.

This commit is contained in:
Andrew Borodin 2019-07-14 17:07:36 +03:00
parent 0f02d49b0d
commit f0c9e50f80
4 changed files with 34 additions and 0 deletions

View File

@ -405,6 +405,7 @@ FilePrev = ctrl-b
SelectCodepage = alt-e
Shell = ctrl-o
Ruler = alt-r
History = alt-shift-e
[viewer:hex]
Help = f1
@ -433,6 +434,7 @@ PageDown = pgdn; ctrl-v
PageUp = pgup; alt-v
Top = ctrl-home; ctrl-pgup; a1; alt-lt; g
Bottom = ctrl-end; ctrl-pgdn; c1; alt-gt; shift-g
History = alt-shift-e
[diffviewer]
ShowSymbols = alt-s; s

View File

@ -407,6 +407,7 @@ FilePrev = ctrl-b
SelectCodepage = alt-e
Shell = ctrl-o
Ruler = alt-r
History = alt-shift-e
[viewer:hex]
Help = f1
@ -435,6 +436,7 @@ PageDown = pgdn; ctrl-v
PageUp = pgup; alt-v
Top = ctrl-home; ctrl-pgup; a1; alt-lt; g
Bottom = ctrl-end; ctrl-pgdn; c1; alt-gt; shift-g
History = alt-shift-e
[diffviewer]
ShowSymbols = alt-s; s

View File

@ -490,6 +490,7 @@ static const global_keymap_ini_t default_viewer_keymap[] = {
{"SearchForwardContinue", "ctrl-s"},
{"SearchBackwardContinue", "ctrl-r"},
{"SearchOppositeContinue", "shift-n"},
{"History", "alt-shift-e"},
{NULL, NULL}
};
@ -525,6 +526,7 @@ static const global_keymap_ini_t default_viewer_hex_keymap[] = {
{"SearchForwardContinue", "ctrl-s"},
{"SearchBackwardContinue", "ctrl-r"},
{"SearchOppositeContinue", "shift-n"},
{"History", "alt-shift-e"},
{NULL, NULL}
};

View File

@ -65,6 +65,7 @@
#include "src/filemanager/ext.h" /* regex_command_for() */
#include "src/history.h"
#include "src/file_history.h" /* show_file_history() */
#include "src/execute.h"
#include "src/keybind-defaults.h"
@ -381,6 +382,30 @@ mcview_load_next_prev (WView * view, int direction)
/* --------------------------------------------------------------------------------------------- */
static void
mcview_load_file_from_history (WView * view)
{
char *filename;
int action;
filename = show_file_history (CONST_WIDGET (view), &action);
if (filename != NULL && (action == CK_View || action == CK_Enter))
{
mcview_done (view);
mcview_init (view);
mcview_load (view, NULL, filename, 0, 0, 0);
view->dpy_bbar_dirty = FALSE; /* FIXME */
view->dirty++;
}
g_free (filename);
}
/* --------------------------------------------------------------------------------------------- */
static cb_ret_t
mcview_execute_cmd (WView * view, long command)
{
@ -538,6 +563,9 @@ mcview_execute_cmd (WView * view, long command)
if (!mcview_is_in_panel (view))
mcview_load_next_prev (view, command == CK_FileNext ? 1 : -1);
break;
case CK_History:
mcview_load_file_from_history (view);
break;
case CK_Quit:
if (!mcview_is_in_panel (view))
dlg_stop (WIDGET (view)->owner);