1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 00:07:58 +01:00

move the global variable hah to vimperator.hints and fix bug #17254

This commit is contained in:
Doug Kearns
2007-06-28 02:16:41 +00:00
parent f2c340360d
commit 8cd219f400
5 changed files with 42 additions and 40 deletions

1
TODO
View File

@@ -13,6 +13,7 @@ BUGS:
dpb| 09:11:50 dpb :: and this happens only when saving the complete dpb| 09:11:50 dpb :: and this happens only when saving the complete
webpage, saving only the html works just fine.. webpage, saving only the html works just fine..
- <ESC> key closes :addons and other XUL windows - <ESC> key closes :addons and other XUL windows
- add window resize support to hints
FEATURES: FEATURES:
9 :map commands to keys 9 :map commands to keys

View File

@@ -29,13 +29,13 @@ the terms of any one of the MPL, the GPL or the LGPL.
/* [command, action, cancel_hint_mode, always_active] */ /* [command, action, cancel_hint_mode, always_active] */
var g_hint_mappings = [ //{{{ var g_hint_mappings = [ //{{{
/* hint action keys */ /* hint action keys */
["o", "hah.openHints(false, false);", true, false], ["o", "vimperator.hints.openHints(false, false);", true, false],
["t", "hah.openHints(true, false);", true, false], ["t", "vimperator.hints.openHints(true, false);", true, false],
["<C-w>", "hah.openHints(false, true );", true, false], ["<C-w>", "vimperator.hints.openHints(false, true );", true, false],
["s", "vimperator.echoerr('Saving of links not yet implemented');", true, false], ["s", "vimperator.echoerr('Saving of links not yet implemented');", true, false],
["y", "hah.yankUrlHints();", true, false], ["y", "vimperator.hints.yankUrlHints();", true, false],
["Y", "hah.yankTextHints();", true, false], ["Y", "vimperator.hints.yankTextHints();", true, false],
[",", "g_inputbuffer+=','; hah.setCurrentState(0);", false, true], [",", "g_inputbuffer+=','; vimperator.hints.setCurrentState(0);", false, true],
[":", "vimperator.commandline.open(':', '', vimperator.modes.EX);", false, true], [":", "vimperator.commandline.open(':', '', vimperator.modes.EX);", false, true],
/* movement keys */ /* movement keys */
["<C-e>", "scrollBufferRelative(0, 1);", false, true], ["<C-e>", "scrollBufferRelative(0, 1);", false, true],
@@ -1467,7 +1467,7 @@ function zoom_in(factor)
zoomMgr.textZoom = value; zoomMgr.textZoom = value;
hah.reshowHints(); vimperator.hints.reshowHints();
vimperator.echo("Zoom value: " + value + "%"); vimperator.echo("Zoom value: " + value + "%");
} }
@@ -1502,7 +1502,7 @@ function zoom_to(value)
zoomMgr.textZoom = value; zoomMgr.textZoom = value;
hah.reshowHints(); vimperator.hints.reshowHints();
vimperator.echo("Zoom value: " + value + "%"); vimperator.echo("Zoom value: " + value + "%");
} }

View File

