mirror of
https://github.com/lbonn/rofi
synced 2024-11-15 16:38:00 +00:00
Move fuzzy_token_match to where it can be reused.
This commit is contained in:
parent
67089677b5
commit
30743d1789
3 changed files with 27 additions and 25 deletions
|
@ -108,6 +108,10 @@ int token_match ( char **tokens, const char *input, int case_sensitive,
|
||||||
__attribute__( ( unused ) ) unsigned int index,
|
__attribute__( ( unused ) ) unsigned int index,
|
||||||
__attribute__( ( unused ) ) Switcher * data );
|
__attribute__( ( unused ) ) Switcher * data );
|
||||||
|
|
||||||
|
int fuzzy_token_match ( char **tokens, const char *input, int case_sensitive,
|
||||||
|
__attribute__( ( unused ) ) unsigned int index,
|
||||||
|
__attribute__( ( unused ) ) Switcher * data );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param cmd The command to execute.
|
* @param cmd The command to execute.
|
||||||
*
|
*
|
||||||
|
|
|
@ -178,31 +178,6 @@ static void dmenu_output_formatted_line ( const char *format, const char *string
|
||||||
fflush ( stdout );
|
fflush ( stdout );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int fuzzy_token_match ( char **tokens, const char *input, int case_sensitive,
|
|
||||||
__attribute__( ( unused ) ) unsigned int index,
|
|
||||||
__attribute__( ( unused ) ) Switcher * data )
|
|
||||||
{
|
|
||||||
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++ ) {
|
|
||||||
char *t = compk;
|
|
||||||
int token_len = strlen ( tokens[j] );
|
|
||||||
for ( int id = 0; match && t != NULL && id < token_len; id++ ) {
|
|
||||||
match = ( ( t = strchr ( t, tokens[j][id] ) ) != NULL );
|
|
||||||
// next should match the next character.
|
|
||||||
if(t != NULL) {
|
|
||||||
t++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_free ( compk );
|
|
||||||
return match;
|
|
||||||
}
|
|
||||||
|
|
||||||
int dmenu_switcher_dialog ( char **input )
|
int dmenu_switcher_dialog ( char **input )
|
||||||
{
|
{
|
||||||
char *dmenu_prompt = "dmenu ";
|
char *dmenu_prompt = "dmenu ";
|
||||||
|
|
|
@ -345,6 +345,29 @@ int token_match ( char **tokens, const char *input, int case_sensitive,
|
||||||
g_free ( compk );
|
g_free ( compk );
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
|
int fuzzy_token_match ( char **tokens, const char *input, int case_sensitive,
|
||||||
|
__attribute__( ( unused ) ) unsigned int index,
|
||||||
|
__attribute__( ( unused ) ) Switcher * data )
|
||||||
|
{
|
||||||
|
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++ ) {
|
||||||
|
char *t = compk;
|
||||||
|
int token_len = strlen ( tokens[j] );
|
||||||
|
for ( int id = 0; match && t != NULL && id < token_len; id++ ) {
|
||||||
|
match = ( ( t = strchr ( t, tokens[j][id] ) ) != NULL );
|
||||||
|
// next should match the next character.
|
||||||
|
if ( t != NULL ) {
|
||||||
|
t++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_free ( compk );
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
|
||||||
int execute_generator ( const char * cmd )
|
int execute_generator ( const char * cmd )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue