mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-05 12:55:46 +01:00
Replace older values with :sty/:hi -append rather than simply concatenating the old string.
This commit is contained in:
@@ -207,14 +207,7 @@ const RangeFinder = Module("rangefinder", {
|
|||||||
"Highlight all /find pattern matches on the current page after submission",
|
"Highlight all /find pattern matches on the current page after submission",
|
||||||
"boolean", false, {
|
"boolean", false, {
|
||||||
setter: function (value) {
|
setter: function (value) {
|
||||||
try {
|
rangefinder[value ? "highlight" : "clear"]();
|
||||||
if (value)
|
|
||||||
rangefinder.highlight();
|
|
||||||
else
|
|
||||||
rangefinder.clear();
|
|
||||||
}
|
|
||||||
catch (e) {}
|
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ const Highlights = Module("Highlight", {
|
|||||||
let highlight = this.highlight[key] || this._create(false, [key]);
|
let highlight = this.highlight[key] || this._create(false, [key]);
|
||||||
|
|
||||||
if (append)
|
if (append)
|
||||||
newStyle = (highlight.value || "").replace(/;?\s*$/, "; " + newStyle);
|
newStyle = Styles.append(highlight.value || "", newStyle);
|
||||||
if (/^\s*$/.test(newStyle))
|
if (/^\s*$/.test(newStyle))
|
||||||
newStyle = null;
|
newStyle = null;
|
||||||
if (newStyle == null) {
|
if (newStyle == null) {
|
||||||
|
|||||||
@@ -249,6 +249,17 @@ const Styles = Module("Styles", {
|
|||||||
services.stylesheet.unregisterSheet(uri, type);
|
services.stylesheet.unregisterSheet(uri, type);
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
|
append: function (dest, src, sort) {
|
||||||
|
let props = {};
|
||||||
|
|
||||||
|
for each (let str in [dest, src])
|
||||||
|
for (let prop in Styles.propertyIter(str))
|
||||||
|
props[prop.name] = prop.value;
|
||||||
|
return Object.keys(props)[sort ? "sort" : "slice"]()
|
||||||
|
.map(function (prop) prop + ": " + props[prop] + ";")
|
||||||
|
.join(" ");
|
||||||
|
},
|
||||||
|
|
||||||
completeSite: function (context, content) {
|
completeSite: function (context, content) {
|
||||||
context.anchored = false;
|
context.anchored = false;
|
||||||
try {
|
try {
|
||||||
@@ -294,12 +305,22 @@ const Styles = Module("Styles", {
|
|||||||
return test(arguments[1]);
|
return test(arguments[1]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
propertyIter: function (str, always) {
|
||||||
|
this.propertyPattern.lastIndex = 0;
|
||||||
|
|
||||||
|
let match;
|
||||||
|
while ((!match || match[0]) && (match = Styles.propertyPattern.exec(str)))
|
||||||
|
if (always || match[0])
|
||||||
|
yield this.Property.fromArray(match);
|
||||||
|
},
|
||||||
|
|
||||||
|
Property: Struct("whole", "preSpace", "name", "value", "postSpace"),
|
||||||
propertyPattern: util.regexp(<![CDATA[
|
propertyPattern: util.regexp(<![CDATA[
|
||||||
(?:
|
(?:
|
||||||
(\s*)
|
(<space>*)
|
||||||
([-a-z]*)
|
([-a-z]*)
|
||||||
(?:
|
(?:
|
||||||
\s* : \s* (
|
<space>* : \s* (
|
||||||
(?:
|
(?:
|
||||||
[-\w]
|
[-\w]
|
||||||
(?:
|
(?:
|
||||||
@@ -308,14 +329,19 @@ const Styles = Module("Styles", {
|
|||||||
\s* (?: \) | $)
|
\s* (?: \) | $)
|
||||||
)?
|
)?
|
||||||
\s*
|
\s*
|
||||||
| \s* <string> \s* | [^;}]*
|
| \s* <string> \s*
|
||||||
|
| <space>*
|
||||||
|
| [^;}]*
|
||||||
)*
|
)*
|
||||||
)
|
)
|
||||||
)?
|
)?
|
||||||
)
|
)
|
||||||
(\s* (?: ; | $) )
|
(<space>* (?: ; | $) )
|
||||||
]]>, "gi",
|
]]>, "gi",
|
||||||
{ string: /(?:"(?:[^\\"]|\\.)*(?:"|$)|'(?:[^\\']|\\.)*(?:'|$))/ })
|
{
|
||||||
|
space: /(?: \s | \/\* .*? \*\/ )/,
|
||||||
|
string: /(?:"(?:[^\\"]|\\.)*(?:"|$)|'(?:[^\\']|\\.)*(?:'|$))/
|
||||||
|
})
|
||||||
}, {
|
}, {
|
||||||
commands: function (dactyl, modules, window) {
|
commands: function (dactyl, modules, window) {
|
||||||
const commands = modules.commands;
|
const commands = modules.commands;
|
||||||
@@ -347,7 +373,7 @@ const Styles = Module("Styles", {
|
|||||||
let sheet = styles.get(false, name);
|
let sheet = styles.get(false, name);
|
||||||
if (sheet) {
|
if (sheet) {
|
||||||
filter = sheet.sites.concat(filter).join(",");
|
filter = sheet.sites.concat(filter).join(",");
|
||||||
css = sheet.css + " " + css;
|
css = Styles.append(sheet.css, css);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
styles.addSheet(false, name, filter, css, args["-agent"]);
|
styles.addSheet(false, name, filter, css, args["-agent"]);
|
||||||
@@ -480,12 +506,11 @@ const Styles = Module("Styles", {
|
|||||||
context.title = ["CSS Property"];
|
context.title = ["CSS Property"];
|
||||||
context.keys = { text: function (p) p + ":", description: function () "" };
|
context.keys = { text: function (p) p + ":", description: function () "" };
|
||||||
|
|
||||||
Styles.propertyPattern.lastIndex = 0;
|
for (let match in Styles.propertyIter(context.filter, true))
|
||||||
let match, lastMatch;
|
var lastMatch = match;
|
||||||
while ((!match || match[0]) && (match = Styles.propertyPattern.exec(context.filter)) && (match[0].length || !lastMatch))
|
|
||||||
lastMatch = match;
|
if (lastMatch != null && !lastMatch.value && !lastMatch.postSpace) {
|
||||||
if (lastMatch != null && !lastMatch[3] && !lastMatch[4]) {
|
context.advance(lastMatch.index + lastMatch.name.length)
|
||||||
context.advance(lastMatch.index + lastMatch[1].length)
|
|
||||||
context.completions = names;
|
context.completions = names;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user