diff options
author | Kris Maglione <maglione.k@gmail.com> | 2011-01-06 13:01:26 -0500 |
---|---|---|
committer | Kris Maglione <maglione.k@gmail.com> | 2011-01-06 13:01:26 -0500 |
commit | 34ce63a150c3008c7a3b4da917a90230e53e8d3e (patch) | |
tree | ca21e7858ae6920070c30cac18c09d75cf1b8465 /common/content/dactyl.js | |
parent | 269a12a71aab463bca369bde5d8ab7a1d2735594 (diff) | |
download | pentadactyl-34ce63a150c3008c7a3b4da917a90230e53e8d3e.tar.gz |
Automagically generate :help key indexes.
Diffstat (limited to 'common/content/dactyl.js')
-rw-r--r-- | common/content/dactyl.js | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 870d07b7..3217ede0 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -156,7 +156,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { }, addUsageCommand: function (params) { - commands.add(params.name, params.description, + let name = commands.add(params.name, params.description, function (args) { let results = array(params.iterate(args)) .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) 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) yield dactyl.generateHelp(obj, null, null, true); } @@ -770,18 +773,23 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { let args = null; 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 || "")); spec = function (cmd) cmd + (obj.bang ? <oa>!</oa> : <></>); } - else if (obj instanceof Map && obj.count) { - spec = function (map) <><oa>count</oa>{map}</>; - link = function (map) let (res = /^<(.*?)>(.*?)/.exec(map)) - res ? <k name={res[1]}>{res[2]}</k> : <k>{map}</k>; + else if (obj instanceof Map) { + spec = function (map) obj.count ? <><oa>count</oa>{map}</> : <>{map}</>; + link = function (map) { + 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) { - tag = spec = function (opt) <>'{opt}'</>; link = function (opt) <o>{opt}</o>; } @@ -794,7 +802,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { </>; 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) }</dd></res>; if (specOnly) |