Go input¶
Example binding in rc.lua¶
bind.buf("^gi$", function (w)
w:emit_form_root_active_signal(w:eval_js_from_file(util.find_data("scripts/go_input.js")))
end),
note that it requires emit_form_active_signal(). If it has not been merged by Mason yet, you can add it manually at the end of window_helpers table:
diff --git a/rc.lua b/rc.lua
index d5478bb..d43b960 100755
--- a/rc.lua
+++ b/rc.lua
@@ -1193,6 +1193,16 @@ window_helpers = {
[i.input] = theme.input_font or theme.inputbar_font or font,
}) do wi.font = v end
end,
+
+ -- If argument is form-active or root-active, emits signal. Ignores all over
+ -- signals.
+ emit_form_root_active_signal = function (w, s)
+ if s == "form-active" then
+ w:get_current():emit_signal("form-active")
+ elseif s == "root-active" then
+ w:get_current():emit_signal("root-active")
+ end
+ end,
}
-- Create new window
go_input.js script¶
/* Based on go-input.js from Uzbl wiki originally posted by n30n */
var elements = document.querySelectorAll("textarea, input" + [
":not([type='button'])",
":not([type='checkbox'])",
":not([type='hidden'])",
":not([type='image'])",
":not([type='radio'])",
":not([type='reset'])",
":not([type='submit'])"].join(""));
function gi() {
if (elements) {
var el, i = 0;
while((el = elements[i++])) {
var style=getComputedStyle(el, null);
if (style.display !== 'none' && style.visibility === 'visible') {
if (el.type === "file") {
el.click();
}
else {
el.focus();
}
return "form-active";
}
}
}
return "root-active";
}
gi();