Issue #66, allow keybindings for navigation to be changed.

up,down,left,right
This commit is contained in:
Dave Davenport 2015-06-15 08:48:13 +02:00
parent 638b5e022f
commit 25633ca4dc
3 changed files with 36 additions and 10 deletions

View File

@ -32,6 +32,11 @@ typedef enum _KeyBindingAction
CUSTOM_7,
CUSTOM_8,
CUSTOM_9,
ROW_LEFT,
ROW_RIGHT,
ROW_UP,
ROW_DOWN,
ROW_TAB,
NUM_ABE
} KeyBindingAction;

View File

@ -182,6 +182,31 @@ DefaultBinding bindings[NUM_ABE] =
.name = "kb-custom-9",
.keybinding = "Alt+9"
},
{
.id = ROW_LEFT,
.name = "kb-row-left",
.keybinding = "Control+Page_Up"
},
{
.id = ROW_RIGHT,
.name = "kb-row-right",
.keybinding = "Control+Page_Down"
},
{
.id = ROW_UP,
.name = "kb-row-up",
.keybinding = "Up,Control+p,Shift+Tab"
},
{
.id = ROW_DOWN,
.name = "kb-row-down",
.keybinding = "Down,Control+n"
},
{
.id = ROW_TAB,
.name = "kb-row-tab",
.keybinding = "Tab"
}
};

View File

@ -571,11 +571,10 @@ static void menu_keyboard_navigation ( MenuState *state, KeySym key, unsigned in
state->quit = TRUE;
}
// Up, Ctrl-p or Shift-Tab
else if ( key == XK_Up || ( key == XK_Tab && modstate & ShiftMask ) ||
( key == XK_p && modstate & ControlMask ) ) {
else if ( abe_test_action ( ROW_UP, modstate, key ) ) {
menu_nav_up ( state );
}
else if ( key == XK_Tab ) {
else if ( abe_test_action ( ROW_TAB, modstate, key ) ) {
if ( state->filtered_lines == 1 ) {
state->retv = MENU_OK;
*( state->selected_line ) = state->line_map[state->selected];
@ -590,20 +589,17 @@ static void menu_keyboard_navigation ( MenuState *state, KeySym key, unsigned in
state->quit = TRUE;
}
else{
state->selected = state->selected < state->filtered_lines - 1 ? MIN (
state->filtered_lines - 1, state->selected + 1 ) : 0;
state->update = TRUE;
menu_nav_down ( state );
}
}
// Down, Ctrl-n
else if ( key == XK_Down ||
( key == XK_n && ( modstate & ControlMask ) ) ) {
else if ( abe_test_action ( ROW_DOWN, modstate, key ) ) {
menu_nav_down ( state );
}
else if ( key == XK_Page_Up && ( modstate & ControlMask ) ) {
else if ( abe_test_action ( ROW_LEFT, modstate, key ) ) {
menu_nav_left ( state );
}
else if ( key == XK_Page_Down && ( modstate & ControlMask ) ) {
else if ( abe_test_action ( ROW_RIGHT, modstate, key ) ) {
menu_nav_right ( state );
}
else if ( key == XK_Page_Up ) {