aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--AUTHORS2
-rw-r--r--Makefile24
-rw-r--r--README7
-rw-r--r--docs/FAQ81
-rw-r--r--examples/config/uzbl/config6
-rw-r--r--examples/data/uzbl/plugins/bind.py17
-rw-r--r--examples/data/uzbl/plugins/cmd_expand.py43
-rw-r--r--examples/data/uzbl/plugins/on_event.py18
-rwxr-xr-xexamples/data/uzbl/scripts/insert_bookmark.sh2
-rwxr-xr-xexamples/data/uzbl/scripts/uzbl-tabbed2
-rwxr-xr-xmisc/hash.sh (renamed from hash.sh)0
-rw-r--r--src/callbacks.c (renamed from callbacks.c)0
-rw-r--r--src/callbacks.h (renamed from callbacks.h)0
-rw-r--r--src/config.h (renamed from config.h)0
-rw-r--r--src/events.c (renamed from events.c)4
-rw-r--r--src/events.h (renamed from events.h)0
-rw-r--r--src/inspector.c (renamed from inspector.c)0
-rw-r--r--src/inspector.h (renamed from inspector.h)0
-rwxr-xr-xsrc/uzbl-browser (renamed from uzbl-browser)2
-rw-r--r--src/uzbl-core.c (renamed from uzbl-core.c)35
-rw-r--r--src/uzbl-core.h (renamed from uzbl-core.h)1
22 files changed, 179 insertions, 67 deletions
diff --git a/.gitignore b/.gitignore
index 3bdd4e9..803a154 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,6 @@
uzbl-core
*.o
+*.pyc
*~
tags
-examples/data
examples/config/enchant
diff --git a/AUTHORS b/AUTHORS
index 7d8d76e..b5d538f 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -17,6 +17,7 @@ In alphabetical order:
(neutralinsomniac) - load_progress = 0 fix
(salinasv) - move some variables to heap
(sentientswitch) - Cleaned up code. Added some commands.
+ (tczy) - patches
Aaron Griffin (phrakture) - Makefile patches to build on OSX
Abel Camarillo (00z) - various portability fixes, such as BSD fixes for Makefile and posix shell scripts
Aldrik Dunbar (n30n) - scroll % script
@@ -53,6 +54,7 @@ In alphabetical order:
Přemysl Hrubý (anydot) <email is dfenze AT gmail.com> - several C contributions and cleanups
Robert Manea (robm) <email is rob DOT manea AT gmail DOT com> - C code all over the place
Sergey Shepelev (temoto) - doc patch
+ Simon Lipp (sloonz) - various patches
Sylvester Johansson (scj) - form filler script & different take on link follower
Tassilo Horn (tsdh) - $VISUAL patch
Thorsten Wilms - logo design
diff --git a/Makefile b/Makefile
index 73b1b67..f48d1f0 100644
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,15 @@
# first entries are for gnu make, 2nd for BSD make. see http://lists.uzbl.org/pipermail/uzbl-dev-uzbl.org/2009-July/000177.html
-CFLAGS:=-std=c99 $(shell pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0) -ggdb -Wall -W -DARCH="\"$(shell uname -m)\"" -lgthread-2.0 -DCOMMIT="\"$(shell ./hash.sh)\"" $(CPPFLAGS) -fPIC -W -Wall -Wextra -pedantic
-CFLAGS!=echo -std=c99 `pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0` -ggdb -Wall -W -DARCH='"\""'`uname -m`'"\""' -lgthread-2.0 -DCOMMIT='"\""'`./hash.sh`'"\""' $(CPPFLAGS) -fPIC -W -Wall -Wextra -pedantic
+CFLAGS:=-std=c99 $(shell pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0) -ggdb -Wall -W -DARCH="\"$(shell uname -m)\"" -lgthread-2.0 -DCOMMIT="\"$(shell ./misc/hash.sh)\"" $(CPPFLAGS) -fPIC -W -Wall -Wextra -pedantic
+CFLAGS!=echo -std=c99 `pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0` -ggdb -Wall -W -DARCH='"\""'`uname -m`'"\""' -lgthread-2.0 -DCOMMIT='"\""'`./misc/hash.sh`'"\""' $(CPPFLAGS) -fPIC -W -Wall -Wextra -pedantic
LDFLAGS:=$(shell pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0) -pthread $(LDFLAGS)
LDFLAGS!=echo `pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0` -pthread $(LDFLAGS)
-SRC = uzbl-core.c events.c callbacks.c inspector.c
-OBJ = ${SRC:.c=.o}
+SRC = $(wildcard src/*.c)
+HEAD = $(wildcard src/*.h)
+TOBJ = $(SRC:.c=.o)
+OBJ = $(foreach obj, $(TOBJ), $(notdir $(obj)))
all: uzbl-browser options
@@ -25,9 +27,9 @@ options:
@${CC} -c ${CFLAGS} $<
@echo ... done.
-${OBJ}: uzbl-core.h events.h callbacks.h inspector.h config.h
+${OBJ}: ${HEAD}
-uzbl-core: ${OBJ}
+uzbl-core: ${TOBJ} # why doesn't ${OBJ} work?
@echo
@echo LINKING object files
@${CC} -o $@ ${OBJ} ${LDFLAGS}
@@ -59,7 +61,7 @@ test-uzbl-core: uzbl-core
./uzbl-core --uri http://www.uzbl.org --verbose
test-uzbl-browser: uzbl-browser
- ./uzbl-browser --uri http://www.uzbl.org --verbose
+ ./src/uzbl-browser --uri http://www.uzbl.org --verbose
test-uzbl-core-sandbox: uzbl-core
make DESTDIR=./sandbox RUN_PREFIX=`pwd`/sandbox/usr/local install-uzbl-core
@@ -94,9 +96,9 @@ install-uzbl-core: all
install -d $(INSTALLDIR)/bin
install -d $(INSTALLDIR)/share/uzbl/docs
install -d $(INSTALLDIR)/share/uzbl/examples
- cp -rp docs $(INSTALLDIR)/share/uzbl/
- cp -rp config.h $(INSTALLDIR)/share/uzbl/docs/
- cp -rp examples $(INSTALLDIR)/share/uzbl/
+ cp -rp docs $(INSTALLDIR)/share/uzbl/
+ cp -rp src/config.h $(INSTALLDIR)/share/uzbl/docs/
+ cp -rp examples $(INSTALLDIR)/share/uzbl/
install -m755 uzbl-core $(INSTALLDIR)/bin/uzbl-core
install -m644 AUTHORS $(INSTALLDIR)/share/uzbl/docs
install -m644 README $(INSTALLDIR)/share/uzbl/docs
@@ -104,7 +106,7 @@ install-uzbl-core: all
install-uzbl-browser:
install -d $(INSTALLDIR)/bin
- install -m755 uzbl-browser $(INSTALLDIR)/bin/uzbl-browser
+ install -m755 src/uzbl-browser $(INSTALLDIR)/bin/uzbl-browser
install -m755 examples/data/uzbl/scripts/uzbl-cookie-daemon $(INSTALLDIR)/bin/uzbl-cookie-daemon
install -m755 examples/data/uzbl/scripts/uzbl-event-manager $(INSTALLDIR)/bin/uzbl-event-manager
sed -i 's#^PREFIX=.*#PREFIX=$(RUN_PREFIX)#' $(INSTALLDIR)/bin/uzbl-browser
diff --git a/README b/README
index 0d6ed04..f46d552 100644
--- a/README
+++ b/README
@@ -206,6 +206,7 @@ Besides the builtin variables you can also define your own ones and use them in
- `scheme_handler`: handler to execute for each URI navigated to - the navigation request will be ignored if handler prints "USED\n"
- `fifo_dir`: location to store fifo's
- `socket_dir`: location to store sockets
+ - `print_events`: show events on stdout
- `http_debug`: http debug mode (value 0-3)
- `shell_cmd`: alias which will be expanded to use shell commands (eg sh -c)
- `proxy_url`: http traffic socks proxy (eg: http://<host>:<port>)
@@ -528,12 +529,14 @@ Basically all events have this format:
### COMMAND LINE ARGUMENTS
- uzbl [ uri ]
+ uzbl-core [OPTION...] [ uri ]
-u, --uri=URI Uri to load at startup (equivalent to 'uzbl <uri>' or 'set uri = URI' after uzbl has launched)
-v, --verbose Whether to print all messages or just errors.
- -n, --name=NAME Name of the current instance (defaults to Xorg window id)
+ -n, --name=NAME Name of the current instance (defaults to Xorg window id or random for GtkSocket mode)
-c, --config=FILE Path to config file or '-' for stdin
-s, --socket=SOCKET Socket ID
+ --connect-socket=CSOCKET Connect to server socket
+ -p, --print-events Whether to print events to stdout
-g, --geometry=GEOMETRY Set window geometry (format: WIDTHxHEIGHT+-X+-Y or maximized)
-V, --version Print the version and exit
--display=DISPLAY X display to use
diff --git a/docs/FAQ b/docs/FAQ
index 1c54ad1..3294999 100644
--- a/docs/FAQ
+++ b/docs/FAQ
@@ -24,21 +24,66 @@ tools and scripts, by itself doesn't do many usefull things. See README.
The layout of uzbl (and derivatives) only contains what you really need to see. we only have a statusbar, which even can also be disabled. There are no buttons, but we do
have lots of keybinding possibilities.
-### Why can uzbl-browser only show one page?
-Among uzbl hackers, there are 2 groups: some people prefer tabs, they use
-uzbl-tabbed. The others stick to "one page per uzbl-browser instance" because
-it's a very flexible approach. They believe "multiple instances management" is something that must
-be handled outside of uzbl by a separate/different program. Here are some solutions:
-
- * Many window managers can handle this by default. Xmonads tabbed layout, Wmii's stacked layout, fluxbox or kwin tabs and so on.
- * Uzbl supports acting as a GtkPlug to plug into GtkSockets (Xembed) so you can embed uzbl instances in other Gtk applications.
- (This is also what uzbl-tabbed does)
- * If you want highest customizablity, you need the 3rd option:
- You can also write a custom script. The only thing you need to do is focus/maximize the instance you want,
- keep the others out of sight and use tools like dmenu and wmctrl to switch instances.
- This allows you to use application-specific properties (such as uzbl tag, name etc).
- For more information about this approach, see docs/multiple-instances-management.
- (If you want to work on such script, let us know and we might include it along with the other sample scripts)
+### Why can uzbl-core/uzbl-browser only show one page?
+It is nearly unanimously agreed that one page per uzbl-core is best.
+It allows a simple implementation of both uzbl-core and
+uzbl-browser, and it makes things more robust.
+But read the next entry...
+
+### How to have multiple pages in one window?
+So, given that uzbl-core and uzbl-browser only deal with one page at a time (see
+above), how can you have a window with multiple pages?
+
+Basically this is involves concerns on two sides:
+
+* window management
+ - can I keep all pages together in 1 X window so that I can move all at once to a different workspace
+ - can I "split off" pages into separate windows (i.e. move only one specific page/window to a different desktop)
+ or merge windows together?
+ - can I integrate uzbl pages/windows into WM features? (alt-tab, tiling layouts, taskbar, ...)
+ - ...
+* application-level
+ - realtime overview of all page titles of all uzbl instances
+ - representation styles which are tightly coupled to the application such as treeviews that show from which you page you opened
+ others, or page state (loading etc)
+ - ...
+
+Uzbl itself can hardly be a limiting factor, as it supports/has:
+
+* Xembed (GtkPlug mode) so you can embed a uzbl-browser or uzbl-core into another window
+* an events system you can have realtime updates of window title, pageload state, etc.
+* command interface to programmatically change it's behavior.
+
+And then there is the style of representation (tabs, tree overviews, visual
+thumbnails etc) which can be handled from the WM side or the application
+side.
+
+There are multiple approaches, each with pros and cons.
+
+* Tabbing in the WM: Xmonads tabbed layout, Wmii's stacked layout, fluxbox or kwin tabs and so on.
+* Visual overview in the WM: commonly used with dwm or Awesome's tiling layouts with master/slave areas.
+ The [dynamic zoom script](http://www.uzbl.org/wiki/dynamic_zooming) is useful here.
+* A container application whih embeds multiple uzbl-browsers and provide tablists, tree views, and more.
+ Examples:
+ - [uzbl-tabbed](http://www.uzbl.org/wiki/uzbl_tabbed) (officially supported)
+ - [uzbltreetab](http://www.uzbl.org/wiki/uzbltreetab)
+ - [uzbltab](http://www.uzbl.org/wiki/uzbltab)
+ - [suckless tabbed](http://tools.suckless.org/tabbed)
+* An application to mimic tabbing independently of WM support.
+ The only thing you need to do is focus/maximize the instance you want,
+ keep the others out of sight and use tools like dmenu/xbindkeys and wmctrl to switch instances.
+ This allows you to use application-specific properties (such as uzbl tag, name etc).
+ For more ideas on such an approach, see docs/multiple-instances-management.
+ Examples:
+ - [wmctrl-based](http://www.uzbl.org/wiki/metacity-tabs) (works on at least Metacity)
+ - [wmii](http://www.uzbl.org/wiki/wmii)
+
+There are really a lot of options. You need to think about what you need,
+what you want and what you don't care about.
+On the wiki you'll find a lot of related scripts, some of them providing new
+workflows (do you really need open windows for all pages you intend to read, or is a list enough?
+[articlecue](http://www.uzbl.org/wiki/article_queue.py)), some providing integration with WM's such as
+[awesome](http://www.uzbl.org/wiki/awesome), and more.
### Okay, what can I actually do? What commands are there? How do I get more information?
* Commands and other features are documented in README. Read it.
@@ -75,6 +120,12 @@ They both have advantages and disadvantages:
So, when writing scripts, using fifo's is usually the fastest method (because you do not need to fork another process), so fifo is preferred unless you need a response.
+### Uzbl uses too much memory! Especially when having multiple windows (i.e. with uzbl-tabbed)
+Don't be fooled with how memory usage is measured and reported on Linux. (or other systems)
+You need to be aware of the difference between RSS and VSS.
+And dynamic libraries (libwebkit, libgtk, etc) that are used by multiple processes are only stored in RAM once.
+See [this page](http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html) for a good explanation.
+
### What the hell is this 'XDG' stuff??
You'll notice our example/default scripts and configs use variables such as `$XDG_CONFIG_HOME` and `$XDG_DATA_HOME`.
Most of us really like the [xdg basedir spec](http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html).
diff --git a/examples/config/uzbl/config b/examples/config/uzbl/config
index 9dc4a35..a6be6d6 100644
--- a/examples/config/uzbl/config
+++ b/examples/config/uzbl/config
@@ -230,9 +230,9 @@ set open_new_window = sh 'uzbl-browser -u \@SELECTED_URI'
@cbind N = search_reverse
# --- Web searching binds ---
-@cbind gg<Google:>_ = uri http://www.google.com/search?q=%s
-@cbind \\awiki<Archwiki:>_ = uri http://wiki.archlinux.org/index.php/Special:Search?search=%s&go=Go
-@cbind \\wiki<Wikipedia:>_ = uri http://en.wikipedia.org/w/index.php?title=Special:Search&search=%s&go=Go
+@cbind gg<Google:>_ = uri http://www.google.com/search?q=\@<encodeURIComponent(%r)>\@
+@cbind \\awiki<Archwiki:>_ = uri http://wiki.archlinux.org/index.php/Special:Search?search=\@<encodeURIComponent(%r)>\@&go=Go
+@cbind \\wiki<Wikipedia:>_ = uri http://en.wikipedia.org/w/index.php?title=Special:Search&search=\@<encodeURIComponent(%r)>\@&go=Go
# --- Handy binds ---
# Set function shortcut
diff --git a/examples/data/uzbl/plugins/bind.py b/examples/data/uzbl/plugins/bind.py
index 1cba7b2..9614df6 100644
--- a/examples/data/uzbl/plugins/bind.py
+++ b/examples/data/uzbl/plugins/bind.py
@@ -303,20 +303,6 @@ class Bind(object):
return self._repr_cache
-def expand(cmd, args):
- '''Replaces "%s %1 %2 %3..." with "<all args> <arg 0> <arg 1>...".'''
-
- if '%s' in cmd:
- cmd = cmd.replace('%s', ' '.join(map(unicode, args)))
-
- for (index, arg) in enumerate(args):
- index += 1
- if '%%%d' % index in cmd:
- cmd = cmd.replace('%%%d' % index, unicode(arg))
-
- return cmd
-
-
def exec_bind(uzbl, bind, *args, **kargs):
'''Execute bind objects.'''
@@ -332,8 +318,9 @@ def exec_bind(uzbl, bind, *args, **kargs):
raise ArgumentError('cannot supply kargs for uzbl commands')
commands = []
+ cmd_expand = uzbl.cmd_expand
for cmd in bind.commands:
- cmd = expand(cmd, args)
+ cmd = cmd_expand(cmd, args)
uzbl.send(cmd)
diff --git a/examples/data/uzbl/plugins/cmd_expand.py b/examples/data/uzbl/plugins/cmd_expand.py
new file mode 100644
index 0000000..a5c279d
--- /dev/null
+++ b/examples/data/uzbl/plugins/cmd_expand.py
@@ -0,0 +1,43 @@
+__export__ = ['cmd_expand',]
+
+
+def escape(str):
+ for (level, char) in [(3, '\\'), (2, "'"), (2, '"'), (1, '@')]:
+ str = str.replace(char, (level * '\\') + char)
+
+ return str
+
+
+def cmd_expand(uzbl, cmd, args):
+ '''Exports a function that provides the following
+ expansions in any uzbl command string:
+
+ %s = replace('%s', ' '.join(args))
+ %r = replace('%r', "'%s'" % escaped(' '.join(args)))
+ %1 = replace('%1', arg[0])
+ %2 = replace('%2', arg[1])
+ %n = replace('%n', arg[n-1])
+ '''
+
+ # Ensure (1) all string representable and (2) correct string encoding.
+ args = map(unicode, args)
+
+ # Direct string replace.
+ if '%s' in cmd:
+ cmd = cmd.replace('%s', ' '.join(args))
+
+ # Escaped and quoted string replace.
+ if '%r' in cmd:
+ cmd = cmd.replace('%r', "'%s'" % escape(' '.join(args)))
+
+ # Arg index string replace.
+ for (index, arg) in enumerate(args):
+ index += 1
+ if '%%%d' % index in cmd:
+ cmd = cmd.replace('%%%d' % index, unicode(arg))
+
+ return cmd
+
+
+def init(*args):
+ pass
diff --git a/examples/data/uzbl/plugins/on_event.py b/examples/data/uzbl/plugins/on_event.py
index afee4e6..f1ad0c9 100644
--- a/examples/data/uzbl/plugins/on_event.py
+++ b/examples/data/uzbl/plugins/on_event.py
@@ -2,6 +2,7 @@
Formatting options:
%s = space separated string of the arguments
+ %r = escaped and quoted version of %s
%1 = argument 1
%2 = argument 2
%n = argument n
@@ -44,20 +45,6 @@ def get_on_events(uzbl):
return UZBLS[uzbl]
-def expand(cmd, args):
- '''Replaces "%s %1 %2 %3..." with "<all args> <arg 0> <arg 1>...".'''
-
- if '%s' in cmd:
- cmd = cmd.replace('%s', ' '.join(map(unicode, args)))
-
- for (index, arg) in enumerate(args):
- index += 1
- if '%%%d' % index in cmd:
- cmd = cmd.replace('%%%d' % index, unicode(arg))
-
- return cmd
-
-
def event_handler(uzbl, *args, **kargs):
'''This function handles all the events being watched by various
on_event definitions and responds accordingly.'''
@@ -68,8 +55,9 @@ def event_handler(uzbl, *args, **kargs):
return
commands = events[event]
+ cmd_expand = uzbl.cmd_expand
for cmd in commands:
- cmd = expand(cmd, args)
+ cmd = cmd_expand(cmd, args)
uzbl.send(cmd)
diff --git a/examples/data/uzbl/scripts/insert_bookmark.sh b/examples/data/uzbl/scripts/insert_bookmark.sh
index e04e6d4..c34e7db 100755
--- a/examples/data/uzbl/scripts/insert_bookmark.sh
+++ b/examples/data/uzbl/scripts/insert_bookmark.sh
@@ -6,6 +6,8 @@ file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/bookmarks
which zenity &>/dev/null || exit 2
entry=`zenity --entry --text="Add bookmark. add tags after the '\t', separated by spaces" --entry-text="$6 $7\t"`
+exitstatus=$?
+if [ $exitstatus -ne 0 ]; then exit $exitstatus; fi
url=`echo $entry | awk '{print $1}'`
# TODO: check if already exists, if so, and tags are different: ask if you want to replace tags
diff --git a/examples/data/uzbl/scripts/uzbl-tabbed b/examples/data/uzbl/scripts/uzbl-tabbed
index bb9b9a2..d93a3f4 100755
--- a/examples/data/uzbl/scripts/uzbl-tabbed
+++ b/examples/data/uzbl/scripts/uzbl-tabbed
@@ -1010,7 +1010,7 @@ class UzblTabbed:
instance.'''
binds = []
- bind_format = r'bind %s = sh "echo \"%s\" > \"%s\""'
+ bind_format = r'@bind %s = sh "echo \"%s\" > \"%s\""'
bind = lambda key, action: binds.append(bind_format % (key, action,\
self.fifo_socket))
diff --git a/hash.sh b/misc/hash.sh
index 0c97722..0c97722 100755
--- a/hash.sh
+++ b/misc/hash.sh
diff --git a/callbacks.c b/src/callbacks.c
index dab92c1..dab92c1 100644
--- a/callbacks.c
+++ b/src/callbacks.c
diff --git a/callbacks.h b/src/callbacks.h
index 3f318f2..3f318f2 100644
--- a/callbacks.h
+++ b/src/callbacks.h
diff --git a/config.h b/src/config.h
index e9b9a8e..e9b9a8e 100644
--- a/config.h
+++ b/src/config.h
diff --git a/events.c b/src/events.c
index 719dc44..acb554c 100644
--- a/events.c
+++ b/src/events.c
@@ -169,8 +169,8 @@ send_event(int type, const gchar *details, const gchar *custom_event) {
}
if(event_message->str) {
- /* TODO: a means to select the interface to which events are sent */
- send_event_stdout(event_message);
+ if(uzbl.state.events_stdout)
+ send_event_stdout(event_message);
send_event_socket(event_message);
g_string_free(event_message, TRUE);
diff --git a/events.h b/src/events.h
index 7b8f58b..7b8f58b 100644
--- a/events.h
+++ b/src/events.h
diff --git a/inspector.c b/src/inspector.c
index de3dbcd..de3dbcd 100644
--- a/inspector.c
+++ b/src/inspector.c
diff --git a/inspector.h b/src/inspector.h
index 57d0ca9..57d0ca9 100644
--- a/inspector.h
+++ b/src/inspector.h
diff --git a/uzbl-browser b/src/uzbl-browser
index eebf9e3..d9b9752 100755
--- a/uzbl-browser
+++ b/src/uzbl-browser
@@ -63,4 +63,4 @@ DAEMON_PID=${DAEMON_SOCKET}.pid
uzbl-event-manager -va start
#fi
-uzbl-core "$@" --connect-socket $DAEMON_SOCKET | grep -v ^EVENT
+uzbl-core "$@" --connect-socket $DAEMON_SOCKET
diff --git a/uzbl-core.c b/src/uzbl-core.c
index fd8ee41..bc294b4 100644
--- a/uzbl-core.c
+++ b/src/uzbl-core.c
@@ -53,6 +53,8 @@ GOptionEntry entries[] =
"Socket ID", "SOCKET" },
{ "connect-socket", 0, 0, G_OPTION_ARG_STRING_ARRAY, &uzbl.state.connect_socket_names,
"Connect to server socket", "CSOCKET" },
+ { "print-events", 'p', 0, G_OPTION_ARG_NONE, &uzbl.state.events_stdout,
+ "Whether to print events to stdout.", NULL },
{ "geometry", 'g', 0, G_OPTION_ARG_STRING, &uzbl.gui.geometry,
"Set window geometry (format: WIDTHxHEIGHT+-X+-Y or maximized)", "GEOMETRY" },
{ "version", 'V', 0, G_OPTION_ARG_NONE, &uzbl.behave.print_version,
@@ -85,6 +87,7 @@ const struct var_name_to_ptr_t {
/* ---------------------------------------------------------------------------------------------- */
{ "uri", PTR_V_STR(uzbl.state.uri, 1, cmd_load_uri)},
{ "verbose", PTR_V_INT(uzbl.state.verbose, 1, NULL)},
+ { "print_events", PTR_V_INT(uzbl.state.events_stdout, 1, NULL)},
{ "inject_html", PTR_V_STR(uzbl.behave.inject_html, 0, cmd_inject_html)},
{ "geometry", PTR_V_STR(uzbl.gui.geometry, 1, cmd_set_geometry)},
{ "keycmd", PTR_V_STR(uzbl.state.keycmd, 1, NULL)},
@@ -1050,6 +1053,7 @@ eval_js(WebKitWebView * web_view, gchar *script, GString *result) {
JSStringRef js_script;
JSValueRef js_result;
+ JSValueRef js_exc = NULL;
JSStringRef js_result_string;
size_t js_result_size;
@@ -1067,7 +1071,7 @@ eval_js(WebKitWebView * web_view, gchar *script, GString *result) {
/* evaluate the script and get return value*/
js_script = JSStringCreateWithUTF8CString(script);
- js_result = JSEvaluateScript(context, js_script, globalobject, NULL, 0, NULL);
+ js_result = JSEvaluateScript(context, js_script, globalobject, NULL, 0, &js_exc);
if (js_result && !JSValueIsUndefined(context, js_result)) {
js_result_string = JSValueToStringCopy(context, js_result, NULL);
js_result_size = JSStringGetMaximumUTF8CStringSize(js_result_string);
@@ -1080,6 +1084,35 @@ eval_js(WebKitWebView * web_view, gchar *script, GString *result) {
JSStringRelease(js_result_string);
}
+ else if (js_exc && JSValueIsObject(context, js_exc)) {
+ size_t size;
+ JSStringRef prop, val;
+ JSObjectRef exc = JSValueToObject(context, js_exc, NULL);
+
+ printf("Exception occured while executing script:\n");
+
+ /* Print line */
+ prop = JSStringCreateWithUTF8CString("line");
+ val = JSValueToStringCopy(context, JSObjectGetProperty(context, exc, prop, NULL), NULL);
+ size = JSStringGetMaximumUTF8CStringSize(val);
+ if(size) {
+ char cstr[size];
+ JSStringGetUTF8CString(val, cstr, size);
+ printf("At line %s: ", cstr);
+ }
+ JSStringRelease(prop);
+ JSStringRelease(val);
+
+ /* Print message */
+ val = JSValueToStringCopy(context, exc, NULL);
+ size = JSStringGetMaximumUTF8CStringSize(val);
+ if(size) {
+ char cstr[size];
+ JSStringGetUTF8CString(val, cstr, size);
+ printf("%s\n", cstr);
+ }
+ JSStringRelease(val);
+ }
/* cleanup */
JSObjectDeleteProperty(context, globalobject, var_name, NULL);
diff --git a/uzbl-core.h b/src/uzbl-core.h
index 83fa4b2..df9eb1a 100644
--- a/uzbl-core.h
+++ b/src/uzbl-core.h
@@ -93,6 +93,7 @@ typedef struct {
gchar* keycmd;
gchar* searchtx;
gboolean verbose;
+ gboolean events_stdout;
GPtrArray *event_buffer;
gchar** connect_socket_names;
GdkEventButton *last_button;