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

move global help() command to a vimperator slot

This commit is contained in:
Doug Kearns
2007-07-04 10:11:36 +00:00
parent 8a38512346
commit 0e1eee7ae7
5 changed files with 54 additions and 51 deletions

View File

@@ -397,7 +397,7 @@ function Commands() //{{{
}
));
addDefaultCommand(new Command(["exu[sage]"],
function() { help("commands"); },
function(args, special, count, modifiers) { vimperator.help("commands", special, null, modifiers); },
{
usage: ["exu[sage]"],
short_help: "Show help for Ex commands"
@@ -427,7 +427,7 @@ function Commands() //{{{
}
));
addDefaultCommand(new Command(["h[elp]"],
help,
function(args, special, count, modifiers) { vimperator.help(args, special, null, modifiers); },
{
usage: ["h[elp] {subject}"],
short_help: "Open the help window",
@@ -620,7 +620,7 @@ function Commands() //{{{
}
));
addDefaultCommand(new Command(["se[t]"],
function(args, special)
function(args, special, count, modifiers)
{
if (args == "")
{
@@ -888,7 +888,7 @@ function Commands() //{{{
}
));
addDefaultCommand(new Command(["viu[sage]"],
function() { help("mappings"); },
function(args, special, count, modifiers) { vimperator.help("mappings", special, null, modifiers); },
{
usage: ["viu[sage]"],
short_help: "Show help for normal mode commands"

View File

@@ -26,7 +26,7 @@ the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/
function help(section, easter) //{{{
Vimperator.prototype.help = function(section, easter) //{{{
{
if (easter)
{
@@ -210,29 +210,29 @@ function help(section, easter) //{{{
return false;
openURLs("about:blank");
setTimeout(function () { help(section, false, null, {recursive: true}); }, 250);
setTimeout(function () { vimperator.help(section, false, null, {recursive: true}); }, 250);
return;
}
doc.write(fulldoc);
doc.close();
function cumulativeOffset(element)
{
var valueT = 0, valueL = 0;
if (!element)
return [0, 0];
function cumulativeOffset(element)
{
var valueT = 0, valueL = 0;
if (!element)
return [0, 0];
do
{
valueT += element.offsetTop || 0;
valueL += element.offsetLeft || 0;
element = element.offsetParent;
}
while (element);
do
{
valueT += element.offsetTop || 0;
valueL += element.offsetLeft || 0;
element = element.offsetParent;
}
while (element);
return [valueL, valueT];
}
return [valueL, valueT];
}
if (section)
{

View File

@@ -199,7 +199,7 @@ function Mappings() //{{{
* Normal mode
*/
addDefaultMap(new Map(vimperator.modes.NORMAL, ["'", "`"],
function (mark) { vimperator.marks.jumpTo(mark) },
function(mark) { vimperator.marks.jumpTo(mark) },
{
short_help: "Jump to the mark in the current buffer",
usage: ["'{a-zA-Z0-9}"],
@@ -207,14 +207,16 @@ function Mappings() //{{{
flags: Mappings.flags.ARGUMENT
}
));
addDefaultMap(new Map(vimperator.modes.NORMAL, ["]f"], function(count) { focusNextFrame(count > 1 ? count : 1, true); },
addDefaultMap(new Map(vimperator.modes.NORMAL, ["]f"],
function(count) { focusNextFrame(count > 1 ? count : 1, true); },
{
short_help: "Focus next frame",
help: "Transfers keyboard focus to the [count]th next frame in order. The newly focused frame is briefly colored red.",
flags: Mappings.flags.COUNT
}
));
addDefaultMap(new Map(vimperator.modes.NORMAL, ["[f"], function(count) { focusNextFrame(count > 1 ? count : 1, false); },
addDefaultMap(new Map(vimperator.modes.NORMAL, ["[f"],
function(count) { focusNextFrame(count > 1 ? count : 1, false); },
{
short_help: "Focus previous frame",
help: "Transfers keyboard focus to the [count]th previous frame in order. The newly focused frame is briefly colored red.",
@@ -222,7 +224,7 @@ function Mappings() //{{{
}
));
addDefaultMap(new Map(vimperator.modes.NORMAL, ["b"],
function (args) { vimperator.commandline.open(":", "buffer ", vimperator.modes.EX); },
function(args) { vimperator.commandline.open(":", "buffer ", vimperator.modes.EX); },
{
short_help: "Open a prompt to switch buffers",
help: "Typing the corresponding number opens switches to this buffer."
@@ -266,7 +268,7 @@ function Mappings() //{{{
}
));
addDefaultMap(new Map(vimperator.modes.NORMAL, ["go"],
function (mark) { vimperator.quickmarks.jumpTo(mark, false) },
function(mark) { vimperator.quickmarks.jumpTo(mark, false) },
{
short_help: "Jump to a QuickMark in the current buffer",
usage: ["go{a-zA-Z0-9}"],
@@ -276,7 +278,7 @@ function Mappings() //{{{
}
));
addDefaultMap(new Map(vimperator.modes.NORMAL, ["gn"],
function (mark) { vimperator.quickmarks.jumpTo(mark, true) },
function(mark) { vimperator.quickmarks.jumpTo(mark, true) },
{
short_help: "Jump to a QuickMark in a new buffer",
usage: ["gn{a-zA-Z0-9}"],
@@ -308,30 +310,31 @@ function Mappings() //{{{
}
));
addDefaultMap(new Map(vimperator.modes.NORMAL, ['<C-^>', '<C-6>'],
function (args) {
if (vimperator.tabs.getTab() == vimperator.tabs.alternate)
{
vimperator.echoerr("E23: No alternate page");
return;
}
// NOTE: this currently relies on v.tabs.index() returning the
// currently selected tab index when passed null
var index = vimperator.tabs.index(vimperator.tabs.alternate);
// TODO: since a tab close is more like a bdelete for us we
// should probably reopen the closed tab when a 'deleted'
// alternate is selected
if (index == -1)
vimperator.echoerr("E86: Buffer does not exist") // TODO: This should read "Buffer N does not exist"
else
vimperator.tabs.select(index);
},
function()
{
if (vimperator.tabs.getTab() == vimperator.tabs.alternate)
{
short_help: "Select the alternate tab",
usage: ['<C-^>'],
help: "The alternate tab is the last selected tab. This provides a quick method of toggling between two tabs."
vimperator.echoerr("E23: No alternate page");
return;
}
// NOTE: this currently relies on v.tabs.index() returning the
// currently selected tab index when passed null
var index = vimperator.tabs.index(vimperator.tabs.alternate);
// TODO: since a tab close is more like a bdelete for us we
// should probably reopen the closed tab when a 'deleted'
// alternate is selected
if (index == -1)
vimperator.echoerr("E86: Buffer does not exist") // TODO: This should read "Buffer N does not exist"
else
vimperator.tabs.select(index);
},
{
short_help: "Select the alternate tab",
usage: ['<C-^>'],
help: "The alternate tab is the last selected tab. This provides a quick method of toggling between two tabs."
}
));
addDefaultMap(new Map(vimperator.modes.NORMAL, ["m"],
function(mark) { vimperator.marks.add(mark) },
@@ -684,7 +687,7 @@ function Mappings() //{{{
/* vimperator managment */
addDefaultMap(new Map(vimperator.modes.NORMAL, ["<F1>"],
function(count) { help(null); },
function(count) { vimperator.help(null); },
{
short_help: "Open help window",
help: "The default section is shown, if you need help for a specific topic, try <code class=\"command\">:help &lt;F1&gt;</code> (jumping to a specific section not implemented yet)."

View File

@@ -112,7 +112,7 @@ function init() //{{{
if (Options.getPref("firsttime", true))
{
setTimeout(function() {
help(null, null, null, { inTab: true });
vimperator.help(null, null, null, { inTab: true });
Options.setPref("firsttime", false);
}, 1000);
}

View File

@@ -38,8 +38,8 @@ the terms of any one of the MPL, the GPL or the LGPL.
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript;version=1.7" src="help.js"/>
<script type="application/x-javascript;version=1.7" src="vimperator.js"/>
<script type="application/x-javascript;version=1.7" src="help.js"/>
<script type="application/x-javascript;version=1.7" src="commands.js"/>
<script type="application/x-javascript;version=1.7" src="ui.js"/>
<script type="application/x-javascript;version=1.7" src="options.js"/>