mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-11 13:50:48 -05:00
Add glob version for testing.
This commit is contained in:
parent
e3115be103
commit
5de38cd755
5 changed files with 27 additions and 5 deletions
|
@ -129,7 +129,8 @@ Settings config = {
|
|||
/** Modi to combine into one view. */
|
||||
.combi_modi = "window,run",
|
||||
/** Fuzzy matching. */
|
||||
.fuzzy = FALSE,
|
||||
.fuzzy = FALSE,
|
||||
.glob = FALSE,
|
||||
/** Monitor */
|
||||
.monitor = -1,
|
||||
/** set line margin */
|
||||
|
|
|
@ -230,6 +230,7 @@ typedef struct _Settings
|
|||
char *combi_modi;
|
||||
/** Fuzzy match */
|
||||
unsigned int fuzzy;
|
||||
unsigned int glob;
|
||||
/** Monitors */
|
||||
int monitor;
|
||||
/** Line margin */
|
||||
|
|
|
@ -59,8 +59,9 @@ typedef struct _DmenuModePrivateData
|
|||
|
||||
static char **get_dmenu ( unsigned int *length )
|
||||
{
|
||||
char buffer[1024];
|
||||
char **retv = NULL;
|
||||
GTimer *t = g_timer_new ();
|
||||
char buffer[1024];
|
||||
char **retv = NULL;
|
||||
|
||||
*length = 0;
|
||||
|
||||
|
@ -80,7 +81,8 @@ static char **get_dmenu ( unsigned int *length )
|
|||
return retv;
|
||||
}
|
||||
}
|
||||
|
||||
g_timer_stop ( t );
|
||||
printf ( "%.4f\n", g_timer_elapsed ( t, NULL ) );
|
||||
return retv;
|
||||
}
|
||||
|
||||
|
|
|
@ -345,11 +345,28 @@ static int normal_token_match ( char **tokens, const char *input, int case_sensi
|
|||
g_free ( compk );
|
||||
return match;
|
||||
}
|
||||
static int glob_token_match ( char **tokens, const char *input, int case_sensitive )
|
||||
{
|
||||
int match = 1;
|
||||
char *compk = token_collate_key ( input, case_sensitive );
|
||||
|
||||
// Do a tokenized match.
|
||||
if ( tokens ) {
|
||||
for ( int j = 0; match && tokens[j]; j++ ) {
|
||||
match = g_pattern_match_simple ( tokens[j], compk );
|
||||
}
|
||||
}
|
||||
g_free ( compk );
|
||||
return match;
|
||||
}
|
||||
int token_match ( char **tokens, const char *input, int case_sensitive,
|
||||
__attribute__( ( unused ) ) unsigned int index,
|
||||
__attribute__( ( unused ) ) Switcher *data )
|
||||
{
|
||||
if ( config.fuzzy ) {
|
||||
if ( config.glob ) {
|
||||
return glob_token_match ( tokens, input, case_sensitive );
|
||||
}
|
||||
else if ( config.fuzzy ) {
|
||||
return fuzzy_token_match ( tokens, input, case_sensitive );
|
||||
}
|
||||
return normal_token_match ( tokens, input, case_sensitive );
|
||||
|
|
|
@ -122,6 +122,7 @@ static XrmOption xrmOptions[] = {
|
|||
{ xrm_Boolean, "parse-hosts", { .num = &config.parse_hosts }, NULL },
|
||||
{ xrm_String, "combi-modi", { .str = &config.combi_modi }, NULL },
|
||||
{ xrm_Boolean, "fuzzy", { .num = &config.fuzzy }, NULL },
|
||||
{ xrm_Boolean, "glob", { .num = &config.glob }, NULL },
|
||||
{ xrm_Number, "monitor", { .snum = &config.monitor }, NULL },
|
||||
/* Alias for dmenu compatibility. */
|
||||
{ xrm_SNumber, "m", { .snum = &config.monitor }, NULL },
|
||||
|
|
Loading…
Reference in a new issue