mirror of https://github.com/davatorium/rofi.git
Add tokenize option and append * to glob.
This commit is contained in:
parent
1369c162fe
commit
6b039ac524
|
@ -131,6 +131,7 @@ Settings config = {
|
||||||
/** Fuzzy matching. */
|
/** Fuzzy matching. */
|
||||||
.fuzzy = FALSE,
|
.fuzzy = FALSE,
|
||||||
.glob = FALSE,
|
.glob = FALSE,
|
||||||
|
.tokenize = FALSE,
|
||||||
/** Monitor */
|
/** Monitor */
|
||||||
.monitor = -1,
|
.monitor = -1,
|
||||||
/** set line margin */
|
/** set line margin */
|
||||||
|
|
|
@ -231,6 +231,7 @@ typedef struct _Settings
|
||||||
/** Fuzzy match */
|
/** Fuzzy match */
|
||||||
unsigned int fuzzy;
|
unsigned int fuzzy;
|
||||||
unsigned int glob;
|
unsigned int glob;
|
||||||
|
unsigned int tokenize;
|
||||||
/** Monitors */
|
/** Monitors */
|
||||||
int monitor;
|
int monitor;
|
||||||
/** Line margin */
|
/** Line margin */
|
||||||
|
|
|
@ -176,6 +176,19 @@ char **tokenize ( const char *input, int case_sensitive )
|
||||||
|
|
||||||
char *saveptr = NULL, *token;
|
char *saveptr = NULL, *token;
|
||||||
char **retv = NULL;
|
char **retv = NULL;
|
||||||
|
if ( !config.tokenize ) {
|
||||||
|
retv = g_malloc0 ( sizeof ( char* ) * 2 );
|
||||||
|
if ( config.glob ) {
|
||||||
|
token = g_strconcat ( input, "*", NULL );
|
||||||
|
retv[0] = token_collate_key ( token, case_sensitive );
|
||||||
|
g_free ( token ); token = NULL;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
token = token_collate_key ( input, case_sensitive );
|
||||||
|
}
|
||||||
|
return retv;
|
||||||
|
}
|
||||||
|
|
||||||
// First entry is always full (modified) stringtext.
|
// First entry is always full (modified) stringtext.
|
||||||
int num_tokens = 0;
|
int num_tokens = 0;
|
||||||
|
|
||||||
|
@ -186,7 +199,14 @@ char **tokenize ( const char *input, int case_sensitive )
|
||||||
// strtok should still be valid for utf8.
|
// strtok should still be valid for utf8.
|
||||||
for ( token = strtok_r ( str, " ", &saveptr ); token != NULL; token = strtok_r ( NULL, " ", &saveptr ) ) {
|
for ( token = strtok_r ( str, " ", &saveptr ); token != NULL; token = strtok_r ( NULL, " ", &saveptr ) ) {
|
||||||
retv = g_realloc ( retv, sizeof ( char* ) * ( num_tokens + 2 ) );
|
retv = g_realloc ( retv, sizeof ( char* ) * ( num_tokens + 2 ) );
|
||||||
|
if ( config.glob ) {
|
||||||
|
char *t = token_collate_key ( token, case_sensitive );
|
||||||
|
retv[num_tokens] = g_strconcat ( t, "*", NULL );
|
||||||
|
g_free ( t );
|
||||||
|
}
|
||||||
|
else {
|
||||||
retv[num_tokens] = token_collate_key ( token, case_sensitive );
|
retv[num_tokens] = token_collate_key ( token, case_sensitive );
|
||||||
|
}
|
||||||
retv[num_tokens + 1] = NULL;
|
retv[num_tokens + 1] = NULL;
|
||||||
num_tokens++;
|
num_tokens++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,6 +123,7 @@ static XrmOption xrmOptions[] = {
|
||||||
{ xrm_String, "combi-modi", { .str = &config.combi_modi }, NULL },
|
{ xrm_String, "combi-modi", { .str = &config.combi_modi }, NULL },
|
||||||
{ xrm_Boolean, "fuzzy", { .num = &config.fuzzy }, NULL },
|
{ xrm_Boolean, "fuzzy", { .num = &config.fuzzy }, NULL },
|
||||||
{ xrm_Boolean, "glob", { .num = &config.glob }, NULL },
|
{ xrm_Boolean, "glob", { .num = &config.glob }, NULL },
|
||||||
|
{ xrm_Boolean, "tokenize", { .num = &config.tokenize }, NULL },
|
||||||
{ xrm_Number, "monitor", { .snum = &config.monitor }, NULL },
|
{ xrm_Number, "monitor", { .snum = &config.monitor }, NULL },
|
||||||
/* Alias for dmenu compatibility. */
|
/* Alias for dmenu compatibility. */
|
||||||
{ xrm_SNumber, "m", { .snum = &config.monitor }, NULL },
|
{ xrm_SNumber, "m", { .snum = &config.monitor }, NULL },
|
||||||
|
|
Loading…
Reference in New Issue