From 8d714bb94fc900cee4fa91048e5c91a67e66a224 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 9 May 2009 16:03:44 +0200 Subject: first draft of new config spec --- Makefile | 4 +- docs/config-syntax | 38 ++++++++++++++++ examples/configs/sampleconfig | 70 ----------------------------- examples/configs/sampleconfig-dev | 92 +++++++++++++++++++-------------------- 4 files changed, 84 insertions(+), 120 deletions(-) create mode 100644 docs/config-syntax delete mode 100644 examples/configs/sampleconfig diff --git a/Makefile b/Makefile index 622a79a..2d6b8c9 100644 --- a/Makefile +++ b/Makefile @@ -6,10 +6,10 @@ test: uzbl ./uzbl --uri http://www.uzbl.org test-config: uzbl - ./uzbl --uri http://www.uzbl.org --config examples/configs/sampleconfig-dev + ./uzbl --uri http://www.uzbl.org < examples/configs/sampleconfig-dev test-config-real: uzbl - ./uzbl --uri http://www.uzbl.org --config /usr/share/uzbl/examples/configs/sampleconfig + ./uzbl --uri http://www.uzbl.org < /usr/share/uzbl/examples/configs/sampleconfig clean: rm -f uzbl diff --git a/docs/config-syntax b/docs/config-syntax new file mode 100644 index 0000000..2315b6c --- /dev/null +++ b/docs/config-syntax @@ -0,0 +1,38 @@ +Configuration setting at startup and changing at runtime happens through one of these: +- stdin at startup (TODO: see if we can keep listening while running) (write command to it + "\n") +- fifo (write command to it + "\n") +- socket (uzblctrl -s -c + +Lines written to the above starting with '#' or being empty, are ignored. + +** Command syntax: +commands can have no, one or 2 arguments. + +[\t[\t]] + +The 'bind' command is a special command, where argument 1 is a keyboard character (combo) and argument 2 is a command as specified above. +You can also use a '_' in the part to denote where you pass on whatever you want, which will be replaced into the specififed command whereever %s is mentioned + +** commands +Commands where one of the arguments is "parameter" expect this arugment to be a valid variable identifier (eg uzbl.behave.status_format) + +set parameter value # make sure the value complies with the datatype. +toggle parameter # expects parameter to be a gboolean. (eg status, insert_mode, ..) +get parameter +bind +script +script_file +back +forward +scroll_vert +scroll_horz +reload +reload_ign_cache +stop +zoom_in +zoom_out +spawn +exit +search + +The 'set' command may do more then just set the variable. eg 'set uri' commands will also cause uzbl to navigate to the uri. \ No newline at end of file diff --git a/examples/configs/sampleconfig b/examples/configs/sampleconfig deleted file mode 100644 index 92a7cfc..0000000 --- a/examples/configs/sampleconfig +++ /dev/null @@ -1,70 +0,0 @@ - -# example uzbl config. in a real config, we should obey the xdg spec - -# all keys in the behavior group are optional. if not set, the corresponding behavior is disabed. -# bindings_internal denote keys to trigger actions internally in uzbl -# bindings_external denote keys to trigger scripts outside uzbl - -# keyboard behavior is vimstyle by default (all actions -> 1 key). set -# always_insert_mode to always be in insert mode and disable going out of it. -# if you do this, make sure you've set a modkey so you can reach the actions -# from insert mode by combining them with the modkey - -[behavior] -history_handler = /usr/share/uzbl/examples/scripts/history.sh -download_handler = /usr/share/uzbl/examples/scripts/download.sh -cookie_handler = /usr/share/uzbl/examples/scripts/cookies.sh -status_format = MODE [KEYCMD] LOAD_PROGRESSBAR URI NAME -# you can optionally use this setting to override the background color of the statusbar from your GTK theme. -status_background = #303030 -fifo_dir = /tmp -socket_dir = /tmp -always_insert_mode = 0 -modkey = Mod1 -show_status = 1 -status_top = 0 - -[bindings] -# scroll down/up/left/right -j = scroll_vert 20 -k = scroll_vert -20 -h = scroll_horz -20 -l = scroll_horz 20 -b = back -m = forward -s = stop -r = reload -R = reload_ign_cache -+ = zoom_in -- = zoom_out -t = toggle_status -#hilight matches -/_ = search %s -#jump to next -; = search -gh = uri http://www.uzbl.org -o _ = uri %s -:wiki _ = uri http://wiki.archlinux.org/index.php/Special:Search?search=%s&go=Go -gg _ = uri http://www.google.com/search?q=%s -i = insert_mode -B = spawn /usr/share/uzbl/examples/scripts/insert_bookmark.sh -u = spawn /usr/share/uzbl/examples/scripts/load_url_from_history.sh -U = spawn /usr/share/uzbl/examples/scripts/load_url_from_bookmarks.sh -ZZ = exit -S = script alert("hi"); - -# Keyboard based link following: work in progress! No C DOM bindings yet, no click() event for hyperlinks so no referrer set..Quite basic but does the job for now... -#hit F to toggle the Hints (now in form of link numbering) -F = script for (var i=0; i < document.links.length; i++) {var uzblid = 'uzbl_link_hint_';var li = document.links[i];var pre = document.getElementById(uzblid+i);if (pre) {li.removeChild(pre);} else {var hint = document.createElement('div');hint.setAttribute('id',uzblid+i);hint.innerHTML = i;hint.style.display='inline';hint.style.lineHeight='90%';hint.style.backgroundColor='red';hint.style.color='white';hint.style.fontSize='small-xx';hint.style.fontWeight='light';hint.style.margin='0px';hint.style.padding='2px';hint.style.position='absolute';hint.style.textDecoration='none';hint.style.left=li.style.left;hint.style.top=li.style.top;li.insertAdjacentElement('afterBegin',hint);}} -#hit f followed by linknumber and ENTER to follow that link -f_ = script window.location = document.links[%s].href; - -[network] -proxy_server = -#values 0-3 -http_debug = 0 -user-agent = uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) -# Example user agent containing everything: -#user-agent = Uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) (%sysname% %nodename% %kernrel% %kernver% %arch-system% [%arch-uzbl%]) (Commit %commit%) -max_conns = -max_conns_per_host = diff --git a/examples/configs/sampleconfig-dev b/examples/configs/sampleconfig-dev index 69c7362..119e3a0 100644 --- a/examples/configs/sampleconfig-dev +++ b/examples/configs/sampleconfig-dev @@ -10,63 +10,59 @@ # if you do this, make sure you've set a modkey so you can reach the actions # from insert mode by combining them with the modkey -[behavior] -history_handler = ./examples/scripts/history.sh -download_handler = ./examples/scripts/download.sh -cookie_handler = ./examples/scripts/cookies.sh -fifo_dir = /tmp -socket_dir = /tmp -always_insert_mode = 0 -modkey = Mod1 -show_status = 1 -status_top = 0 -status_format = MODE [KEYCMD] LOAD_PROGRESSBAR URI NAME +set uzbl.behave.history_handler ./examples/scripts/history.sh +set uzbl.behave.download_handler ./examples/scripts/download.sh +set uzbl.behave.cookie_handler ./examples/scripts/cookies.sh +set uzbl.behave.fifo_dir /tmp +set uzbl.behave.socket_dir /tmp +set uzbl.behave.always_insert_mode 0 +set uzbl.behave.modkey Mod1 +set uzbl.behave.show_status 1 +set uzbl.behave.status_top 0 +set uzbl.behave.status_format MODE [KEYCMD] LOAD_PROGRESSBAR URI NAME # you can optionally use this setting to override the background color of the statusbar from your GTK theme. -status_background = #303030 +set uzbl.behave.status_background #303030 -[bindings] # scroll down/up/left/right -j = scroll_vert 20 -k = scroll_vert -20 -h = scroll_horz -20 -l = scroll_horz 20 -b = back -m = forward -s = stop -r = reload -R = reload_ign_cache -+ = zoom_in -- = zoom_out -t = toggle_status +bind j scroll_vert 20 +bind k scroll_vert -20 +bind h scroll_horz -20 +bind l scroll_horz 20 +bind b back +bind m forward +bind s stop +bind r reload +bind R reload_ign_cache +bind + zoom_in +bind - zoom_out +bind t toggle uzbl.behave.show_status #hilight matches -/_ = search %s +bind /_ search %s #jump to next -; = search -gh = uri http://www.uzbl.org -o _ = uri %s -:wiki _ = uri http://wiki.archlinux.org/index.php/Special:Search?search=%s&go=Go -gg _ = uri http://www.google.com/search?q=%s -i = insert_mode -B = spawn ./examples/scripts/insert_bookmark.sh -u = spawn ./examples/scripts/load_url_from_history.sh -U = spawn ./examples/scripts/load_url_from_bookmarks.sh -ZZ = exit -S = script alert("hi"); - +bind ; search +bind gh set uzbl.state.uri http://www.uzbl.org +bind o _ set uzbl.state.uri %s +bind :wiki _ set uzbl.state.uri http://wiki.archlinux.org/index.php/Special:Search?search=%s&go=Go +bind gg _ set uzbl.state.uri http://www.google.com/search?q=%s +bind i toggle uzbl.behave.insert_mode +bind B spawn ./examples/scripts/insert_bookmark.sh +bind u spawn ./examples/scripts/load_url_from_history.sh +bind U spawn ./examples/scripts/load_url_from_bookmarks.sh +bind ZZ exit +bind S script alert("hi"); # Keyboard based link following: work in progress! No C DOM bindings yet, no click() event for hyperlinks so no referrer set..Quite basic but does the job for now... #hit F to toggle the Hints (now in form of link numbering) -F = script for (var i=0; i < document.links.length; i++) {var uzblid = 'uzbl_link_hint_';var li = document.links[i];var pre = document.getElementById(uzblid+i);if (pre) {li.removeChild(pre);} else {var hint = document.createElement('div');hint.setAttribute('id',uzblid+i);hint.innerHTML = i;hint.style.display='inline';hint.style.lineHeight='90%';hint.style.backgroundColor='red';hint.style.color='white';hint.style.fontSize='small-xx';hint.style.fontWeight='light';hint.style.margin='0px';hint.style.padding='2px';hint.style.position='absolute';hint.style.textDecoration='none';hint.style.left=li.style.left;hint.style.top=li.style.top;li.insertAdjacentElement('afterBegin',hint);}} +bind F script for (var i=0; i < document.links.length; i++) {var uzblid = 'uzbl_link_hint_';var li = document.links[i];var pre = document.getElementById(uzblid+i);if (pre) {li.removeChild(pre);} else {var hint = document.createElement('div');hint.setAttribute('id',uzblid+i);hint.innerHTML = i;hint.style.display='inline';hint.style.lineHeight='90%';hint.style.backgroundColor='red';hint.style.color='white';hint.style.fontSize='small-xx';hint.style.fontWeight='light';hint.style.margin='0px';hint.style.padding='2px';hint.style.position='absolute';hint.style.textDecoration='none';hint.style.left=li.style.left;hint.style.top=li.style.top;li.insertAdjacentElement('afterBegin',hint);}} #hit f followed by linknumber and ENTER to follow that link -f_ = script window.location = document.links[%s].href; +bind f_ script window.location = document.links[%s].href; + -[network] # to start a local socks server, do : ssh -fND localhost:8118 localhost -#proxy_server = http://127.0.0.1:8118 +set uzbl.net.proxy_url http://127.0.0.1:8118 #values 0-3 -http_debug = 0 -user-agent = uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) +set uzbl.behave.http_debug = 0 +set uzbl.net.useragent uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) # Example user agent containing everything: -#user-agent = Uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) (%sysname% %nodename% %kernrel% %kernver% %arch-system% [%arch-uzbl%]) (Commit %commit%) -max_conns = -max_conns_per_host = - +#set uzbl.net.useragent Uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) (%sysname% %nodename% %kernrel% %kernver% %arch-system% [%arch-uzbl%]) (Commit %commit%) +set uzbl.net.max_conns 0 +set uzbl.net.max_conns_host 0 -- cgit v1.2.3 From 4cd06fbc9b54704bb85e536d0c4302334d26d324 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 9 May 2009 17:14:27 +0200 Subject: support getting commands from stdin --- uzbl.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- uzbl.h | 6 ++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/uzbl.c b/uzbl.c index 975cf62..127c585 100644 --- a/uzbl.c +++ b/uzbl.c @@ -714,6 +714,59 @@ create_fifo() { return; } +static void +control_stdin(GIOChannel *gio, GIOCondition condition) { + gchar *ctl_line; + GIOStatus ret; + GError *err = NULL; + printf("stdin triggered\n"); + + if (condition & G_IO_HUP) { //FIXME: for some reason, the last command is not interpreted. but when we get here gio->is_readable = FALSE. + ret = g_io_channel_shutdown (gio, FALSE, &err); + if (ret == G_IO_STATUS_ERROR) { + g_error ("Stdin: disconnected with HUP, but could not close it!\n"); + } else { + printf("Stdin: closed on request with HUP\n"); + return; + } + } + if(!gio) + g_error ("Stdin: GIOChannel broke\n"); + + ret = g_io_channel_read_line(gio, &ctl_line, NULL, NULL, &err); + if (ret == G_IO_STATUS_ERROR) + g_error ("Stdin: Error reading: %s\n", err->message); + if (ret == G_IO_STATUS_EOF) { + ret = g_io_channel_shutdown (gio, FALSE, &err); + if (ret == G_IO_STATUS_ERROR) { + g_error ("Stdin: disconnected without HUP, but could not close it!\n"); + } else { + printf("Stdin: closed on request without HUP\n"); + } + } + parse_line(ctl_line); + g_free(ctl_line); + printf("stdin...done\n"); + return; +} + +static void +create_stdin () { + GIOChannel *chan = NULL; + GError *error = NULL; + + chan = g_io_channel_unix_new (fileno(stdin)); + if (chan) { + if (!g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_stdin, NULL)) { + g_error ("Stdin: could not add watch\n"); + } else { + printf ("Stdin: watch added successfully\n"); + } + } else { + g_error ("Stdin: Error while opening: %s\n", error->message); + } +} + static void control_socket(GIOChannel *chan) { struct sockaddr_un remote; @@ -1304,7 +1357,8 @@ main (int argc, char* argv[]) { if (uzbl.behave.fifo_dir) create_fifo (); if (uzbl.behave.socket_dir) - create_socket(); + create_socket (); + create_stdin (); gtk_main (); clean_up(); diff --git a/uzbl.h b/uzbl.h index 71ec587..d414645 100644 --- a/uzbl.h +++ b/uzbl.h @@ -224,6 +224,12 @@ control_fifo(GIOChannel *gio, GIOCondition condition); static void create_fifo(); +static void +control_stdin(GIOChannel *gio, GIOCondition condition); + +static void +create_stdin(); + static void create_socket(); -- cgit v1.2.3 From 6ebc2b46357d6324311da7ec667a5b53fae8cbab Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Mon, 11 May 2009 19:14:41 +0200 Subject: rationale for config refactoring --- docs/config-syntax | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/config-syntax b/docs/config-syntax index 2315b6c..30cf91f 100644 --- a/docs/config-syntax +++ b/docs/config-syntax @@ -35,4 +35,22 @@ spawn exit search -The 'set' command may do more then just set the variable. eg 'set uri' commands will also cause uzbl to navigate to the uri. \ No newline at end of file +The 'set' command may do more then just set the variable. eg 'set uri' commands will also cause uzbl to navigate to the uri. + + + +Rationale. AKA "why not config files?" +-> unify code to configure uzbl and to accept incoming commands +-> no more code needed for config file parsing/handling +-> runtime changing of configuration + +issues +-> new instances (open link etc) need same config/state + solutions? + - serialize all state structs -> some libs available, could work. but: + - binary format not very user friendly + - not that easy (C has no introspection etc) + - iterate over state structs and generate appropriate commands to bring an instance in this state. + - plaintext :) + - user editable + - also useful for saving state if we need to update/shutdown/.. \ No newline at end of file -- cgit v1.2.3 From 5dc4a7cb20e1c3e175068c1a6b6c046f88eef5ed Mon Sep 17 00:00:00 2001 From: DuClare Date: Mon, 11 May 2009 23:16:48 +0300 Subject: Added support for incremental commands. --- uzbl.c | 80 ++++++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 46 insertions(+), 34 deletions(-) diff --git a/uzbl.c b/uzbl.c index 975cf62..c9c27e1 100644 --- a/uzbl.c +++ b/uzbl.c @@ -898,49 +898,61 @@ key_press_cb (WebKitWebView* page, GdkEventKey* event) if ((event->keyval == GDK_BackSpace) && (uzbl.state.keycmd->len > 0)) { g_string_truncate(uzbl.state.keycmd, uzbl.state.keycmd->len - 1); update_title(); - return TRUE; } - if ((event->keyval == GDK_Return) || (event->keyval == GDK_KP_Enter)) { - GString* short_keys = g_string_new (""); - unsigned int i; - for (i=0; i<(uzbl.state.keycmd->len); i++) { - g_string_append_c(short_keys, uzbl.state.keycmd->str[i]); - g_string_append_c(short_keys, '_'); - - //printf("\nTesting string: @%s@\n", short_keys->str); - if ((action = g_hash_table_lookup(uzbl.bindings, short_keys->str))) { - GString* parampart = g_string_new (uzbl.state.keycmd->str); - g_string_erase (parampart, 0, i+1); - //printf("\nParameter: @%s@\n", parampart->str); - GString* actionname = g_string_new (""); - if (action->name) - g_string_printf (actionname, action->name, parampart->str); - GString* actionparam = g_string_new (""); - if (action->param) - g_string_printf (actionparam, action->param, parampart->str); - parse_command(actionname->str, actionparam->str); - g_string_free (actionname, TRUE); - g_string_free (actionparam, TRUE); - g_string_free (parampart, TRUE); - g_string_truncate(uzbl.state.keycmd, 0); - update_title(); - } - - g_string_truncate(short_keys, short_keys->len - 1); - } - g_string_free (short_keys, TRUE); - return (!uzbl.behave.insert_mode); - } + gboolean key_ret = FALSE; + if ((event->keyval == GDK_Return) || (event->keyval == GDK_KP_Enter)) + key_ret = TRUE; - g_string_append(uzbl.state.keycmd, event->string); + if (!key_ret) g_string_append(uzbl.state.keycmd, event->string); if ((action = g_hash_table_lookup(uzbl.bindings, uzbl.state.keycmd->str))) { g_string_truncate(uzbl.state.keycmd, 0); parse_command(action->name, action->param); } - update_title(); + GString* short_keys = g_string_new (""); + GString* short_keys_inc = g_string_new (""); + unsigned int i; + for (i=0; i<(uzbl.state.keycmd->len); i++) { + g_string_append_c(short_keys, uzbl.state.keycmd->str[i]); + g_string_assign(short_keys_inc, short_keys->str); + g_string_append_c(short_keys, '_'); + g_string_append_c(short_keys_inc, '*'); + + gboolean exec_now = FALSE; + if ((action = g_hash_table_lookup(uzbl.bindings, short_keys->str))) { + if (key_ret) exec_now = TRUE; // run normal cmds only if return was pressed + } else if ((action = g_hash_table_lookup(uzbl.bindings, short_keys_inc->str))) { + if (key_ret) { // just quit the incremental command on return + g_string_truncate(uzbl.state.keycmd, 0); + break; + } else exec_now = TRUE; // always exec inc. commands on keys other than return + } + if (exec_now) { + GString* parampart = g_string_new (uzbl.state.keycmd->str); + GString* actionname = g_string_new (""); + GString* actionparam = g_string_new (""); + g_string_erase (parampart, 0, i+1); + if (action->name) + g_string_printf (actionname, action->name, parampart->str); + if (action->param) + g_string_printf (actionparam, action->param, parampart->str); + parse_command(actionname->str, actionparam->str); + g_string_free (actionname, TRUE); + g_string_free (actionparam, TRUE); + g_string_free (parampart, TRUE); + if (key_ret) + g_string_truncate(uzbl.state.keycmd, 0); + break; + } + + g_string_truncate(short_keys, short_keys->len - 1); + } + g_string_free (short_keys, TRUE); + g_string_free (short_keys_inc, TRUE); + update_title(); + if (key_ret) return (!uzbl.behave.insert_mode); return TRUE; } -- cgit v1.2.3 From c6c5e95d8f00f9cc1404b1dd49431a0ce464c239 Mon Sep 17 00:00:00 2001 From: DuClare Date: Mon, 11 May 2009 23:25:45 +0300 Subject: Use incremental search in sampleconfigs. --- examples/configs/sampleconfig | 2 +- examples/configs/sampleconfig-dev | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/configs/sampleconfig b/examples/configs/sampleconfig index 92a7cfc..aa681fe 100644 --- a/examples/configs/sampleconfig +++ b/examples/configs/sampleconfig @@ -39,7 +39,7 @@ R = reload_ign_cache - = zoom_out t = toggle_status #hilight matches -/_ = search %s +/* = search %s #jump to next ; = search gh = uri http://www.uzbl.org diff --git a/examples/configs/sampleconfig-dev b/examples/configs/sampleconfig-dev index 69c7362..e512202 100644 --- a/examples/configs/sampleconfig-dev +++ b/examples/configs/sampleconfig-dev @@ -39,7 +39,7 @@ R = reload_ign_cache - = zoom_out t = toggle_status #hilight matches -/_ = search %s +/* = search %s #jump to next ; = search gh = uri http://www.uzbl.org -- cgit v1.2.3 From 5e21bf494a0b6b0b2ec3cf0e2132fce181adc473 Mon Sep 17 00:00:00 2001 From: DuClare Date: Tue, 12 May 2009 00:13:17 +0300 Subject: Don't process commands when shift is pressed. --- uzbl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uzbl.c b/uzbl.c index c9c27e1..0050d40 100644 --- a/uzbl.c +++ b/uzbl.c @@ -860,7 +860,7 @@ key_press_cb (WebKitWebView* page, GdkEventKey* event) Action *action; if (event->type != GDK_KEY_PRESS || event->keyval == GDK_Page_Up || event->keyval == GDK_Page_Down - || event->keyval == GDK_Up || event->keyval == GDK_Down || event->keyval == GDK_Left || event->keyval == GDK_Right) + || event->keyval == GDK_Up || event->keyval == GDK_Down || event->keyval == GDK_Left || event->keyval == GDK_Right || event->keyval == GDK_Shift_L || event->keyval == GDK_Shift_R) return FALSE; /* turn off insert mode (if always_insert_mode is not used) */ -- cgit v1.2.3 From 3c65486d1ee8f769e51f078d1a9945cfef98ea07 Mon Sep 17 00:00:00 2001 From: DuClare Date: Tue, 12 May 2009 00:13:17 +0300 Subject: Ignore presses of shift. --- uzbl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uzbl.c b/uzbl.c index c9c27e1..0050d40 100644 --- a/uzbl.c +++ b/uzbl.c @@ -860,7 +860,7 @@ key_press_cb (WebKitWebView* page, GdkEventKey* event) Action *action; if (event->type != GDK_KEY_PRESS || event->keyval == GDK_Page_Up || event->keyval == GDK_Page_Down - || event->keyval == GDK_Up || event->keyval == GDK_Down || event->keyval == GDK_Left || event->keyval == GDK_Right) + || event->keyval == GDK_Up || event->keyval == GDK_Down || event->keyval == GDK_Left || event->keyval == GDK_Right || event->keyval == GDK_Shift_L || event->keyval == GDK_Shift_R) return FALSE; /* turn off insert mode (if always_insert_mode is not used) */ -- cgit v1.2.3 From b463f4fb28e4b89780063d8acc0c92c332155417 Mon Sep 17 00:00:00 2001 From: DuClare Date: Tue, 12 May 2009 11:01:55 +0300 Subject: Erase the command line upon loading a new page. --- uzbl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/uzbl.c b/uzbl.c index 0050d40..e4d0051 100644 --- a/uzbl.c +++ b/uzbl.c @@ -245,6 +245,7 @@ load_commit_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data) { free (uzbl.state.uri); GString* newuri = g_string_new (webkit_web_frame_get_uri (frame)); uzbl.state.uri = g_string_free (newuri, FALSE); + g_string_truncate(uzbl.state.keycmd, 0); // don't need old commands to remain on new page? } static void -- cgit v1.2.3 From a288ea2fe02082acdf73c125588e0f7c91b738e3 Mon Sep 17 00:00:00 2001 From: DuClare Date: Tue, 12 May 2009 13:28:59 +0300 Subject: Reset insert mode on page load, added option to disable the behavior. --- uzbl.c | 6 ++++++ uzbl.h | 1 + 2 files changed, 7 insertions(+) diff --git a/uzbl.c b/uzbl.c index e4d0051..2e829ef 100644 --- a/uzbl.c +++ b/uzbl.c @@ -245,6 +245,10 @@ load_commit_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data) { free (uzbl.state.uri); GString* newuri = g_string_new (webkit_web_frame_get_uri (frame)); uzbl.state.uri = g_string_free (newuri, FALSE); + if ((!uzbl.behave.never_reset_mode) && (uzbl.behave.insert_mode)) { + uzbl.behave.insert_mode = uzbl.behave.always_insert_mode; + update_title(); + } g_string_truncate(uzbl.state.keycmd, 0); // don't need old commands to remain on new page? } @@ -1085,6 +1089,7 @@ settings_init () { b->show_status = g_key_file_get_boolean (config, "behavior", "show_status", NULL); b->modkey = g_key_file_get_value (config, "behavior", "modkey", NULL); b->status_top = g_key_file_get_boolean (config, "behavior", "status_top", NULL); + b->never_reset_mode = g_key_file_get_boolean (config, "behavior", "never_reset_mode", NULL); b->status_format = g_key_file_get_string (config, "behavior", "status_format", NULL); b->status_background = g_key_file_get_string (config, "behavior", "status_background", NULL); if (! b->fifo_dir) @@ -1100,6 +1105,7 @@ settings_init () { printf ("Fifo directory: %s\n", (b->fifo_dir ? b->fifo_dir : "disabled")); printf ("Socket directory: %s\n", (b->socket_dir ? b->socket_dir : "disabled")); printf ("Always insert mode: %s\n", (b->always_insert_mode ? "TRUE" : "FALSE")); + printf ("Don't reset mode: %s\n", (b->never_reset_mode ? "TRUE" : "FALSE")); printf ("Show status: %s\n", (b->show_status ? "TRUE" : "FALSE")); printf ("Status top: %s\n", (b->status_top ? "TRUE" : "FALSE")); printf ("Modkey: %s\n", (b->modkey ? b->modkey : "disabled")); diff --git a/uzbl.h b/uzbl.h index 71ec587..a97f24e 100644 --- a/uzbl.h +++ b/uzbl.h @@ -98,6 +98,7 @@ typedef struct { gboolean show_status; gboolean insert_mode; gboolean status_top; + gboolean never_reset_mode; gchar* modkey; guint modmask; guint http_debug; -- cgit v1.2.3 From 87598a5098910fe1395d201a008fdd9ff4926f8f Mon Sep 17 00:00:00 2001 From: DuClare Date: Tue, 12 May 2009 15:46:14 +0300 Subject: Added my cfg, a simple session manager and a clipboard handler. --- examples/duclare/clipboard.sh | 13 ++++++++ examples/duclare/session.sh | 44 +++++++++++++++++++++++++ examples/duclare/uzbl.conf | 75 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100755 examples/duclare/clipboard.sh create mode 100755 examples/duclare/session.sh create mode 100644 examples/duclare/uzbl.conf diff --git a/examples/duclare/clipboard.sh b/examples/duclare/clipboard.sh new file mode 100755 index 0000000..a2b3717 --- /dev/null +++ b/examples/duclare/clipboard.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +fifo="$5" +action="$1" +url="$7" +selection=$(xclip -o) + +case $action in + "yank" ) echo -n "$url" | xclip;; + "goto" ) echo "uri $selection" > "$fifo";; + * ) echo "clipboard.sh: invalid action";; +esac + diff --git a/examples/duclare/session.sh b/examples/duclare/session.sh new file mode 100755 index 0000000..4dd4a39 --- /dev/null +++ b/examples/duclare/session.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Simple session manager for uzbl. When called with "endsession" as the +# argument, it'lla empty the sessionfile, look for fifos in $fifodir and +# instruct each of them to store their current url in $sessionfile and +# terminate themselves. Run with "launch" as the argument and an instance of +# uzbl will be launched for each stored url. "endinstance" is used internally +# and doesn't need to be called manually at any point. + + +scriptfile=~/.uzbl/session.sh # this script +sessionfile=~/.uzbl/session # the file in which the "session" (i.e. urls) are stored + +# a simple script that calls the executable with --config and args +launcher=~/.uzbl/launch + +fifodir=/tmp # remember to change this if you instructed uzbl to put its fifos elsewhere +thisfifo="$5" +act="$1" +url="$7" + +case $act in + "launch" ) + for url in $(cat $sessionfile); do + $launcher --uri "$url" & + done + exit 0;; + "endinstance" ) + if [ "$url" != "(null)" ]; then + echo "$url" >> $sessionfile; echo "exit" > "$thisfifo" + else + echo "exit" > "$thisfifo" + fi;; + "endsession" ) + echo -n "" > "$sessionfile" + for fifo in $fifodir/uzbl_fifo_*; do + if [ "$fifo" != "$thisfifo" ]; then + echo "spawn $scriptfile endinstance" > "$fifo" + fi + done + echo "spawn $scriptfile endinstance" > "$thisfifo";; + * ) echo "session manager: bad action";; +esac + diff --git a/examples/duclare/uzbl.conf b/examples/duclare/uzbl.conf new file mode 100644 index 0000000..1ce5944 --- /dev/null +++ b/examples/duclare/uzbl.conf @@ -0,0 +1,75 @@ + +# example uzbl config. in a real config, we should obey the xdg spec + +# all keys in the behavior group are optional. if not set, the corresponding behavior is disabed. +# bindings_internal denote keys to trigger actions internally in uzbl +# bindings_external denote keys to trigger scripts outside uzbl + +# keyboard behavior is vimstyle by default (all actions -> 1 key). set +# always_insert_mode to always be in insert mode and disable going out of it. +# if you do this, make sure you've set a modkey so you can reach the actions +# from insert mode by combining them with the modkey + +[behavior] +history_handler = /home/duclare/.uzbl/history.sh +download_handler = ~/.uzbl/download.sh +cookie_handler = ~/.uzbl/cookie.sh +status_format = MODE [KEYCMD] LOAD_PROGRESSBAR URI NAME +fifo_dir = /tmp +socket_dir = /tmp +always_insert_mode = 0 +modkey = Mod1 +show_status = 1 +status_top = 0 +never_reset_mode = 0 + +[bindings] +# scroll down/up/left/right +j = scroll_vert 40 +k = scroll_vert -40 +h = scroll_horz -20 +l = scroll_horz 20 +b = back +m = forward +s = stop +r = reload +R = reload_ign_cache +w = follow_link_new_window ++ = zoom_in +- = zoom_out +t = toggle_status +#hilight matches +/* = search %s +#jump to next +; = search +gh = uri http://www.uzbl.org +o_ = uri %s +:wiki _ = uri http://wiki.archlinux.org/index.php/Special:Search?search=%s&go=Go +ew_ = uri http://en.wikipedia.org/w/index.php?title=Special%3ASearch&search=%s&go=Go + +g_ = uri http://www.google.com/search?q=%s +i = insert_mode +B = spawn /home/duclare/.uzbl/insert_bookmark.sh +u = spawn /home/duclare/.uzbl/load_url_from_history.sh +U = spawn /home/duclare/.uzbl/load_url_from_bookmarks.sh +y = spawn /home/duclare/.uzbl/clipboard.sh yank +p = spawn /home/duclare/.uzbl/clipboard.sh goto +W = spawn /home/duclare/.uzbl/launch +ZZ = exit +:q = spawn /home/duclare/.uzbl/session.sh endsession + +# Keyboard based link following: work in progress! No C DOM bindings yet, no click() event for hyperlinks so no referrer set..Quite basic but does the job for now... +# Vimperator-like hints, except that you can't type text to narrow on targets. You can still the text of a link from the beginning, and it'll activate as soon as the word is unique +f* = script var uzblid = 'uzbl_link_hint'; var uzbldivid = uzblid+'_div_container'; var links = document.links; try { HTMLElement.prototype.click = function () {if (typeof this.onclick == 'function') this.onclick({type: 'click'}); } } catch (e) {} function removeOldHints() { var elements = document.getElementById(uzbldivid); if( elements) elements.parentNode.removeChild(elements); } function keyPressHandler(e) {var kC = (window.event) ? event.keyCode : e.keyCode; var Esc = (window.event) ? 27 : e.DOM_VK_ESCAPE; if(kC==Esc) removeOldHints();} function isVisible(obj) { if (obj == document) return true; if (!obj) return false; if (!obj.parentNode) return false; if (obj.style) { if (obj.style.display == 'none') return false; if (obj.style.visibility == 'hidden') return false; } return isVisible(obj.parentNode); } function elementPosition(el) { var up = el.offsetTop; var left = el.offsetLeft; var width = el.offsetWidth; var height = el.offsetHeight; while(el.offsetParent) { el = el.offsetParent; up += el.offsetTop; left += el.offsetLeft; } return [up,left,width,height]; } function elementInViewport(el) { offset = elementPosition(el); var up = offset[0]; var left = offset[1]; var width = offset[2]; var height = offset[3]; return (up < (window.pageYOffset + window.innerHeight) && left < (window.pageXOffset + window.innerWidth) && (up + height) > window.pageYOffset && (left + width) > window.pageXOffset); } function generateHints(items, l) { var hintdiv = document.createElement('div'); hintdiv.setAttribute('id', uzbldivid); for (var i=0; i < items.length; i++) { var nr = items[i]; var li = links[nr]; var pos = elementPosition(li); var hint = document.createElement('div'); hint.setAttribute('name',uzblid); var n = (nr+'').length; for (n; n0) { hint.style.left=pos[1]+(img[0].width/2)+'px'; } hint.style.textDecoration='none'; hint.style.webkitBorderRadius='6px'; hint.style.webkitTransform='scale(0.9) rotate(0deg) translate(-6px,-5px)'; hintdiv.appendChild(hint); } document.body.appendChild(hintdiv); } function clickLink(item) { removeOldHints(); if (item) { item.click(); window.location = item.href; } } function followLink(follow) { document.body.setAttribute('onkeyup', 'keyPressHandler(event)'); var s = follow.split(''); var linktexts = [[],[]]; for (var i=0; i < links.length; i++) { var li = links[i]; if (isVisible(li) && elementInViewport(li)) { linktexts[0].push(i); linktexts[1].push(li.innerText); } } var leftovers = []; var nrlength = (linktexts[0][linktexts[0].length-1]+'').length; var linknr = parseInt(follow, 10); if (s.length == nrlength) { clickLink(links[linknr]); } else { for (var j=0; j < linktexts[0].length; j++) { var b = true; for (var k=0; k < s.length; k++) { b = (b && (linktexts[1][j].charAt(k)==s[k])); } if (b) { leftovers.push(linktexts[0][j]); } } if (leftovers.length == 1 && s.length >= nrlength) { clickLink(links[leftovers[0]]); } else if (!document.getElementById(uzbldivid)) { generateHints(linktexts[0], nrlength); } } } followLink('%s'); + +[network] +# to start a local socks server, do : ssh -fND localhost:8118 localhost +#proxy_server = http://127.0.0.1:8118 +#values 0-3 +http_debug = 0 +user-agent = uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) +# Example user agent containing everything: +#user-agent = Uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) (%sysname% %nodename% %kernrel% %kernver% %arch-system% [%arch-uzbl%]) (Commit %commit%) +max_conns = +max_conns_per_host = + -- cgit v1.2.3 From 06decd112822531e5c789f7438b909944cdf3039 Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Tue, 12 May 2009 15:33:46 +0200 Subject: first partially working command parser --- uzbl.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++-------------- uzbl.h | 10 ++++-- 2 files changed, 101 insertions(+), 28 deletions(-) diff --git a/uzbl.c b/uzbl.c index 127c585..8a951ee 100644 --- a/uzbl.c +++ b/uzbl.c @@ -57,7 +57,28 @@ static Uzbl uzbl; - +char *foobar="Just a test"; + +/* define names and pointers to all config specific variables */ +const struct { + char *name; + void **ptr; +} var_name_to_ptr[] = { + { "name", (void *)&uzbl.state.instance_name }, + { "show_status", (void *)&uzbl.behave.show_status }, + { "insert_mode", (void *)&uzbl.behave.insert_mode }, + { NULL, NULL } +}, *n2v_p = var_name_to_ptr; + +/* construct a hash from the var_name_to_ptr array for quick access */ +static void +make_var_to_name_hash() { + uzbl.comm.proto_var = g_hash_table_new(g_str_hash, g_str_equal); + while(n2v_p->name) { + g_hash_table_insert(uzbl.comm.proto_var, n2v_p->name, n2v_p->ptr); + n2v_p++; + } +} /* commandline arguments (set initial values for the state variables) */ static GOptionEntry entries[] = @@ -714,40 +735,82 @@ create_fifo() { return; } +static gboolean +get_var_value(gchar *name) { + void **p = NULL; + + if( (p = g_hash_table_lookup(uzbl.comm.proto_var, name)) ) { + if(!strcmp(name, "name")) { + printf("VAR: %s VALUE: %s\n", name, (char *)*p); + } else { + printf("VAR: %s VALUE: %d\n", name, (int)*p); + } + } + return TRUE; +} + +static gboolean +set_var_value(gchar *name, gchar *val) { + void **p = NULL; + char *endp = NULL; + + if( (p = g_hash_table_lookup(uzbl.comm.proto_var, name)) ) { + if(!strcmp(name, "name")) { + free(*p); + *p = g_strdup(val); + } else { + *p = (int)strtoul(val, &endp, 10); + } + } + return TRUE; +} + static void +setup_regex() { + GError *err=NULL; + + uzbl.comm.get_regex = g_regex_new("^GET\\s+([^ \\n]+)$", 0, 0, &err); + uzbl.comm.set_regex = g_regex_new("^SET\\s+([^ ]+)\\s*=\\s*([^\\n].*)$", 0, 0, &err); +} + +static gboolean control_stdin(GIOChannel *gio, GIOCondition condition) { - gchar *ctl_line; + gchar *ctl_line = NULL; + gsize ctl_line_len = 0; GIOStatus ret; GError *err = NULL; - printf("stdin triggered\n"); + gchar **tokens; - if (condition & G_IO_HUP) { //FIXME: for some reason, the last command is not interpreted. but when we get here gio->is_readable = FALSE. + if (condition & G_IO_HUP) { ret = g_io_channel_shutdown (gio, FALSE, &err); - if (ret == G_IO_STATUS_ERROR) { - g_error ("Stdin: disconnected with HUP, but could not close it!\n"); - } else { - printf("Stdin: closed on request with HUP\n"); - return; - } + return FALSE; } - if(!gio) - g_error ("Stdin: GIOChannel broke\n"); - ret = g_io_channel_read_line(gio, &ctl_line, NULL, NULL, &err); - if (ret == G_IO_STATUS_ERROR) - g_error ("Stdin: Error reading: %s\n", err->message); - if (ret == G_IO_STATUS_EOF) { - ret = g_io_channel_shutdown (gio, FALSE, &err); - if (ret == G_IO_STATUS_ERROR) { - g_error ("Stdin: disconnected without HUP, but could not close it!\n"); - } else { - printf("Stdin: closed on request without HUP\n"); + ret = g_io_channel_read_line(gio, &ctl_line, &ctl_line_len, NULL, &err); + if ( (ret == G_IO_STATUS_ERROR) || (ret == G_IO_STATUS_EOF) ) + return FALSE; + + /* SET command */ + if(ctl_line[0] == 'S') { + tokens = g_regex_split(uzbl.comm.set_regex, ctl_line, 0); + if(tokens) { + set_var_value(tokens[1], tokens[2]); + g_strfreev(tokens); } } - parse_line(ctl_line); + /* GET command */ + else if(ctl_line[0] == 'G') { + tokens = g_regex_split(uzbl.comm.get_regex, ctl_line, 0); + if(tokens) { + get_var_value(tokens[1]); + g_strfreev(tokens); + } + } else + printf("Command not understood (%s)\n", ctl_line); + g_free(ctl_line); - printf("stdin...done\n"); - return; + + return TRUE; } static void @@ -755,7 +818,7 @@ create_stdin () { GIOChannel *chan = NULL; GError *error = NULL; - chan = g_io_channel_unix_new (fileno(stdin)); + chan = g_io_channel_unix_new(fileno(stdin)); if (chan) { if (!g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_stdin, NULL)) { g_error ("Stdin: could not add watch\n"); @@ -1345,7 +1408,10 @@ main (int argc, char* argv[]) { if(setup_signal(SIGTERM, catch_sigterm) == SIG_ERR) fprintf(stderr, "uzbl: error hooking SIGTERM\n"); + + setup_regex(); setup_scanner(); + if (!uzbl.behave.status_format) uzbl.behave.status_format = STATUS_DEFAULT; if (!uzbl.behave.show_status) @@ -1354,11 +1420,12 @@ main (int argc, char* argv[]) { update_title(); + make_var_to_name_hash(); + create_stdin(); if (uzbl.behave.fifo_dir) create_fifo (); if (uzbl.behave.socket_dir) create_socket (); - create_stdin (); gtk_main (); clean_up(); diff --git a/uzbl.h b/uzbl.h index d414645..0f47304 100644 --- a/uzbl.h +++ b/uzbl.h @@ -57,6 +57,12 @@ enum { FIFO, SOCKET}; typedef struct { char fifo_path[64]; char socket_path[108]; + /* stores (key)"variable name" -> (value)"pointer to this var*/ + GHashTable *proto_var; + /* command parsing regexes */ + GRegex *set_regex; + GRegex *get_regex; + GRegex *bind_regex; } Communication; @@ -64,7 +70,7 @@ typedef struct { typedef struct { gchar *uri; gchar *config_file; - gchar *instance_name; + char *instance_name; gchar config_file_path[500]; gchar selected_url[500]; char executable_path[500]; @@ -224,7 +230,7 @@ control_fifo(GIOChannel *gio, GIOCondition condition); static void create_fifo(); -static void +static gboolean control_stdin(GIOChannel *gio, GIOCondition condition); static void -- cgit v1.2.3 From 474f7ff26c8a4112d17b6922c70a4d5a0bd95e97 Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Tue, 12 May 2009 17:17:35 +0200 Subject: added BIND to cmd parser --- uzbl.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/uzbl.c b/uzbl.c index 8a951ee..c599d65 100644 --- a/uzbl.c +++ b/uzbl.c @@ -769,8 +769,9 @@ static void setup_regex() { GError *err=NULL; - uzbl.comm.get_regex = g_regex_new("^GET\\s+([^ \\n]+)$", 0, 0, &err); - uzbl.comm.set_regex = g_regex_new("^SET\\s+([^ ]+)\\s*=\\s*([^\\n].*)$", 0, 0, &err); + uzbl.comm.get_regex = g_regex_new("^GET\\s+([^ \\n]+)$", 0, 0, &err); + uzbl.comm.set_regex = g_regex_new("^SET\\s+([^ ]+)\\s*=\\s*([^\\n].*)$", 0, 0, &err); + uzbl.comm.bind_regex = g_regex_new("^BIND\\s+(.+[^ ])\\s*=\\s*([a-z][^\\n].+)$", 0, 0, &err); } static gboolean @@ -805,7 +806,15 @@ control_stdin(GIOChannel *gio, GIOCondition condition) { get_var_value(tokens[1]); g_strfreev(tokens); } - } else + } + else if(ctl_line[0] == 'B') { + tokens = g_regex_split(uzbl.comm.bind_regex, ctl_line, 0); + if(tokens) { + add_binding(tokens[1], tokens[2]); + g_strfreev(tokens); + } + } + else printf("Command not understood (%s)\n", ctl_line); g_free(ctl_line); -- cgit v1.2.3 From 14cf19d150fd67149d3b376032a5df503362df57 Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Tue, 12 May 2009 17:46:29 +0200 Subject: catch errors in commands --- uzbl.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/uzbl.c b/uzbl.c index c599d65..b4e104d 100644 --- a/uzbl.c +++ b/uzbl.c @@ -57,7 +57,6 @@ static Uzbl uzbl; -char *foobar="Just a test"; /* define names and pointers to all config specific variables */ const struct { @@ -794,25 +793,32 @@ control_stdin(GIOChannel *gio, GIOCondition condition) { /* SET command */ if(ctl_line[0] == 'S') { tokens = g_regex_split(uzbl.comm.set_regex, ctl_line, 0); - if(tokens) { + if(!strcmp(tokens[0], "")) { set_var_value(tokens[1], tokens[2]); g_strfreev(tokens); } + else + printf("Error in command: %s\n", tokens[0]); } /* GET command */ else if(ctl_line[0] == 'G') { tokens = g_regex_split(uzbl.comm.get_regex, ctl_line, 0); - if(tokens) { + if(!strcmp(tokens[0], "")) { get_var_value(tokens[1]); g_strfreev(tokens); } + else + printf("Error in command: %s\n", tokens[0]); } + /* BIND command */ else if(ctl_line[0] == 'B') { tokens = g_regex_split(uzbl.comm.bind_regex, ctl_line, 0); - if(tokens) { + if(!strcmp(tokens[0], "")) { add_binding(tokens[1], tokens[2]); g_strfreev(tokens); } + else + printf("Error in command: %s\n", tokens[0]); } else printf("Command not understood (%s)\n", ctl_line); -- cgit v1.2.3 From d14d86bd1cf7fc611435a9c927d99f3a39fcc05f Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Tue, 12 May 2009 17:50:47 +0200 Subject: more efficient error catching in commands --- uzbl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/uzbl.c b/uzbl.c index b4e104d..c652917 100644 --- a/uzbl.c +++ b/uzbl.c @@ -793,7 +793,7 @@ control_stdin(GIOChannel *gio, GIOCondition condition) { /* SET command */ if(ctl_line[0] == 'S') { tokens = g_regex_split(uzbl.comm.set_regex, ctl_line, 0); - if(!strcmp(tokens[0], "")) { + if(tokens[0][0] == 0) { set_var_value(tokens[1], tokens[2]); g_strfreev(tokens); } @@ -803,7 +803,7 @@ control_stdin(GIOChannel *gio, GIOCondition condition) { /* GET command */ else if(ctl_line[0] == 'G') { tokens = g_regex_split(uzbl.comm.get_regex, ctl_line, 0); - if(!strcmp(tokens[0], "")) { + if(tokens[0][0] == 0) { get_var_value(tokens[1]); g_strfreev(tokens); } @@ -813,7 +813,7 @@ control_stdin(GIOChannel *gio, GIOCondition condition) { /* BIND command */ else if(ctl_line[0] == 'B') { tokens = g_regex_split(uzbl.comm.bind_regex, ctl_line, 0); - if(!strcmp(tokens[0], "")) { + if(tokens[0][0] == 0) { add_binding(tokens[1], tokens[2]); g_strfreev(tokens); } -- cgit v1.2.3 From 2fe6de7e003d01d8c06bcee60f6131a7da059bce Mon Sep 17 00:00:00 2001 From: DuClare Date: Tue, 12 May 2009 19:30:39 +0300 Subject: Whitespace cleanup --- uzbl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uzbl.c b/uzbl.c index 2e829ef..e7414e3 100644 --- a/uzbl.c +++ b/uzbl.c @@ -1109,7 +1109,7 @@ settings_init () { printf ("Show status: %s\n", (b->show_status ? "TRUE" : "FALSE")); printf ("Status top: %s\n", (b->status_top ? "TRUE" : "FALSE")); printf ("Modkey: %s\n", (b->modkey ? b->modkey : "disabled")); - printf ("Status format: %s\n", (b->status_format ? b->status_format : "none")); + printf ("Status format: %s\n", (b->status_format ? b->status_format : "none")); if (!b->modkey) b->modkey = ""; -- cgit v1.2.3 From 0131a31934ae5330ad2bee7db89ce642f158bf5e Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Tue, 12 May 2009 18:31:51 +0200 Subject: further enhancements to the cmd parser, added sampleconfig-pipe --- examples/configs/sampleconfig-pipe | 4 ++++ uzbl.c | 25 +++++++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 examples/configs/sampleconfig-pipe diff --git a/examples/configs/sampleconfig-pipe b/examples/configs/sampleconfig-pipe new file mode 100644 index 0000000..305f57d --- /dev/null +++ b/examples/configs/sampleconfig-pipe @@ -0,0 +1,4 @@ +GET status_format +BIND xx = exit +BIND gG _ = uri http://www.google.com/search?q=%s +SET status_format = MODE KEYCMD URI diff --git a/uzbl.c b/uzbl.c index c652917..ccb2203 100644 --- a/uzbl.c +++ b/uzbl.c @@ -63,7 +63,7 @@ const struct { char *name; void **ptr; } var_name_to_ptr[] = { - { "name", (void *)&uzbl.state.instance_name }, + { "status_format", (void *)&uzbl.behave.status_format }, { "show_status", (void *)&uzbl.behave.show_status }, { "insert_mode", (void *)&uzbl.behave.insert_mode }, { NULL, NULL } @@ -212,6 +212,16 @@ static void scroll_horz(WebKitWebView* page, const char *param) { scroll(uzbl.gui.bar_h, param); } +static void +cmd_set_status() { + if (!uzbl.behave.show_status) { + gtk_widget_hide(uzbl.gui.mainbar); + } else { + gtk_widget_show(uzbl.gui.mainbar); + } + update_title(); +} + static void toggle_status_cb (WebKitWebView* page, const char *param) { (void)page; @@ -754,11 +764,18 @@ set_var_value(gchar *name, gchar *val) { char *endp = NULL; if( (p = g_hash_table_lookup(uzbl.comm.proto_var, name)) ) { - if(!strcmp(name, "name")) { + if(!strcmp(name, "status_format")) { free(*p); *p = g_strdup(val); - } else { + update_title(); + } + /* variables that take int values */ + else { *p = (int)strtoul(val, &endp, 10); + + if(!strcmp(name, "show_status")) { + cmd_set_status(); + } } } return TRUE; @@ -770,7 +787,7 @@ setup_regex() { uzbl.comm.get_regex = g_regex_new("^GET\\s+([^ \\n]+)$", 0, 0, &err); uzbl.comm.set_regex = g_regex_new("^SET\\s+([^ ]+)\\s*=\\s*([^\\n].*)$", 0, 0, &err); - uzbl.comm.bind_regex = g_regex_new("^BIND\\s+(.+[^ ])\\s*=\\s*([a-z][^\\n].+)$", 0, 0, &err); + uzbl.comm.bind_regex = g_regex_new("^BIND\\s+(.*[^ ])\\s*=\\s*([a-z][^\\n].+)$", 0, 0, &err); } static gboolean -- cgit v1.2.3 From 77ccea2297831ec45a9086cd06ab0360d5082b2a Mon Sep 17 00:00:00 2001 From: DuClare Date: Tue, 12 May 2009 19:32:44 +0300 Subject: Whitespace cleanup. --- uzbl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uzbl.c b/uzbl.c index e7414e3..cbeb8bf 100644 --- a/uzbl.c +++ b/uzbl.c @@ -1273,7 +1273,7 @@ main (int argc, char* argv[]) { /* initialize hash table */ uzbl.bindings = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, free_action); - uzbl.net.soup_session = webkit_get_default_session(); + uzbl.net.soup_session = webkit_get_default_session(); uzbl.state.keycmd = g_string_new(""); settings_init (); -- cgit v1.2.3 From 7e9e843b750db72f3be38ffb2f7396543741563e Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Tue, 12 May 2009 22:42:08 +0200 Subject: correct erroneous cmd name --- uzbl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uzbl.c b/uzbl.c index ccb2203..43a861b 100644 --- a/uzbl.c +++ b/uzbl.c @@ -749,7 +749,7 @@ get_var_value(gchar *name) { void **p = NULL; if( (p = g_hash_table_lookup(uzbl.comm.proto_var, name)) ) { - if(!strcmp(name, "name")) { + if(!strcmp(name, "status_format")) { printf("VAR: %s VALUE: %s\n", name, (char *)*p); } else { printf("VAR: %s VALUE: %d\n", name, (int)*p); -- cgit v1.2.3 From 9e0d67238f69114f900ee4c279734c63bbdaf545 Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Tue, 12 May 2009 23:00:08 +0200 Subject: added status_msg and MSG to status template --- uzbl.c | 16 ++++++++++++++-- uzbl.h | 4 +++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/uzbl.c b/uzbl.c index 43a861b..5f33b81 100644 --- a/uzbl.c +++ b/uzbl.c @@ -63,7 +63,8 @@ const struct { char *name; void **ptr; } var_name_to_ptr[] = { - { "status_format", (void *)&uzbl.behave.status_format }, + { "status_format", (void *)&uzbl.behave.status_format }, + { "status_message", (void *)&uzbl.gui.sbar.msg }, { "show_status", (void *)&uzbl.behave.show_status }, { "insert_mode", (void *)&uzbl.behave.insert_mode }, { NULL, NULL } @@ -570,6 +571,10 @@ parse_status_template(const char *template) { g_string_append(ret, uzbl.behave.insert_mode?"[I]":"[C]"); break; + case SYM_MSG: + g_string_append(ret, + uzbl.gui.sbar.msg?uzbl.gui.sbar.msg:""); + break; default: break; } @@ -765,7 +770,14 @@ set_var_value(gchar *name, gchar *val) { if( (p = g_hash_table_lookup(uzbl.comm.proto_var, name)) ) { if(!strcmp(name, "status_format")) { - free(*p); + if(*p) + free(*p); + *p = g_strdup(val); + update_title(); + } + else if(!strcmp(name, "status_message")) { + if(*p) + free(*p); *p = g_strdup(val); update_title(); } diff --git a/uzbl.h b/uzbl.h index 0f47304..7c6b811 100644 --- a/uzbl.h +++ b/uzbl.h @@ -15,7 +15,7 @@ /* statusbar symbols */ enum { SYM_TITLE, SYM_URI, SYM_NAME, SYM_LOADPRGS, SYM_LOADPRGSBAR, - SYM_KEYCMD, SYM_MODE}; + SYM_KEYCMD, SYM_MODE, SYM_MSG}; const struct { gchar *symbol_name; guint symbol_token; @@ -25,6 +25,7 @@ const struct { {"TITLE", SYM_TITLE}, {"KEYCMD", SYM_KEYCMD}, {"MODE", SYM_MODE}, + {"MSG", SYM_MSG}, {"LOAD_PROGRESS", SYM_LOADPRGS}, {"LOAD_PROGRESSBAR", SYM_LOADPRGSBAR}, {NULL, 0} @@ -33,6 +34,7 @@ const struct { /* status bar elements */ typedef struct { gint load_progress; + gchar *msg; } StatusBar; -- cgit v1.2.3 From ff18592e4aef6bf1aa01759aee65199a8624c0fd Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Tue, 12 May 2009 23:18:41 +0200 Subject: fixed segfault on free --- uzbl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uzbl.c b/uzbl.c index 5f33b81..96bbf0f 100644 --- a/uzbl.c +++ b/uzbl.c @@ -1457,7 +1457,7 @@ main (int argc, char* argv[]) { setup_scanner(); if (!uzbl.behave.status_format) - uzbl.behave.status_format = STATUS_DEFAULT; + uzbl.behave.status_format = g_strdup(STATUS_DEFAULT); if (!uzbl.behave.show_status) gtk_widget_hide(uzbl.gui.mainbar); else -- cgit v1.2.3 From 3532d7214d6a6e6c676f1b87e4ba8c851fcc8f2f Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Wed, 13 May 2009 00:26:16 +0200 Subject: stdin, fifo, socket support only the new command style, added uri variable --- examples/configs/sampleconfig-pipe | 7 +- uzbl.c | 202 ++++++++++++++++++++----------------- 2 files changed, 114 insertions(+), 95 deletions(-) diff --git a/examples/configs/sampleconfig-pipe b/examples/configs/sampleconfig-pipe index 305f57d..45f3e08 100644 --- a/examples/configs/sampleconfig-pipe +++ b/examples/configs/sampleconfig-pipe @@ -1,4 +1,7 @@ GET status_format -BIND xx = exit +SET show_status = 1 +BIND x = exit BIND gG _ = uri http://www.google.com/search?q=%s -SET status_format = MODE KEYCMD URI +SET status_format = MSG URI +SET status_message = Wazz up dude? +BIND x = exit diff --git a/uzbl.c b/uzbl.c index 96bbf0f..84005df 100644 --- a/uzbl.c +++ b/uzbl.c @@ -63,10 +63,12 @@ const struct { char *name; void **ptr; } var_name_to_ptr[] = { - { "status_format", (void *)&uzbl.behave.status_format }, - { "status_message", (void *)&uzbl.gui.sbar.msg }, - { "show_status", (void *)&uzbl.behave.show_status }, - { "insert_mode", (void *)&uzbl.behave.insert_mode }, + { "uri", (void *)&uzbl.state.uri }, + { "status_format", (void *)&uzbl.behave.status_format }, + { "status_background", (void *)&uzbl.behave.status_background }, + { "status_message", (void *)&uzbl.gui.sbar.msg }, + { "show_status", (void *)&uzbl.behave.show_status }, + { "insert_mode", (void *)&uzbl.behave.insert_mode }, { NULL, NULL } }, *n2v_p = var_name_to_ptr; @@ -663,6 +665,103 @@ parse_line(char *line) { g_strfreev(parts); } +/* command parser */ +static void +setup_regex() { + GError *err=NULL; + + uzbl.comm.get_regex = g_regex_new("^GET\\s+([^ \\n]+)$", 0, 0, &err); + uzbl.comm.set_regex = g_regex_new("^SET\\s+([^ ]+)\\s*=\\s*([^\\n].*)$", 0, 0, &err); + uzbl.comm.bind_regex = g_regex_new("^BIND\\s+(.*[^ ])\\s*=\\s*([a-z][^\\n].+)$", 0, 0, &err); +} +static gboolean +get_var_value(gchar *name) { + void **p = NULL; + + if( (p = g_hash_table_lookup(uzbl.comm.proto_var, name)) ) { + if(!strcmp(name, "status_format")) { + printf("VAR: %s VALUE: %s\n", name, (char *)*p); + } else { + printf("VAR: %s VALUE: %d\n", name, (int)*p); + } + } + return TRUE; +} + +static gboolean +set_var_value(gchar *name, gchar *val) { + void **p = NULL; + char *endp = NULL; + + if( (p = g_hash_table_lookup(uzbl.comm.proto_var, name)) ) { + if(!strcmp(name, "status_message") + || !strcmp(name, "status_background") + || !strcmp(name, "status_format")) { + if(*p) + free(*p); + *p = g_strdup(val); + update_title(); + } + else if(!strcmp(name, "uri")) { + if(*p) + free(*p); + *p = g_strdup(val); + load_uri(uzbl.gui.web_view, (const gchar*)*p); + } + /* variables that take int values */ + else { + *p = (int)strtoul(val, &endp, 10); + + if(!strcmp(name, "show_status")) { + cmd_set_status(); + } + } + } + return TRUE; +} + + +static void +parse_cmd_line(char *ctl_line) { + gchar **tokens; + + /* SET command */ + if(ctl_line[0] == 'S') { + tokens = g_regex_split(uzbl.comm.set_regex, ctl_line, 0); + if(tokens[0][0] == 0) { + set_var_value(tokens[1], tokens[2]); + g_strfreev(tokens); + } + else + printf("Error in command: %s\n", tokens[0]); + } + /* GET command */ + else if(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]); + g_strfreev(tokens); + } + else + printf("Error in command: %s\n", tokens[0]); + } + /* BIND command */ + else if(ctl_line[0] == 'B') { + tokens = g_regex_split(uzbl.comm.bind_regex, ctl_line, 0); + if(tokens[0][0] == 0) { + add_binding(tokens[1], tokens[2]); + g_strfreev(tokens); + } + else + printf("Error in command: %s\n", tokens[0]); + } + else + printf("Command not understood (%s)\n", ctl_line); + + return; +} + + void build_stream_name(int type) { char *xwin_str; @@ -715,9 +814,10 @@ control_fifo(GIOChannel *gio, GIOCondition condition) { if (ret == G_IO_STATUS_ERROR) g_error ("Fifo: Error reading: %s\n", err->message); - parse_line(ctl_line); + //parse_line(ctl_line); + parse_cmd_line(ctl_line); g_free(ctl_line); - printf("...done\n"); + return; } @@ -749,58 +849,6 @@ create_fifo() { return; } -static gboolean -get_var_value(gchar *name) { - void **p = NULL; - - if( (p = g_hash_table_lookup(uzbl.comm.proto_var, name)) ) { - if(!strcmp(name, "status_format")) { - printf("VAR: %s VALUE: %s\n", name, (char *)*p); - } else { - printf("VAR: %s VALUE: %d\n", name, (int)*p); - } - } - return TRUE; -} - -static gboolean -set_var_value(gchar *name, gchar *val) { - void **p = NULL; - char *endp = NULL; - - if( (p = g_hash_table_lookup(uzbl.comm.proto_var, name)) ) { - if(!strcmp(name, "status_format")) { - if(*p) - free(*p); - *p = g_strdup(val); - update_title(); - } - else if(!strcmp(name, "status_message")) { - if(*p) - free(*p); - *p = g_strdup(val); - update_title(); - } - /* variables that take int values */ - else { - *p = (int)strtoul(val, &endp, 10); - - if(!strcmp(name, "show_status")) { - cmd_set_status(); - } - } - } - return TRUE; -} - -static void -setup_regex() { - GError *err=NULL; - - uzbl.comm.get_regex = g_regex_new("^GET\\s+([^ \\n]+)$", 0, 0, &err); - uzbl.comm.set_regex = g_regex_new("^SET\\s+([^ ]+)\\s*=\\s*([^\\n].*)$", 0, 0, &err); - uzbl.comm.bind_regex = g_regex_new("^BIND\\s+(.*[^ ])\\s*=\\s*([a-z][^\\n].+)$", 0, 0, &err); -} static gboolean control_stdin(GIOChannel *gio, GIOCondition condition) { @@ -808,7 +856,6 @@ control_stdin(GIOChannel *gio, GIOCondition condition) { gsize ctl_line_len = 0; GIOStatus ret; GError *err = NULL; - gchar **tokens; if (condition & G_IO_HUP) { ret = g_io_channel_shutdown (gio, FALSE, &err); @@ -819,39 +866,7 @@ control_stdin(GIOChannel *gio, GIOCondition condition) { if ( (ret == G_IO_STATUS_ERROR) || (ret == G_IO_STATUS_EOF) ) return FALSE; - /* SET command */ - if(ctl_line[0] == 'S') { - tokens = g_regex_split(uzbl.comm.set_regex, ctl_line, 0); - if(tokens[0][0] == 0) { - set_var_value(tokens[1], tokens[2]); - g_strfreev(tokens); - } - else - printf("Error in command: %s\n", tokens[0]); - } - /* GET command */ - else if(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]); - g_strfreev(tokens); - } - else - printf("Error in command: %s\n", tokens[0]); - } - /* BIND command */ - else if(ctl_line[0] == 'B') { - tokens = g_regex_split(uzbl.comm.bind_regex, ctl_line, 0); - if(tokens[0][0] == 0) { - add_binding(tokens[1], tokens[2]); - g_strfreev(tokens); - } - else - printf("Error in command: %s\n", tokens[0]); - } - else - printf("Command not understood (%s)\n", ctl_line); - + parse_cmd_line(ctl_line); g_free(ctl_line); return TRUE; @@ -908,7 +923,8 @@ control_socket(GIOChannel *chan) { } close (clientsock); ctl_line = g_strdup(buffer); - parse_line (ctl_line); + //parse_line (ctl_line); + parse_cmd_line (ctl_line); /* TODO: we should be able to do it with this. but glib errors out with "Invalid argument" -- cgit v1.2.3 From 76d8e267b0f64b7213c0cf5f8aa46b6c47ad77cb Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Wed, 13 May 2009 01:28:13 +0200 Subject: fixed BIND regex's greedyness, support to overwrite existing bindings --- examples/configs/sampleconfig-pipe | 36 +++++++++++++++++++++++++++++------- uzbl.c | 12 +++++++++--- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/examples/configs/sampleconfig-pipe b/examples/configs/sampleconfig-pipe index 45f3e08..78a1b80 100644 --- a/examples/configs/sampleconfig-pipe +++ b/examples/configs/sampleconfig-pipe @@ -1,7 +1,29 @@ -GET status_format -SET show_status = 1 -BIND x = exit -BIND gG _ = uri http://www.google.com/search?q=%s -SET status_format = MSG URI -SET status_message = Wazz up dude? -BIND x = exit +SET show_status = 1 +SET status_background = #303030 +SET status_format = MODE [KEYCMD] LOAD_PROGRESSBAR URI NAME +BIND j = scroll_vert 20 +BIND k = scroll_vert -20 +BIND h = scroll_horz -20 +BIND l = scroll_horz 20 +BIND b = back +BIND m = forward +BIND s = stop +BIND r = reload +BIND R = reload_ign_cache +BIND + = zoom_in +BIND - = zoom_out +BIND t = toggle uzbl.behave.show_status +BIND /_ = search %s +BIND ; = search +BIND gh = uri http://www.uzbl.org +BIND o _ = uri %s +BIND :wiki _ = uri http://wiki.archlinux.org/index.php/Special:Search?search=%s&go=Go +BIND gg _ = uri http://www.google.com/search?q=%s +BIND i = insert_mode +BIND B = spawn ./examples/scripts/insert_bookmark.sh +BIND u = spawn ./examples/scripts/load_url_from_history.sh +BIND U = spawn ./examples/scripts/load_url_from_bookmarks.sh +BIND ZZ = exit +BIND S = script alert("hi"); +BIND F= script for (var i=0; i < document.links.length; i++) {var uzblid = 'uzbl_link_hint_';var li = document.links[i];var pre = document.getElementById(uzblid+i);if (pre) {li.removeChild(pre);} else {var hint = document.createElement('div');hint.setAttribute('id',uzblid+i);hint.innerHTML = i;hint.style.display='inline';hint.style.lineHeight='90%';hint.style.backgroundColor='red';hint.style.color='white';hint.style.fontSize='small-xx';hint.style.fontWeight='light';hint.style.margin='0px';hint.style.padding='2px';hint.style.position='absolute';hint.style.textDecoration='none';hint.style.left=li.style.left;hint.style.top=li.style.top;li.insertAdjacentElement('afterBegin',hint);}} +BIND f_ = script window.location = document.links[%s].href; diff --git a/uzbl.c b/uzbl.c index 84005df..612fd87 100644 --- a/uzbl.c +++ b/uzbl.c @@ -670,9 +670,12 @@ static void setup_regex() { GError *err=NULL; - uzbl.comm.get_regex = g_regex_new("^GET\\s+([^ \\n]+)$", 0, 0, &err); - uzbl.comm.set_regex = g_regex_new("^SET\\s+([^ ]+)\\s*=\\s*([^\\n].*)$", 0, 0, &err); - uzbl.comm.bind_regex = g_regex_new("^BIND\\s+(.*[^ ])\\s*=\\s*([a-z][^\\n].+)$", 0, 0, &err); + uzbl.comm.get_regex = g_regex_new("^GET\\s+([^ \\n]+)$", + G_REGEX_OPTIMIZE, 0, &err); + uzbl.comm.set_regex = g_regex_new("^SET\\s+([^ ]+)\\s*=\\s*([^\\n].*)$", + G_REGEX_OPTIMIZE, 0, &err); + uzbl.comm.bind_regex = g_regex_new("^BIND\\s+?(.*[^ ])\\s*?=\\s*([a-z][^\\n].+)$", + G_REGEX_UNGREEDY|G_REGEX_OPTIMIZE, 0, &err); } static gboolean get_var_value(gchar *name) { @@ -1178,6 +1181,9 @@ add_binding (const gchar *key, const gchar *act) { //Debug: printf ("Binding %-10s : %s\n", key, act); action = new_action(parts[0], parts[1]); + + if(g_hash_table_lookup(uzbl.bindings, key)) + g_hash_table_remove(uzbl.bindings, key); g_hash_table_insert(uzbl.bindings, g_strdup(key), action); g_strfreev(parts); -- cgit v1.2.3 From a135f3b6e6d03ca3d4ad15c8383047c659953f15 Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Wed, 13 May 2009 01:35:21 +0200 Subject: typos in sampleconfig-pipe --- examples/configs/sampleconfig-pipe | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/configs/sampleconfig-pipe b/examples/configs/sampleconfig-pipe index 78a1b80..a23f6d9 100644 --- a/examples/configs/sampleconfig-pipe +++ b/examples/configs/sampleconfig-pipe @@ -1,10 +1,10 @@ SET show_status = 1 SET status_background = #303030 SET status_format = MODE [KEYCMD] LOAD_PROGRESSBAR URI NAME -BIND j = scroll_vert 20 -BIND k = scroll_vert -20 -BIND h = scroll_horz -20 -BIND l = scroll_horz 20 +BIND j = scroll_vert 20 +BIND k = scroll_vert -20 +BIND h = scroll_horz -20 +BIND l = scroll_horz 20 BIND b = back BIND m = forward BIND s = stop @@ -12,7 +12,7 @@ BIND r = reload BIND R = reload_ign_cache BIND + = zoom_in BIND - = zoom_out -BIND t = toggle uzbl.behave.show_status +BIND t = toggle_status BIND /_ = search %s BIND ; = search BIND gh = uri http://www.uzbl.org -- cgit v1.2.3 From 702868aaa0ae049f527df3d7071f300d60ffe6ec Mon Sep 17 00:00:00 2001 From: DuClare Date: Wed, 13 May 2009 10:44:30 +0300 Subject: Added load_finish_handler, call when a page has finished loading. --- uzbl.c | 11 +++++++++++ uzbl.h | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/uzbl.c b/uzbl.c index 31b8ae4..64a085d 100644 --- a/uzbl.c +++ b/uzbl.c @@ -271,6 +271,15 @@ progress_change_cb (WebKitWebView* page, gint progress, gpointer data) { update_title(); } +static void +load_finish_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data) { + (void) page; + (void) data; + if (uzbl.behave.load_finish_handler) { + run_command_async(uzbl.behave.load_finish_handler, NULL); + } +} + static void load_commit_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data) { (void) page; @@ -1154,6 +1163,7 @@ create_browser () { g_signal_connect (G_OBJECT (g->web_view), "load-progress-changed", G_CALLBACK (progress_change_cb), g->web_view); g_signal_connect (G_OBJECT (g->web_view), "load-committed", G_CALLBACK (load_commit_cb), g->web_view); g_signal_connect (G_OBJECT (g->web_view), "load-committed", G_CALLBACK (log_history_cb), g->web_view); + g_signal_connect (G_OBJECT (g->web_view), "load-finished", G_CALLBACK (load_finish_cb), g->web_view); g_signal_connect (G_OBJECT (g->web_view), "hovering-over-link", G_CALLBACK (link_hover_cb), g->web_view); g_signal_connect (G_OBJECT (g->web_view), "key-press-event", G_CALLBACK (key_press_cb), g->web_view); g_signal_connect (G_OBJECT (g->web_view), "new-window-policy-decision-requested", G_CALLBACK (new_window_cb), g->web_view); @@ -1264,6 +1274,7 @@ settings_init () { } if (res) { + b->load_finish_handler= g_key_file_get_value (config, "behavior", "load_finish_handler",NULL); b->history_handler = g_key_file_get_value (config, "behavior", "history_handler", NULL); b->download_handler = g_key_file_get_value (config, "behavior", "download_handler", NULL); b->cookie_handler = g_key_file_get_string (config, "behavior", "cookie_handler", NULL); diff --git a/uzbl.h b/uzbl.h index bde85e2..89c27ac 100644 --- a/uzbl.h +++ b/uzbl.h @@ -95,6 +95,7 @@ typedef struct { /* behaviour */ typedef struct { + gchar* load_finish_handler; gchar* status_format; gchar* status_background; gchar* history_handler; @@ -179,6 +180,9 @@ progress_change_cb (WebKitWebView* page, gint progress, gpointer data); static void load_commit_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data); +static void +load_finish_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data); + static void destroy_cb (GtkWidget* widget, gpointer data); -- cgit v1.2.3 From b3f12703f3c8920a96eba51157d5f561f9695527 Mon Sep 17 00:00:00 2001 From: DuClare Date: Wed, 13 May 2009 11:42:11 +0300 Subject: Ignore modmask if it's unset --- uzbl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uzbl.c b/uzbl.c index 64a085d..9920407 100644 --- a/uzbl.c +++ b/uzbl.c @@ -1063,7 +1063,7 @@ key_press_cb (WebKitWebView* page, GdkEventKey* event) return TRUE; } - if (uzbl.behave.insert_mode && ((event->state & uzbl.behave.modmask) != uzbl.behave.modmask)) + if (uzbl.behave.insert_mode && (((event->state & uzbl.behave.modmask) != uzbl.behave.modmask) || (!uzbl.behave.modmask))) return FALSE; if (event->keyval == GDK_Escape) { -- cgit v1.2.3 From 90a7cebb6fbb37392bf626bfdf4274a764be2deb Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Wed, 13 May 2009 12:15:04 +0200 Subject: command files can contain comments and empty lines --- examples/configs/sampleconfig-pipe | 5 ++++- uzbl.c | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/configs/sampleconfig-pipe b/examples/configs/sampleconfig-pipe index a23f6d9..4db3f23 100644 --- a/examples/configs/sampleconfig-pipe +++ b/examples/configs/sampleconfig-pipe @@ -1,6 +1,9 @@ +# Behaviour and appearance SET show_status = 1 SET status_background = #303030 -SET status_format = MODE [KEYCMD] LOAD_PROGRESSBAR URI NAME +SET status_format = MODE [KEYCMD] LOAD_PROGRESSBAR URI NAME MSG + +# Key bindings BIND j = scroll_vert 20 BIND k = scroll_vert -20 BIND h = scroll_horz -20 diff --git a/uzbl.c b/uzbl.c index 612fd87..dcb4706 100644 --- a/uzbl.c +++ b/uzbl.c @@ -758,6 +758,11 @@ parse_cmd_line(char *ctl_line) { 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 printf("Command not understood (%s)\n", ctl_line); -- cgit v1.2.3 From f2c90543e0d41108ec08fde70e19c57158b26219 Mon Sep 17 00:00:00 2001 From: DuClare Date: Wed, 13 May 2009 13:42:56 +0300 Subject: Added CMD for invoking core commands via stdin and scripts. --- uzbl.c | 13 +++++++++++++ uzbl.h | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/uzbl.c b/uzbl.c index 9920407..2af9cc5 100644 --- a/uzbl.c +++ b/uzbl.c @@ -690,7 +690,10 @@ setup_regex() { G_REGEX_OPTIMIZE, 0, &err); uzbl.comm.bind_regex = g_regex_new("^BIND\\s+?(.*[^ ])\\s*?=\\s*([a-z][^\\n].+)$", G_REGEX_UNGREEDY|G_REGEX_OPTIMIZE, 0, &err); + uzbl.comm.cmd_regex = g_regex_new("^CMD\\s+([^ \\n]+)\\s*([^\\n]*)?$", + G_REGEX_OPTIMIZE, 0, &err); } + static gboolean get_var_value(gchar *name) { void **p = NULL; @@ -772,6 +775,16 @@ parse_cmd_line(char *ctl_line) { else printf("Error in command: %s\n", tokens[0]); } + /* CMD command */ + else if(ctl_line[0] == 'C') { + tokens = g_regex_split(uzbl.comm.cmd_regex, ctl_line, 0); + if(tokens[0][0] == 0) { + parse_command(tokens[1], tokens[2]); + g_strfreev(tokens); + } + else + printf("Error in command: %s\n", tokens[0]); + } else printf("Command not understood (%s)\n", ctl_line); diff --git a/uzbl.h b/uzbl.h index 89c27ac..d9b4b06 100644 --- a/uzbl.h +++ b/uzbl.h @@ -62,7 +62,8 @@ typedef struct { /* stores (key)"variable name" -> (value)"pointer to this var*/ GHashTable *proto_var; /* command parsing regexes */ - GRegex *set_regex; + GRegex *set_regex; + GRegex *cmd_regex; GRegex *get_regex; GRegex *bind_regex; } Communication; -- cgit v1.2.3 From 7ad67b457eb953810536a0844781cfcd95f38476 Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Wed, 13 May 2009 13:16:05 +0200 Subject: initial command don't have to be uppercase any more --- examples/configs/sampleconfig-pipe | 58 +++++++++++++++++++------------------- uzbl.c | 12 ++++---- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/examples/configs/sampleconfig-pipe b/examples/configs/sampleconfig-pipe index 4db3f23..9fc4d52 100644 --- a/examples/configs/sampleconfig-pipe +++ b/examples/configs/sampleconfig-pipe @@ -1,32 +1,32 @@ # Behaviour and appearance -SET show_status = 1 -SET status_background = #303030 -SET status_format = MODE [KEYCMD] LOAD_PROGRESSBAR URI NAME MSG +set show_status = 1 +set status_background = #303030 +set status_format = MODE [KEYCMD] LOAD_PROGRESSBAR URI NAME MSG # Key bindings -BIND j = scroll_vert 20 -BIND k = scroll_vert -20 -BIND h = scroll_horz -20 -BIND l = scroll_horz 20 -BIND b = back -BIND m = forward -BIND s = stop -BIND r = reload -BIND R = reload_ign_cache -BIND + = zoom_in -BIND - = zoom_out -BIND t = toggle_status -BIND /_ = search %s -BIND ; = search -BIND gh = uri http://www.uzbl.org -BIND o _ = uri %s -BIND :wiki _ = uri http://wiki.archlinux.org/index.php/Special:Search?search=%s&go=Go -BIND gg _ = uri http://www.google.com/search?q=%s -BIND i = insert_mode -BIND B = spawn ./examples/scripts/insert_bookmark.sh -BIND u = spawn ./examples/scripts/load_url_from_history.sh -BIND U = spawn ./examples/scripts/load_url_from_bookmarks.sh -BIND ZZ = exit -BIND S = script alert("hi"); -BIND F= script for (var i=0; i < document.links.length; i++) {var uzblid = 'uzbl_link_hint_';var li = document.links[i];var pre = document.getElementById(uzblid+i);if (pre) {li.removeChild(pre);} else {var hint = document.createElement('div');hint.setAttribute('id',uzblid+i);hint.innerHTML = i;hint.style.display='inline';hint.style.lineHeight='90%';hint.style.backgroundColor='red';hint.style.color='white';hint.style.fontSize='small-xx';hint.style.fontWeight='light';hint.style.margin='0px';hint.style.padding='2px';hint.style.position='absolute';hint.style.textDecoration='none';hint.style.left=li.style.left;hint.style.top=li.style.top;li.insertAdjacentElement('afterBegin',hint);}} -BIND f_ = script window.location = document.links[%s].href; +bind j = scroll_vert 20 +bind k = scroll_vert -20 +bind h = scroll_horz -20 +bind l = scroll_horz 20 +bind b = back +bind m = forward +bind s = stop +bind r = reload +bind R = reload_ign_cache +bind + = zoom_in +bind - = zoom_out +bind t = toggle_status +bind /_ = search %s +bind ; = search +bind gh = uri http://www.uzbl.org +bind o _ = uri %s +bind :wiki _ = uri http://wiki.archlinux.org/index.php/Special:Search?search=%s&go=Go +bind gg _ = uri http://www.google.com/search?q=%s +bind i = insert_mode +bind B = spawn ./examples/scripts/insert_bookmark.sh +bind u = spawn ./examples/scripts/load_url_from_history.sh +bind U = spawn ./examples/scripts/load_url_from_bookmarks.sh +bind ZZ = exit +bind S = script alert("hi"); +bind F= script for (var i=0; i < document.links.length; i++) {var uzblid = 'uzbl_link_hint_';var li = document.links[i];var pre = document.getElementById(uzblid+i);if (pre) {li.removeChild(pre);} else {var hint = document.createElement('div');hint.setAttribute('id',uzblid+i);hint.innerHTML = i;hint.style.display='inline';hint.style.lineHeight='90%';hint.style.backgroundColor='red';hint.style.color='white';hint.style.fontSize='small-xx';hint.style.fontWeight='light';hint.style.margin='0px';hint.style.padding='2px';hint.style.position='absolute';hint.style.textDecoration='none';hint.style.left=li.style.left;hint.style.top=li.style.top;li.insertAdjacentElement('afterBegin',hint);}} +bind f_ = script window.location = document.links[%s].href; diff --git a/uzbl.c b/uzbl.c index dcb4706..c55c572 100644 --- a/uzbl.c +++ b/uzbl.c @@ -670,11 +670,11 @@ static void setup_regex() { GError *err=NULL; - uzbl.comm.get_regex = g_regex_new("^GET\\s+([^ \\n]+)$", + uzbl.comm.get_regex = g_regex_new("^[Gg][a-zA-Z]*\\s+([^ \\n]+)$", G_REGEX_OPTIMIZE, 0, &err); - uzbl.comm.set_regex = g_regex_new("^SET\\s+([^ ]+)\\s*=\\s*([^\\n].*)$", + uzbl.comm.set_regex = g_regex_new("^[Ss][a-zA-Z]*\\s+([^ ]+)\\s*=\\s*([^\\n].*)$", G_REGEX_OPTIMIZE, 0, &err); - uzbl.comm.bind_regex = g_regex_new("^BIND\\s+?(.*[^ ])\\s*?=\\s*([a-z][^\\n].+)$", + uzbl.comm.bind_regex = g_regex_new("^[Bb][a-zA-Z]*\\s+?(.*[^ ])\\s*?=\\s*([a-z][^\\n].+)$", G_REGEX_UNGREEDY|G_REGEX_OPTIMIZE, 0, &err); } static gboolean @@ -729,7 +729,7 @@ parse_cmd_line(char *ctl_line) { gchar **tokens; /* SET command */ - if(ctl_line[0] == 'S') { + 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) { set_var_value(tokens[1], tokens[2]); @@ -739,7 +739,7 @@ parse_cmd_line(char *ctl_line) { printf("Error in command: %s\n", tokens[0]); } /* GET command */ - else if(ctl_line[0] == 'G') { + 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]); @@ -749,7 +749,7 @@ parse_cmd_line(char *ctl_line) { printf("Error in command: %s\n", tokens[0]); } /* BIND command */ - else if(ctl_line[0] == 'B') { + else 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) { add_binding(tokens[1], tokens[2]); -- cgit v1.2.3 From 06637937a58892b4665a5e25c991cf721d57d024 Mon Sep 17 00:00:00 2001 From: DuClare Date: Wed, 13 May 2009 16:43:43 +0300 Subject: Made handlers configurable via the new cfg system. --- uzbl.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/uzbl.c b/uzbl.c index 0a11099..38fe65f 100644 --- a/uzbl.c +++ b/uzbl.c @@ -69,6 +69,10 @@ const struct { { "status_message", (void *)&uzbl.gui.sbar.msg }, { "show_status", (void *)&uzbl.behave.show_status }, { "insert_mode", (void *)&uzbl.behave.insert_mode }, + { "load_finish_handler",(void *)&uzbl.behave.load_finish_handler}, + { "history_handler", (void *)&uzbl.behave.history_handler }, + { "download_handler", (void *)&uzbl.behave.download_handler }, + { "cookie_handler", (void *)&uzbl.behave.cookie_handler }, { NULL, NULL } }, *n2v_p = var_name_to_ptr; @@ -274,6 +278,7 @@ progress_change_cb (WebKitWebView* page, gint progress, gpointer data) { static void load_finish_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data) { (void) page; + (void) frame; (void) data; if (uzbl.behave.load_finish_handler) { run_command_async(uzbl.behave.load_finish_handler, NULL); @@ -716,7 +721,11 @@ set_var_value(gchar *name, gchar *val) { if( (p = g_hash_table_lookup(uzbl.comm.proto_var, name)) ) { if(!strcmp(name, "status_message") || !strcmp(name, "status_background") - || !strcmp(name, "status_format")) { + || !strcmp(name, "status_format") + || !strcmp(name, "load_finish_handler") + || !strcmp(name, "history_handler") + || !strcmp(name, "download_handler") + || !strcmp(name, "cookie_handler")) { if(*p) free(*p); *p = g_strdup(val); -- cgit v1.2.3 From 3805fe89296634aea7634cb92e4c830ff5fe7716 Mon Sep 17 00:00:00 2001 From: DuClare Date: Wed, 13 May 2009 17:24:35 +0300 Subject: Always watch cookie signals; make the handler func return if var unset --- uzbl.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/uzbl.c b/uzbl.c index 38fe65f..3f7312b 100644 --- a/uzbl.c +++ b/uzbl.c @@ -1429,21 +1429,15 @@ settings_init () { printf("User-agent: %s\n", n->useragent? n->useragent : "default"); printf("Maximum connections: %d\n", n->max_conns ? n->max_conns : 0); printf("Maximum connections per host: %d\n", n->max_conns_host ? n->max_conns_host: 0); - - - if(b->cookie_handler){ - /* ck = soup_cookie_jar_new(); */ - /* soup_session_add_feature(soup_session, SOUP_SESSION_FEATURE(ck)); */ - /* g_signal_connect(ck, "changed", G_CALLBACK(cookie_recieved_action), NULL); */ - g_signal_connect(n->soup_session, "request-queued", G_CALLBACK(handle_cookies), NULL); - } - + g_signal_connect(n->soup_session, "request-queued", G_CALLBACK(handle_cookies), NULL); } static void handle_cookies (SoupSession *session, SoupMessage *msg, gpointer user_data){ (void) session; (void) user_data; + if (!uzbl.behave.cookie_handler) return; + gchar * stdout = NULL; soup_message_add_header_handler(msg, "got-headers", "Set-Cookie", G_CALLBACK(save_cookies), NULL); GString* args = g_string_new (""); -- cgit v1.2.3 From 058b72031ff55a2ec320af4ec505c2559fad21dd Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Thu, 14 May 2009 11:01:46 +0200 Subject: added ability to set proxy_url on the fly, refactored some code --- uzbl.c | 57 ++++++++++++++++++++++++++++++++++----------------------- uzbl.h | 3 --- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/uzbl.c b/uzbl.c index c55c572..2b0d958 100644 --- a/uzbl.c +++ b/uzbl.c @@ -63,13 +63,20 @@ const struct { char *name; void **ptr; } var_name_to_ptr[] = { + // Already working commands { "uri", (void *)&uzbl.state.uri }, { "status_format", (void *)&uzbl.behave.status_format }, { "status_background", (void *)&uzbl.behave.status_background }, { "status_message", (void *)&uzbl.gui.sbar.msg }, { "show_status", (void *)&uzbl.behave.show_status }, { "insert_mode", (void *)&uzbl.behave.insert_mode }, - { NULL, NULL } + { "proxy_url", (void *)&uzbl.net.proxy_url }, + // TODO: write cmd handlers for the following + { "useragent", (void *)&uzbl.net.useragent }, + { "max_conns", (void *)&uzbl.net.max_conns }, + { "max_conns_host", (void *)&uzbl.net.max_conns_host }, + { "http_debug", (void *)&uzbl.behave.http_debug }, + { NULL, NULL } }, *n2v_p = var_name_to_ptr; /* construct a hash from the var_name_to_ptr array for quick access */ @@ -649,22 +656,6 @@ parse_command(const char *cmd, const char *param) { fprintf (stderr, "command \"%s\" not understood. ignoring.\n", cmd); } -static void -parse_line(char *line) { - gchar **parts; - - g_strstrip(line); - - parts = g_strsplit(line, " ", 2); - - if (!parts) - return; - - parse_command(parts[0], parts[1]); - - g_strfreev(parts); -} - /* command parser */ static void setup_regex() { @@ -677,6 +668,7 @@ 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, &err); } + static gboolean get_var_value(gchar *name) { void **p = NULL; @@ -691,6 +683,25 @@ get_var_value(gchar *name) { return TRUE; } +static void +set_proxy_url() { + SoupURI *suri; + + if(*uzbl.net.proxy_url == ' ' + || uzbl.net.proxy_url == NULL) { + soup_session_remove_feature_by_type(uzbl.net.soup_session, + (GType) SOUP_SESSION_PROXY_URI); + } + else { + suri = soup_uri_new(uzbl.net.proxy_url); + g_object_set(G_OBJECT(uzbl.net.soup_session), + SOUP_SESSION_PROXY_URI, + suri, NULL); + soup_uri_free(suri); + } + return; +} + static gboolean set_var_value(gchar *name, gchar *val) { void **p = NULL; @@ -711,6 +722,12 @@ set_var_value(gchar *name, gchar *val) { *p = g_strdup(val); load_uri(uzbl.gui.web_view, (const gchar*)*p); } + else if(!strcmp(name, "proxy_url")) { + if(*p) + free(*p); + *p = g_strdup(val); + set_proxy_url(); + } /* variables that take int values */ else { *p = (int)strtoul(val, &endp, 10); @@ -822,7 +839,6 @@ control_fifo(GIOChannel *gio, GIOCondition condition) { if (ret == G_IO_STATUS_ERROR) g_error ("Fifo: Error reading: %s\n", err->message); - //parse_line(ctl_line); parse_cmd_line(ctl_line); g_free(ctl_line); @@ -931,7 +947,6 @@ control_socket(GIOChannel *chan) { } close (clientsock); ctl_line = g_strdup(buffer); - //parse_line (ctl_line); parse_cmd_line (ctl_line); /* @@ -1316,16 +1331,12 @@ settings_init () { /* networking options */ if (res) { - n->proxy_url = g_key_file_get_value (config, "network", "proxy_server", NULL); b->http_debug = g_key_file_get_integer (config, "network", "http_debug", NULL); n->useragent = g_key_file_get_value (config, "network", "user-agent", NULL); n->max_conns = g_key_file_get_integer (config, "network", "max_conns", NULL); n->max_conns_host = g_key_file_get_integer (config, "network", "max_conns_per_host", NULL); } - if(n->proxy_url){ - g_object_set(G_OBJECT(n->soup_session), SOUP_SESSION_PROXY_URI, soup_uri_new(n->proxy_url), NULL); - } if(!(b->http_debug <= 3)){ b->http_debug = 0; diff --git a/uzbl.h b/uzbl.h index 7c6b811..3511b29 100644 --- a/uzbl.h +++ b/uzbl.h @@ -220,9 +220,6 @@ spawn(WebKitWebView *web_view, const char *param); static void parse_command(const char *cmd, const char *param); -static void -parse_line(char *line); - void build_stream_name(int type); -- cgit v1.2.3 From a5d12d1264e65c213b2739cb2ae24099c938cff6 Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Thu, 14 May 2009 12:02:01 +0200 Subject: added var_is() function --- uzbl.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/uzbl.c b/uzbl.c index 2b0d958..5a1203b 100644 --- a/uzbl.c +++ b/uzbl.c @@ -702,27 +702,37 @@ set_proxy_url() { return; } +static gboolean +var_is(const char *x, const char *y) { + gboolean ret = FALSE; + + if(!strcmp(x, y)) + ret = TRUE; + + return ret; +} + static gboolean set_var_value(gchar *name, gchar *val) { void **p = NULL; char *endp = NULL; if( (p = g_hash_table_lookup(uzbl.comm.proto_var, name)) ) { - if(!strcmp(name, "status_message") - || !strcmp(name, "status_background") - || !strcmp(name, "status_format")) { + if(var_is("status_message", name) + || var_is("status_background", name) + || var_is("status_format", name)) { if(*p) free(*p); *p = g_strdup(val); update_title(); } - else if(!strcmp(name, "uri")) { + else if(var_is("uri", name)) { if(*p) free(*p); *p = g_strdup(val); load_uri(uzbl.gui.web_view, (const gchar*)*p); } - else if(!strcmp(name, "proxy_url")) { + else if(var_is("proxy_url", name)) { if(*p) free(*p); *p = g_strdup(val); @@ -732,7 +742,7 @@ set_var_value(gchar *name, gchar *val) { else { *p = (int)strtoul(val, &endp, 10); - if(!strcmp(name, "show_status")) { + if(var_is("show_status", name)) { cmd_set_status(); } } -- cgit v1.2.3 From 7c4012caa42539572909082d55cc565fe308b28f Mon Sep 17 00:00:00 2001 From: DuClare Date: Thu, 14 May 2009 14:02:33 +0300 Subject: Made CMD case insensitive --- uzbl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uzbl.c b/uzbl.c index f13bdfb..a3782c1 100644 --- a/uzbl.c +++ b/uzbl.c @@ -686,7 +686,7 @@ setup_regex() { G_REGEX_OPTIMIZE, 0, &err); uzbl.comm.bind_regex = g_regex_new("^[Bb][a-zA-Z]*\\s+?(.*[^ ])\\s*?=\\s*([a-z][^\\n].+)$", G_REGEX_UNGREEDY|G_REGEX_OPTIMIZE, 0, &err); - uzbl.comm.cmd_regex = g_regex_new("^CMD\\s+([^ \\n]+)\\s*([^\\n]*)?$", + uzbl.comm.cmd_regex = g_regex_new("^[Cc][a-zA-Z]*\\s+([^ \\n]+)\\s*([^\\n]*)?$", G_REGEX_OPTIMIZE, 0, &err); } @@ -811,7 +811,7 @@ parse_cmd_line(char *ctl_line) { printf("Error in command: %s\n", tokens[0]); } /* CMD command */ - else if(ctl_line[0] == 'C') { + else if(ctl_line[0] == 'C' || ctl_line[0] == 'c') { tokens = g_regex_split(uzbl.comm.cmd_regex, ctl_line, 0); if(tokens[0][0] == 0) { parse_command(tokens[1], tokens[2]); -- cgit v1.2.3 From 6aa99a6a27aec94e28b1000198eb572a7a4a97e8 Mon Sep 17 00:00:00 2001 From: DuClare Date: Thu, 14 May 2009 15:47:39 +0300 Subject: Added functionality for (re)setting fifo_dir. --- uzbl.c | 40 ++++++++++++++++++++++++++++++---------- uzbl.h | 7 +++++-- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/uzbl.c b/uzbl.c index a3782c1..58f8add 100644 --- a/uzbl.c +++ b/uzbl.c @@ -74,6 +74,7 @@ const struct { { "history_handler", (void *)&uzbl.behave.history_handler }, { "download_handler", (void *)&uzbl.behave.download_handler }, { "cookie_handler", (void *)&uzbl.behave.cookie_handler }, + { "fifo_dir", (void *)&uzbl.behave.fifo_dir }, { "proxy_url", (void *)&uzbl.net.proxy_url }, // TODO: write cmd handlers for the following { "useragent", (void *)&uzbl.net.useragent }, @@ -762,7 +763,13 @@ set_var_value(gchar *name, gchar *val) { free(*p); *p = g_strdup(val); set_proxy_url(); - } + } + else if(var_is("fifo_dir", name)) { + if(*p) + free(*p); + *p = g_strdup(val); + set_fifo_dir(); + } /* variables that take int values */ else { *p = (int)strtoul(val, &endp, 10); @@ -831,6 +838,25 @@ parse_cmd_line(char *ctl_line) { return; } +static void +set_fifo_dir() { + if (uzbl.comm.fifo_path) { + if (file_exists(uzbl.comm.fifo_path)) { + unlink(uzbl.comm.fifo_path); + printf("set_fifo_dir: removed old fifo at %s\n", uzbl.comm.fifo_path); + } + g_free(uzbl.comm.fifo_path); + uzbl.comm.fifo_path = NULL; + } + + if (!strcmp(uzbl.behave.fifo_dir, " ")) { /* set to space to unset */ + g_free(uzbl.behave.fifo_dir); + uzbl.behave.fifo_dir = NULL; + return; + } + + create_fifo(); +} void build_stream_name(int type) { @@ -841,16 +867,10 @@ build_stream_name(int type) { xwin_str = itos((int)uzbl.xwin); switch(type) { case FIFO: - if (b->fifo_dir) { - sprintf (uzbl.comm.fifo_path, "%s/uzbl_fifo_%s", - b->fifo_dir, - s->instance_name ? s->instance_name : xwin_str); - } else { - sprintf (uzbl.comm.fifo_path, "/tmp/uzbl_fifo_%s", - s->instance_name ? s->instance_name : xwin_str); - } + uzbl.comm.fifo_path = g_strdup_printf + ("%s/uzbl_fifo_%s", b->fifo_dir, + s->instance_name ? s->instance_name : xwin_str); break; - case SOCKET: if (b->socket_dir) { sprintf (uzbl.comm.socket_path, "%s/uzbl_socket_%s", diff --git a/uzbl.h b/uzbl.h index d2dbcf9..2fb27a7 100644 --- a/uzbl.h +++ b/uzbl.h @@ -57,8 +57,8 @@ typedef struct { /* external communication*/ enum { FIFO, SOCKET}; typedef struct { - char fifo_path[64]; - char socket_path[108]; + gchar *fifo_path; + gchar *socket_path; /* stores (key)"variable name" -> (value)"pointer to this var*/ GHashTable *proto_var; /* command parsing regexes */ @@ -232,6 +232,9 @@ build_stream_name(int type); static void control_fifo(GIOChannel *gio, GIOCondition condition); +static void +set_fifo_dir(); + static void create_fifo(); -- cgit v1.2.3 From 0698662378c59c7f20ec66e08e1975b410d03bc9 Mon Sep 17 00:00:00 2001 From: DuClare Date: Thu, 14 May 2009 19:17:02 +0300 Subject: Use g_warning rather than g_error when settin up a fifo --- uzbl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/uzbl.c b/uzbl.c index 58f8add..3e74749 100644 --- a/uzbl.c +++ b/uzbl.c @@ -917,22 +917,22 @@ create_fifo() { build_stream_name(FIFO); if (file_exists(uzbl.comm.fifo_path)) { - g_error ("Fifo: Error when creating %s: File exists\n", uzbl.comm.fifo_path); + g_warning ("Fifo: Error when creating %s: File exists\n", uzbl.comm.fifo_path); return; } if (mkfifo (uzbl.comm.fifo_path, 0666) == -1) { - g_error ("Fifo: Error when creating %s: %s\n", uzbl.comm.fifo_path, strerror(errno)); + g_warning ("Fifo: Error when creating %s: %s\n", uzbl.comm.fifo_path, strerror(errno)); } else { // we don't really need to write to the file, but if we open the file as 'r' we will block here, waiting for a writer to open the file. chan = g_io_channel_new_file((gchar *) uzbl.comm.fifo_path, "r+", &error); if (chan) { if (!g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_fifo, NULL)) { - g_error ("Fifo: could not add watch on %s\n", uzbl.comm.fifo_path); + g_warning ("Fifo: could not add watch on %s\n", uzbl.comm.fifo_path); } else { printf ("Fifo: created successfully as %s\n", uzbl.comm.fifo_path); } } else { - g_error ("Fifo: Error while opening: %s\n", error->message); + g_warning ("Fifo: Error while opening: %s\n", error->message); } } return; -- cgit v1.2.3 From c151fc6cbfe2cec611f51112d408de91374bc6bb Mon Sep 17 00:00:00 2001 From: DuClare Date: Thu, 14 May 2009 19:36:02 +0300 Subject: Merge set_fifo_dir with create_fifo and rename to init_fifo --- uzbl.c | 45 ++++++++++++++++++++------------------------- uzbl.h | 5 +---- 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/uzbl.c b/uzbl.c index 3e74749..a4d5c9d 100644 --- a/uzbl.c +++ b/uzbl.c @@ -768,7 +768,7 @@ set_var_value(gchar *name, gchar *val) { if(*p) free(*p); *p = g_strdup(val); - set_fifo_dir(); + init_fifo(); } /* variables that take int values */ else { @@ -782,7 +782,6 @@ set_var_value(gchar *name, gchar *val) { return TRUE; } - static void parse_cmd_line(char *ctl_line) { gchar **tokens; @@ -838,26 +837,6 @@ parse_cmd_line(char *ctl_line) { return; } -static void -set_fifo_dir() { - if (uzbl.comm.fifo_path) { - if (file_exists(uzbl.comm.fifo_path)) { - unlink(uzbl.comm.fifo_path); - printf("set_fifo_dir: removed old fifo at %s\n", uzbl.comm.fifo_path); - } - g_free(uzbl.comm.fifo_path); - uzbl.comm.fifo_path = NULL; - } - - if (!strcmp(uzbl.behave.fifo_dir, " ")) { /* set to space to unset */ - g_free(uzbl.behave.fifo_dir); - uzbl.behave.fifo_dir = NULL; - return; - } - - create_fifo(); -} - void build_stream_name(int type) { char *xwin_str; @@ -911,10 +890,27 @@ control_fifo(GIOChannel *gio, GIOCondition condition) { } static void -create_fifo() { +init_fifo() { GIOChannel *chan = NULL; GError *error = NULL; + if (uzbl.comm.fifo_path) { /* get rid of the old fifo if one exists */ + if (file_exists(uzbl.comm.fifo_path)) { + if (unlink(uzbl.comm.fifo_path) == -1) { + g_warning ("Fifo: Ran't unlink old fifo at %s\n", uzbl.comm.fifo_path); + return; + } else printf ("Fifo: Removed old fifo at %s\n", uzbl.comm.fifo_path); + } + g_free(uzbl.comm.fifo_path); + uzbl.comm.fifo_path = NULL; + } + + if (!strcmp(uzbl.behave.fifo_dir, " ")) { /* space unsets the variable */ + g_free(uzbl.behave.fifo_dir); + uzbl.behave.fifo_dir = NULL; + return; /* variable was unset, so don't procceed to create a new fifo */ + } + build_stream_name(FIFO); if (file_exists(uzbl.comm.fifo_path)) { g_warning ("Fifo: Error when creating %s: File exists\n", uzbl.comm.fifo_path); @@ -938,7 +934,6 @@ create_fifo() { return; } - static gboolean control_stdin(GIOChannel *gio, GIOCondition condition) { gchar *ctl_line = NULL; @@ -1580,7 +1575,7 @@ main (int argc, char* argv[]) { make_var_to_name_hash(); create_stdin(); if (uzbl.behave.fifo_dir) - create_fifo (); + init_fifo (); if (uzbl.behave.socket_dir) create_socket (); diff --git a/uzbl.h b/uzbl.h index 2fb27a7..80ec9b2 100644 --- a/uzbl.h +++ b/uzbl.h @@ -233,10 +233,7 @@ static void control_fifo(GIOChannel *gio, GIOCondition condition); static void -set_fifo_dir(); - -static void -create_fifo(); +init_fifo(); static gboolean control_stdin(GIOChannel *gio, GIOCondition condition); -- cgit v1.2.3 From 44ec7396369ae42cfbe056f084318f9e2f2f3016 Mon Sep 17 00:00:00 2001 From: DuClare Date: Thu, 14 May 2009 21:57:11 +0300 Subject: Rename create_socket to init_socket, refactor init_* --- uzbl.c | 161 +++++++++++++++++++++++++++++++++-------------------------------- uzbl.h | 12 ++--- 2 files changed, 88 insertions(+), 85 deletions(-) diff --git a/uzbl.c b/uzbl.c index a4d5c9d..e2ed969 100644 --- a/uzbl.c +++ b/uzbl.c @@ -75,6 +75,7 @@ const struct { { "download_handler", (void *)&uzbl.behave.download_handler }, { "cookie_handler", (void *)&uzbl.behave.cookie_handler }, { "fifo_dir", (void *)&uzbl.behave.fifo_dir }, + { "socket_dir", (void *)&uzbl.behave.socket_dir }, { "proxy_url", (void *)&uzbl.net.proxy_url }, // TODO: write cmd handlers for the following { "useragent", (void *)&uzbl.net.useragent }, @@ -765,10 +766,12 @@ set_var_value(gchar *name, gchar *val) { set_proxy_url(); } else if(var_is("fifo_dir", name)) { - if(*p) - free(*p); - *p = g_strdup(val); - init_fifo(); + if(*p) free(*p); + *p = init_fifo(g_strdup(val)); + } + else if(var_is("socket_dir", name)) { + if(*p) free(*p); + *p = init_socket(g_strdup(val)); } /* variables that take int values */ else { @@ -837,33 +840,24 @@ parse_cmd_line(char *ctl_line) { return; } -void -build_stream_name(int type) { +static gchar* +build_stream_name(int type, const gchar* dir) { char *xwin_str; State *s = &uzbl.state; - Behaviour *b = &uzbl.behave; + gchar *str; xwin_str = itos((int)uzbl.xwin); - switch(type) { - case FIFO: - uzbl.comm.fifo_path = g_strdup_printf - ("%s/uzbl_fifo_%s", b->fifo_dir, - s->instance_name ? s->instance_name : xwin_str); - break; - case SOCKET: - if (b->socket_dir) { - sprintf (uzbl.comm.socket_path, "%s/uzbl_socket_%s", - b->socket_dir, - s->instance_name ? s->instance_name : xwin_str); - } else { - sprintf (uzbl.comm.socket_path, "/tmp/uzbl_socket_%s", - s->instance_name ? s->instance_name : xwin_str); - } - break; - default: - break; + if (type == FIFO) { + str = g_strdup_printf + ("%s/uzbl_fifo_%s", dir, + s->instance_name ? s->instance_name : xwin_str); + } else if (type == SOCKET) { + str = g_strdup_printf + ("%s/uzbl_socket_%s", dir, + s->instance_name ? s->instance_name : xwin_str ); } g_free(xwin_str); + return str; } static void @@ -889,49 +883,42 @@ control_fifo(GIOChannel *gio, GIOCondition condition) { return; } -static void -init_fifo() { - GIOChannel *chan = NULL; - GError *error = NULL; - +static gchar* +init_fifo(gchar *dir) { /* return dir or, on error, free dir and return NULL */ if (uzbl.comm.fifo_path) { /* get rid of the old fifo if one exists */ - if (file_exists(uzbl.comm.fifo_path)) { - if (unlink(uzbl.comm.fifo_path) == -1) { - g_warning ("Fifo: Ran't unlink old fifo at %s\n", uzbl.comm.fifo_path); - return; - } else printf ("Fifo: Removed old fifo at %s\n", uzbl.comm.fifo_path); - } + if (unlink(uzbl.comm.fifo_path) == -1) + g_warning ("Fifo: Can't unlink old fifo at %s\n", uzbl.comm.fifo_path); g_free(uzbl.comm.fifo_path); uzbl.comm.fifo_path = NULL; } - if (!strcmp(uzbl.behave.fifo_dir, " ")) { /* space unsets the variable */ - g_free(uzbl.behave.fifo_dir); - uzbl.behave.fifo_dir = NULL; - return; /* variable was unset, so don't procceed to create a new fifo */ + if (!strcmp(dir, " ")) { /* space unsets the variable */ + g_free(dir); + return NULL; } - build_stream_name(FIFO); - if (file_exists(uzbl.comm.fifo_path)) { - g_warning ("Fifo: Error when creating %s: File exists\n", uzbl.comm.fifo_path); - return; - } - if (mkfifo (uzbl.comm.fifo_path, 0666) == -1) { - g_warning ("Fifo: Error when creating %s: %s\n", uzbl.comm.fifo_path, strerror(errno)); - } else { - // we don't really need to write to the file, but if we open the file as 'r' we will block here, waiting for a writer to open the file. - chan = g_io_channel_new_file((gchar *) uzbl.comm.fifo_path, "r+", &error); - if (chan) { - if (!g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_fifo, NULL)) { - g_warning ("Fifo: could not add watch on %s\n", uzbl.comm.fifo_path); - } else { - printf ("Fifo: created successfully as %s\n", uzbl.comm.fifo_path); - } - } else { - g_warning ("Fifo: Error while opening: %s\n", error->message); - } - } - return; + GIOChannel *chan = NULL; + GError *error = NULL; + gchar *path = build_stream_name(FIFO, dir); + + if (!file_exists(path)) { + if (mkfifo (path, 0666) == 0) { + // we don't really need to write to the file, but if we open the file as 'r' we will block here, waiting for a writer to open the file. + chan = g_io_channel_new_file(path, "r+", &error); + if (chan) { + if (g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_fifo, NULL)) { + printf ("init_fifo: created successfully as %s\n", path); + uzbl.comm.fifo_path = path; + return dir; + } else g_warning ("init_fifo: could not add watch on %s\n", path); + } else g_warning ("init_fifo: can't open: %s\n", error->message); + } else g_warning ("init_fifo: can't create %s: %s\n", path, strerror(errno)); + } else g_warning ("init_fifo: can't create %s: file exists\n", path); + + /* if we got this far, there was an error; cleanup */ + g_free(path); + g_free(dir); + return NULL; } static gboolean @@ -1025,33 +1012,49 @@ control_socket(GIOChannel *chan) { g_free(ctl_line); return; -} +} + +static gchar* +init_socket(gchar *dir) { /* return dir or, on error, free dir and return NULL */ + if (uzbl.comm.socket_path) { /* remove an existing socket should one exist */ + if (unlink(uzbl.comm.socket_path) == -1) + g_warning ("init_socket: couldn't unlink socket at %s\n", uzbl.comm.socket_path); + g_free(uzbl.comm.socket_path); + uzbl.comm.socket_path = NULL; + } + + if (!strcmp(dir, " ")) { + g_free(dir); + return NULL; + } -static void -create_socket() { GIOChannel *chan = NULL; int sock, len; struct sockaddr_un local; - - build_stream_name(SOCKET); + gchar *path = build_stream_name(SOCKET, dir); + sock = socket (AF_UNIX, SOCK_STREAM, 0); local.sun_family = AF_UNIX; - strcpy (local.sun_path, uzbl.comm.socket_path); + strcpy (local.sun_path, path); unlink (local.sun_path); len = strlen (local.sun_path) + sizeof (local.sun_family); - bind (sock, (struct sockaddr *) &local, len); - - if (errno == -1) { - printf ("Socket: Could not open in %s: %s\n", uzbl.comm.socket_path, strerror(errno)); - } else { - printf ("Socket: Opened in %s\n", uzbl.comm.socket_path); + if (bind (sock, (struct sockaddr *) &local, len) != -1) { + printf ("init_socket: opened in %s\n", path); listen (sock, 5); - if( (chan = g_io_channel_unix_new(sock)) ) + if( (chan = g_io_channel_unix_new(sock)) ) { g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_socket, chan); - } + uzbl.comm.socket_path = path; + return dir; + } + } else g_warning ("init_socket: could not open in %s: %s\n", path, strerror(errno)); + + /* if we got this far, there was an error; cleanup */ + g_free(path); + g_free(dir); + return NULL; } static void @@ -1574,10 +1577,10 @@ main (int argc, char* argv[]) { make_var_to_name_hash(); create_stdin(); - if (uzbl.behave.fifo_dir) - init_fifo (); - if (uzbl.behave.socket_dir) - create_socket (); + /*if (uzbl.behave.fifo_dir) + init_fifo ();*/ + /*if (uzbl.behave.socket_dir) + init_socket ();*/ gtk_main (); clean_up(); diff --git a/uzbl.h b/uzbl.h index 80ec9b2..6749994 100644 --- a/uzbl.h +++ b/uzbl.h @@ -226,14 +226,14 @@ spawn(WebKitWebView *web_view, const char *param); static void parse_command(const char *cmd, const char *param); -void -build_stream_name(int type); +static gchar* +build_stream_name(int type, const gchar *dir); static void control_fifo(GIOChannel *gio, GIOCondition condition); -static void -init_fifo(); +static gchar* +init_fifo(gchar *dir); static gboolean control_stdin(GIOChannel *gio, GIOCondition condition); @@ -241,8 +241,8 @@ control_stdin(GIOChannel *gio, GIOCondition condition); static void create_stdin(); -static void -create_socket(); +static gchar* +init_socket(gchar *dir); static void control_socket(GIOChannel *chan); -- cgit v1.2.3 From 4edb7150f9557e064b7e3221b9d59adc9b2bfeb8 Mon Sep 17 00:00:00 2001 From: DuClare Date: Thu, 14 May 2009 22:40:04 +0300 Subject: Added SET handlers for max_conns and max_conns_host --- uzbl.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/uzbl.c b/uzbl.c index e2ed969..35efafa 100644 --- a/uzbl.c +++ b/uzbl.c @@ -77,10 +77,10 @@ const struct { { "fifo_dir", (void *)&uzbl.behave.fifo_dir }, { "socket_dir", (void *)&uzbl.behave.socket_dir }, { "proxy_url", (void *)&uzbl.net.proxy_url }, - // TODO: write cmd handlers for the following - { "useragent", (void *)&uzbl.net.useragent }, { "max_conns", (void *)&uzbl.net.max_conns }, { "max_conns_host", (void *)&uzbl.net.max_conns_host }, + // TODO: write cmd handlers for the following + { "useragent", (void *)&uzbl.net.useragent }, { "http_debug", (void *)&uzbl.behave.http_debug }, { NULL, NULL } }, *n2v_p = var_name_to_ptr; @@ -780,6 +780,14 @@ set_var_value(gchar *name, gchar *val) { if(var_is("show_status", name)) { cmd_set_status(); } + else if (var_is("max_conns", name)) { + g_object_set(G_OBJECT(uzbl.net.soup_session), + SOUP_SESSION_MAX_CONNS, uzbl.net.max_conns, NULL); + } + else if (var_is("max_conns_host", name)) { + g_object_set(G_OBJECT(uzbl.net.soup_session), + SOUP_SESSION_MAX_CONNS_PER_HOST, uzbl.net.max_conns_host, NULL); + } } } return TRUE; -- cgit v1.2.3 From 7ffea9d233f35b29ee825904fe0e0cc11ee623e4 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Thu, 14 May 2009 22:21:26 +0200 Subject: todo updates --- TODO | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/TODO b/TODO index 1191626..2dda70b 100644 --- a/TODO +++ b/TODO @@ -50,6 +50,11 @@ status bar -> str_replace(all vars) -> pango markup thingie +* config: check in the default place (XDG_CONFIG_HOME/..) for a config file, and if needed, do file reading (interpret line by line). not ini-based. +* readd the --config flag to allow entering the same commands either through the file/stdin/fifo/socket + + + SOMEDAY: check if we can make the settings loading less hard coded. eg( keep a list of all settings, and for each one, try to load it) figure out caching with webkit and in general how we can speed up everything -- cgit v1.2.3 From 8a7a9a8c47711c1bfa33ffc2e38deb3e6ae6b5be Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Thu, 14 May 2009 22:35:26 +0200 Subject: todo updates --- TODO | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TODO b/TODO index 2dda70b..0b11dce 100644 --- a/TODO +++ b/TODO @@ -52,7 +52,7 @@ status bar -> str_replace(all vars) -> pango markup thingie * config: check in the default place (XDG_CONFIG_HOME/..) for a config file, and if needed, do file reading (interpret line by line). not ini-based. * readd the --config flag to allow entering the same commands either through the file/stdin/fifo/socket - +* check for real command name, not just the first letter. SOMEDAY: -- cgit v1.2.3 From d5f76f3eaade2e29a4f1541ab539357651c104b3 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Thu, 14 May 2009 22:56:25 +0200 Subject: better name for resetting to command mode --- uzbl.c | 6 +++--- uzbl.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/uzbl.c b/uzbl.c index e2ed969..4262fbe 100644 --- a/uzbl.c +++ b/uzbl.c @@ -301,7 +301,7 @@ load_commit_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data) { free (uzbl.state.uri); GString* newuri = g_string_new (webkit_web_frame_get_uri (frame)); uzbl.state.uri = g_string_free (newuri, FALSE); - if ((!uzbl.behave.never_reset_mode) && (uzbl.behave.insert_mode)) { + if (uzbl.behave.reset_command_mode && uzbl.behave.insert_mode) { uzbl.behave.insert_mode = uzbl.behave.always_insert_mode; update_title(); } @@ -1351,7 +1351,7 @@ settings_init () { b->show_status = g_key_file_get_boolean (config, "behavior", "show_status", NULL); b->modkey = g_key_file_get_value (config, "behavior", "modkey", NULL); b->status_top = g_key_file_get_boolean (config, "behavior", "status_top", NULL); - b->never_reset_mode = g_key_file_get_boolean (config, "behavior", "never_reset_mode", NULL); + b->reset_command_mode = g_key_file_get_boolean (config, "behavior", "reset_command_mode", NULL); b->status_format = g_key_file_get_string (config, "behavior", "status_format", NULL); b->status_background = g_key_file_get_string (config, "behavior", "status_background", NULL); if (! b->fifo_dir) @@ -1367,7 +1367,7 @@ settings_init () { printf ("Fifo directory: %s\n", (b->fifo_dir ? b->fifo_dir : "disabled")); printf ("Socket directory: %s\n", (b->socket_dir ? b->socket_dir : "disabled")); printf ("Always insert mode: %s\n", (b->always_insert_mode ? "TRUE" : "FALSE")); - printf ("Don't reset mode: %s\n", (b->never_reset_mode ? "TRUE" : "FALSE")); + printf ("Reset mode: %s\n" , (b->reset_command_mode ? "TRUE" : "FALSE")); printf ("Show status: %s\n", (b->show_status ? "TRUE" : "FALSE")); printf ("Status top: %s\n", (b->status_top ? "TRUE" : "FALSE")); printf ("Modkey: %s\n", (b->modkey ? b->modkey : "disabled")); diff --git a/uzbl.h b/uzbl.h index 6749994..1da04cc 100644 --- a/uzbl.h +++ b/uzbl.h @@ -108,7 +108,7 @@ typedef struct { gboolean show_status; gboolean insert_mode; gboolean status_top; - gboolean never_reset_mode; + gboolean reset_command_mode; gchar* modkey; guint modmask; guint http_debug; -- cgit v1.2.3 From 4482ee0af3813938b437e8b54c2a13267fc955cf Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Thu, 14 May 2009 23:11:51 +0200 Subject: import whats useful from duclares sample stuff --- examples/duclare/clipboard.sh | 13 -------- examples/duclare/session.sh | 44 ------------------------- examples/duclare/uzbl.conf | 75 ------------------------------------------- examples/scripts/clipboard.sh | 15 +++++++++ examples/scripts/session.sh | 42 ++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 132 deletions(-) delete mode 100755 examples/duclare/clipboard.sh delete mode 100755 examples/duclare/session.sh delete mode 100644 examples/duclare/uzbl.conf create mode 100755 examples/scripts/clipboard.sh create mode 100755 examples/scripts/session.sh diff --git a/examples/duclare/clipboard.sh b/examples/duclare/clipboard.sh deleted file mode 100755 index a2b3717..0000000 --- a/examples/duclare/clipboard.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -fifo="$5" -action="$1" -url="$7" -selection=$(xclip -o) - -case $action in - "yank" ) echo -n "$url" | xclip;; - "goto" ) echo "uri $selection" > "$fifo";; - * ) echo "clipboard.sh: invalid action";; -esac - diff --git a/examples/duclare/session.sh b/examples/duclare/session.sh deleted file mode 100755 index 4dd4a39..0000000 --- a/examples/duclare/session.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -# Simple session manager for uzbl. When called with "endsession" as the -# argument, it'lla empty the sessionfile, look for fifos in $fifodir and -# instruct each of them to store their current url in $sessionfile and -# terminate themselves. Run with "launch" as the argument and an instance of -# uzbl will be launched for each stored url. "endinstance" is used internally -# and doesn't need to be called manually at any point. - - -scriptfile=~/.uzbl/session.sh # this script -sessionfile=~/.uzbl/session # the file in which the "session" (i.e. urls) are stored - -# a simple script that calls the executable with --config and args -launcher=~/.uzbl/launch - -fifodir=/tmp # remember to change this if you instructed uzbl to put its fifos elsewhere -thisfifo="$5" -act="$1" -url="$7" - -case $act in - "launch" ) - for url in $(cat $sessionfile); do - $launcher --uri "$url" & - done - exit 0;; - "endinstance" ) - if [ "$url" != "(null)" ]; then - echo "$url" >> $sessionfile; echo "exit" > "$thisfifo" - else - echo "exit" > "$thisfifo" - fi;; - "endsession" ) - echo -n "" > "$sessionfile" - for fifo in $fifodir/uzbl_fifo_*; do - if [ "$fifo" != "$thisfifo" ]; then - echo "spawn $scriptfile endinstance" > "$fifo" - fi - done - echo "spawn $scriptfile endinstance" > "$thisfifo";; - * ) echo "session manager: bad action";; -esac - diff --git a/examples/duclare/uzbl.conf b/examples/duclare/uzbl.conf deleted file mode 100644 index 1ce5944..0000000 --- a/examples/duclare/uzbl.conf +++ /dev/null @@ -1,75 +0,0 @@ - -# example uzbl config. in a real config, we should obey the xdg spec - -# all keys in the behavior group are optional. if not set, the corresponding behavior is disabed. -# bindings_internal denote keys to trigger actions internally in uzbl -# bindings_external denote keys to trigger scripts outside uzbl - -# keyboard behavior is vimstyle by default (all actions -> 1 key). set -# always_insert_mode to always be in insert mode and disable going out of it. -# if you do this, make sure you've set a modkey so you can reach the actions -# from insert mode by combining them with the modkey - -[behavior] -history_handler = /home/duclare/.uzbl/history.sh -download_handler = ~/.uzbl/download.sh -cookie_handler = ~/.uzbl/cookie.sh -status_format = MODE [KEYCMD] LOAD_PROGRESSBAR URI NAME -fifo_dir = /tmp -socket_dir = /tmp -always_insert_mode = 0 -modkey = Mod1 -show_status = 1 -status_top = 0 -never_reset_mode = 0 - -[bindings] -# scroll down/up/left/right -j = scroll_vert 40 -k = scroll_vert -40 -h = scroll_horz -20 -l = scroll_horz 20 -b = back -m = forward -s = stop -r = reload -R = reload_ign_cache -w = follow_link_new_window -+ = zoom_in -- = zoom_out -t = toggle_status -#hilight matches -/* = search %s -#jump to next -; = search -gh = uri http://www.uzbl.org -o_ = uri %s -:wiki _ = uri http://wiki.archlinux.org/index.php/Special:Search?search=%s&go=Go -ew_ = uri http://en.wikipedia.org/w/index.php?title=Special%3ASearch&search=%s&go=Go - -g_ = uri http://www.google.com/search?q=%s -i = insert_mode -B = spawn /home/duclare/.uzbl/insert_bookmark.sh -u = spawn /home/duclare/.uzbl/load_url_from_history.sh -U = spawn /home/duclare/.uzbl/load_url_from_bookmarks.sh -y = spawn /home/duclare/.uzbl/clipboard.sh yank -p = spawn /home/duclare/.uzbl/clipboard.sh goto -W = spawn /home/duclare/.uzbl/launch -ZZ = exit -:q = spawn /home/duclare/.uzbl/session.sh endsession - -# Keyboard based link following: work in progress! No C DOM bindings yet, no click() event for hyperlinks so no referrer set..Quite basic but does the job for now... -# Vimperator-like hints, except that you can't type text to narrow on targets. You can still the text of a link from the beginning, and it'll activate as soon as the word is unique -f* = script var uzblid = 'uzbl_link_hint'; var uzbldivid = uzblid+'_div_container'; var links = document.links; try { HTMLElement.prototype.click = function () {if (typeof this.onclick == 'function') this.onclick({type: 'click'}); } } catch (e) {} function removeOldHints() { var elements = document.getElementById(uzbldivid); if( elements) elements.parentNode.removeChild(elements); } function keyPressHandler(e) {var kC = (window.event) ? event.keyCode : e.keyCode; var Esc = (window.event) ? 27 : e.DOM_VK_ESCAPE; if(kC==Esc) removeOldHints();} function isVisible(obj) { if (obj == document) return true; if (!obj) return false; if (!obj.parentNode) return false; if (obj.style) { if (obj.style.display == 'none') return false; if (obj.style.visibility == 'hidden') return false; } return isVisible(obj.parentNode); } function elementPosition(el) { var up = el.offsetTop; var left = el.offsetLeft; var width = el.offsetWidth; var height = el.offsetHeight; while(el.offsetParent) { el = el.offsetParent; up += el.offsetTop; left += el.offsetLeft; } return [up,left,width,height]; } function elementInViewport(el) { offset = elementPosition(el); var up = offset[0]; var left = offset[1]; var width = offset[2]; var height = offset[3]; return (up < (window.pageYOffset + window.innerHeight) && left < (window.pageXOffset + window.innerWidth) && (up + height) > window.pageYOffset && (left + width) > window.pageXOffset); } function generateHints(items, l) { var hintdiv = document.createElement('div'); hintdiv.setAttribute('id', uzbldivid); for (var i=0; i < items.length; i++) { var nr = items[i]; var li = links[nr]; var pos = elementPosition(li); var hint = document.createElement('div'); hint.setAttribute('name',uzblid); var n = (nr+'').length; for (n; n0) { hint.style.left=pos[1]+(img[0].width/2)+'px'; } hint.style.textDecoration='none'; hint.style.webkitBorderRadius='6px'; hint.style.webkitTransform='scale(0.9) rotate(0deg) translate(-6px,-5px)'; hintdiv.appendChild(hint); } document.body.appendChild(hintdiv); } function clickLink(item) { removeOldHints(); if (item) { item.click(); window.location = item.href; } } function followLink(follow) { document.body.setAttribute('onkeyup', 'keyPressHandler(event)'); var s = follow.split(''); var linktexts = [[],[]]; for (var i=0; i < links.length; i++) { var li = links[i]; if (isVisible(li) && elementInViewport(li)) { linktexts[0].push(i); linktexts[1].push(li.innerText); } } var leftovers = []; var nrlength = (linktexts[0][linktexts[0].length-1]+'').length; var linknr = parseInt(follow, 10); if (s.length == nrlength) { clickLink(links[linknr]); } else { for (var j=0; j < linktexts[0].length; j++) { var b = true; for (var k=0; k < s.length; k++) { b = (b && (linktexts[1][j].charAt(k)==s[k])); } if (b) { leftovers.push(linktexts[0][j]); } } if (leftovers.length == 1 && s.length >= nrlength) { clickLink(links[leftovers[0]]); } else if (!document.getElementById(uzbldivid)) { generateHints(linktexts[0], nrlength); } } } followLink('%s'); - -[network] -# to start a local socks server, do : ssh -fND localhost:8118 localhost -#proxy_server = http://127.0.0.1:8118 -#values 0-3 -http_debug = 0 -user-agent = uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) -# Example user agent containing everything: -#user-agent = Uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) (%sysname% %nodename% %kernrel% %kernver% %arch-system% [%arch-uzbl%]) (Commit %commit%) -max_conns = -max_conns_per_host = - diff --git a/examples/scripts/clipboard.sh b/examples/scripts/clipboard.sh new file mode 100755 index 0000000..c64b65c --- /dev/null +++ b/examples/scripts/clipboard.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# with this script you can store the current url in the clipboard, or go to the url which is stored in the clipboard. + +fifo="$5" +action="$1" +url="$7" +selection=$(xclip -o) + +case $action in + "yank" ) echo -n "$url" | xclip;; + "goto" ) echo "uri $selection" > "$fifo";; + * ) echo "clipboard.sh: invalid action";; +esac + diff --git a/examples/scripts/session.sh b/examples/scripts/session.sh new file mode 100755 index 0000000..5087af0 --- /dev/null +++ b/examples/scripts/session.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# Very simple session manager for uzbl. When called with "endsession" as the +# argument, it'lla empty the sessionfile, look for fifos in $fifodir and +# instruct each of them to store their current url in $sessionfile and +# terminate themselves. Run with "launch" as the argument and an instance of +# uzbl will be launched for each stored url. "endinstance" is used internally +# and doesn't need to be called manually at any point. + + +scriptfile=$XDG_CONFIG_HOME/uzbl/session.sh # this script +sessionfile=$XDG_DATA_HOME/uzbl/session # the file in which the "session" (i.e. urls) are stored +UZBL="uzbl" # add custom flags and whatever here. + +fifodir=/tmp # remember to change this if you instructed uzbl to put its fifos elsewhere +thisfifo="$5" +act="$1" +url="$7" + +case $act in + "launch" ) + for url in $(cat $sessionfile); do + $UZBL --uri "$url" & + done + exit 0;; + "endinstance" ) + if [ "$url" != "(null)" ]; then + echo "$url" >> $sessionfile; + fi + echo "exit" > "$thisfifo" + ;; + "endsession" ) + echo -n "" > "$sessionfile" + for fifo in $fifodir/uzbl_fifo_*; do + if [ "$fifo" != "$thisfifo" ]; then + echo "spawn $scriptfile endinstance" > "$fifo" + fi + done + echo "spawn $scriptfile endinstance" > "$thisfifo";; + * ) echo "session manager: bad action";; +esac + -- cgit v1.2.3 From dce02ced85cc6cbc04425facf3646d2df51f840b Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Thu, 14 May 2009 23:16:06 +0200 Subject: update authors file --- AUTHORS | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index ff39641..8a470d0 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,12 +1,13 @@ Developers: - Dieter Plaetinck (Dieter@be) + Dieter Plaetinck (Dieter@be) Dusan Popovic (dusanx) - Michael Walker (Barrucadu) - Přemysl Hrubý, (anydot) + Michael Walker (Barrucadu) + Přemysl Hrubý, (anydot) + Robert Manea (robm) Contributors: - Robert Manea - Various improvements + (DuClare) - Various improvements Zane Ashby (HashBox) - Rewrote FIFO interface. Fixed various bugs. (sentientswitch) - Cleaned up code. Added some commands. Jan Kolkmeier (jouz) - scrolling, link following -- cgit v1.2.3 From 07d306ef509607510dda99d3197023b7c3d90d83 Mon Sep 17 00:00:00 2001 From: DuClare Date: Fri, 15 May 2009 00:39:56 +0300 Subject: Added SET handling for http_debug and fixed a bug wrt setting ints --- uzbl.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/uzbl.c b/uzbl.c index 35efafa..46cc22c 100644 --- a/uzbl.c +++ b/uzbl.c @@ -79,9 +79,9 @@ const struct { { "proxy_url", (void *)&uzbl.net.proxy_url }, { "max_conns", (void *)&uzbl.net.max_conns }, { "max_conns_host", (void *)&uzbl.net.max_conns_host }, + { "http_debug", (void *)&uzbl.behave.http_debug }, // TODO: write cmd handlers for the following { "useragent", (void *)&uzbl.net.useragent }, - { "http_debug", (void *)&uzbl.behave.http_debug }, { NULL, NULL } }, *n2v_p = var_name_to_ptr; @@ -775,7 +775,8 @@ set_var_value(gchar *name, gchar *val) { } /* variables that take int values */ else { - *p = (int)strtoul(val, &endp, 10); + int *ip = p; + *ip = (int)strtoul(val, &endp, 10); if(var_is("show_status", name)) { cmd_set_status(); @@ -788,6 +789,16 @@ set_var_value(gchar *name, gchar *val) { g_object_set(G_OBJECT(uzbl.net.soup_session), SOUP_SESSION_MAX_CONNS_PER_HOST, uzbl.net.max_conns_host, NULL); } + else if (var_is("http_debug", name)) { + soup_session_remove_feature + (uzbl.net.soup_session, uzbl.net.soup_logger); + /* do we leak if this doesn't get freed? why does it occasionally crash if freed? */ + /*g_free(uzbl.net.soup_logger);*/ + + uzbl.net.soup_logger = soup_logger_new(uzbl.behave.http_debug, -1); + soup_session_add_feature(uzbl.net.soup_session, + SOUP_SESSION_FEATURE(uzbl.net.soup_logger)); + } } } return TRUE; -- cgit v1.2.3 From 00c500d2a90b99b15159b9107b7f262122dee202 Mon Sep 17 00:00:00 2001 From: DuClare Date: Fri, 15 May 2009 11:55:56 +0300 Subject: Cleanup. --- uzbl.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/uzbl.c b/uzbl.c index 282784e..5a4712c 100644 --- a/uzbl.c +++ b/uzbl.c @@ -727,12 +727,7 @@ set_proxy_url() { static gboolean var_is(const char *x, const char *y) { - gboolean ret = FALSE; - - if(!strcmp(x, y)) - ret = TRUE; - - return ret; + return (strcmp(x, y) == 0 ? TRUE : FALSE ); } static gboolean @@ -911,7 +906,7 @@ init_fifo(gchar *dir) { /* return dir or, on error, free dir and return NULL */ uzbl.comm.fifo_path = NULL; } - if (!strcmp(dir, " ")) { /* space unsets the variable */ + if (*dir == ' ') { /* space unsets the variable */ g_free(dir); return NULL; } @@ -1042,7 +1037,7 @@ init_socket(gchar *dir) { /* return dir or, on error, free dir and return NULL * uzbl.comm.socket_path = NULL; } - if (!strcmp(dir, " ")) { + if (*dir == ' ') { g_free(dir); return NULL; } -- cgit v1.2.3 From 8c0bb5bc66390906ba7c5e01b1e9d0eb17a87f7e Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Fri, 15 May 2009 11:00:56 +0200 Subject: pseudo commit --- uzbl.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/uzbl.c b/uzbl.c index 5a1203b..f534a6e 100644 --- a/uzbl.c +++ b/uzbl.c @@ -1343,8 +1343,6 @@ settings_init () { if (res) { b->http_debug = g_key_file_get_integer (config, "network", "http_debug", NULL); n->useragent = g_key_file_get_value (config, "network", "user-agent", NULL); - n->max_conns = g_key_file_get_integer (config, "network", "max_conns", NULL); - n->max_conns_host = g_key_file_get_integer (config, "network", "max_conns_per_host", NULL); } @@ -1385,13 +1383,6 @@ settings_init () { g_object_set(G_OBJECT(n->soup_session), SOUP_SESSION_USER_AGENT, n->useragent, NULL); } - if(n->max_conns >= 1){ - g_object_set(G_OBJECT(n->soup_session), SOUP_SESSION_MAX_CONNS, n->max_conns, NULL); - } - - if(n->max_conns_host >= 1){ - g_object_set(G_OBJECT(n->soup_session), SOUP_SESSION_MAX_CONNS_PER_HOST, n->max_conns_host, NULL); - } printf("Proxy configured: %s\n", n->proxy_url ? n->proxy_url : "none"); printf("HTTP logging level: %d\n", b->http_debug); -- cgit v1.2.3 From ec8973e07453baeee83fc7e8a229832acc872f47 Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Fri, 15 May 2009 11:48:35 +0200 Subject: added modkey and always_insert to cmd parser --- examples/configs/sampleconfig-pipe | 4 ++ uzbl.c | 128 +++++++++++++------------------------ 2 files changed, 50 insertions(+), 82 deletions(-) diff --git a/examples/configs/sampleconfig-pipe b/examples/configs/sampleconfig-pipe index 9fc4d52..c25db06 100644 --- a/examples/configs/sampleconfig-pipe +++ b/examples/configs/sampleconfig-pipe @@ -2,6 +2,10 @@ set show_status = 1 set status_background = #303030 set status_format = MODE [KEYCMD] LOAD_PROGRESSBAR URI NAME MSG +set modkey = Mod1 +set always_insert = 0 +#set proxy_url = http://127.0.0.1:8118 +set fifo_dir = /tmp # Key bindings bind j = scroll_vert 20 diff --git a/uzbl.c b/uzbl.c index 5a93d37..8bd952a 100644 --- a/uzbl.c +++ b/uzbl.c @@ -70,6 +70,8 @@ const struct { { "status_message", (void *)&uzbl.gui.sbar.msg }, { "show_status", (void *)&uzbl.behave.show_status }, { "insert_mode", (void *)&uzbl.behave.insert_mode }, + { "modkey" , (void *)&uzbl.behave.modkey }, + { "always_insert" , (void *)&uzbl.behave.always_insert_mode }, { "load_finish_handler",(void *)&uzbl.behave.load_finish_handler}, { "history_handler", (void *)&uzbl.behave.history_handler }, { "download_handler", (void *)&uzbl.behave.download_handler }, @@ -725,6 +727,34 @@ set_proxy_url() { return; } +static void +set_modkey() { + Behaviour *b = &uzbl.behave; + + if (!b->modkey) + b->modkey = ""; + + //POSSIBLE MODKEY VALUES (COMBINATIONS CAN BE USED) + gchar* modkeyup = g_utf8_strup (b->modkey, -1); + if (g_strrstr (modkeyup,"SHIFT") != NULL) b->modmask |= GDK_SHIFT_MASK; //the Shift key. + if (g_strrstr (modkeyup,"LOCK") != NULL) b->modmask |= GDK_LOCK_MASK; //a Lock key (depending on the modifier mapping of the X server this may either be CapsLock or ShiftLock). + if (g_strrstr (modkeyup,"CONTROL") != NULL) b->modmask |= GDK_CONTROL_MASK; //the Control key. + if (g_strrstr (modkeyup,"MOD1") != NULL) b->modmask |= GDK_MOD1_MASK; //the fourth modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier, but normally it is the Alt key). + if (g_strrstr (modkeyup,"MOD2") != NULL) b->modmask |= GDK_MOD2_MASK; //the fifth modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier). + if (g_strrstr (modkeyup,"MOD3") != NULL) b->modmask |= GDK_MOD3_MASK; //the sixth modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier). + if (g_strrstr (modkeyup,"MOD4") != NULL) b->modmask |= GDK_MOD4_MASK; //the seventh modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier). + if (g_strrstr (modkeyup,"MOD5") != NULL) b->modmask |= GDK_MOD5_MASK; //the eighth modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier). + if (g_strrstr (modkeyup,"BUTTON1") != NULL) b->modmask |= GDK_BUTTON1_MASK; //the first mouse button. + if (g_strrstr (modkeyup,"BUTTON2") != NULL) b->modmask |= GDK_BUTTON2_MASK; //the second mouse button. + if (g_strrstr (modkeyup,"BUTTON3") != NULL) b->modmask |= GDK_BUTTON3_MASK; //the third mouse button. + if (g_strrstr (modkeyup,"BUTTON4") != NULL) b->modmask |= GDK_BUTTON4_MASK; //the fourth mouse button. + if (g_strrstr (modkeyup,"BUTTON5") != NULL) b->modmask |= GDK_BUTTON5_MASK; //the fifth mouse button. + if (g_strrstr (modkeyup,"SUPER") != NULL) b->modmask |= GDK_SUPER_MASK; //the Super modifier. Since 2.10 + if (g_strrstr (modkeyup,"HYPER") != NULL) b->modmask |= GDK_HYPER_MASK; //the Hyper modifier. Since 2.10 + if (g_strrstr (modkeyup,"META") != NULL) b->modmask |= GDK_META_MASK; //the Meta modifier. Since 2.10 */ + g_free (modkeyup); +} + static gboolean var_is(const char *x, const char *y) { gboolean ret = FALSE; @@ -754,14 +784,12 @@ set_var_value(gchar *name, gchar *val) { update_title(); } else if(var_is("uri", name)) { - if(*p) - free(*p); + if(*p) free(*p); *p = g_strdup(val); load_uri(uzbl.gui.web_view, (const gchar*)*p); } else if(var_is("proxy_url", name)) { - if(*p) - free(*p); + if(*p) free(*p); *p = g_strdup(val); set_proxy_url(); } @@ -773,6 +801,11 @@ set_var_value(gchar *name, gchar *val) { if(*p) free(*p); *p = init_socket(g_strdup(val)); } + else if(var_is("modkey", name)) { + if(*p) free(*p); + *p = g_strdup(val); + set_modkey(); + } /* variables that take int values */ else { int *ip = p; @@ -781,6 +814,12 @@ set_var_value(gchar *name, gchar *val) { if(var_is("show_status", name)) { cmd_set_status(); } + else if(var_is("always_insert", name)) { + + uzbl.behave.insert_mode = + uzbl.behave.always_insert_mode ? TRUE : FALSE; + update_title(); + } else if (var_is("max_conns", name)) { g_object_set(G_OBJECT(uzbl.net.soup_session), SOUP_SESSION_MAX_CONNS, uzbl.net.max_conns, NULL); @@ -790,8 +829,10 @@ set_var_value(gchar *name, gchar *val) { SOUP_SESSION_MAX_CONNS_PER_HOST, uzbl.net.max_conns_host, NULL); } else if (var_is("http_debug", name)) { + //soup_session_remove_feature + // (uzbl.net.soup_session, uzbl.net.soup_logger); soup_session_remove_feature - (uzbl.net.soup_session, uzbl.net.soup_logger); + (uzbl.net.soup_session, SOUP_SESSION_FEATURE(uzbl.net.soup_logger)); /* do we leak if this doesn't get freed? why does it occasionally crash if freed? */ /*g_free(uzbl.net.soup_logger);*/ @@ -1309,7 +1350,6 @@ settings_init () { GKeyFile* config = NULL; gboolean res = FALSE; char *saveptr; - gchar** keys = NULL; State *s = &uzbl.state; Network *n = &uzbl.net; Behaviour *b = &uzbl.behave; @@ -1362,86 +1402,17 @@ settings_init () { } if (res) { - b->load_finish_handler= g_key_file_get_value (config, "behavior", "load_finish_handler",NULL); - b->history_handler = g_key_file_get_value (config, "behavior", "history_handler", NULL); - b->download_handler = g_key_file_get_value (config, "behavior", "download_handler", NULL); - b->cookie_handler = g_key_file_get_string (config, "behavior", "cookie_handler", NULL); - b->always_insert_mode = g_key_file_get_boolean (config, "behavior", "always_insert_mode", NULL); - b->show_status = g_key_file_get_boolean (config, "behavior", "show_status", NULL); - b->modkey = g_key_file_get_value (config, "behavior", "modkey", NULL); b->status_top = g_key_file_get_boolean (config, "behavior", "status_top", NULL); b->reset_command_mode = g_key_file_get_boolean (config, "behavior", "reset_command_mode", NULL); - b->status_format = g_key_file_get_string (config, "behavior", "status_format", NULL); - b->status_background = g_key_file_get_string (config, "behavior", "status_background", NULL); - if (! b->fifo_dir) - b->fifo_dir = g_key_file_get_value (config, "behavior", "fifo_dir", NULL); - if (! b->socket_dir) - b->socket_dir = g_key_file_get_value (config, "behavior", "socket_dir", NULL); - keys = g_key_file_get_keys (config, "bindings", NULL, NULL); } - printf ("History handler: %s\n", (b->history_handler ? b->history_handler : "disabled")); - printf ("Download manager: %s\n", (b->download_handler ? b->download_handler : "disabled")); - printf ("Cookie handler: %s\n", (b->cookie_handler ? b->cookie_handler : "disabled")); - printf ("Fifo directory: %s\n", (b->fifo_dir ? b->fifo_dir : "disabled")); - printf ("Socket directory: %s\n", (b->socket_dir ? b->socket_dir : "disabled")); - printf ("Always insert mode: %s\n", (b->always_insert_mode ? "TRUE" : "FALSE")); printf ("Reset mode: %s\n" , (b->reset_command_mode ? "TRUE" : "FALSE")); - printf ("Show status: %s\n", (b->show_status ? "TRUE" : "FALSE")); - printf ("Status top: %s\n", (b->status_top ? "TRUE" : "FALSE")); - printf ("Modkey: %s\n", (b->modkey ? b->modkey : "disabled")); - printf ("Status format: %s\n", (b->status_format ? b->status_format : "none")); - - if (!b->modkey) - b->modkey = ""; - - //POSSIBLE MODKEY VALUES (COMBINATIONS CAN BE USED) - gchar* modkeyup = g_utf8_strup (b->modkey, -1); - if (g_strrstr (modkeyup,"SHIFT") != NULL) b->modmask |= GDK_SHIFT_MASK; //the Shift key. - if (g_strrstr (modkeyup,"LOCK") != NULL) b->modmask |= GDK_LOCK_MASK; //a Lock key (depending on the modifier mapping of the X server this may either be CapsLock or ShiftLock). - if (g_strrstr (modkeyup,"CONTROL") != NULL) b->modmask |= GDK_CONTROL_MASK; //the Control key. - if (g_strrstr (modkeyup,"MOD1") != NULL) b->modmask |= GDK_MOD1_MASK; //the fourth modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier, but normally it is the Alt key). - if (g_strrstr (modkeyup,"MOD2") != NULL) b->modmask |= GDK_MOD2_MASK; //the fifth modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier). - if (g_strrstr (modkeyup,"MOD3") != NULL) b->modmask |= GDK_MOD3_MASK; //the sixth modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier). - if (g_strrstr (modkeyup,"MOD4") != NULL) b->modmask |= GDK_MOD4_MASK; //the seventh modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier). - if (g_strrstr (modkeyup,"MOD5") != NULL) b->modmask |= GDK_MOD5_MASK; //the eighth modifier key (it depends on the modifier mapping of the X server which key is interpreted as this modifier). - if (g_strrstr (modkeyup,"BUTTON1") != NULL) b->modmask |= GDK_BUTTON1_MASK; //the first mouse button. - if (g_strrstr (modkeyup,"BUTTON2") != NULL) b->modmask |= GDK_BUTTON2_MASK; //the second mouse button. - if (g_strrstr (modkeyup,"BUTTON3") != NULL) b->modmask |= GDK_BUTTON3_MASK; //the third mouse button. - if (g_strrstr (modkeyup,"BUTTON4") != NULL) b->modmask |= GDK_BUTTON4_MASK; //the fourth mouse button. - if (g_strrstr (modkeyup,"BUTTON5") != NULL) b->modmask |= GDK_BUTTON5_MASK; //the fifth mouse button. - if (g_strrstr (modkeyup,"SUPER") != NULL) b->modmask |= GDK_SUPER_MASK; //the Super modifier. Since 2.10 - if (g_strrstr (modkeyup,"HYPER") != NULL) b->modmask |= GDK_HYPER_MASK; //the Hyper modifier. Since 2.10 - if (g_strrstr (modkeyup,"META") != NULL) b->modmask |= GDK_META_MASK; //the Meta modifier. Since 2.10 */ - free (modkeyup); - - if (keys) { - int i; - for (i = 0; keys[i]; i++) { - gchar *value = g_key_file_get_string (config, "bindings", keys[i], NULL); - - add_binding(g_strstrip(keys[i]), value); - g_free(value); - } - - g_strfreev(keys); - } /* networking options */ if (res) { - b->http_debug = g_key_file_get_integer (config, "network", "http_debug", NULL); n->useragent = g_key_file_get_value (config, "network", "user-agent", NULL); } - - if(!(b->http_debug <= 3)){ - b->http_debug = 0; - fprintf(stderr, "Wrong http_debug level, ignoring.\n"); - } else if (b->http_debug > 0) { - n->soup_logger = soup_logger_new(b->http_debug, -1); - soup_session_add_feature(n->soup_session, SOUP_SESSION_FEATURE(n->soup_logger)); - } - if(n->useragent){ char* newagent = malloc(1024); @@ -1471,12 +1442,7 @@ settings_init () { g_object_set(G_OBJECT(n->soup_session), SOUP_SESSION_USER_AGENT, n->useragent, NULL); } - - printf("Proxy configured: %s\n", n->proxy_url ? n->proxy_url : "none"); - printf("HTTP logging level: %d\n", b->http_debug); printf("User-agent: %s\n", n->useragent? n->useragent : "default"); - printf("Maximum connections: %d\n", n->max_conns ? n->max_conns : 0); - printf("Maximum connections per host: %d\n", n->max_conns_host ? n->max_conns_host: 0); g_signal_connect(n->soup_session, "request-queued", G_CALLBACK(handle_cookies), NULL); } @@ -1541,8 +1507,6 @@ main (int argc, char* argv[]) { settings_init (); commands_hash (); - if (uzbl.behave.always_insert_mode) - uzbl.behave.insert_mode = TRUE; GtkWidget* vbox = gtk_vbox_new (FALSE, 0); if (uzbl.behave.status_top) -- cgit v1.2.3 From bac32a276e802b4d679c9006317b97e880fc7c7a Mon Sep 17 00:00:00 2001 From: DuClare Date: Fri, 15 May 2009 12:56:25 +0300 Subject: Added SET handling for modkey --- uzbl.c | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/uzbl.c b/uzbl.c index 5a4712c..896803e 100644 --- a/uzbl.c +++ b/uzbl.c @@ -80,11 +80,35 @@ const struct { { "max_conns", (void *)&uzbl.net.max_conns }, { "max_conns_host", (void *)&uzbl.net.max_conns_host }, { "http_debug", (void *)&uzbl.behave.http_debug }, + { "modkey", (void *)&uzbl.behave.modkey }, // TODO: write cmd handlers for the following { "useragent", (void *)&uzbl.net.useragent }, { NULL, NULL } }, *n2v_p = var_name_to_ptr; +const struct { + char *key; + guint mask; +} modkeys[] = { + { "SHIFT", GDK_SHIFT_MASK }, // shift + { "LOCK", GDK_LOCK_MASK }, // capslock or shiftlock, depending on xserver's modmappings + { "CONTROL", GDK_CONTROL_MASK }, // control + { "MOD1", GDK_MOD1_MASK }, // 4th mod - normally alt but depends on modmappings + { "MOD2", GDK_MOD2_MASK }, // 5th mod + { "MOD3", GDK_MOD3_MASK }, // 6th mod + { "MOD4", GDK_MOD4_MASK }, // 7th mod + { "MOD5", GDK_MOD5_MASK }, // 8th mod + { "BUTTON1", GDK_BUTTON1_MASK }, // 1st mouse button + { "BUTTON2", GDK_BUTTON2_MASK }, // 2nd mouse button + { "BUTTON3", GDK_BUTTON3_MASK }, // 3rd mouse button + { "BUTTON4", GDK_BUTTON4_MASK }, // 4th mouse button + { "BUTTON5", GDK_BUTTON5_MASK }, // 5th mouse button + { "SUPER", GDK_SUPER_MASK }, // super + { "HYPER", GDK_HYPER_MASK }, // hyper + { "META", GDK_META_MASK }, // meta + { NULL, NULL } +}; + /* construct a hash from the var_name_to_ptr array for quick access */ static void make_var_to_name_hash() { @@ -768,6 +792,16 @@ set_var_value(gchar *name, gchar *val) { if(*p) free(*p); *p = init_socket(g_strdup(val)); } + else if(var_is("modkey", name)) { + if(*p) free(*p); + int i; + *p = g_utf8_strup(val, -1); + uzbl.behave.modmask = 0; + for (i = 0; modkeys[i].key != NULL; i++) { + if (g_strrstr(*p, modkeys[i].key)) + uzbl.behave.modmask |= modkeys[i].mask; + } + } /* variables that take int values */ else { int *ip = p; @@ -1387,9 +1421,6 @@ settings_init () { printf ("Modkey: %s\n", (b->modkey ? b->modkey : "disabled")); printf ("Status format: %s\n", (b->status_format ? b->status_format : "none")); - if (!b->modkey) - b->modkey = ""; - //POSSIBLE MODKEY VALUES (COMBINATIONS CAN BE USED) gchar* modkeyup = g_utf8_strup (b->modkey, -1); if (g_strrstr (modkeyup,"SHIFT") != NULL) b->modmask |= GDK_SHIFT_MASK; //the Shift key. -- cgit v1.2.3 From 9f95fa5e9ab1781e5189e6d7568245366832c7a7 Mon Sep 17 00:00:00 2001 From: DuClare Date: Fri, 15 May 2009 13:03:08 +0300 Subject: set_var_value: suppress warnings from remove_feature and ip --- uzbl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uzbl.c b/uzbl.c index 896803e..93fbd97 100644 --- a/uzbl.c +++ b/uzbl.c @@ -804,7 +804,7 @@ set_var_value(gchar *name, gchar *val) { } /* variables that take int values */ else { - int *ip = p; + int *ip = (int *)p; *ip = (int)strtoul(val, &endp, 10); if(var_is("show_status", name)) { @@ -820,7 +820,7 @@ set_var_value(gchar *name, gchar *val) { } else if (var_is("http_debug", name)) { soup_session_remove_feature - (uzbl.net.soup_session, uzbl.net.soup_logger); + (uzbl.net.soup_session, SOUP_SESSION_FEATURE(uzbl.net.soup_logger)); /* do we leak if this doesn't get freed? why does it occasionally crash if freed? */ /*g_free(uzbl.net.soup_logger);*/ -- cgit v1.2.3 From c2950b32a5a841aec553716b8de33fe899371f2e Mon Sep 17 00:00:00 2001 From: DuClare Date: Fri, 15 May 2009 13:11:34 +0300 Subject: Added SET handling for always_insert_mode. --- uzbl.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/uzbl.c b/uzbl.c index 93fbd97..6413037 100644 --- a/uzbl.c +++ b/uzbl.c @@ -81,6 +81,7 @@ const struct { { "max_conns_host", (void *)&uzbl.net.max_conns_host }, { "http_debug", (void *)&uzbl.behave.http_debug }, { "modkey", (void *)&uzbl.behave.modkey }, + { "always_insert_mode", (void *)&uzbl.behave.always_insert_mode }, // TODO: write cmd handlers for the following { "useragent", (void *)&uzbl.net.useragent }, { NULL, NULL } @@ -828,6 +829,12 @@ set_var_value(gchar *name, gchar *val) { soup_session_add_feature(uzbl.net.soup_session, SOUP_SESSION_FEATURE(uzbl.net.soup_logger)); } + else if (var_is("always_insert_mode", name)) { + if (*ip) { + uzbl.behave.insert_mode = TRUE; + update_title(); + } + } } } return TRUE; -- cgit v1.2.3 From 5171e781e76dbec2ed87d6f445afd38d76eb81a9 Mon Sep 17 00:00:00 2001 From: DuClare Date: Fri, 15 May 2009 14:14:15 +0300 Subject: Add missing declaration, add runcmd for running bind, etc. via gui Example: bind :$_ = runcmd %s Then you can type :$bind xx = exit --- uzbl.c | 11 +++++++++-- uzbl.h | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/uzbl.c b/uzbl.c index 6413037..4008a31 100644 --- a/uzbl.c +++ b/uzbl.c @@ -388,7 +388,8 @@ static struct {char *name; Command command;} cmdlist[] = { "spawn", spawn }, { "exit", close_uzbl }, { "search", search_text }, - { "insert_mode", set_insert_mode } + { "insert_mode", set_insert_mode }, + { "runcmd", runcmd } }; static void @@ -840,8 +841,14 @@ set_var_value(gchar *name, gchar *val) { return TRUE; } +static void +runcmd(WebKitWebView* page, const char *param) { + (void) page; + parse_cmd_line(param); +} + static void -parse_cmd_line(char *ctl_line) { +parse_cmd_line(const char *ctl_line) { gchar **tokens; /* SET command */ diff --git a/uzbl.h b/uzbl.h index 1da04cc..a63b5dd 100644 --- a/uzbl.h +++ b/uzbl.h @@ -226,6 +226,12 @@ spawn(WebKitWebView *web_view, const char *param); static void parse_command(const char *cmd, const char *param); +static void +runcmd(WebKitWebView *page, const char *param); + +static void +parse_cmd_line(const char *ctl_line); + static gchar* build_stream_name(int type, const gchar *dir); -- cgit v1.2.3 From 07293241d3c13b34d312937b5db182134c90ce5d Mon Sep 17 00:00:00 2001 From: DuClare Date: Fri, 15 May 2009 14:19:26 +0300 Subject: Cleanup. --- uzbl.c | 5 ----- uzbl.h | 1 - 2 files changed, 6 deletions(-) diff --git a/uzbl.c b/uzbl.c index 4008a31..418ca0f 100644 --- a/uzbl.c +++ b/uzbl.c @@ -1633,13 +1633,8 @@ main (int argc, char* argv[]) { else update_title(); - make_var_to_name_hash(); create_stdin(); - /*if (uzbl.behave.fifo_dir) - init_fifo ();*/ - /*if (uzbl.behave.socket_dir) - init_socket ();*/ gtk_main (); clean_up(); diff --git a/uzbl.h b/uzbl.h index a63b5dd..592edcf 100644 --- a/uzbl.h +++ b/uzbl.h @@ -252,7 +252,6 @@ init_socket(gchar *dir); static void control_socket(GIOChannel *chan); - static void update_title (void); -- cgit v1.2.3 From d6edddd27fd625e69b9b1091e19853b16aa12677 Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Fri, 15 May 2009 13:33:45 +0200 Subject: added status_top to cmd parser --- examples/configs/sampleconfig-pipe | 1 + uzbl.c | 49 ++++++++++++++++++++++++++++++++------ uzbl.h | 2 ++ 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/examples/configs/sampleconfig-pipe b/examples/configs/sampleconfig-pipe index c25db06..bc5fdca 100644 --- a/examples/configs/sampleconfig-pipe +++ b/examples/configs/sampleconfig-pipe @@ -6,6 +6,7 @@ set modkey = Mod1 set always_insert = 0 #set proxy_url = http://127.0.0.1:8118 set fifo_dir = /tmp +#set status_top = 1 # Key bindings bind j = scroll_vert 20 diff --git a/uzbl.c b/uzbl.c index 8bd952a..1c3bec4 100644 --- a/uzbl.c +++ b/uzbl.c @@ -69,6 +69,7 @@ const struct { { "status_background", (void *)&uzbl.behave.status_background }, { "status_message", (void *)&uzbl.gui.sbar.msg }, { "show_status", (void *)&uzbl.behave.show_status }, + { "status_top", (void *)&uzbl.behave.status_top }, { "insert_mode", (void *)&uzbl.behave.insert_mode }, { "modkey" , (void *)&uzbl.behave.modkey }, { "always_insert" , (void *)&uzbl.behave.always_insert_mode }, @@ -755,6 +756,29 @@ set_modkey() { g_free (modkeyup); } +static void +move_statusbar() { + /* TODO: investigate how to make gtk not warn */ + gtk_widget_ref(uzbl.gui.scrolled_win); + gtk_widget_ref(uzbl.gui.mainbar); + gtk_container_remove(GTK_CONTAINER(uzbl.gui.vbox), uzbl.gui.scrolled_win); + gtk_container_remove(GTK_CONTAINER(uzbl.gui.vbox), uzbl.gui.mainbar); + + if(uzbl.behave.status_top) { + gtk_box_pack_start (GTK_BOX (uzbl.gui.vbox), uzbl.gui.mainbar, FALSE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (uzbl.gui.vbox), uzbl.gui.scrolled_win, TRUE, TRUE, 0); + } + else { + gtk_box_pack_start (GTK_BOX (uzbl.gui.vbox), uzbl.gui.scrolled_win, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (uzbl.gui.vbox), uzbl.gui.mainbar, FALSE, TRUE, 0); + } + + gtk_container_add(GTK_CONTAINER(uzbl.gui.vbox), uzbl.gui.scrolled_win); + gtk_container_add(GTK_CONTAINER(uzbl.gui.vbox), uzbl.gui.mainbar); + gtk_widget_unref(uzbl.gui.scrolled_win); + gtk_widget_unref(uzbl.gui.mainbar); +} + static gboolean var_is(const char *x, const char *y) { gboolean ret = FALSE; @@ -840,6 +864,9 @@ set_var_value(gchar *name, gchar *val) { soup_session_add_feature(uzbl.net.soup_session, SOUP_SESSION_FEATURE(uzbl.net.soup_logger)); } + else if (var_is("status_top", name)) { + move_statusbar(); + } } } return TRUE; @@ -1283,6 +1310,7 @@ create_browser () { GUI *g = &uzbl.gui; GtkWidget* scrolled_window = gtk_scrolled_window_new (NULL, NULL); + //main_window_ref = g_object_ref(scrolled_window); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_NEVER); //todo: some sort of display of position/total length. like what emacs does g->web_view = WEBKIT_WEB_VIEW (webkit_web_view_new ()); @@ -1307,6 +1335,10 @@ create_mainbar () { GUI *g = &uzbl.gui; g->mainbar = gtk_hbox_new (FALSE, 0); + + /* keep a reference to the bar so we can re-pack it at runtime*/ + //sbar_ref = g_object_ref(g->mainbar); + g->mainbar_label = gtk_label_new (""); gtk_label_set_selectable((GtkLabel *)g->mainbar_label, TRUE); gtk_label_set_ellipsize(GTK_LABEL(g->mainbar_label), PANGO_ELLIPSIZE_END); @@ -1481,6 +1513,7 @@ save_cookies (SoupMessage *msg, gpointer user_data){ g_slist_free(ck); } + int main (int argc, char* argv[]) { gtk_init (&argc, &argv); @@ -1508,15 +1541,17 @@ main (int argc, char* argv[]) { commands_hash (); - GtkWidget* vbox = gtk_vbox_new (FALSE, 0); - if (uzbl.behave.status_top) - gtk_box_pack_start (GTK_BOX (vbox), create_mainbar (), FALSE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (vbox), create_browser (), TRUE, TRUE, 0); - if (!uzbl.behave.status_top) - gtk_box_pack_start (GTK_BOX (vbox), create_mainbar (), FALSE, TRUE, 0); + uzbl.gui.vbox = gtk_vbox_new (FALSE, 0); + + uzbl.gui.scrolled_win = create_browser(); + create_mainbar(); + /* initial packing */ + gtk_box_pack_start (GTK_BOX (uzbl.gui.vbox), uzbl.gui.scrolled_win, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (uzbl.gui.vbox), uzbl.gui.mainbar, FALSE, TRUE, 0); + uzbl.gui.main_window = create_window (); - gtk_container_add (GTK_CONTAINER (uzbl.gui.main_window), vbox); + gtk_container_add (GTK_CONTAINER (uzbl.gui.main_window), uzbl.gui.vbox); load_uri (uzbl.gui.web_view, uzbl.state.uri); diff --git a/uzbl.h b/uzbl.h index 1da04cc..410d7b9 100644 --- a/uzbl.h +++ b/uzbl.h @@ -41,6 +41,8 @@ typedef struct { /* gui elements */ typedef struct { GtkWidget* main_window; + GtkWidget* scrolled_win; + GtkWidget* vbox; GtkWidget* mainbar; GtkWidget* mainbar_label; GtkScrollbar* scbar_v; // Horizontal and Vertical Scrollbar -- cgit v1.2.3 From 54a67c8db33d27d9ef1af20163a49a09a5c972fc Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Fri, 15 May 2009 13:36:50 +0200 Subject: removed status_top from cfg file parser --- uzbl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/uzbl.c b/uzbl.c index 1c3bec4..3a0ee47 100644 --- a/uzbl.c +++ b/uzbl.c @@ -1434,7 +1434,6 @@ settings_init () { } if (res) { - b->status_top = g_key_file_get_boolean (config, "behavior", "status_top", NULL); b->reset_command_mode = g_key_file_get_boolean (config, "behavior", "reset_command_mode", NULL); } -- cgit v1.2.3 From aaebf72e9133b9b58ed4663f83b06f4fbea49e42 Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Fri, 15 May 2009 13:39:05 +0200 Subject: fixed gtk warning --- uzbl.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/uzbl.c b/uzbl.c index 3a0ee47..8ce870b 100644 --- a/uzbl.c +++ b/uzbl.c @@ -758,7 +758,6 @@ set_modkey() { static void move_statusbar() { - /* TODO: investigate how to make gtk not warn */ gtk_widget_ref(uzbl.gui.scrolled_win); gtk_widget_ref(uzbl.gui.mainbar); gtk_container_remove(GTK_CONTAINER(uzbl.gui.vbox), uzbl.gui.scrolled_win); @@ -772,9 +771,6 @@ move_statusbar() { gtk_box_pack_start (GTK_BOX (uzbl.gui.vbox), uzbl.gui.scrolled_win, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (uzbl.gui.vbox), uzbl.gui.mainbar, FALSE, TRUE, 0); } - - gtk_container_add(GTK_CONTAINER(uzbl.gui.vbox), uzbl.gui.scrolled_win); - gtk_container_add(GTK_CONTAINER(uzbl.gui.vbox), uzbl.gui.mainbar); gtk_widget_unref(uzbl.gui.scrolled_win); gtk_widget_unref(uzbl.gui.mainbar); } -- cgit v1.2.3 From cb0ab53e5c503ec26a8da1a5c04706b43ca71978 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Fri, 15 May 2009 14:56:34 +0200 Subject: merge pipe config into dev config --- examples/configs/sampleconfig-dev | 109 +++++++++++++++++++------------------ examples/configs/sampleconfig-pipe | 37 ------------- 2 files changed, 56 insertions(+), 90 deletions(-) delete mode 100644 examples/configs/sampleconfig-pipe diff --git a/examples/configs/sampleconfig-dev b/examples/configs/sampleconfig-dev index 119e3a0..40fc67a 100644 --- a/examples/configs/sampleconfig-dev +++ b/examples/configs/sampleconfig-dev @@ -1,68 +1,71 @@ # example uzbl config. in a real config, we should obey the xdg spec - -# all keys in the behavior group are optional. if not set, the corresponding behavior is disabed. -# bindings_internal denote keys to trigger actions internally in uzbl -# bindings_external denote keys to trigger scripts outside uzbl +# all settings are optional. you can use uzbl without any config at all (but it won't do much) # keyboard behavior is vimstyle by default (all actions -> 1 key). set # always_insert_mode to always be in insert mode and disable going out of it. # if you do this, make sure you've set a modkey so you can reach the actions # from insert mode by combining them with the modkey -set uzbl.behave.history_handler ./examples/scripts/history.sh -set uzbl.behave.download_handler ./examples/scripts/download.sh -set uzbl.behave.cookie_handler ./examples/scripts/cookies.sh -set uzbl.behave.fifo_dir /tmp -set uzbl.behave.socket_dir /tmp -set uzbl.behave.always_insert_mode 0 -set uzbl.behave.modkey Mod1 -set uzbl.behave.show_status 1 -set uzbl.behave.status_top 0 -set uzbl.behave.status_format MODE [KEYCMD] LOAD_PROGRESSBAR URI NAME +# TODO: ability to attach misc things (spawn , script ,.. to internal events) +#set history_handler ./examples/scripts/history.sh +#set download_handler ./examples/scripts/download.sh +#set behave.cookie_handler ./examples/scripts/cookies.sh + + + +# Behaviour and appearance +set show_status = 1 # you can optionally use this setting to override the background color of the statusbar from your GTK theme. -set uzbl.behave.status_background #303030 +set status_background = #303030 +set status_format = MODE [KEYCMD] LOAD_PROGRESSBAR URI NAME MSG +set modkey = Mod1 +set always_insert = 0 +# to start a local socks server, do : ssh -fND localhost:8118 localhost +#set proxy_url = http://127.0.0.1:8118 +#values 0-3 +#set http_debug = 0 +#set useragent uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) +# Example user agent containing everything: +#set useragent Uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) (%sysname% %nodename% %kernrel% %kernver% %arch-system% [%arch-uzbl%]) (Commit %commit%) +#set max_conns 0 +#set .max_conns_host 0 -# scroll down/up/left/right -bind j scroll_vert 20 -bind k scroll_vert -20 -bind h scroll_horz -20 -bind l scroll_horz 20 -bind b back -bind m forward -bind s stop -bind r reload -bind R reload_ign_cache -bind + zoom_in -bind - zoom_out -bind t toggle uzbl.behave.show_status +set fifo_dir = /tmp +#TODO socket dir +#set status_top = 1 + +# Key bindings +bind j = scroll_vert 20 +bind k = scroll_vert -20 +bind h = scroll_horz -20 +bind l = scroll_horz 20 +bind b = back +bind m = forward +bind s = stop +bind r = reload +bind R = reload_ign_cache +bind + = zoom_in +bind - = zoom_out +bind t = toggle_status #hilight matches -bind /_ search %s +bind /_ = search %s #jump to next -bind ; search -bind gh set uzbl.state.uri http://www.uzbl.org -bind o _ set uzbl.state.uri %s -bind :wiki _ set uzbl.state.uri http://wiki.archlinux.org/index.php/Special:Search?search=%s&go=Go -bind gg _ set uzbl.state.uri http://www.google.com/search?q=%s -bind i toggle uzbl.behave.insert_mode -bind B spawn ./examples/scripts/insert_bookmark.sh -bind u spawn ./examples/scripts/load_url_from_history.sh -bind U spawn ./examples/scripts/load_url_from_bookmarks.sh -bind ZZ exit -bind S script alert("hi"); +bind ; = search +bind gh = uri http://www.uzbl.org +#TODO: set uri? +bind o _ = uri %s +bind :wiki _ = uri http://wiki.archlinux.org/index.php/Special:Search?search=%s&go=Go +bind gg _ = uri http://www.google.com/search?q=%s +bind i = insert_mode +#TODO: no 'toggle' command? +bind B = spawn ./examples/scripts/insert_bookmark.sh +bind u = spawn ./examples/scripts/load_url_from_history.sh +bind U = spawn ./examples/scripts/load_url_from_bookmarks.sh +bind ZZ = exit +bind S = script alert("hi"); # Keyboard based link following: work in progress! No C DOM bindings yet, no click() event for hyperlinks so no referrer set..Quite basic but does the job for now... #hit F to toggle the Hints (now in form of link numbering) -bind F script for (var i=0; i < document.links.length; i++) {var uzblid = 'uzbl_link_hint_';var li = document.links[i];var pre = document.getElementById(uzblid+i);if (pre) {li.removeChild(pre);} else {var hint = document.createElement('div');hint.setAttribute('id',uzblid+i);hint.innerHTML = i;hint.style.display='inline';hint.style.lineHeight='90%';hint.style.backgroundColor='red';hint.style.color='white';hint.style.fontSize='small-xx';hint.style.fontWeight='light';hint.style.margin='0px';hint.style.padding='2px';hint.style.position='absolute';hint.style.textDecoration='none';hint.style.left=li.style.left;hint.style.top=li.style.top;li.insertAdjacentElement('afterBegin',hint);}} +bind F= script for (var i=0; i < document.links.length; i++) {var uzblid = 'uzbl_link_hint_';var li = document.links[i];var pre = document.getElementById(uzblid+i);if (pre) {li.removeChild(pre);} else {var hint = document.createElement('div');hint.setAttribute('id',uzblid+i);hint.innerHTML = i;hint.style.display='inline';hint.style.lineHeight='90%';hint.style.backgroundColor='red';hint.style.color='white';hint.style.fontSize='small-xx';hint.style.fontWeight='light';hint.style.margin='0px';hint.style.padding='2px';hint.style.position='absolute';hint.style.textDecoration='none';hint.style.left=li.style.left;hint.style.top=li.style.top;li.insertAdjacentElement('afterBegin',hint);}} #hit f followed by linknumber and ENTER to follow that link -bind f_ script window.location = document.links[%s].href; - - -# to start a local socks server, do : ssh -fND localhost:8118 localhost -set uzbl.net.proxy_url http://127.0.0.1:8118 -#values 0-3 -set uzbl.behave.http_debug = 0 -set uzbl.net.useragent uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) -# Example user agent containing everything: -#set uzbl.net.useragent Uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) (%sysname% %nodename% %kernrel% %kernver% %arch-system% [%arch-uzbl%]) (Commit %commit%) -set uzbl.net.max_conns 0 -set uzbl.net.max_conns_host 0 +bind f_ = script window.location = document.links[%s].href; diff --git a/examples/configs/sampleconfig-pipe b/examples/configs/sampleconfig-pipe deleted file mode 100644 index bc5fdca..0000000 --- a/examples/configs/sampleconfig-pipe +++ /dev/null @@ -1,37 +0,0 @@ -# Behaviour and appearance -set show_status = 1 -set status_background = #303030 -set status_format = MODE [KEYCMD] LOAD_PROGRESSBAR URI NAME MSG -set modkey = Mod1 -set always_insert = 0 -#set proxy_url = http://127.0.0.1:8118 -set fifo_dir = /tmp -#set status_top = 1 - -# Key bindings -bind j = scroll_vert 20 -bind k = scroll_vert -20 -bind h = scroll_horz -20 -bind l = scroll_horz 20 -bind b = back -bind m = forward -bind s = stop -bind r = reload -bind R = reload_ign_cache -bind + = zoom_in -bind - = zoom_out -bind t = toggle_status -bind /_ = search %s -bind ; = search -bind gh = uri http://www.uzbl.org -bind o _ = uri %s -bind :wiki _ = uri http://wiki.archlinux.org/index.php/Special:Search?search=%s&go=Go -bind gg _ = uri http://www.google.com/search?q=%s -bind i = insert_mode -bind B = spawn ./examples/scripts/insert_bookmark.sh -bind u = spawn ./examples/scripts/load_url_from_history.sh -bind U = spawn ./examples/scripts/load_url_from_bookmarks.sh -bind ZZ = exit -bind S = script alert("hi"); -bind F= script for (var i=0; i < document.links.length; i++) {var uzblid = 'uzbl_link_hint_';var li = document.links[i];var pre = document.getElementById(uzblid+i);if (pre) {li.removeChild(pre);} else {var hint = document.createElement('div');hint.setAttribute('id',uzblid+i);hint.innerHTML = i;hint.style.display='inline';hint.style.lineHeight='90%';hint.style.backgroundColor='red';hint.style.color='white';hint.style.fontSize='small-xx';hint.style.fontWeight='light';hint.style.margin='0px';hint.style.padding='2px';hint.style.position='absolute';hint.style.textDecoration='none';hint.style.left=li.style.left;hint.style.top=li.style.top;li.insertAdjacentElement('afterBegin',hint);}} -bind f_ = script window.location = document.links[%s].href; -- cgit v1.2.3 From b329cac456b7fd76c8ab2b18222c1da9940ad7f5 Mon Sep 17 00:00:00 2001 From: DuClare Date: Fri, 15 May 2009 15:58:58 +0300 Subject: Add SET handling for useragent. --- uzbl.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- uzbl.h | 35 +++++++++++++++++++++++++++++---- 2 files changed, 91 insertions(+), 13 deletions(-) diff --git a/uzbl.c b/uzbl.c index 418ca0f..8755b10 100644 --- a/uzbl.c +++ b/uzbl.c @@ -82,7 +82,6 @@ const struct { { "http_debug", (void *)&uzbl.behave.http_debug }, { "modkey", (void *)&uzbl.behave.modkey }, { "always_insert_mode", (void *)&uzbl.behave.always_insert_mode }, - // TODO: write cmd handlers for the following { "useragent", (void *)&uzbl.net.useragent }, { NULL, NULL } }, *n2v_p = var_name_to_ptr; @@ -581,14 +580,13 @@ setup_scanner() { static gchar * parse_status_template(const char *template) { + if(!template) return NULL; + GTokenType token = G_TOKEN_NONE; GString *ret = g_string_new(""); gchar *buf=NULL; int sym; - if(!template) - return NULL; - g_scanner_input_text(uzbl.scan, template, strlen(template)); while(!g_scanner_eof(uzbl.scan) && token != G_TOKEN_LAST) { token = g_scanner_get_next_token(uzbl.scan); @@ -631,6 +629,42 @@ parse_status_template(const char *template) { g_string_append(ret, uzbl.gui.sbar.msg?uzbl.gui.sbar.msg:""); break; + /* useragent syms */ + case SYM_WK_MAJ: + g_string_append(ret, itos(WEBKIT_MAJOR_VERSION)); + break; + case SYM_WK_MIN: + g_string_append(ret, itos(WEBKIT_MINOR_VERSION)); + break; + case SYM_WK_MIC: + g_string_append(ret, itos(WEBKIT_MICRO_VERSION)); + break; + case SYM_SYSNAME: + g_string_append(ret, uzbl.state.unameinfo.sysname); + break; + case SYM_NODENAME: + g_string_append(ret, uzbl.state.unameinfo.nodename); + break; + case SYM_KERNREL: + g_string_append(ret, uzbl.state.unameinfo.release); + break; + case SYM_KERNVER: + g_string_append(ret, uzbl.state.unameinfo.version); + break; + case SYM_ARCHSYS: + g_string_append(ret, uzbl.state.unameinfo.machine); + break; + case SYM_ARCHUZBL: + g_string_append(ret, ARCH); + break; +#ifdef _GNU_SOURCE + case SYM_DOMAINNAME: + g_string_append(ret, uzbl.state.unameinfo.domainname); + break; +#endif + case SYM_COMMIT: + g_string_append(ret, COMMIT); + break; default: break; } @@ -723,11 +757,10 @@ get_var_value(gchar *name) { void **p = NULL; if( (p = g_hash_table_lookup(uzbl.comm.proto_var, name)) ) { - if(!strcmp(name, "status_format")) { + if(var_is("status_format", name) + || var_is("useragent", name)) { printf("VAR: %s VALUE: %s\n", name, (char *)*p); - } else { - printf("VAR: %s VALUE: %d\n", name, (int)*p); - } + } else printf("VAR: %s VALUE: %d\n", name, (int)*p); } return TRUE; } @@ -804,6 +837,10 @@ set_var_value(gchar *name, gchar *val) { uzbl.behave.modmask |= modkeys[i].mask; } } + else if(var_is("useragent", name)) { + if(*p) free(*p); + *p = set_useragent(g_strdup(val)); + } /* variables that take int values */ else { int *ip = (int *)p; @@ -1483,7 +1520,7 @@ settings_init () { n->soup_logger = soup_logger_new(b->http_debug, -1); soup_session_add_feature(n->soup_session, SOUP_SESSION_FEATURE(n->soup_logger)); } - + if(n->useragent){ char* newagent = malloc(1024); @@ -1530,6 +1567,18 @@ settings_init () { g_signal_connect(n->soup_session, "request-queued", G_CALLBACK(handle_cookies), NULL); } +static gchar* +set_useragent(gchar *val) { + if (*val == ' ') { + g_free(val); + return NULL; + } + gchar *ua = parse_status_template(val); + if (ua) + g_object_set(G_OBJECT(uzbl.net.soup_session), SOUP_SESSION_USER_AGENT, ua, NULL); + return ua; +} + static void handle_cookies (SoupSession *session, SoupMessage *msg, gpointer user_data){ (void) session; (void) user_data; @@ -1622,6 +1671,8 @@ main (int argc, char* argv[]) { if(setup_signal(SIGTERM, catch_sigterm) == SIG_ERR) fprintf(stderr, "uzbl: error hooking SIGTERM\n"); + if(uname(&uzbl.state.unameinfo) == -1) + g_printerr("Can't retrieve unameinfo. Your useragent might appear wrong.\n"); setup_regex(); setup_scanner(); diff --git a/uzbl.h b/uzbl.h index 592edcf..5122375 100644 --- a/uzbl.h +++ b/uzbl.h @@ -12,10 +12,19 @@ #define STATUS_DEFAULT " MODE KEYCMD (LOAD_PROGRESS%) TITLE - Uzbl browser" -/* statusbar symbols */ -enum { SYM_TITLE, SYM_URI, SYM_NAME, - SYM_LOADPRGS, SYM_LOADPRGSBAR, - SYM_KEYCMD, SYM_MODE, SYM_MSG}; +enum { + /* statusbar symbols */ + SYM_TITLE, SYM_URI, SYM_NAME, + SYM_LOADPRGS, SYM_LOADPRGSBAR, + SYM_KEYCMD, SYM_MODE, SYM_MSG, + /* useragent symbols */ + SYM_WK_MAJ, SYM_WK_MIN, SYM_WK_MIC, + SYM_SYSNAME, SYM_NODENAME, + SYM_KERNREL, SYM_KERNVER, + SYM_ARCHSYS, SYM_ARCHUZBL, + SYM_DOMAINNAME, SYM_COMMIT +}; + const struct { gchar *symbol_name; guint symbol_token; @@ -28,6 +37,18 @@ const struct { {"MSG", SYM_MSG}, {"LOAD_PROGRESS", SYM_LOADPRGS}, {"LOAD_PROGRESSBAR", SYM_LOADPRGSBAR}, + + {"WEBKIT_MAJOR", SYM_WK_MAJ}, + {"WEBKIT_MINOR", SYM_WK_MIN}, + {"WEBKIT_MICRO", SYM_WK_MIC}, + {"SYSNAME", SYM_SYSNAME}, + {"NODENAME", SYM_NODENAME}, + {"KERNREL", SYM_KERNREL}, + {"KERNVER", SYM_KERNVER}, + {"ARCH_SYSTEM", SYM_ARCHSYS}, + {"ARCH_UZBL", SYM_ARCHUZBL}, + {"DOMAINNAME", SYM_DOMAINNAME}, + {"COMMIT", SYM_COMMIT}, {NULL, 0} }, *symp = symbols; @@ -235,6 +256,12 @@ parse_cmd_line(const char *ctl_line); static gchar* build_stream_name(int type, const gchar *dir); +static gboolean +var_is(const char *x, const char *y); + +static gchar* +set_useragent(gchar *val); + static void control_fifo(GIOChannel *gio, GIOCondition condition); -- cgit v1.2.3 From 11160dedad814686986f5b9decc54fb28885fbde Mon Sep 17 00:00:00 2001 From: DuClare Date: Fri, 15 May 2009 16:13:52 +0300 Subject: Rename parse_status_template to expand_template (it's used for useragent too) --- uzbl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/uzbl.c b/uzbl.c index 8755b10..c59e168 100644 --- a/uzbl.c +++ b/uzbl.c @@ -579,7 +579,7 @@ setup_scanner() { } static gchar * -parse_status_template(const char *template) { +expand_template(const char *template) { if(!template) return NULL; GTokenType token = G_TOKEN_NONE; @@ -1195,7 +1195,7 @@ update_title (void) { if (b->show_status) { gtk_window_set_title (GTK_WINDOW(uzbl.gui.main_window), title_short); // TODO: we should probably not do this every time we want to update the title..? - statln = parse_status_template(uzbl.behave.status_format); + statln = expand_template(uzbl.behave.status_format); gtk_label_set_markup(GTK_LABEL(uzbl.gui.mainbar_label), statln); if (b->status_background) { GdkColor color; @@ -1573,7 +1573,7 @@ set_useragent(gchar *val) { g_free(val); return NULL; } - gchar *ua = parse_status_template(val); + gchar *ua = expand_template(val); if (ua) g_object_set(G_OBJECT(uzbl.net.soup_session), SOUP_SESSION_USER_AGENT, ua, NULL); return ua; -- cgit v1.2.3 From 8bb034612bc8342dc50d2b5250793c7535ff2ce2 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Fri, 15 May 2009 15:15:14 +0200 Subject: fix for too many always_insert_mode stuff --- examples/configs/sampleconfig-dev | 2 +- uzbl.c | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/examples/configs/sampleconfig-dev b/examples/configs/sampleconfig-dev index 40fc67a..ae7dea8 100644 --- a/examples/configs/sampleconfig-dev +++ b/examples/configs/sampleconfig-dev @@ -20,7 +20,7 @@ set show_status = 1 set status_background = #303030 set status_format = MODE [KEYCMD] LOAD_PROGRESSBAR URI NAME MSG set modkey = Mod1 -set always_insert = 0 +set always_insert_mode = 0 # to start a local socks server, do : ssh -fND localhost:8118 localhost #set proxy_url = http://127.0.0.1:8118 #values 0-3 diff --git a/uzbl.c b/uzbl.c index 67ee0ae..631f338 100644 --- a/uzbl.c +++ b/uzbl.c @@ -72,7 +72,6 @@ const struct { { "status_top", (void *)&uzbl.behave.status_top }, { "insert_mode", (void *)&uzbl.behave.insert_mode }, { "modkey" , (void *)&uzbl.behave.modkey }, - { "always_insert" , (void *)&uzbl.behave.always_insert_mode }, { "load_finish_handler",(void *)&uzbl.behave.load_finish_handler}, { "history_handler", (void *)&uzbl.behave.history_handler }, { "download_handler", (void *)&uzbl.behave.download_handler }, @@ -832,8 +831,7 @@ set_var_value(gchar *name, gchar *val) { if(var_is("show_status", name)) { cmd_set_status(); } - else if(var_is("always_insert", name)) { - + else if(var_is("always_insert_mode", name)) { uzbl.behave.insert_mode = uzbl.behave.always_insert_mode ? TRUE : FALSE; update_title(); @@ -861,12 +859,6 @@ set_var_value(gchar *name, gchar *val) { else if (var_is("status_top", name)) { move_statusbar(); } - else if (var_is("always_insert_mode", name)) { - if (*ip) { - uzbl.behave.insert_mode = TRUE; - update_title(); - } - } } } return TRUE; -- cgit v1.2.3 From 114df42ec53d1ba41340559a0dabf29b921a1c56 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Fri, 15 May 2009 15:32:44 +0200 Subject: fix for dup modkey entries. reorder entries in var_name_to_ptr --- uzbl.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/uzbl.c b/uzbl.c index 06844ed..5b69c87 100644 --- a/uzbl.c +++ b/uzbl.c @@ -65,12 +65,13 @@ const struct { } var_name_to_ptr[] = { // Already working commands { "uri", (void *)&uzbl.state.uri }, - { "status_format", (void *)&uzbl.behave.status_format }, - { "status_background", (void *)&uzbl.behave.status_background }, { "status_message", (void *)&uzbl.gui.sbar.msg }, { "show_status", (void *)&uzbl.behave.show_status }, { "status_top", (void *)&uzbl.behave.status_top }, + { "status_format", (void *)&uzbl.behave.status_format }, + { "status_background", (void *)&uzbl.behave.status_background }, { "insert_mode", (void *)&uzbl.behave.insert_mode }, + { "always_insert_mode", (void *)&uzbl.behave.always_insert_mode }, { "modkey" , (void *)&uzbl.behave.modkey }, { "load_finish_handler",(void *)&uzbl.behave.load_finish_handler}, { "history_handler", (void *)&uzbl.behave.history_handler }, @@ -78,12 +79,10 @@ const struct { { "cookie_handler", (void *)&uzbl.behave.cookie_handler }, { "fifo_dir", (void *)&uzbl.behave.fifo_dir }, { "socket_dir", (void *)&uzbl.behave.socket_dir }, + { "http_debug", (void *)&uzbl.behave.http_debug }, { "proxy_url", (void *)&uzbl.net.proxy_url }, { "max_conns", (void *)&uzbl.net.max_conns }, { "max_conns_host", (void *)&uzbl.net.max_conns_host }, - { "http_debug", (void *)&uzbl.behave.http_debug }, - { "modkey", (void *)&uzbl.behave.modkey }, - { "always_insert_mode", (void *)&uzbl.behave.always_insert_mode }, { "useragent", (void *)&uzbl.net.useragent }, { NULL, NULL } }, *n2v_p = var_name_to_ptr; -- cgit v1.2.3 From 5703e7d3d290047cd855e80f700d29d10fa1a0a1 Mon Sep 17 00:00:00 2001 From: DuClare Date: Fri, 15 May 2009 16:33:15 +0300 Subject: Remove deprecated code. --- uzbl.c | 48 ------------------------------------------------ uzbl.h | 3 --- 2 files changed, 51 deletions(-) diff --git a/uzbl.c b/uzbl.c index 06844ed..f149279 100644 --- a/uzbl.c +++ b/uzbl.c @@ -147,11 +147,6 @@ itos(int val) { return g_strdup(tmp); } -static char * -str_replace (const char* search, const char* replace, const char* string) { - return g_strjoinv (replace, g_strsplit(string, search, -1)); -} - static sigfunc* setup_signal(int signr, sigfunc *shandler) { struct sigaction nh, oh; @@ -1420,7 +1415,6 @@ settings_init () { char *saveptr; State *s = &uzbl.state; Network *n = &uzbl.net; - Behaviour *b = &uzbl.behave; if (!s->config_file) { const char* XDG_CONFIG_HOME = getenv ("XDG_CONFIG_HOME"); @@ -1469,48 +1463,6 @@ settings_init () { printf ("No configuration.\n"); } - if (res) { - b->reset_command_mode = g_key_file_get_boolean (config, "behavior", "reset_command_mode", NULL); - } - - printf ("Reset mode: %s\n" , (b->reset_command_mode ? "TRUE" : "FALSE")); - - /* networking options */ - if (res) { - n->useragent = g_key_file_get_value (config, "network", "user-agent", NULL); - } - - if(n->useragent){ - char* newagent = malloc(1024); - - strcpy(newagent, str_replace("%webkit-major%", itos(WEBKIT_MAJOR_VERSION), n->useragent)); - strcpy(newagent, str_replace("%webkit-minor%", itos(WEBKIT_MINOR_VERSION), newagent)); - strcpy(newagent, str_replace("%webkit-micro%", itos(WEBKIT_MICRO_VERSION), newagent)); - - if (uname (&s->unameinfo) == -1) { - printf("Error getting uname info. Not replacing system-related user agent variables.\n"); - } else { - strcpy(newagent, str_replace("%sysname%", s->unameinfo.sysname, newagent)); - strcpy(newagent, str_replace("%nodename%", s->unameinfo.nodename, newagent)); - strcpy(newagent, str_replace("%kernrel%", s->unameinfo.release, newagent)); - strcpy(newagent, str_replace("%kernver%", s->unameinfo.version, newagent)); - strcpy(newagent, str_replace("%arch-system%", s->unameinfo.machine, newagent)); - - #ifdef _GNU_SOURCE - strcpy(newagent, str_replace("%domainname%", s->unameinfo.domainname, newagent)); - #endif - } - - strcpy(newagent, str_replace("%arch-uzbl%", ARCH, newagent)); - strcpy(newagent, str_replace("%commit%", COMMIT, newagent)); - - n->useragent = malloc(1024); - strcpy(n->useragent, newagent); - g_object_set(G_OBJECT(n->soup_session), SOUP_SESSION_USER_AGENT, n->useragent, NULL); - } - - printf("User-agent: %s\n", n->useragent? n->useragent : "default"); - g_signal_connect(n->soup_session, "request-queued", G_CALLBACK(handle_cookies), NULL); } diff --git a/uzbl.h b/uzbl.h index b5e73e9..085977e 100644 --- a/uzbl.h +++ b/uzbl.h @@ -309,9 +309,6 @@ search_text (WebKitWebView *page, const char *param); static void run_js (WebKitWebView * web_view, const gchar *param); -static char * -str_replace (const char* search, const char* replace, const char* string); - static void handle_cookies (SoupSession *session, SoupMessage *msg, gpointer user_data); -- cgit v1.2.3 From 8b2e8ac8a34201e0512e8d640af02b0a534e8015 Mon Sep 17 00:00:00 2001 From: DuClare Date: Fri, 15 May 2009 17:11:00 +0300 Subject: Add reset_command_mode to var->ptr map and give it a default in init_settings --- uzbl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/uzbl.c b/uzbl.c index 26ced67..7efb8f1 100644 --- a/uzbl.c +++ b/uzbl.c @@ -72,6 +72,7 @@ const struct { { "status_background", (void *)&uzbl.behave.status_background }, { "insert_mode", (void *)&uzbl.behave.insert_mode }, { "always_insert_mode", (void *)&uzbl.behave.always_insert_mode }, + { "reset_command_mode", (void *)&uzbl.behave.reset_command_mode }, { "modkey" , (void *)&uzbl.behave.modkey }, { "load_finish_handler",(void *)&uzbl.behave.load_finish_handler}, { "history_handler", (void *)&uzbl.behave.history_handler }, @@ -1415,6 +1416,8 @@ settings_init () { State *s = &uzbl.state; Network *n = &uzbl.net; + uzbl.behave.reset_command_mode = 1; + if (!s->config_file) { const char* XDG_CONFIG_HOME = getenv ("XDG_CONFIG_HOME"); if (! XDG_CONFIG_HOME || ! strcmp (XDG_CONFIG_HOME, "")) { -- cgit v1.2.3 From 9ec1dd0b2bdd9a541c5552a85a164c79cf222e55 Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Fri, 15 May 2009 16:18:28 +0200 Subject: free memory returned by itos() --- uzbl.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/uzbl.c b/uzbl.c index 5b69c87..073dd41 100644 --- a/uzbl.c +++ b/uzbl.c @@ -585,7 +585,7 @@ expand_template(const char *template) { GTokenType token = G_TOKEN_NONE; GString *ret = g_string_new(""); - gchar *buf=NULL; + char *buf=NULL; int sym; g_scanner_input_text(uzbl.scan, template, strlen(template)); @@ -601,7 +601,9 @@ expand_template(const char *template) { g_markup_printf_escaped("%s", uzbl.state.uri):""); break; case SYM_LOADPRGS: - g_string_append(ret, itos(uzbl.gui.sbar.load_progress)); + buf = itos(uzbl.gui.sbar.load_progress); + g_string_append(ret, buf); + free(buf); break; case SYM_LOADPRGSBAR: buf = build_progressbar_ascii(uzbl.gui.sbar.load_progress); @@ -614,8 +616,10 @@ expand_template(const char *template) { g_markup_printf_escaped("%s", uzbl.gui.main_title):""); break; case SYM_NAME: + buf = itos(uzbl.xwin); g_string_append(ret, - uzbl.state.instance_name?uzbl.state.instance_name:itos(uzbl.xwin)); + uzbl.state.instance_name?uzbl.state.instance_name:buf); + free(buf); break; case SYM_KEYCMD: g_string_append(ret, @@ -632,13 +636,19 @@ expand_template(const char *template) { break; /* useragent syms */ case SYM_WK_MAJ: - g_string_append(ret, itos(WEBKIT_MAJOR_VERSION)); + buf = itos(WEBKIT_MAJOR_VERSION); + g_string_append(ret, buf); + free(buf); break; case SYM_WK_MIN: - g_string_append(ret, itos(WEBKIT_MINOR_VERSION)); + buf = itos(WEBKIT_MINOR_VERSION); + g_string_append(ret, buf); + free(buf); break; case SYM_WK_MIC: - g_string_append(ret, itos(WEBKIT_MICRO_VERSION)); + buf = itos(WEBKIT_MICRO_VERSION); + g_string_append(ret, buf); + free(buf); break; case SYM_SYSNAME: g_string_append(ret, uzbl.state.unameinfo.sysname); @@ -671,7 +681,9 @@ expand_template(const char *template) { } } else if(token == G_TOKEN_INT) { - g_string_append(ret, itos(g_scanner_cur_value(uzbl.scan).v_int)); + buf = itos(g_scanner_cur_value(uzbl.scan).v_int); + g_string_append(ret, buf); + free(buf); } else if(token == G_TOKEN_IDENTIFIER) { g_string_append(ret, (gchar *)g_scanner_cur_value(uzbl.scan).v_identifier); -- cgit v1.2.3 From 5d498b3df714fa31230d682456e69938614e6074 Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Fri, 15 May 2009 16:22:52 +0200 Subject: fix focus bug --- uzbl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/uzbl.c b/uzbl.c index 073dd41..7c9187d 100644 --- a/uzbl.c +++ b/uzbl.c @@ -815,6 +815,7 @@ move_statusbar() { } gtk_widget_unref(uzbl.gui.scrolled_win); gtk_widget_unref(uzbl.gui.mainbar); + gtk_widget_grab_focus (GTK_WIDGET (uzbl.gui.web_view)); } static gboolean -- cgit v1.2.3 From 1cee2c9fd589bcefea2ba142148409a7e21ed789 Mon Sep 17 00:00:00 2001 From: DuClare Date: Fri, 15 May 2009 18:05:35 +0300 Subject: Add actions for scrolling to the beginning / end of buffer --- uzbl.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/uzbl.c b/uzbl.c index 90c6a26..70808a4 100644 --- a/uzbl.c +++ b/uzbl.c @@ -237,15 +237,24 @@ scroll (GtkAdjustment* bar, const char *param) { gtk_adjustment_set_value (bar, gtk_adjustment_get_value(bar)+amount); } +static void scroll_begin(WebKitWebView* page, const char *param) { + (void) page; (void) param; + gtk_adjustment_set_value (uzbl.gui.bar_v, gtk_adjustment_get_lower(uzbl.gui.bar_v)); +} + +static void scroll_end(WebKitWebView* page, const char *param) { + (void) page; (void) param; + 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, const char *param) { (void) page; - scroll(uzbl.gui.bar_v, param); } static void scroll_horz(WebKitWebView* page, const char *param) { (void) page; - scroll(uzbl.gui.bar_h, param); } @@ -373,6 +382,8 @@ static struct {char *name; Command command;} cmdlist[] = { "forward", view_go_forward }, { "scroll_vert", scroll_vert }, { "scroll_horz", scroll_horz }, + { "scroll_begin", scroll_begin }, + { "scroll_end", scroll_end }, { "reload", view_reload, }, { "reload_ign_cache", view_reload_bypass_cache}, { "stop", view_stop_loading, }, -- cgit v1.2.3 From 96a449a2e1a486a7a24fd12e00bbf6b12a223f6a Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Fri, 15 May 2009 17:48:17 +0200 Subject: valgrind profiling --- README | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README b/README index 42db76a..b457295 100644 --- a/README +++ b/README @@ -128,3 +128,10 @@ KNOWN BUGS - Something in the FIFO code causes CPU usage to jump. Report new issues @ uzbl.org/bugs + + +VALGRIND PROFILING +add this to Makefile header: CFLAGS=-g +recompile +valgrind --tool=callgrind ./uzbl .... +kcachegrind callgrind.out.foo -- cgit v1.2.3 From 5ece4cb04a07953ff6ac8197fc61be9a715b0f11 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Fri, 15 May 2009 17:49:09 +0200 Subject: deprecated comment --- uzbl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/uzbl.c b/uzbl.c index 5b69c87..7893d38 100644 --- a/uzbl.c +++ b/uzbl.c @@ -63,7 +63,6 @@ const struct { char *name; void **ptr; } var_name_to_ptr[] = { - // Already working commands { "uri", (void *)&uzbl.state.uri }, { "status_message", (void *)&uzbl.gui.sbar.msg }, { "show_status", (void *)&uzbl.behave.show_status }, -- cgit v1.2.3 From 52a1804fdcd2af3e030a842e6c0e55c53b720e92 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Fri, 15 May 2009 17:53:11 +0200 Subject: markup --- README | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README b/README index b457295..60ed089 100644 --- a/README +++ b/README @@ -135,3 +135,9 @@ add this to Makefile header: CFLAGS=-g recompile valgrind --tool=callgrind ./uzbl .... kcachegrind callgrind.out.foo + +CONFIG FILE +** Variable replacement and markup format +See http://library.gnome.org/devel/pango/stable/PangoMarkupFormat.html for +what you can do, markup wise. +TODO: document possible variables, and what you can do with useragent/title/statusbar -- cgit v1.2.3 From 263cb1a9da4030b2fe5e7f1b73721c28915bf002 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Fri, 15 May 2009 18:07:44 +0200 Subject: fixes in config --- examples/configs/sampleconfig-dev | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/configs/sampleconfig-dev b/examples/configs/sampleconfig-dev index ae7dea8..38f1274 100644 --- a/examples/configs/sampleconfig-dev +++ b/examples/configs/sampleconfig-dev @@ -10,7 +10,7 @@ # TODO: ability to attach misc things (spawn , script ,.. to internal events) #set history_handler ./examples/scripts/history.sh #set download_handler ./examples/scripts/download.sh -#set behave.cookie_handler ./examples/scripts/cookies.sh +#set cookie_handler ./examples/scripts/cookies.sh @@ -29,7 +29,7 @@ set always_insert_mode = 0 # Example user agent containing everything: #set useragent Uzbl (Webkit %webkit-major%.%webkit-minor%.%webkit-micro%) (%sysname% %nodename% %kernrel% %kernver% %arch-system% [%arch-uzbl%]) (Commit %commit%) #set max_conns 0 -#set .max_conns_host 0 +#set max_conns_host 0 set fifo_dir = /tmp #TODO socket dir -- cgit v1.2.3 From 4cb5e65f51d7d4c0ffb34ce44511297426ae41e7 Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Fri, 15 May 2009 18:23:20 +0200 Subject: fixed control_fifo() to return a correct status --- uzbl.c | 6 +++--- uzbl.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/uzbl.c b/uzbl.c index 7c9187d..f44db2e 100644 --- a/uzbl.c +++ b/uzbl.c @@ -995,14 +995,14 @@ build_stream_name(int type, const gchar* dir) { return str; } -static void +static gboolean control_fifo(GIOChannel *gio, GIOCondition condition) { printf("triggered\n"); gchar *ctl_line; GIOStatus ret; GError *err = NULL; - if (condition & G_IO_HUP) + if (condition & G_IO_HUP) g_error ("Fifo: Read end of pipe died!\n"); if(!gio) @@ -1015,7 +1015,7 @@ control_fifo(GIOChannel *gio, GIOCondition condition) { parse_cmd_line(ctl_line); g_free(ctl_line); - return; + return TRUE; } static gchar* diff --git a/uzbl.h b/uzbl.h index b5e73e9..30c7601 100644 --- a/uzbl.h +++ b/uzbl.h @@ -264,7 +264,7 @@ var_is(const char *x, const char *y); static gchar* set_useragent(gchar *val); -static void +static gboolean control_fifo(GIOChannel *gio, GIOCondition condition); static gchar* -- cgit v1.2.3 From 75c29a1c77d85718e2625dbe26da3c38e6310578 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Fri, 15 May 2009 18:53:41 +0200 Subject: support reading config file line by line --- uzbl.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/uzbl.c b/uzbl.c index a2a5f88..9985b52 100644 --- a/uzbl.c +++ b/uzbl.c @@ -1433,8 +1433,6 @@ add_binding (const gchar *key, const gchar *act) { static void settings_init () { - GKeyFile* config = NULL; - gboolean res = FALSE; char *saveptr; State *s = &uzbl.state; Network *n = &uzbl.net; @@ -1477,15 +1475,22 @@ settings_init () { } if (s->config_file) { - config = g_key_file_new (); - res = g_key_file_load_from_file (config, s->config_file, G_KEY_FILE_NONE, NULL); - if (res) { - printf ("Config %s loaded\n", s->config_file); - } else { - fprintf (stderr, "Config %s loading failed\n", s->config_file); + FILE * conf; + char readbuf [300]; + conf = fopen (s->config_file, "r"); + if (conf == NULL) { + fprintf(stderr, "uzbl: error loading file%s\n", s->config_file); + } else { + while(!feof(conf)) { + fgets (readbuf , 300 , conf); + parse_cmd_line(readbuf); + } + fclose (conf); } + + printf ("Config %s loaded\n", s->config_file); } else { - printf ("No configuration.\n"); + printf ("No configuration file loaded.\n"); } g_signal_connect(n->soup_session, "request-queued", G_CALLBACK(handle_cookies), NULL); @@ -1561,6 +1566,14 @@ main (int argc, char* argv[]) { uzbl.net.soup_session = webkit_get_default_session(); uzbl.state.keycmd = g_string_new(""); + if(setup_signal(SIGTERM, catch_sigterm) == SIG_ERR) + fprintf(stderr, "uzbl: error hooking SIGTERM\n"); + + if(uname(&uzbl.state.unameinfo) == -1) + g_printerr("Can't retrieve unameinfo. Your useragent might appear wrong.\n"); + + setup_regex(); + setup_scanner(); settings_init (); commands_hash (); @@ -1593,14 +1606,7 @@ main (int argc, char* argv[]) { gtk_widget_set_scroll_adjustments ((GtkWidget*) uzbl.gui.web_view, uzbl.gui.bar_h, uzbl.gui.bar_v); - if(setup_signal(SIGTERM, catch_sigterm) == SIG_ERR) - fprintf(stderr, "uzbl: error hooking SIGTERM\n"); - if(uname(&uzbl.state.unameinfo) == -1) - g_printerr("Can't retrieve unameinfo. Your useragent might appear wrong.\n"); - - setup_regex(); - setup_scanner(); if (!uzbl.behave.status_format) uzbl.behave.status_format = g_strdup(STATUS_DEFAULT); -- cgit v1.2.3 From 48c483439e10f8d007c2fb4167a02813c29e16cb Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Fri, 15 May 2009 19:59:27 +0200 Subject: reorder some stuff to make more sense + allow up to 1k chars on a line --- uzbl.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/uzbl.c b/uzbl.c index 9985b52..688c418 100644 --- a/uzbl.c +++ b/uzbl.c @@ -1476,13 +1476,13 @@ settings_init () { if (s->config_file) { FILE * conf; - char readbuf [300]; + char readbuf [1000]; conf = fopen (s->config_file, "r"); if (conf == NULL) { fprintf(stderr, "uzbl: error loading file%s\n", s->config_file); } else { while(!feof(conf)) { - fgets (readbuf , 300 , conf); + fgets (readbuf , 1000 , conf); parse_cmd_line(readbuf); } fclose (conf); @@ -1492,6 +1492,8 @@ settings_init () { } else { printf ("No configuration file loaded.\n"); } + if (!uzbl.behave.status_format) + uzbl.behave.status_format = g_strdup(STATUS_DEFAULT); g_signal_connect(n->soup_session, "request-queued", G_CALLBACK(handle_cookies), NULL); } @@ -1574,8 +1576,8 @@ main (int argc, char* argv[]) { setup_regex(); setup_scanner(); - settings_init (); commands_hash (); + make_var_to_name_hash(); uzbl.gui.vbox = gtk_vbox_new (FALSE, 0); @@ -1590,7 +1592,7 @@ main (int argc, char* argv[]) { uzbl.gui.main_window = create_window (); gtk_container_add (GTK_CONTAINER (uzbl.gui.main_window), uzbl.gui.vbox); - load_uri (uzbl.gui.web_view, uzbl.state.uri); + load_uri (uzbl.gui.web_view, uzbl.state.uri); //TODO: is this needed? gtk_widget_grab_focus (GTK_WIDGET (uzbl.gui.web_view)); gtk_widget_show_all (uzbl.gui.main_window); @@ -1605,17 +1607,13 @@ main (int argc, char* argv[]) { uzbl.gui.bar_h = gtk_range_get_adjustment((GtkRange*) uzbl.gui.scbar_h); gtk_widget_set_scroll_adjustments ((GtkWidget*) uzbl.gui.web_view, uzbl.gui.bar_h, uzbl.gui.bar_v); + settings_init (); - - - if (!uzbl.behave.status_format) - uzbl.behave.status_format = g_strdup(STATUS_DEFAULT); if (!uzbl.behave.show_status) gtk_widget_hide(uzbl.gui.mainbar); else update_title(); - make_var_to_name_hash(); create_stdin(); gtk_main (); -- cgit v1.2.3 From e4229be55a4c397227485b7a4575ba13f4473acb Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Fri, 15 May 2009 21:13:06 +0200 Subject: use g io channels for file reading so we dont have size limits on the buffer string --- uzbl.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/uzbl.c b/uzbl.c index 688c418..5622299 100644 --- a/uzbl.c +++ b/uzbl.c @@ -1475,20 +1475,24 @@ settings_init () { } if (s->config_file) { - FILE * conf; - char readbuf [1000]; - conf = fopen (s->config_file, "r"); - if (conf == NULL) { - fprintf(stderr, "uzbl: error loading file%s\n", s->config_file); - } else { - while(!feof(conf)) { - fgets (readbuf , 1000 , conf); + GIOChannel *chan = NULL; + GError *error = NULL; + gchar *readbuf = NULL; + gsize len; + GIOStatus status = G_IO_STATUS_NORMAL; + chan = g_io_channel_new_file(s->config_file, "r", &error); + if (chan) { + while (status == G_IO_STATUS_NORMAL) { + status = g_io_channel_read_line (chan, &readbuf, &len, NULL, NULL); + readbuf[len-1] = '\0'; // strip the "\n" parse_cmd_line(readbuf); - } - fclose (conf); - } - - printf ("Config %s loaded\n", s->config_file); + g_free (readbuf); + } + g_io_channel_unref (chan); + printf ("Config %s loaded\n", s->config_file); + } else { + fprintf(stderr, "uzbl: error loading file%s\n", s->config_file); + } } else { printf ("No configuration file loaded.\n"); } -- cgit v1.2.3 From beeb58aba25b36523b68b25789200dae17f6ab7d Mon Sep 17 00:00:00 2001 From: Robert Manea Date: Fri, 15 May 2009 21:31:29 +0200 Subject: fixed settings_init() --- uzbl.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/uzbl.c b/uzbl.c index 747c36a..7997753 100644 --- a/uzbl.c +++ b/uzbl.c @@ -1479,20 +1479,21 @@ settings_init () { GError *error = NULL; gchar *readbuf = NULL; gsize len; - GIOStatus status = G_IO_STATUS_NORMAL; + chan = g_io_channel_new_file(s->config_file, "r", &error); + if (chan) { - while (status == G_IO_STATUS_NORMAL) { - status = g_io_channel_read_line (chan, &readbuf, &len, NULL, NULL); - readbuf[len-1] = '\0'; // strip the "\n" + while (g_io_channel_read_line(chan, &readbuf, &len, NULL, NULL) + == G_IO_STATUS_NORMAL) { parse_cmd_line(readbuf); - g_free (readbuf); - } - g_io_channel_unref (chan); + g_free (readbuf); + } + + g_io_channel_unref (chan); printf ("Config %s loaded\n", s->config_file); - } else { - fprintf(stderr, "uzbl: error loading file%s\n", s->config_file); - } + } else { + fprintf(stderr, "uzbl: error loading file%s\n", s->config_file); + } } else { printf ("No configuration file loaded.\n"); } -- cgit v1.2.3 From a759f9ca068fa219d171fcc9d79a4a063818de2d Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 16 May 2009 09:23:21 +0200 Subject: support dmenu vertical patch (with gracefull fallback to normal dmenu) --- examples/scripts/load_url_from_bookmarks.sh | 8 +++++++- examples/scripts/load_url_from_history.sh | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/examples/scripts/load_url_from_bookmarks.sh b/examples/scripts/load_url_from_bookmarks.sh index 35c772c..032c8fe 100755 --- a/examples/scripts/load_url_from_bookmarks.sh +++ b/examples/scripts/load_url_from_bookmarks.sh @@ -1,5 +1,11 @@ #!/bin/bash +if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]' +then + DMENU="dmenu -i -xs -rs -l 10" # vertical patch +else + DMENU="dmenu -i" +fi # you probably want your bookmarks file in your $XDG_DATA_HOME ( eg $HOME/.local/share/uzbl/bookmarks) if [ -f /usr/share/uzbl/examples/data/bookmarks ] then @@ -8,6 +14,6 @@ else file=./examples/data/bookmarks #useful when developing fi -goto=`awk '{print $1}' $file | dmenu -i` #NOTE: it's the job of the script that inserts bookmarks to make sure there are no dupes. +goto=`awk '{print $1}' $file | $DMENU` #NOTE: it's the job of the script that inserts bookmarks to make sure there are no dupes. #[ -n "$goto" ] && echo "uri $goto" > $4 [ -n "$goto" ] && uzblctrl -s $5 -c "uri $goto" diff --git a/examples/scripts/load_url_from_history.sh b/examples/scripts/load_url_from_history.sh index 3e2e2ee..aef7739 100755 --- a/examples/scripts/load_url_from_history.sh +++ b/examples/scripts/load_url_from_history.sh @@ -2,10 +2,17 @@ # you probably really want this in your $XDG_DATA_HOME (eg $HOME/.local/share/uzbl/history) history_file=/tmp/uzbl.history +if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]' +then + DMENU="dmenu -i -xs -rs -l 10" # vertical patch +else + DMENU="dmenu -i" +fi + # choose from all entries, sorted and uniqued # goto=`awk '{print $3}' $history_file | sort -u | dmenu -i` # choose from all entries, the first one being current url, and after that all others, sorted and uniqued. -current=`tail -n 1 $history_file | awk '{print $3}'`; goto=`(echo $current; awk '{print $3}' $history_file | grep -v "^$current\$" | sort -u) | dmenu -i` +current=`tail -n 1 $history_file | awk '{print $3}'`; goto=`(echo $current; awk '{print $3}' $history_file | grep -v "^$current\$" | sort -u) | $DMENU` #[ -n "$goto" ] && echo "uri $goto" > $4 [ -n "$goto" ] && uzblctrl -s $5 -c "uri $goto" -- cgit v1.2.3 From 7d6b9d5e9d61a75110708e002d7381c67bff0343 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 16 May 2009 09:36:05 +0200 Subject: fix for handlers in sample config --- examples/configs/sampleconfig-dev | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/configs/sampleconfig-dev b/examples/configs/sampleconfig-dev index 38f1274..d42957d 100644 --- a/examples/configs/sampleconfig-dev +++ b/examples/configs/sampleconfig-dev @@ -8,9 +8,9 @@ # from insert mode by combining them with the modkey # TODO: ability to attach misc things (spawn , script ,.. to internal events) -#set history_handler ./examples/scripts/history.sh -#set download_handler ./examples/scripts/download.sh -#set cookie_handler ./examples/scripts/cookies.sh +set history_handler = ./examples/scripts/history.sh +set download_handler = ./examples/scripts/download.sh +set cookie_handler = ./examples/scripts/cookies.sh -- cgit v1.2.3 From 87ad07963cdc6caf4a96bcbc485b366536c157b8 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 16 May 2009 09:44:44 +0200 Subject: regression fix: different command syntax for setting uris --- examples/scripts/load_url_from_bookmarks.sh | 4 ++-- examples/scripts/load_url_from_history.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/scripts/load_url_from_bookmarks.sh b/examples/scripts/load_url_from_bookmarks.sh index 032c8fe..2d19067 100755 --- a/examples/scripts/load_url_from_bookmarks.sh +++ b/examples/scripts/load_url_from_bookmarks.sh @@ -15,5 +15,5 @@ else fi goto=`awk '{print $1}' $file | $DMENU` #NOTE: it's the job of the script that inserts bookmarks to make sure there are no dupes. -#[ -n "$goto" ] && echo "uri $goto" > $4 -[ -n "$goto" ] && uzblctrl -s $5 -c "uri $goto" +#[ -n "$goto" ] && echo "cmd uri $goto" > $4 +[ -n "$goto" ] && uzblctrl -s $5 -c "cmd uri $goto" diff --git a/examples/scripts/load_url_from_history.sh b/examples/scripts/load_url_from_history.sh index aef7739..9dd56d2 100755 --- a/examples/scripts/load_url_from_history.sh +++ b/examples/scripts/load_url_from_history.sh @@ -14,5 +14,5 @@ fi # choose from all entries, the first one being current url, and after that all others, sorted and uniqued. current=`tail -n 1 $history_file | awk '{print $3}'`; goto=`(echo $current; awk '{print $3}' $history_file | grep -v "^$current\$" | sort -u) | $DMENU` -#[ -n "$goto" ] && echo "uri $goto" > $4 -[ -n "$goto" ] && uzblctrl -s $5 -c "uri $goto" +#[ -n "$goto" ] && echo "cmd uri $goto" > $4 +[ -n "$goto" ] && uzblctrl -s $5 -c "cmd uri $goto" -- cgit v1.2.3 From 2eb9dae768134ee685ee81bb6c257147b552d210 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 16 May 2009 09:49:21 +0200 Subject: reenable sockets --- examples/configs/sampleconfig-dev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/configs/sampleconfig-dev b/examples/configs/sampleconfig-dev index d42957d..cee74cd 100644 --- a/examples/configs/sampleconfig-dev +++ b/examples/configs/sampleconfig-dev @@ -32,7 +32,7 @@ set always_insert_mode = 0 #set max_conns_host 0 set fifo_dir = /tmp -#TODO socket dir +set socket_dir = /tmp #set status_top = 1 # Key bindings -- cgit v1.2.3 From 5202ec3fff80466fba649e4f1435237715727f53 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 16 May 2009 09:51:46 +0200 Subject: fix return for control_socket --- uzbl.c | 4 ++-- uzbl.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/uzbl.c b/uzbl.c index 7997753..5edc5e1 100644 --- a/uzbl.c +++ b/uzbl.c @@ -1101,7 +1101,7 @@ create_stdin () { } } -static void +static gboolean control_socket(GIOChannel *chan) { struct sockaddr_un remote; char buffer[512], *ctl_line; @@ -1152,7 +1152,7 @@ control_socket(GIOChannel *chan) { */ g_free(ctl_line); - return; + return TRUE; } static gchar* diff --git a/uzbl.h b/uzbl.h index 6f38052..e23fa69 100644 --- a/uzbl.h +++ b/uzbl.h @@ -279,7 +279,7 @@ create_stdin(); static gchar* init_socket(gchar *dir); -static void +static gboolean control_socket(GIOChannel *chan); static void -- cgit v1.2.3 From 262ccb5f3e120f1d48a63dc46ad7e7689a46ad83 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sat, 16 May 2009 09:56:42 +0200 Subject: document reset_command_mode in config + reorder a bit --- examples/configs/sampleconfig-dev | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/configs/sampleconfig-dev b/examples/configs/sampleconfig-dev index cee74cd..761a4f9 100644 --- a/examples/configs/sampleconfig-dev +++ b/examples/configs/sampleconfig-dev @@ -19,7 +19,12 @@ 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 MSG +set status_top = 0 + set modkey = Mod1 +# reset to command mode when new page is loaded +set reset_command_mode = 1 +# this var has precedence over reset_command_mode set always_insert_mode = 0 # to start a local socks server, do : ssh -fND localhost:8118 localhost #set proxy_url = http://127.0.0.1:8118 @@ -33,7 +38,6 @@ set always_insert_mode = 0 set fifo_dir = /tmp set socket_dir = /tmp -#set status_top = 1 # Key bindings bind j = scroll_vert 20 -- cgit v1.2.3