1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-30 01:55:45 +01:00

Preparation for a future commit and fix ;F in the MOW.

This commit is contained in:
Kris Maglione
2010-09-26 10:36:46 -04:00
parent a1aa473440
commit c8faebba0a
8 changed files with 205 additions and 148 deletions

View File

@@ -256,7 +256,33 @@ const Styles = Module("Styles", {
context.title = ["Site"];
context.completions = [[s, ""] for ([, s] in Iterator(styles.sites))];
});
}
},
propertyPattern: (function () {
const string = /(?:"(?:[^\\"]|\\.)*(?:"|$)|'(?:[^\\']|\\.)*(?:'|$))/.source;
return RegExp(String.replace(<![CDATA[
(?:
(\s*)
([-a-z]*)
(?:
\s* : \s* (
(?:
[-\w]
(?:
\s* \( \s*
(?: S | [^)]* )
\s* (?: \) | $)
)?
\s*
| \s* S \s* | [^;}]*
)*
)
)?
)
(\s* (?: ; | $) )
]]>, /S/g, string).replace(/\s*/g, ""),
"gi");
})()
}, {
commands: function (dactyl, modules, window) {
const commands = modules.commands;
@@ -383,35 +409,13 @@ const Styles = Module("Styles", {
},
completion: function (dactyl, modules, window) {
const names = Array.slice(util.computedStyle(window.document.createElement("div")));
const string = /(?:"(?:[^\\"]|\\.)*(?:"|$)|'(?:[^\\']|\\.)*(?:'|$))/.source;
const pattern = RegExp(String.replace(<![CDATA[
(?:
(\s*)
([-a-z]*)
(?:
\s* : \s* (
(?:
[-\w]
(?:
\s* \( \s*
(?: S | [^)]* )
\s* (?: \) | $)
)?
\s*
| \s* S \s* | [^;}]*
)*
)
)?
)
(\s* (?: ; | $) )
]]>, /S/g, string).replace(/\s*/g, ""), "gi");
modules.completion.css = function (context) {
context.title = ["Property"];
context.title = ["CSS Property"];
context.keys = { text: function (p) p + ":", description: function () "" };
pattern.lastIndex = 0;
Styles.propertyPattern.lastIndex = 0;
let match, lastMatch;
while ((!match || match[0]) && (match = pattern.exec(context.filter)) && (match[0].length || !lastMatch))
while ((!match || match[0]) && (match = Styles.propertyPattern.exec(context.filter)) && (match[0].length || !lastMatch))
lastMatch = match;
if (lastMatch != null && !lastMatch[3] && !lastMatch[4]) {
context.advance(lastMatch.index + lastMatch[1].length)