From 6b96ae123bd9bd0a1d13f3deebb560b45eeef80d Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Fri, 14 Dec 2018 16:58:26 +0100 Subject: [PATCH] Add an option to change the matching negation character. Fixes: #877 --- config/config.c | 2 ++ doc/test_xr.txt | 2 ++ include/settings.h | 2 ++ source/helper.c | 2 +- source/xrmoptions.c | 2 ++ 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/config/config.c b/config/config.c index d10876c0..8e2bc62a 100644 --- a/config/config.c +++ b/config/config.c @@ -152,4 +152,6 @@ Settings config = { .plugin_path = PLUGIN_PATH, .max_history_size = 25, .combi_hide_mode_prefix = FALSE, + + .matching_negate_char = '-', }; diff --git a/doc/test_xr.txt b/doc/test_xr.txt index adcf0a63..dc1453eb 100644 --- a/doc/test_xr.txt +++ b/doc/test_xr.txt @@ -118,6 +118,8 @@ rofi.scroll-method: 0 ! rofi.max-history-size: 25 ! "Hide the prefix mode prefix on the combi view." Set from: Default ! rofi.combi-hide-mode-prefix: false +! "Set the character used to negate the matching. ('\0' to disable)" Set from: Default +! rofi.matching-negate-char: - ! "Pidfile location" Set from: File rofi.pid: /tmp/rofi.pid ! "Paste primary selection" Set from: File diff --git a/include/settings.h b/include/settings.h index 74580611..db7f4f7d 100644 --- a/include/settings.h +++ b/include/settings.h @@ -177,6 +177,8 @@ typedef struct /** Maximum history length per mode. */ unsigned int max_history_size; gboolean combi_hide_mode_prefix; + + char matching_negate_char; } Settings; /** Global Settings structure. */ extern Settings config; diff --git a/source/helper.c b/source/helper.c index 788eb489..3174d34d 100644 --- a/source/helper.c +++ b/source/helper.c @@ -221,7 +221,7 @@ static rofi_int_matcher * create_regex ( const char *input, int case_sensitive ) GRegex * retv = NULL; gchar *r; rofi_int_matcher *rv = g_malloc0 ( sizeof ( rofi_int_matcher ) ); - if ( input && input[0] == '-' ) { + if ( input && input[0] == config.matching_negate_char ) { rv->invert = 1; input++; } diff --git a/source/xrmoptions.c b/source/xrmoptions.c index c8eb37cd..cb05a9b4 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -214,6 +214,8 @@ static XrmOption xrmOptions[] = { "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, "Hide the prefix mode prefix on the combi view.", CONFIG_DEFAULT }, + { xrm_Char, "matching-negate-char", { .charc= &config.matching_negate_char }, NULL, + "Set the character used to negate the matching. ('\\0' to disable)", CONFIG_DEFAULT }, }; /** Dynamic array of extra options */