mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 22:07:59 +01:00
move the global variable hah to vimperator.hints and fix bug #17254
This commit is contained in:
1
TODO
1
TODO
@@ -13,6 +13,7 @@ BUGS:
|
||||
dpb| 09:11:50 dpb :: and this happens only when saving the complete
|
||||
webpage, saving only the html works just fine..
|
||||
- <ESC> key closes :addons and other XUL windows
|
||||
- add window resize support to hints
|
||||
|
||||
FEATURES:
|
||||
9 :map commands to keys
|
||||
|
||||
@@ -29,13 +29,13 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
||||
/* [command, action, cancel_hint_mode, always_active] */
|
||||
var g_hint_mappings = [ //{{{
|
||||
/* hint action keys */
|
||||
["o", "hah.openHints(false, false);", true, false],
|
||||
["t", "hah.openHints(true, false);", true, false],
|
||||
["<C-w>", "hah.openHints(false, true );", true, false],
|
||||
["o", "vimperator.hints.openHints(false, false);", true, false],
|
||||
["t", "vimperator.hints.openHints(true, false);", true, false],
|
||||
["<C-w>", "vimperator.hints.openHints(false, true );", true, false],
|
||||
["s", "vimperator.echoerr('Saving of links not yet implemented');", true, false],
|
||||
["y", "hah.yankUrlHints();", true, false],
|
||||
["Y", "hah.yankTextHints();", true, false],
|
||||
[",", "g_inputbuffer+=','; hah.setCurrentState(0);", false, true],
|
||||
["y", "vimperator.hints.yankUrlHints();", true, false],
|
||||
["Y", "vimperator.hints.yankTextHints();", true, false],
|
||||
[",", "g_inputbuffer+=','; vimperator.hints.setCurrentState(0);", false, true],
|
||||
[":", "vimperator.commandline.open(':', '', vimperator.modes.EX);", false, true],
|
||||
/* movement keys */
|
||||
["<C-e>", "scrollBufferRelative(0, 1);", false, true],
|
||||
@@ -1467,7 +1467,7 @@ function zoom_in(factor)
|
||||
|
||||
zoomMgr.textZoom = value;
|
||||
|
||||
hah.reshowHints();
|
||||
vimperator.hints.reshowHints();
|
||||
|
||||
vimperator.echo("Zoom value: " + value + "%");
|
||||
}
|
||||
@@ -1502,7 +1502,7 @@ function zoom_to(value)
|
||||
|
||||
zoomMgr.textZoom = value;
|
||||
|
||||
hah.reshowHints();
|
||||
vimperator.hints.reshowHints();
|
||||
|
||||
vimperator.echo("Zoom value: " + value + "%");
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ function hit_a_hint() //{{{
|
||||
}
|
||||
// logMessage("winId:"+win.winId);
|
||||
win.res = evaluateXPath(vimperator.options["hinttags"], doc);
|
||||
win.coordLoaderId = window.setTimeout("hah.loadCoord(" + win.winId + ", 0);", 1);
|
||||
win.coordLoaderId = window.setTimeout("vimperator.hints.loadCoord(" + win.winId + ", 0);", 1);
|
||||
}
|
||||
|
||||
this.loadCoord = function(winId, i)
|
||||
@@ -93,7 +93,7 @@ function hit_a_hint() //{{{
|
||||
i++;
|
||||
|
||||
if (i < win.res.snapshotLength && !isHahModeEnabled)
|
||||
window.setTimeout("hah.loadCoord(" + winId + ", "+ i +");", 1);
|
||||
window.setTimeout("vimperator.hints.loadCoord(" + winId + ", "+ i +");", 1);
|
||||
else
|
||||
win.coordLoaderId = null;
|
||||
};
|
||||
@@ -521,7 +521,7 @@ function hit_a_hint() //{{{
|
||||
this.yankUrlHints = function()
|
||||
{
|
||||
var loc = "";
|
||||
var elems = hah.hintedElements();
|
||||
var elems = this.hintedElements();
|
||||
var tmp = "";
|
||||
for(i=0; i<elems.length; i++)
|
||||
{
|
||||
@@ -540,7 +540,7 @@ function hit_a_hint() //{{{
|
||||
this.yankTextHints = function()
|
||||
{
|
||||
var loc = "";
|
||||
var elems = hah.hintedElements();
|
||||
var elems = this.hintedElements();
|
||||
var tmp = "";
|
||||
for(i=0; i<elems.length; i++)
|
||||
{
|
||||
@@ -680,9 +680,8 @@ function hit_a_hint() //{{{
|
||||
}
|
||||
|
||||
window.document.addEventListener("pageshow", initDoc, null);
|
||||
window.addEventListener("resize", onResize, null);
|
||||
// FIXME: add resize support
|
||||
//window.addEventListener("resize", onResize, null);
|
||||
} //}}}
|
||||
|
||||
var hah = new hit_a_hint();
|
||||
|
||||
// vim: set fdm=marker sw=4 ts=4 et:
|
||||
|
||||
@@ -546,7 +546,7 @@ function Mappings() //{{{
|
||||
|
||||
/* hint managment */
|
||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["f"],
|
||||
function(count) { hah.enableHahMode(vimperator.modes.QUICK_HINT); },
|
||||
function(count) { vimperator.hints.enableHahMode(vimperator.modes.QUICK_HINT); },
|
||||
{
|
||||
short_help: "Start QuickHint mode",
|
||||
help: "In QuickHint mode, every hintable item (according to the <code class=\"option\">'hinttags'</code> XPath query) is assigned a label.<br/>" +
|
||||
@@ -555,7 +555,7 @@ function Mappings() //{{{
|
||||
}
|
||||
));
|
||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["F"],
|
||||
function(count) { hah.enableHahMode(vimperator.modes.ALWAYS_HINT); },
|
||||
function(count) { vimperator.hints.enableHahMode(vimperator.modes.ALWAYS_HINT); },
|
||||
{
|
||||
short_help: "Start AlwaysHint mode",
|
||||
help: "In AlwaysHint mode, every hintable item (according to the <code class=\"option\">'hinttags'</code> XPath query) is assigned a label.<br/>" +
|
||||
@@ -565,7 +565,7 @@ function Mappings() //{{{
|
||||
}
|
||||
));
|
||||
addDefaultMap(new Map(vimperator.modes.NORMAL, [";"],
|
||||
function(count) { hah.enableHahMode(vimperator.modes.EXTENDED_HINT); },
|
||||
function(count) { vimperator.hints.enableHahMode(vimperator.modes.EXTENDED_HINT); },
|
||||
{
|
||||
short_help: "Start ExtendedHint mode",
|
||||
help: "ExtendedHint mode is useful, since in this mode you can yank link locations, or open them in a new window.<br/>" +
|
||||
@@ -665,13 +665,13 @@ function Mappings() //{{{
|
||||
// TODO: Convert these to the new mappings model
|
||||
var hint_maps = [ //{{{
|
||||
/* hint action keys */
|
||||
["o", "hah.openHints(false, false);", true, false],
|
||||
["t", "hah.openHints(true, false);", true, false],
|
||||
["<C-w>", "hah.openHints(false, true );", true, false],
|
||||
["o", "vimperator.hints.openHints(false, false);", true, false],
|
||||
["t", "vimperator.hints.openHints(true, false);", true, false],
|
||||
["<C-w>", "vimperator.hints.openHints(false, true );", true, false],
|
||||
["s", "vimperator.echoerr('Saving of links not yet implemented');", true, false],
|
||||
["y", "hah.yankUrlHints();", true, false],
|
||||
["Y", "hah.yankTextHints();", true, false],
|
||||
[",", "vimperator.input.count+=','; hah.setCurrentState(0);", false, true],
|
||||
["y", "vimperator.hints.yankUrlHints();", true, false],
|
||||
["Y", "vimperator.hints.yankTextHints();", true, false],
|
||||
[",", "vimperator.input.count+=','; vimperator.hints.setCurrentState(0);", false, true],
|
||||
[":", "vimperator.commandline.open(':', '', vimperator.modes.EX);", false, true],
|
||||
/* movement keys */
|
||||
["<C-e>", "scrollBufferRelative(0, 1);", false, true],
|
||||
|
||||
@@ -73,6 +73,8 @@ function init() //{{{
|
||||
Vimperator.prototype.tabs = new Tabs;
|
||||
vimperator.log("Loading module marks...", 3);
|
||||
Vimperator.prototype.marks = new Marks;
|
||||
vimperator.log("Loading module hints...", 3);
|
||||
vimperator.hints = new hit_a_hint();
|
||||
vimperator.log("All modules loaded", 3);
|
||||
|
||||
// DJK FIXME
|
||||
@@ -445,7 +447,7 @@ function Events() //{{{
|
||||
{
|
||||
vimperator.setMode(vimperator.modes.NORMAL);
|
||||
vimperator.echo("");
|
||||
hah.disableHahMode();
|
||||
vimperator.hints.disableHahMode();
|
||||
vimperator.focusContent();
|
||||
vimperator.statusline.updateUrl();
|
||||
}
|
||||
@@ -527,13 +529,13 @@ function Events() //{{{
|
||||
{
|
||||
if(g_hint_mappings[i][0] == key)
|
||||
{
|
||||
if(g_hint_mappings[i][3] == true || hah.currentState() == 1)
|
||||
if(g_hint_mappings[i][3] == true || vimperator.hints.currentState() == 1)
|
||||
{
|
||||
//g_hint_mappings[i][1].call(this, event);
|
||||
eval(g_hint_mappings[i][1]);
|
||||
if (g_hint_mappings[i][2] == true) // stop processing this event
|
||||
{
|
||||
hah.disableHahMode();
|
||||
vimperator.hints.disableHahMode();
|
||||
vimperator.input.buffer = "";
|
||||
vimperator.statusline.updateInputBuffer("");
|
||||
return false;
|
||||
@@ -550,10 +552,10 @@ function Events() //{{{
|
||||
}
|
||||
|
||||
// no mapping found, beep()
|
||||
if (hah.currentState() == 1)
|
||||
if (vimperator.hints.currentState() == 1)
|
||||
{
|
||||
beep();
|
||||
hah.disableHahMode();
|
||||
vimperator.hints.disableHahMode();
|
||||
vimperator.input.buffer = "";
|
||||
vimperator.statusline.updateInputBuffer(vimperator.input.buffer);
|
||||
return true;
|
||||
@@ -561,18 +563,18 @@ function Events() //{{{
|
||||
|
||||
// if we came here, let hit-a-hint process the key as it is part
|
||||
// of a partial link
|
||||
var res = hah.processEvent(event);
|
||||
var res = vimperator.hints.processEvent(event);
|
||||
if (res < 0) // error occured processing this key
|
||||
{
|
||||
beep();
|
||||
//if(hah.currentMode() == HINT_MODE_QUICK)
|
||||
//if(vimperator.hints.currentMode() == HINT_MODE_QUICK)
|
||||
if(vimperator.hasMode(vimperator.modes.QUICK_HINT))
|
||||
hah.disableHahMode();
|
||||
vimperator.hints.disableHahMode();
|
||||
else // ALWAYS mode
|
||||
hah.resetHintedElements();
|
||||
vimperator.hints.resetHintedElements();
|
||||
vimperator.input.buffer = "";
|
||||
}
|
||||
//else if (res == 0 || hah.currentMode() == HINT_MODE_EXTENDED) // key processed, part of a larger hint
|
||||
//else if (res == 0 || vimperator.hints.currentMode() == HINT_MODE_EXTENDED) // key processed, part of a larger hint
|
||||
else if (res == 0 || vimperator.hasMode(vimperator.modes.EXTENDED_HINT)) // key processed, part of a larger hint
|
||||
vimperator.input.buffer += key;
|
||||
else // this key completed a quick hint
|
||||
@@ -580,15 +582,15 @@ function Events() //{{{
|
||||
// if the hint is all in UPPERCASE, open it in new tab
|
||||
vimperator.input.buffer += key;
|
||||
if (vimperator.input.buffer.toUpperCase() == vimperator.input.buffer)
|
||||
hah.openHints(true, false);
|
||||
vimperator.hints.openHints(true, false);
|
||||
else // open in current window
|
||||
hah.openHints(false, false);
|
||||
vimperator.hints.openHints(false, false);
|
||||
|
||||
//if(hah.currentMode() == HINT_MODE_QUICK)
|
||||
//if(vimperator.hints.currentMode() == HINT_MODE_QUICK)
|
||||
if(vimperator.hasMode(vimperator.modes.QUICK_HINT))
|
||||
hah.disableHahMode();
|
||||
vimperator.hints.disableHahMode();
|
||||
else // ALWAYS mode
|
||||
hah.resetHintedElements();
|
||||
vimperator.hints.resetHintedElements();
|
||||
|
||||
vimperator.input.buffer = "";
|
||||
}
|
||||
@@ -711,7 +713,7 @@ function Events() //{{{
|
||||
onLocationChange: function()
|
||||
{
|
||||
// if (vimperator.hasMode(vimperator.modes.HINTS) && !vimperator.hasMode(vimperator.modes.ALWAYS_HINT))
|
||||
// hah.disableHahMode();
|
||||
// vimperator.hints.disableHahMode();
|
||||
|
||||
vimperator.statusline.updateUrl();
|
||||
vimperator.statusline.updateProgress();
|
||||
|
||||
Reference in New Issue
Block a user