diff options
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | docs/INSTALL | 2 | ||||
-rw-r--r-- | examples/config/config | 43 | ||||
-rw-r--r-- | examples/data/plugins/bind.py | 71 | ||||
-rwxr-xr-x | examples/data/scripts/uzbl-event-manager | 24 | ||||
-rwxr-xr-x | misc/env.sh | 23 | ||||
-rwxr-xr-x | sandbox/env.sh | 13 |
7 files changed, 89 insertions, 93 deletions
@@ -66,6 +66,7 @@ test-uzbl-browser: uzbl-browser test-uzbl-core-sandbox: uzbl-core make DESTDIR=./sandbox RUN_PREFIX=`pwd`/sandbox/usr/local install-uzbl-core make DESTDIR=./sandbox RUN_PREFIX=`pwd`/sandbox/usr/local install-example-data + cp -np ./misc/env.sh ./sandbox/env.sh source ./sandbox/env.sh && uzbl-core --uri http://www.uzbl.org --verbose make DESTDIR=./sandbox uninstall rm -rf ./sandbox/usr @@ -74,6 +75,7 @@ test-uzbl-browser-sandbox: uzbl-browser make DESTDIR=./sandbox RUN_PREFIX=`pwd`/sandbox/usr/local install-uzbl-core make DESTDIR=./sandbox RUN_PREFIX=`pwd`/sandbox/usr/local install-uzbl-browser make DESTDIR=./sandbox RUN_PREFIX=`pwd`/sandbox/usr/local install-example-data + cp -np ./misc/env.sh ./sandbox/env.sh source ./sandbox/env.sh && uzbl-cookie-daemon restart -nv & source ./sandbox/env.sh && uzbl-event-manager restart -nav & source ./sandbox/env.sh && uzbl-browser --uri http://www.uzbl.org --verbose @@ -88,9 +90,9 @@ clean: rm -f events.o rm -f callbacks.o rm -f inspector.o - find examples/ -name "*.pyc" -delete + find ./examples/ -name "*.pyc" -delete cd ./tests/; $(MAKE) clean - rm -rf ./sandbox/{examples,usr}/ + rm -rf ./sandbox/ install: install-uzbl-core install-uzbl-browser install-uzbl-tabbed diff --git a/docs/INSTALL b/docs/INSTALL index 711ea97..c795502 100644 --- a/docs/INSTALL +++ b/docs/INSTALL @@ -9,8 +9,8 @@ From source You can pull the code from git or get a tagged tarball. $ git clone git://github.com/Dieterbe/uzbl.git - [ $ git checkout origin/experimental ] # optional. see below $ cd uzbl + [ $ git checkout origin/experimental ] # optional. see below $ make $ sudo make install If you want to remove uzbl again, you can issue: diff --git a/examples/config/config b/examples/config/config index d58d0a5..a2cbdcb 100644 --- a/examples/config/config +++ b/examples/config/config @@ -34,8 +34,6 @@ set shell_cmd = sh -c # Spawn path shortcuts. In spawn the first dir+path match is used in "dir1:dir2:dir3:executable" set scripts_dir = $XDG_DATA_HOME/uzbl:@prefix/share/uzbl/examples/data:scripts -# Javascipt helpers. -set jsh = js var run=Uzbl.run; function get(k){return run("print \\\@"+k)}; function set(k, v) {run("set "+k+" = "+v)}; # === Handlers =============================================================== @@ -69,10 +67,6 @@ set new_window = sh 'uzbl-browser -u $8' @on_event LOAD_FINISH @set_status <span foreground="gold">done</span> @on_event LOAD_FINISH spawn @scripts_dir/history.sh -# Generate a FORM_ACTIVE event if an editable -# element on the loaded site has initial focus -@on_event LOAD_FINISH js if(document.activeElement.type == 'text') {Uzbl.run("event FORM_ACTIVE");} - # Switch to insert mode if a (editable) html form is clicked @on_event FORM_ACTIVE @set_mode insert # Switch to command mode if anything else is clicked @@ -81,6 +75,7 @@ set new_window = sh 'uzbl-browser -u $8' # Example CONFIG_CHANGED event handler #@on_event CONFIG_CHANGED print Config changed: %1 = %2 + # === Behaviour and appearance =============================================== set show_status = 1 @@ -189,12 +184,8 @@ set ebind = @mode_bind global,-insert # === Mouse bindings ========================================================= -# Middle click -# if clicked on a link open the link in a new uzbl window -# otherwise open the selection in the current window -set load_from_xclip = sh 'echo "uri $(xclip -o)" > $4' -set open_new_window = sh 'uzbl-browser -u \@SELECTED_URI' -@bind <Button2> = @jsh if(get("SELECTED_URI")) { run("\@open_new_window"); } else { run("\\\@load_from_xclip"); } +# Middle click open in new window +@bind <Button2> = sh 'if [ "\@SELECTED_URI" ]; then uzbl-browser -u "\@SELECTED_URI"; else echo "uri $(xclip -o)" > $4; fi' # === Keyboard bindings ====================================================== @@ -240,6 +231,27 @@ set open_new_window = sh 'uzbl-browser -u \@SELECTED_URI' @cbind n = search @cbind N = search_reverse +# --- Uzbl tabbed binds --- +# Tab opening +@cbind gn = event NEW_TAB +@cbind go<uri:>_ = event NEW_TAB %s +@cbind gY = sh 'echo "event NEW_TAB `xclip -selection primary -o`" > $4' +# Closing / resting +@cbind gC = exit +@cbind gQ = event CLEAN_TABS +# Tab navigating +@cbind g< = event FIRST_TAB +@cbind g> = event LAST_TAB +@cbind gt = event NEXT_TAB +@cbind gT = event PREV_TAB +@cbind gi<index:>_ = event GOTO_TAB %s +# Preset loading +set preset = event PRESET_TABS +@cbind gs<preset save:>_ = @preset save %s +@cbind glo<preset load:>_ = @preset load %s +@cbind gd<preset del:>_ = @preset del %s +@cbind gli = @preset list + # --- Web searching binds --- @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 @@ -276,7 +288,8 @@ set toggle_cmd_ins = @toggle_modes command insert @cbind gh = uri http://www.uzbl.org # --- Yanking & pasting binds --- -@cbind y<Yank (t)itle or (u)rl:>* = @jsh if('%s' == 'u') { run("sh 'echo -n $6 | xclip'"); } else if('%s' == 't') { run("sh 'echo -n $7 | xclip'"); }; run('event SET_KEYCMD'); +@cbind yu = sh 'echo -n $6 | xclip' +@cbind yy = sh 'echo -n $7 | xclip' # Go the page from primary selection @cbind p = sh 'echo "uri `xclip -selection primary -o`" > $4' @@ -327,10 +340,6 @@ menu_editable_add Open in @external_editor = script @scripts_dir/extedit.js #@bind X1 = sh 'echo "set zoom_level = 1.0" > "$4"' #@bind X2 = sh 'echo "js alert (\\"This is sent by the shell via a fifo\\")" > "$4"' -# Working with the javascript helper variable jsh. -#@bind X3 = @jsh alert(get('zoom_level')); -#@bind X4 = @jsh if(get('mode') == "insert") { alert("You are in insert mode") } else { alert(get('mode')+" is a silly mode.") }; - # === Context menu items ===================================================== diff --git a/examples/data/plugins/bind.py b/examples/data/plugins/bind.py index 9e09337..a1a5d89 100644 --- a/examples/data/plugins/bind.py +++ b/examples/data/plugins/bind.py @@ -404,7 +404,6 @@ def mode_changed(uzbl, mode): def match_and_exec(uzbl, bind, depth, keylet, bindlet): - (on_exec, has_args, mod_cmd, glob, more) = bind[depth] cmd = keylet.modcmd if mod_cmd else keylet.keycmd @@ -432,24 +431,28 @@ def match_and_exec(uzbl, bind, depth, keylet, bindlet): elif more: bindlet.stack(bind, args, depth) + (on_exec, has_args, mod_cmd, glob, more) = bind[depth+1] + if not on_exec and has_args and not glob and not more: + exec_bind(uzbl, bind, *(args+['',])) + return False args = bindlet.args + args exec_bind(uzbl, bind, *args) - uzbl.set_mode() - if not has_args: + if not has_args or on_exec: + uzbl.set_mode() bindlet.reset() uzbl.clear_current() return True -def keycmd_update(uzbl, keylet): +def key_event(uzbl, keylet, mod_cmd=False, on_exec=False): bindlet = get_bindlet(uzbl) depth = bindlet.depth for bind in bindlet.get_binds(): t = bind[depth] - if t[MOD_CMD] or t[ON_EXEC]: + if (bool(t[MOD_CMD]) != mod_cmd) or (t[ON_EXEC] != on_exec): continue if match_and_exec(uzbl, bind, depth, keylet, bindlet): @@ -457,61 +460,29 @@ def keycmd_update(uzbl, keylet): bindlet.after() - -def keycmd_exec(uzbl, keylet): - bindlet = get_bindlet(uzbl) - depth = bindlet.depth - for bind in bindlet.get_binds(): - t = bind[depth] - if t[MOD_CMD] or not t[ON_EXEC]: - continue - - if match_and_exec(uzbl, bind, depth, keylet, bindlet): - return uzbl.clear_keycmd() - - bindlet.after() - - -def modcmd_update(uzbl, keylet): - bindlet = get_bindlet(uzbl) - depth = bindlet.depth - for bind in bindlet.get_binds(): - t = bind[depth] - if not t[MOD_CMD] or t[ON_EXEC]: - continue - - if match_and_exec(uzbl, bind, depth, keylet, bindlet): - return - - bindlet.after() - - -def modcmd_exec(uzbl, keylet): - bindlet = get_bindlet(uzbl) - depth = bindlet.depth - for bind in bindlet.get_binds(): - t = bind[depth] - if not t[MOD_CMD] or not t[ON_EXEC]: - continue - - if match_and_exec(uzbl, bind, depth, keylet, bindlet): - return uzbl.clear_modcmd() - - bindlet.after() + # Return to the previous mode if the KEYCMD_EXEC keycmd doesn't match any + # binds in the stack mode. + if on_exec and not mod_cmd and depth and depth == bindlet.depth: + uzbl.set_mode() def init(uzbl): # Event handling hooks. uzbl.connect_dict({ 'BIND': parse_bind, - 'KEYCMD_EXEC': keycmd_exec, - 'KEYCMD_UPDATE': keycmd_update, - 'MODCMD_EXEC': modcmd_exec, - 'MODCMD_UPDATE': modcmd_update, 'MODE_BIND': parse_mode_bind, 'MODE_CHANGED': mode_changed, }) + # Connect key related events to the key_event function. + events = [['KEYCMD_UPDATE', 'KEYCMD_EXEC'], + ['MODCMD_UPDATE', 'MODCMD_EXEC']] + + for mod_cmd in range(2): + for on_exec in range(2): + event = events[mod_cmd][on_exec] + uzbl.connect(event, key_event, bool(mod_cmd), bool(on_exec)) + # Function exports to the uzbl object, `function(uzbl, *args, ..)` # becomes `uzbl.function(*args, ..)`. uzbl.export_dict({ diff --git a/examples/data/scripts/uzbl-event-manager b/examples/data/scripts/uzbl-event-manager index 99b215a..9624b14 100755 --- a/examples/data/scripts/uzbl-event-manager +++ b/examples/data/scripts/uzbl-event-manager @@ -217,9 +217,13 @@ def daemonize(): def make_dirs(path): '''Make all basedirs recursively as required.''' - dirname = os.path.dirname(path) - if not os.path.isdir(dirname): - os.makedirs(dirname) + try: + dirname = os.path.dirname(path) + if not os.path.isdir(dirname): + os.makedirs(dirname) + + except OSError: + print_exc() def make_pid_file(pid_file): @@ -295,7 +299,7 @@ def parse_msg(uzbl, msg): cmd = FINDSPACES.split(msg, 3) if not cmd or cmd[0] != 'EVENT': # Not an event message. - print '---', msg + print '---', msg.encode('utf-8') return while len(cmd) < 4: @@ -333,12 +337,12 @@ class EventHandler(object): "function=%r" % self.function] if self.args: - args.append("args=%r" % self.args) + args.append(u"args=%r" % unicode(self.args)) if self.kargs: - args.append("kargs=%r" % self.kargs) + args.append(u"kargs=%r" % unicode(self.kargs)) - return "<EventHandler(%s)>" % ', '.join(args) + return u"<EventHandler(%s)>" % ', '.join(args) class UzblInstance(object): @@ -374,11 +378,11 @@ class UzblInstance(object): msg = msg.strip() if self.client_socket: - print '%s<-- %s' % (' ' * self.depth, msg) + print (u'%s<-- %s' % (' ' * self.depth, msg)).encode('utf-8') self.client_socket.send(("%s\n" % msg).encode('utf-8')) else: - print '%s!-- %s' % (' ' * self.depth, msg) + print (u'%s!-- %s' % (' ' * self.depth, msg)).encode('utf-8') def export(self, name, function): @@ -466,7 +470,7 @@ class UzblInstance(object): elems = [event,] if args: elems.append(unicode(args)) if kargs: elems.append(unicode(kargs)) - print "%s--> %s" % (' ' * self.depth, ' '.join(elems)) + print (u'%s--> %s' % (' ' * self.depth, ' '.join(elems))).encode('utf-8') if event == "INSTANCE_START" and args: self.pid = int(args[0]) diff --git a/misc/env.sh b/misc/env.sh new file mode 100755 index 0000000..4eec525 --- /dev/null +++ b/misc/env.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# This script is copied in to the sandbox/ directory during any sandbox make +# target and is used to create an isolated environment for uzbl-core, +# uzbl-browser and uzbl-tabbed to be run and tested. + +# It would be better to use something more flexible like $(dirname $0) but I +# couldn't get to work nicely from the Makefile: +# - Sourcing file gives $0 == /bin/sh +# - Executing limits scope of variables too much (even with exporting) +# Maybe we should spawn processes from here with an 'exec' at the end? + +# Re-define our home location inside the sandbox dir. +export HOME=./sandbox/home + +# Export default XDG_{DATA,CACHE,..}_HOME locations inside the sandbox +# directory according to defaults in the xdg specification. +# <http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html> +export XDG_DATA_HOME=$HOME/.local/share +export XDG_CACHE_HOME=$HOME/.cache +export XDG_CONFIG_HOME=$HOME/.config + +# Now update the path to include our sandbox bin directory. +export PATH="./sandbox/usr/local/bin:$PATH" diff --git a/sandbox/env.sh b/sandbox/env.sh deleted file mode 100755 index 122a7f2..0000000 --- a/sandbox/env.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# it would be better to use something more flexible like $(dirname $0) but i -# couldn't get to work nicely from the Makefile: -# - sourcing file gives $0 == /bin/sh -# - executing limits scope of variables too much (even with exporting) -# maybe we should spawn processes from here with an 'exec' at the end? - -export HOME=./sandbox/home -export XDG_DATA_HOME=$HOME/.local/share -export XDG_CACHE_HOME=$HOME/.cache -export XDG_CONFIG_HOME=$HOME/.config -#export PATH="./sandbox/usr/local/share/uzbl/examples/data/scripts/:$PATH" # needed when running uzbl-browser from here? don't think so.. -export PATH="./sandbox/usr/local/bin:$PATH" # needed to run uzbl-browser etc from here |