From 6dcbd38b46b3d43af443f297348f406250fe9fce Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Wed, 27 May 2009 10:22:51 +0200 Subject: added dump_config action --- uzbl.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'uzbl.h') diff --git a/uzbl.h b/uzbl.h index cd5e3ef..287d9ef 100644 --- a/uzbl.h +++ b/uzbl.h @@ -416,12 +416,24 @@ save_cookies (SoupMessage *msg, static void set_var(WebKitWebView *page, GArray *argv); +static void +act_dump_config(); + static void render_html(); static void set_timeout(int seconds); +static void +dump_var_hash(gpointer k, gpointer v, gpointer ud); + +static void +dump_key_hash(gpointer k, gpointer v, gpointer ud); + +static void +dump_config(); + /* Command callbacks */ static void -- cgit v1.2.3 From eacd934e6456f354df9a1eaedee7e10964eea90c Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Wed, 27 May 2009 13:14:51 +0200 Subject: added insert_indicator and command_indicator --- uzbl.c | 11 +++++++++-- uzbl.h | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'uzbl.h') diff --git a/uzbl.c b/uzbl.c index 282be1b..0fc5911 100644 --- a/uzbl.c +++ b/uzbl.c @@ -88,7 +88,7 @@ typedef const struct { enum {TYPE_INT, TYPE_STR}; /* an abbreviation to help keep the table's width humane */ -#define PTR(var, t, d, fun) { .ptr = (void*)&(var), .type = TYPE_##t, .dump = d,.func = fun } +#define PTR(var, t, d, fun) { .ptr = (void*)&(var), .type = TYPE_##t, .dump = d, .func = fun } const struct { char *name; @@ -110,6 +110,8 @@ const struct { { "status_pbar_pending", PTR(uzbl.gui.sbar.progress_u, STR, 1, update_title)}, { "status_pbar_width", PTR(uzbl.gui.sbar.progress_w, INT, 1, update_title)}, { "status_background", PTR(uzbl.behave.status_background, STR, 1, update_title)}, + { "insert_indicator", PTR(uzbl.behave.insert_indicator, STR, 1, update_title)}, + { "command_indicator", PTR(uzbl.behave.cmd_indicator, STR, 1, update_title)}, { "title_format_long", PTR(uzbl.behave.title_format_long, STR, 1, update_title)}, { "title_format_short", PTR(uzbl.behave.title_format_short, STR, 1, update_title)}, { "insert_mode", PTR(uzbl.behave.insert_mode, INT, 1, NULL)}, @@ -904,7 +906,8 @@ expand_template(const char *template, gboolean escape_markup) { break; case SYM_MODE: g_string_append(ret, - uzbl.behave.insert_mode?"[I]":"[C]"); + uzbl.behave.insert_mode? + uzbl.behave.insert_indicator:uzbl.behave.cmd_indicator); break; case SYM_MSG: g_string_append(ret, @@ -2297,6 +2300,10 @@ main (int argc, char* argv[]) { uzbl.behave.html_timeout = 60; uzbl.behave.base_url = g_strdup("http://invalid"); + /* default mode indicators */ + uzbl.behave.insert_indicator = g_strdup("I"); + uzbl.behave.cmd_indicator = g_strdup("C"); + setup_regex(); setup_scanner(); commands_hash (); diff --git a/uzbl.h b/uzbl.h index 287d9ef..8618675 100644 --- a/uzbl.h +++ b/uzbl.h @@ -171,6 +171,8 @@ typedef struct { guint mode; gchar* base_url; gchar* html_endmarker; + gchar* insert_indicator; + gchar* cmd_indicator; GString* html_buffer; guint html_timeout; -- cgit v1.2.3 From 7b2b1b142159f2c7ec0de334b303723dd2c6e70c Mon Sep 17 00:00:00 2001 From: DuClare Date: Thu, 28 May 2009 15:53:09 +0300 Subject: Add action 'keycmd_bs' for backspacing a char --- uzbl.c | 17 ++++++++++++----- uzbl.h | 3 +++ 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'uzbl.h') diff --git a/uzbl.c b/uzbl.c index ba6655a..a8b97c4 100644 --- a/uzbl.c +++ b/uzbl.c @@ -567,7 +567,8 @@ static struct {char *name; Command command[2];} cmdlist[] = { "toggle_insert_mode", {toggle_insert_mode, 0} }, { "runcmd", {runcmd, NOSPLIT} }, { "set", {set_var, NOSPLIT} }, - { "dump_config", {act_dump_config, 0} } + { "dump_config", {act_dump_config, 0} }, + { "keycmd_bs", {keycmd_bs, 0} } }; static void @@ -746,6 +747,14 @@ new_window_load_uri (const gchar * uri) { g_string_free (to_execute, TRUE); } +static void +keycmd_bs (WebKitWebView *page, GArray *argv) { + (void)page; + (void)argv; + g_string_truncate(uzbl.state.keycmd, uzbl.state.keycmd->len - 1); + update_title(); +} + static void close_uzbl (WebKitWebView *page, GArray *argv) { (void)page; @@ -1856,10 +1865,8 @@ key_press_cb (GtkWidget* window, GdkEventKey* event) return TRUE; } - if ((event->keyval == GDK_BackSpace) && (uzbl.state.keycmd->len > 0)) { - g_string_truncate(uzbl.state.keycmd, uzbl.state.keycmd->len - 1); - update_title(); - } + if (event->keyval == GDK_BackSpace) + keycmd_bs(NULL, NULL); gboolean key_ret = FALSE; if ((event->keyval == GDK_Return) || (event->keyval == GDK_KP_Enter)) diff --git a/uzbl.h b/uzbl.h index 8618675..b7a5565 100644 --- a/uzbl.h +++ b/uzbl.h @@ -305,6 +305,9 @@ load_uri (WebKitWebView * web_view, GArray *argv); static void new_window_load_uri (const gchar * uri); +static void +keycmd_bs (WebKitWebView *page, GArray *argv); + static void close_uzbl (WebKitWebView *page, GArray *argv); -- cgit v1.2.3 From 51b0c647afd2c93e020fd414065805cd20e8a83f Mon Sep 17 00:00:00 2001 From: DuClare Date: Thu, 28 May 2009 16:02:40 +0300 Subject: Add actions keycmd and keycmd_nl --- uzbl.c | 20 ++++++++++++++++++++ uzbl.h | 6 ++++++ 2 files changed, 26 insertions(+) (limited to 'uzbl.h') diff --git a/uzbl.c b/uzbl.c index a8b97c4..70b3ed7 100644 --- a/uzbl.c +++ b/uzbl.c @@ -568,6 +568,8 @@ static struct {char *name; Command command[2];} cmdlist[] = { "runcmd", {runcmd, NOSPLIT} }, { "set", {set_var, NOSPLIT} }, { "dump_config", {act_dump_config, 0} }, + { "keycmd", {keycmd, NOSPLIT} }, + { "keycmd_nl", {keycmd_nl, NOSPLIT} }, { "keycmd_bs", {keycmd_bs, 0} } }; @@ -747,6 +749,24 @@ new_window_load_uri (const gchar * uri) { g_string_free (to_execute, TRUE); } +static void +keycmd (WebKitWebView *page, GArray *argv) { + (void)page; + (void)argv; + g_string_assign(uzbl.state.keycmd, argv_idx(argv, 0)); + run_keycmd(FALSE); + update_title(); +} + +static void +keycmd_nl (WebKitWebView *page, GArray *argv) { + (void)page; + (void)argv; + g_string_assign(uzbl.state.keycmd, argv_idx(argv, 0)); + run_keycmd(TRUE); + update_title(); +} + static void keycmd_bs (WebKitWebView *page, GArray *argv) { (void)page; diff --git a/uzbl.h b/uzbl.h index b7a5565..0750e63 100644 --- a/uzbl.h +++ b/uzbl.h @@ -305,6 +305,12 @@ load_uri (WebKitWebView * web_view, GArray *argv); static void new_window_load_uri (const gchar * uri); +static void +keycmd (WebKitWebView *page, GArray *argv); + +static void +keycmd_nl (WebKitWebView *page, GArray *argv); + static void keycmd_bs (WebKitWebView *page, GArray *argv); -- cgit v1.2.3 From cf6f5f41dfb424213b6a8d06edadc0a4c384661d Mon Sep 17 00:00:00 2001 From: DuClare Date: Thu, 28 May 2009 16:05:28 +0300 Subject: Remove KEYCMD and KEYCMDN commands --- uzbl.c | 15 --------------- uzbl.h | 1 - 2 files changed, 16 deletions(-) (limited to 'uzbl.h') diff --git a/uzbl.c b/uzbl.c index 70b3ed7..371b40f 100644 --- a/uzbl.c +++ b/uzbl.c @@ -1198,8 +1198,6 @@ setup_regex() { G_REGEX_UNGREEDY|G_REGEX_OPTIMIZE, 0, NULL); uzbl.comm.act_regex = g_regex_new("^[Aa][a-zA-Z]*\\s+([^ \\n]+)\\s*([^\\n]*)?$", G_REGEX_OPTIMIZE, 0, NULL); - uzbl.comm.keycmd_regex = g_regex_new("^[Kk][a-zA-Z]*\\s+([^\\n]+)$", - G_REGEX_OPTIMIZE, 0, NULL); } static gboolean @@ -1558,19 +1556,6 @@ parse_cmd_line(const char *ctl_line) { else printf("Error in command: %s\n", tokens[0]); } - /* KEYCMD command */ - else if(ctl_line[0] == 'K' || ctl_line[0] == 'k') { - tokens = g_regex_split(uzbl.comm.keycmd_regex, ctl_line, 0); - if(tokens[0][0] == 0) { - /* should incremental commands want each individual "keystroke" - sent in a loop or the whole string in one go like now? */ - g_string_assign(uzbl.state.keycmd, tokens[1]); - run_keycmd(FALSE); - if (g_strstr_len(ctl_line, 7, "n") || g_strstr_len(ctl_line, 7, "N")) - run_keycmd(TRUE); - update_title(); - } - } /* Comments */ else if( (ctl_line[0] == '#') || (ctl_line[0] == ' ') diff --git a/uzbl.h b/uzbl.h index 0750e63..fe63b3c 100644 --- a/uzbl.h +++ b/uzbl.h @@ -96,7 +96,6 @@ typedef struct { /* command parsing regexes */ GRegex *set_regex; GRegex *act_regex; - GRegex *keycmd_regex; GRegex *get_regex; GRegex *bind_regex; gchar *sync_stdout; -- cgit v1.2.3 From cbc4a4fcf731d6d215ce47fa67bfa7e0b9feddd8 Mon Sep 17 00:00:00 2001 From: DuClare Date: Thu, 28 May 2009 18:46:29 +0300 Subject: Add 'chain' action for binding multiple actions --- uzbl.c | 16 +++++++++++++++- uzbl.h | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'uzbl.h') diff --git a/uzbl.c b/uzbl.c index 371b40f..a064e99 100644 --- a/uzbl.c +++ b/uzbl.c @@ -570,7 +570,8 @@ static struct {char *name; Command command[2];} cmdlist[] = { "dump_config", {act_dump_config, 0} }, { "keycmd", {keycmd, NOSPLIT} }, { "keycmd_nl", {keycmd_nl, NOSPLIT} }, - { "keycmd_bs", {keycmd_bs, 0} } + { "keycmd_bs", {keycmd_bs, 0} }, + { "chain", {chain, 0} } }; static void @@ -749,6 +750,19 @@ new_window_load_uri (const gchar * uri) { g_string_free (to_execute, TRUE); } +static void +chain (WebKitWebView *page, GArray *argv) { + (void)page; + gchar *a = NULL; + gchar **parts = NULL; + guint i = 0; + while ((a = argv_idx(argv, i++))) { + parts = g_strsplit (a, " ", 2); + parse_command(parts[0], parts[1]); + g_strfreev (parts); + } +} + static void keycmd (WebKitWebView *page, GArray *argv) { (void)page; diff --git a/uzbl.h b/uzbl.h index fe63b3c..a36b3f7 100644 --- a/uzbl.h +++ b/uzbl.h @@ -304,6 +304,9 @@ load_uri (WebKitWebView * web_view, GArray *argv); static void new_window_load_uri (const gchar * uri); +static void +chain (WebKitWebView *page, GArray *argv); + static void keycmd (WebKitWebView *page, GArray *argv); -- cgit v1.2.3 From afce27422a221c718958a06a1e7f804f0a59003d Mon Sep 17 00:00:00 2001 From: Sylvester Johansson Date: Thu, 28 May 2009 22:13:24 +0200 Subject: OH GOD I DON'T KNOW WHAT I AM DOING --- docs/INSTALL | 2 +- examples/configs/sampleconfig-dev | 5 +- examples/data/style.css | 4 + examples/scripts/linkfollow.js | 22 +++-- uzbl.c | 171 ++++++++++++++++++++++++-------------- uzbl.h | 14 ++++ 6 files changed, 144 insertions(+), 74 deletions(-) (limited to 'uzbl.h') diff --git a/docs/INSTALL b/docs/INSTALL index 440157a..3453e03 100644 --- a/docs/INSTALL +++ b/docs/INSTALL @@ -29,7 +29,7 @@ Dependencies * pkgconfig (for Make/gcc) * libwebkit 1.1.4 or higher * libsoup 2.24 or higher (dep for webkit/gtk+) -* gtk 2 something something +* gtk 2.14 or higher Optional/Recommended -------------------- diff --git a/examples/configs/sampleconfig-dev b/examples/configs/sampleconfig-dev index 3deeac1..0dcc0d2 100644 --- a/examples/configs/sampleconfig-dev +++ b/examples/configs/sampleconfig-dev @@ -60,7 +60,7 @@ set shell_cmd = sh -c set show_status = 1 # you can optionally use this setting to override the background color of the statusbar from your GTK theme. set status_background = #303030 -set status_format = MODE [KEYCMD] LOAD_PROGRESSBAR URI NAME MSGSELECTED_URI +set status_format = [MODE] [KEYCMD] LOAD_PROGRESSBAR URI NAME MSGSELECTED_URI set status_top = 0 # define how your titlebar should look like. (short = statusbar is also shown, long = show everything you must see if statusbar is off) set title_format_short = TITLE - Uzbl browser @@ -69,7 +69,8 @@ set title_format_long = KEYCMD MODE TITLE - Uzbl browser > SELECTED_URI set status_pbar_done = * set status_pbar_pending = - set status_pbar_width = 12 - +set insert_indicator = I +set command_indicator = C set modkey = Mod1 # reset to command mode when new page is loaded set reset_command_mode = 1 diff --git a/examples/data/style.css b/examples/data/style.css index 9789e6f..de0a38b 100644 --- a/examples/data/style.css +++ b/examples/data/style.css @@ -1,6 +1,10 @@ .uzbl_highlight { background-color: yellow;} .uzbl_h_first { background-color: lightgreen;} +.uzbl_follow { border-style: dotted; + border-width: thin; +} + #uzbl_hint > div { display: inline; border: 2px solid #4a6600; diff --git a/examples/scripts/linkfollow.js b/examples/scripts/linkfollow.js index e77219c..aad7353 100644 --- a/examples/scripts/linkfollow.js +++ b/examples/scripts/linkfollow.js @@ -10,7 +10,7 @@ // bind f_ = js hints.follow("%s",hints.open) // // At the moment, it may be useful to have way of forcing uzbl to load the script -// bind :lf = script /usr/share/examples/scripts/linkfollow.js +// bind :lf = script /usr/share/uzbl/examples/scripts/linkfollow.js // // The default style for the hints are pretty ugly, so it is recommended to add the following // to config file @@ -25,11 +25,20 @@ function Hints(){ + // Settings + //////////////////////////////////////////////////////////////////////////// // if set to true, you must explicitly call hints.follow(), otherwise it will // follow the link if there is only one matching result var requireReturn = true; + // Case sensitivity flag + var matchCase = "i"; + + // For case sensitive matching, uncomment: + // var matchCase = ""; + + var uzblid = 'uzbl_hint'; var uzblclass = 'uzbl_highlight'; var uzblclassfirst = 'uzbl_h_first'; @@ -81,7 +90,7 @@ function Hints(){ function Matcher(str){ var numbers = str.replace(/[^\d]/g,""); - var words = str.replace(/\d/g,"").split(/\s+/).map(function (n) { return new RegExp(n,"i")}); + var words = str.replace(/\d/g,"").split(/\s+/).map(function (n) { return new RegExp(n,matchCase)}); this.test = test; this.toString = toString; this.numbers = numbers; @@ -195,10 +204,12 @@ function Hints(){ this.openNewWindow = function(item){ // TODO: this doesn't work yet + item.className += " uzbl_follow"; window.open(item.href,"uzblnew",""); } this.open = function(item){ simulateMouseOver(item); + item.className += " uzbl_follow"; window.location = item.href; } @@ -222,13 +233,6 @@ function Hints(){ var item = items[0].node; } if (item) { - // This causes some elements to move around. Guess it should only be applied to - // links - item.style.margin -= 3; - item.style.padding -= 3; - item.style.borderStyle = "dotted"; - item.style.borderWidth = "thin"; - var name = item.tagName; if (name == 'A') { if(item.click) {item.click()}; diff --git a/uzbl.c b/uzbl.c index 60c9eaa..ba6655a 100644 --- a/uzbl.c +++ b/uzbl.c @@ -81,72 +81,75 @@ GOptionEntry entries[] = typedef const struct { void **ptr; int type; + int dump; void (*func)(void); } uzbl_cmdprop; enum {TYPE_INT, TYPE_STR}; /* an abbreviation to help keep the table's width humane */ -#define PTR(var, t, fun) { .ptr = (void*)&(var), .type = TYPE_##t, .func = fun } +#define PTR(var, t, d, fun) { .ptr = (void*)&(var), .type = TYPE_##t, .dump = d, .func = fun } const struct { char *name; uzbl_cmdprop cp; } var_name_to_ptr[] = { -/* variable name pointer to variable in code type callback function */ +/* variable name pointer to variable in code type dump callback function */ /* --------------------------------------------------------------------------------------- */ - { "uri", PTR(uzbl.state.uri, STR, cmd_load_uri)}, - { "mode", PTR(uzbl.behave.mode, INT, NULL)}, - { "inject_html", PTR(uzbl.behave.inject_html, STR, cmd_inject_html)}, - { "base_url", PTR(uzbl.behave.base_url, STR, NULL)}, - { "html_endmarker", PTR(uzbl.behave.html_endmarker, STR, NULL)}, - { "html_mode_timeout", PTR(uzbl.behave.html_timeout, INT, NULL)}, - { "status_message", PTR(uzbl.gui.sbar.msg, STR, update_title)}, - { "show_status", PTR(uzbl.behave.show_status, INT, cmd_set_status)}, - { "status_top", PTR(uzbl.behave.status_top, INT, move_statusbar)}, - { "status_format", PTR(uzbl.behave.status_format, STR, update_title)}, - { "status_pbar_done", PTR(uzbl.gui.sbar.progress_s, STR, update_title)}, - { "status_pbar_pending", PTR(uzbl.gui.sbar.progress_u, STR, update_title)}, - { "status_pbar_width", PTR(uzbl.gui.sbar.progress_w, INT, update_title)}, - { "status_background", PTR(uzbl.behave.status_background, STR, update_title)}, - { "title_format_long", PTR(uzbl.behave.title_format_long, STR, update_title)}, - { "title_format_short", PTR(uzbl.behave.title_format_short, STR, update_title)}, - { "insert_mode", PTR(uzbl.behave.insert_mode, INT, NULL)}, - { "always_insert_mode", PTR(uzbl.behave.always_insert_mode, INT, cmd_always_insert_mode)}, - { "reset_command_mode", PTR(uzbl.behave.reset_command_mode, INT, NULL)}, - { "modkey", PTR(uzbl.behave.modkey, STR, cmd_modkey)}, - { "load_finish_handler", PTR(uzbl.behave.load_finish_handler, STR, NULL)}, - { "load_start_handler", PTR(uzbl.behave.load_start_handler, STR, NULL)}, - { "load_commit_handler", PTR(uzbl.behave.load_commit_handler, STR, NULL)}, - { "history_handler", PTR(uzbl.behave.history_handler, STR, NULL)}, - { "download_handler", PTR(uzbl.behave.download_handler, STR, NULL)}, - { "cookie_handler", PTR(uzbl.behave.cookie_handler, STR, cmd_cookie_handler)}, - { "fifo_dir", PTR(uzbl.behave.fifo_dir, STR, cmd_fifo_dir)}, - { "socket_dir", PTR(uzbl.behave.socket_dir, STR, cmd_socket_dir)}, - { "http_debug", PTR(uzbl.behave.http_debug, INT, cmd_http_debug)}, - { "shell_cmd", PTR(uzbl.behave.shell_cmd, STR, NULL)}, - { "proxy_url", PTR(uzbl.net.proxy_url, STR, set_proxy_url)}, - { "max_conns", PTR(uzbl.net.max_conns, INT, cmd_max_conns)}, - { "max_conns_host", PTR(uzbl.net.max_conns_host, INT, cmd_max_conns_host)}, - { "useragent", PTR(uzbl.net.useragent, STR, cmd_useragent)}, + { "uri", PTR(uzbl.state.uri, STR, 1, cmd_load_uri)}, + { "mode", PTR(uzbl.behave.mode, INT, 0, NULL)}, + { "inject_html", PTR(uzbl.behave.inject_html, STR, 0, cmd_inject_html)}, + { "base_url", PTR(uzbl.behave.base_url, STR, 1, NULL)}, + { "html_endmarker", PTR(uzbl.behave.html_endmarker, STR, 1, NULL)}, + { "html_mode_timeout", PTR(uzbl.behave.html_timeout, INT, 1, NULL)}, + { "status_message", PTR(uzbl.gui.sbar.msg, STR, 1, update_title)}, + { "show_status", PTR(uzbl.behave.show_status, INT, 1, cmd_set_status)}, + { "status_top", PTR(uzbl.behave.status_top, INT, 1, move_statusbar)}, + { "status_format", PTR(uzbl.behave.status_format, STR, 1, update_title)}, + { "status_pbar_done", PTR(uzbl.gui.sbar.progress_s, STR, 1, update_title)}, + { "status_pbar_pending", PTR(uzbl.gui.sbar.progress_u, STR, 1, update_title)}, + { "status_pbar_width", PTR(uzbl.gui.sbar.progress_w, INT, 1, update_title)}, + { "status_background", PTR(uzbl.behave.status_background, STR, 1, update_title)}, + { "insert_indicator", PTR(uzbl.behave.insert_indicator, STR, 1, update_title)}, + { "command_indicator", PTR(uzbl.behave.cmd_indicator, STR, 1, update_title)}, + { "title_format_long", PTR(uzbl.behave.title_format_long, STR, 1, update_title)}, + { "title_format_short", PTR(uzbl.behave.title_format_short, STR, 1, update_title)}, + { "insert_mode", PTR(uzbl.behave.insert_mode, INT, 1, NULL)}, + { "always_insert_mode", PTR(uzbl.behave.always_insert_mode, INT, 1, cmd_always_insert_mode)}, + { "reset_command_mode", PTR(uzbl.behave.reset_command_mode, INT, 1, NULL)}, + { "modkey", PTR(uzbl.behave.modkey, STR, 1, cmd_modkey)}, + { "load_finish_handler", PTR(uzbl.behave.load_finish_handler, STR, 1, NULL)}, + { "load_start_handler", PTR(uzbl.behave.load_start_handler, STR, 1, NULL)}, + { "load_commit_handler", PTR(uzbl.behave.load_commit_handler, STR, 1, NULL)}, + { "history_handler", PTR(uzbl.behave.history_handler, STR, 1, NULL)}, + { "download_handler", PTR(uzbl.behave.download_handler, STR, 1, NULL)}, + { "cookie_handler", PTR(uzbl.behave.cookie_handler, STR, 1, cmd_cookie_handler)}, + { "fifo_dir", PTR(uzbl.behave.fifo_dir, STR, 1, cmd_fifo_dir)}, + { "socket_dir", PTR(uzbl.behave.socket_dir, STR, 1, cmd_socket_dir)}, + { "http_debug", PTR(uzbl.behave.http_debug, INT, 1, cmd_http_debug)}, + { "shell_cmd", PTR(uzbl.behave.shell_cmd, STR, 1, NULL)}, + { "proxy_url", PTR(uzbl.net.proxy_url, STR, 1, set_proxy_url)}, + { "max_conns", PTR(uzbl.net.max_conns, INT, 1, cmd_max_conns)}, + { "max_conns_host", PTR(uzbl.net.max_conns_host, INT, 1, cmd_max_conns_host)}, + { "useragent", PTR(uzbl.net.useragent, STR, 1, cmd_useragent)}, /* exported WebKitWebSettings properties*/ - { "font_size", PTR(uzbl.behave.font_size, INT, cmd_font_size)}, - { "monospace_size", PTR(uzbl.behave.monospace_size, INT, cmd_font_size)}, - { "minimum_font_size", PTR(uzbl.behave.minimum_font_size, INT, cmd_minimum_font_size)}, - { "disable_plugins", PTR(uzbl.behave.disable_plugins, INT, cmd_disable_plugins)}, - { "disable_scripts", PTR(uzbl.behave.disable_scripts, INT, cmd_disable_scripts)}, - { "autoload_images", PTR(uzbl.behave.autoload_img, INT, cmd_autoload_img)}, - { "autoshrink_images", PTR(uzbl.behave.autoshrink_img, INT, cmd_autoshrink_img)}, - { "enable_spellcheck", PTR(uzbl.behave.enable_spellcheck, INT, cmd_enable_spellcheck)}, - { "enable_private", PTR(uzbl.behave.enable_private, INT, cmd_enable_private)}, - { "print_backgrounds", PTR(uzbl.behave.print_bg, INT, cmd_print_bg)}, - { "stylesheet_uri", PTR(uzbl.behave.style_uri, STR, cmd_style_uri)}, - { "resizable_text_areas",PTR(uzbl.behave.resizable_txt, INT, cmd_resizable_txt)}, - { "default_encoding", PTR(uzbl.behave.default_encoding, STR, cmd_default_encoding)}, - { "enforce_96_dpi", PTR(uzbl.behave.enforce_96dpi, INT, cmd_enforce_96dpi)}, - { "caret_browsing", PTR(uzbl.behave.caret_browsing, INT, cmd_caret_browsing)}, - - { NULL, {.ptr = NULL, .type = TYPE_INT, .func = NULL}} + { "font_size", PTR(uzbl.behave.font_size, INT, 1, cmd_font_size)}, + { "monospace_size", PTR(uzbl.behave.monospace_size, INT, 1, cmd_font_size)}, + { "minimum_font_size", PTR(uzbl.behave.minimum_font_size, INT, 1, cmd_minimum_font_size)}, + { "disable_plugins", PTR(uzbl.behave.disable_plugins, INT, 1, cmd_disable_plugins)}, + { "disable_scripts", PTR(uzbl.behave.disable_scripts, INT, 1, cmd_disable_scripts)}, + { "autoload_images", PTR(uzbl.behave.autoload_img, INT, 1, cmd_autoload_img)}, + { "autoshrink_images", PTR(uzbl.behave.autoshrink_img, INT, 1, cmd_autoshrink_img)}, + { "enable_spellcheck", PTR(uzbl.behave.enable_spellcheck, INT, 1, cmd_enable_spellcheck)}, + { "enable_private", PTR(uzbl.behave.enable_private, INT, 1, cmd_enable_private)}, + { "print_backgrounds", PTR(uzbl.behave.print_bg, INT, 1, cmd_print_bg)}, + { "stylesheet_uri", PTR(uzbl.behave.style_uri, STR, 1, cmd_style_uri)}, + { "resizable_text_areas",PTR(uzbl.behave.resizable_txt, INT, 1, cmd_resizable_txt)}, + { "default_encoding", PTR(uzbl.behave.default_encoding, STR, 1, cmd_default_encoding)}, + { "enforce_96_dpi", PTR(uzbl.behave.enforce_96dpi, INT, 1, cmd_enforce_96dpi)}, + { "caret_browsing", PTR(uzbl.behave.caret_browsing, INT, 1, cmd_caret_browsing)}, + + { NULL, {.ptr = NULL, .type = TYPE_INT, .dump = 0, .func = NULL}} }, *n2v_p = var_name_to_ptr; const struct { @@ -386,23 +389,27 @@ scroll (GtkAdjustment* bar, GArray *argv) { gtk_adjustment_set_value (bar, gtk_adjustment_get_value(bar)+amount); } -static void scroll_begin(WebKitWebView* page, GArray *argv) { +static void +scroll_begin(WebKitWebView* page, GArray *argv) { (void) page; (void) argv; gtk_adjustment_set_value (uzbl.gui.bar_v, gtk_adjustment_get_lower(uzbl.gui.bar_v)); } -static void scroll_end(WebKitWebView* page, GArray *argv) { +static void +scroll_end(WebKitWebView* page, GArray *argv) { (void) page; (void) argv; gtk_adjustment_set_value (uzbl.gui.bar_v, gtk_adjustment_get_upper(uzbl.gui.bar_v) - gtk_adjustment_get_page_size(uzbl.gui.bar_v)); } -static void scroll_vert(WebKitWebView* page, GArray *argv) { +static void +scroll_vert(WebKitWebView* page, GArray *argv) { (void) page; scroll(uzbl.gui.bar_v, argv); } -static void scroll_horz(WebKitWebView* page, GArray *argv) { +static void +scroll_horz(WebKitWebView* page, GArray *argv) { (void) page; scroll(uzbl.gui.bar_h, argv); } @@ -559,7 +566,8 @@ static struct {char *name; Command command[2];} cmdlist[] = { "dehilight", {dehilight, 0} }, { "toggle_insert_mode", {toggle_insert_mode, 0} }, { "runcmd", {runcmd, NOSPLIT} }, - { "set", {set_var, NOSPLIT} } + { "set", {set_var, NOSPLIT} }, + { "dump_config", {act_dump_config, 0} } }; static void @@ -611,6 +619,11 @@ set_var(WebKitWebView *page, GArray *argv) { g_free(ctl_line); } +static void +act_dump_config() { + dump_config(); +} + static void toggle_insert_mode(WebKitWebView *page, GArray *argv) { (void)page; @@ -893,7 +906,8 @@ expand_template(const char *template, gboolean escape_markup) { break; case SYM_MODE: g_string_append(ret, - uzbl.behave.insert_mode?"[I]":"[C]"); + uzbl.behave.insert_mode? + uzbl.behave.insert_indicator:uzbl.behave.cmd_indicator); break; case SYM_MSG: g_string_append(ret, @@ -1457,17 +1471,19 @@ static void parse_cmd_line(const char *ctl_line) { gchar **tokens = NULL; Behaviour *b = &uzbl.behave; + size_t len=0; if(b->mode == M_HTML) { - - if(!strncmp(b->html_endmarker, ctl_line, strlen(b->html_endmarker))) { + len = strlen(b->html_endmarker); + /* ctl_line has trailing '\n' so we check for strlen(ctl_line)-1 */ + if(len == strlen(ctl_line)-1 && + !strncmp(b->html_endmarker, ctl_line, len)) { set_timeout(0); set_var_value("mode", "0"); render_html(); return; } else { - /* set an alarm to kill us after the timeout */ set_timeout(b->html_timeout); g_string_append(b->html_buffer, ctl_line); } @@ -2217,7 +2233,34 @@ set_up_inspector() { g_signal_connect (G_OBJECT (g->inspector), "notify::inspected-uri", G_CALLBACK (inspector_uri_changed_cb), NULL); } +static void +dump_var_hash(gpointer k, gpointer v, gpointer ud) { + (void) ud; + uzbl_cmdprop *c = v; + + if(!c->dump) + return; + + if(c->type == TYPE_STR) + printf("set %s = %s\n", (char *)k, *c->ptr?(char *)*c->ptr:" "); + else if(c->type == TYPE_INT) + printf("set %s = %d\n", (char *)k, (int)*c->ptr); +} + +static void +dump_key_hash(gpointer k, gpointer v, gpointer ud) { + (void) ud; + Action *a = v; + + printf("bind %s = %s %s\n", (char *)k , + (char *)a->name, a->param?(char *)a->param:""); +} +static void +dump_config() { + g_hash_table_foreach(uzbl.comm.proto_var, dump_var_hash, NULL); + g_hash_table_foreach(uzbl.bindings, dump_key_hash, NULL); +} /** -- MAIN -- **/ int @@ -2261,6 +2304,10 @@ main (int argc, char* argv[]) { uzbl.behave.html_timeout = 60; uzbl.behave.base_url = g_strdup("http://invalid"); + /* default mode indicators */ + uzbl.behave.insert_indicator = g_strdup("I"); + uzbl.behave.cmd_indicator = g_strdup("C"); + setup_regex(); setup_scanner(); commands_hash (); diff --git a/uzbl.h b/uzbl.h index cd5e3ef..8618675 100644 --- a/uzbl.h +++ b/uzbl.h @@ -171,6 +171,8 @@ typedef struct { guint mode; gchar* base_url; gchar* html_endmarker; + gchar* insert_indicator; + gchar* cmd_indicator; GString* html_buffer; guint html_timeout; @@ -416,12 +418,24 @@ save_cookies (SoupMessage *msg, static void set_var(WebKitWebView *page, GArray *argv); +static void +act_dump_config(); + static void render_html(); static void set_timeout(int seconds); +static void +dump_var_hash(gpointer k, gpointer v, gpointer ud); + +static void +dump_key_hash(gpointer k, gpointer v, gpointer ud); + +static void +dump_config(); + /* Command callbacks */ static void -- cgit v1.2.3 From 0c6a5ff58fa87ec65ea1b3054586da19d0dc96f2 Mon Sep 17 00:00:00 2001 From: DuClare Date: Fri, 29 May 2009 21:16:38 +0300 Subject: Add 'get' action, remove GET command. Const correctness fix. --- uzbl.c | 18 ++++++++---------- uzbl.h | 6 ++++++ 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'uzbl.h') diff --git a/uzbl.c b/uzbl.c index e5498f0..7855353 100644 --- a/uzbl.c +++ b/uzbl.c @@ -614,6 +614,7 @@ static struct {char *name; Command command[2];} cmdlist[] = { "toggle_insert_mode", {toggle_insert_mode, 0} }, { "runcmd", {runcmd, NOSPLIT} }, { "set", {set_var, NOSPLIT} }, + { "get", {get_var, NOSPLIT} }, { "dump_config", {act_dump_config, 0} }, { "keycmd", {keycmd, NOSPLIT} }, { "keycmd_nl", {keycmd_nl, NOSPLIT} }, @@ -670,6 +671,12 @@ set_var(WebKitWebView *page, GArray *argv) { g_free(ctl_line); } +static void +get_var(WebKitWebView *page, GArray *argv) { + (void) page; + get_var_value(argv_idx(argv, 0)); +} + static void act_dump_config() { dump_config(); @@ -1262,7 +1269,7 @@ setup_regex() { } static gboolean -get_var_value(gchar *name) { +get_var_value(const gchar *name) { uzbl_cmdprop *c; if( (c = g_hash_table_lookup(uzbl.comm.proto_var, name)) ) { @@ -1593,15 +1600,6 @@ parse_cmd_line(const char *ctl_line) { else printf("Error in command: %s\n", tokens[0]); } - /* GET command */ - else if(ctl_line[0] == 'g' || ctl_line[0] == 'G') { - tokens = g_regex_split(uzbl.comm.get_regex, ctl_line, 0); - if(tokens[0][0] == 0) { - get_var_value(tokens[1]); - } - else - printf("Error in command: %s\n", tokens[0]); - } /* BIND command */ else if(ctl_line[0] == 'b' || ctl_line[0] == 'B') { tokens = g_regex_split(uzbl.comm.bind_regex, ctl_line, 0); diff --git a/uzbl.h b/uzbl.h index a36b3f7..dd4ceb5 100644 --- a/uzbl.h +++ b/uzbl.h @@ -247,6 +247,9 @@ setup_signal(int signe, sigfunc *shandler); static gboolean set_var_value(gchar *name, gchar *val); +static gboolean +get_var_value(const gchar *name); + static gboolean new_window_cb (WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, WebKitWebNavigationAction *navigation_action, WebKitWebPolicyDecision *policy_decision, gpointer user_data); @@ -429,6 +432,9 @@ save_cookies (SoupMessage *msg, static void set_var(WebKitWebView *page, GArray *argv); +static void +get_var(WebKitWebView *page, GArray *argv); + static void act_dump_config(); -- cgit v1.2.3 From b33d152c8cca9ea50899a74e24316808d8e12607 Mon Sep 17 00:00:00 2001 From: DuClare Date: Fri, 29 May 2009 21:40:36 +0300 Subject: Don't call parse_cmd_line in set_var, rm SET cmd, rm unused regexes --- uzbl.c | 25 ++++--------------------- uzbl.h | 2 -- 2 files changed, 4 insertions(+), 23 deletions(-) (limited to 'uzbl.h') diff --git a/uzbl.c b/uzbl.c index 7855353..205e9c0 100644 --- a/uzbl.c +++ b/uzbl.c @@ -664,11 +664,9 @@ file_exists (const char * filename) { static void set_var(WebKitWebView *page, GArray *argv) { (void) page; - gchar *ctl_line; - - ctl_line = g_strdup_printf("%s %s", "set", argv_idx(argv, 0)); - parse_cmd_line(ctl_line); - g_free(ctl_line); + gchar **split = g_strsplit(argv_idx(argv, 0), "=", 2); + set_var_value(g_strstrip(split[0]), (g_strchug(split[1]) ? split[1] : " ")); + g_strfreev(split); } static void @@ -1258,10 +1256,6 @@ parse_command(const char *cmd, const char *param) { /* command parser */ static void setup_regex() { - uzbl.comm.get_regex = g_regex_new("^[Gg][a-zA-Z]*\\s+([^ \\n]+)$", - G_REGEX_OPTIMIZE, 0, NULL); - uzbl.comm.set_regex = g_regex_new("^[Ss][a-zA-Z]*\\s+([^ ]+)\\s*=\\s*([^\\n].*)$", - G_REGEX_OPTIMIZE, 0, NULL); uzbl.comm.bind_regex = g_regex_new("^[Bb][a-zA-Z]*\\s+?(.*[^ ])\\s*?=\\s*([a-z][^\\n].+)$", G_REGEX_UNGREEDY|G_REGEX_OPTIMIZE, 0, NULL); uzbl.comm.act_regex = g_regex_new("^[Aa][a-zA-Z]*\\s+([^ \\n]+)\\s*([^\\n]*)?$", @@ -1589,19 +1583,8 @@ parse_cmd_line(const char *ctl_line) { } } else { - /* SET command */ - if(ctl_line[0] == 's' || ctl_line[0] == 'S') { - tokens = g_regex_split(uzbl.comm.set_regex, ctl_line, 0); - if(tokens[0][0] == 0) { - gchar* value = parseenv(g_strdup(tokens[2])); - set_var_value(tokens[1], value); - g_free(value); - } - else - printf("Error in command: %s\n", tokens[0]); - } /* BIND command */ - else if(ctl_line[0] == 'b' || ctl_line[0] == 'B') { + if(ctl_line[0] == 'b' || ctl_line[0] == 'B') { tokens = g_regex_split(uzbl.comm.bind_regex, ctl_line, 0); if(tokens[0][0] == 0) { gchar* value = parseenv(g_strdup(tokens[2])); diff --git a/uzbl.h b/uzbl.h index dd4ceb5..d2364de 100644 --- a/uzbl.h +++ b/uzbl.h @@ -94,9 +94,7 @@ typedef struct { /* stores (key)"variable name" -> (value)"pointer to this var*/ GHashTable *proto_var; /* command parsing regexes */ - GRegex *set_regex; GRegex *act_regex; - GRegex *get_regex; GRegex *bind_regex; gchar *sync_stdout; } Communication; -- cgit v1.2.3 From 1e66be3a8635040f7e7d3ab828507ba361523a71 Mon Sep 17 00:00:00 2001 From: DuClare Date: Fri, 29 May 2009 22:11:06 +0300 Subject: Rem BIND cmd, add 'bind' action. Use parseenv in set_var & bind --- uzbl.c | 31 ++++++++++++++++--------------- uzbl.h | 4 +++- 2 files changed, 19 insertions(+), 16 deletions(-) (limited to 'uzbl.h') diff --git a/uzbl.c b/uzbl.c index 205e9c0..2b0571d 100644 --- a/uzbl.c +++ b/uzbl.c @@ -615,6 +615,7 @@ static struct {char *name; Command command[2];} cmdlist[] = { "runcmd", {runcmd, NOSPLIT} }, { "set", {set_var, NOSPLIT} }, { "get", {get_var, NOSPLIT} }, + { "bind", {act_bind, NOSPLIT} }, { "dump_config", {act_dump_config, 0} }, { "keycmd", {keycmd, NOSPLIT} }, { "keycmd_nl", {keycmd_nl, NOSPLIT} }, @@ -665,7 +666,9 @@ static void set_var(WebKitWebView *page, GArray *argv) { (void) page; gchar **split = g_strsplit(argv_idx(argv, 0), "=", 2); - set_var_value(g_strstrip(split[0]), (g_strchug(split[1]) ? split[1] : " ")); + gchar *value = parseenv(g_strdup(split[1] ? g_strchug(split[1]) : " ")); + set_var_value(g_strstrip(split[0]), value); + g_free(value); g_strfreev(split); } @@ -675,6 +678,17 @@ get_var(WebKitWebView *page, GArray *argv) { get_var_value(argv_idx(argv, 0)); } +static void +act_bind(WebKitWebView *page, GArray *argv) { + (void) page; + gchar **split = g_strsplit(argv_idx(argv, 0), " = ", 2); + gchar *value = parseenv(g_strdup(split[1] ? g_strchug(split[1]) : " ")); + add_binding(g_strstrip(split[0]), value); + g_free(value); + g_strfreev(split); +} + + static void act_dump_config() { dump_config(); @@ -1256,8 +1270,6 @@ parse_command(const char *cmd, const char *param) { /* command parser */ static void setup_regex() { - uzbl.comm.bind_regex = g_regex_new("^[Bb][a-zA-Z]*\\s+?(.*[^ ])\\s*?=\\s*([a-z][^\\n].+)$", - G_REGEX_UNGREEDY|G_REGEX_OPTIMIZE, 0, NULL); uzbl.comm.act_regex = g_regex_new("^[Aa][a-zA-Z]*\\s+([^ \\n]+)\\s*([^\\n]*)?$", G_REGEX_OPTIMIZE, 0, NULL); } @@ -1583,19 +1595,8 @@ parse_cmd_line(const char *ctl_line) { } } else { - /* BIND command */ - if(ctl_line[0] == 'b' || ctl_line[0] == 'B') { - tokens = g_regex_split(uzbl.comm.bind_regex, ctl_line, 0); - if(tokens[0][0] == 0) { - gchar* value = parseenv(g_strdup(tokens[2])); - add_binding(tokens[1], value); - g_free(value); - } - else - printf("Error in command: %s\n", tokens[0]); - } /* ACT command */ - else if(ctl_line[0] == 'A' || ctl_line[0] == 'a') { + if(ctl_line[0] == 'A' || ctl_line[0] == 'a') { tokens = g_regex_split(uzbl.comm.act_regex, ctl_line, 0); if(tokens[0][0] == 0) { parse_command(tokens[1], tokens[2]); diff --git a/uzbl.h b/uzbl.h index d2364de..bedefe0 100644 --- a/uzbl.h +++ b/uzbl.h @@ -95,7 +95,6 @@ typedef struct { GHashTable *proto_var; /* command parsing regexes */ GRegex *act_regex; - GRegex *bind_regex; gchar *sync_stdout; } Communication; @@ -433,6 +432,9 @@ set_var(WebKitWebView *page, GArray *argv); static void get_var(WebKitWebView *page, GArray *argv); +static void +act_bind(WebKitWebView *page, GArray *argv); + static void act_dump_config(); -- cgit v1.2.3 From d1c6ba765827f985507283080bf67a2b012f2e17 Mon Sep 17 00:00:00 2001 From: DuClare Date: Fri, 29 May 2009 22:15:02 +0300 Subject: Remove action 'runcmd': commands are deprecated :) --- uzbl.c | 7 ------- uzbl.h | 3 --- 2 files changed, 10 deletions(-) (limited to 'uzbl.h') diff --git a/uzbl.c b/uzbl.c index 2b0571d..51e89e6 100644 --- a/uzbl.c +++ b/uzbl.c @@ -612,7 +612,6 @@ static struct {char *name; Command command[2];} cmdlist[] = { "search_reverse", {search_reverse_text, NOSPLIT} }, { "dehilight", {dehilight, 0} }, { "toggle_insert_mode", {toggle_insert_mode, 0} }, - { "runcmd", {runcmd, NOSPLIT} }, { "set", {set_var, NOSPLIT} }, { "get", {get_var, NOSPLIT} }, { "bind", {act_bind, NOSPLIT} }, @@ -1554,12 +1553,6 @@ set_var_value(gchar *name, gchar *val) { return TRUE; } -static void -runcmd(WebKitWebView* page, GArray *argv) { - (void) page; - parse_cmd_line(argv_idx(argv, 0)); -} - static void render_html() { Behaviour *b = &uzbl.behave; diff --git a/uzbl.h b/uzbl.h index bedefe0..a78a79e 100644 --- a/uzbl.h +++ b/uzbl.h @@ -338,9 +338,6 @@ spawn_sh_sync(WebKitWebView *web_view, GArray *argv); static void parse_command(const char *cmd, const char *param); -static void -runcmd(WebKitWebView *page, GArray *argv); - static void parse_cmd_line(const char *ctl_line); -- cgit v1.2.3 From 9ede5b7d9622e4468b917ce552dc43871a3bfb98 Mon Sep 17 00:00:00 2001 From: DuClare Date: Fri, 29 May 2009 23:25:06 +0300 Subject: Remove ACT command, remove regexes as they're no longer used. --- uzbl.c | 54 ++++++++++++++++-------------------------------------- uzbl.h | 2 -- 2 files changed, 16 insertions(+), 40 deletions(-) (limited to 'uzbl.h') diff --git a/uzbl.c b/uzbl.c index fd2a887..d854bd2 100644 --- a/uzbl.c +++ b/uzbl.c @@ -1266,13 +1266,6 @@ parse_command(const char *cmd, const char *param) { g_printerr ("command \"%s\" not understood. ignoring.\n", cmd); } -/* command parser */ -static void -setup_regex() { - uzbl.comm.act_regex = g_regex_new("^[Aa][a-zA-Z]*\\s+([^ \\n]+)\\s*([^\\n]*)?$", - G_REGEX_OPTIMIZE, 0, NULL); -} - static gboolean get_var_value(const gchar *name) { uzbl_cmdprop *c; @@ -1568,7 +1561,6 @@ render_html() { enum {M_CMD, M_HTML}; static void parse_cmd_line(const char *ctl_line) { - gchar **tokens = NULL; Behaviour *b = &uzbl.behave; size_t len=0; @@ -1587,36 +1579,23 @@ parse_cmd_line(const char *ctl_line) { g_string_append(b->html_buffer, ctl_line); } } - else { - /* ACT command */ - if(ctl_line[0] == 'A' || ctl_line[0] == 'a') { - tokens = g_regex_split(uzbl.comm.act_regex, ctl_line, 0); - if(tokens[0][0] == 0) { - parse_command(tokens[1], tokens[2]); - } - else - printf("Error in command: %s\n", tokens[0]); - } - /* Comments */ - else if( (ctl_line[0] == '#') - || (ctl_line[0] == ' ') - || (ctl_line[0] == '\n')) - ; /* ignore these lines */ - else { - gchar *ctlstrip; - if (ctl_line[strlen(ctl_line) - 1] == '\n') - ctlstrip = g_strndup(ctl_line, strlen(ctl_line) - 1); - else ctlstrip = g_strdup(ctl_line); - tokens = g_strsplit(ctlstrip, " ", 2); - - parse_command(tokens[0], tokens[1]); - g_free(ctlstrip); - } - if(tokens) - g_strfreev(tokens); + else if((ctl_line[0] == '#') /* Comments */ + || (ctl_line[0] == ' ') + || (ctl_line[0] == '\n')) + ; /* ignore these lines */ + else { /* parse a command */ + gchar *ctlstrip; + gchar **tokens = NULL; + + if (ctl_line[strlen(ctl_line) - 1] == '\n') /* strip trailing newline */ + ctlstrip = g_strndup(ctl_line, strlen(ctl_line) - 1); + else ctlstrip = g_strdup(ctl_line); + + tokens = g_strsplit(ctlstrip, " ", 2); + parse_command(tokens[0], tokens[1]); + g_free(ctlstrip); + g_strfreev(tokens); } - - return; } static gchar* @@ -2444,7 +2423,6 @@ main (int argc, char* argv[]) { uzbl.behave.insert_indicator = g_strdup("I"); uzbl.behave.cmd_indicator = g_strdup("C"); - setup_regex(); setup_scanner(); commands_hash (); make_var_to_name_hash(); diff --git a/uzbl.h b/uzbl.h index a78a79e..6ab31f6 100644 --- a/uzbl.h +++ b/uzbl.h @@ -93,8 +93,6 @@ typedef struct { gchar *socket_path; /* stores (key)"variable name" -> (value)"pointer to this var*/ GHashTable *proto_var; - /* command parsing regexes */ - GRegex *act_regex; gchar *sync_stdout; } Communication; -- cgit v1.2.3 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 +++++++++++++++--- uzbl.h | 3 +++ 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'uzbl.h') 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); diff --git a/uzbl.h b/uzbl.h index 6ab31f6..121d6b5 100644 --- 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); -- cgit v1.2.3 From d6911ffa67b69deecfbab30b72e4aebf592754d3 Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Sat, 30 May 2009 14:14:08 +0200 Subject: removed get command in favour of print --- uzbl.c | 21 +-------------------- uzbl.h | 6 ------ 2 files changed, 1 insertion(+), 26 deletions(-) (limited to 'uzbl.h') diff --git a/uzbl.c b/uzbl.c index db7d7e9..9041f35 100644 --- a/uzbl.c +++ b/uzbl.c @@ -610,7 +610,7 @@ static struct {char *name; Command command[2];} cmdlist[] = { "dehilight", {dehilight, 0} }, { "toggle_insert_mode", {toggle_insert_mode, 0} }, { "set", {set_var, NOSPLIT} }, - { "get", {get_var, NOSPLIT} }, + //{ "get", {get_var, NOSPLIT} }, { "bind", {act_bind, NOSPLIT} }, { "dump_config", {act_dump_config, 0} }, { "keycmd", {keycmd, NOSPLIT} }, @@ -669,12 +669,6 @@ set_var(WebKitWebView *page, GArray *argv) { g_strfreev(split); } -static void -get_var(WebKitWebView *page, GArray *argv) { - (void) page; - get_var_value(argv_idx(argv, 0)); -} - static void print(WebKitWebView *page, GArray *argv) { (void) page; @@ -1274,19 +1268,6 @@ parse_command(const char *cmd, const char *param) { g_printerr ("command \"%s\" not understood. ignoring.\n", cmd); } -static gboolean -get_var_value(const gchar *name) { - uzbl_cmdprop *c; - - if( (c = g_hash_table_lookup(uzbl.comm.proto_var, name)) ) { - if(c->type == TYPE_STR) - printf("VAR: %s VALUE: (%s)\n", name, (char *)*c->ptr); - else if(c->type == TYPE_INT) - printf("VAR: %s VALUE: %d\n", name, (int)*c->ptr); - } - return TRUE; -} - static void set_proxy_url() { SoupURI *suri; diff --git a/uzbl.h b/uzbl.h index 121d6b5..846dad6 100644 --- a/uzbl.h +++ b/uzbl.h @@ -242,9 +242,6 @@ setup_signal(int signe, sigfunc *shandler); static gboolean set_var_value(gchar *name, gchar *val); -static gboolean -get_var_value(const gchar *name); - static void print(WebKitWebView *page, GArray *argv); @@ -427,9 +424,6 @@ save_cookies (SoupMessage *msg, static void set_var(WebKitWebView *page, GArray *argv); -static void -get_var(WebKitWebView *page, GArray *argv); - static void act_bind(WebKitWebView *page, GArray *argv); -- cgit v1.2.3 From 0ef46333e1a68130afb16b038852de1344b0e499 Mon Sep 17 00:00:00 2001 From: Sylvester Johansson Date: Mon, 1 Jun 2009 14:31:43 +0200 Subject: fixed broken merge --- uzbl.c | 26 -------------------------- uzbl.h | 3 --- 2 files changed, 29 deletions(-) (limited to 'uzbl.h') diff --git a/uzbl.c b/uzbl.c index ce24e99..bb11fcf 100644 --- a/uzbl.c +++ b/uzbl.c @@ -97,10 +97,7 @@ const struct { /* variable name pointer to variable in code type dump callback function */ /* --------------------------------------------------------------------------------------- */ { "uri", PTR(uzbl.state.uri, STR, 1, cmd_load_uri)}, -<<<<<<< HEAD:uzbl.c -======= { "verbose", PTR(uzbl.state.verbose, INT, 1, NULL)}, ->>>>>>> dieterbe/experimental:uzbl.c { "mode", PTR(uzbl.behave.mode, INT, 0, NULL)}, { "inject_html", PTR(uzbl.behave.inject_html, STR, 0, cmd_inject_html)}, { "base_url", PTR(uzbl.behave.base_url, STR, 1, NULL)}, @@ -612,11 +609,6 @@ static struct {char *name; Command command[2];} cmdlist[] = { "search_reverse", {search_reverse_text, NOSPLIT} }, { "dehilight", {dehilight, 0} }, { "toggle_insert_mode", {toggle_insert_mode, 0} }, -<<<<<<< HEAD:uzbl.c - { "runcmd", {runcmd, NOSPLIT} }, - { "set", {set_var, NOSPLIT} }, - { "dump_config", {act_dump_config, 0} } -======= { "set", {set_var, NOSPLIT} }, //{ "get", {get_var, NOSPLIT} }, { "bind", {act_bind, NOSPLIT} }, @@ -626,7 +618,6 @@ static struct {char *name; Command command[2];} cmdlist[] = { "keycmd_bs", {keycmd_bs, 0} }, { "chain", {chain, 0} }, { "print", {print, NOSPLIT} } ->>>>>>> dieterbe/experimental:uzbl.c }; static void @@ -699,11 +690,6 @@ act_bind(WebKitWebView *page, GArray *argv) { } -static void -act_dump_config() { - dump_config(); -} - static void act_dump_config() { dump_config(); @@ -2377,19 +2363,11 @@ static void dump_key_hash(gpointer k, gpointer v, gpointer ud) { (void) ud; Action *a = v; -<<<<<<< HEAD:uzbl.c - - printf("bind %s = %s %s\n", (char *)k , - (char *)a->name, a->param?(char *)a->param:""); -} - -======= printf("bind %s = %s %s\n", (char *)k , (char *)a->name, a->param?(char *)a->param:""); } ->>>>>>> dieterbe/experimental:uzbl.c static void dump_config() { g_hash_table_foreach(uzbl.comm.proto_var, dump_var_hash, NULL); @@ -2446,10 +2424,6 @@ main (int argc, char* argv[]) { uzbl.behave.insert_indicator = g_strdup("I"); uzbl.behave.cmd_indicator = g_strdup("C"); -<<<<<<< HEAD:uzbl.c - setup_regex(); -======= ->>>>>>> dieterbe/experimental:uzbl.c setup_scanner(); commands_hash (); make_var_to_name_hash(); diff --git a/uzbl.h b/uzbl.h index bbc1f39..846dad6 100644 --- a/uzbl.h +++ b/uzbl.h @@ -425,12 +425,9 @@ static void set_var(WebKitWebView *page, GArray *argv); static void -<<<<<<< HEAD:uzbl.h -======= act_bind(WebKitWebView *page, GArray *argv); static void ->>>>>>> dieterbe/experimental:uzbl.h act_dump_config(); static void -- cgit v1.2.3