From f219ef203be9b8b89a8ef13b7ebc78aa3ff01112 Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Sat, 30 May 2009 13:22:08 +0200 Subject: added print command --- uzbl.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'uzbl.c') diff --git a/uzbl.c b/uzbl.c index e870872..db7d7e9 100644 --- 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 @@ -674,6 +675,16 @@ get_var(WebKitWebView *page, GArray *argv) { get_var_value(argv_idx(argv, 0)); } +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; @@ -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); -- cgit v1.2.3