1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 05:18:12 +01:00

Automagically generate :help key indexes.

This commit is contained in:
Kris Maglione
2011-01-06 13:01:26 -05:00
parent 269a12a71a
commit 34ce63a150
5 changed files with 36 additions and 195 deletions

View File

@@ -486,7 +486,7 @@ var Commands = Module("commands", {
for (let alias in values(names.slice(1))) for (let alias in values(names.slice(1)))
memoize(this._exMap, alias, closure); memoize(this._exMap, alias, closure);
return true; return name;
}, },
/** /**

View File

@@ -156,7 +156,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
}, },
addUsageCommand: function (params) { addUsageCommand: function (params) {
commands.add(params.name, params.description, let name = commands.add(params.name, params.description,
function (args) { function (args) {
let results = array(params.iterate(args)) let results = array(params.iterate(args))
.sort(function (a, b) String.localeCompare(a.name, b.name)); .sort(function (a, b) String.localeCompare(a.name, b.name));
@@ -186,7 +186,10 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
}); });
if (params.index) if (params.index)
this.indices[params.index] = function () { this.indices[params.index] = function () {
for (let obj in (params.iterateIndex || params.iterate)()) let results = array((params.iterateIndex || params.iterate).call(params, commands.get(name).newArgs()))
.array.sort(function (a, b) String.localeCompare(a.name, b.name));
for (let obj in values(results))
if (obj.helpTag in services["dactyl:"].HELP_TAGS) if (obj.helpTag in services["dactyl:"].HELP_TAGS)
yield dactyl.generateHelp(obj, null, null, true); yield dactyl.generateHelp(obj, null, null, true);
} }
@@ -770,18 +773,23 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
let args = null; let args = null;
if (obj instanceof Command) { if (obj instanceof Command) {
tag = spec = function (cmd) <>:{cmd}</>; link = function (cmd) <ex>{cmd}</ex>;
link = function (cmd) <ex>:{cmd}</ex>;
args = obj.parseArgs("", CompletionContext(str || "")); args = obj.parseArgs("", CompletionContext(str || ""));
spec = function (cmd) cmd + (obj.bang ? <oa>!</oa> : <></>); spec = function (cmd) cmd + (obj.bang ? <oa>!</oa> : <></>);
} }
else if (obj instanceof Map && obj.count) { else if (obj instanceof Map) {
spec = function (map) <><oa>count</oa>{map}</>; spec = function (map) obj.count ? <><oa>count</oa>{map}</> : <>{map}</>;
link = function (map) let (res = /^<(.*?)>(.*?)/.exec(map)) link = function (map) {
res ? <k name={res[1]}>{res[2]}</k> : <k>{map}</k>; let [, mode, name, extra] = /^(?:(.)_)?(?:<([^>]+)>)?(.*)$/.exec(map);
let k = <k>{extra}</k>;
if (name)
k.@name = name;
if (mode)
k.@mode = mode;
return k
}
} }
else if (obj instanceof Option) { else if (obj instanceof Option) {
tag = spec = function (opt) <>'{opt}'</>;
link = function (opt) <o>{opt}</o>; link = function (opt) <o>{opt}</o>;
} }
@@ -794,7 +802,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
</>; </>;
let res = <res> let res = <res>
<dt>{link(obj.name)}</dt> <dd>{ <dt>{link(obj.helpTag || obj.name)}</dt> <dd>{
template.linkifyHelp(obj.description ? obj.description.replace(/\.$/, "") : "", true) template.linkifyHelp(obj.description ? obj.description.replace(/\.$/, "") : "", true)
}</dd></res>; }</dd></res>;
if (specOnly) if (specOnly)

View File

@@ -587,7 +587,12 @@ var Mappings = Module("mappings", {
dactyl.addUsageCommand({ dactyl.addUsageCommand({
__proto__: args, __proto__: args,
name: [mode.char + "listk[eys]", mode.char + "lk"], name: [mode.char + "listk[eys]", mode.char + "lk"],
iterateIndex: function (args)
let (self = this, prefix = mode.char == "n" ? "" : mode.char + "_")
({ helpTag: prefix + map.name, __proto__: map }
for (map in self.iterate(args))),
description: "List all " + mode.name + " mode mappings along with their short descriptions", description: "List all " + mode.name + " mode mappings along with their short descriptions",
index: mode.char + "-maps",
getMode: function (args) mode, getMode: function (args) mode,
options: [] options: []
}); });

View File

@@ -14,194 +14,15 @@
This file contains a list of all available commands, mappings and options. This file contains a list of all available commands, mappings and options.
<h2 tag="insert-index">Insert mode</h2> <h2 tag="i-maps-index">Insert mode</h2>
<dl> <h2 tag="n-maps-index">Normal mode</h2>
<dt><k mode="t">i</k></dt> <dd>Start Insert mode in text areas when <o>insertmode</o> is not set</dd>
<dt><k name="C-i" mode="i"/></dt> <dd>Launch the external editor</dd>
<dt><k name="C-t" mode="i"/></dt> <dd>Enter TextEdit mode</dd>
<dt><k name="C-]" mode="i"/></dt> <dd>Expand an Insert-mode abbreviation</dd>
</dl>
<h2 tag="normal-index">Normal mode</h2> <h2 tag="v-maps-index">Visual mode</h2>
<dl> <h2 tag="c-maps-index">Command-line editing</h2>
<dt><k name="C-^"/></dt> <dd>Select the alternate tab or the <oa>count</oa>th tab</dd>
<dt><k name="C-a"/></dt> <dd>Increment last number in URL</dd>
<dt><k name="C-b"/></dt> <dd>Scroll up a full page</dd>
<dt><k name="C-c"/></dt> <dd>Stop loading the current web page</dd>
<dt><k name="C-d"/></dt> <dd>Scroll window downwards in the buffer</dd>
<dt><k name="C-f"/></dt> <dd>Scroll down a full page</dd>
<dt><k name="C-g"/></dt> <dd>Print the current file name</dd>
<dt><k name="C-i"/></dt> <dd>Go to a newer position in the jump list</dd>
<dt><k name="C-l"/></dt> <dd>Redraw the screen</dd>
<dt><k name="C-o"/></dt> <dd>Go to an older position in the jump list</dd>
<dt><k name="C-u"/></dt> <dd>Scroll window upwards in the buffer</dd>
<dt><k name="C-v"/></dt> <dd>Pass through next key</dd>
<dt><k name="C-x"/></dt> <dd>Decrement last number in URL</dd>
<dt><k name="C-z"/></dt> <dd>Temporarily ignore all &dactyl.appName; key bindings</dd>
</dl>
<dl> <h2 tag="t-map-index">Text editing</h2>
<dt><k name="Esc"/></dt> <dd>Focus content</dd>
</dl>
<dl>
<dt><k name="F1"/></dt> <dd>Open the introductory help page</dd>
<dt><k name="A-F1"/></dt> <dd>Open the single unchunked help page</dd>
</dl>
<dl>
<dt><k name="S-Tab"/></dt> <dd>Rewind keyboard focus</dd>
<dt><k name="Tab"/></dt> <dd>Advance keyboard focus</dd>
</dl>
<dl>
<dt><k>0</k></dt> <dd>Scroll to the absolute left of the document</dd>
<dt><k>$</k></dt> <dd>Scroll to the absolute right of the document</dd>
</dl>
<dl>
<dt><k>A</k></dt> <dd>Toggle bookmarked state of current URL</dd>
<dt><k>B</k></dt> <dd>Show buffer list</dd>
<dt><k>D</k></dt> <dd>Delete current buffer, focus tab to the left</dd>
<dt><k>F</k></dt> <dd>Start QuickHint mode, but open link in a new tab</dd>
<dt><k>G</k></dt> <dd>Go to the end of the document</dd>
<dt><k>H</k></dt> <dd>Go back in the browser history</dd>
<dt><k>L</k></dt> <dd>Go forward in the browser history</dd>
<dt><k>M</k></dt> <dd>Add new QuickMark for current URL</dd>
<dt><k>N</k></dt> <dd>Find previous</dd>
<dt><k>O</k></dt> <dd>Open one or more URLs, based on current location</dd>
<dt><k>P</k></dt> <dd>Open (put) a URL based on the current clipboard contents in a new buffer</dd>
<dt><k>R</k></dt> <dd>Reload while skipping the cache</dd>
<dt><k>T</k></dt> <dd>Open one or more URLs in a new tab, based on current location</dd>
<dt><k>Y</k></dt> <dd>Copy selected text or current word</dd>
<dt><k>W</k></dt> <dd>Open one or more URLs in a new window, based on current location</dd>
</dl>
<dl>
<dt><k>a</k></dt> <dd>Open a prompt to bookmark the current URL</dd>
<dt><k>b</k></dt> <dd>Open a prompt to switch buffers</dd>
<dt><k>d</k></dt> <dd>Delete current buffer</dd>
<dt><k>f</k></dt> <dd>Start QuickHint mode</dd>
<dt><k>h</k></dt> <dd>Scroll document to the left</dd>
<dt><k>i</k></dt> <dd>Start Caret mode</dd>
<dt><k>j</k></dt> <dd>Scroll document down</dd>
<dt><k>k</k></dt> <dd>Scroll document up</dd>
<dt><k>l</k></dt> <dd>Scroll document to the right</dd>
<dt><k>m</k></dt> <dd>Set mark at the cursor position</dd>
<dt><k>n</k></dt> <dd>Find next</dd>
<dt><k>o</k></dt> <dd>Open one or more URLs</dd>
<dt><k>p</k></dt> <dd>Open (put) a URL based on the current clipboard contents in the current buffer</dd>
<dt><k>q</k></dt> <dd>Record a key sequence into a macro</dd>
<dt><k>r</k></dt> <dd>Reload the current web page</dd>
<dt><k>t</k></dt> <dd>Open one or more URLs in a new tab</dd>
<dt><k>u</k></dt> <dd>Undo closing of a tab</dd>
<dt><k>y</k></dt> <dd>Yank current location to the clipboard</dd>
<dt><k>w</k></dt> <dd>Open one or more URLs in a new window</dd>
</dl>
<dl>
<dt><k>;</k></dt> <dd>Start an extended hint mode</dd>
</dl>
<dl>
<dt><k>:</k></dt> <dd>Enter Command-line mode</dd>
</dl>
<dl>
<dt><k>~</k></dt> <dd>Open home directory</dd>
</dl>
<dl>
<dt><k>/</k></dt> <dd>Search forward for a pattern</dd>
<dt><k>?</k></dt> <dd>Search backwards for a pattern</dd>
<dt><k>*</k></dt> <dd>Find word under cursor</dd>
<dt><k>#</k></dt> <dd>Find word under cursor backwards</dd>
</dl>
<dl>
<dt><k>N%</k></dt> <dd>Scroll to <a>count</a> percent of the document</dd>
</dl>
<dl>
<dt><k>'</k></dt> <dd>Jump to the mark</dd>
</dl>
<dl>
<dt><k>@</k></dt> <dd>Play a macro</dd>
</dl>
<dl>
<dt><k>.</k></dt> <dd>Repeat the last keyboard command</dd>
<dt><k>@:</k></dt> <dd>Repeat the last Ex command <oa>count</oa> times</dd>
</dl>
<dl>
<dt><k>]f</k></dt> <dd>Focus next frame</dd>
<dt><k>[f</k></dt> <dd>Focus previous frame</dd>
<dt><k>]] </k></dt> <dd>Follow the link labeled 'next' or '>' if it exists</dd>
<dt><k>[[ </k></dt> <dd>Follow the link labeled 'prev', 'previous' or '&lt;' if it exists</dd>
</dl>
<dl>
<dt><k>g$</k></dt> <dd>Go to the last tab</dd>
<dt><k>g&lt;</k></dt> <dd>Redisplay the last command output</dd>
<dt><k>g0</k></dt> <dd>Go to the first tab</dd>
<dt><k>g&lt;C-g></k></dt> <dd>Print file information</dd>
<dt><k>gB</k></dt> <dd>Repeat last <ex>:buffer<oa>!</oa></ex> command in reverse direction</dd>
<dt><k>gF</k></dt> <dd>View source with an external editor</dd>
<dt><k>gH</k></dt> <dd>Open homepage in a new tab</dd>
<dt><k>gP</k></dt> <dd>Open (put) a URL based on the current clipboard contents in a new buffer</dd>
<dt><k>gT</k></dt> <dd>Go to previous tab</dd>
<dt><k>gU</k></dt> <dd>Go to the root of the website</dd>
<dt><k>gb</k></dt> <dd>Repeat last <ex>:buffer<oa>!</oa></ex> command</dd>
<dt><k>gf</k></dt> <dd>Toggle between rendered and source view</dd>
<dt><k>gg</k></dt> <dd>Go to the top of the document</dd>
<dt><k>gh</k></dt> <dd>Open homepage</dd>
<dt><k>gi</k></dt> <dd>Focus last used input field</dd>
<dt><k>gn</k></dt> <dd>Jump to a QuickMark in a new tab</dd>
<dt><k>go</k></dt> <dd>Jump to a QuickMark</dd>
<dt><k>gt</k></dt> <dd>Go to the next tab</dd>
<dt><k>gu</k></dt> <dd>Go to parent directory</dd>
</dl>
<dl>
<dt><k>ZQ</k></dt> <dd>Quit and don't save the session</dd>
<dt><k>ZZ</k></dt> <dd>Quit and save the session</dd>
<dt><k>zI</k></dt> <dd>Enlarge full zoom of current web page</dd>
<dt><k>zM</k></dt> <dd>Enlarge full zoom of current web page by a larger amount</dd>
<dt><k>zO</k></dt> <dd>Reduce full zoom of current web page</dd>
<dt><k>zR</k></dt> <dd>Reduce full zoom of current web page by a larger amount</dd>
<dt><k>zZ</k></dt> <dd>Set full zoom value of current web page</dd>
<dt><k>zi</k></dt> <dd>Enlarge text zoom of current web page</dd>
<dt><k>zm</k></dt> <dd>Enlarge text zoom of current web page by a larger amount</dd>
<dt><k>zo</k></dt> <dd>Reduce text zoom of current web page</dd>
<dt><k>zr</k></dt> <dd>Reduce text zoom of current web page by a larger amount</dd>
<dt><k>zz</k></dt> <dd>Set text zoom value of current web page</dd>
</dl>
<h2 tag="ex-edit-index">Command-line editing</h2>
<dl>
<dt><k name="C-c" mode="c"/></dt> <dd>Quit Command-line mode without executing</dd>
</dl>
<dl>
<dt><k name="C-]" mode="c"/></dt> <dd>Expand a command-line abbreviation</dd>
</dl>
<dl>
<dt><k name="Up" mode="c"/></dt> <dd>Recall the previous command line from the history list which matches the current command line</dd>
<dt><k name="Down" mode="c"/></dt> <dd>Recall the next command line from the history list which matches the current command line</dd>
</dl>
<dl>
<dt><k name="Tab" mode="c"/></dt> <dd>Complete the word in front of the cursor according to the behavior specified in <o>wildmode</o></dd>
<dt><k name="S-Tab" mode="c"/></dt> <dd>Complete the previous full match when <o>wildmode</o> contains "full"</dd>
<dt><k name="A-Tab" mode="c"/></dt> <dd>Complete the word in front of the cursor according to the behavior specified in <o>altwildmode</o></dd>
<dt><k name="A-S-Tab" mode="c"/></dt> <dd>Complete the previous full match when <o>altwildmode</o> contains "full"</dd>
</dl>
<h2 tag="ex-cmd-index :index">Ex commands</h2> <h2 tag="ex-cmd-index :index">Ex commands</h2>

View File

@@ -347,6 +347,13 @@ var File = Class("File", {
return array; return array;
}, },
/**
* Returns a new nsIFileURL object for this file.
*
* @returns {nsIFileURL}
*/
toURI: function toURI() services.io.newFileURI(this),
/** /**
* Writes the string *buf* to this file. * Writes the string *buf* to this file.
* *