aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Rob <rob.manea@gmail.com>2009-11-03 16:20:13 +0100
committerGravatar Rob <rob.manea@gmail.com>2009-11-03 16:20:13 +0100
commit849aacc54869eb047c710467802ef8aaa5fbc522 (patch)
tree6d759db8dbf524d6fe09846a09748bb0cbe045c7
parent77e2abd3d243d2edf57a4bfa63ffcd525a3fc478 (diff)
added include command
-rw-r--r--README2
-rw-r--r--uzbl-core.c30
-rw-r--r--uzbl-core.h3
3 files changed, 34 insertions, 1 deletions
diff --git a/README b/README
index cd3e8db..0be6ca9 100644
--- a/README
+++ b/README
@@ -178,6 +178,8 @@ The following commands are recognized:
- removes the entry "label" from one of the right click context menus
* hardcopy
- open print dialog
+* include <file>
+ - read contents of file and interprete commands
### VARIABLES AND CONSTANTS
diff --git a/uzbl-core.c b/uzbl-core.c
index 7b44c52..1383cc9 100644
--- a/uzbl-core.c
+++ b/uzbl-core.c
@@ -636,7 +636,8 @@ struct {const char *key; CommandInfo value;} cmdlist[] =
{ "menu_link_remove", {menu_remove_link, TRUE} },
{ "menu_image_remove", {menu_remove_image, TRUE} },
{ "menu_editable_remove", {menu_remove_edit, TRUE} },
- { "hardcopy", {hardcopy, TRUE} }
+ { "hardcopy", {hardcopy, TRUE} },
+ { "include", {include, TRUE} }
};
void
@@ -876,6 +877,33 @@ hardcopy(WebKitWebView *page, GArray *argv, GString *result) {
}
void
+include(WebKitWebView *page, GArray *argv, GString *result) {
+ (void) page;
+ (void) result;
+ gchar *pe = NULL, *path = NULL;
+ gchar *line;
+ int i;
+
+ if(!argv_idx(argv, 0))
+ return;
+
+ pe = parseenv(argv_idx(argv, 0));
+ if((path = find_existing_file(pe))) {
+ g_free(pe);
+
+ GArray* lines = read_file_by_line(path);
+ g_free(path);
+
+ while ((line = g_array_index(lines, gchar*, i))) {
+ parse_cmd_line (line, NULL);
+ i++;
+ g_free (line);
+ }
+ g_array_free (lines, TRUE);
+ }
+}
+
+void
act_dump_config() {
dump_config();
}
diff --git a/uzbl-core.h b/uzbl-core.h
index 67c1bda..c3fbc12 100644
--- a/uzbl-core.h
+++ b/uzbl-core.h
@@ -477,6 +477,9 @@ get_click_context();
void
hardcopy(WebKitWebView *page, GArray *argv, GString *result);
+void
+include(WebKitWebView *page, GArray *argv, GString *result);
+
typedef void (*Command)(WebKitWebView*, GArray *argv, GString *result);
typedef struct {