":open \fB!\fPfoo ba" will match all bookmark that have the tags "foo" or
"foot" and tags starting with "ba" like "ball".
.TP
+.B boomark tags
+The boomark tag completion allows to insert already used bookmars for the
+`:bma ` or `:bookmark-add ` commands.
+.TP
.B search
The search completion allow to get a filtered list of already done searches.
This completion starts by `/` or `?` in inputbox and performs a prefix
return found;
}
+gboolean bookmark_fill_tag_completion(GtkListStore *store, const char *input)
+{
+ gboolean found = false;
+ unsigned int len, i;
+ GtkTreeIter iter;
+ GList *src = NULL, *tags = NULL, *l;
+ Bookmark *bm;
+
+ /* get all distinct tags from bookmark file */
+ src = load(vb.files[FILES_BOOKMARK]);
+ for (GList *l = src; l; l = l->next) {
+ bm = (Bookmark*)l->data;
+ len = (bm->tags) ? g_strv_length(bm->tags) : 0;
+ for (i = 0; i < len; i++) {
+ char *tag = bm->tags[i];
+ /* add tag only if it isn't already in the list */
+ if (!g_list_find_custom(tags, tag, (GCompareFunc)strcmp)) {
+ tags = g_list_prepend(tags, tag);
+ }
+ }
+ }
+
+ /* generate the completion with the found tags */
+ if (!input || *input == '\0') {
+ for (l = tags; l; l = l->next) {
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter, COMPLETION_STORE_FIRST, l->data, -1);
+ found = true;
+ }
+ } else {
+ for (l = tags; l; l = l->next) {
+ if (g_str_has_prefix(l->data, input)) {
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter, COMPLETION_STORE_FIRST, l->data, -1);
+ found = true;
+ }
+ }
+ }
+ g_list_free_full(src, (GDestroyNotify)free_bookmark);
+ /* we don't need to free the values, because they where already removed by
+ * freeing the src list - we never allocated new momory for them */
+ g_list_free(tags);
+
+ return found;
+}
+
#ifdef FEATURE_QUEUE
/**
* Push a uri to the end of the queue.
gboolean bookmark_add(const char *uri, const char *title, const char *tags);
gboolean bookmark_remove(const char *uri);
gboolean bookmark_fill_completion(GtkListStore *store, const char *input);
+gboolean bookmark_fill_tag_completion(GtkListStore *store, const char *input);
#ifdef FEATURE_QUEUE
gboolean bookmark_queue_push(const char *uri);
gboolean bookmark_queue_unshift(const char *uri);
res = command_fill_completion(store, command);
} else if (type == VB_INPUT_SEARCH_FORWARD || type == VB_INPUT_SEARCH_BACKWARD) {
res = history_fill_completion(store, HISTORY_SEARCH, suffix);
+ } else if (type == VB_INPUT_BOOKMARK_ADD) {
+ res = bookmark_fill_tag_completion(store, suffix);
}
if (!res) {
{VB_INPUT_OPEN, ":open ", 6},
{VB_INPUT_TABOPEN, ":tabopen ", 9},
{VB_INPUT_SET, ":set ", 5},
+ {VB_INPUT_BOOKMARK_ADD, ":bma ", 5},
+ {VB_INPUT_BOOKMARK_ADD, ":bookmark-add ", 14},
{VB_INPUT_COMMAND, ":", 1},
{VB_INPUT_SEARCH_FORWARD, "/", 1},
{VB_INPUT_SEARCH_BACKWARD, "?", 1},
typedef enum {
VB_INPUT_UNKNOWN,
- VB_INPUT_SET = 1<<0,
- VB_INPUT_OPEN = 1<<1,
- VB_INPUT_TABOPEN = 1<<2,
- VB_INPUT_COMMAND = 1<<3,
- VB_INPUT_SEARCH_FORWARD = 1<<4,
- VB_INPUT_SEARCH_BACKWARD = 1<<5,
- VB_INPUT_ALL = VB_INPUT_OPEN | VB_INPUT_TABOPEN | VB_INPUT_SET | VB_INPUT_COMMAND | VB_INPUT_SEARCH_FORWARD | VB_INPUT_SEARCH_BACKWARD,
+ VB_INPUT_SET = 0x01,
+ VB_INPUT_OPEN = 0x02,
+ VB_INPUT_TABOPEN = 0x04,
+ VB_INPUT_COMMAND = 0x08,
+ VB_INPUT_SEARCH_FORWARD = 0x10,
+ VB_INPUT_SEARCH_BACKWARD = 0x20,
+ VB_INPUT_BOOKMARK_ADD = 0x40,
+ VB_INPUT_ALL = 0xff, /* map to match all input types */
} VbInputType;
enum {