mirror of
https://github.com/profanity-im/profanity.git
synced 2024-08-11 18:54:16 -04:00
Added quote param to autocomplete searches
This commit is contained in:
parent
88180568e0
commit
0c9851106b
@ -34,7 +34,7 @@ struct autocomplete_t {
|
|||||||
gchar *search_str;
|
gchar *search_str;
|
||||||
};
|
};
|
||||||
|
|
||||||
static gchar * _search_from(Autocomplete ac, GSList *curr);
|
static gchar * _search_from(Autocomplete ac, GSList *curr, gboolean quote);
|
||||||
|
|
||||||
Autocomplete
|
Autocomplete
|
||||||
autocomplete_new(void)
|
autocomplete_new(void)
|
||||||
@ -166,18 +166,18 @@ autocomplete_complete(Autocomplete ac, gchar *search_str)
|
|||||||
FREE_SET_NULL(ac->search_str);
|
FREE_SET_NULL(ac->search_str);
|
||||||
}
|
}
|
||||||
ac->search_str = strdup(search_str);
|
ac->search_str = strdup(search_str);
|
||||||
found = _search_from(ac, ac->items);
|
found = _search_from(ac, ac->items, TRUE);
|
||||||
return found;
|
return found;
|
||||||
|
|
||||||
// subsequent search attempt
|
// subsequent search attempt
|
||||||
} else {
|
} else {
|
||||||
// search from here+1 tp end
|
// search from here+1 tp end
|
||||||
found = _search_from(ac, g_slist_next(ac->last_found));
|
found = _search_from(ac, g_slist_next(ac->last_found), TRUE);
|
||||||
if (found != NULL)
|
if (found != NULL)
|
||||||
return found;
|
return found;
|
||||||
|
|
||||||
// search from beginning
|
// search from beginning
|
||||||
found = _search_from(ac, ac->items);
|
found = _search_from(ac, ac->items, TRUE);
|
||||||
if (found != NULL)
|
if (found != NULL)
|
||||||
return found;
|
return found;
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ autocomplete_param_no_with_func(char *input, int *size, char *command,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
_search_from(Autocomplete ac, GSList *curr)
|
_search_from(Autocomplete ac, GSList *curr, gboolean quote)
|
||||||
{
|
{
|
||||||
while(curr) {
|
while(curr) {
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ _search_from(Autocomplete ac, GSList *curr)
|
|||||||
ac->last_found = curr;
|
ac->last_found = curr;
|
||||||
|
|
||||||
// if contains space, quote before returning
|
// if contains space, quote before returning
|
||||||
if (g_strrstr(curr->data, " ")) {
|
if (quote && g_strrstr(curr->data, " ")) {
|
||||||
GString *quoted = g_string_new("\"");
|
GString *quoted = g_string_new("\"");
|
||||||
g_string_append(quoted, curr->data);
|
g_string_append(quoted, curr->data);
|
||||||
g_string_append(quoted, "\"");
|
g_string_append(quoted, "\"");
|
||||||
@ -323,4 +323,4 @@ _search_from(Autocomplete ac, GSList *curr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user