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:
@@ -37,7 +37,11 @@ liberator.Buffer = function () //{{{
|
||||
const highlightClasses = ["Boolean", "ErrorMsg", "Function", "InfoMsg", "Keyword",
|
||||
"LineNr", "ModeMsg", "MoreMsg", "Normal", "Null", "Number", "Question",
|
||||
"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();
|
||||
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_-]+)(.*)/);
|
||||
|
||||
if (highlightClasses.indexOf(class) == -1)
|
||||
let class = highlightClasses.filter(function (i) i == class || i[0] == class)[0];
|
||||
if (!class)
|
||||
{
|
||||
liberator.echoerr("Unknown highlight keyword");
|
||||
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);
|
||||
|
||||
if (highlight.get(key))
|
||||
styles.removeSheet(highlightDocs, getCSS(highlight.get(key)), true);
|
||||
styles.removeSheet(scope, getCSS(highlight.get(key)), true);
|
||||
|
||||
if (/^\s*$/.test(style))
|
||||
return highlight.remove(key);
|
||||
|
||||
let error = styles.addSheet(highlightDocs, css, true, force);
|
||||
let error = styles.addSheet(scope, css, true, force);
|
||||
if (error)
|
||||
liberator.echoerr(error);
|
||||
else
|
||||
|
||||
@@ -176,9 +176,7 @@ liberator.Search = function () //{{{
|
||||
return;
|
||||
}
|
||||
|
||||
var baseNode = <span style={liberator.options["hlsearchstyle"] +
|
||||
"; display: inline; font-size: inherit; padding: 0"}
|
||||
class="__liberator-search"/>
|
||||
var baseNode = <span class="__liberator-search"/>
|
||||
baseNode = liberator.util.xmlToDom(baseNode, window.content.document);
|
||||
|
||||
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"],
|
||||
"Ignore case in search patterns",
|
||||
"boolean", true);
|
||||
|
||||
@@ -88,7 +88,7 @@ liberator.Hints = function () //{{{
|
||||
var scrollY = doc.defaultView.scrollY;
|
||||
|
||||
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 res = liberator.buffer.evaluateXPath(liberator.options["hinttags"], doc, null, true);
|
||||
@@ -555,10 +555,6 @@ liberator.Hints = function () //{{{
|
||||
"XPath string of hintable elements activated by ';'",
|
||||
"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"],
|
||||
"XPath string of hintable elements activated by 'f' and 'F'",
|
||||
"string", DEFAULT_HINTTAGS);
|
||||
|
||||
@@ -123,11 +123,6 @@ const liberator = (function () //{{{
|
||||
return value;
|
||||
}
|
||||
});
|
||||
|
||||
liberator.options.add(["visualbellstyle", "t_vb"],
|
||||
"CSS specification of the visual bell",
|
||||
"string", "border: none; background-color: black;"
|
||||
);
|
||||
}
|
||||
|
||||
function addMappings()
|
||||
@@ -663,20 +658,15 @@ const liberator = (function () //{{{
|
||||
{
|
||||
if (liberator.options["visualbell"])
|
||||
{
|
||||
var vbs = liberator.options["visualbellstyle"];
|
||||
if (vbs)
|
||||
{
|
||||
// flash the visual bell
|
||||
var popup = document.getElementById("liberator-visualbell");
|
||||
var win = liberator.config.visualbellWindow;
|
||||
var box = document.getBoxObjectFor(win);
|
||||
// flash the visual bell
|
||||
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.width = box.width;
|
||||
popup.openPopup(win, "overlap", 0, 0, false, false);
|
||||
setTimeout(function () { popup.hidePopup(); }, 50);
|
||||
}
|
||||
popup.height = box.height;
|
||||
popup.width = box.width;
|
||||
popup.openPopup(win, "overlap", 0, 0, false, false);
|
||||
setTimeout(function () { popup.hidePopup(); }, 50);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user