From 8cd219f400f4f4f2f26cfa8bcb6858ec2ec7d70a Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Thu, 28 Jun 2007 02:16:41 +0000 Subject: [PATCH] move the global variable hah to vimperator.hints and fix bug #17254 --- TODO | 1 + chrome/content/vimperator/commands.js | 16 ++++++------ chrome/content/vimperator/hints.js | 13 +++++----- chrome/content/vimperator/mappings.js | 18 ++++++------- chrome/content/vimperator/vimperator.js | 34 +++++++++++++------------ 5 files changed, 42 insertions(+), 40 deletions(-) diff --git a/TODO b/TODO index 2d349e5a..41d82d50 100644 --- a/TODO +++ b/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.. - key closes :addons and other XUL windows +- add window resize support to hints FEATURES: 9 :map commands to keys diff --git a/chrome/content/vimperator/commands.js b/chrome/content/vimperator/commands.js index 3973650c..02f39f15 100644 --- a/chrome/content/vimperator/commands.js +++ b/chrome/content/vimperator/commands.js @@ -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], - ["", "hah.openHints(false, true );", true, false], + ["o", "vimperator.hints.openHints(false, false);", true, false], + ["t", "vimperator.hints.openHints(true, false);", true, false], + ["", "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 */ ["", "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 + "%"); } diff --git a/chrome/content/vimperator/hints.js b/chrome/content/vimperator/hints.js index e766bd88..33f2abe9 100644 --- a/chrome/content/vimperator/hints.js +++ b/chrome/content/vimperator/hints.js @@ -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'hinttags' XPath query) is assigned a label.
" + @@ -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 'hinttags' XPath query) is assigned a label.
" + @@ -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.
" + @@ -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], - ["", "hah.openHints(false, true );", true, false], + ["o", "vimperator.hints.openHints(false, false);", true, false], + ["t", "vimperator.hints.openHints(true, false);", true, false], + ["", "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 */ ["", "scrollBufferRelative(0, 1);", false, true], diff --git a/chrome/content/vimperator/vimperator.js b/chrome/content/vimperator/vimperator.js index 2171a18b..ef548d30 100644 --- a/chrome/content/vimperator/vimperator.js +++ b/chrome/content/vimperator/vimperator.js @@ -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();