mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Added quote param to autocomplete_complete
This commit is contained in:
parent
0c9851106b
commit
954661e59e
@ -1272,7 +1272,7 @@ cmd_autocomplete(char *input, int *size)
|
|||||||
inp_cpy[i] = input[i];
|
inp_cpy[i] = input[i];
|
||||||
}
|
}
|
||||||
inp_cpy[i] = '\0';
|
inp_cpy[i] = '\0';
|
||||||
found = autocomplete_complete(commands_ac, inp_cpy);
|
found = autocomplete_complete(commands_ac, inp_cpy, TRUE);
|
||||||
if (found != NULL) {
|
if (found != NULL) {
|
||||||
char *auto_msg = strdup(found);
|
char *auto_msg = strdup(found);
|
||||||
ui_replace_input(input, auto_msg, size);
|
ui_replace_input(input, auto_msg, size);
|
||||||
|
@ -101,13 +101,13 @@ _accounts_close(void)
|
|||||||
static char *
|
static char *
|
||||||
_accounts_find_enabled(char *prefix)
|
_accounts_find_enabled(char *prefix)
|
||||||
{
|
{
|
||||||
return autocomplete_complete(enabled_ac, prefix);
|
return autocomplete_complete(enabled_ac, prefix, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_accounts_find_all(char *prefix)
|
_accounts_find_all(char *prefix)
|
||||||
{
|
{
|
||||||
return autocomplete_complete(all_ac, prefix);
|
return autocomplete_complete(all_ac, prefix, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -125,7 +125,7 @@ prefs_close(void)
|
|||||||
char *
|
char *
|
||||||
prefs_autocomplete_boolean_choice(char *prefix)
|
prefs_autocomplete_boolean_choice(char *prefix)
|
||||||
{
|
{
|
||||||
return autocomplete_complete(boolean_choice_ac, prefix);
|
return autocomplete_complete(boolean_choice_ac, prefix, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -117,7 +117,7 @@ muc_reset_invites_ac(void)
|
|||||||
char *
|
char *
|
||||||
muc_find_invite(char *search_str)
|
muc_find_invite(char *search_str)
|
||||||
{
|
{
|
||||||
return autocomplete_complete(invite_ac, search_str);
|
return autocomplete_complete(invite_ac, search_str, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -578,7 +578,7 @@ muc_autocomplete(char *input, int *size)
|
|||||||
gchar *last_space = g_strrstr(input, " ");
|
gchar *last_space = g_strrstr(input, " ");
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
if (last_space == NULL) {
|
if (last_space == NULL) {
|
||||||
result = autocomplete_complete(nick_ac, input);
|
result = autocomplete_complete(nick_ac, input, TRUE);
|
||||||
} else {
|
} else {
|
||||||
int len = (last_space - input);
|
int len = (last_space - input);
|
||||||
char *start_str = strndup(input, len);
|
char *start_str = strndup(input, len);
|
||||||
|
@ -291,13 +291,13 @@ roster_has_pending_subscriptions(void)
|
|||||||
char *
|
char *
|
||||||
roster_find_contact(char *search_str)
|
roster_find_contact(char *search_str)
|
||||||
{
|
{
|
||||||
return autocomplete_complete(name_ac, search_str);
|
return autocomplete_complete(name_ac, search_str, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
roster_find_resource(char *search_str)
|
roster_find_resource(char *search_str)
|
||||||
{
|
{
|
||||||
return autocomplete_complete(fulljid_ac, search_str);
|
return autocomplete_complete(fulljid_ac, search_str, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
GSList *
|
GSList *
|
||||||
@ -333,13 +333,13 @@ roster_get_groups(void)
|
|||||||
char *
|
char *
|
||||||
roster_find_group(char *search_str)
|
roster_find_group(char *search_str)
|
||||||
{
|
{
|
||||||
return autocomplete_complete(groups_ac, search_str);
|
return autocomplete_complete(groups_ac, search_str, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
roster_find_jid(char *search_str)
|
roster_find_jid(char *search_str)
|
||||||
{
|
{
|
||||||
return autocomplete_complete(barejid_ac, search_str);
|
return autocomplete_complete(barejid_ac, search_str, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -148,7 +148,7 @@ autocomplete_contains(Autocomplete ac, const char *value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
gchar *
|
||||||
autocomplete_complete(Autocomplete ac, gchar *search_str)
|
autocomplete_complete(Autocomplete ac, gchar *search_str, gboolean quote)
|
||||||
{
|
{
|
||||||
gchar *found = NULL;
|
gchar *found = NULL;
|
||||||
|
|
||||||
@ -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, TRUE);
|
found = _search_from(ac, ac->items, quote);
|
||||||
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), TRUE);
|
found = _search_from(ac, g_slist_next(ac->last_found), quote);
|
||||||
if (found != NULL)
|
if (found != NULL)
|
||||||
return found;
|
return found;
|
||||||
|
|
||||||
// search from beginning
|
// search from beginning
|
||||||
found = _search_from(ac, ac->items, TRUE);
|
found = _search_from(ac, ac->items, quote);
|
||||||
if (found != NULL)
|
if (found != NULL)
|
||||||
return found;
|
return found;
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ autocomplete_param_with_ac(char *input, int *size, char *command,
|
|||||||
}
|
}
|
||||||
inp_cpy[(*size) - len] = '\0';
|
inp_cpy[(*size) - len] = '\0';
|
||||||
|
|
||||||
char *found = autocomplete_complete(ac, inp_cpy);
|
char *found = autocomplete_complete(ac, inp_cpy, TRUE);
|
||||||
if (found != NULL) {
|
if (found != NULL) {
|
||||||
auto_msg = g_string_new(command_cpy);
|
auto_msg = g_string_new(command_cpy);
|
||||||
g_string_append(auto_msg, found);
|
g_string_append(auto_msg, found);
|
||||||
|
@ -41,7 +41,7 @@ void autocomplete_add(Autocomplete ac, const char *item);
|
|||||||
void autocomplete_remove(Autocomplete ac, const char * const item);
|
void autocomplete_remove(Autocomplete ac, const char * const item);
|
||||||
|
|
||||||
// find the next item prefixed with search string
|
// find the next item prefixed with search string
|
||||||
gchar * autocomplete_complete(Autocomplete ac, gchar *search_str);
|
gchar * autocomplete_complete(Autocomplete ac, gchar *search_str, gboolean quote);
|
||||||
|
|
||||||
GSList * autocomplete_get_list(Autocomplete ac);
|
GSList * autocomplete_get_list(Autocomplete ac);
|
||||||
gint autocomplete_length(Autocomplete ac);
|
gint autocomplete_length(Autocomplete ac);
|
||||||
|
@ -217,7 +217,7 @@ _bookmark_get_list(void)
|
|||||||
static char *
|
static char *
|
||||||
_bookmark_find(char *search_str)
|
_bookmark_find(char *search_str)
|
||||||
{
|
{
|
||||||
return autocomplete_complete(bookmark_ac, search_str);
|
return autocomplete_complete(bookmark_ac, search_str, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -149,7 +149,7 @@ presence_clear_sub_requests(void)
|
|||||||
static char *
|
static char *
|
||||||
_presence_sub_request_find(char * search_str)
|
_presence_sub_request_find(char * search_str)
|
||||||
{
|
{
|
||||||
return autocomplete_complete(sub_requests_ac, search_str);
|
return autocomplete_complete(sub_requests_ac, search_str, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -24,7 +24,7 @@ void reset_after_create(void **state)
|
|||||||
void find_after_create(void **state)
|
void find_after_create(void **state)
|
||||||
{
|
{
|
||||||
Autocomplete ac = autocomplete_new();
|
Autocomplete ac = autocomplete_new();
|
||||||
autocomplete_complete(ac, "hello");
|
autocomplete_complete(ac, "hello", TRUE);
|
||||||
autocomplete_clear(ac);
|
autocomplete_clear(ac);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ void add_one_and_complete(void **state)
|
|||||||
{
|
{
|
||||||
Autocomplete ac = autocomplete_new();
|
Autocomplete ac = autocomplete_new();
|
||||||
autocomplete_add(ac, "Hello");
|
autocomplete_add(ac, "Hello");
|
||||||
char *result = autocomplete_complete(ac, "Hel");
|
char *result = autocomplete_complete(ac, "Hel", TRUE);
|
||||||
|
|
||||||
assert_string_equal("Hello", result);
|
assert_string_equal("Hello", result);
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ void add_two_and_complete_returns_first(void **state)
|
|||||||
Autocomplete ac = autocomplete_new();
|
Autocomplete ac = autocomplete_new();
|
||||||
autocomplete_add(ac, "Hello");
|
autocomplete_add(ac, "Hello");
|
||||||
autocomplete_add(ac, "Help");
|
autocomplete_add(ac, "Help");
|
||||||
char *result = autocomplete_complete(ac, "Hel");
|
char *result = autocomplete_complete(ac, "Hel", TRUE);
|
||||||
|
|
||||||
assert_string_equal("Hello", result);
|
assert_string_equal("Hello", result);
|
||||||
|
|
||||||
@ -66,8 +66,8 @@ void add_two_and_complete_returns_second(void **state)
|
|||||||
Autocomplete ac = autocomplete_new();
|
Autocomplete ac = autocomplete_new();
|
||||||
autocomplete_add(ac, "Hello");
|
autocomplete_add(ac, "Hello");
|
||||||
autocomplete_add(ac, "Help");
|
autocomplete_add(ac, "Help");
|
||||||
char *result1 = autocomplete_complete(ac, "Hel");
|
char *result1 = autocomplete_complete(ac, "Hel", TRUE);
|
||||||
char *result2 = autocomplete_complete(ac, result1);
|
char *result2 = autocomplete_complete(ac, result1, TRUE);
|
||||||
|
|
||||||
assert_string_equal("Help", result2);
|
assert_string_equal("Help", result2);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user