@@ -79,7 +79,7 @@ function hit_a_hint() //{{{
} }
// logMessage("winId:"+win.winId); // logMessage("winId:"+win.winId);
win.res = evaluateXPath(vimperator.options["hinttags"], doc); 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) this.loadCoord = function(winId, i)
@@ -93,7 +93,7 @@ function hit_a_hint() //{{{
i++; i++;
if (i < win.res.snapshotLength && !isHahModeEnabled) if (i < win.res.snapshotLength && !isHahModeEnabled)
window.setTimeout("hah.loadCoord(" + winId + ", "+ i +");", 1); window.setTimeout("vimperator.hints.loadCoord(" + winId + ", "+ i +");", 1);
else else
win.coordLoaderId = null; win.coordLoaderId = null;
}; };
@@ -521,7 +521,7 @@ function hit_a_hint() //{{{
this.yankUrlHints = function() this.yankUrlHints = function()
{ {
var loc = ""; var loc = "";
var elems = hah.hintedElements(); var elems = this.hintedElements();
var tmp = ""; var tmp = "";
for(i=0; i<elems.length; i++) for(i=0; i<elems.length; i++)
{ {
@@ -540,7 +540,7 @@ function hit_a_hint() //{{{
this.yankTextHints = function() this.yankTextHints = function()
{ {
var loc = ""; var loc = "";
var elems = hah.hintedElements(); var elems = this.hintedElements();
var tmp = ""; var tmp = "";
for(i=0; i<elems.length; i++) for(i=0; i<elems.length; i++)
{ {
@@ -680,9 +680,8 @@ function hit_a_hint() //{{{
} }
window.document.addEventListener("pageshow", initDoc, null); 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: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -546,7 +546,7 @@ function Mappings() //{{{
/* hint managment */ /* hint managment */
addDefaultMap(new Map(vimperator.modes.NORMAL, ["f"], 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", 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/>" + 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"], 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", 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/>" + 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, [";"], 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", 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/>" + 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 // TODO: Convert these to the new mappings model
var hint_maps = [ //{{{ var hint_maps = [ //{{{
/* hint action keys */ /* hint action keys */
["o", "hah.openHints(false, false);", true, false], ["o", "vimperator.hints.openHints(false, false);", true, false],
["t", "hah.openHints(true, false);", true, false], ["t", "vimperator.hints.openHints(true, false);", true, false],
["<C-w>", "hah.openHints(false, true );", true, false], ["<C-w>", "vimperator.hints.openHints(false, true );", true, false],
["s", "vimperator.echoerr('Saving of links not yet implemented');", true, false], ["s", "vimperator.echoerr('Saving of links not yet implemented');", true, false],
["y", "hah.yankUrlHints();", true, false], ["y", "vimperator.hints.yankUrlHints();", true, false],
["Y", "hah.yankTextHints();", true, false], ["Y", "vimperator.hints.yankTextHints();", true, false],
[",", "vimperator.input.count+=','; hah.setCurrentState(0);", false, true], [",", "vimperator.input.count+=','; vimperator.hints.setCurrentState(0);", false, true],
[":", "vimperator.commandline.open(':', '', vimperator.modes.EX);", false, true], [":", "vimperator.commandline.open(':', '', vimperator.modes.EX);", false, true],
/* movement keys */ /* movement keys */
["<C-e>", "scrollBufferRelative(0, 1);", false, true], ["<C-e>", "scrollBufferRelative(0, 1);", false, true],

View File

@@ -73,6 +73,8 @@ function init() //{{{
Vimperator.prototype.tabs = new Tabs; Vimperator.prototype.tabs = new Tabs;
vimperator.log("Loading module marks...", 3); vimperator.log("Loading module marks...", 3);
Vimperator.prototype.marks = new Marks; Vimperator.prototype.marks = new Marks;
vimperator.log("Loading module hints...", 3);
vimperator.hints = new hit_a_hint();
vimperator.log("All modules loaded", 3); vimperator.log("All modules loaded", 3);
// DJK FIXME // DJK FIXME
@@ -445,7 +447,7 @@ function Events() //{{{
{ {
vimperator.setMode(vimperator.modes.NORMAL); vimperator.setMode(vimperator.modes.NORMAL);
vimperator.echo(""); vimperator.echo("");
hah.disableHahMode(); vimperator.hints.disableHahMode();
vimperator.focusContent(); vimperator.focusContent();
vimperator.statusline.updateUrl(); vimperator.statusline.updateUrl();
} }
@@ -527,13 +529,13 @@ function Events() //{{{
{ {
if(g_hint_mappings[i][0] == key) 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); //g_hint_mappings[i][1].call(this, event);
eval(g_hint_mappings[i][1]); eval(g_hint_mappings[i][1]);
if (g_hint_mappings[i][2] == true) // stop processing this event if (g_hint_mappings[i][2] == true) // stop processing this event
{ {
hah.disableHahMode(); vimperator.hints.disableHahMode();
vimperator.input.buffer = ""; vimperator.input.buffer = "";
vimperator.statusline.updateInputBuffer(""); vimperator.statusline.updateInputBuffer("");
return false; return false;
@@ -550,10 +552,10 @@ function Events() //{{{
} }
// no mapping found, beep() // no mapping found, beep()
if (hah.currentState() == 1) if (vimperator.hints.currentState() == 1)
{ {
beep(); beep();
hah.disableHahMode(); vimperator.hints.disableHahMode();
vimperator.input.buffer = ""; vimperator.input.buffer = "";
vimperator.statusline.updateInputBuffer(vimperator.input.buffer); vimperator.statusline.updateInputBuffer(vimperator.input.buffer);
return true; return true;
@@ -561,18 +563,18 @@ function Events() //{{{
// if we came here, let hit-a-hint process the key as it is part // if we came here, let hit-a-hint process the key as it is part
// of a partial link // of a partial link
var res = hah.processEvent(event); var res = vimperator.hints.processEvent(event);
if (res < 0) // error occured processing this key if (res < 0) // error occured processing this key
{ {
beep(); beep();
//if(hah.currentMode() == HINT_MODE_QUICK) //if(vimperator.hints.currentMode() == HINT_MODE_QUICK)
if(vimperator.hasMode(vimperator.modes.QUICK_HINT)) if(vimperator.hasMode(vimperator.modes.QUICK_HINT))
hah.disableHahMode(); vimperator.hints.disableHahMode();
else // ALWAYS mode else // ALWAYS mode
hah.resetHintedElements(); vimperator.hints.resetHintedElements();
vimperator.input.buffer = ""; 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 else if (res == 0 || vimperator.hasMode(vimperator.modes.EXTENDED_HINT)) // key processed, part of a larger hint
vimperator.input.buffer += key; vimperator.input.buffer += key;
else // this key completed a quick hint 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 // if the hint is all in UPPERCASE, open it in new tab
vimperator.input.buffer += key; vimperator.input.buffer += key;
if (vimperator.input.buffer.toUpperCase() == vimperator.input.buffer) if (vimperator.input.buffer.toUpperCase() == vimperator.input.buffer)
hah.openHints(true, false); vimperator.hints.openHints(true, false);
else // open in current window 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)) if(vimperator.hasMode(vimperator.modes.QUICK_HINT))
hah.disableHahMode(); vimperator.hints.disableHahMode();
else // ALWAYS mode else // ALWAYS mode
hah.resetHintedElements(); vimperator.hints.resetHintedElements();
vimperator.input.buffer = ""; vimperator.input.buffer = "";
} }
@@ -711,7 +713,7 @@ function Events() //{{{
onLocationChange: function() onLocationChange: function()
{ {
// if (vimperator.hasMode(vimperator.modes.HINTS) && !vimperator.hasMode(vimperator.modes.ALWAYS_HINT)) // if (vimperator.hasMode(vimperator.modes.HINTS) && !vimperator.hasMode(vimperator.modes.ALWAYS_HINT))
// hah.disableHahMode(); // vimperator.hints.disableHahMode();
vimperator.statusline.updateUrl(); vimperator.statusline.updateUrl();
vimperator.statusline.updateProgress(); vimperator.statusline.updateProgress();