added print command
authorRobert Manea <gotmor@gmail.com>
Sat, 30 May 2009 11:22:08 +0000 (13:22 +0200)
committerRobert Manea <gotmor@gmail.com>
Sat, 30 May 2009 11:22:08 +0000 (13:22 +0200)
uzbl.c
uzbl.h

diff --git a/uzbl.c b/uzbl.c
index e870872..db7d7e9 100644 (file)
--- a/uzbl.c
+++ b/uzbl.c
@@ -616,7 +616,8 @@ static struct {char *name; Command command[2];} cmdlist[] =
     { "keycmd",             {keycmd, NOSPLIT}              },
     { "keycmd_nl",          {keycmd_nl, NOSPLIT}           },
     { "keycmd_bs",          {keycmd_bs, 0}                 },
-    { "chain",              {chain, 0}                     }
+    { "chain",              {chain, 0}                     },
+    { "print",              {print, NOSPLIT}               }
 };
 
 static void
@@ -675,6 +676,16 @@ get_var(WebKitWebView *page, GArray *argv) {
 }
 
 static void
+print(WebKitWebView *page, GArray *argv) {
+    (void) page;
+    gchar* buf;
+
+    buf = expand_vars(argv_idx(argv, 0));
+    puts(buf);
+    g_free(buf);
+}
+
+static void
 act_bind(WebKitWebView *page, GArray *argv) {
     (void) page;
     gchar **split = g_strsplit(argv_idx(argv, 0), " = ", 2);
@@ -1583,9 +1594,10 @@ parse_cmd_line(const char *ctl_line) {
     else { /* parse a command */
         gchar *ctlstrip;
         gchar **tokens = NULL;
+        len = strlen(ctl_line);
 
-        if (ctl_line[strlen(ctl_line) - 1] == '\n') /* strip trailing newline */
-            ctlstrip = g_strndup(ctl_line, strlen(ctl_line) - 1);
+        if (ctl_line[len - 1] == '\n') /* strip trailing newline */
+            ctlstrip = g_strndup(ctl_line, len - 1);
         else ctlstrip = g_strdup(ctl_line);
 
         tokens = g_strsplit(ctlstrip, " ", 2);
diff --git a/uzbl.h b/uzbl.h
index 6ab31f6..121d6b5 100644 (file)
--- a/uzbl.h
+++ b/uzbl.h
@@ -245,6 +245,9 @@ set_var_value(gchar *name, gchar *val);
 static gboolean
 get_var_value(const gchar *name);
 
+static void
+print(WebKitWebView *page, GArray *argv);
+
 static gboolean
 new_window_cb (WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, WebKitWebNavigationAction *navigation_action, WebKitWebPolicyDecision *policy_decision, gpointer user_data);