Ticket #2375 (do cd .. if command line is empty)

New keybinding "PanelSmartJumpUp" for the jump to the parent directory if command line is empty. Not defined by default.
    This binding maybe used for bind 'Backspace' as hotkey for 'cd ..' (only if command line is empty).

Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
This commit is contained in:
Ilia Maslakov 2010-11-21 22:00:09 +00:00
parent 2bff7b9d80
commit 2690d2d9f5
5 changed files with 22 additions and 1 deletions

View File

@ -431,6 +431,7 @@ static name_keymap_t command_names[] = {
{"PanelSortOrderByExt", CK_PanelSortOrderByExt},
{"PanelSortOrderBySize", CK_PanelSortOrderBySize},
{"PanelSortOrderByMTime", CK_PanelSortOrderByMTime},
{"PanelSmartJumpUp", CK_PanelSmartJumpUp},
/* input line */
{"InputBol", CK_InputBol},

View File

@ -454,6 +454,7 @@
#define CK_PanelSortOrderByExt 8040
#define CK_PanelSortOrderBySize 8041
#define CK_PanelSortOrderByMTime 8042
#define CK_PanelSmartJumpUp 8043
/* diff viewer */
#define CK_DiffDisplaySymbols 9001

View File

@ -311,6 +311,7 @@ PanelSortOrderByName=
PanelSortOrderByExt=
PanelSortOrderBySize=
PanelSortOrderByMTime=
PanelSmartJumpUp=
[input]
InputBol = ctrl-a; alt-lt; home; a1

View File

@ -315,6 +315,7 @@ PanelSortOrderByName=
PanelSortOrderByExt=
PanelSortOrderBySize=
PanelSortOrderByMTime=
PanelSmartJumpUp=
[input]
InputBol = ctrl-a; alt-lt; home; a1

View File

@ -1720,8 +1720,22 @@ maybe_cd (int move_up_dir)
}
/* --------------------------------------------------------------------------------------------- */
/** Returns the number of items in the given panel */
/* if command line is empty then do 'cd ..' */
static cb_ret_t
force_maybe_cd ()
{
if (cmdline->buffer[0] == '\0')
{
do_cd ("..", cd_exact);
return MSG_HANDLED;
}
return MSG_NOT_HANDLED;
}
/* --------------------------------------------------------------------------------------------- */
/* Returns the number of items in the given panel */
static int
ITEMS (WPanel * p)
{
@ -2793,6 +2807,9 @@ panel_execute_cmd (WPanel * panel, unsigned long command)
case CK_PanelMarkFileDown:
mark_file_down (panel);
break;
case CK_PanelSmartJumpUp:
res = force_maybe_cd ();
break;
case CK_PanelMoveUp:
move_up (panel);
break;