'everything' module:

- fuzz<_match fix: match last word of 'string' with every word in 'match'
- dont fetch new items when only space was added
- apps: cleanup


SVN revision: 41794
This commit is contained in:
Hannes Janetzek 2009-08-15 20:12:04 +00:00
parent 5e526f44cd
commit 68fc50e538
2 changed files with 49 additions and 38 deletions

View File

@ -97,7 +97,7 @@ struct _Evry_List_Window
static void _evry_matches_update(Evry_Selector *sel); static void _evry_matches_update(Evry_Selector *sel);
static void _evry_plugin_action(Evry_Selector *sel, int finished); static void _evry_plugin_action(Evry_Selector *sel, int finished);
static void _evry_backspace(Evry_State *s); static void _evry_backspace(Evry_State *s);
static void _evry_update(Evry_State *s); static void _evry_update(Evry_State *s, int fetch);
static void _evry_clear(Evry_State *s); static void _evry_clear(Evry_State *s);
static int _evry_update_timer(void *data); static int _evry_update_timer(void *data);
static Evry_State *_evry_state_new(Evry_Selector *sel, Eina_List *plugins); static Evry_State *_evry_state_new(Evry_Selector *sel, Eina_List *plugins);
@ -473,25 +473,25 @@ evry_fuzzy_match(const char *str, const char *match)
if (!match || !str) return 0; if (!match || !str) return 0;
word_min[0] = MAX_FUZZ;
/* remove white spaces at the beginning */ /* remove white spaces at the beginning */
for (; (*match != 0) && isspace(*match); match++); for (; (*match != 0) && isspace(*match); match++);
for (; (*str != 0) && isspace(*str); str++); for (; (*str != 0) && isspace(*str); str++);
/* count words in match */
word_min[0] = MAX_FUZZ;
for (m = match; *m != 0 && *(m+1) != 0; m++) for (m = match; *m != 0 && *(m+1) != 0; m++)
{ {
if (isspace(*m) && !isspace(*(m+1))) if (isspace(*m) && !isspace(*(m+1)))
{ {
word_min[words] = MAX_FUZZ; word_min[words] = MAX_FUZZ;
words++; words++;
} }
} }
p = next = str; next = str;
m = match; m = match;
for (word = 0; word < words && *p != 0;) for (word = 0; word < words && *next != 0; )
{ {
/* reset match */ /* reset match */
if (word == 0) m = match; if (word == 0) m = match;
@ -500,18 +500,16 @@ evry_fuzzy_match(const char *str, const char *match)
if (*m == 0) break; if (*m == 0) break;
mc = tolower(*m); mc = tolower(*m);
offset = 0; offset = 0;
last = 0; last = 0;
min = 1; min = 1;
first = 0; first = 0;
/* match current word of string against current match */ /* match current word of string against current match */
for (p = next; *p != 0; p++) for (p = next; *next != 0; p++)
{ {
pc = tolower(*p);
/* new word of string begins */ /* new word of string begins */
if (isspace(pc)) if (*p == 0 || isspace(*p))
{ {
if (word < words - 1) if (word < words - 1)
{ {
@ -531,6 +529,8 @@ evry_fuzzy_match(const char *str, const char *match)
} }
} }
pc = tolower(*p);
/* current char matches? */ /* current char matches? */
if (pc != mc) if (pc != mc)
{ {
@ -567,7 +567,7 @@ evry_fuzzy_match(const char *str, const char *match)
word++; word++;
break; break;
} }
else else if(*p != 0)
{ {
/* go to next word */ /* go to next word */
for (; (*p != 0) && !isspace(*p); p++); for (; (*p != 0) && !isspace(*p); p++);
@ -576,6 +576,11 @@ evry_fuzzy_match(const char *str, const char *match)
word = 0; word = 0;
break; break;
} }
else
{
next = p;
break;
}
} }
} }
@ -1301,7 +1306,10 @@ _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
if (strlen(s->input) < (INPUTLEN - strlen(ev->compose))) if (strlen(s->input) < (INPUTLEN - strlen(ev->compose)))
{ {
strcat(s->input, ev->compose); strcat(s->input, ev->compose);
_evry_update(s); if (isspace(*ev->compose))
_evry_update(s, 0);
else
_evry_update(s, 1);
} }
} }
return 1; return 1;
@ -1319,7 +1327,7 @@ _evry_backspace(Evry_State *s)
if ((pos < len) && (pos >= 0)) if ((pos < len) && (pos >= 0))
{ {
s->input[pos] = 0; s->input[pos] = 0;
_evry_update(s); _evry_update(s, 1);
} }
} }
} }
@ -1338,12 +1346,15 @@ _evry_update_text_label(Evry_State *s)
} }
static void static void
_evry_update(Evry_State *s) _evry_update(Evry_State *s, int fetch)
{ {
_evry_update_text_label(s); _evry_update_text_label(s);
if (update_timer) ecore_timer_del(update_timer); if (fetch)
update_timer = ecore_timer_add(MATCH_LAG, _evry_update_timer, s); {
if (update_timer) ecore_timer_del(update_timer);
update_timer = ecore_timer_add(MATCH_LAG, _evry_update_timer, s);
}
} }
static int static int
@ -1367,12 +1378,12 @@ _evry_clear(Evry_State *s)
(!strncmp(s->plugin->trigger, s->input, strlen(s->plugin->trigger)))) (!strncmp(s->plugin->trigger, s->input, strlen(s->plugin->trigger))))
{ {
s->input[strlen(s->plugin->trigger)] = 0; s->input[strlen(s->plugin->trigger)] = 0;
_evry_update(s); _evry_update(s, 1);
} }
else if (s->input[0] != 0) else if (s->input[0] != 0)
{ {
s->input[0] = 0; s->input[0] = 0;
_evry_update(s); _evry_update(s, 1);
edje_object_signal_emit(list->o_main, "e,state,entry_hide", "e"); edje_object_signal_emit(list->o_main, "e,state,entry_hide", "e");
} }
} }
@ -2486,7 +2497,7 @@ _evry_cb_selection_notify(void *data, int type, void *event)
text_data = ev->data; text_data = ev->data;
strncat(s->input, text_data->text, (INPUTLEN - strlen(s->input)) - 1); strncat(s->input, text_data->text, (INPUTLEN - strlen(s->input)) - 1);
_evry_update(s); _evry_update(s, 1);
} }
} }

