diff --git a/content/buffer.js b/content/buffer.js index 4fafcb3f..2a6d6676 100644 --- a/content/buffer.js +++ b/content/buffer.js @@ -47,7 +47,7 @@ liberator.Buffer = function () //{{{ const sss = Components.classes["@mozilla.org/content/style-sheet-service;1"] .getService(Components.interfaces.nsIStyleSheetService); - let cssUri = function (css) ios.newURI("data:text/css," + encodeURI(css), null, null); + let cssUri = function (css) "data:text/css," + encodeURI(css); let sheets = []; this.__iterator__ = function () Iterator(sheets); @@ -58,15 +58,11 @@ liberator.Buffer = function () //{{{ if (errors.length) return errors.map(function (e) "CSS: " + filter + ": " + e).join("\n"); - let chrome = /^chrome:/.test(filter); - if (chrome) - return "Chrome styling not supported"; /* For now. */ - if (sheets.some(function (s) s[0] == filter && s[1] == css)) return null; sheets.push([filter, css]); let uri = cssUri(wrapCSS(filter, css)); - sss.loadAndRegisterSheet(uri, sss.USER_SHEET); + this.registerSheet(uri, sss.USER_SHEET); return null; } @@ -76,10 +72,24 @@ liberator.Buffer = function () //{{{ return false; let sheet = sheets.splice(number)[0]; let uri = cssUri(wrapCSS(sheet[0], sheet[1])); - sss.unregisterSheet(uri, sss.USER_SHEET); + this.unregisterSheet(uri, sss.USER_SHEET); return true; } + this.registerSheet = function (uri) + { + let uri = ios.newURI(uri, null, null); + if (!sss.sheetRegistered(uri, sss.USER_SHEET)) + sss.loadAndRegisterSheet(uri, sss.USER_SHEET); + } + + this.unregisterSheet = function (uri) + { + let uri = ios.newURI(uri, null, null); + if (sss.sheetRegistered(uri, sss.USER_SHEET)) + sss.unregisterSheet(uri, sss.USER_SHEET); + } + function wrapCSS(filter, css) { if (filter == "*") @@ -91,11 +101,12 @@ liberator.Buffer = function () //{{{ /* } vim */ } + let queryinterface = XPCOMUtils.generateQI([Components.interfaces.nsIConsoleListener]); function checkSyntax(css) { let errors = []; let listener = { - QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIConsoleListener]), + QueryInterface: queryinterface, observe: function (message) { try @@ -116,7 +127,7 @@ liberator.Buffer = function () //{{{ { var doc = document.implementation.createDocument(XHTML, "doc", null); doc.documentElement.appendChild(liberator.util.xmlToDom( - , doc)); + , doc)); while (true) { @@ -126,7 +137,7 @@ liberator.Buffer = function () //{{{ break; } catch (e) { if (e.name != "NS_ERROR_DOM_INVALID_ACCESS_ERR") - throw e; + return [e.toString()]; liberator.sleep(10); } } @@ -141,6 +152,18 @@ liberator.Buffer = function () //{{{ let styles = liberator.storage.newObject(styles, Styles, false); + for (let sheet in arrayIter(liberator.config.userSheets || [])) + styles.registerSheet(sheet); + + /* FIXME: This doesn't belong here. */ + let mainWindowID = liberator.config.mainWindowID || "main-window"; + let fontSize = document.defaultView.getComputedStyle(document.getElementById(mainWindowID), null) + .getPropertyValue("font-size"); + + let name = liberator.config.name.toLowerCase(); + let error = styles.addSheet("chrome://" + name + "/skin/blank-" + name + ".xhtml", + "body { font-size: " + fontSize + "}"); + function setZoom(value, fullZoom) { if (value < 1 || value > 2000) @@ -1375,10 +1398,14 @@ liberator.Buffer = function () //{{{ // add the frame indicator var doc = frames[next].document; - var indicator = -
; + + /* Doesn't unapply... + var class = doc.body.class || ""; + doc.body.setAttribute("class", class + " liberator-frame-indicator"); + setTimeout(function () doc.body.setAttribute("class", class), 500); + */ + + var indicator =
; doc.body.appendChild(liberator.util.xmlToDom(indicator)); // remove the frame indicator @@ -1389,7 +1416,7 @@ liberator.Buffer = function () //{{{ // TODO: print more useful information, just like the DOM inspector showElementInfo: function (elem) { - liberator.echo("Element:
" + liberator.util.objectToString(elem), liberator.commandline.FORCE_MULTILINE); + liberator.echo(<>Element:
+ liberator.util.objectToString(elem), liberator.commandline.FORCE_MULTILINE); }, showPageInfo: function (verbose) @@ -1400,8 +1427,8 @@ liberator.Buffer = function () //{{{ let file = content.document.location.pathname.split("/").pop() || "[No Name]"; let title = content.document.title || "[No Title]"; - let info = liberator.template.map("gf", function (opt) - liberator.template.map(pageInfo[opt][0](), function (val) val, ", "), + let info = liberator.template.map("gf", + function (opt) liberator.template.map(pageInfo[opt][0](), function (val) val, ", "), ", "); if (liberator.bookmarks.isBookmarked(this.URL)) @@ -1418,10 +1445,7 @@ liberator.Buffer = function () //{{{ let opt = pageInfo[option]; if (opt) return liberator.template.table(opt[1], opt[0](true)); - else - alert(option); },
); - XML.prettyPrinting = false; liberator.echo(list, liberator.commandline.FORCE_MULTILINE); }, @@ -1872,9 +1896,11 @@ liberator.template = { maybeXML: function (xml) { + if (typeof xml == "xml") + return xml; try { - return new XML(xml) + return new XMLList(xml) } catch (e) {} return <>{xml}; @@ -1882,8 +1908,7 @@ liberator.template = { generic: function (xml) { - XML.prettyPrinting = false; - return (<>:{liberator.commandline.getCommand()}
+ xml).toXMLString(); + return <>:{liberator.commandline.getCommand()}
+ xml }, bookmarks: function (header, items) diff --git a/content/commands.js b/content/commands.js index 2c859eba..9e330494 100644 --- a/content/commands.js +++ b/content/commands.js @@ -710,7 +710,9 @@ liberator.Commands = function () //{{{ if (cmdlist.length > 0) { var str = liberator.template.tabular(["Name", "Args", "Definition"], [], - ([cmd.name, "*", cmd.replacementText || "function () { ... }"] + ([cmd.name, + "*", + cmd.replacementText || "function () { ... }"] for each (cmd in cmdlist))); liberator.commandline.echo(str, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE); } diff --git a/content/editor.js b/content/editor.js index 744f1260..7c7a693b 100644 --- a/content/editor.js +++ b/content/editor.js @@ -928,31 +928,26 @@ liberator.Editor = function () //{{{ } else // list all (for that filter {i,c,!}) { - var searchFilter = (filter == "!") ? "!ci" : filter + "!"; // ! -> list all, on c or i ! matches too) + var searchFilter = (filter == "!") ? "!ci" + : filter + "!"; // ! -> list all, on c or i ! matches too) - XML.prettyPrinting = false; - let list = ; - for (let tmplhs in abbrev) - { - abbrev[tmplhs].forEach(function (abbr) + let list = +
{ - if (searchFilter.indexOf(abbr[0]) > -1) - { - list.* += - - - - ; - } - }); - } - - if (!list.*.length()) - { + liberator.template.map2(abbrev, function (lhs, rhs) + liberator.template.map(rhs, function (abbr) + searchFilter.indexOf(abbr[0]) < 0 ? undefined : + + + + + )) + } +
{abbr[0]}{tmplhs}{abbr[1]}
{abbr[0]}{lhs}{abbr[1]}
; + if (list.*.length()) + liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE); + else liberator.echoerr("No abbreviations found"); - return; - } - liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE); } }, diff --git a/content/events.js b/content/events.js index bd8a0104..e1232fc8 100644 --- a/content/events.js +++ b/content/events.js @@ -215,11 +215,12 @@ liberator.AutoCommands = function () //{{{ {event} - + liberator.template.map(items, function (item) - -  {item[0]} - {item[1]} - )) + + + liberator.template.map(items, function (item) + +  {item[0]} + {item[1]} + )) } ); @@ -666,7 +667,7 @@ liberator.Events = function () //{{{ function (args) { XML.prettyPrinting = false; - var str = liberator.template.tabular(["Macro", "Keys"], [], liberator.events.getMacros(args)); + var str = liberator.template.tabular(["Macro", "Keys"], [], liberator.events.getMacros(args)); liberator.echo(str, liberator.commandline.FORCE_MULTILINE); }, { diff --git a/content/io.js b/content/io.js index f648d829..6c5c3443 100644 --- a/content/io.js +++ b/content/io.js @@ -320,7 +320,6 @@ liberator.IO = function () //{{{ "List all sourced script names", function () { - XML.prettyPrinting = false; var list = liberator.template.tabular(["Idx", "Filename"], ["text-align: right"], Iterator(scriptNames)); liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE); }, diff --git a/content/liberator.js b/content/liberator.js index faa31186..af48a0b4 100644 --- a/content/liberator.js +++ b/content/liberator.js @@ -45,6 +45,7 @@ const liberator = (function () //{{{ } catch (e) { + Components.utils.reportError(e); liberator.dump(e + "\n"); } } @@ -281,7 +282,6 @@ const liberator = (function () //{{{ else { // TODO: clicking on these should open the help - XML.prettyPrinting = false; var usage = { liberator.template.map(liberator.commands, function (command) @@ -290,7 +290,7 @@ const liberator = (function () //{{{ ) } -
{command.description}
.toXMLString(); + ; liberator.echo(usage, liberator.commandline.FORCE_MULTILINE); } }, @@ -425,7 +425,6 @@ const liberator = (function () //{{{   Average time:{each.toFixed(2)}{eachUnits}   Total time:{total.toFixed(2)}{totalUnits} ); - liberator.commandline.echo(str, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE); } else @@ -486,7 +485,6 @@ const liberator = (function () //{{{ else { // TODO: clicking on these should open the help - XML.prettyPrinting = false; var usage = { liberator.template.add(liberator.mappings, function (mapping) @@ -495,8 +493,7 @@ const liberator = (function () //{{{ ) } -
{mapping.description}
.toXMLString(); - + ; liberator.echo(usage, liberator.commandline.FORCE_MULTILINE); } }, diff --git a/content/mappings.js b/content/mappings.js index 908b8bcc..9d956244 100644 --- a/content/mappings.js +++ b/content/mappings.js @@ -417,7 +417,6 @@ liberator.Mappings = function () //{{{ let _maps = (map for ([i, map] in Iterator(maps)) if (output[i])); - XML.prettyPrinting = false; let list = { liberator.template.map(_maps, function (map) @@ -428,8 +427,7 @@ liberator.Mappings = function () //{{{ )) } -
{map.rhs || "function () { ... }"}
- + ; liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE); } diff --git a/content/options.js b/content/options.js index a6747cb6..d7affbc1 100644 --- a/content/options.js +++ b/content/options.js @@ -268,18 +268,20 @@ liberator.Options = function () //{{{ { if (!args) { - XML.prettyPrinting = false; - var str = - for (let [i, value] in Iterator(liberator.globalVariables)) - { - let prefix = typeof value == "number" ? "#" : - typeof value == "function" ? "*" : - " "; - str.* += - - - ; - } + var str = +
{i}{prefix}{value}
+ { + liberator.template.map2(liberator.globalVariables, function (i, value) { + let prefix = typeof value == "number" ? "#" : + typeof value == "function" ? "*" : + " "; + return + + + + }) + } +
{i}{prefix}{value}
; if (str.*.length()) liberator.echo(str, liberator.commandline.FORCE_MULTILINE); else diff --git a/content/tabs.js b/content/tabs.js index 86d3b18c..3e75dc89 100644 --- a/content/tabs.js +++ b/content/tabs.js @@ -726,7 +726,7 @@ liberator.Tabs = function () //{{{ {number} {indicator} - {title} + {title} {item[1]} ; } diff --git a/content/ui.js b/content/ui.js index 3dac34fc..66c26eaf 100644 --- a/content/ui.js +++ b/content/ui.js @@ -121,8 +121,7 @@ liberator.CommandLine = function () //{{{ // the widget used for multiline output var multilineOutputWidget = document.getElementById("liberator-multiline-output"); - multilineOutputWidget.setAttribute("src", - liberator.util.blankDocument("liberator-multiline-output-content")); + liberator.util.blankDocument(multilineOutputWidget, "liberator-multiline-output-content"); var outputContainer = multilineOutputWidget.parentNode; @@ -209,7 +208,9 @@ liberator.CommandLine = function () //{{{ let doc = multilineOutputWidget.contentDocument; let win = multilineOutputWidget.contentWindow; + XML.ignoreWhitespace = false; var output =
{liberator.template.maybeXML(str)}
; + XML.ignoreWhitespace = true; lastMowOutput = output; @@ -1190,7 +1191,7 @@ liberator.ItemList = function (id) //{{{ var doc; var container = iframe.parentNode; - iframe.setAttribute("src", liberator.util.blankDocument(id + "-content")); + liberator.util.blankDocument(iframe, id + "-content"); var completions = []; // a reference to the Array of completions var listOffset = -1; // how many items is the displayed list shifted from the internal tab index diff --git a/content/util.js b/content/util.js index f59a9080..65314492 100644 --- a/content/util.js +++ b/content/util.js @@ -77,22 +77,11 @@ liberator.util = { //{{{ yield ary[i]; }, - blankDocument: function (bodyId) + blankDocument: function (iframe, bodyId) { - let mainWindowID = liberator.config.mainWindowID || "main-window"; - let fontSize = document.defaultView.getComputedStyle(document.getElementById(mainWindowID), null) - .getPropertyValue("font-size"); - - return 'data:application/xhtml+xml,' + encodeURI('' + - '' + - - - - <link rel="stylesheet" type="text/css" - href={"chrome://" + liberator.config.name.toLowerCase() + "/skin/vimperator.css"}/> - </head> - <body id={bodyId} style={"font-size: " + fontSize}/> - </html>) + let name = liberator.config.name.toLowerCase(); + iframe.addEventListener("load", function () iframe.contentDocument.body.setAttribute("id", bodyId), true); + iframe.setAttribute("src", "chrome://" + name + "/skin/blank-" + name + ".xhtml"); }, clip: function (str, length) diff --git a/content/vimperator.js b/content/vimperator.js index 969cad0a..38c76d9e 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -110,6 +110,10 @@ liberator.config = { //{{{ "message.html", "developer.html", "various.html", "index.html" ], + userSheets: [ + "chrome://vimperator/skin/content.css", + ], + init: function () { function incrementURL(count) diff --git a/skin/blank-muttator.xhtml b/skin/blank-muttator.xhtml new file mode 100644 index 00000000..9fe8e380 --- /dev/null +++ b/skin/blank-muttator.xhtml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" + "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title/> + <link rel="stylesheet" type="text/css" + href="chrome://muttator/skin/vimperator.css"/> + </head> + <body/> +</html> diff --git a/skin/blank-vimperator.xhtml b/skin/blank-vimperator.xhtml new file mode 100644 index 00000000..384f2c2c --- /dev/null +++ b/skin/blank-vimperator.xhtml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" + "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title/> + <link rel="stylesheet" type="text/css" + href="chrome://vimperator/skin/vimperator.css"/> + </head> + <body/> +</html> diff --git a/skin/content.css b/skin/content.css new file mode 100644 index 00000000..fdd80886 --- /dev/null +++ b/skin/content.css @@ -0,0 +1,16 @@ + +.liberator-frame-indicator { + -moz-binding: url(chrome://vimperator/content/bindings.xml#frame); +} + +#liberator-frame-indicator { + background-color: red; + opacity: 0.5; + z-index: 999 + position: fixed; + top: 0; + bottom: 0; + left: 0; + right: 0; +} +