1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 00:17:57 +01:00

<return> support for hints

This commit is contained in:
Martin Stubenschrott
2007-10-24 21:20:10 +00:00
parent 701496cd0a
commit d9856b3f06
2 changed files with 46 additions and 12 deletions

View File

@@ -336,24 +336,58 @@ outer:
this.onEvent = function(event) this.onEvent = function(event)
{ {
var num = String.fromCharCode(event.charCode).toLowerCase(); var key = vimperator.events.toString(event);
linkNumString += "" + num; var endAfterThisKey = false;
//setTimeout( function() { canUpdate = true; }, timeout); switch (key)
{
case "<Return>":
endAfterThisKey = true;
//if (valid_hints.length == 0)
//{
// vimperator.beep();
// vimperator.modes.reset();
// return;
//}
//else
// valid_hints = [valid_hints[0]];
break;
case "<Space>":
linkNumString += " ";
break;
case "<BS>":
if (linkNumString = "")
{
vimperator.beep();
return;
}
else
linkNumString = linkNumString.substr(0, linkNumString.length-1);
break;
default:
linkNumString += key;
}
vimperator.statusline.updateInputBuffer(linkNumString); vimperator.statusline.updateInputBuffer(linkNumString);
showHints(null, linkNumString); showHints(null, linkNumString);
if (valid_hints.length == 0) if (valid_hints.length == 0)
vimperator.beep(); vimperator.beep();
else if (valid_hints.length >= 1) else
{ {
var first_href = valid_hints[0].getAttribute("href") || null; if (!endAfterThisKey)
if (first_href)
{ {
if (valid_hints.some( function(e) { return e.getAttribute("href") != first_href; } )) var first_href = valid_hints[0].getAttribute("href") || null;
if (first_href)
{
if (valid_hints.some( function(e) { return e.getAttribute("href") != first_href; } ))
return;
}
else if (valid_hints.length > 1)
return; return;
} }
else if (valid_hints.length > 1)
return;
vimperator.echo(" "); vimperator.echo(" ");
vimperator.statusline.updateInputBuffer(""); vimperator.statusline.updateInputBuffer("");
@@ -388,7 +422,7 @@ outer:
setTimeout( function() { setTimeout( function() {
if (vimperator.mode == vimperator.modes.HINTS) if (vimperator.mode == vimperator.modes.HINTS)
vimperator.modes.reset(true); vimperator.modes.reset(true);
}, 500); }, endAfterThisKey ? 0 : 500);
} }
} }

View File

@@ -112,8 +112,8 @@ vimperator.modes = (function()
vimperator.options.setFirefoxPref("accessibility.browsewithcaret", false); vimperator.options.setFirefoxPref("accessibility.browsewithcaret", false);
vimperator.statusline.updateUrl(); vimperator.statusline.updateUrl();
// XXX: auto-focusing of content disabled, as it breaks hints partly // XXX: auto-focusing breaks hints partly, find a good solution
//vimperator.focusContent(); vimperator.focusContent();
} }
} }