mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-23 18:45:45 +01:00
Add :list* commands, linkify help tags in certain output, and augment :yank to accept JavaScript directly.
This commit is contained in:
@@ -131,7 +131,7 @@ const Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference
|
||||
if (saved == null && curval != defval || curval != saved) {
|
||||
let msg = "Warning: setting preference " + name + ", but it's changed from its default value.";
|
||||
if (message)
|
||||
msg += " " + message;
|
||||
msg = template.linkifyHelp(msg + " " + message);
|
||||
util.dactyl.echomsg(msg);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
Components.utils.import("resource://dactyl/base.jsm");
|
||||
defineModule("template", {
|
||||
exports: ["Template", "template"],
|
||||
require: ["util"]
|
||||
require: ["util"],
|
||||
use: ["services"]
|
||||
});
|
||||
|
||||
default xml namespace = XHTML;
|
||||
@@ -78,6 +79,16 @@ const Template = Module("Template", {
|
||||
// </e4x>
|
||||
},
|
||||
|
||||
helpLink: function (topic, type) {
|
||||
if (services["dactyl:"].initialized && !set.has(services["dactyl:"].HELP_TAGS, topic))
|
||||
return <>{topic}</>;
|
||||
|
||||
XML.ignoreWhitespace = false; XML.prettyPrinting = false;
|
||||
type = type || /^'.*'$/.test(topic) ? "HelpOpt" :
|
||||
/^:\w/.test(topic) ? "HelpEx" : "HelpKey";
|
||||
return <a highlight={type} href={"dactyl://help-tag/" + topic} dactyl:command="dactyl.help" xmlns:dactyl={NS}>{topic}</a>
|
||||
},
|
||||
|
||||
// if "processStrings" is true, any passed strings will be surrounded by " and
|
||||
// any line breaks are displayed as \n
|
||||
highlight: function highlight(arg, processStrings, clip) {
|
||||
@@ -199,6 +210,21 @@ const Template = Module("Template", {
|
||||
// </e4x>
|
||||
},
|
||||
|
||||
linkifyHelp: function linkifyHelp(str) {
|
||||
util.dactyl.initHelp();
|
||||
|
||||
let re = util.regexp(<![CDATA[
|
||||
([/\s]|^)
|
||||
( '[\w-]+' | :(?:[\w-]+|!) | (?:._)?<[\w-]+> )
|
||||
(?=[[!,;./\s]|$)
|
||||
]]>, "g");
|
||||
return this.highlightSubstrings(str, (function () {
|
||||
let res;
|
||||
while ((res = re.exec(str)) && res[2].length)
|
||||
yield [res.index + res[1].length, res[2].length];
|
||||
})(), template.helpLink);
|
||||
},
|
||||
|
||||
options: function options(title, opts) {
|
||||
XML.ignoreWhitespace = false; XML.prettyPrinting = false;
|
||||
// <e4x>
|
||||
@@ -285,8 +311,9 @@ const Template = Module("Template", {
|
||||
// </e4x>
|
||||
},
|
||||
|
||||
usage: function usage(iter) {
|
||||
usage: function usage(iter, format) {
|
||||
XML.ignoreWhitespace = false; XML.prettyPrinting = false;
|
||||
let desc = format && format.description || function (item) template.linkifyHelp(item.description);
|
||||
// <e4x>
|
||||
return <table>
|
||||
{
|
||||
@@ -298,7 +325,7 @@ const Template = Module("Template", {
|
||||
<span highlight="Title">{name}</span> + <> </> +
|
||||
<span highlight="LineInfo">Defined at {template.sourceLink(frame)}</span>
|
||||
}</td>
|
||||
<td>{item.description}</td>
|
||||
<td>{desc(item)}</td>
|
||||
</tr>)
|
||||
}
|
||||
</table>;
|
||||
|
||||
@@ -30,7 +30,7 @@ memoize(this, "Commands", function () {
|
||||
|
||||
const FailedAssertion = Class("FailedAssertion", Error, {
|
||||
init: function (message) {
|
||||
this.message = message;
|
||||
update(this, Error(message))
|
||||
}
|
||||
});
|
||||
|
||||
@@ -102,7 +102,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
*/
|
||||
assert: function (condition, message) {
|
||||
if (!condition)
|
||||
throw new FailedAssertion(message);
|
||||
throw FailedAssertion(message);
|
||||
},
|
||||
|
||||
get chromePackages() {
|
||||
|
||||
Reference in New Issue
Block a user