summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-06-19 14:56:57 +0200
committerDave Davenport <qball@gmpclient.org>2016-06-19 14:56:57 +0200
commit341f8322ed11456bd206a17e5a7438d45e7412fe (patch)
treecf3f80d58433e152b7e20333a81a49065b363455
parent72ffebc8febd7888e11a044db75a52a8723500fe (diff)
parentdab872879eb522ec1aa64bd923aa1e5c8329243c (diff)
Merge remote-tracking branch 'origin/highlight_match'
-rw-r--r--Changelog3
-rw-r--r--Makefile.am2
-rw-r--r--config/config.c2
-rw-r--r--doc/rofi-manpage.markdown4
-rw-r--r--doc/rofi.16
-rw-r--r--doc/test_xr.txt2
-rw-r--r--include/helper.h20
-rw-r--r--include/mode-private.h8
-rw-r--r--include/mode.h15
-rw-r--r--include/settings.h2
-rw-r--r--include/textbox.h32
-rw-r--r--include/view-internal.h1
-rw-r--r--source/dialogs/combi.c63
-rw-r--r--source/dialogs/dmenu.c24
-rw-r--r--source/dialogs/drun.c28
-rw-r--r--source/dialogs/help-keys.c12
-rw-r--r--source/dialogs/run.c12
-rw-r--r--source/dialogs/script.c12
-rw-r--r--source/dialogs/ssh.c23
-rw-r--r--source/dialogs/window.c38
-rw-r--r--source/helper.c207
-rw-r--r--source/mode.c18
-rw-r--r--source/rofi.c36
-rw-r--r--source/textbox.c21
-rw-r--r--source/view.c77
-rw-r--r--source/xrmoptions.c2
-rw-r--r--test/helper-test.c28
-rwxr-xr-xtest/run_fuzzy_test.sh22
28 files changed, 232 insertions, 488 deletions
diff --git a/Changelog b/Changelog
index 6f7e24a1..0b295f42 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,6 @@
+v1.unrelease
+ - Remove fuzzy option
+
v1.1.0
New Features
- Keys mode, showing keybindings.
diff --git a/Makefile.am b/Makefile.am
index f50c0240..1a9619e3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -317,8 +317,6 @@ test-x: $(bin_PROGRAMS) textbox_test
$(top_srcdir)/test/run_test.sh 215 $(top_srcdir)/test/run_regex_test.sh $(top_builddir)
echo "Test dmenu glob"
$(top_srcdir)/test/run_test.sh 216 $(top_srcdir)/test/run_glob_test.sh $(top_builddir)
- echo "Test dmenu fuzzy"
- $(top_srcdir)/test/run_test.sh 217 $(top_srcdir)/test/run_fuzzy_test.sh $(top_builddir)
echo "Test config dump"
$(top_srcdir)/test/run_test.sh 218 $(top_srcdir)/test/xr_config_test.sh $(top_builddir) $(top_srcdir)
echo "Test issue 333"
diff --git a/config/config.c b/config/config.c
index d20a2cb4..c1455cef 100644
--- a/config/config.c
+++ b/config/config.c
@@ -108,8 +108,6 @@ Settings config = {
.parse_known_hosts = TRUE,
/** Modi to combine into one view. */
.combi_modi = "window,run",
- /** Fuzzy matching. */
- .fuzzy = FALSE,
.glob = FALSE,
.tokenize = TRUE,
.regex = FALSE,
diff --git a/doc/rofi-manpage.markdown b/doc/rofi-manpage.markdown
index 6ee43a6f..4e34e145 100644
--- a/doc/rofi-manpage.markdown
+++ b/doc/rofi-manpage.markdown
@@ -187,10 +187,6 @@ Start in case sensitive mode.
Cycle through the results list. Default is 'true'.
-`-fuzzy`
-
-Enable experimental fuzzy matching.
-
`-filter` *filter*
Filter the list by setting text in input bar to *filter*
diff --git a/doc/rofi.1 b/doc/rofi.1
index c16b8a3f..a7fa9fb0 100644
--- a/doc/rofi.1
+++ b/doc/rofi.1
@@ -274,12 +274,6 @@ Start in case sensitive mode\.
Cycle through the results list\. Default is \'true\'\.
.
.P
-\fB\-fuzzy\fR
-.
-.P
-Enable experimental fuzzy matching\.
-.
-.P
\fB\-filter\fR \fIfilter\fR
.
.P
diff --git a/doc/test_xr.txt b/doc/test_xr.txt
index c32eda8b..d895e08d 100644
--- a/doc/test_xr.txt
+++ b/doc/test_xr.txt
@@ -64,8 +64,6 @@ rofi.parse-hosts: false
rofi.parse-known-hosts: true
! Set the modi to combine in combi mode
rofi.combi-modi: window,drun,run,ssh
-! Do a more fuzzy matching
-rofi.fuzzy: false
! Use glob matching
rofi.glob: false
! Use regex matching
diff --git a/include/helper.h b/include/helper.h
index de6f1097..81cd330c 100644
--- a/include/helper.h
+++ b/include/helper.h
@@ -2,6 +2,7 @@
#define ROFI_HELPER_H
#include "rofi.h"
+#include <pango/pango.h>
/**
* @defgroup HELPERS Helpers
*/
@@ -24,18 +25,6 @@
int helper_parse_setup ( char * string, char ***output, int *length, ... );
/**
- * @param token The string for which we want a collation key.
- * @param case_sensitive Whether case is significant.
- *
- * Get a collation key for @p token. @p token must be a null-terminated string.
- * This collation key can be used for matching the user input against the list
- * of commands, windows, or ssh commands.
- *
- * @returns A newly allocated string containing the collation key.
- */
-char *token_collate_key ( const char *token, int case_sensitive );
-
-/**
* @param input The input string.
* @param case_sensitive Whether case is significant.
*
@@ -43,8 +32,8 @@ char *token_collate_key ( const char *token, int case_sensitive );
*
* @returns a newly allocated 2 dimensional array of strings.
*/
-char **tokenize ( const char *input, int case_sensitive );
-void tokenize_free ( char ** tokens );
+GRegex **tokenize ( const char *input, int case_sensitive );
+void tokenize_free ( GRegex ** tokens );
/**
* @param key The key to search for
@@ -108,7 +97,7 @@ int find_arg ( const char * const key );
*
* @returns 1 when matches, 0 otherwise
*/
-int token_match ( char **tokens, const char *input, int not_ascii, int case_sensitive );
+int token_match ( GRegex **tokens, const char *input );
/**
* @param cmd The command to execute.
*
@@ -171,5 +160,6 @@ unsigned int levenshtein ( const char *needle, const char *haystack );
*/
char * rofi_force_utf8 ( gchar *data );
char * rofi_latin_to_utf8_strdup ( const char *input, gssize length );
+PangoAttrList *token_match_get_pango_attr ( GRegex **tokens, const char *input, PangoAttrList *retv );
/*@}*/
#endif // ROFI_HELPER_H
diff --git a/include/mode-private.h b/include/mode-private.h
index 7747de0a..31e92c98 100644
--- a/include/mode-private.h
+++ b/include/mode-private.h
@@ -17,7 +17,7 @@ typedef char * ( *_mode_get_completion )( const Mode *sw, unsigned int selected_
*
* @returns 1 when it matches, 0 if not.
*/
-typedef int ( *_mode_token_match )( const Mode *data, char **tokens, int not_ascii, int case_sensitive, unsigned int index );
+typedef int ( *_mode_token_match )( const Mode *data, GRegex **tokens, unsigned int index );
typedef int ( *__mode_init )( Mode *sw );
@@ -27,7 +27,7 @@ typedef void ( *__mode_destroy )( Mode *sw );
typedef ModeMode ( *_mode_result )( Mode *sw, int menu_retv, char **input, unsigned int selected_line );
-typedef int ( *_mode_is_not_ascii )( const Mode *sw, unsigned int index );
+typedef char* ( *_mode_preprocess_input )( Mode *sw, const char *input );
/**
* Structure defining a switcher.
@@ -50,8 +50,6 @@ struct rofi_mode
__mode_destroy _destroy;
/** Get number of entries to display. (unfiltered). */
__mode_get_num_entries _get_num_entries;
- /** Check if the element is ascii. */
- _mode_is_not_ascii _is_not_ascii;
/** Process the result of the user selection. */
_mode_result _result;
/** Token match. */
@@ -61,6 +59,8 @@ struct rofi_mode
/** Get the 'completed' entry. */
_mode_get_completion _get_completion;
+ _mode_preprocess_input _preprocess_input;
+
/** Pointer to private data. */
void *private_data;
diff --git a/include/mode.h b/include/mode.h
index 85642826..4cd2244d 100644
--- a/include/mode.h
+++ b/include/mode.h
@@ -98,16 +98,6 @@ char * mode_get_completion ( const Mode *mode, unsigned int selected_line );
/**
* @param mode The mode to query
- * @param selected_line The entry to query
- *
- * Check if the entry has non-ascii characters.
- *
- * @returns TRUE when selected line has non-ascii characters.
- */
-int mode_is_not_ascii ( const Mode *mode, unsigned int selected_line );
-
-/**
- * @param mode The mode to query
* @param mretv The menu return value.
* @param input Pointer to the user input string.
* @param selected_line the line selected by the user.
@@ -121,15 +111,13 @@ ModeMode mode_result ( Mode *mode, int menu_retv, char **input, unsigned int sel
/**
* @param mode The mode to query
* @param tokens The set of tokens to match against
- * @param not_ascii If the entry is pure-ascii
- * @param case_sensitive If the entry should be matched case sensitive
* @param selected_line The index of the entry to match
*
* Match entry against the set of tokens.
*
* @returns TRUE if matches
*/
-int mode_token_match ( const Mode *mode, char **tokens, int not_ascii, int case_sensitive, unsigned int selected_line );
+int mode_token_match ( const Mode *mode, GRegex **tokens, unsigned int selected_line );
/**
* @param mode The mode to query
@@ -166,5 +154,6 @@ void mode_set_private_data ( Mode *mode, void *pd );
const char *mode_get_display_name ( const Mode *mode );
void mode_set_config ( Mode *mode );
+char * mode_preprocess_input ( Mode *mode, const char *input );
/*@}*/
#endif
diff --git a/include/settings.h b/include/settings.h
index 848d8a6b..ff9393a5 100644
--- a/include/settings.h
+++ b/include/settings.h
@@ -106,8 +106,6 @@ typedef struct
unsigned int parse_known_hosts;
/** Combi Modes */
char *combi_modi;
- /** Fuzzy match */
- unsigned int fuzzy;
unsigned int glob;
unsigned int tokenize;
unsigned int regex;
diff --git a/include/textbox.h b/include/textbox.h
index afadd9e4..455904f8 100644
--- a/include/textbox.h
+++ b/include/textbox.h
@@ -39,15 +39,15 @@ typedef struct
typedef enum
{
- TB_AUTOHEIGHT = 1 << 0,
- TB_AUTOWIDTH = 1 << 1,
- TB_LEFT = 1 << 16,
- TB_RIGHT = 1 << 17,
- TB_CENTER = 1 << 18,
- TB_EDITABLE = 1 << 19,
- TB_MARKUP = 1 << 20,
- TB_WRAP = 1 << 21,
- TB_PASSWORD = 1 << 22,
+ TB_AUTOHEIGHT = 1 << 0,
+ TB_AUTOWIDTH = 1 << 1,
+ TB_LEFT = 1 << 16,
+ TB_RIGHT = 1 << 17,
+ TB_CENTER = 1 << 18,
+ TB_EDITABLE = 1 << 19,
+ TB_MARKUP = 1 << 20,
+ TB_WRAP = 1 << 21,
+ TB_PASSWORD = 1 << 22,
} TextboxFlags;
typedef enum
@@ -103,7 +103,15 @@ void textbox_text ( textbox *tb, const char *text );
void textbox_draw ( textbox *tb, cairo_t *draw );
int textbox_keybinding ( textbox *tb, KeyBindingAction action );
-gboolean textbox_append ( textbox *tb, char *pad, int pad_len );
+/**
+ * @param tb Handle to the textbox
+ * @param pad The text to insert
+ * @param pad_len the length of the text
+ *
+ * The text should be one insert from a keypress.. the first gunichar is validated to be (or not) control
+ * return TRUE if inserted
+ */
+gboolean textbox_append_char ( textbox *tb, char *pad, int pad_len );
/**
* @param tb Handle to the textbox
@@ -225,6 +233,10 @@ void textbox_delete ( textbox *tb, int pos, int dlen );
void textbox_moveresize ( textbox *tb, int x, int y, int w, int h );
int textbox_get_estimated_char_height ( void );
void textbox_set_pango_context ( PangoContext *p );
+void textbox_set_pango_attributes ( textbox *tb, PangoAttrList *list );
+
+PangoAttrList *textbox_get_pango_attributes ( textbox *tb );
+const char *textbox_get_visible_text ( textbox *tb );
/*@}*/
#endif //ROFI_TEXTBOX_H
diff --git a/include/view-internal.h b/include/view-internal.h
index 4912da10..43ba6875 100644
--- a/include/view-internal.h
+++ b/include/view-internal.h
@@ -56,7 +56,6 @@ struct RofiViewState
// Return state
unsigned int selected_line;
MenuReturn retv;
- int *lines_not_ascii;
int line_height;
unsigned int border;
workarea mon;
diff --git a/source/dialogs/combi.c b/source/dialogs/combi.c
index 5ab58940..7cba5200 100644
--- a/source/dialogs/combi.c
+++ b/source/dialogs/combi.c
@@ -45,6 +45,7 @@ typedef struct
// List of switchers to combine.
unsigned int num_switchers;
Mode **switchers;
+ Mode *current;
} CombiModePrivateData;
static void combi_mode_parse_switchers ( Mode *sw )
@@ -175,37 +176,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 ) {
- // 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] );
- }
+ for ( unsigned i = 0; i < pd->num_switchers; i++ ) {
+ if ( pd->current != NULL && pd->switchers[i] != pd->current ) {
+ continue;
}
- }
- else{
- for ( unsigned i = 0; i < pd->num_switchers; i++ ) {
- if ( index >= pd->starts[i] && index < ( pd->starts[i] + pd->lengths[i] ) ) {
- if ( tokens && tokens[0][0] == '!' ) {
- if ( tokens[0][1] == mode_get_name ( pd->switchers[i] )[0] ) {
- return mode_token_match ( pd->switchers[i], &tokens[1], not_ascii, case_sensitive,
- index - pd->starts[i] );
- }
- return 0;
- }
- else {
- return mode_token_match ( pd->switchers[i], tokens, not_ascii, case_sensitive,
- index - pd->starts[i] );
- }
- }
+ if ( index >= pd->starts[i] && index < ( pd->starts[i] + pd->lengths[i] ) ) {
+ return mode_token_match ( pd->switchers[i], tokens, index - pd->starts[i] );
}
}
- abort ();
return 0;
}
static char * combi_mgrv ( const Mode *sw, unsigned int selected_line, int *state, int get_entry )
@@ -231,16 +212,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 );
@@ -257,6 +228,24 @@ static char * combi_get_completion ( const Mode *sw, unsigned int index )
return NULL;
}
+static char * combi_preprocess_input ( Mode *sw, const char *input )
+{
+ CombiModePrivateData *pd = mode_get_private_data ( sw );
+ pd->current = NULL;
+ if ( input != NULL && input[0] == '!' && strlen ( input ) > 1 ) {
+ for ( unsigned i = 0; i < pd->num_switchers; i++ ) {
+ if ( input[1] == mode_get_name ( pd->switchers[i] )[0] ) {
+ pd->current = pd->switchers[i];
+ if ( input[2] == '\0' ) {
+ return NULL;
+ }
+ return g_strdup ( &input[2] );
+ }
+ }
+ }
+ return g_strdup ( input );
+}
+
#include "mode-private.h"
Mode combi_mode =
{
@@ -269,7 +258,7 @@ 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,
+ ._preprocess_input = combi_preprocess_input,
.private_data = NULL,
.free = NULL
};
diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c
index 56f397bf..c7b016aa 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,7 @@ Mode dmenu_mode =
._token_match = dmenu_token_match,
._get_display_value = get_display_data,
._get_completion = NULL,
- ._is_not_ascii = dmenu_is_not_ascii,
+ ._preprocess_input = NULL,
.private_data = NULL,
.free = NULL
};
@@ -516,25 +510,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 8e004075..feec11c6 100644
--- a/source/dialogs/drun.c
+++ b/source/dialogs/drun.c
@@ -400,29 +400,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 };
+ int test = 0;
+ 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 ) {
@@ -438,15 +433,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 =
{
@@ -459,7 +445,7 @@ 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,
+ ._preprocess_input = NULL,
.private_data = NULL,
.free = NULL
};
diff --git a/source/dialogs/help-keys.c b/source/dialogs/help-keys.c
index 6a633174..dc0955e6 100644
--- a/source/dialogs/help-keys.c
+++ b/source/dialogs/help-keys.c
@@ -103,14 +103,12 @@ static char *_get_display_value ( const Mode *sw, unsigned int selected_line, in
return g_strdup ( pd->messages[selected_line] );
}
static int help_keys_token_match ( const Mode *data,
- char **tokens,
- int not_ascii,
- int case_sensitive,
+ GRegex **tokens,
unsigned int index
)
{
KeysHelpModePrivateData *rmpd = (KeysHelpModePrivateData *) mode_get_private_data ( data );
- return token_match ( tokens, rmpd->messages[index], not_ascii, case_sensitive );
+ return token_match ( tokens, rmpd->messages[index] );
}
static unsigned int help_keys_mode_get_num_entries ( const Mode *sw )
@@ -118,11 +116,6 @@ static unsigned int help_keys_mode_get_num_entries ( const Mode *sw )
const KeysHelpModePrivateData *pd = (const KeysHelpModePrivateData *) mode_get_private_data ( sw );
return pd->messages_length;
}
-static int help_keys_is_not_ascii ( const Mode *sw, unsigned int index )
-{
- const KeysHelpModePrivateData *pd = (const KeysHelpModePrivateData *) mode_get_private_data ( sw );
- return !g_str_is_ascii ( pd->messages[index] );
-}
#include "mode-private.h"
Mode help_keys_mode =
@@ -136,7 +129,6 @@ Mode help_keys_mode =
._token_match = help_keys_token_match,
._get_completion = NULL,
._get_display_value = _get_display_value,
- ._is_not_ascii = help_keys_is_not_ascii,
.private_data = NULL,
.free = NULL
};
diff --git a/source/dialogs/run.c b/source/dialogs/run.c
index 00dae3fe..523a0b4e 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,7 @@ Mode run_mode =
._token_match = run_token_match,
._get_display_value = _get_display_value,
._get_completion = NULL,
- ._is_not_ascii = run_is_not_ascii,
+ ._preprocess_input = NULL,
.private_data = NULL,
.free = NULL
};
diff --git a/source/dialogs/script.c b/source/dialogs/script.c
index 92f9129b..bac6e1b8 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"
@@ -206,8 +200,8 @@ Mode *script_switcher_parse_setup ( const char *str )
sw->_destroy = script_mode_destroy;
sw->_token_match = script_token_match;
sw->_get_completion = NULL,
+ sw->_preprocess_input = 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 8e1a6da7..331e5431 100644
--- a/source/dialogs/ssh.c
+++ b/source/dialogs/ssh.c
@@ -198,7 +198,7 @@ static char **read_hosts_file ( char ** retv, unsigned int *length )
// Reading one line per time.
while ( getline ( &buffer, &buffer_length, fd ) > 0 ) {
// Evaluate one line.
- unsigned int index = 0, ti = 0;
+ unsigned int index = 0, ti = 0;
char *token = buffer;
// Tokenize it.
@@ -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,7 @@ Mode ssh_mode =
._token_match = ssh_token_match,
._get_display_value = _get_display_value,
._get_completion = NULL,
- ._is_not_ascii = ssh_is_not_ascii,
+ ._preprocess_input = NULL,
.private_data = NULL,
.free = NULL
};
diff --git a/source/dialogs/window.c b/source/dialogs/window.c
index 20021862..d56e76f0 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,