diff options
author | Dave Davenport <qball@gmpclient.org> | 2016-11-14 16:53:01 +0100 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2016-11-14 16:53:01 +0100 |
commit | 62879ee7392018f5dbfb4cfd04fc12266168b827 (patch) | |
tree | ab48ca5ec093cb08929ede59a0e135f40578184e /source | |
parent | d450d02ad66a507ef531e1431b3993cc104445e3 (diff) |
Continue parsing when keybinding fail, only show errors after all are done.
Diffstat (limited to 'source')
-rw-r--r-- | source/keyb.c | 13 | ||||
-rw-r--r-- | source/x11-helper.c | 26 |
2 files changed, 17 insertions, 22 deletions
diff --git a/source/keyb.c b/source/keyb.c index 1553bdb8..2bbb8210 100644 --- a/source/keyb.c +++ b/source/keyb.c @@ -109,6 +109,7 @@ void setup_abe ( void ) gboolean parse_keys_abe ( void ) { + GString *error_msg = g_string_new ( "" ); for ( int iter = 0; iter < NUM_ABE; iter++ ) { char *keystr = g_strdup ( abe[iter].keystr ); char *sp = NULL; @@ -123,15 +124,19 @@ gboolean parse_keys_abe ( void ) abe[iter].kb = g_realloc ( abe[iter].kb, ( abe[iter].num_bindings + 1 ) * sizeof ( KeyBinding ) ); KeyBinding *kb = &( abe[iter].kb[abe[iter].num_bindings] ); memset ( kb, 0, sizeof ( KeyBinding ) ); - if ( !x11_parse_key ( entry, &( kb->modmask ), &( kb->keysym ), &( kb->release ) ) ) { - g_free ( keystr ); - return FALSE; + if ( x11_parse_key ( entry, &( kb->modmask ), &( kb->keysym ), &( kb->release ), error_msg ) ) { + abe[iter].num_bindings++; } - abe[iter].num_bindings++; } g_free ( keystr ); } + if ( error_msg->len > 0 ) { + rofi_view_error_dialog ( error_msg->str, TRUE ); + g_string_free ( error_msg, TRUE ); + return FALSE; + } + g_string_free ( error_msg, TRUE ); return TRUE; } diff --git a/source/x11-helper.c b/source/x11-helper.c index ba61c8e4..98b2d39d 100644 --- a/source/x11-helper.c +++ b/source/x11-helper.c @@ -612,16 +612,15 @@ unsigned int x11_get_current_mask ( xkb_stuff *xkb ) } // convert a Mod+key arg to mod mask and keysym -gboolean x11_parse_key ( char *combo, unsigned int *mod, xkb_keysym_t *key, gboolean *release ) +gboolean x11_parse_key ( char *combo, unsigned int *mod, xkb_keysym_t *key, gboolean *release, GString *str ) { - GString *str = g_string_new ( "" ); unsigned int modmask = 0; if ( g_str_has_prefix ( combo, "!" ) ) { ++combo; *release = TRUE; } - + // TODO split this into tokonized parsing, so propper error can be generated. if ( strcasestr ( combo, "shift" ) ) { modmask |= x11_mod_masks[X11MOD_SHIFT]; if ( x11_mod_masks[X11MOD_SHIFT] == 0 ) { @@ -658,10 +657,6 @@ gboolean x11_parse_key ( char *combo, unsigned int *mod, xkb_keysym_t *key, gboo g_string_append_printf ( str, "X11 configured keyboard has no <b>Hyper</b> key.\n" ); } } - int seen_mod = FALSE; - if ( strcasestr ( combo, "Mod" ) ) { - seen_mod = TRUE; - } // Find location of modifier (if it exists) char i = strlen ( combo ); @@ -678,26 +673,21 @@ gboolean x11_parse_key ( char *combo, unsigned int *mod, xkb_keysym_t *key, gboo *mod = modmask; } - - // Parse key xkb_keysym_t sym = XKB_KEY_NoSymbol; sym = xkb_keysym_from_name ( combo + i, XKB_KEYSYM_NO_FLAGS ); if ( sym == XKB_KEY_NoSymbol || ( !modmask && ( strchr ( combo, '-' ) || strchr ( combo, '+' ) ) ) ) { g_string_append_printf ( str, "Sorry, rofi cannot understand the key combination: <i>%s</i>\n", combo ); - g_string_append ( str, "\nRofi supports the following modifiers:\n\t" ); - g_string_append ( str, "<i>Shift,Control,Alt,Super,Meta,Hyper</i>" ); - if ( seen_mod ) { - g_string_append ( str, "\n\n<b>Mod1,Mod2,Mod3,Mod4,Mod5 are no longer supported, use one of the above.</b>" ); + if ( sym == XKB_KEY_NoSymbol ) { + g_string_append_printf ( str, "∙ Key <i>%s</i> is not understood\n", combo + i ); } - } - if ( str->len > 0 ) { - rofi_view_error_dialog ( str->str, TRUE ); - g_string_free ( str, TRUE ); + if ( ( !modmask && ( strchr ( combo, '-' ) || strchr ( combo, '+' ) ) ) ) { + g_string_append ( str, "∙ Rofi supports the following modifiers: <i>Shift,Control,Alt,Super,Meta,Hyper</i>\n" ); + } + g_string_append_c ( str, '\n' ); return FALSE; } - g_string_free ( str, TRUE ); *key = sym; return TRUE; } |