diff options
author | Kris Maglione <maglione.k@gmail.com> | 2010-10-15 00:30:03 -0400 |
---|---|---|
committer | Kris Maglione <maglione.k@gmail.com> | 2010-10-15 00:30:03 -0400 |
commit | a3799d3d05a053bb00a748943d7676453c921c82 (patch) | |
tree | e8ad8b0fb9daabccd6fe75e22e63fe790b5ac5a3 /common/content | |
parent | bea1c208587795df007057cb15bbffc57f1a6743 (diff) | |
download | pentadactyl-a3799d3d05a053bb00a748943d7676453c921c82.tar.gz |
Import (and augment) my cookies plugin per Doug's suggestion, and improve dactyl.generateHelp (and :yank).
Diffstat (limited to 'common/content')
-rw-r--r-- | common/content/commandline.js | 5 | ||||
-rw-r--r-- | common/content/completion.js | 7 | ||||
-rw-r--r-- | common/content/dactyl.js | 36 |
3 files changed, 36 insertions, 12 deletions
diff --git a/common/content/commandline.js b/common/content/commandline.js index 0ec215b6..1bfbcfb9 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -1571,8 +1571,6 @@ const CommandLine = Module("commandline", { if (typeof arg === "object") arg = util.objectToString(arg, useColor); - else if (typeof arg === "string" && /\n/.test(arg)) - arg = <span highlight="CmdOutput">{arg}</span>; else arg = String(arg); @@ -1983,7 +1981,8 @@ const ItemList = Class("ItemList", { this._fill(newOffset); if (index >= 0) { this._getCompletion(index).setAttribute("selected", "true"); - util.scrollIntoView(this._getCompletion(index)); + if (this._container.height != 0) + util.scrollIntoView(this._getCompletion(index)); } //if (index == 0) diff --git a/common/content/completion.js b/common/content/completion.js index 1e0d436d..5aca30e3 100644 --- a/common/content/completion.js +++ b/common/content/completion.js @@ -733,8 +733,11 @@ const Completion = Module("completion", { let context = CompletionContext(filter); context.maxItems = maxItems; let res = context.fork.apply(context, ["run", 0, this, name].concat(Array.slice(arguments, 3))); - if (res) // FIXME - return { items: res.map(function (i) ({ item: i })) }; + if (res) { + if (Components.stack.caller.name === "runCompleter") // FIXME + return { items: res.map(function (i) ({ item: i })) }; + context.contexts["/run"].completions = res; + } context.wait(true); return context.allItems; }, diff --git a/common/content/dactyl.js b/common/content/dactyl.js index b9e9df39..02b2053a 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -603,16 +603,27 @@ const Dactyl = Module("dactyl", { * @param {XMLList} extraHelp Extra help text beyond the description. * @returns {string} */ - generateHelp: function generateHelp(obj, extraHelp) { + generateHelp: function generateHelp(obj, extraHelp, str) { default xml namespace = ""; - let spec = util.identity; - let tag = util.identity; - if (obj instanceof Command) + + let link, tag, spec; + link = tag = spec = util.identity; + let args = null; + + if (obj instanceof Command) { tag = spec = function (cmd) <>:{cmd}</>; - else if (obj instanceof Map && obj.count) + link = function (cmd) <ex>:{cmd}</ex> + args = obj.parseArgs("", CompletionContext(str || "")); + } + else if (obj instanceof Map && obj.count) { spec = function (map) <><oa>count</oa>{map}</>; - else if (obj instanceof Option) + link = function (map) let (res = /^<(.*?)>(.*?)/.exec(map)) + res ? <k name={res[1]}>{res[2]}</k> : <k>{map}</k>; + } + else if (obj instanceof Option) { tag = spec = function (opt) <>'{opt}'</>; + link = function (opt) <o>{opt}</o>; + } XML.prettyPrinting = false; XML.ignoreWhitespace = false; @@ -621,7 +632,17 @@ const Dactyl = Module("dactyl", { let br = <> </>; + if (obj.completer) + var completions = let (br = br + <> </>) <> + <dl>{ br + + template.map( + completion._runCompleter(obj.completer, "", null, args).items, + function (i) <><dt>{i.text}</dt> <dd>{i.description}</dd></>, + br) } + </dl></>; + return <> + <dt>{link(obj.name)}</dt> <dd>{obj.description ? obj.description.replace(/\.$/, "") : ""}</dd> <item> <tags>{template.map(obj.names, tag, " ")}</tags> <spec>{spec((obj.specs || obj.names)[0])}</spec>{ @@ -631,7 +652,8 @@ const Dactyl = Module("dactyl", { <description>{ obj.description ? br+<p>{obj.description.replace(/\.?$/, ".")}</p> : "" }{ extraHelp ? br+extraHelp : "" }{ - !(extraHelp || obj.description) ? br+<p>Sorry, no help available.</p> : "" } + !(extraHelp || obj.description) ? br+<p>Sorry, no help available.</p> : "" }{ + completions ? br + completions : "" } </description> </item></>.toXMLString().replace(/^ {12}/gm, ""); }, |