From c7cf3ef494c7e971c7884bb8e5ba93c9c5e9b32d Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 13 Apr 2011 22:15:53 -0400 Subject: Handle returning a uri selected by follow.js --- examples/data/scripts/follow.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/data/scripts/follow.js b/examples/data/scripts/follow.js index b7b0d82..ad71674 100644 --- a/examples/data/scripts/follow.js +++ b/examples/data/scripts/follow.js @@ -222,7 +222,7 @@ uzbl.follow.followLinks = function(follow) { //var desc = '*[title], img[alt], applet[alt], area[alt], input[alt]'; //var image = 'img, input[type=image]'; - if(newwindow) + if(newwindow || returnuri) var res = this.query(uri); else var res = this.query(followable); @@ -237,6 +237,11 @@ uzbl.follow.followLinks = function(follow) { // clear all of our hints this.clearHints(); + if (returnuri) { + var uri = el.src || el.href; + return "XXXRETURNED_URIXXX" + uri + } + if (newwindow) { // we're opening a new window using the URL attached to this element var uri = el.src || el.href; -- cgit v1.2.3 From 0809e47599aeb86b851a3338b71602f69306dfed Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 13 Apr 2011 22:16:34 -0400 Subject: Handle returned uris in the follow.sh wrapper --- examples/data/scripts/follow.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/data/scripts/follow.sh b/examples/data/scripts/follow.sh index 014793e..01a4f91 100755 --- a/examples/data/scripts/follow.sh +++ b/examples/data/scripts/follow.sh @@ -1,7 +1,13 @@ #!/bin/sh # This scripts acts on the return value of followLinks in follow.js -case "$1" in +result=$1 +shift + +uriaction=$1 +shift + +case "$result" in XXXEMIT_FORM_ACTIVEXXX) # a form element was selected printf 'event FORM_ACTIVE\nevent KEYCMD_CLEAR\n' > "$UZBL_FIFO" @@ -10,4 +16,12 @@ case "$1" in # a link was selected, reset uzbl's input mode printf 'set mode=\nevent KEYCMD_CLEAR\n' > "$UZBL_FIFO" ;; + XXXRETURNED_URIXXX*) + uri=${result#XXXRETURNED_URIXXX} + + case "$uriaction" in + set) + printf 'uri '"$uri"'\nset mode=\nevent KEYCMD_CLEAR\n' > "$UZBL_FIFO" + ;; + esac esac -- cgit v1.2.3 From 5931675528cd29642987512acbc08142d5699f6a Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 13 Apr 2011 22:16:52 -0400 Subject: Add binding for going to the uri of a target Also ports old commands to new structure. --- examples/config/config | 5 +++-- examples/data/scripts/follow.js | 11 ++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/config/config b/examples/config/config index d049f0e..b8312e5 100644 --- a/examples/config/config +++ b/examples/config/config @@ -343,8 +343,9 @@ set follow_hint_keys = 0123456789 #set follow_hint_keys = qwerty #set follow_hint_keys = asdfghjkl; #set follow_hint_keys = thsnd-rcgmvwb/;789aefijkopquxyz234 -@cbind fl* = spawn @scripts_dir/follow.sh \@< uzbl.follow("\@follow_hint_keys", "%s", 0) >\@ -@cbind Fl* = spawn @scripts_dir/follow.sh \@< uzbl.follow("\@follow_hint_keys", "%s", 1) >\@ +@cbind fl* = spawn @scripts_dir/follow.sh \@< uzbl.follow("\@follow_hint_keys", "%s", 'click') >\@ +@cbind Fl* = spawn @scripts_dir/follow.sh \@< uzbl.follow("\@follow_hint_keys", "%s", 'newwindow') >\@ +@cbind fL* = spawn @scripts_dir/follow.sh \@< uzbl.follow("\@follow_hint_keys", "%s", 'returnuri') >\@ set @cbind fi = spawn @scripts_dir/go_input.sh # Form filler binds diff --git a/examples/data/scripts/follow.js b/examples/data/scripts/follow.js index ad71674..22175ca 100644 --- a/examples/data/scripts/follow.js +++ b/examples/data/scripts/follow.js @@ -16,7 +16,16 @@ uzbldivid = 'uzbl_link_hints'; uzbl.follow = function() { // Export charset = arguments[0]; - newwindow = arguments[2]; + if (arguments[2] == 'click') { + newwindow = false; + returnuri = false; + } else if (arguments[2] == 'newwindow') { + newwindow = true; + returnuri = false; + } else if (arguments[2] == 'returnuri') { + newwindow = false; + returnuri = true; + } var keypress = arguments[1]; return arguments.callee.followLinks(keypress); -- cgit v1.2.3 From 1b171ea59fffa3df92aa4b3b1604c911a77b9c3a Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 14 Apr 2011 22:58:05 -0400 Subject: Ignore errors when attaching labels --- examples/data/scripts/follow.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/data/scripts/follow.js b/examples/data/scripts/follow.js index 22175ca..782b1d1 100644 --- a/examples/data/scripts/follow.js +++ b/examples/data/scripts/follow.js @@ -178,9 +178,13 @@ uzbl.follow.reDrawHints = function(elems, chars) { elements.forEach(function(el, i) { var label = labels[i]; var pos = positions[i]; - var doc = uzbl.follow.getDocument(el); - var h = uzbl.follow.generateHint(doc, el, label, pos[0], pos[1]); - doc.hintdiv.appendChild(h); + try { + var doc = uzbl.follow.getDocument(el); + var h = uzbl.follow.generateHint(doc, el, label, pos[0], pos[1]); + doc.hintdiv.appendChild(h); + } catch (err) { + // Unable to attach label -> shrug it off and continue + } }); } -- cgit v1.2.3 From a4ec13b670c5e27483aa388a1ef03a15b8bba935 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 20 Apr 2011 21:29:48 -0400 Subject: Add binding to copy a link to the clipboard --- examples/config/config | 1 + examples/data/scripts/follow.sh | 3 +++ 2 files changed, 4 insertions(+) (limited to 'examples') diff --git a/examples/config/config b/examples/config/config index b8312e5..8ed533f 100644 --- a/examples/config/config +++ b/examples/config/config @@ -346,6 +346,7 @@ set follow_hint_keys = 0123456789 @cbind fl* = spawn @scripts_dir/follow.sh \@< uzbl.follow("\@follow_hint_keys", "%s", 'click') >\@ @cbind Fl* = spawn @scripts_dir/follow.sh \@< uzbl.follow("\@follow_hint_keys", "%s", 'newwindow') >\@ @cbind fL* = spawn @scripts_dir/follow.sh \@< uzbl.follow("\@follow_hint_keys", "%s", 'returnuri') >\@ set +@cbind FL* = spawn @scripts_dir/follow.sh \@< uzbl.follow("\@follow_hint_keys", "%s", 'returnuri') >\@ clipboard @cbind fi = spawn @scripts_dir/go_input.sh # Form filler binds diff --git a/examples/data/scripts/follow.sh b/examples/data/scripts/follow.sh index 01a4f91..262aec3 100755 --- a/examples/data/scripts/follow.sh +++ b/examples/data/scripts/follow.sh @@ -23,5 +23,8 @@ case "$result" in set) printf 'uri '"$uri"'\nset mode=\nevent KEYCMD_CLEAR\n' > "$UZBL_FIFO" ;; + clipboard) + printf "$uri" | xclip + ;; esac esac -- cgit v1.2.3 From f39423189b7e564656a241c22ff6eb7fc03bd8c9 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 20 Apr 2011 21:39:44 -0400 Subject: Factor out the clearing of the labels --- examples/data/scripts/follow.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/data/scripts/follow.sh b/examples/data/scripts/follow.sh index 262aec3..f08bd29 100755 --- a/examples/data/scripts/follow.sh +++ b/examples/data/scripts/follow.sh @@ -21,10 +21,11 @@ case "$result" in case "$uriaction" in set) - printf 'uri '"$uri"'\nset mode=\nevent KEYCMD_CLEAR\n' > "$UZBL_FIFO" + printf 'uri '"$uri"'\n' > "$UZBL_FIFO" ;; clipboard) printf "$uri" | xclip ;; esac + printf 'set mode=\nevent KEYCMD_CLEAR\n' > "$UZBL_FIFO" esac -- cgit v1.2.3