diff options
author | QC <qball@gmpclient.org> | 2015-04-30 22:42:04 +0200 |
---|---|---|
committer | QC <qball@gmpclient.org> | 2015-04-30 22:42:04 +0200 |
commit | 09d2be260b067f49e00f5039ff603701ac1d0043 (patch) | |
tree | 95476efc099c930f60cc61378bec739d03373aad /source/keyb.c | |
parent | a70404f12812f3c26d122fc304a294bfcd72a0bf (diff) |
Allow keybindings to be set.
Diffstat (limited to 'source/keyb.c')
-rw-r--r-- | source/keyb.c | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/source/keyb.c b/source/keyb.c index 6108e9ab..cc5bf6e8 100644 --- a/source/keyb.c +++ b/source/keyb.c @@ -1,6 +1,7 @@ #include "rofi.h" #include <X11/keysym.h> #include "x11-helper.h" +#include "xrmoptions.h" ActionBindingEntry abe[NUM_ABE]; // Use this so we can ignore numlock mask. @@ -23,10 +24,16 @@ const char *KeyBindingActionName[NUM_ABE] = // REMOVE_WORD_FORWARD "remove-word-forward", // REMOVE_CHAR_FORWARD - "remove-char-forward" + "remove-char-forward", + // REMOVE_CHAR_BACK + "remove-char-back", + // MOVE_WORD_BACK + "move-word-back", + // MOVE_WORD_FORWARD + "move-word-forward", }; -const char *KeyBindingActionDefault[NUM_ABE] = +char *KeyBindingActionDefault[NUM_ABE] = { // PASTE_PRIMARY "Control+Shift+v,Shift+Insert", @@ -44,15 +51,36 @@ const char *KeyBindingActionDefault[NUM_ABE] = "Control+Alt+d", // REMOVE_CHAR_FORWARD "Delete,Control+d", + // REMOVE_CHAR_BACK + "BackSpace,Control+h", + // MOVE_WORD_BACK + "Alt+b", + // MOVE_WORD_FORWARD + "Alt+f", }; void setup_abe ( void ) { for ( int iter = 0; iter < NUM_ABE; iter++ ) { - char *keystr = g_strdup ( KeyBindingActionDefault[iter] ); - char *sp = NULL; // set pointer to name. - abe[iter].name = KeyBindingActionName[iter]; + abe[iter].name = KeyBindingActionName[iter]; + abe[iter].keystr = g_strdup ( KeyBindingActionDefault[iter] ); + abe[iter].num_bindings = 0; + abe[iter].kb = NULL; + + config_parser_add_option ( xrm_String, + abe[iter].name, &( abe[iter].keystr ) ); + } +} + +void parse_keys_abe ( void ) +{ + for ( int iter = 0; iter < NUM_ABE; iter++ ) { + char *keystr = g_strdup ( abe[iter].keystr ); + char *sp = NULL; + + g_free ( abe[iter].kb ); + abe[iter].num_bindings = 0; // Iter over bindings. for ( char *entry = strtok_r ( keystr, ",", &sp ); entry != NULL; entry = strtok_r ( NULL, ",", &sp ) ) { @@ -66,6 +94,15 @@ void setup_abe ( void ) } } +void cleanup_abe ( void ) +{ + for ( int iter = 0; iter < NUM_ABE; iter++ ) { + g_free ( abe[iter].kb ); + abe[iter].kb = NULL; + abe[iter].num_bindings = 0; + } +} + int abe_test_action ( KeyBindingAction action, unsigned int mask, KeySym key ) { ActionBindingEntry *akb = &( abe[action] ); |