about summary refs log tree commit diff stats
path: root/src/tools
diff options
context:
space:
mode:
authorPaul Fariello <paul@fariello.eu>2020-01-30 23:44:43 +0100
committerPaul Fariello <paul@fariello.eu>2020-01-31 10:07:08 +0100
commita52e3ea1d860b155c73869c3d6cc4fa81015b9cf (patch)
treef64dca66cc3d387d9f50325cf25d06cdbed3bd65 /src/tools
parent8fba8a8958146a0fa42d649339b66604defd6297 (diff)
downloadprofani-tty-a52e3ea1d860b155c73869c3d6cc4fa81015b9cf.tar.gz
Add context to autocomplete_with_func and use it for omemo trust command
Fix #1068
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/autocomplete.c8
-rw-r--r--src/tools/autocomplete.h6
2 files changed, 7 insertions, 7 deletions
diff --git a/src/tools/autocomplete.c b/src/tools/autocomplete.c
index 8b7a998c..5e9f14f1 100644
--- a/src/tools/autocomplete.c
+++ b/src/tools/autocomplete.c
@@ -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);
diff --git a/src/tools/autocomplete.h b/src/tools/autocomplete.h
index 8f2e5c96..90b17bb3 100644
--- a/src/tools/autocomplete.h
+++ b/src/tools/autocomplete.h
@@ -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);