Add context to autocomplete_with_func and use it for omemo trust command
Fix #1068
This commit is contained in:
@@ -285,7 +285,7 @@ autocomplete_complete(Autocomplete ac, const gchar *search_str, gboolean quote,
|
||||
}
|
||||
|
||||
char*
|
||||
autocomplete_param_with_func(const char *const input, char *command, autocomplete_func func, gboolean previous)
|
||||
autocomplete_param_with_func(const char *const input, char *command, autocomplete_func func, gboolean previous, void *context)
|
||||
{
|
||||
GString *auto_msg = NULL;
|
||||
char *result = NULL;
|
||||
@@ -302,7 +302,7 @@ autocomplete_param_with_func(const char *const input, char *command, autocomplet
|
||||
}
|
||||
prefix[inp_len - len] = '\0';
|
||||
|
||||
char *found = func(prefix, previous);
|
||||
char *found = func(prefix, previous, context);
|
||||
if (found) {
|
||||
auto_msg = g_string_new(command_cpy);
|
||||
g_string_append(auto_msg, found);
|
||||
@@ -347,7 +347,7 @@ autocomplete_param_with_ac(const char *const input, char *command, Autocomplete
|
||||
}
|
||||
|
||||
char*
|
||||
autocomplete_param_no_with_func(const char *const input, char *command, int arg_number, autocomplete_func func, gboolean previous)
|
||||
autocomplete_param_no_with_func(const char *const input, char *command, int arg_number, autocomplete_func func, gboolean previous, void *context)
|
||||
{
|
||||
if (strncmp(input, command, strlen(command)) == 0) {
|
||||
GString *result_str = NULL;
|
||||
@@ -362,7 +362,7 @@ autocomplete_param_no_with_func(const char *const input, char *command, int arg_
|
||||
|
||||
// autocomplete param
|
||||
if (comp_str) {
|
||||
char *found = func(comp_str, previous);
|
||||
char *found = func(comp_str, previous, context);
|
||||
if (found) {
|
||||
result_str = g_string_new("");
|
||||
g_string_append(result_str, start_str);
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
typedef char* (*autocomplete_func)(const char *const, gboolean);
|
||||
typedef char* (*autocomplete_func)(const char *const, gboolean, void *);
|
||||
typedef struct autocomplete_t *Autocomplete;
|
||||
|
||||
// allocate new autocompleter with no items
|
||||
@@ -63,13 +63,13 @@ GList* autocomplete_create_list(Autocomplete ac);
|
||||
gint autocomplete_length(Autocomplete ac);
|
||||
|
||||
char* autocomplete_param_with_func(const char *const input, char *command,
|
||||
autocomplete_func func, gboolean previous);
|
||||
autocomplete_func func, gboolean previous, void *context);
|
||||
|
||||
char* autocomplete_param_with_ac(const char *const input, char *command,
|
||||
Autocomplete ac, gboolean quote, gboolean previous);
|
||||
|
||||
char* autocomplete_param_no_with_func(const char *const input, char *command,
|
||||
int arg_number, autocomplete_func func, gboolean previous);
|
||||
int arg_number, autocomplete_func func, gboolean previous, void *context);
|
||||
|
||||
void autocomplete_reset(Autocomplete ac);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user