1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-06 02:35:44 +01:00

Add Find highlight group.

This commit is contained in:
Kris Maglione
2011-04-01 18:20:58 -04:00
parent a52a0dc61f
commit b181d7164f
6 changed files with 30 additions and 5 deletions

View File

@@ -648,10 +648,9 @@ var CommandLine = Module("commandline", {
* @param {XML} xml The output as an E4X XML object.
*/
commandOutput: function commandOutput(xml) {
XML.ignoreWhitespace = false;
XML.prettyPrinting = false;
XML.ignoreWhitespace = XML.prettyPrinting = false;
if (this.command)
this.echo(<>:{this.command}{xml}</>, this.HIGHLIGHT_NORMAL, this.FORCE_MULTILINE);
this.echo(<><div xmlns={XHTML}>:{this.command}</div>&#x0d;{xml}</>, this.HIGHLIGHT_NORMAL, this.FORCE_MULTILINE);
else
this.echo(xml, this.HIGHLIGHT_NORMAL, this.FORCE_MULTILINE);
this.command = null;

View File

@@ -79,6 +79,7 @@
<dt>Enabled</dt> <dd>Text indicating enabled status, such as of an extension or style group</dd>
<dt>ErrorMsg</dt> <dd>Error messages</dd>
<dt>Filter</dt> <dd>The matching text in a completion list</dd>
<dt>Find</dt> <dd>Text find highlighting. Only background and foreground colors apply.</dd>
<dt>FrameIndicator</dt> <dd>The indicator shown when a new frame is selected</dd>
<dt>Function</dt> <dd>A JavaScript Function object</dd>
<dt>Hint</dt> <dd>A hint indicator. See <ex>:help hints</ex></dd>

View File

@@ -13,7 +13,7 @@ Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("config", {
exports: ["ConfigBase", "Config", "config"],
require: ["services", "storage", "util", "template"],
use: ["io", "messages", "prefs"]
use: ["io", "messages", "prefs", "styles"]
}, this);
var ConfigBase = Class("ConfigBase", {
@@ -33,9 +33,12 @@ var ConfigBase = Class("ConfigBase", {
loadStyles: function loadStyles() {
const { highlight } = require("highlight");
highlight.styleableChrome = this.styleableChrome;
highlight.loadCSS(this.CSS);
highlight.loadCSS(this.helpCSS);
if (!util.haveGecko("2b"))
highlight.loadCSS(<![CDATA[
!TabNumber font-weight: bold; margin: 0px; padding-right: .8ex;
@@ -46,6 +49,25 @@ var ConfigBase = Class("ConfigBase", {
text-shadow: black -1px 0 1px, black 0 1px 1px, black 1px 0 1px, black 0 -1px 1px;
}
]]>);
let hl = highlight.set("Find", "");
hl.onChange = function () {
function hex(val) ("#" + util.regexp.iterate(/\d+/g, val)
.map(function (num) ("0" + Number(num).toString(16)).slice(-2))
.join("")
).slice(0, 7);
let elem = services.appShell.hiddenDOMWindow.document.createElement("div");
elem.style.cssText = this.cssText;
let style = util.computedStyle(elem);
let keys = iter(Styles.propertyIter(this.cssText)).map(function (p) p.name).toArray();
let bg = keys.some(function (k) /^background/.test(k));
let fg = keys.indexOf("color") >= 0;
prefs[bg ? "safeSet" : "safeReset"]("ui.textHighlightBackground", hex(style.backgroundColor));
prefs[fg ? "safeSet" : "safeReset"]("ui.textHighlightForeground", hex(style.color));
};
},
get addonID() this.name + "@dactyl.googlecode.com",

View File

@@ -33,6 +33,8 @@ Highlight.liveProperty = function (name, prop) {
h.style.css = h.css;
this.style[prop || name] = this[prop || name];
if (this.onChange)
this.onChange();
});
}
Highlight.liveProperty("agent");

View File

@@ -1694,7 +1694,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
do {
mainThread.processNextEvent(!flush);
if (util.interrupted)
throw new Error("Interrupted");
throw Error("Interrupted");
}
while (flush === true && mainThread.hasPendingEvents());
}

View File

@@ -134,6 +134,7 @@
- CSS property name completion is now available. [b4]
- :delstyle, :styleenable, :styledisable and :styletoggle accept a !
to operate on all styles. [b6]
- Added Find group. [b7]
• IMPORTANT option changes:
- Option value quoting has changed. List options will
no longer be split at quoted commas and the option name,