mirror of
https://github.com/lbonn/rofi
synced 2024-11-15 00:27:36 +00:00
Add tokenize option and append * to glob.
This commit is contained in:
parent
1369c162fe
commit
6b039ac524
5 changed files with 30 additions and 7 deletions
|
@ -131,6 +131,7 @@ Settings config = {
|
|||
/** Fuzzy matching. */
|
||||
.fuzzy = FALSE,
|
||||
.glob = FALSE,
|
||||
.tokenize = FALSE,
|
||||
/** Monitor */
|
||||
.monitor = -1,
|
||||
/** set line margin */
|
||||
|
|
|
@ -231,6 +231,7 @@ typedef struct _Settings
|
|||
/** Fuzzy match */
|
||||
unsigned int fuzzy;
|
||||
unsigned int glob;
|
||||
unsigned int tokenize;
|
||||
/** Monitors */
|
||||
int monitor;
|
||||
/** Line margin */
|
||||
|
|
|
@ -176,6 +176,19 @@ char **tokenize ( const char *input, int case_sensitive )
|
|||
|
||||
char *saveptr = NULL, *token;
|
||||
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.
|
||||
int num_tokens = 0;
|
||||
|
||||
|
@ -186,7 +199,14 @@ char **tokenize ( const char *input, int case_sensitive )
|
|||
// strtok should still be valid for utf8.
|
||||
for ( token = strtok_r ( str, " ", &saveptr ); token != NULL; token = strtok_r ( NULL, " ", &saveptr ) ) {
|
||||
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 + 1] = NULL;
|
||||
num_tokens++;
|
||||
}
|
||||
|
|
|
@ -123,6 +123,7 @@ static XrmOption xrmOptions[] = {
|
|||
{ xrm_String, "combi-modi", { .str = &config.combi_modi }, NULL },
|
||||
{ xrm_Boolean, "fuzzy", { .num = &config.fuzzy }, NULL },
|
||||
{ xrm_Boolean, "glob", { .num = &config.glob }, NULL },
|
||||
{ xrm_Boolean, "tokenize", { .num = &config.tokenize }, 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