mirror of https://github.com/MidnightCommander/mc
Ticket #212: replacement of hardcoded keys in viewer and interactive help.
Added new viewer keybindings instaed of hardcoded keys: - for move to top and bottom of file; - for horizontal scroll by 10 columns. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
a1dce46339
commit
6b4914b46e
|
@ -173,12 +173,16 @@ ViewMoveToBol = ctrl-a
|
|||
ViewMoveToEol = ctrl-e
|
||||
ViewMoveLeft = h; left
|
||||
ViewMoveRight = l; right
|
||||
ViewMoveLeft10 = ctrl-left
|
||||
ViewMoveRight10 = ctrl-right
|
||||
ViewMoveUp = k; y; insert; up
|
||||
ViewMoveDown = j; e; delete; down; enter
|
||||
ViewMovePgDn = f; space; pgdn
|
||||
ViewMovePgUp = b; pgup
|
||||
ViewMoveHalfPgDn = d
|
||||
ViewMoveHalfPgUp = u
|
||||
ViewMoveTop = home; ctrl-home; ctrl-pgup; a1; alt-lt; g
|
||||
ViewMoveBottom = end; ctrl-end; ctrl-pgdn; c1; alt-gt; shift-g
|
||||
ViewGotoBookmark = m
|
||||
ViewNewBookmark = r
|
||||
ViewNextFile = ctrl-f
|
||||
|
@ -204,6 +208,8 @@ ViewMoveLeft = b; left
|
|||
ViewMoveRight = f; right
|
||||
ViewMoveUp = k; y; up
|
||||
ViewMoveDown = j; delete; down
|
||||
ViewMoveTop = home; ctrl-home; ctrl-pgup; a1; alt-lt; g
|
||||
ViewMoveBottom = end; ctrl-end; ctrl-pgdn; c1; alt-gt; shift-g
|
||||
|
||||
[main]
|
||||
CmdHelp = f1
|
||||
|
|
|
@ -177,12 +177,16 @@ ViewMoveToBol = ctrl-a
|
|||
ViewMoveToEol = ctrl-e
|
||||
ViewMoveLeft = h; left
|
||||
ViewMoveRight = l; right
|
||||
ViewMoveLeft10 = ctrl-left
|
||||
ViewMoveRight10 = ctrl-right
|
||||
ViewMoveUp = k; y; insert; up
|
||||
ViewMoveDown = j; e; delete; down; enter
|
||||
ViewMovePgDn = f; space; pgdn
|
||||
ViewMovePgUp = b; pgup
|
||||
ViewMoveHalfPgDn = d
|
||||
ViewMoveHalfPgUp = u
|
||||
ViewMoveTop = home; ctrl-home; ctrl-pgup; a1; alt-lt; g
|
||||
ViewMoveBottom = end; ctrl-end; ctrl-pgdn; c1; alt-gt; shift-g
|
||||
ViewGotoBookmark = m
|
||||
ViewNewBookmark = r
|
||||
ViewNextFile = ctrl-f
|
||||
|
@ -208,6 +212,8 @@ ViewMoveLeft = b; left
|
|||
ViewMoveRight = f; right
|
||||
ViewMoveUp = k; y; up
|
||||
ViewMoveDown = j; delete; down
|
||||
ViewMoveTop = home; ctrl-home; ctrl-pgup; a1; alt-lt; g
|
||||
ViewMoveBottom = end; ctrl-end; ctrl-pgdn; c1; alt-gt; shift-g
|
||||
|
||||
[main]
|
||||
CmdHelp = f1
|
||||
|
|
|
@ -299,6 +299,10 @@
|
|||
#define CK_ViewPrevFile 5025
|
||||
#define CK_ViewToggleRuler 5026
|
||||
#define CK_ViewToggleHexNavMode 5027
|
||||
#define CK_ViewMoveTop 5028
|
||||
#define CK_ViewMoveBottom 5029
|
||||
#define CK_ViewMoveLeft10 5030
|
||||
#define CK_ViewMoveRight10 5031
|
||||
|
||||
/* tree */
|
||||
#define CK_TreeHelp 6001
|
||||
|
|
|
@ -273,12 +273,16 @@ static name_keymap_t command_names[] = {
|
|||
{ "ViewMoveDown", CK_ViewMoveDown },
|
||||
{ "ViewMoveLeft", CK_ViewMoveLeft },
|
||||
{ "ViewMoveRight", CK_ViewMoveRight },
|
||||
{ "ViewMoveLeft10", CK_ViewMoveLeft10 },
|
||||
{ "ViewMoveRight10", CK_ViewMoveRight10 },
|
||||
{ "ViewMovePgDn", CK_ViewMovePgDn },
|
||||
{ "ViewMovePgUp", CK_ViewMovePgUp },
|
||||
{ "ViewMoveHalfPgDn", CK_ViewMoveHalfPgDn },
|
||||
{ "ViewMoveHalfPgUp", CK_ViewMoveHalfPgUp },
|
||||
{ "ViewMoveToBol", CK_ViewMoveToBol },
|
||||
{ "ViewMoveToEol", CK_ViewMoveToEol },
|
||||
{ "ViewMoveTop", CK_ViewMoveTop },
|
||||
{ "ViewMoveBottom", CK_ViewMoveBottom },
|
||||
{ "ViewNextFile", CK_ViewNextFile },
|
||||
{ "ViewPrevFile", CK_ViewPrevFile },
|
||||
{ "ViewToggleRuler", CK_ViewToggleRuler },
|
||||
|
@ -593,6 +597,9 @@ const global_keymap_t default_viewer_keymap[] = {
|
|||
{ 'l', CK_ViewMoveRight, "l" },
|
||||
{ KEY_RIGHT, CK_ViewMoveRight, "Right" },
|
||||
|
||||
{ KEY_M_CTRL | KEY_LEFT, CK_ViewMoveLeft10, "C-Left" },
|
||||
{ KEY_M_CTRL | KEY_RIGHT, CK_ViewMoveRight10, "C-Right" },
|
||||
|
||||
{ 'k', CK_ViewMoveUp, "k" },
|
||||
{ 'y', CK_ViewMoveUp, "y" },
|
||||
{ KEY_IC, CK_ViewMoveUp, "Insert" },
|
||||
|
@ -602,6 +609,7 @@ const global_keymap_t default_viewer_keymap[] = {
|
|||
{ 'e', CK_ViewMoveDown, "e" },
|
||||
{ KEY_DOWN, CK_ViewMoveDown, "Down" },
|
||||
{ KEY_DC, CK_ViewMoveDown, "Delete" },
|
||||
{ '\n', CK_ViewMoveDown, "Endter" },
|
||||
|
||||
{ ' ', CK_ViewMovePgDn, "Space" },
|
||||
{ 'f', CK_ViewMovePgDn, "f" },
|
||||
|
@ -613,6 +621,20 @@ const global_keymap_t default_viewer_keymap[] = {
|
|||
{ 'd', CK_ViewMoveHalfPgDn, "d" },
|
||||
{ 'u', CK_ViewMoveHalfPgUp, "u" },
|
||||
|
||||
{ KEY_HOME, CK_ViewMoveTop, "Home" },
|
||||
{ KEY_M_CTRL | KEY_HOME, CK_ViewMoveTop, "C-Home" },
|
||||
{ KEY_M_CTRL | KEY_PPAGE, CK_ViewMoveTop, "C-PgUp" },
|
||||
{ KEY_A1, CK_ViewMoveTop, "A1" },
|
||||
{ ALT ('<'), CK_ViewMoveTop, "M-<" },
|
||||
{ 'g', CK_ViewMoveTop, "g" },
|
||||
|
||||
{ KEY_END, CK_ViewMoveBottom, "End" },
|
||||
{ KEY_M_CTRL | KEY_END, CK_ViewMoveBottom, "C-End" },
|
||||
{ KEY_M_CTRL | KEY_NPAGE, CK_ViewMoveBottom, "C-PgDn" },
|
||||
{ KEY_C1, CK_ViewMoveBottom, "C1" },
|
||||
{ ALT ('>'), CK_ViewMoveBottom, "M->" },
|
||||
{ 'G', CK_ViewMoveBottom, "G" },
|
||||
|
||||
{ 'm', CK_ViewGotoBookmark, "m" },
|
||||
{ 'r', CK_ViewNewBookmark, "r" },
|
||||
|
||||
|
@ -666,6 +688,20 @@ const global_keymap_t default_viewer_hex_keymap[] = {
|
|||
{ KEY_DOWN, CK_ViewMoveDown, "Down" },
|
||||
{ KEY_DC, CK_ViewMoveDown, "Delete" },
|
||||
|
||||
{ KEY_HOME, CK_ViewMoveTop, "Home" },
|
||||
{ KEY_M_CTRL | KEY_HOME, CK_ViewMoveTop, "C-Home" },
|
||||
{ KEY_M_CTRL | KEY_PPAGE, CK_ViewMoveTop, "C-PgUp" },
|
||||
{ KEY_A1, CK_ViewMoveTop, "A1" },
|
||||
{ ALT ('<'), CK_ViewMoveTop, "M-<" },
|
||||
{ 'g', CK_ViewMoveTop, "g" },
|
||||
|
||||
{ KEY_END, CK_ViewMoveBottom, "End" },
|
||||
{ KEY_M_CTRL | KEY_END, CK_ViewMoveBottom, "C-End" },
|
||||
{ KEY_M_CTRL | KEY_NPAGE, CK_ViewMoveBottom, "C-PgDn" },
|
||||
{ KEY_C1, CK_ViewMoveBottom, "C1" },
|
||||
{ ALT ('>'), CK_ViewMoveBottom, "M->" },
|
||||
{ 'G', CK_ViewMoveBottom, "G" },
|
||||
|
||||
{ 'q', CK_ViewQuit, "q" },
|
||||
{ XCTRL ('g'), CK_ViewQuit, "C-g" },
|
||||
{ ESC_CHAR, CK_ViewQuit, "Esc" },
|
||||
|
|
|
@ -144,51 +144,6 @@ mcview_continue_search_cmd (mcview_t * view)
|
|||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* Check for left and right arrows, possibly with modifiers */
|
||||
static cb_ret_t
|
||||
mcview_check_left_right_keys (mcview_t * view, int c)
|
||||
{
|
||||
if (c == KEY_LEFT)
|
||||
{
|
||||
mcview_move_left (view, 1);
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
if (c == KEY_RIGHT)
|
||||
{
|
||||
mcview_move_right (view, 1);
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
/* Ctrl with arrows moves by 10 postions in the unwrap mode */
|
||||
if (view->hex_mode || view->text_wrap_mode)
|
||||
return MSG_NOT_HANDLED;
|
||||
|
||||
if (c == (KEY_M_CTRL | KEY_LEFT))
|
||||
{
|
||||
if (view->dpy_text_column >= 10)
|
||||
view->dpy_text_column -= 10;
|
||||
else
|
||||
view->dpy_text_column = 0;
|
||||
view->dirty++;
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
if (c == (KEY_M_CTRL | KEY_RIGHT))
|
||||
{
|
||||
if (view->dpy_text_column <= OFFSETTYPE_MAX - 10)
|
||||
view->dpy_text_column += 10;
|
||||
else
|
||||
view->dpy_text_column = OFFSETTYPE_MAX;
|
||||
view->dirty++;
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
return MSG_NOT_HANDLED;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
mcview_cmk_move_up (void *w, int n)
|
||||
{
|
||||
|
@ -387,7 +342,14 @@ mcview_execute_cmd (mcview_t * view, unsigned long command)
|
|||
case CK_ViewMoveRight:
|
||||
mcview_move_right (view, 1);
|
||||
break;
|
||||
/* Continue search */
|
||||
case CK_ViewMoveLeft10:
|
||||
if (!view->hex_mode)
|
||||
mcview_move_left (view, 10);
|
||||
break;
|
||||
case CK_ViewMoveRight10:
|
||||
if (!view->hex_mode)
|
||||
mcview_move_right (view, 10);
|
||||
break;
|
||||
case CK_ViewContinueSearch:
|
||||
mcview_continue_search_cmd (view);
|
||||
break;
|
||||
|
@ -412,6 +374,12 @@ mcview_execute_cmd (mcview_t * view, unsigned long command)
|
|||
case CK_ViewMovePgDn:
|
||||
mcview_move_down (view, view->data_area.height);
|
||||
break;
|
||||
case CK_ViewMoveTop:
|
||||
mcview_moveto_top (view);
|
||||
break;
|
||||
case CK_ViewMoveBottom:
|
||||
mcview_moveto_bottom (view);
|
||||
break;
|
||||
case CK_ShowCommandLine:
|
||||
view_other_cmd ();
|
||||
break;
|
||||
|
@ -471,9 +439,6 @@ mcview_handle_key (mcview_t * view, int key)
|
|||
if ((command != CK_Ignore_Key) && (mcview_execute_cmd (view, command) == MSG_HANDLED))
|
||||
return MSG_HANDLED;
|
||||
|
||||
if (mcview_check_left_right_keys (view, key) == MSG_HANDLED)
|
||||
return MSG_HANDLED;
|
||||
|
||||
if (check_movement_keys (key, view->data_area.height + 1, view,
|
||||
mcview_cmk_move_up, mcview_cmk_move_down,
|
||||
mcview_cmk_moveto_top, mcview_cmk_moveto_bottom) == MSG_HANDLED)
|
||||
|
|
Loading…
Reference in New Issue