1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 09:17:59 +01:00

Get rid of *style options and add highlight groups

This commit is contained in:
Kris Maglione
2008-10-07 14:46:18 +00:00
parent 45ad9f0c8b
commit 12a6b7ee05
4 changed files with 24 additions and 37 deletions

View File

@@ -37,7 +37,11 @@ liberator.Buffer = function () //{{{
const highlightClasses = ["Boolean", "ErrorMsg", "Function", "InfoMsg", "Keyword", const highlightClasses = ["Boolean", "ErrorMsg", "Function", "InfoMsg", "Keyword",
"LineNr", "ModeMsg", "MoreMsg", "Normal", "Null", "Number", "Question", "LineNr", "ModeMsg", "MoreMsg", "Normal", "Null", "Number", "Question",
"StatusLine", "StatusLineBroken", "StatusLineSecure", "String", "Tag", "StatusLine", "StatusLineBroken", "StatusLineSecure", "String", "Tag",
"Title", "URL", "WarningMsg"]; "Title", "URL", "WarningMsg",
["Hint", ".liberator-hint", "*"]
["Search", ".__liberator-search", "*"],
["Bell", "#liberator-visualbell"],
];
let name = liberator.config.name.toLowerCase(); let name = liberator.config.name.toLowerCase();
const highlightDocs = "chrome://" + name + "/content/buffer.xhtml,chrome://browser/content/browser.xul"; const highlightDocs = "chrome://" + name + "/content/buffer.xhtml,chrome://browser/content/browser.xul";
@@ -1092,22 +1096,27 @@ liberator.Buffer = function () //{{{
{ {
let [, class, selectors] = key.match(/^([a-zA-Z_-]+)(.*)/); let [, class, selectors] = key.match(/^([a-zA-Z_-]+)(.*)/);
if (highlightClasses.indexOf(class) == -1) let class = highlightClasses.filter(function (i) i == class || i[0] == class)[0];
if (!class)
{ {
liberator.echoerr("Unknown highlight keyword"); liberator.echoerr("Unknown highlight keyword");
return; return;
} }
if (!(class instanceof Array))
class = [class];
let cssClass = class[1] || ".hl-" + class[0];
let scope = class[2] || highlightDocs;
let getCSS = function (style) ".hl-" + class + selectors + " { " + style.replace(/(?:!\s*important\s*)?(?:;|;?$)/g, "!important;") + " }"; let getCSS = function (style) cssClass + selectors + " { " + style.replace(/(?:!\s*important\s*)?(?:;|;?$)/g, "!important;") + " }";
let css = getCSS(style); let css = getCSS(style);
if (highlight.get(key)) if (highlight.get(key))
styles.removeSheet(highlightDocs, getCSS(highlight.get(key)), true); styles.removeSheet(scope, getCSS(highlight.get(key)), true);
if (/^\s*$/.test(style)) if (/^\s*$/.test(style))
return highlight.remove(key); return highlight.remove(key);
let error = styles.addSheet(highlightDocs, css, true, force); let error = styles.addSheet(scope, css, true, force);
if (error) if (error)
liberator.echoerr(error); liberator.echoerr(error);
else else

View File

@@ -176,9 +176,7 @@ liberator.Search = function () //{{{
return; return;
} }
var baseNode = <span style={liberator.options["hlsearchstyle"] + var baseNode = <span class="__liberator-search"/>
"; display: inline; font-size: inherit; padding: 0"}
class="__liberator-search"/>
baseNode = liberator.util.xmlToDom(baseNode, window.content.document); baseNode = liberator.util.xmlToDom(baseNode, window.content.document);
var body = doc.body; var body = doc.body;
@@ -245,12 +243,6 @@ liberator.Search = function () //{{{
} }
}); });
// TODO: use Search highlight group instead when we have proper highlight
// support
liberator.options.add(["hlsearchstyle", "hlss"],
"CSS specification of highlighted search items",
"string", "color: black; background-color: yellow; padding: 0; display: inline;");
liberator.options.add(["ignorecase", "ic"], liberator.options.add(["ignorecase", "ic"],
"Ignore case in search patterns", "Ignore case in search patterns",
"boolean", true); "boolean", true);

View File

@@ -88,7 +88,7 @@ liberator.Hints = function () //{{{
var scrollY = doc.defaultView.scrollY; var scrollY = doc.defaultView.scrollY;
var baseNodeAbsolute = liberator.util.xmlToDom( var baseNodeAbsolute = liberator.util.xmlToDom(
<span style={liberator.options["hintstyle"]} class="liberator-hint"/>, doc); <span class="liberator-hint"/>, doc);
var elem, tagname, text, span, rect; var elem, tagname, text, span, rect;
var res = liberator.buffer.evaluateXPath(liberator.options["hinttags"], doc, null, true); var res = liberator.buffer.evaluateXPath(liberator.options["hinttags"], doc, null, true);
@@ -555,10 +555,6 @@ liberator.Hints = function () //{{{
"XPath string of hintable elements activated by ';'", "XPath string of hintable elements activated by ';'",
"string", DEFAULT_HINTTAGS); "string", DEFAULT_HINTTAGS);
liberator.options.add(["hintstyle", "hs"],
"CSS specification of unfocused hints",
"string", "z-index:5000; font-family:monospace; font-size:10px; font-weight: bold; color:white; background-color:red; border-color:ButtonShadow; border-width:0px; border-style:solid; padding:0px 1px 0px 1px; position:absolute;");
liberator.options.add(["hinttags", "ht"], liberator.options.add(["hinttags", "ht"],
"XPath string of hintable elements activated by 'f' and 'F'", "XPath string of hintable elements activated by 'f' and 'F'",
"string", DEFAULT_HINTTAGS); "string", DEFAULT_HINTTAGS);

View File

@@ -123,11 +123,6 @@ const liberator = (function () //{{{
return value; return value;
} }
}); });
liberator.options.add(["visualbellstyle", "t_vb"],
"CSS specification of the visual bell",
"string", "border: none; background-color: black;"
);
} }
function addMappings() function addMappings()
@@ -663,20 +658,15 @@ const liberator = (function () //{{{
{ {
if (liberator.options["visualbell"]) if (liberator.options["visualbell"])
{ {
var vbs = liberator.options["visualbellstyle"]; // flash the visual bell
if (vbs) var popup = document.getElementById("liberator-visualbell");
{ var win = liberator.config.visualbellWindow;
// flash the visual bell var box = document.getBoxObjectFor(win);
var popup = document.getElementById("liberator-visualbell");
var win = liberator.config.visualbellWindow;
var box = document.getBoxObjectFor(win);
popup.style.cssText = vbs; popup.height = box.height;
popup.height = box.height; popup.width = box.width;
popup.width = box.width; popup.openPopup(win, "overlap", 0, 0, false, false);
popup.openPopup(win, "overlap", 0, 0, false, false); setTimeout(function () { popup.hidePopup(); }, 50);
setTimeout(function () { popup.hidePopup(); }, 50);
}
} }
else else
{ {