summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2015-06-15 09:01:22 +0200
committerDave Davenport <qball@gmpclient.org>2015-06-15 09:01:22 +0200
commit90eb18b3c035071fde689fcc33ba752c479b961d (patch)
treeceab7a1458f1969a6d7bd77ee338ec3439a8ea2a
parent25633ca4dc7b4259087f19f6bf8ffec3ccbd033f (diff)
Make 'all?' keys user configurable.
Fixes #66
-rw-r--r--Changelog2
-rw-r--r--include/keyb.h6
-rw-r--r--source/keyb.c32
-rw-r--r--source/rofi.c12
4 files changed, 45 insertions, 7 deletions
diff --git a/Changelog b/Changelog
index 1ba8a0a2..00a98556 100644
--- a/Changelog
+++ b/Changelog
@@ -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:
diff --git a/include/keyb.h b/include/keyb.h
index c2213d85..452205d2 100644
--- a/include/keyb.h
+++ b/include/keyb.h
@@ -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;
diff --git a/source/keyb.c b/source/keyb.c
index b8474f65..ea140f4b 100644
--- a/source/keyb.c
+++ b/source/keyb.c
@@ -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"
+ },
};
diff --git a/source/rofi.c b/source/rofi.c
index 92e067b4..cd6e826b 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -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]] );