From 94aa18522723584cf3966ed5bc97d6a1275697a0 Mon Sep 17 00:00:00 2001 From: kabanov Date: Wed, 10 Jul 2019 13:09:28 +0500 Subject: [PATCH 1/4] non-sensitivity to keyboard layout --- include/keyb.h | 18 +++++ include/settings.h | 3 +- meson.build | 10 +++ source/helper.c | 29 +++++++- source/keyb-layout.c | 148 +++++++++++++++++++++++++++++++++++++++++ source/xcb.c | 7 +- source/xrmoptions.c | 2 +- test/helper-tokenize.c | 89 +++++++++++++++++++++++++ 8 files changed, 302 insertions(+), 4 deletions(-) create mode 100644 source/keyb-layout.c diff --git a/include/keyb.h b/include/keyb.h index bc8628b97..6a5ba48f4 100644 --- a/include/keyb.h +++ b/include/keyb.h @@ -184,5 +184,23 @@ gboolean parse_keys_abe ( NkBindings *bindings ); */ void setup_abe ( void ); +/** + * Load the charmap from a keymap + */ +void kbl_charmap_load_from_keymap ( struct xkb_keymap *keymap ); + +/** + * Cleanup the charmap + */ +void kbl_charmap_cleanup ( void ); + +/** + * Allocate and initialize an input buffer state. + * @param chr character in utf8. + * + * @return the allocated string containing corresponding characters + */ +gchar *kbl_charmap_for_char ( const gchar *chr ); + /*@}*/ #endif // ROFI_KEYB_H diff --git a/include/settings.h b/include/settings.h index e6aebc8bb..bf477dc58 100644 --- a/include/settings.h +++ b/include/settings.h @@ -40,7 +40,8 @@ typedef enum MM_NORMAL = 0, MM_REGEX = 1, MM_GLOB = 2, - MM_FUZZY = 3 + MM_FUZZY = 3, + MM_ALL_KB_LAYOUTS = 4 } MatchingMethod; typedef enum diff --git a/meson.build b/meson.build index e5eebb303..f9ce3ebf4 100644 --- a/meson.build +++ b/meson.build @@ -137,6 +137,7 @@ rofi_sources = files( 'source/view.c', 'source/mode.c', 'source/keyb.c', + 'source/keyb-layout.c', 'config/config.c', 'source/helper.c', 'source/timings.c', @@ -290,6 +291,7 @@ test('helper_pidfile test', executable('helper_pidfile.test', [ 'source/helper.c', 'source/xrmoptions.c', 'source/rofi-types.c', + 'source/keyb-layout.c', ]), dependencies: deps, )) @@ -308,6 +310,7 @@ test('widget test', executable('widget.test', [ 'source/css-colors.c', 'source/helper.c', 'config/config.c', + 'source/keyb-layout.c', ]), dependencies: deps, )) @@ -357,6 +360,7 @@ test('textbox test', executable('textbox.test', [ 'source/css-colors.c', 'source/helper.c', 'config/config.c', + 'source/keyb-layout.c', ]), dependencies: deps, )) @@ -369,6 +373,7 @@ test('helper test', executable('helper.test', [ 'source/helper.c', 'source/xrmoptions.c', 'source/rofi-types.c', + 'source/keyb-layout.c', ]), dependencies: deps, )) @@ -381,6 +386,7 @@ test('helper_expand test', executable('helper_expand.test', [ 'source/helper.c', 'source/xrmoptions.c', 'source/rofi-types.c', + 'source/keyb-layout.c', ]), dependencies: deps, )) @@ -393,6 +399,7 @@ test('helper_config_cmdline_parser test', executable('helper_config_cmdline_pars 'source/helper.c', 'source/xrmoptions.c', 'source/rofi-types.c', + 'source/keyb-layout.c', ]), dependencies: deps, )) @@ -412,6 +419,7 @@ if check.found() 'source/theme.c', 'source/rofi-types.c', 'source/css-colors.c', + 'source/keyb-layout.c', ]), dependencies: deps, )) @@ -427,6 +435,7 @@ if check.found() 'source/xrmoptions.c', 'source/rofi-types.c', 'source/keyb.c', + 'source/keyb-layout.c', ]), dependencies: deps, )) @@ -439,6 +448,7 @@ if check.found() 'source/helper.c', 'source/xrmoptions.c', 'source/rofi-types.c', + 'source/keyb-layout.c', ]), dependencies: deps, )) diff --git a/source/helper.c b/source/helper.c index 783dc2cfd..820db0e36 100644 --- a/source/helper.c +++ b/source/helper.c @@ -55,6 +55,7 @@ #include "settings.h" #include "rofi.h" #include "view.h" +#include "keyb.h" /** * Textual description of positioning rofi. @@ -180,6 +181,24 @@ static gchar *fuzzy_to_regex ( const char * input ) g_string_free ( str, FALSE ); return retv; } +static gchar *all_kb_layouts_to_regex ( const char * input ) +{ + GString *str = g_string_new ( "" ); + gchar *iter; + for ( iter = input; iter && *iter != '\0'; iter = g_utf8_next_char ( iter ) ) { + gchar *kblchs = kbl_charmap_for_char ( iter ); + gchar *r = g_regex_escape_string ( kblchs, -1 ); + + g_string_append_printf( str, "[%s]", r); + g_free ( kblchs ); + g_free ( r ); + } + + gchar *retv = str->str; + g_string_free ( str, FALSE ); + return retv; +} + // Macro for quickly generating regex for matching. static inline GRegex * R ( const char *s, int case_sensitive ) @@ -216,6 +235,11 @@ static rofi_int_matcher * create_regex ( const char *input, int case_sensitive ) retv = R ( r, case_sensitive ); g_free ( r ); break; + case MM_ALL_KB_LAYOUTS: + r = all_kb_layouts_to_regex ( input ); + retv = R ( r, case_sensitive ); + g_free ( r ); + break; default: r = g_regex_escape_string ( input, -1 ); retv = R ( r, case_sensitive ); @@ -576,11 +600,14 @@ int config_sanity_check ( void ) else if ( g_strcmp0 ( config.matching, "fuzzy" ) == 0 ) { config.matching_method = MM_FUZZY; } + else if ( g_strcmp0 ( config.matching, "all_kb_layouts" ) == 0 ) { + config.matching_method = MM_ALL_KB_LAYOUTS; + } else if ( g_strcmp0 ( config.matching, "normal" ) == 0 ) { config.matching_method = MM_NORMAL;; } else { - g_string_append_printf ( msg, "\tconfig.matching=%s is not a valid matching strategy.\nValid options are: glob, regex, fuzzy or normal.\n", + g_string_append_printf ( msg, "\tconfig.matching=%s is not a valid matching strategy.\nValid options are: glob, regex, fuzzy, all_kb_layouts or normal.\n", config.matching ); found_error = 1; } diff --git a/source/keyb-layout.c b/source/keyb-layout.c new file mode 100644 index 000000000..4d0a017c3 --- /dev/null +++ b/source/keyb-layout.c @@ -0,0 +1,148 @@ +/* + * rofi + * + * MIT/X11 License + * Copyright © 2013-2017 Qball Cow + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#include "rofi.h" + +/** + * Data structure corresponding to the relationship of the character to the layout + */ +struct kbl_charmap { + xkb_layout_index_t layout; + xkb_level_index_t level; + xkb_keycode_t keycode; + int keysim; + gunichar chr; +}; + +/** + * Array of relationships of the character to the layout. Sorted by keycode + */ +static GArray *rofi_kbl_charmap; + +static void kbl_charmap_key_iter ( struct xkb_keymap *keymap, xkb_keycode_t key, void *data ) { + const xkb_keysym_t *keysims; + char buffer[255]; + GArray *char_array = ( GArray* ) data; + + xkb_layout_index_t lt_count = xkb_keymap_num_layouts_for_key ( keymap, key ); + if ( lt_count <= 1 ) { + return; + } + for ( xkb_layout_index_t lt_index = 0; lt_index < lt_count; lt_index ++ ) { + xkb_level_index_t lvl_count = xkb_keymap_num_levels_for_key ( keymap, key, lt_index ); + for ( xkb_level_index_t lvl_index = 0; lvl_index < lvl_count; lvl_index++ ) { + int ks_count = xkb_keymap_key_get_syms_by_level ( keymap, key, lt_index, lvl_index, &keysims ); + for ( int ks_index=0; ks_index < ks_count; ks_index++ ) { + int char_count = xkb_keysym_to_utf8 ( keysims[ks_index], buffer, 255 ); + if ( char_count > 0 ) { + gunichar chr = g_utf8_get_char ( buffer ); + if ( g_unichar_isdefined ( chr ) ) { + struct kbl_charmap charmap_item = { + .layout = lt_index, + .level = lvl_index, + .keycode = key, + .keysim = ks_index, + .chr = g_utf8_get_char ( buffer ) + }; + g_array_append_val ( char_array, charmap_item ); + } + } + } + } + } +} + +void kbl_charmap_load_from_keymap ( struct xkb_keymap *keymap ) { + rofi_kbl_charmap = NULL; + xkb_layout_index_t layout_count = xkb_keymap_num_layouts ( keymap ); + if ( layout_count <= 1 ) { + return; + } + rofi_kbl_charmap = g_array_new ( FALSE, FALSE, sizeof ( struct kbl_charmap ) ); + xkb_keymap_key_for_each ( keymap, kbl_charmap_key_iter, rofi_kbl_charmap ); +} + +void kbl_charmap_cleanup(void) { + g_array_free ( rofi_kbl_charmap, TRUE ); +} + +static gint kbl_charmap_find_char_key ( GArray *charmap, gunichar chr, struct kbl_charmap *key, gint next ) { + for ( guint i = ( guint ) next; ilen; i++ ) { + struct kbl_charmap *charmap_item = &g_array_index ( charmap, struct kbl_charmap, i ); + if ( charmap_item->chr == chr ) { + key->layout = charmap_item->layout; + key->level = charmap_item->level; + key->keycode = charmap_item->keycode; + key->keysim = charmap_item->keysim; + key->chr = charmap_item->chr; + return ( gint ) i; + } + } + return -1; +} + +gchar *kbl_charmap_for_char ( const gchar *chr ) { + gint found = 0; + struct kbl_charmap key_for_char; + gunichar uchar = g_utf8_get_char ( chr ); + GString * str = g_string_new ( "" ); + if ( rofi_kbl_charmap ) { + while ( ( found = kbl_charmap_find_char_key ( rofi_kbl_charmap, uchar, &key_for_char, found ) ) >= 0) { + for ( gint i = found; i >= 0; i-- ) { + struct kbl_charmap *charmap_item = &g_array_index ( rofi_kbl_charmap, struct kbl_charmap, i ); + if ( key_for_char.level == charmap_item->level && + key_for_char.keycode == charmap_item->keycode && + key_for_char.keysim == charmap_item->keysim ) + { + g_string_append_unichar ( str, charmap_item->chr ); + } + if (key_for_char.keycode != charmap_item->keycode) { + break; + } + } + for ( guint i = ( guint ) found+1; i < rofi_kbl_charmap->len; i++ ) { + struct kbl_charmap *charmap_item = &g_array_index ( rofi_kbl_charmap, struct kbl_charmap, i ); + if ( key_for_char.level == charmap_item->level && + key_for_char.keycode == charmap_item->keycode && + key_for_char.keysim == charmap_item->keysim ) + { + g_string_append_unichar ( str, charmap_item->chr ); + } + if (key_for_char.keycode != charmap_item->keycode) { + break; + } + } + found++; + } + } + if ( str->len ==0 ) { + g_string_append_unichar ( str, uchar ); + } + gchar *retv = str->str; + g_string_free ( str, FALSE ); + return retv; +} diff --git a/source/xcb.c b/source/xcb.c index 249069f51..7fa56cd90 100644 --- a/source/xcb.c +++ b/source/xcb.c @@ -884,7 +884,7 @@ static void main_loop_x11_event_handler_view ( xcb_generic_event_t *event ) for ( gint32 by = 0; by < 31; ++by ) { for ( gint8 bi = 0; bi < 7; ++bi ) { if ( kne->keys[by] & ( 1 << bi ) ) { - // X11 keycodes starts at 8 + // X11 keycodes starts at 8 nk_bindings_seat_handle_key ( xcb->bindings_seat, NULL, ( 8 * by + bi ) + 8, NK_BINDINGS_KEY_STATE_PRESSED ); } } @@ -1178,6 +1178,9 @@ gboolean display_setup ( GMainLoop *main_loop, NkBindings *bindings ) g_warning ( "Failed to get Keymap for current keyboard device." ); return FALSE; } + + kbl_charmap_load_from_keymap(keymap); + struct xkb_state *state = xkb_x11_state_new_from_device ( keymap, xcb->connection, xcb->xkb.device_id ); if ( state == NULL ) { g_warning ( "Failed to get state object for current keyboard device." ); @@ -1357,6 +1360,7 @@ void display_cleanup ( void ) xcb->connection = NULL; xcb->screen = NULL; xcb->screen_nbr = 0; + kbl_charmap_cleanup (); } void x11_disable_decoration ( xcb_window_t window ) @@ -1383,3 +1387,4 @@ void x11_disable_decoration ( xcb_window_t window ) xcb_atom_t ha = netatoms[_MOTIF_WM_HINTS]; xcb_change_property ( xcb->connection, XCB_PROP_MODE_REPLACE, window, ha, ha, 32, 5, &hints ); } + diff --git a/source/xrmoptions.c b/source/xrmoptions.c index fde3fa2a9..a77e26548 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -164,7 +164,7 @@ static XrmOption xrmOptions[] = { { xrm_String, "combi-modi", { .str = &config.combi_modi }, NULL, "Set the modi to combine in combi mode", CONFIG_DEFAULT }, { xrm_String, "matching", { .str = &config.matching }, NULL, - "Set the matching algorithm. (normal, regex, glob, fuzzy)", CONFIG_DEFAULT }, + "Set the matching algorithm. (normal, regex, glob, fuzzy, all_kb_layouts)", CONFIG_DEFAULT }, { xrm_Boolean, "tokenize", { .num = &config.tokenize }, NULL, "Tokenize input string", CONFIG_DEFAULT }, { xrm_String, "monitor", { .str = &config.monitor }, NULL, diff --git a/test/helper-tokenize.c b/test/helper-tokenize.c index 66cfb60f3..543c7ea60 100644 --- a/test/helper-tokenize.c +++ b/test/helper-tokenize.c @@ -391,6 +391,86 @@ START_TEST ( test_tokenizer_match_regex_single_two_word_till_end ) } END_TEST +START_TEST ( test_tokenizer_match_all_lt_single_ci ) +{ + config.matching_method = MM_ALL_KB_LAYOUTS; + rofi_int_matcher **tokens = helper_tokenize ( "noot", FALSE ); + + ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE ); + ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE ); + ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE ); + ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE ); + ck_assert_int_eq ( helper_token_match ( tokens, "aap Noot mies") , TRUE ); + ck_assert_int_eq ( helper_token_match ( tokens, "Nooaap mies") , FALSE ); + ck_assert_int_eq ( helper_token_match ( tokens, "noOTap mies") , TRUE ); + + helper_tokenize_free ( tokens ); +} +END_TEST + +START_TEST ( test_tokenizer_match_all_lt_single_cs ) +{ + config.matching_method = MM_ALL_KB_LAYOUTS; + rofi_int_matcher **tokens = helper_tokenize ( "noot", TRUE ); + + ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE ); + ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE ); + ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE ); + ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE ); + ck_assert_int_eq ( helper_token_match ( tokens, "aap Noot mies") , FALSE ); + ck_assert_int_eq ( helper_token_match ( tokens, "Nooaap mies") , FALSE ); + ck_assert_int_eq ( helper_token_match ( tokens, "noOTap mies") , FALSE ); + helper_tokenize_free ( tokens ); +} +END_TEST + +START_TEST ( test_tokenizer_match_all_lt_multiple_ci ) +{ + config.matching_method = MM_ALL_KB_LAYOUTS; + rofi_int_matcher **tokens = helper_tokenize ( "no ot", FALSE ); + ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE ); + ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE ); + ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE ); + ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE ); + ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE ); + helper_tokenize_free ( tokens ); + + tokens = helper_tokenize ( "n ot", FALSE ); + ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE ); + ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE ); + ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE ); + ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE ); + ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE); + helper_tokenize_free ( tokens ); +} +END_TEST + +START_TEST ( test_tokenizer_match_all_lt_single_ci_split ) +{ + config.matching_method = MM_ALL_KB_LAYOUTS; + rofi_int_matcher **tokens = helper_tokenize ( "ont", FALSE ); + ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , FALSE); + ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE ); + ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE ); + ck_assert_int_eq ( helper_token_match ( tokens, "nootap nmiest") , FALSE ); + helper_tokenize_free ( tokens ); +} +END_TEST + +START_TEST ( test_tokenizer_match_all_lt_multiple_ci_split ) +{ + config.matching_method = MM_ALL_KB_LAYOUTS; + rofi_int_matcher **tokens = helper_tokenize ( "o n t", FALSE ); + ck_assert_int_eq ( helper_token_match ( tokens, "aap noot mies") , TRUE ); + ck_assert_int_eq ( helper_token_match ( tokens, "aap mies") , FALSE ); + ck_assert_int_eq ( helper_token_match ( tokens, "nooaap mies") , FALSE ); + ck_assert_int_eq ( helper_token_match ( tokens, "nootap mies") , TRUE ); + ck_assert_int_eq ( helper_token_match ( tokens, "noap miesot") , TRUE); + ck_assert_int_eq ( helper_token_match ( tokens, "ot nap mies") , TRUE); + helper_tokenize_free ( tokens ); +} +END_TEST + static Suite * helper_tokenizer_suite (void) { Suite *s; @@ -442,6 +522,15 @@ static Suite * helper_tokenizer_suite (void) tcase_add_test(tc_regex, test_tokenizer_match_regex_multiple_ci); suite_add_tcase(s, tc_regex); } + { + TCase *tc_all_layaut = tcase_create ("AllLayout"); + tcase_add_test(tc_all_layaut, test_tokenizer_match_all_lt_single_ci); + tcase_add_test(tc_all_layaut, test_tokenizer_match_all_lt_single_cs); + tcase_add_test(tc_all_layaut, test_tokenizer_match_all_lt_single_ci_split); + tcase_add_test(tc_all_layaut, test_tokenizer_match_all_lt_multiple_ci); + tcase_add_test(tc_all_layaut, test_tokenizer_match_all_lt_multiple_ci_split); + suite_add_tcase(s, tc_all_layaut); + } return s; From 06ccbacc83284729de9c715a583d5291f3ecdc6a Mon Sep 17 00:00:00 2001 From: kabanov Date: Wed, 10 Jul 2019 14:52:15 +0500 Subject: [PATCH 2/4] make indent --- Makefile.am | 30 ++++++---- include/settings.h | 8 +-- source/helper.c | 47 ++++++++------- source/keyb-layout.c | 78 +++++++++++++------------ source/xcb.c | 15 +++-- source/xrmoptions.c | 132 +++++++++++++++++++++---------------------- 6 files changed, 164 insertions(+), 146 deletions(-) diff --git a/Makefile.am b/Makefile.am index 41284e4f9..f44c19a7c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -127,7 +127,8 @@ SOURCES=\ include/dialogs/help-keys.h\ include/dialogs/dmenuscriptshared.h\ resources/resources.c\ - resources/resources.h + resources/resources.h\ + source/keyb-layout.c rofi_SOURCES=\ lexer/theme-parser.y\ @@ -349,7 +350,8 @@ helper_pidfile_SOURCES=\ include/helper-theme.h\ include/xrmoptions.h\ source/xrmoptions.c\ - test/helper-pidfile.c + test/helper-pidfile.c\ + source/keyb-layout.c widget_test_LDADD=$(textbox_test_LDADD) widget_test_CFLAGS=$(textbox_test_CFLAGS) @@ -364,7 +366,8 @@ widget_test_SOURCES=\ config/config.c\ lexer/theme-parser.y\ lexer/theme-lexer.l\ - test/widget-test.c + test/widget-test.c\ + source/keyb-layout.c box_test_LDADD=$(textbox_test_LDADD) box_test_CFLAGS=$(textbox_test_CFLAGS) @@ -418,7 +421,8 @@ textbox_test_SOURCES=\ include/xrmoptions.h\ include/helper.h\ include/helper-theme.h\ - test/textbox-test.c + test/textbox-test.c\ + source/keyb-layout.c if USE_CHECK theme_parser_test_CFLAGS=${helper_test_CFLAGS} $(check_CFLAGS) @@ -442,7 +446,8 @@ theme_parser_test_SOURCES=\ source/rofi-types.c\ include/rofi-types.h\ source/css-colors.c\ - test/theme-parser-test.c + test/theme-parser-test.c\ + source/keyb-layout.c endif helper_test_SOURCES=\ @@ -457,7 +462,8 @@ helper_test_SOURCES=\ source/xrmoptions.c\ source/rofi-types.c\ include/rofi-types.h\ - test/helper-test.c + test/helper-test.c\ + source/keyb-layout.c helper_test_CFLAGS=\ @@ -499,7 +505,8 @@ helper_expand_SOURCES=\ source/xrmoptions.c\ source/rofi-types.c\ include/rofi-types.h\ - test/helper-expand.c + test/helper-expand.c\ + source/keyb-layout.c helper_expand_CFLAGS=${helper_test_CFLAGS} @@ -520,7 +527,8 @@ helper_config_cmdline_parser_SOURCES=\ include/helper-theme.h\ include/xrmoptions.h\ source/xrmoptions.c\ - test/helper-config-cmdline-parser.c + test/helper-config-cmdline-parser.c\ + source/keyb-layout.c if USE_CHECK @@ -537,7 +545,8 @@ mode_test_SOURCES=\ source/xrmoptions.c\ source/keyb.c\ include/mode.h\ - include/mode-private.h + include/mode-private.h\ + source/keyb-layout.c helper_tokenize_CFLAGS=$(textbox_test_CFLAGS) $(check_CFLAGS) helper_tokenize_LDADD=$(textbox_test_LDADD) $(check_LIBS) helper_tokenize_SOURCES=\ @@ -552,7 +561,8 @@ helper_tokenize_SOURCES=\ include/helper-theme.h\ include/xrmoptions.h\ source/xrmoptions.c\ - test/helper-tokenize.c + test/helper-tokenize.c\ + source/keyb-layout.c endif diff --git a/include/settings.h b/include/settings.h index bf477dc58..1f48a57a6 100644 --- a/include/settings.h +++ b/include/settings.h @@ -37,10 +37,10 @@ */ typedef enum { - MM_NORMAL = 0, - MM_REGEX = 1, - MM_GLOB = 2, - MM_FUZZY = 3, + MM_NORMAL = 0, + MM_REGEX = 1, + MM_GLOB = 2, + MM_FUZZY = 3, MM_ALL_KB_LAYOUTS = 4 } MatchingMethod; diff --git a/source/helper.c b/source/helper.c index 820db0e36..ed7084e00 100644 --- a/source/helper.c +++ b/source/helper.c @@ -80,7 +80,6 @@ void cmd_set_arguments ( int argc, char **argv ) stored_argv = argv; } - int helper_parse_setup ( char * string, char ***output, int *length, ... ) { GError *error = NULL; @@ -187,9 +186,9 @@ static gchar *all_kb_layouts_to_regex ( const char * input ) gchar *iter; for ( iter = input; iter && *iter != '\0'; iter = g_utf8_next_char ( iter ) ) { gchar *kblchs = kbl_charmap_for_char ( iter ); - gchar *r = g_regex_escape_string ( kblchs, -1 ); + gchar *r = g_regex_escape_string ( kblchs, -1 ); - g_string_append_printf( str, "[%s]", r); + g_string_append_printf ( str, "[%s]", r ); g_free ( kblchs ); g_free ( r ); } @@ -199,7 +198,6 @@ static gchar *all_kb_layouts_to_regex ( const char * input ) return retv; } - // Macro for quickly generating regex for matching. static inline GRegex * R ( const char *s, int case_sensitive ) { @@ -1145,12 +1143,13 @@ cairo_surface_t* cairo_image_surface_create_from_svg ( const gchar* file, int he static void parse_pair ( char *input, rofi_range_pair *item ) { // Skip leading blanks. - while ( input != NULL && isblank(*input) ) + while ( input != NULL && isblank ( *input ) ) { ++input; + } - const char *sep[] = { "-", ":" }; - int pythonic = ( strchr(input, ':') || input[0] == '-' ) ? 1 : 0; - int index = 0; + const char *sep[] = { "-", ":" }; + int pythonic = ( strchr ( input, ':' ) || input[0] == '-' ) ? 1 : 0; + int index = 0; for ( char *token = strsep ( &input, sep[pythonic] ); token != NULL; token = strsep ( &input, sep[pythonic] ) ) { if ( index == 0 ) { @@ -1218,12 +1217,13 @@ void rofi_output_formatted_line ( const char *format, const char *string, int se } else if ( format[i] == 'p' ) { char *esc = NULL; - pango_parse_markup(string, -1, 0, NULL, &esc, NULL, NULL); - if ( esc ){ + pango_parse_markup ( string, -1, 0, NULL, &esc, NULL, NULL ); + if ( esc ) { fputs ( esc, stdout ); g_free ( esc ); - } else { - fputs ( "invalid string" , stdout ); + } + else { + fputs ( "invalid string", stdout ); } } else if ( format[i] == 'q' ) { @@ -1251,15 +1251,14 @@ void rofi_output_formatted_line ( const char *format, const char *string, int se fflush ( stdout ); } - static gboolean helper_eval_cb2 ( const GMatchInfo *info, GString *res, gpointer data ) { gchar *match; // Get the match - int num_match = g_match_info_get_match_count(info); + int num_match = g_match_info_get_match_count ( info ); // Just {text} This is inside () 5. if ( num_match == 5 ) { - match = g_match_info_fetch ( info, 4); + match = g_match_info_fetch ( info, 4 ); if ( match != NULL ) { // Lookup the match, so we can replace it. gchar *r = g_hash_table_lookup ( (GHashTable *) data, match ); @@ -1273,21 +1272,21 @@ static gboolean helper_eval_cb2 ( const GMatchInfo *info, GString *res, gpointer } // {} with [] guard around it. else if ( num_match == 4 ) { - match = g_match_info_fetch ( info, 2); + match = g_match_info_fetch ( info, 2 ); if ( match != NULL ) { // Lookup the match, so we can replace it. gchar *r = g_hash_table_lookup ( (GHashTable *) data, match ); if ( r != NULL ) { // Add (optional) prefix - gchar *prefix = g_match_info_fetch (info, 1); + gchar *prefix = g_match_info_fetch ( info, 1 ); g_string_append ( res, prefix ); - g_free (prefix ); + g_free ( prefix ); // Append the replacement to the string. g_string_append ( res, r ); // Add (optional) postfix - gchar *post = g_match_info_fetch (info, 3); + gchar *post = g_match_info_fetch ( info, 3 ); g_string_append ( res, post ); - g_free (post ); + g_free ( post ); } // Free match. g_free ( match ); @@ -1302,7 +1301,7 @@ char *helper_string_replace_if_exists ( char * string, ... ) { GHashTable *h; h = g_hash_table_new ( g_str_hash, g_str_equal ); - va_list ap; + va_list ap; va_start ( ap, string ); // Add list from variable arguments. while ( 1 ) { @@ -1334,12 +1333,12 @@ char *helper_string_replace_if_exists ( char * string, ... ) */ char *helper_string_replace_if_exists_v ( char * string, GHashTable *h ) { - GError *error = NULL; - char *res = NULL; + GError *error = NULL; + char *res = NULL; // Replace hits within {-\w+}. GRegex *reg = g_regex_new ( "\\[(.*)({[-\\w]+})(.*)\\]|({[\\w-]+})", 0, 0, &error ); - if ( error == NULL ){ + if ( error == NULL ) { res = g_regex_replace_eval ( reg, string, -1, 0, 0, helper_eval_cb2, h, &error ); } // Free regex. diff --git a/source/keyb-layout.c b/source/keyb-layout.c index 4d0a017c3..ec55998c5 100644 --- a/source/keyb-layout.c +++ b/source/keyb-layout.c @@ -30,12 +30,13 @@ /** * Data structure corresponding to the relationship of the character to the layout */ -struct kbl_charmap { +struct kbl_charmap +{ xkb_layout_index_t layout; - xkb_level_index_t level; - xkb_keycode_t keycode; - int keysim; - gunichar chr; + xkb_level_index_t level; + xkb_keycode_t keycode; + int keysim; + gunichar chr; }; /** @@ -43,30 +44,31 @@ struct kbl_charmap { */ static GArray *rofi_kbl_charmap; -static void kbl_charmap_key_iter ( struct xkb_keymap *keymap, xkb_keycode_t key, void *data ) { +static void kbl_charmap_key_iter ( struct xkb_keymap *keymap, xkb_keycode_t key, void *data ) +{ const xkb_keysym_t *keysims; - char buffer[255]; - GArray *char_array = ( GArray* ) data; + char buffer[255]; + GArray *char_array = ( GArray * ) data; xkb_layout_index_t lt_count = xkb_keymap_num_layouts_for_key ( keymap, key ); if ( lt_count <= 1 ) { return; } - for ( xkb_layout_index_t lt_index = 0; lt_index < lt_count; lt_index ++ ) { + for ( xkb_layout_index_t lt_index = 0; lt_index < lt_count; lt_index++ ) { xkb_level_index_t lvl_count = xkb_keymap_num_levels_for_key ( keymap, key, lt_index ); for ( xkb_level_index_t lvl_index = 0; lvl_index < lvl_count; lvl_index++ ) { int ks_count = xkb_keymap_key_get_syms_by_level ( keymap, key, lt_index, lvl_index, &keysims ); - for ( int ks_index=0; ks_index < ks_count; ks_index++ ) { + for ( int ks_index = 0; ks_index < ks_count; ks_index++ ) { int char_count = xkb_keysym_to_utf8 ( keysims[ks_index], buffer, 255 ); if ( char_count > 0 ) { gunichar chr = g_utf8_get_char ( buffer ); if ( g_unichar_isdefined ( chr ) ) { struct kbl_charmap charmap_item = { - .layout = lt_index, - .level = lvl_index, + .layout = lt_index, + .level = lvl_index, .keycode = key, - .keysim = ks_index, - .chr = g_utf8_get_char ( buffer ) + .keysim = ks_index, + .chr = g_utf8_get_char ( buffer ) }; g_array_append_val ( char_array, charmap_item ); } @@ -76,7 +78,8 @@ static void kbl_charmap_key_iter ( struct xkb_keymap *keymap, xkb_keycode_t key, } } -void kbl_charmap_load_from_keymap ( struct xkb_keymap *keymap ) { +void kbl_charmap_load_from_keymap ( struct xkb_keymap *keymap ) +{ rofi_kbl_charmap = NULL; xkb_layout_index_t layout_count = xkb_keymap_num_layouts ( keymap ); if ( layout_count <= 1 ) { @@ -86,60 +89,63 @@ void kbl_charmap_load_from_keymap ( struct xkb_keymap *keymap ) { xkb_keymap_key_for_each ( keymap, kbl_charmap_key_iter, rofi_kbl_charmap ); } -void kbl_charmap_cleanup(void) { - g_array_free ( rofi_kbl_charmap, TRUE ); +void kbl_charmap_cleanup ( void ) +{ + if ( rofi_kbl_charmap ) { + g_array_free ( rofi_kbl_charmap, TRUE ); + } } -static gint kbl_charmap_find_char_key ( GArray *charmap, gunichar chr, struct kbl_charmap *key, gint next ) { - for ( guint i = ( guint ) next; ilen; i++ ) { +static gint kbl_charmap_find_char_key ( GArray *charmap, gunichar chr, struct kbl_charmap *key, gint next ) +{ + for ( guint i = ( guint ) next; i < charmap->len; i++ ) { struct kbl_charmap *charmap_item = &g_array_index ( charmap, struct kbl_charmap, i ); if ( charmap_item->chr == chr ) { - key->layout = charmap_item->layout; - key->level = charmap_item->level; + key->layout = charmap_item->layout; + key->level = charmap_item->level; key->keycode = charmap_item->keycode; - key->keysim = charmap_item->keysim; - key->chr = charmap_item->chr; + key->keysim = charmap_item->keysim; + key->chr = charmap_item->chr; return ( gint ) i; } } return -1; } -gchar *kbl_charmap_for_char ( const gchar *chr ) { - gint found = 0; +gchar *kbl_charmap_for_char ( const gchar *chr ) +{ + gint found = 0; struct kbl_charmap key_for_char; - gunichar uchar = g_utf8_get_char ( chr ); - GString * str = g_string_new ( "" ); + gunichar uchar = g_utf8_get_char ( chr ); + GString * str = g_string_new ( "" ); if ( rofi_kbl_charmap ) { - while ( ( found = kbl_charmap_find_char_key ( rofi_kbl_charmap, uchar, &key_for_char, found ) ) >= 0) { + while ( ( found = kbl_charmap_find_char_key ( rofi_kbl_charmap, uchar, &key_for_char, found ) ) >= 0 ) { for ( gint i = found; i >= 0; i-- ) { struct kbl_charmap *charmap_item = &g_array_index ( rofi_kbl_charmap, struct kbl_charmap, i ); if ( key_for_char.level == charmap_item->level && key_for_char.keycode == charmap_item->keycode && - key_for_char.keysim == charmap_item->keysim ) - { + key_for_char.keysim == charmap_item->keysim ) { g_string_append_unichar ( str, charmap_item->chr ); } - if (key_for_char.keycode != charmap_item->keycode) { + if ( key_for_char.keycode != charmap_item->keycode ) { break; } } - for ( guint i = ( guint ) found+1; i < rofi_kbl_charmap->len; i++ ) { + for ( guint i = ( guint ) found + 1; i < rofi_kbl_charmap->len; i++ ) { struct kbl_charmap *charmap_item = &g_array_index ( rofi_kbl_charmap, struct kbl_charmap, i ); if ( key_for_char.level == charmap_item->level && key_for_char.keycode == charmap_item->keycode && - key_for_char.keysim == charmap_item->keysim ) - { + key_for_char.keysim == charmap_item->keysim ) { g_string_append_unichar ( str, charmap_item->chr ); } - if (key_for_char.keycode != charmap_item->keycode) { + if ( key_for_char.keycode != charmap_item->keycode ) { break; } } found++; } } - if ( str->len ==0 ) { + if ( str->len == 0 ) { g_string_append_unichar ( str, uchar ); } gchar *retv = str->str; diff --git a/source/xcb.c b/source/xcb.c index 7fa56cd90..1b2fc6111 100644 --- a/source/xcb.c +++ b/source/xcb.c @@ -988,8 +988,8 @@ static int take_pointer ( xcb_window_t w, int iters ) break; } struct timespec del = { - .tv_sec = 0, - .tv_nsec = 1000000 + .tv_sec = 0, + .tv_nsec = 1000000 }; nanosleep ( &del, NULL ); } @@ -1019,8 +1019,8 @@ static int take_keyboard ( xcb_window_t w, int iters ) break; } struct timespec del = { - .tv_sec = 0, - .tv_nsec = 1000000 + .tv_sec = 0, + .tv_nsec = 1000000 }; nanosleep ( &del, NULL ); } @@ -1179,7 +1179,11 @@ gboolean display_setup ( GMainLoop *main_loop, NkBindings *bindings ) return FALSE; } - kbl_charmap_load_from_keymap(keymap); + char *matching_str; + find_arg_str ( "-matching", &matching_str ); + if ( g_strcmp0 ( matching_str, "all_kb_layouts" ) == 0 ) { + kbl_charmap_load_from_keymap ( keymap ); + } struct xkb_state *state = xkb_x11_state_new_from_device ( keymap, xcb->connection, xcb->xkb.device_id ); if ( state == NULL ) { @@ -1387,4 +1391,3 @@ void x11_disable_decoration ( xcb_window_t window ) xcb_atom_t ha = netatoms[_MOTIF_WM_HINTS]; xcb_change_property ( xcb->connection, XCB_PROP_MODE_REPLACE, window, ha, ha, 32, 5, &hints ); } - diff --git a/source/xrmoptions.c b/source/xrmoptions.c index a77e26548..fbd26ec90 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -81,144 +81,144 @@ typedef struct * Currently supports string, boolean and number (signed and unsigned). */ static XrmOption xrmOptions[] = { - { xrm_String, "switchers", { .str = &config.modi }, NULL, + { xrm_String, "switchers", { .str = &config.modi }, NULL, "", CONFIG_DEFAULT }, - { xrm_String, "modi", { .str = &config.modi }, NULL, + { xrm_String, "modi", { .str = &config.modi }, NULL, "Enabled modi", CONFIG_DEFAULT }, - { xrm_SNumber, "width", { .snum = &config.menu_width }, NULL, + { xrm_SNumber, "width", { .snum = &config.menu_width }, NULL, "Window width", CONFIG_DEFAULT }, - { xrm_Number, "lines", { .num = &config.menu_lines }, NULL, + { xrm_Number, "lines", { .num = &config.menu_lines }, NULL, "Number of lines", CONFIG_DEFAULT }, - { xrm_Number, "columns", { .num = &config.menu_columns }, NULL, + { xrm_Number, "columns", { .num = &config.menu_columns }, NULL, "Number of columns", CONFIG_DEFAULT }, - { xrm_String, "font", { .str = &config.menu_font }, NULL, + { xrm_String, "font", { .str = &config.menu_font }, NULL, "Font to use", CONFIG_DEFAULT }, - { xrm_Number, "borderwidth", { .num = &config.menu_bw }, NULL, + { xrm_Number, "borderwidth", { .num = &config.menu_bw }, NULL, "", CONFIG_DEFAULT }, - { xrm_Number, "bw", { .num = &config.menu_bw }, NULL, + { xrm_Number, "bw", { .num = &config.menu_bw }, NULL, "Border width", CONFIG_DEFAULT }, - { xrm_Number, "location", { .num = &config.location }, NULL, + { xrm_Number, "location", { .num = &config.location }, NULL, "Location on screen", CONFIG_DEFAULT }, - { xrm_Number, "padding", { .num = &config.padding }, NULL, + { xrm_Number, "padding", { .num = &config.padding }, NULL, "Padding", CONFIG_DEFAULT }, - { xrm_SNumber, "yoffset", { .snum = &config.y_offset }, NULL, + { xrm_SNumber, "yoffset", { .snum = &config.y_offset }, NULL, "Y-offset relative to location", CONFIG_DEFAULT }, - { xrm_SNumber, "xoffset", { .snum = &config.x_offset }, NULL, + { xrm_SNumber, "xoffset", { .snum = &config.x_offset }, NULL, "X-offset relative to location", CONFIG_DEFAULT }, - { xrm_Boolean, "fixed-num-lines", { .num = &config.fixed_num_lines }, NULL, + { xrm_Boolean, "fixed-num-lines", { .num = &config.fixed_num_lines }, NULL, "Always show number of lines", CONFIG_DEFAULT }, - { xrm_Boolean, "show-icons", { .snum = &config.show_icons }, NULL, + { xrm_Boolean, "show-icons", { .snum = &config.show_icons }, NULL, "Whether to load and show icons", CONFIG_DEFAULT }, - { xrm_String, "terminal", { .str = &config.terminal_emulator }, NULL, + { xrm_String, "terminal", { .str = &config.terminal_emulator }, NULL, "Terminal to use", CONFIG_DEFAULT }, - { xrm_String, "ssh-client", { .str = &config.ssh_client }, NULL, + { xrm_String, "ssh-client", { .str = &config.ssh_client }, NULL, "Ssh client to use", CONFIG_DEFAULT }, - { xrm_String, "ssh-command", { .str = &config.ssh_command }, NULL, + { xrm_String, "ssh-command", { .str = &config.ssh_command }, NULL, "Ssh command to execute", CONFIG_DEFAULT }, - { xrm_String, "run-command", { .str = &config.run_command }, NULL, + { xrm_String, "run-command", { .str = &config.run_command }, NULL, "Run command to execute", CONFIG_DEFAULT }, - { xrm_String, "run-list-command", { .str = &config.run_list_command }, NULL, + { xrm_String, "run-list-command", { .str = &config.run_list_command }, NULL, "Command to get extra run targets", CONFIG_DEFAULT }, - { xrm_String, "run-shell-command", { .str = &config.run_shell_command }, NULL, + { xrm_String, "run-shell-command", { .str = &config.run_shell_command }, NULL, "Run command to execute that runs in shell", CONFIG_DEFAULT }, - { xrm_String, "window-command", { .str = &config.window_command }, NULL, + { xrm_String, "window-command", { .str = &config.window_command }, NULL, "Command executed on accep-entry-custom for window modus", CONFIG_DEFAULT }, - { xrm_String, "window-match-fields", { .str = &config.window_match_fields }, NULL, + { xrm_String, "window-match-fields", { .str = &config.window_match_fields }, NULL, "Window fields to match in window mode", CONFIG_DEFAULT }, - { xrm_String, "icon-theme", { .str = &config.icon_theme }, NULL, + { xrm_String, "icon-theme", { .str = &config.icon_theme }, NULL, "Theme to use to look for icons", CONFIG_DEFAULT }, - { xrm_String, "drun-match-fields", { .str = &config.drun_match_fields }, NULL, + { xrm_String, "drun-match-fields", { .str = &config.drun_match_fields }, NULL, "Desktop entry fields to match in drun", CONFIG_DEFAULT }, - { xrm_Boolean, "drun-show-actions", { .num = &config.drun_show_actions }, NULL, + { xrm_Boolean, "drun-show-actions", { .num = &config.drun_show_actions }, NULL, "Desktop entry show actions.", CONFIG_DEFAULT }, - { xrm_String, "drun-display-format", { .str = &config.drun_display_format }, NULL, + { xrm_String, "drun-display-format", { .str = &config.drun_display_format }, NULL, "DRUN format string. (Supports: generic,name,comment,exec,categories)", CONFIG_DEFAULT }, - { xrm_Boolean, "disable-history", { .num = &config.disable_history }, NULL, + { xrm_Boolean, "disable-history", { .num = &config.disable_history }, NULL, "Disable history in run/ssh", CONFIG_DEFAULT }, - { xrm_String, "ignored-prefixes", { .str = &config.ignored_prefixes }, NULL, + { xrm_String, "ignored-prefixes", { .str = &config.ignored_prefixes }, NULL, "Programs ignored for history", CONFIG_DEFAULT }, - { xrm_Boolean, "sort", { .num = &config.sort }, NULL, + { xrm_Boolean, "sort", { .num = &config.sort }, NULL, "Use sorting", CONFIG_DEFAULT }, - { xrm_String, "sorting-method", { .str = &config.sorting_method }, NULL, + { xrm_String, "sorting-method", { .str = &config.sorting_method }, NULL, "Choose the strategy used for sorting: normal (levenshtein) or fzf.", CONFIG_DEFAULT }, - { xrm_Boolean, "case-sensitive", { .num = &config.case_sensitive }, NULL, + { xrm_Boolean, "case-sensitive", { .num = &config.case_sensitive }, NULL, "Set case-sensitivity", CONFIG_DEFAULT }, - { xrm_Boolean, "cycle", { .num = &config.cycle }, NULL, + { xrm_Boolean, "cycle", { .num = &config.cycle }, NULL, "Cycle through the results list", CONFIG_DEFAULT }, - { xrm_Boolean, "sidebar-mode", { .num = &config.sidebar_mode }, NULL, + { xrm_Boolean, "sidebar-mode", { .num = &config.sidebar_mode }, NULL, "Enable sidebar-mode", CONFIG_DEFAULT }, - { xrm_SNumber, "eh", { .snum = &config.element_height }, NULL, + { xrm_SNumber, "eh", { .snum = &config.element_height }, NULL, "Row height (in chars)", CONFIG_DEFAULT }, - { xrm_Boolean, "auto-select", { .num = &config.auto_select }, NULL, + { xrm_Boolean, "auto-select", { .num = &config.auto_select }, NULL, "Enable auto select mode", CONFIG_DEFAULT }, - { xrm_Boolean, "parse-hosts", { .num = &config.parse_hosts }, NULL, + { xrm_Boolean, "parse-hosts", { .num = &config.parse_hosts }, NULL, "Parse hosts file for ssh mode", CONFIG_DEFAULT }, - { xrm_Boolean, "parse-known-hosts", { .num = &config.parse_known_hosts }, NULL, + { xrm_Boolean, "parse-known-hosts", { .num = &config.parse_known_hosts }, NULL, "Parse known_hosts file for ssh mode", CONFIG_DEFAULT }, - { xrm_String, "combi-modi", { .str = &config.combi_modi }, NULL, + { xrm_String, "combi-modi", { .str = &config.combi_modi }, NULL, "Set the modi to combine in combi mode", CONFIG_DEFAULT }, - { xrm_String, "matching", { .str = &config.matching }, NULL, + { xrm_String, "matching", { .str = &config.matching }, NULL, "Set the matching algorithm. (normal, regex, glob, fuzzy, all_kb_layouts)", CONFIG_DEFAULT }, - { xrm_Boolean, "tokenize", { .num = &config.tokenize }, NULL, + { xrm_Boolean, "tokenize", { .num = &config.tokenize }, NULL, "Tokenize input string", CONFIG_DEFAULT }, - { xrm_String, "monitor", { .str = &config.monitor }, NULL, + { xrm_String, "monitor", { .str = &config.monitor }, NULL, "", CONFIG_DEFAULT }, /* Alias for dmenu compatibility. */ - { xrm_String, "m", { .str = &config.monitor }, NULL, + { xrm_String, "m", { .str = &config.monitor }, NULL, "Monitor id to show on", CONFIG_DEFAULT }, - { xrm_Number, "line-margin", { .num = &config.line_margin }, NULL, + { xrm_Number, "line-margin", { .num = &config.line_margin }, NULL, "Margin between rows *DEPRECATED*", CONFIG_DEFAULT }, - { xrm_Number, "line-padding", { .num = &config.line_padding }, NULL, + { xrm_Number, "line-padding", { .num = &config.line_padding }, NULL, "Padding within rows *DEPRECATED*", CONFIG_DEFAULT }, - { xrm_String, "filter", { .str = &config.filter }, NULL, + { xrm_String, "filter", { .str = &config.filter }, NULL, "Pre-set filter", CONFIG_DEFAULT }, - { xrm_String, "separator-style", { .str = &config.separator_style }, NULL, + { xrm_String, "separator-style", { .str = &config.separator_style }, NULL, "Separator style (none, dash, solid) *DEPRECATED*", CONFIG_DEFAULT }, - { xrm_Boolean, "hide-scrollbar", { .num = &config.hide_scrollbar }, NULL, + { xrm_Boolean, "hide-scrollbar", { .num = &config.hide_scrollbar }, NULL, "Hide scroll-bar *DEPRECATED*", CONFIG_DEFAULT }, - { xrm_Boolean, "fullscreen", { .num = &config.fullscreen }, NULL, + { xrm_Boolean, "fullscreen", { .num = &config.fullscreen }, NULL, "Fullscreen", CONFIG_DEFAULT }, - { xrm_Boolean, "fake-transparency", { .num = &config.fake_transparency }, NULL, + { xrm_Boolean, "fake-transparency", { .num = &config.fake_transparency }, NULL, "Fake transparency *DEPRECATED*", CONFIG_DEFAULT }, - { xrm_SNumber, "dpi", { .snum = &config.dpi }, NULL, + { xrm_SNumber, "dpi", { .snum = &config.dpi }, NULL, "DPI", CONFIG_DEFAULT }, - { xrm_Number, "threads", { .num = &config.threads }, NULL, + { xrm_Number, "threads", { .num = &config.threads }, NULL, "Threads to use for string matching", CONFIG_DEFAULT }, - { xrm_Number, "scrollbar-width", { .num = &config.scrollbar_width }, NULL, + { xrm_Number, "scrollbar-width", { .num = &config.scrollbar_width }, NULL, "Scrollbar width *DEPRECATED*", CONFIG_DEFAULT }, - { xrm_Number, "scroll-method", { .num = &config.scroll_method }, NULL, + { xrm_Number, "scroll-method", { .num = &config.scroll_method }, NULL, "Scrolling method. (0: Page, 1: Centered)", CONFIG_DEFAULT }, - { xrm_String, "fake-background", { .str = &config.fake_background }, NULL, + { xrm_String, "fake-background", { .str = &config.fake_background }, NULL, "Background to use for fake transparency. (background or screenshot) *DEPRECATED*", CONFIG_DEFAULT }, - { xrm_String, "window-format", { .str = &config.window_format }, NULL, + { xrm_String, "window-format", { .str = &config.window_format }, NULL, "Window Format. w (desktop name), t (title), n (name), r (role), c (class)", CONFIG_DEFAULT }, - { xrm_Boolean, "click-to-exit", { .snum = &config.click_to_exit }, NULL, + { xrm_Boolean, "click-to-exit", { .snum = &config.click_to_exit }, NULL, "Click outside the window to exit", CONFIG_DEFAULT }, - { xrm_Boolean, "show-match", { .snum = &config.show_match }, NULL, + { xrm_Boolean, "show-match", { .snum = &config.show_match }, NULL, "Indicate how it match by underlining it.", CONFIG_DEFAULT }, - { xrm_String, "theme", { .str = &config.theme }, NULL, + { xrm_String, "theme", { .str = &config.theme }, NULL, "New style theme file", CONFIG_DEFAULT }, - { xrm_String, "color-normal", { .str = &config.color_normal }, NULL, + { xrm_String, "color-normal", { .str = &config.color_normal }, NULL, "Color scheme for normal row", CONFIG_DEFAULT }, - { xrm_String, "color-urgent", { .str = &config.color_urgent }, NULL, + { xrm_String, "color-urgent", { .str = &config.color_urgent }, NULL, "Color scheme for urgent row", CONFIG_DEFAULT }, - { xrm_String, "color-active", { .str = &config.color_active }, NULL, + { xrm_String, "color-active", { .str = &config.color_active }, NULL, "Color scheme for active row", CONFIG_DEFAULT }, - { xrm_String, "color-window", { .str = &config.color_window }, NULL, + { xrm_String, "color-window", { .str = &config.color_window }, NULL, "Color scheme window", CONFIG_DEFAULT }, - { xrm_Number, "max-history-size", { .num = &config.max_history_size }, NULL, + { xrm_Number, "max-history-size", { .num = &config.max_history_size }, NULL, "Max history size (WARNING: can cause slowdowns when set to high).", CONFIG_DEFAULT }, - { xrm_Boolean, "combi-hide-mode-prefix", { .snum = &config.combi_hide_mode_prefix }, NULL, + { xrm_Boolean, "combi-hide-mode-prefix", { .snum = &config.combi_hide_mode_prefix }, NULL, "Hide the prefix mode prefix on the combi view.", CONFIG_DEFAULT }, - { xrm_Char, "matching-negate-char", { .charc= &config.matching_negate_char }, NULL, + { xrm_Char, "matching-negate-char", { .charc = &config.matching_negate_char }, NULL, "Set the character used to negate the matching. ('\\0' to disable)", CONFIG_DEFAULT }, - { xrm_String, "cache-dir", { .str = &config.cache_dir }, NULL, + { xrm_String, "cache-dir", { .str = &config.cache_dir }, NULL, "Directory where history and temporary files are stored.", CONFIG_DEFAULT }, }; From e80c2149956bfeb3f2d5abd35ffbb1c548b0a32e Mon Sep 17 00:00:00 2001 From: kabanov Date: Wed, 10 Jul 2019 15:08:37 +0500 Subject: [PATCH 3/4] fix manpage --- doc/rofi.1.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/rofi.1.markdown b/doc/rofi.1.markdown index e4225ee3c..a6a8ef962 100644 --- a/doc/rofi.1.markdown +++ b/doc/rofi.1.markdown @@ -224,6 +224,7 @@ Current the following methods are supported. * **regex**: match a regex input * **glob**: match a glob pattern * **fuzzy**: do a fuzzy match +* **all_kb_layouts**: normal with non-sensitivity to keyboard layout Default: *normal* From 74c1a494d9e17234e1fbb965f6203b6703c0470a Mon Sep 17 00:00:00 2001 From: kabanov Date: Mon, 26 Oct 2020 01:48:03 +0500 Subject: [PATCH 4/4] fix error --- source/keyb-layout.c | 2 +- source/xcb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/keyb-layout.c b/source/keyb-layout.c index ec55998c5..df4590045 100644 --- a/source/keyb-layout.c +++ b/source/keyb-layout.c @@ -42,7 +42,7 @@ struct kbl_charmap /** * Array of relationships of the character to the layout. Sorted by keycode */ -static GArray *rofi_kbl_charmap; +static GArray *rofi_kbl_charmap = NULL; static void kbl_charmap_key_iter ( struct xkb_keymap *keymap, xkb_keycode_t key, void *data ) { diff --git a/source/xcb.c b/source/xcb.c index f8f7c0ed2..e5568934b 100644 --- a/source/xcb.c +++ b/source/xcb.c @@ -1248,7 +1248,7 @@ gboolean display_setup ( GMainLoop *main_loop, NkBindings *bindings ) return FALSE; } - char *matching_str; + char *matching_str = NULL; find_arg_str ( "-matching", &matching_str ); if ( g_strcmp0 ( matching_str, "all_kb_layouts" ) == 0 ) { kbl_charmap_load_from_keymap ( keymap );