[Vimprobable-users] [PATCH 2/4] read per-site settings from the rc file
Vimprobable is a lean web browser optimised for full keyboard control
Brought to you by:
hanness
|
From: Hannes S. <ha...@yl...> - 2012-04-12 21:29:40
|
---
utilities.c | 24 ++++++++++++++++++++++--
vimprobable.h | 5 +++++
vimprobablerc.5 | 18 ++++++++++++++++++
3 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/utilities.c b/utilities.c
index 78f4586..856eb36 100644
--- a/utilities.c
+++ b/utilities.c
@@ -20,7 +20,7 @@ extern Key keys[];
extern char *error_msg;
extern char *config_base;
extern VSettings cursettings;
-static GList *dynamic_searchengines = NULL, *dynamic_uri_handlers = NULL;
+static GList *dynamic_searchengines = NULL, *dynamic_uri_handlers = NULL, *site_settings = NULL;
void add_modkeys(char key);
@@ -721,6 +721,7 @@ read_rcfile(const char *config)
gboolean found_malformed_lines = FALSE;
Searchengine *new;
URIHandler *newhandler;
+ SSettings *newsettings;
if (access(config, F_OK) != 0)
return FILE_NOT_FOUND;
@@ -738,7 +739,26 @@ read_rcfile(const char *config)
continue;
t = strlen(s);
s[t - 1] = '\0';
- if (strncmp(s, "searchengine", 12) == 0) {
+ if (strncmp(s, "site ", 5) == 0) {
+ buffer = (s + 4);
+ while (buffer[0] == ' ')
+ buffer++;
+ /* split line at whitespace */
+ index = split_string_at_whitespace(buffer);
+ if (index < 0 || buffer[0] == '\0' || buffer[index] == '\0') {
+ fprintf(stderr, "site settings: syntax error on line %d\n", linum);
+ found_malformed_lines = TRUE;
+ continue;
+ }
+ newsettings = malloc(sizeof(SSettings));
+ if (newsettings == NULL) {
+ fprintf(stderr, "Memory exhausted while loading site settings.\n");
+ exit(EXIT_FAILURE);
+ }
+ newsettings->url = g_strdup(buffer);
+ newsettings->settings = g_strdup(buffer+index);
+ site_settings = g_list_prepend(site_settings, newsettings);
+ } else if (strncmp(s, "searchengine", 12) == 0) {
buffer = (s + 12);
while (buffer[0] == ' ')
buffer++;
diff --git a/vimprobable.h b/vimprobable.h
index 16d4ee9..f24bc56 100644
--- a/vimprobable.h
+++ b/vimprobable.h
@@ -144,6 +144,11 @@ typedef struct {
} VSettings;
typedef struct {
+ char *url;
+ char *settings;
+} SSettings;
+
+typedef struct {
guint mask;
guint modkey;
guint key;
diff --git a/vimprobablerc.5 b/vimprobablerc.5
index f69dda9..cf1773c 100644
--- a/vimprobablerc.5
+++ b/vimprobablerc.5
@@ -263,6 +263,24 @@ handler <URI schema> <handler command with exactly one %s>
where the %s serves as a placeholder for the rest of the URI.
+.SH PER-SITE SETTINGS
+
+You can define overrides for many internal settings on a website basis. This
+includes anything you can define interactively using the :set command. This
+is useful to define exceptions to the default settings using a whitelist or
+blacklist approach.
+
+The following syntax must be used in the configuration file
+(without the angle brackets):
+
+.RS 4
+site <URL schema> <list of settings separated by pipe symbols (|)>
+.RE
+
+where any site which begins with the defined URL schema will use the defined
+special settings. Visiting another URL again in the same browser window will
+automatically revert the browser to the default settings.
+
.SH BUGS
There has not been any significant bug-hunting yet.
.SH AUTHORS
--
1.7.2.5
|