diff --git a/chrome.manifest b/chrome.manifest index 1d72d897..ed4476f9 100644 --- a/chrome.manifest +++ b/chrome.manifest @@ -4,3 +4,4 @@ resource vimperator modules/ locale vimperator en-US locale/en-US/ skin vimperator classic/1.0 skin/ overlay chrome://browser/content/browser.xul chrome://vimperator/content/vimperator.xul + diff --git a/content/bookmarks.js b/content/bookmarks.js index 42b5c156..56e7193b 100644 --- a/content/bookmarks.js +++ b/content/bookmarks.js @@ -504,8 +504,8 @@ liberator.Bookmarks = function () //{{{ { url: item[0], title: item[1], - extra: [['keyword', item[2], 'red'], - ['tags', (item[3]||[]).join(', '), 'blue']].filter(function (i) i[1]) + extra: [['keyword', item[2], "hl-Keyword"], + ['tags', (item[3]||[]).join(', '), "hl-Tag"]].filter(function (i) i[1]) } for each (item in items))); liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE); }, diff --git a/content/buffer.js b/content/buffer.js index 6d0f0137..e5d8c875 100644 --- a/content/buffer.js +++ b/content/buffer.js @@ -46,6 +46,7 @@ liberator.Buffer = function () //{{{ const consoleService = Components.classes["@mozilla.org/consoleservice;1"] .getService(Components.interfaces.nsIConsoleService); const sleep = liberator.sleep; + const storage = liberator.storage; function Styles(name, store, serial) { const XHTML = "http://www.w3.org/1999/xhtml"; @@ -56,11 +57,22 @@ liberator.Buffer = function () //{{{ let cssUri = function (css) "data:text/css," + encodeURI(css); - let sheets = []; - this.__iterator__ = function () Iterator(sheets); + let userSheets = []; + let systemSheets = []; - this.addSheet = function (filter, css) + this.__iterator__ = function () Iterator(userSheets); + this.__defineGetter__("systemSheets", function () Iterator(systemSheets)); + + this.__defineGetter__("chromeCSS", function () { + let css = [v[1] for ([k, v] in this) if (v[0].indexOf("chrome") >= 0)]; + return cssUri(css.join("\n/**/\n")); + }); + + this.addSheet = function (filter, css, system) + { + let sheets = system ? systemSheets : userSheets; + let errors = checkSyntax(css); if (errors.length) return errors.map(function (e) "CSS: " + filter + ": " + e).join("\n"); @@ -70,11 +82,16 @@ liberator.Buffer = function () //{{{ filter = filter.split(","); sheets.push([filter, css]); this.registerSheet(cssUri(wrapCSS(filter, css))); + + if (filter.indexOf("chrome") > -1) + storage.fireEvent(name, "chrome-added") return null; } - this.removeSheet = function (filter, index) + this.removeSheet = function (filter, index, system) { + let sheets = system ? systemSheets : userSheets; + if (filter == undefined) filter = ""; /* Find all sheets which match the filter */ @@ -87,15 +104,25 @@ liberator.Buffer = function () //{{{ else if (index) matches = [m for each (m in matches) if (m[1][1] == index)]; + let foundChrome = false; for (let [,[i, sheet]] in Iterator(matches.reverse())) { + let sites = sheet[0]; this.unregisterSheet(cssUri(wrapCSS(sheet[0], sheet[1]))); - sheet[0] = sheet[0].filter(function (f) f != filter); + sheet[0] = sites.filter(function (f) f != filter); if (sheet[0].length && isNaN(filter)) this.registerSheet(cssUri(wrapCSS(sheet[0], sheet[1]))); else sheets.splice(i, 1); + /* Crazy, I know. If we had chrome before, and either we don't have it now, or we've removed + * the whole entry, we've found chrome. + * Perhaps we out to just refresh the chrome stylesheet any time anything is removed. + */ + if (!foundChrome && sites.indexOf("chrome") > -1 && (sheet[0].indexOf("chrome") == -1 || !isNaN(filter))) + foundChrome = true; } + if (foundChrome) + storage.fireEvent(name, "chrome-removed"); return true; } @@ -184,6 +211,15 @@ liberator.Buffer = function () //{{{ let styles = liberator.storage.newObject("styles", Styles, false); + let stylesheet = document.createProcessingInstruction("xml-stylesheet", ""); + document.insertBefore(stylesheet, document.firstChild); + + let chromeObserver = function () { stylesheet.data = 'type="text/css" href="' + styles.chromeCSS + '"' }; + storage.addObserver("styles", chromeObserver); + liberator.registerObserver("shutdown", function () { + liberator.storage.removeObserver("styles", chromeObserver) + }); + /* FIXME: This doesn't belong here. */ let mainWindowID = liberator.config.mainWindowID || "main-window"; let fontSize = document.defaultView.getComputedStyle(document.getElementById(mainWindowID), null) @@ -192,7 +228,7 @@ liberator.Buffer = function () //{{{ let name = liberator.config.name.toLowerCase(); styles.registerSheet("chrome://" + name + "/skin/vimperator.css"); let error = styles.addSheet("chrome://" + name + "/content/buffer.xhtml", - "body { font-size: " + fontSize + "}"); + "body { font-size: " + fontSize + "}", true); function setZoom(value, fullZoom) { @@ -862,7 +898,7 @@ liberator.Buffer = function () //{{{ nFeed++; var type = feedTypes[feed.type] || feedTypes["application/rss+xml"]; if (verbose) - yield [feed.title, liberator.util.highlightURL(feed.href, true) +  ({type})]; + yield [feed.title, liberator.util.highlightURL(feed.href, true) +  ({type})]; } } } @@ -1947,10 +1983,10 @@ liberator.template = { {item.url}  { !(item.extra && item.extra.length) ? "" : - + ({ liberator.template.map(item.extra, function (e) - <>{e[0]}: {e[1]}, + <>{e[0]}: {e[1]}, /* Non-breaking space */) }) @@ -1971,7 +2007,7 @@ liberator.template = { { this.map2(elems, function (idx, val) - {idx == index ? ">" : ""} + {idx == index ? ">" : ""} {Math.abs(idx - index)} {val.title} {val.URI.spec} @@ -1992,7 +2028,7 @@ liberator.template = { {opt.pre}{opt.name}{opt.value} - {opt.isDefault || opt.default == null ? "" : (default: {opt.default})} + {opt.isDefault || opt.default == null ? "" : (default: {opt.default})} ) } diff --git a/content/liberator.js b/content/liberator.js index 79ac99c2..4d8bc312 100644 --- a/content/liberator.js +++ b/content/liberator.js @@ -454,9 +454,9 @@ const liberator = (function () //{{{ Code execution summary -   Executed:{count}times -   Average time:{each.toFixed(2)}{eachUnits} -   Total time:{total.toFixed(2)}{totalUnits} +   Executed:{count}times +   Average time:{each.toFixed(2)}{eachUnits} +   Total time:{total.toFixed(2)}{totalUnits} ); liberator.commandline.echo(str, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE); } @@ -685,6 +685,18 @@ const liberator = (function () //{{{ dump(liberator.config.name.toLowerCase() + ": " + message); }, + dumpStack: function (msg) + { + try + { + someStatisticallyImprobableVariableName.foo = 1; + } + catch (e) + { + liberator.dump((msg || "") + e.stack); + } + }, + // with (liberator) means, liberator is the default namespace "inside" eval eval: function (str) { diff --git a/content/muttator.xul b/content/muttator.xul index 964d801e..4e1a0412 100644 --- a/content/muttator.xul +++ b/content/muttator.xul @@ -80,12 +80,14 @@ the terms of any one of the MPL, the GPL or the LGPL. oncommandupdate="if (typeof liberator.events != 'undefined') liberator.events.onSelectionChange(event);"/>