Merge branch '2534_mark_file_left_right'

* 2534_mark_file_left_right:
  Ticket #2534 (mark files by shift-left/shift-right)
This commit is contained in:
Ilia Maslakov 2011-06-24 09:26:50 +00:00
commit 92d21199c4
3 changed files with 65 additions and 1 deletions

View File

@ -77,6 +77,8 @@ Search = ctrl-s; alt-s
Mark = insert; ctrl-t Mark = insert; ctrl-t
MarkUp = shift-up MarkUp = shift-up
MarkDown = shift-down MarkDown = shift-down
MarkLeft =
MarkRight =
Down = down; ctrl-n Down = down; ctrl-n
Up = up; ctrl-p Up = up; ctrl-p
Left = left Left = left

View File

@ -78,6 +78,8 @@ Search = ctrl-s; alt-s
Mark = insert; ctrl-t Mark = insert; ctrl-t
MarkUp = shift-up MarkUp = shift-up
MarkDown = shift-down MarkDown = shift-down
MarkLeft =
MarkRight =
Down = down; ctrl-n Down = down; ctrl-n
Up = up; ctrl-p Up = up; ctrl-p
Left = left Left = left

View File

@ -350,7 +350,7 @@ static char *panel_history_show_list_sign = NULL;
static WPanel *mouse_mark_panel = NULL; static WPanel *mouse_mark_panel = NULL;
static int mouse_marking = 0; static int mouse_marking = 0;
static int state_mark = 0;
/*** file scope functions ************************************************************************/ /*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -2059,6 +2059,44 @@ mark_file_down (WPanel * panel)
do_mark_file (panel, MARK_FORCE_DOWN); do_mark_file (panel, MARK_FORCE_DOWN);
} }
/* --------------------------------------------------------------------------------------------- */
static void
mark_file_right (WPanel * panel)
{
int lines = llines (panel);
if (state_mark < 0)
state_mark = selection (panel)->f.marked ? 0 : 1;
lines = min (lines, panel->count - panel->selected - 1);
for (; lines != 0; lines--)
{
do_file_mark (panel, panel->selected, state_mark);
move_down (panel);
}
do_file_mark (panel, panel->selected, state_mark);
}
/* --------------------------------------------------------------------------------------------- */
static void
mark_file_left (WPanel * panel)
{
int lines = llines (panel);
if (state_mark < 0)
state_mark = selection (panel)->f.marked ? 0 : 1;
lines = min (lines, panel->selected + 1);
for (; lines != 0; lines--)
{
do_file_mark (panel, panel->selected, state_mark);
move_up (panel);
}
do_file_mark (panel, panel->selected, state_mark);
}
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
/** Incremental search of a file name in the panel. /** Incremental search of a file name in the panel.
* @param panel instance of WPanel structure * @param panel instance of WPanel structure
@ -2744,6 +2782,21 @@ panel_execute_cmd (WPanel * panel, unsigned long command)
if (command != CK_Search) if (command != CK_Search)
stop_search (panel); stop_search (panel);
switch (command)
{
case CK_Up:
case CK_Down:
case CK_Left:
case CK_Right:
case CK_Bottom:
case CK_Top:
case CK_PageDown:
case CK_PageUp:
/* reset state of marks flag*/
state_mark = -1;
break;
}
switch (command) switch (command)
{ {
case CK_PanelOtherCd: case CK_PanelOtherCd:
@ -2818,6 +2871,12 @@ panel_execute_cmd (WPanel * panel, unsigned long command)
case CK_MarkDown: case CK_MarkDown:
mark_file_down (panel); mark_file_down (panel);
break; break;
case CK_MarkLeft:
mark_file_left (panel);
break;
case CK_MarkRight:
mark_file_right (panel);
break;
case CK_CdParentSmart: case CK_CdParentSmart:
res = force_maybe_cd (); res = force_maybe_cd ();
break; break;
@ -2951,6 +3010,7 @@ panel_callback (Widget * w, widget_msg_t msg, int parm)
return MSG_HANDLED; return MSG_HANDLED;
case WIDGET_FOCUS: case WIDGET_FOCUS:
state_mark = -1;
current_panel = panel; current_panel = panel;
panel->active = 1; panel->active = 1;
if (mc_chdir (panel->cwd) != 0) if (mc_chdir (panel->cwd) != 0)