about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-05-14 20:49:25 +0100
committerJames Booth <boothj5@gmail.com>2014-05-14 20:49:25 +0100
commit506ce9cb136c4c82114cd6b863f6362b53fa22ba (patch)
tree71a2cb19460de1242ece382537868860f41e4230
parent62dd30ff9068c7c4a851415314f0d2709079d17e (diff)
downloadprofani-tty-506ce9cb136c4c82114cd6b863f6362b53fa22ba.tar.gz
Added autocomplete for bookmark autojoin
-rw-r--r--src/command/command.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 65c56ab3..afc8bf05 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -1664,31 +1664,52 @@ _bookmark_autocomplete(char *input, int *size)
     char *found = NULL;
 
     gboolean result;
-    gchar **args = parse_args(input, 3, 7, &result);
+    gchar **args = parse_args(input, 3, 8, &result);
 
     if (result && ((strcmp(args[0], "add") == 0) || (strcmp(args[0], "update") == 0)) ) {
         GString *beginning = g_string_new("/bookmark ");
+        gboolean autojoin = FALSE;
+        int num_args = g_strv_length(args);
 
-        if (g_strv_length(args) > 2) {
+        if (num_args > 2) {
             g_string_append(beginning, args[0]);
             g_string_append(beginning, " ");
             g_string_append(beginning, args[1]);
+            if (num_args == 4 && g_strcmp0(args[2], "autojoin") == 0) {
+                g_string_append(beginning, " ");
+                g_string_append(beginning, args[2]);
+                autojoin = TRUE;
+            }
 
-            if (g_strv_length(args) > 4) {
+            if (num_args > 4) {
                 g_string_append(beginning, " ");
                 g_string_append(beginning, args[2]);
                 g_string_append(beginning, " ");
                 g_string_append(beginning, args[3]);
+                if (num_args == 6 && g_strcmp0(args[4], "autojoin") == 0) {
+                    g_string_append(beginning, " ");
+                    g_string_append(beginning, args[4]);
+                    autojoin = TRUE;
+                }
 
-                if (g_strv_length(args) > 6) {
+                if (num_args > 6) {
                     g_string_append(beginning, " ");
                     g_string_append(beginning, args[4]);
                     g_string_append(beginning, " ");
                     g_string_append(beginning, args[5]);
+                    if (num_args == 8 && g_strcmp0(args[6], "autojoin") == 0) {
+                        g_string_append(beginning, " ");
+                        g_string_append(beginning, args[6]);
+                        autojoin = TRUE;
+                    }
                 }
             }
 
-            found = autocomplete_param_with_ac(input, size, beginning->str, bookmark_property_ac);
+            if (autojoin) {
+                found = autocomplete_param_with_func(input, size, beginning->str, prefs_autocomplete_boolean_choice);
+            } else {
+                found = autocomplete_param_with_ac(input, size, beginning->str, bookmark_property_ac);
+            }
             g_string_free(beginning, TRUE);
             if (found != NULL) {
                 return found;