- custom configuration files
- tagged bookmarks
- open input or teaxteaeas with configurable external editor
+- user defined URL-shortcuts with placeholders
## Dependencies
- libwebkit-1.0
+.\" vim: ft=groff
.\" Process this file with
.\" groff -man -Tascii vimb.1
.TH PROJECT 1 "06/04/2013" "PROJECT/VERSION" "Vimb Manual"
.TP
.B yank-selection
Yank the selected text into the primary and secondary clipboard.
-.SS Searchengines
-Searchengines allows to query a searchengine instead of typing a full url. If
-a searchengine with shortcut 'dd' is defined you can use 'dd search terms' to
-perform a search query.
+.SS Shortcuts
+Shortcuts allows to open URL build up from a named tamplate with additional
+parameters. If a sortcut named 'dd' is defined, you can use it with `:open dd
+list of parameters' to open the generated URL.
+
+Shortcuts are a good to use searchengines where the URL is nearly the same but
+a single parameter is user diefined.
.TP
-.BI "searchengine-add " "SHORTCUT" "=" "URI"
-Adds a searchengine with the \fISHORTCUT\fP and search \fIURI\fP. The uri must
+.BI "shortcut-add " "SHORTCUT" "=" "URI"
+Adds a shortcut with the \fISHORTCUT\fP and search \fIURI\fP. The uri must
not contain more than one '%s' placeholder.
-Example: searchengine-add dl=https://duckduckgo.com/lite/?q=%s
+Example: shortcut-add dl=https://duckduckgo.com/lite/?q=%s
.TP
-.BI "searchengine-remove " "SHORTCUT"
+.BI "shortcut-remove " "SHORTCUT"
Remove the search engine to the given \fISHORTCUT\fP.
.TP
-.BI "searchengine-default " "SHORTCUT"
+.BI "shortcut-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.
#include "completion.h"
#include "hints.h"
#include "util.h"
-#include "searchengine.h"
+#include "shortcut.h"
#include "history.h"
#include "bookmark.h"
#include "dom.h"
{"tabopen-clipboard", command_paste, {VB_CLIPBOARD_PRIMARY | VB_CLIPBOARD_SECONDARY | VB_TARGET_NEW}},
{"search-forward", command_search, {VB_SEARCH_FORWARD}},
{"search-backward", command_search, {VB_SEARCH_BACKWARD}},
- {"searchengine-add", command_searchengine, {1}},
- {"searchengine-remove", command_searchengine, {0}},
- {"searchengine-default", command_searchengine_default, {0}},
+ {"shortcut-add", command_shortcut, {1}},
+ {"shortcut-remove", command_shortcut, {0}},
+ {"shortcut-default", command_shortcut_default, {0}},
{"zoomin", command_zoom, {COMMAND_ZOOM_IN}},
{"zoomout", command_zoom, {COMMAND_ZOOM_OUT}},
{"zoominfull", command_zoom, {COMMAND_ZOOM_IN | COMMAND_ZOOM_FULL}},
return true;
}
-gboolean command_searchengine(const Arg *arg)
+gboolean command_shortcut(const Arg *arg)
{
gboolean result;
if (arg->i) {
if ((handle = strchr(arg->s, '='))) {
*handle = '\0';
handle++;
- result = searchengine_add(arg->s, handle);
+ result = shortcut_add(arg->s, handle);
} else {
return false;
}
} else {
- /* remove the search engine */
- result = searchengine_remove(arg->s);
+ /* remove the shortcut */
+ result = shortcut_remove(arg->s);
}
vb_set_mode(VB_MODE_NORMAL, false);
return result;
}
-gboolean command_searchengine_default(const Arg *arg)
+gboolean command_shortcut_default(const Arg *arg)
{
vb_set_mode(VB_MODE_NORMAL, false);
- return searchengine_set_default(arg->s);
+ return shortcut_set_default(arg->s);
}
gboolean command_zoom(const Arg *arg)
gboolean command_yank(const Arg *arg);
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_shortcut(const Arg *arg);
+gboolean command_shortcut_default(const Arg *arg);
gboolean command_zoom(const Arg *arg);
gboolean command_history(const Arg *arg);
gboolean command_bookmark(const Arg *arg);
"cmap <up>=hist-prev",
"cmap <down>=hist-next",
"imap <ctrl-t>=editor",
- "searchengine-add dl=https://duckduckgo.com/lite/?q=%s",
- "searchengine-add dd=https://duckduckgo.com/?q=%s",
- "searchengine-default dl",
+ "shortcut-add dl=https://duckduckgo.com/lite/?q=%s",
+ "shortcut-add dd=https://duckduckgo.com/?q=%s",
+ "shortcut-default dl",
"set images=on",
"set cursivfont=serif",
"set defaultencondig=utf-8",
#include "completion.h"
#include "dom.h"
#include "hints.h"
-#include "searchengine.h"
+#include "shortcut.h"
#include "history.h"
#include "session.h"
uri = g_strdup_printf("file://%s", rp);
free(rp);
} else if (!strchr(path, '.')) {
- /* use a searchengine */
- uri = searchengine_get_uri(path);
+ /* use a shortcut */
+ uri = shortcut_get_uri(path);
}
if (!uri) {
command_cleanup();
setting_cleanup();
keybind_cleanup();
- searchengine_cleanup();
+ shortcut_cleanup();
history_cleanup();
for (int i = 0; i < FILES_LAST; i++) {
+++ /dev/null
-/**
- * vimb - a webkit based vim like browser.
- *
- * Copyright (C) 2012-2013 Daniel Carl
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see http://www.gnu.org/licenses/.
- */
-
-#include "main.h"
-#include "searchengine.h"
-#include "util.h"
-
-extern VbCore vb;
-
-typedef struct {
- char *handle;
- char *uri;
-} Searchengine;
-
-static GSList *searchengines;
-static char *default_handle = NULL;
-
-static GSList *find(const char *handle);
-static void free_searchengine(Searchengine *se);
-
-
-void searchengine_cleanup(void)
-{
- if (searchengines) {
- g_slist_free_full(searchengines, (GDestroyNotify)free_searchengine);
- }
-}
-
-gboolean searchengine_add(const char *handle, const char *uri)
-{
- /* validate if the uri contains only one %s sequence */
- if (!util_valid_format_string(uri, 's', 1)) {
- return false;
- }
- Searchengine *s = g_new0(Searchengine, 1);
-
- s->handle = g_strdup(handle);
- s->uri = g_strdup(uri);
-
- searchengines = g_slist_prepend(searchengines, s);
-
- return true;
-}
-
-gboolean searchengine_remove(const char *handle)
-{
- GSList *list = find(handle);
-
- if (list) {
- free_searchengine((Searchengine*)list->data);
- searchengines = g_slist_delete_link(searchengines, list);
-
- return true;
- }
-
- 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(default_handle, handle);
-
- return true;
-}
-
-/**
- * Retrieves the search uri for given query string.
- * Not that the memory of the returned uri must be freed.
- */
-char *searchengine_get_uri(const char *string)
-{
- GSList *l = NULL;
- char *p = NULL, *tmpl = NULL, *query = NULL, *uri = NULL;
-
- if ((p = strchr(string, ' '))) {
- *p = '\0';
- /* is the first word the handle? */
- if ((l = find(string))) {
- tmpl = ((Searchengine*)l->data)->uri;
- query = soup_uri_encode(p + 1, "&");
- } else {
- *p = ' ';
- }
- }
-
- if (!tmpl && (l = find(default_handle))) {
- tmpl = ((Searchengine*)l->data)->uri;
- query = soup_uri_encode(string, "&");
- }
-
- if (tmpl) {
- uri = g_strdup_printf(tmpl, query);
- g_free(query);
-
- return uri;
- }
-
- return NULL;
-}
-
-static GSList *find(const char *handle)
-{
- GSList *s;
- for (s = searchengines; s != NULL; s = s->next) {
- if (!strcmp(((Searchengine*)s->data)->handle, handle)) {
- return s;
- }
- }
-
- return NULL;
-}
-
-static void free_searchengine(Searchengine *se)
-{
- g_free(se->uri);
- g_free(se->handle);
- g_free(se);
-}
+++ /dev/null
-/**
- * vimb - a webkit based vim like browser.
- *
- * Copyright (C) 2012-2013 Daniel Carl
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see http://www.gnu.org/licenses/.
- */
-
-#ifndef _SEARCHENGINE_H
-#define _SEARCHENGINE_H
-
-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 */
--- /dev/null
+/**
+ * vimb - a webkit based vim like browser.
+ *
+ * Copyright (C) 2012-2013 Daniel Carl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/.
+ */
+
+#include "main.h"
+#include "shortcut.h"
+#include "util.h"
+
+extern VbCore vb;
+
+typedef struct {
+ char *handle;
+ char *uri;
+} Shortcut;
+
+static GSList *shortcuts;
+static char *default_handle = NULL;
+
+static GSList *find(const char *handle);
+static void free_shortcut(Shortcut *se);
+
+
+void shortcut_cleanup(void)
+{
+ if (shortcuts) {
+ g_slist_free_full(shortcuts, (GDestroyNotify)free_shortcut);
+ }
+}
+
+gboolean shortcut_add(const char *handle, const char *uri)
+{
+ /* validate if the uri contains only one %s sequence */
+ if (!util_valid_format_string(uri, 's', 1)) {
+ return false;
+ }
+ Shortcut *s = g_new0(Shortcut, 1);
+
+ s->handle = g_strdup(handle);
+ s->uri = g_strdup(uri);
+
+ shortcuts = g_slist_prepend(shortcuts, s);
+
+ return true;
+}
+
+gboolean shortcut_remove(const char *handle)
+{
+ GSList *list = find(handle);
+
+ if (list) {
+ free_shortcut((Shortcut*)list->data);
+ shortcuts = g_slist_delete_link(shortcuts, list);
+
+ return true;
+ }
+
+ return false;
+}
+
+gboolean shortcut_set_default(const char *handle)
+{
+ /* do not check if the shotcut exists to be able to set the default
+ * before defining the shotcut */
+ OVERWRITE_STRING(default_handle, handle);
+
+ return true;
+}
+
+/**
+ * Retrieves the uri for given query string. Not that the memory of the
+ * returned uri must be freed.
+ */
+char *shortcut_get_uri(const char *string)
+{
+ GSList *l = NULL;
+ char *p = NULL, *tmpl = NULL, *query = NULL, *uri = NULL;
+
+ if ((p = strchr(string, ' '))) {
+ *p = '\0';
+ /* is the first word the handle? */
+ if ((l = find(string))) {
+ tmpl = ((Shortcut*)l->data)->uri;
+ query = soup_uri_encode(p + 1, "&");
+ } else {
+ *p = ' ';
+ }
+ }
+
+ if (!tmpl && (l = find(default_handle))) {
+ tmpl = ((Shortcut*)l->data)->uri;
+ query = soup_uri_encode(string, "&");
+ }
+
+ if (tmpl) {
+ uri = g_strdup_printf(tmpl, query);
+ g_free(query);
+
+ return uri;
+ }
+
+ return NULL;
+}
+
+static GSList *find(const char *handle)
+{
+ GSList *s;
+ for (s = shortcuts; s != NULL; s = s->next) {
+ if (!strcmp(((Shortcut*)s->data)->handle, handle)) {
+ return s;
+ }
+ }
+
+ return NULL;
+}
+
+static void free_shortcut(Shortcut *se)
+{
+ g_free(se->uri);
+ g_free(se->handle);
+ g_free(se);
+}
--- /dev/null
+/**
+ * vimb - a webkit based vim like browser.
+ *
+ * Copyright (C) 2012-2013 Daniel Carl
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/.
+ */
+
+#ifndef _SHORTCUT_H
+#define _SHORTCUT_H
+
+void shortcut_cleanup(void);
+gboolean shortcut_add(const char *handle, const char *uri);
+gboolean shortcut_remove(const char *handle);
+gboolean shortcut_set_default(const char *handle);
+char *shortcut_get_uri(const char *handle);
+
+#endif /* end of include guard: _SHORTCUT_H */