1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 15:52:29 +01:00

Protect the MOW from invalid XML. Other minor cleanup.

This commit is contained in:
Kris Maglione
2008-10-04 01:10:53 +00:00
parent 40ff96452e
commit 982bbfd9ce
2 changed files with 25 additions and 44 deletions

View File

@@ -1829,7 +1829,13 @@ liberator.Marks = function () //{{{
} }
} }
var list = liberator.template.marks(marks); let list = liberator.template.tabular(["mark", "line", "col", "file"],
["", "text-align: right", "text-align: right", "color: green"],
([mark[0],
Math.round(mark[1].position.x & 100) + "%",
Math.round(mark[1].position.y & 100) + "%",
mark[1].location]
for each (mark in marks)));
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE); liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
} }
@@ -1871,7 +1877,7 @@ liberator.template = {
return new XML(xml) return new XML(xml)
} }
catch (e) {} catch (e) {}
return xml; return <>{xml}</>;
}, },
generic: function (xml) generic: function (xml)
@@ -1928,28 +1934,6 @@ liberator.template = {
</table>); </table>);
}, },
marks: function (marks)
{
return this.generic(
<table>
<tr class="hl-Title" align="left">
<th>mark</th>
<th>line</th>
<th>col</th>
<th>file</th>
</tr>
{
this.map(marks, function (mark)
<tr>
<td>{mark[0]}</td>
<td align="right">{Math.round(mark[1].position.y * 100)}%</td>
<td align="right">{Math.round(mark[1].position.x * 100)}%</td>
<td style="color: green;">{mark[1].location}</td>
</tr>)
}
</table>);
},
options: function (title, opts) options: function (title, opts)
{ {
return this.generic( return this.generic(
@@ -1973,15 +1957,13 @@ liberator.template = {
{ {
let table = let table =
<table> <table>
<col style={"width: " + (indent || "2ex")}/> <tr class="hl-Title">
<tr> <th colspan="2">{title}</th>
<th class="hl-Title" align="left" colspan="3">{title}</th>
</tr> </tr>
{ {
this.map(data, function (datum) this.map(data, function (datum)
<tr> <tr>
<td/> <td style={"font-weight: bold; min-width: 150px; padding-left: " + (indent || "2ex")}>{datum[0]}</td>
<td style="font-weight: bold; min-width: 150px">{datum[0]}</td>
<td>{liberator.template.maybeXML(datum[1])}</td> <td>{liberator.template.maybeXML(datum[1])}</td>
</tr>) </tr>)
} }

View File

@@ -206,20 +206,19 @@ liberator.CommandLine = function () //{{{
function setMultiline(str, highlightGroup) function setMultiline(str, highlightGroup)
{ {
//outputContainer.collapsed = true; //outputContainer.collapsed = true;
let doc = multilineOutputWidget.contentDocument;
let win = multilineOutputWidget.contentWindow;
var output = "<div class=\"ex-command-output " + highlightGroup + "\">" + str + "</div>"; var output = <div class={"ex-command-output " + highlightGroup}>{liberator.template.maybeXML(str)}</div>;
lastMowOutput = output; lastMowOutput = output;
if (!outputContainer.collapsed) // FIXME: need to make sure an open MOW is closed when commands
{ // that don't generate output are executed
// FIXME: need to make sure an open MOW is closed when commands if (outputContainer.collapsed)
// that don't generate output are executed doc.body.innerHTML = "";
output = multilineOutputWidget.contentDocument.body.innerHTML + output;
//outputContainer.collapsed = true;
}
multilineOutputWidget.contentDocument.body.innerHTML = output; doc.body.appendChild(liberator.util.xmlToDom(output, doc));
var availableHeight = 250; var availableHeight = 250;
try try
@@ -228,30 +227,30 @@ liberator.CommandLine = function () //{{{
getBrowser().mPanelContainer.boxObject.height : getBrowser().boxObject.height; getBrowser().mPanelContainer.boxObject.height : getBrowser().boxObject.height;
} }
catch (e) {} catch (e) {}
var contentHeight = multilineOutputWidget.contentDocument.height; var contentHeight = doc.height;
var height = contentHeight < availableHeight ? contentHeight : availableHeight; var height = contentHeight < availableHeight ? contentHeight : availableHeight;
outputContainer.height = height + "px"; outputContainer.height = height + "px";
outputContainer.collapsed = false; outputContainer.collapsed = false;
if (liberator.options["more"] && multilineOutputWidget.contentWindow.scrollMaxY > 0) if (liberator.options["more"] && win.scrollMaxY > 0)
{ {
// start the last executed command's output at the top of the screen // start the last executed command's output at the top of the screen
var elements = multilineOutputWidget.contentDocument.getElementsByClassName("ex-command-output"); var elements = doc.getElementsByClassName("ex-command-output");
elements[elements.length - 1].scrollIntoView(true); elements[elements.length - 1].scrollIntoView(true);
if (multilineOutputWidget.contentWindow.scrollY >= multilineOutputWidget.contentWindow.scrollMaxY) if (win.scrollY >= win.scrollMaxY)
setLine("Press ENTER or type command to continue", liberator.commandline.HL_QUESTION); setLine("Press ENTER or type command to continue", liberator.commandline.HL_QUESTION);
else else
setLine("-- More --", liberator.commandline.HL_QUESTION); setLine("-- More --", liberator.commandline.HL_QUESTION);
} }
else else
{ {
multilineOutputWidget.contentWindow.scrollTo(0, contentHeight); win.scrollTo(0, contentHeight);
setLine("Press ENTER or type command to continue", liberator.commandline.HL_QUESTION); setLine("Press ENTER or type command to continue", liberator.commandline.HL_QUESTION);
} }
multilineOutputWidget.contentWindow.focus(); win.focus();
startHints = false; startHints = false;
liberator.modes.push(liberator.modes.COMMAND_LINE, liberator.modes.OUTPUT_MULTILINE); liberator.modes.push(liberator.modes.COMMAND_LINE, liberator.modes.OUTPUT_MULTILINE);