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

Allow most characters in command names.

This commit is contained in:
Kris Maglione
2010-12-20 13:59:38 -05:00
parent bd4ad25901
commit f290f022dd
3 changed files with 59 additions and 9 deletions

View File

@@ -995,6 +995,58 @@ const Commands = Module("commands", {
} }
}, },
nameRegexp: util.regexp(<![CDATA[
[^
\x30-\x39 // 0-9
<forbid>
]
[^ <forbid> ]*
]]>, "", {
forbid: util.regexp(<![CDATA[
\x00-\x2c // \x2d -
\x2e-\x2f
\x3a-\x40 // \x41-\x5a a-z
\x5b-\x60 // \x61-\x7a A-Z
\x7b-\xff
\u02b0-\u02ff // Spacing Modifier Letters
\u0300-\u036f // Combining Diacritical Marks
\u1dc0-\u1dff // Combining Diacritical Marks Supplement
\u2000-\u206f // General Punctuation
\u20a0-\u20cf // Currency Symbols
\u20d0-\u20ff // Combining Diacritical Marks for Symbols
\u2400-\u243f // Control Pictures
\u2440-\u245f // Optical Character Recognition
\u2500-\u257f // Box Drawing
\u2580-\u259f // Block Elements
\u2700-\u27bf // Dingbats
\ufe20-\ufe2f // Combining Half Marks
\ufe30-\ufe4f // CJK Compatibility Forms
\ufe50-\ufe6f // Small Form Variants
\ufe70-\ufeff // Arabic Presentation Forms-B
\uff00-\uffef // Halfwidth and Fullwidth Forms
\ufff0-\uffff // Specials
]]>)
}),
validName: Class.memoize(function () RegExp("^" + this.nameRegexp.source + "$")),
_commandRegexp: Class.memoize(function () util.regexp(<![CDATA[
^
(
[:\s]*
(\d+ | %)?
(<name> | !)
(!)?
(\s*)
)
(
(?:. | \n)*?
)?
$
]]>, "", {
name: this.nameRegexp
})),
/** /**
* Parses a complete Ex command. * Parses a complete Ex command.
* *
@@ -1014,9 +1066,7 @@ const Commands = Module("commands", {
// remove comments // remove comments
str.replace(/\s*".*$/, ""); str.replace(/\s*".*$/, "");
// 0 - count, 1 - cmd, 2 - special, 3 - args let matches = this._commandRegexp.exec(str);
let matches = str.match(/^([:\s]*(\d+|%)?([a-zA-Z]+|!)(!)?(\s*))((?:.|\n)*?)?$/);
//var matches = str.match(/^:*(\d+|%)?([a-zA-Z]+|!)(!)?(?:\s*(.*?)\s*)?$/);
if (!matches) if (!matches)
return []; return [];
@@ -1240,7 +1290,7 @@ const Commands = Module("commands", {
function (args) { function (args) {
let cmd = args[0]; let cmd = args[0];
dactyl.assert(!/\W/.test(cmd || ''), "E182: Invalid command name"); dactyl.assert(!cmd || commands.validName.test(cmd), "E182: Invalid command name");
if (args.literalArg) { if (args.literalArg) {
let completeOpt = args["-complete"]; let completeOpt = args["-complete"];

View File

@@ -480,7 +480,7 @@ function isinstance(targ, src) {
/** /**
* Returns true if obj is a non-null object. * Returns true if obj is a non-null object.
*/ */
function isObject(obj) typeof obj === "object" && obj != null; function isObject(obj) typeof obj === "object" && obj != null || obj instanceof Ci.nsISupports;
/** /**
* Returns true if and only if its sole argument is an * Returns true if and only if its sole argument is an

View File

@@ -773,11 +773,11 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
XML.prettyPrinting = false; XML.prettyPrinting = false;
XML.ignoreWhitespace = false; XML.ignoreWhitespace = false;
if (object === null) if (object == null)
return "null\n"; return object + "\n";
if (typeof object !== "object") if (!isObject(object))
return false; return String(object);
if (object instanceof Ci.nsIDOMElement) { if (object instanceof Ci.nsIDOMElement) {
const NAMESPACES = array.toObject([ const NAMESPACES = array.toObject([