View File

@ -248,8 +248,6 @@ _fetch(Evry_Plugin *p, const char *input)
Eina_List *l; Eina_List *l;
Efreet_Desktop *desktop; Efreet_Desktop *desktop;
char *file; char *file;
char match1[4096];
char match2[4096];
Evry_Item *it; Evry_Item *it;
Evry_App *app; Evry_App *app;
Inst *inst = p->private; Inst *inst = p->private;
@ -312,24 +310,26 @@ _fetch(Evry_Plugin *p, const char *input)
if (input || p == p2) if (input || p == p2)
{ {
int found = 0; int found = 0;
char *path;
char *end; char *end;
char *dir;
char cmd[1024];
char path[1024];
if (input) if (input)
{ {
snprintf(match2, 4096, "%s", input); snprintf(cmd, sizeof(cmd), "%s", input);
if (end = strchr(input, ' ')) if (end = strchr(input, ' '))
{ {
int len = (end - input) - 1; int len = (end - input) + 1;
if (len >= 0) if (len >= 0)
snprintf(match2, len, "%s", input); snprintf(cmd, len, "%s", input);
} }
EINA_LIST_FOREACH(exe_path, l, path) EINA_LIST_FOREACH(exe_path, l, dir)
{ {
snprintf(match1, 4096, "%s/%s", path, match2); snprintf(path, sizeof(path), "%s/%s", dir, cmd);
if (ecore_file_exists(match1)) if (ecore_file_exists(path))
{ {
found = 1; found = 1;
break; break;
@ -346,18 +346,18 @@ _fetch(Evry_Plugin *p, const char *input)
else else
app->file = eina_stringshare_add(""); app->file = eina_stringshare_add("");
it->data[0] = app; it->data[0] = app;
it->priority = 99; it->priority = 9999;
p->items = eina_list_append(p->items, it); p->items = eina_list_append(p->items, it);
snprintf(match1, 4096, "xterm -hold -e %s", input); snprintf(cmd, sizeof(cmd), "xterm -hold -e %s", input);
it = evry_item_new(p, _("Run in Terminal"), &_item_free); it = evry_item_new(p, _("Run in Terminal"), &_item_free);
app = E_NEW(Evry_App, 1); app = E_NEW(Evry_App, 1);
if (input) if (input)
app->file = eina_stringshare_add(match1); app->file = eina_stringshare_add(cmd);
else else
app->file = eina_stringshare_add(""); app->file = eina_stringshare_add("");
it->data[0] = app; it->data[0] = app;
it->priority = 100; it->priority = 1000;
p->items = eina_list_append(p->items, it); p->items = eina_list_append(p->items, it);
} }
} }