void hints_create(Client* c, const char* input, guint mode, const guint prefixLength)
{
char* js = NULL;
- char type;
+ char type, usage;
if (CLEAN_MODE(c->state.mode) != VP_MODE_HINTING) {
Style* style = &core.style;
c->hints.prefixLength = prefixLength;
type = 'i';
}
- js = g_strdup_printf("%s.create('%s', '%c');", HINT_VAR, input ? input : "", type);
+ if (mode & HINTS_PROCESS_OPEN) {
+ usage = mode & HINTS_OPEN_NEW ? 'T' : 'O';
+ } else {
+ usage = 'U';
+ }
+
+ js = g_strdup_printf(
+ "%s.create('%s', '%c', '%c');",
+ HINT_VAR,
+ input ? input : "", type,
+ usage
+ );
hints_run_script(c, js);
g_free(js);
}
hints_observe_input(c, FALSE);
Arg a = {0};
char* v = (value + 5);
- if (mode & HINTS_PROCESS_OPEN) {
- a.s = v;
- a.i = (mode & HINTS_OPEN_NEW) ? VP_TARGET_NEW : VP_TARGET_CURRENT;
- command_open(c, &a);
- } else if (mode & HINTS_PROCESS_INPUT) {
+ if (mode & HINTS_PROCESS_INPUT) {
a.s = g_strconcat((mode & HINTS_OPEN_NEW) ? ":tabopen " : ":open ", v, NULL);
command_input(c, &a);
g_free(a.s);
} else if (c->hints.change_handler && c->hints.keypress_handler) {
g_signal_handler_disconnect(G_OBJECT(c->gui.inputbox), c->hints.change_handler);
g_signal_handler_disconnect(G_OBJECT(c->gui.inputbox), c->hints.keypress_handler);
-
+
c->hints.change_handler = c->hints.keypress_handler = 0;
/* clear the input box - TODO move this to a better place */
var curFocusNum = 1;
var hints = [];
var mode;
+ /* O - open, T - open in new window, U - use source */
+ var usage;
- this.create = function(inputText, hintMode)
+ this.create = function(inputText, hintMode, resultUsage)
{
if (hintMode) {
mode = hintMode;
}
+ if (resultUsage) {
+ usage = resultUsage;
+ }
var topwin = window;
var top_height = topwin.innerHeight;
return "DONE:";
}
- return "DATA:" + _getSrc(el);;
+ switch (usage) {
+ case "T": _openNewWindow(el); return "DONE:";
+ case "O": _open(el); return "DONE:";
+ default: return "DATA:" + _getSrc(el);
+ }
};
+ /* opens given element */
+ function _open(elem)
+ {
+ if (elem.target == "_blank") {
+ elem.removeAttribute("target");
+ }
+ _mouseEvent(elem, "moudedown", 0);
+ _mouseEvent(elem, "click", 0);
+ }
+
+ /* opens given element into new window */
+ function _openNewWindow(elem)
+ {
+ var oldTarget = elem.target;
+
+ /* set target to open in new window */
+ elem.target = "_blank";
+ _mouseEvent(elem, "moudedown");
+ _mouseEvent(elem, "click");
+ elem.target = oldTarget;
+ }
+
+
/* set focus on hint with given number */
function _focus(n)
{