diff options
author | Brendan Taylor <whateley@gmail.com> | 2010-11-24 15:13:02 -0700 |
---|---|---|
committer | Brendan Taylor <whateley@gmail.com> | 2010-11-24 15:13:02 -0700 |
commit | b5b38b968697becad4034b5803d39ff6c78aa107 (patch) | |
tree | 4160a304f1dde3d728b39aa0c6ff107cb9951041 | |
parent | 3659b1d8bc32956d1be5e25a6c30a085953f0435 (diff) |
make follow.sh use the utils scripts, restore mode changing functionality
-rw-r--r-- | examples/data/scripts/follow.js | 15 | ||||
-rwxr-xr-x | examples/data/scripts/follow.sh | 36 |
2 files changed, 30 insertions, 21 deletions
diff --git a/examples/data/scripts/follow.js b/examples/data/scripts/follow.js index 3a18b1b..d995696 100644 --- a/examples/data/scripts/follow.js +++ b/examples/data/scripts/follow.js @@ -119,30 +119,37 @@ function generateHint(el, label) { // hint.style.webkitTransform = 'scale(1) rotate(0deg) translate(-6px,-5px)'; return hint; } -//Here we choose what to do with an element if we -//want to "follow" it. On form elements we "select" -//or pass the focus, on links we try to perform a click, -//but at least set the href of the link. (needs some improvements) + +// Here we choose what to do with an element that the user has selected. +// Form elements get selected and/or focussed, and links and buttons are +// clicked. This function returns "XXXRESET_MODEXXX" to indicate that uzbl +// should be reset to command mode with an empty keycmd, or +// "XXX_EMIT_FORM_ACTIVEXXX" to indicate that uzbl should be set to insert mode. function clickElem(item) { removeAllHints(); if (item) { var name = item.tagName; if (name == 'BUTTON') { item.click(); + return "XXXRESET_MODEXXX"; } else if (name == 'INPUT') { var type = item.type.toUpperCase(); if (type == 'TEXT' || type == 'SEARCH' || type == 'PASSWORD') { item.focus(); item.select(); + return "XXXEMIT_FORM_ACTIVEXXX"; } else { item.click(); + return "XXXRESET_MODEXXX"; } } else if (name == 'TEXTAREA' || name == 'SELECT') { item.focus(); item.select(); + return "XXXEMIT_FORM_ACTIVEXXX"; } else { item.click(); window.location = item.href; + return "XXXRESET_MODEXXX"; } } } diff --git a/examples/data/scripts/follow.sh b/examples/data/scripts/follow.sh index ba59575..c8ded84 100755 --- a/examples/data/scripts/follow.sh +++ b/examples/data/scripts/follow.sh @@ -1,21 +1,23 @@ #!/bin/sh -config=$1; -shift -pid=$1; -shift -xid=$1; -shift -fifo=$1; -shift -socket=$1; -shift -url=$1; -shift -title=$1; -shift +# This script is just a wrapper around follow.js that lets us change uzbl's mode +# after a link is selected. -case $(echo 'script @scripts_dir/follow.js "@{follow_hint_keys} '$1'"' | socat - unix-connect:$socket) in - *XXXEMIT_FORM_ACTIVEXXX*) echo 'event FORM_ACTIVE' | socat - unix-connect:$socket ;; - *XXXRESET_MODEXXX*) echo 'set mode=' | socat - unix-connect:$socket ;; +. "$UZBL_UTIL_DIR"/uzbl-args.sh + +# if socat is installed then we can change Uzbl's input mode once a link is +# selected; otherwise we just select a link. +if ! which socat >/dev/null 2>&1; then + echo 'script @scripts_dir/follow.js "@{follow_hint_keys} '$1'"' > "$UZBL_FIFO" + exit +fi + +result=$(echo 'script @scripts_dir/follow.js "@{follow_hint_keys} '$1'"' | socat - unix-connect:"$UZBL_SOCKET") +case $result in + *XXXEMIT_FORM_ACTIVEXXX*) + # a form element was selected + echo 'event FORM_ACTIVE' > "$UZBL_FIFO" ;; + *XXXRESET_MODEXXX*) + # a link was selected, reset uzbl's input mode + echo 'set mode=' > "$UZBL_FIFO" ;; esac |