about summary refs log tree commit diff stats
path: root/src/tools
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-05-20 10:26:48 +0200
committerMichael Vetter <jubalh@iodoru.org>2020-05-20 10:54:58 +0200
commitaef74f90ece0d71a981312372e9a10df64e7035c (patch)
treec094d6eb5b5a38e0e5a55e8794f8473eea15d756 /src/tools
parentce32d874e0a4587010f5535fe7bff6b7438da560 (diff)
downloadprofani-tty-aef74f90ece0d71a981312372e9a10df64e7035c.tar.gz
Only save max 20 urls
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/autocomplete.c12
-rw-r--r--src/tools/autocomplete.h2
2 files changed, 14 insertions, 0 deletions
diff --git a/src/tools/autocomplete.c b/src/tools/autocomplete.c
index 5e9f14f1..6c960ba2 100644
--- a/src/tools/autocomplete.c
+++ b/src/tools/autocomplete.c
@@ -385,6 +385,18 @@ autocomplete_param_no_with_func(const char *const input, char *command, int arg_
     return NULL;
 }
 
+/* remove the first message if we have more than max */
+void
+autocomplete_remove_older_than_max(Autocomplete ac, int maxsize)
+{
+    if (autocomplete_length(ac) > maxsize) {
+        GList *first = g_list_nth(ac->items, 0);
+        if (first) {
+            ac->items = g_list_delete_link(ac->items, first);
+        }
+    }
+}
+
 static gchar*
 _search_next(Autocomplete ac, GList *curr, gboolean quote)
 {
diff --git a/src/tools/autocomplete.h b/src/tools/autocomplete.h
index 90b17bb3..10bbbf61 100644
--- a/src/tools/autocomplete.h
+++ b/src/tools/autocomplete.h
@@ -74,4 +74,6 @@ char* autocomplete_param_no_with_func(const char *const input, char *command,
 void autocomplete_reset(Autocomplete ac);
 
 gboolean autocomplete_contains(Autocomplete ac, const char *value);
+
+void autocomplete_remove_older_than_max(Autocomplete ac, int maxsize);
 #endif