not contain more than one '%s' placeholder.
Example: searchengine-add dl=https://duckduckgo.com/lite/?q=%s
+.TP
+.BI "searchengine-remove " "SHORTCUT"
+Remove the search engine to the given \fISHORTCUT\fP.
+.TP
+.BI "searchengine-default " "SHORTCUT"
+Set the search engine for given \fISHORTCUT\fP as the default search engine.
+It doesn't metter if the \fISHORTCUT\fP is already in use or not to be able to
+set the default search engine.
.SS Configuration
.TP
.BI "set " VAR = VALUE
{"search-backward", command_search, {VB_SEARCH_BACKWARD}},
{"searchengine-add", command_searchengine,{1}},
{"searchengine-remove", command_searchengine,{0}},
+ {"searchengine-default", command_searchengine_default,{0}},
{"zoomin", command_zoom, {COMMAND_ZOOM_IN}},
{"zoomout", command_zoom, {COMMAND_ZOOM_OUT}},
{"zoominfull", command_zoom, {COMMAND_ZOOM_IN | COMMAND_ZOOM_FULL}},
return result;
}
+gboolean command_searchengine_default(const Arg* arg)
+{
+ vb_set_mode(VB_MODE_NORMAL, FALSE);
+
+ return searchengine_set_default(arg->s);
+}
+
gboolean command_zoom(const Arg* arg)
{
float step, level;
gboolean command_paste(const Arg* arg);
gboolean command_search(const Arg* arg);
gboolean command_searchengine(const Arg* arg);
+gboolean command_searchengine_default(const Arg* arg);
gboolean command_zoom(const Arg* arg);
gboolean command_history(const Arg* arg);
{"hmap <shift-tab>=hint-focus-prev"},
{"searchengine-add dl=https://duckduckgo.com/lite/?q=%s"},
{"searchengine-add dd=https://duckduckgo.com/?q=%s"},
+ {"searchengine-default dl"},
{"set images=on"},
{"set cursivfont=serif"},
{"set defaultencondig=utf-8"},
GSList* keys;
GString* modkeys;
GSList* searchengines;
+ char* searchengine_default; /* handle of the default search engine */
} Behaviour;
typedef struct {
extern VbCore vb;
+typedef struct {
+ char* handle;
+ char* uri;
+} Searchengine;
+
static GSList* searchengine_find(const char* handle);
static gboolean searchengine_is_valid_uri(const char* uri);
static void searchengine_free(Searchengine* se);
return FALSE;
}
+gboolean searchengine_set_default(const char* handle)
+{
+ /* do not check if the search engin exists to be able to set the default
+ * before defining the search engines */
+ OVERWRITE_STRING(vb.behave.searchengine_default, handle);
+
+ return TRUE;
+}
+
char* searchengine_get_uri(const char* handle)
{
- GSList* list = searchengine_find(handle);
+ char* def = vb.behave.searchengine_default;
+ GSList* l = searchengine_find(handle);
- if (list) {
- return ((Searchengine*)list->data)->uri;
+ if (l) {
+ return ((Searchengine*)l->data)->uri;
+ } else if (def && (l = searchengine_find(def))) {
+ return ((Searchengine*)l->data)->uri;
}
return NULL;
#ifndef _SEARCHENGINE_H
#define _SEARCHENGINE_H
-typedef struct {
- char* handle;
- char* uri;
-} Searchengine;
-
void searchengine_cleanup(void);
gboolean searchengine_add(const char* handle, const char* uri);
gboolean searchengine_remove(const char* handle);
+gboolean searchengine_set_default(const char* handle);
char* searchengine_get_uri(const char* handle);
#endif /* end of include guard: _SEARCHENGINE_H */