summaryrefslogtreecommitdiffstats
path: root/source/dialogs
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-05-22 17:47:34 +0200
committerDave Davenport <qball@gmpclient.org>2016-05-22 17:47:34 +0200
commit498fadc735df509ef0a864db1e93d2120d8eb9ee (patch)
tree8d322b8736c615cc0ba51c9b40ad30d3a9668480 /source/dialogs
parent8091558ed8234914b398fe288aaccfe9770dac9c (diff)
Remove the is_ascii mess.
Diffstat (limited to 'source/dialogs')
-rw-r--r--source/dialogs/combi.c21
-rw-r--r--source/dialogs/dmenu.c23
-rw-r--r--source/dialogs/drun.c25
-rw-r--r--source/dialogs/run.c11
-rw-r--r--source/dialogs/script.c11
-rw-r--r--source/dialogs/ssh.c20
-rw-r--r--source/dialogs/window.c35
7 files changed, 30 insertions, 116 deletions
diff --git a/source/dialogs/combi.c b/source/dialogs/combi.c
index 5ab58940..89c634b8 100644
--- a/source/dialogs/combi.c
+++ b/source/dialogs/combi.c
@@ -175,18 +175,17 @@ static ModeMode combi_mode_result ( Mode *sw, int mretv, char **input, unsigned
}
return MODE_EXIT;
}
-static int combi_mode_match ( const Mode *sw, char **tokens, int not_ascii,
- int case_sensitive, unsigned int index )
+static int combi_mode_match ( const Mode *sw, GRegex **tokens, unsigned int index )
{
CombiModePrivateData *pd = mode_get_private_data ( sw );
- if ( config.regex || config.glob ) {
+// if ( config.regex || config.glob ) {
// Bang support only works in text mode.
for ( unsigned i = 0; i < pd->num_switchers; i++ ) {
if ( index >= pd->starts[i] && index < ( pd->starts[i] + pd->lengths[i] ) ) {
- return mode_token_match ( pd->switchers[i], tokens, not_ascii, case_sensitive,
- index - pd->starts[i] );
+ return mode_token_match ( pd->switchers[i], tokens, index - pd->starts[i] );
}
}
+ /* @TODO fix this
}
else{
for ( unsigned i = 0; i < pd->num_switchers; i++ ) {
@@ -205,6 +204,7 @@ static int combi_mode_match ( const Mode *sw, char **tokens, int not_ascii,
}
}
}
+ */
abort ();
return 0;
}
@@ -231,16 +231,6 @@ static char * combi_mgrv ( const Mode *sw, unsigned int selected_line, int *stat
return NULL;
}
-static int combi_is_not_ascii ( const Mode *sw, unsigned int index )
-{
- CombiModePrivateData *pd = mode_get_private_data ( sw );
- for ( unsigned i = 0; i < pd->num_switchers; i++ ) {
- if ( index >= pd->starts[i] && index < ( pd->starts[i] + pd->lengths[i] ) ) {
- return mode_is_not_ascii ( pd->switchers[i], index - pd->starts[i] );
- }
- }
- return FALSE;
-}
static char * combi_get_completion ( const Mode *sw, unsigned int index )
{
CombiModePrivateData *pd = mode_get_private_data ( sw );
@@ -269,7 +259,6 @@ Mode combi_mode =
._token_match = combi_mode_match,
._get_completion = combi_get_completion,
._get_display_value = combi_mgrv,
- ._is_not_ascii = combi_is_not_ascii,
.private_data = NULL,
.free = NULL
};
diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c
index 56f397bf..4d4cdbbc 100644
--- a/source/dialogs/dmenu.c
+++ b/source/dialogs/dmenu.c
@@ -332,16 +332,10 @@ static int dmenu_mode_init ( Mode *sw )
return TRUE;
}
-static int dmenu_token_match ( const Mode *sw, char **tokens, int not_ascii, int case_sensitive, unsigned int index )
+static int dmenu_token_match ( const Mode *sw, GRegex **tokens, unsigned int index )
{
DmenuModePrivateData *rmpd = (DmenuModePrivateData *) mode_get_private_data ( sw );
- return token_match ( tokens, rmpd->cmd_list[index], not_ascii, case_sensitive );
-}
-
-static int dmenu_is_not_ascii ( const Mode *sw, unsigned int index )
-{
- DmenuModePrivateData *rmpd = (DmenuModePrivateData *) mode_get_private_data ( sw );
- return !g_str_is_ascii ( rmpd->cmd_list[index] );
+ return token_match ( tokens, rmpd->cmd_list[index] );
}
#include "mode-private.h"
@@ -356,7 +350,6 @@ Mode dmenu_mode =
._token_match = dmenu_token_match,
._get_display_value = get_display_data,
._get_completion = NULL,
- ._is_not_ascii = dmenu_is_not_ascii,
.private_data = NULL,
.free = NULL
};
@@ -516,25 +509,25 @@ int dmenu_switcher_dialog ( void )
char *select = NULL;
find_arg_str ( "-select", &select );
if ( select != NULL ) {
- char **tokens = tokenize ( select, config.case_sensitive );
+ GRegex **tokens = tokenize ( select, config.case_sensitive );
unsigned int i = 0;
for ( i = 0; i < cmd_list_length; i++ ) {
- if ( token_match ( tokens, cmd_list[i], !g_str_is_ascii ( cmd_list[i] ), config.case_sensitive ) ) {
+ if ( token_match ( tokens, cmd_list[i] ) ) {
pd->selected_line = i;
break;
}
}
- g_strfreev ( tokens );
+ tokenize_free ( tokens );
}
if ( find_arg ( "-dump" ) >= 0 ) {
- char **tokens = tokenize ( config.filter ? config.filter : "", config.case_sensitive );
+ GRegex **tokens = tokenize ( config.filter ? config.filter : "", config.case_sensitive );
unsigned int i = 0;
for ( i = 0; i < cmd_list_length; i++ ) {
- if ( token_match ( tokens, cmd_list[i], !g_str_is_ascii ( cmd_list[i] ), config.case_sensitive ) ) {
+ if ( token_match ( tokens, cmd_list[i] ) ) {
dmenu_output_formatted_line ( pd->format, cmd_list[i], i, config.filter );
}
}
- g_strfreev ( tokens );
+ tokenize_free ( tokens );
return TRUE;
}
// TODO remove
diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c
index 5f063701..39fee13f 100644
--- a/source/dialogs/drun.c
+++ b/source/dialogs/drun.c
@@ -378,29 +378,24 @@ static char *drun_get_completion ( const Mode *sw, unsigned int index )
}
}
-static int drun_token_match ( const Mode *data,
- char **tokens,
- int not_ascii,
- int case_sensitive,
- unsigned int index
- )
+static int drun_token_match ( const Mode *data, GRegex **tokens, unsigned int index)
{
DRunModePrivateData *rmpd = (DRunModePrivateData *) mode_get_private_data ( data );
int match = 1;
if ( tokens ) {
for ( int j = 0; match && tokens != NULL && tokens[j] != NULL; j++ ) {
int test = 0;
- char *ftokens[2] = { tokens[j], NULL };
+ GRegex *ftokens[2] = { tokens[j], NULL };
if ( !test && rmpd->entry_list[index].name &&
- token_match ( ftokens, rmpd->entry_list[index].name, not_ascii, case_sensitive ) ) {
+ token_match ( ftokens, rmpd->entry_list[index].name ) ) {
test = 1;
}
if ( !test && rmpd->entry_list[index].generic_name &&
- token_match ( ftokens, rmpd->entry_list[index].generic_name, not_ascii, case_sensitive ) ) {
+ token_match ( ftokens, rmpd->entry_list[index].generic_name) ) {
test = 1;
}
- if ( !test && token_match ( ftokens, rmpd->entry_list[index].exec, not_ascii, case_sensitive ) ) {
+ if ( !test && token_match ( ftokens, rmpd->entry_list[index].exec) ) {
test = 1;
}
if ( test == 0 ) {
@@ -416,15 +411,6 @@ static unsigned int drun_mode_get_num_entries ( const Mode *sw )
const DRunModePrivateData *pd = (const DRunModePrivateData *) mode_get_private_data ( sw );
return pd->cmd_list_length;
}
-static int drun_is_not_ascii ( const Mode *sw, unsigned int index )
-{
- DRunModePrivateData *pd = (DRunModePrivateData *) mode_get_private_data ( sw );
- if ( pd->entry_list[index].generic_name ) {
- return !g_str_is_ascii ( pd->entry_list[index].name ) || !g_str_is_ascii ( pd->entry_list[index].generic_name );
- }
- return !g_str_is_ascii ( pd->entry_list[index].name );
-}
-
#include "mode-private.h"
Mode drun_mode =
{
@@ -437,7 +423,6 @@ Mode drun_mode =
._token_match = drun_token_match,
._get_completion = drun_get_completion,
._get_display_value = _get_display_value,
- ._is_not_ascii = drun_is_not_ascii,
.private_data = NULL,
.free = NULL
};
diff --git a/source/dialogs/run.c b/source/dialogs/run.c
index 00dae3fe..51db25d9 100644
--- a/source/dialogs/run.c
+++ b/source/dialogs/run.c
@@ -418,16 +418,10 @@ static char *_get_display_value ( const Mode *sw, unsigned int selected_line, G_
const RunModePrivateData *rmpd = (const RunModePrivateData *) sw->private_data;
return get_entry ? g_strdup ( rmpd->cmd_list[selected_line] ) : NULL;
}
-static int run_token_match ( const Mode *sw, char **tokens, int not_ascii, int case_sensitive, unsigned int index )
+static int run_token_match ( const Mode *sw, GRegex **tokens, unsigned int index )
{
const RunModePrivateData *rmpd = (const RunModePrivateData *) sw->private_data;
- return token_match ( tokens, rmpd->cmd_list[index], not_ascii, case_sensitive );
-}
-
-static int run_is_not_ascii ( const Mode *sw, unsigned int index )
-{
- const RunModePrivateData *rmpd = (const RunModePrivateData *) sw->private_data;
- return !g_str_is_ascii ( rmpd->cmd_list[index] );
+ return token_match ( tokens, rmpd->cmd_list[index]);
}
#include "mode-private.h"
@@ -442,7 +436,6 @@ Mode run_mode =
._token_match = run_token_match,
._get_display_value = _get_display_value,
._get_completion = NULL,
- ._is_not_ascii = run_is_not_ascii,
.private_data = NULL,
.free = NULL
};
diff --git a/source/dialogs/script.c b/source/dialogs/script.c
index 92f9129b..3abb2aba 100644
--- a/source/dialogs/script.c
+++ b/source/dialogs/script.c
@@ -168,16 +168,10 @@ static char *_get_display_value ( const Mode *sw, unsigned int selected_line, G_
return get_entry ? g_strdup ( rmpd->cmd_list[selected_line] ) : NULL;
}
-static int script_token_match ( const Mode *sw, char **tokens, int not_ascii, int case_sensitive, unsigned int index )
+static int script_token_match ( const Mode *sw, GRegex **tokens, unsigned int index )
{
ScriptModePrivateData *rmpd = sw->private_data;
- return token_match ( tokens, rmpd->cmd_list[index], not_ascii, case_sensitive );
-}
-
-static int script_is_not_ascii ( const Mode *sw, unsigned int index )
-{
- ScriptModePrivateData *rmpd = sw->private_data;
- return !g_str_is_ascii ( rmpd->cmd_list[index] );
+ return token_match ( tokens, rmpd->cmd_list[index] );
}
#include "mode-private.h"
@@ -207,7 +201,6 @@ Mode *script_switcher_parse_setup ( const char *str )
sw->_token_match = script_token_match;
sw->_get_completion = NULL,
sw->_get_display_value = _get_display_value;
- sw->_is_not_ascii = script_is_not_ascii;
return sw;
}
diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c
index 95bcd080..3bf38f8e 100644
--- a/source/dialogs/ssh.c
+++ b/source/dialogs/ssh.c
@@ -481,26 +481,11 @@ static char *_get_display_value ( const Mode *sw, unsigned int selected_line, G_
*
* @returns TRUE if matches
*/
-static int ssh_token_match ( const Mode *sw, char **tokens, int not_ascii, int case_sensitive, unsigned int index )
+static int ssh_token_match ( const Mode *sw, GRegex **tokens, unsigned int index )
{
SSHModePrivateData *rmpd = (SSHModePrivateData *) mode_get_private_data ( sw );
- return token_match ( tokens, rmpd->hosts_list[index], not_ascii, case_sensitive );
+ return token_match ( tokens, rmpd->hosts_list[index] );
}
-
-/**
- * @param sw Object handle to the SSH Mode object
- * @param index The index of the entry to match
- *
- * Check if the selected entry contains non-ascii symbols.
- *
- * @returns TRUE if string contains non-ascii symbols
- */
-static int ssh_is_not_ascii ( const Mode *sw, unsigned int index )
-{
- SSHModePrivateData *rmpd = (SSHModePrivateData *) mode_get_private_data ( sw );
- return !g_str_is_ascii ( rmpd->hosts_list[index] );
-}
-
#include "mode-private.h"
Mode ssh_mode =
{
@@ -513,7 +498,6 @@ Mode ssh_mode =
._token_match = ssh_token_match,
._get_display_value = _get_display_value,
._get_completion = NULL,
- ._is_not_ascii = ssh_is_not_ascii,
.private_data = NULL,
.free = NULL
};
diff --git a/source/dialogs/window.c b/source/dialogs/window.c
index f228cbf7..a2918bb7 100644
--- a/source/dialogs/window.c
+++ b/source/dialogs/window.c
@@ -319,9 +319,7 @@ typedef struct
char *cache;
} ModeModePrivateData;
-static int window_match ( const Mode *sw, char **tokens,
- __attribute__( ( unused ) ) int not_ascii,
- int case_sensitive, unsigned int index )
+static int window_match ( const Mode *sw, GRegex **tokens, unsigned int index )
{
ModeModePrivateData *rmpd = (ModeModePrivateData *) mode_get_private_data ( sw );
int match = 1;
@@ -338,21 +336,21 @@ static int window_match ( const Mode *sw, char **tokens,
// Now we want it to match only one item at the time.
// If hack not in place it would not match queries spanning multiple fields.
// e.g. when searching 'title element' and 'class element'
- char *ftokens[2] = { tokens[j], NULL };
+ GRegex *ftokens[2] = { tokens[j], NULL };
if ( !test && c->title != NULL && c->title[0] != '\0' ) {
- test = token_match ( ftokens, c->title, not_ascii, case_sensitive );
+ test = token_match ( ftokens, c->title);
}
if ( !test && c->class != NULL && c->class[0] != '\0' ) {
- test = token_match ( ftokens, c->class, not_ascii, case_sensitive );
+ test = token_match ( ftokens, c->class);
}
if ( !test && c->role != NULL && c->role[0] != '\0' ) {
- test = token_match ( ftokens, c->role, not_ascii, case_sensitive );
+ test = token_match ( ftokens, c->role);
}
if ( !test && c->name != NULL && c->name[0] != '\0' ) {
- test = token_match ( ftokens, c->name, not_ascii, case_sensitive );
+ test = token_match ( ftokens, c->name);
}
if ( test == 0 ) {
@@ -655,25 +653,6 @@ static char *_get_display_value ( const Mode *sw, unsigned int selected_line, in
return get_entry ? g_strdup ( rmpd->cmd_list[selected_line] ) : NULL;
}
-static int window_is_not_ascii ( const Mode *sw, unsigned int index )
-{
- const ModeModePrivateData *rmpd = mode_get_private_data ( sw );
- const winlist *ids = ( winlist * ) rmpd->ids;
- // Want to pull directly out of cache, X calls are not thread safe.
- int idx = winlist_find ( cache_client, ids->array[index] );
- g_assert ( idx >= 0 );
- client *c = cache_client->data[idx];
- if ( c->role && !g_str_is_ascii ( c->role ) ) {
- return TRUE;
- }
- if ( c->class && !g_str_is_ascii ( c->class ) ) {
- return TRUE;
- }
- if ( c->title && !g_str_is_ascii ( c->title ) ) {
- return TRUE;
- }
- return FALSE;
-}
#include "mode-private.h"
Mode window_mode =
@@ -687,7 +666,6 @@ Mode window_mode =
._token_match = window_match,
._get_display_value = _get_display_value,
._get_completion = NULL,
- ._is_not_ascii = window_is_not_ascii,
.private_data = NULL,
.free = NULL
};
@@ -702,7 +680,6 @@ Mode window_mode_cd =
._token_match = window_match,
._get_display_value = _get_display_value,
._get_completion = NULL,
- ._is_not_ascii = window_is_not_ascii,
.private_data = NULL,
.free = NULL
};