mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-11 08:05:45 +01:00
Use :highlight groups for styling input boxes during external editing.
This commit is contained in:
@@ -218,6 +218,11 @@ const ConfigBase = Class(ModuleBase, {
|
|||||||
CompMore::after content: "⌄";
|
CompMore::after content: "⌄";
|
||||||
CompGroup:last-of-type padding-bottom: 1.5ex;
|
CompGroup:last-of-type padding-bottom: 1.5ex;
|
||||||
|
|
||||||
|
EditorEditing;;* background: #bbb !important; -moz-user-input: none; -moz-user-modify: read-only;
|
||||||
|
EditorError;;* background: red !important;
|
||||||
|
EditorBlink1;;* background: yellow !important;
|
||||||
|
EditorBlink2;;*
|
||||||
|
|
||||||
Indicator color: blue; width: 1.5em; text-align: center;
|
Indicator color: blue; width: 1.5em; text-align: center;
|
||||||
Filter font-weight: bold;
|
Filter font-weight: bold;
|
||||||
|
|
||||||
|
|||||||
@@ -280,14 +280,16 @@ const Editor = Module("editor", {
|
|||||||
dactyl.assert(editor);
|
dactyl.assert(editor);
|
||||||
text = Array.map(editor.rootElement.childNodes, function (e) util.domToString(e, true)).join("");
|
text = Array.map(editor.rootElement.childNodes, function (e) util.domToString(e, true)).join("");
|
||||||
}
|
}
|
||||||
let oldBg, tmpBg;
|
|
||||||
function cleanup(error) {
|
let origGroup = textBox && textBox.getAttributeNS(NS, "highlight") || "";
|
||||||
|
let cleanup = util.yieldable(function cleanup(error) {
|
||||||
if (timer)
|
if (timer)
|
||||||
timer.cancel();
|
timer.cancel();
|
||||||
|
|
||||||
|
let blink = ["EditorBlink1", "EditorBlink2"];
|
||||||
if (error) {
|
if (error) {
|
||||||
dactyl.reportError(error, true);
|
dactyl.reportError(error, true);
|
||||||
tmpBg = "red";
|
blink[1] = "EditorError";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dactyl.trapErrors(update, null, true);
|
dactyl.trapErrors(update, null, true);
|
||||||
@@ -295,19 +297,15 @@ const Editor = Module("editor", {
|
|||||||
if (tmpfile && tmpfile.exists())
|
if (tmpfile && tmpfile.exists())
|
||||||
tmpfile.remove(false);
|
tmpfile.remove(false);
|
||||||
|
|
||||||
if (textBox)
|
|
||||||
textBox.removeAttribute("readonly");
|
|
||||||
|
|
||||||
// blink the textbox after returning
|
// blink the textbox after returning
|
||||||
if (textBox) {
|
if (textBox) {
|
||||||
let colors = [tmpBg, oldBg, tmpBg, oldBg];
|
dactyl.focus(textBox);
|
||||||
(function next() {
|
for (let group in values(blink.concat(blink, ""))) {
|
||||||
textBox.style.backgroundColor = colors.shift();
|
highlight.highlightNode(textBox, origGroup + " " + group);
|
||||||
if (colors.length > 0)
|
yield 100;
|
||||||
util.timeout(next, 100);
|
}
|
||||||
})();
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var tmpfile = io.createTempFile();
|
var tmpfile = io.createTempFile();
|
||||||
@@ -315,10 +313,8 @@ const Editor = Module("editor", {
|
|||||||
throw Error("Couldn't create temporary file");
|
throw Error("Couldn't create temporary file");
|
||||||
|
|
||||||
if (textBox) {
|
if (textBox) {
|
||||||
textBox.setAttribute("readonly", "true");
|
highlight.highlightNode(textBox, origGroup + " EditorEditing");
|
||||||
oldBg = textBox.style.backgroundColor;
|
textBox.blur();
|
||||||
tmpBg = "yellow";
|
|
||||||
textBox.style.backgroundColor = "#bbbbbb";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tmpfile.write(text))
|
if (!tmpfile.write(text))
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ const Hive = Class("Hive", {
|
|||||||
sheet.sites = filter;
|
sheet.sites = filter;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sheet = Sheet(name, this._id++, filter.filter(util.identity), String(css), this, agent);
|
sheet = Sheet(name, styles._id++, filter.filter(util.identity), String(css), this, agent);
|
||||||
this.sheets.push(sheet);
|
this.sheets.push(sheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user