Make 'all?' keys user configurable.

Fixes #66
This commit is contained in:
Dave Davenport 2015-06-15 09:01:22 +02:00
parent 25633ca4dc
commit 90eb18b3c0
4 changed files with 45 additions and 7 deletions

View File

@ -7,6 +7,8 @@
New feature:
- Markup support error message.
- Implement -no-custom as alternative to -only-select (#176).
Improvements:
- Make more keys user-configurable. (#66)
0.15.5:
Bug fixes:

View File

@ -37,6 +37,12 @@ typedef enum _KeyBindingAction
ROW_UP,
ROW_DOWN,
ROW_TAB,
PAGE_PREV,
PAGE_NEXT,
ROW_FIRST,
ROW_LAST,
ROW_SELECT,
CANCEL,
NUM_ABE
} KeyBindingAction;

View File

@ -206,7 +206,37 @@ DefaultBinding bindings[NUM_ABE] =
.id = ROW_TAB,
.name = "kb-row-tab",
.keybinding = "Tab"
}
},
{
.id = PAGE_PREV,
.name = "kb-page-prev",
.keybinding = "Page_Up"
},
{
.id = PAGE_NEXT,
.name = "kb-page-next",
.keybinding = "Page_Down"
},
{
.id = ROW_FIRST,
.name = "kb-row-first",
.keybinding = "Home,KP_Home"
},
{
.id = ROW_LAST,
.name = "kb-row-last",
.keybinding = "End,KP_End"
},
{
.id = ROW_SELECT,
.name = "kb-row-select",
.keybinding = "Control+space"
},
{
.id = CANCEL,
.name = "kb-cancel",
.keybinding = "Escape"
},
};

View File

@ -566,7 +566,7 @@ static void menu_keyboard_navigation ( MenuState *state, KeySym key, unsigned in
{
// pressing one of the global key bindings closes the switcher. This allows fast closing of the
// menu if an item is not selected
if ( locate_switcher ( key, modstate ) != -1 || key == XK_Escape ) {
if ( locate_switcher ( key, modstate ) != -1 || abe_test_action ( CANCEL, modstate, key ) ) {
state->retv = MENU_CANCEL;
state->quit = TRUE;
}
@ -602,7 +602,7 @@ static void menu_keyboard_navigation ( MenuState *state, KeySym key, unsigned in
else if ( abe_test_action ( ROW_RIGHT, modstate, key ) ) {
menu_nav_right ( state );
}
else if ( key == XK_Page_Up ) {
else if ( abe_test_action ( PAGE_PREV, modstate, key ) ) {
if ( state->selected < state->max_elements ) {
state->selected = 0;
}
@ -611,22 +611,22 @@ static void menu_keyboard_navigation ( MenuState *state, KeySym key, unsigned in
}
state->update = TRUE;
}
else if ( key == XK_Page_Down ) {
else if ( abe_test_action ( PAGE_NEXT, modstate, key ) ) {
state->selected += ( state->max_elements );
if ( state->selected >= state->filtered_lines ) {
state->selected = state->filtered_lines - 1;
}
state->update = TRUE;
}
else if ( key == XK_Home || key == XK_KP_Home ) {
else if ( abe_test_action ( ROW_FIRST, modstate, key ) ) {
state->selected = 0;
state->update = TRUE;
}
else if ( key == XK_End || key == XK_KP_End ) {
else if ( abe_test_action ( ROW_LAST, modstate, key ) ) {
state->selected = state->filtered_lines - 1;
state->update = TRUE;
}
else if ( key == XK_space && ( modstate & ControlMask ) == ControlMask ) {
else if ( abe_test_action ( ROW_SELECT, modstate, key ) ) {
// If a valid item is selected, return that..
if ( state->selected < state->filtered_lines ) {
textbox_text ( state->text, state->lines[state->line_map[state->selected]] );