mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
add prefix matching method feature (#1237)
* add prefix matching method feature * Update helper.c * prefix matching regex memory leak fix * prefix matching regex memory leak fix Co-authored-by: francis <oxfrancis@outlook.com>
This commit is contained in:
parent
24dde58019
commit
c3e70d4e1a
6 changed files with 37 additions and 17 deletions
|
@ -410,6 +410,8 @@ Current the following methods are supported.
|
|||
\fBglob\fP: match a glob pattern
|
||||
.IP \(bu 2
|
||||
\fBfuzzy\fP: do a fuzzy match
|
||||
.IP \(bu 2
|
||||
\fBprefix\fP: match prefix
|
||||
|
||||
.RE
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ Select the scrolling method. 0: Per page, 1: continuous.
|
|||
|
||||
Normalize the string before matching, so o will match ö, and é matches e.
|
||||
This is not a perfect implementation, but works.
|
||||
For now it disabled highlighting of the matched part.
|
||||
For now it disabled highlighting of the matched part.
|
||||
|
||||
`-no-lazy-grab`
|
||||
|
||||
|
@ -244,6 +244,7 @@ Current the following methods are supported.
|
|||
* **regex**: match a regex input
|
||||
* **glob**: match a glob pattern
|
||||
* **fuzzy**: do a fuzzy match
|
||||
* **prefix**: match prefix
|
||||
|
||||
Default: *normal*
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ rofi.ssh-command: {terminal} -e {ssh-client} {host}
|
|||
! "Run command to execute" Set from: File
|
||||
rofi.run-command: bash -c "{cmd}"
|
||||
! "Command to get extra run targets" Set from: Default
|
||||
! rofi.run-list-command:
|
||||
! rofi.run-list-command:
|
||||
! "Run command to execute that runs in shell" Set from: File
|
||||
rofi.run-shell-command: {terminal} -e {cmd}
|
||||
! "Command executed on accep-entry-custom for window modus" Set from: File
|
||||
|
@ -39,11 +39,11 @@ rofi.window-command: xkill -id {window}
|
|||
! "Window fields to match in window mode" Set from: Default
|
||||
! rofi.window-match-fields: all
|
||||
! "Theme to use to look for icons" Set from: Default
|
||||
! rofi.icon-theme:
|
||||
! rofi.icon-theme:
|
||||
! "Desktop entry fields to match in drun" Set from: Default
|
||||
! rofi.drun-match-fields: name,generic,exec,categories,keywords
|
||||
! "Only show Desktop entry from these categories" Set from: Default
|
||||
! rofi.drun-categories:
|
||||
! rofi.drun-categories:
|
||||
! "Desktop entry show actions." Set from: Default
|
||||
! rofi.drun-show-actions: false
|
||||
! "DRUN format string. (Supports: generic,name,comment,exec,categories)" Set from: Default
|
||||
|
@ -51,11 +51,11 @@ rofi.window-command: xkill -id {window}
|
|||
! "Disable history in run/ssh" Set from: File
|
||||
rofi.disable-history: false
|
||||
! "Programs ignored for history" Set from: Default
|
||||
! rofi.ignored-prefixes:
|
||||
! rofi.ignored-prefixes:
|
||||
! "Use sorting" Set from: Default
|
||||
! rofi.sort: false
|
||||
! "Choose the strategy used for sorting: normal (levenshtein) or fzf." Set from: Default
|
||||
! rofi.sorting-method:
|
||||
! rofi.sorting-method:
|
||||
! "Set case-sensitivity" Set from: File
|
||||
rofi.case-sensitive: false
|
||||
! "Cycle through the results list" Set from: File
|
||||
|
@ -72,7 +72,7 @@ rofi.parse-hosts: false
|
|||
rofi.parse-known-hosts: true
|
||||
! "Set the modi to combine in combi mode" Set from: File
|
||||
rofi.combi-modi: window,drun,run,ssh
|
||||
! "Set the matching algorithm. (normal, regex, glob, fuzzy)" Set from: Default
|
||||
! "Set the matching algorithm. (normal, regex, glob, fuzzy, prefix)" Set from: Default
|
||||
! rofi.matching: normal
|
||||
! "Tokenize input string" Set from: File
|
||||
rofi.tokenize: true
|
||||
|
@ -83,7 +83,7 @@ rofi.m: -1
|
|||
! "Padding within rows *DEPRECATED*" Set from: Default
|
||||
! rofi.line-padding: 1
|
||||
! "Pre-set filter" Set from: Default
|
||||
! rofi.filter:
|
||||
! rofi.filter:
|
||||
! "Separator style (none, dash, solid) *DEPRECATED*" Set from: Default
|
||||
! rofi.separator-style: dash
|
||||
! "Hide scroll-bar *DEPRECATED*" Set from: Default
|
||||
|
@ -107,15 +107,15 @@ rofi.scroll-method: 0
|
|||
! "Click outside the window to exit" Set from: Default
|
||||
! rofi.click-to-exit: true
|
||||
! "New style theme file" Set from: Default
|
||||
! rofi.theme:
|
||||
! rofi.theme:
|
||||
! "Color scheme for normal row" Set from: Default
|
||||
! rofi.color-normal:
|
||||
! rofi.color-normal:
|
||||
! "Color scheme for urgent row" Set from: Default
|
||||
! rofi.color-urgent:
|
||||
! rofi.color-urgent:
|
||||
! "Color scheme for active row" Set from: Default
|
||||
! rofi.color-active:
|
||||
! rofi.color-active:
|
||||
! "Color scheme window" Set from: Default
|
||||
! rofi.color-window:
|
||||
! rofi.color-window:
|
||||
! "Max history size (WARNING: can cause slowdowns when set to high)." Set from: Default
|
||||
! rofi.max-history-size: 25
|
||||
! "Hide the prefix mode prefix on the combi view." Set from: Default
|
||||
|
@ -123,7 +123,7 @@ rofi.scroll-method: 0
|
|||
! "Set the character used to negate the matching. ('\0' to disable)" Set from: Default
|
||||
! rofi.matching-negate-char: -
|
||||
! "Directory where history and temporary files are stored." Set from: Default
|
||||
! rofi.cache-dir:
|
||||
! rofi.cache-dir:
|
||||
! "Show window thumbnail in window switcher if availalbe." Set from: Default
|
||||
! rofi.window-thumbnail: false
|
||||
! "Pidfile location" Set from: File
|
||||
|
|
|
@ -40,7 +40,8 @@ typedef enum
|
|||
MM_NORMAL = 0,
|
||||
MM_REGEX = 1,
|
||||
MM_GLOB = 2,
|
||||
MM_FUZZY = 3
|
||||
MM_FUZZY = 3,
|
||||
MM_PREFIX = 4
|
||||
} MatchingMethod;
|
||||
|
||||
/**
|
||||
|
|
|
@ -179,6 +179,14 @@ static gchar *fuzzy_to_regex ( const char * input )
|
|||
return retv;
|
||||
}
|
||||
|
||||
static gchar *prefix_regex (const char * input)
|
||||
{
|
||||
gchar *r = g_regex_escape_string(input, -1);
|
||||
char *retv = g_strconcat("\\b", r, NULL);
|
||||
g_free(r);
|
||||
return retv;
|
||||
}
|
||||
|
||||
static char *utf8_helper_simplify_string ( const char *s )
|
||||
{
|
||||
gunichar buf2[G_UNICHAR_MAX_DECOMPOSITION_LENGTH] = { 0, };
|
||||
|
@ -248,6 +256,11 @@ static rofi_int_matcher * create_regex ( const char *input, int case_sensitive )
|
|||
retv = R ( r, case_sensitive );
|
||||
g_free ( r );
|
||||
break;
|
||||
case MM_PREFIX:
|
||||
r = prefix_regex(input);
|
||||
retv = R(r, case_sensitive);
|
||||
g_free(r);
|
||||
break;
|
||||
default:
|
||||
r = g_regex_escape_string ( input, -1 );
|
||||
retv = R ( r, case_sensitive );
|
||||
|
@ -632,8 +645,11 @@ int config_sanity_check ( void )
|
|||
else if ( g_strcmp0 ( config.matching, "normal" ) == 0 ) {
|
||||
config.matching_method = MM_NORMAL;;
|
||||
}
|
||||
else if (g_strcmp0 (config.matching, "prefix") == 0) {
|
||||
config.matching_method = MM_PREFIX;
|
||||
}
|
||||
else {
|
||||
g_string_append_printf ( msg, "\t<b>config.matching</b>=%s is not a valid matching strategy.\nValid options are: glob, regex, fuzzy or normal.\n",
|
||||
g_string_append_printf ( msg, "\t<b>config.matching</b>=%s is not a valid matching strategy.\nValid options are: glob, regex, fuzzy, prefix or normal.\n",
|
||||
config.matching );
|
||||
found_error = 1;
|
||||
}
|
||||
|
|
|
@ -169,7 +169,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, prefix)", CONFIG_DEFAULT },
|
||||
{ xrm_Boolean, "tokenize", { .num = &config.tokenize }, NULL,
|
||||
"Tokenize input string", CONFIG_DEFAULT },
|
||||
{ xrm_String, "monitor", { .str = &config.monitor }, NULL,
|
||||
|
|
Loading…
Reference in a new issue