mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 09:48:00 +01:00
Bunch-o-fixes, plus some non-trivial changes that I may wind up weeding out.
This commit is contained in:
@@ -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(
|
||||
<html><head><link type="text/css" rel="stylesheet" href={cssUri(css).spec}/></head></html>, doc));
|
||||
<html><head><link type="text/css" rel="stylesheet" href={cssUri(css)}/></head></html>, 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 =
|
||||
<div id="liberator-frame-indicator"
|
||||
style="background-color: red; opacity: 0.5; z-index: 999
|
||||
position: fixed; top: 0; bottom: 0; left: 0; right: 0"/>;
|
||||
|
||||
/* 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 = <div id="liberator-frame-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:<br/>" + liberator.util.objectToString(elem), liberator.commandline.FORCE_MULTILINE);
|
||||
liberator.echo(<>Element:<br/></> + 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);
|
||||
}, <br/>);
|
||||
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()}<br/></> + xml).toXMLString();
|
||||
return <>:{liberator.commandline.getCommand()}<br/></> + xml
|
||||
},
|
||||
|
||||
bookmarks: function (header, items)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 = <table/>;
|
||||
for (let tmplhs in abbrev)
|
||||
{
|
||||
abbrev[tmplhs].forEach(function (abbr)
|
||||
let list =
|
||||
<table>
|
||||
{
|
||||
if (searchFilter.indexOf(abbr[0]) > -1)
|
||||
{
|
||||
list.* += <tr>
|
||||
<td>{abbr[0]}</td>
|
||||
<td>{tmplhs}</td>
|
||||
<td>{abbr[1]}</td>
|
||||
</tr>;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!list.*.length())
|
||||
{
|
||||
liberator.template.map2(abbrev, function (lhs, rhs)
|
||||
liberator.template.map(rhs, function (abbr)
|
||||
searchFilter.indexOf(abbr[0]) < 0 ? undefined :
|
||||
<tr>
|
||||
<td>{abbr[0]}</td>
|
||||
<td>{lhs}</td>
|
||||
<td>{abbr[1]}</td>
|
||||
</tr>))
|
||||
}
|
||||
</table>;
|
||||
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);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -215,11 +215,12 @@ liberator.AutoCommands = function () //{{{
|
||||
<tr>
|
||||
<td class="hl-Title" colspan="2">{event}</td>
|
||||
</tr>
|
||||
+ liberator.template.map(items, function (item)
|
||||
<tr>
|
||||
<td> {item[0]}</td>
|
||||
<td>{item[1]}</td>
|
||||
</tr>))
|
||||
+
|
||||
liberator.template.map(items, function (item)
|
||||
<tr>
|
||||
<td> {item[0]}</td>
|
||||
<td>{item[1]}</td>
|
||||
</tr>))
|
||||
}
|
||||
</table>);
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
|
||||
@@ -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 = <table>
|
||||
{
|
||||
liberator.template.map(liberator.commands, function (command)
|
||||
@@ -290,7 +290,7 @@ const liberator = (function () //{{{
|
||||
<td>{command.description}</td>
|
||||
</tr>)
|
||||
}
|
||||
</table>.toXMLString();
|
||||
</table>;
|
||||
liberator.echo(usage, liberator.commandline.FORCE_MULTILINE);
|
||||
}
|
||||
},
|
||||
@@ -425,7 +425,6 @@ const liberator = (function () //{{{
|
||||
<tr><td> Average time:</td><td align="right"><span style="color: green">{each.toFixed(2)}</span></td><td>{eachUnits}</td></tr>
|
||||
<tr><td> Total time:</td><td align="right"><span style="color: red">{total.toFixed(2)}</span></td><td>{totalUnits}</td></tr>
|
||||
</table>);
|
||||
|
||||
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 = <table>
|
||||
{
|
||||
liberator.template.add(liberator.mappings, function (mapping)
|
||||
@@ -495,8 +493,7 @@ const liberator = (function () //{{{
|
||||
<td>{mapping.description}</td>
|
||||
</tr>)
|
||||
}
|
||||
</table>.toXMLString();
|
||||
|
||||
</table>;
|
||||
liberator.echo(usage, liberator.commandline.FORCE_MULTILINE);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -417,7 +417,6 @@ liberator.Mappings = function () //{{{
|
||||
|
||||
let _maps = (map for ([i, map] in Iterator(maps))
|
||||
if (output[i]));
|
||||
XML.prettyPrinting = false;
|
||||
let list = <table>
|
||||
{
|
||||
liberator.template.map(_maps, function (map)
|
||||
@@ -428,8 +427,7 @@ liberator.Mappings = function () //{{{
|
||||
<td>{map.rhs || "function () { ... }"}</td>
|
||||
</tr>))
|
||||
}
|
||||
</table>
|
||||
|
||||
</table>;
|
||||
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
||||
}
|
||||
|
||||
|
||||
@@ -268,18 +268,20 @@ liberator.Options = function () //{{{
|
||||
{
|
||||
if (!args)
|
||||
{
|
||||
XML.prettyPrinting = false;
|
||||
var str = <table/>
|
||||
for (let [i, value] in Iterator(liberator.globalVariables))
|
||||
{
|
||||
let prefix = typeof value == "number" ? "#" :
|
||||
typeof value == "function" ? "*" :
|
||||
" ";
|
||||
str.* += <tr>
|
||||
<td style="width: 200px;">{i}</td>
|
||||
<td>{prefix}{value}</td>
|
||||
</tr>;
|
||||
}
|
||||
var str =
|
||||
<table>
|
||||
{
|
||||
liberator.template.map2(liberator.globalVariables, function (i, value) {
|
||||
let prefix = typeof value == "number" ? "#" :
|
||||
typeof value == "function" ? "*" :
|
||||
" ";
|
||||
return <tr>
|
||||
<td style="width: 200px;">{i}</td>
|
||||
<td>{prefix}{value}</td>
|
||||
</tr>
|
||||
})
|
||||
}
|
||||
</table>;
|
||||
if (str.*.length())
|
||||
liberator.echo(str, liberator.commandline.FORCE_MULTILINE);
|
||||
else
|
||||
|
||||
@@ -726,7 +726,7 @@ liberator.Tabs = function () //{{{
|
||||
<tr>
|
||||
<td align="right"> {number}</td>
|
||||
<td><span style="color: blue"> {indicator} </span></td>
|
||||
<td style="width:250px; max-width: 500px; overflow: hidden">{title}</td>
|
||||
<td style="width: 250px; max-width: 500px; overflow: hidden">{title}</td>
|
||||
<td><a href="#" class="hl-URL buffer-list">{item[1]}</a></td>
|
||||
</tr>;
|
||||
}
|
||||
|
||||
@@ -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 = <div class={"ex-command-output " + highlightGroup}>{liberator.template.maybeXML(str)}</div>;
|
||||
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
|
||||
|
||||
@@ -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('<?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://" + 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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
11
skin/blank-muttator.xhtml
Normal file
11
skin/blank-muttator.xhtml
Normal file
@@ -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>
|
||||
11
skin/blank-vimperator.xhtml
Normal file
11
skin/blank-vimperator.xhtml
Normal file
@@ -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>
|
||||
16
skin/content.css
Normal file
16
skin/content.css
Normal file
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user