mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-17 18:33:32 +01:00
Added :sty chrome to style the main window, moved a bunch of inline styles to CSS, fixed some completion bugs, removed util.blankDocument
This commit is contained in:
@@ -4,3 +4,4 @@ resource vimperator modules/
|
|||||||
locale vimperator en-US locale/en-US/
|
locale vimperator en-US locale/en-US/
|
||||||
skin vimperator classic/1.0 skin/
|
skin vimperator classic/1.0 skin/
|
||||||
overlay chrome://browser/content/browser.xul chrome://vimperator/content/vimperator.xul
|
overlay chrome://browser/content/browser.xul chrome://vimperator/content/vimperator.xul
|
||||||
|
|
||||||
|
|||||||
@@ -504,8 +504,8 @@ liberator.Bookmarks = function () //{{{
|
|||||||
{
|
{
|
||||||
url: item[0],
|
url: item[0],
|
||||||
title: item[1],
|
title: item[1],
|
||||||
extra: [['keyword', item[2], 'red'],
|
extra: [['keyword', item[2], "hl-Keyword"],
|
||||||
['tags', (item[3]||[]).join(', '), 'blue']].filter(function (i) i[1])
|
['tags', (item[3]||[]).join(', '), "hl-Tag"]].filter(function (i) i[1])
|
||||||
} for each (item in items)));
|
} for each (item in items)));
|
||||||
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ liberator.Buffer = function () //{{{
|
|||||||
const consoleService = Components.classes["@mozilla.org/consoleservice;1"]
|
const consoleService = Components.classes["@mozilla.org/consoleservice;1"]
|
||||||
.getService(Components.interfaces.nsIConsoleService);
|
.getService(Components.interfaces.nsIConsoleService);
|
||||||
const sleep = liberator.sleep;
|
const sleep = liberator.sleep;
|
||||||
|
const storage = liberator.storage;
|
||||||
function Styles(name, store, serial)
|
function Styles(name, store, serial)
|
||||||
{
|
{
|
||||||
const XHTML = "http://www.w3.org/1999/xhtml";
|
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 cssUri = function (css) "data:text/css," + encodeURI(css);
|
||||||
|
|
||||||
let sheets = [];
|
let userSheets = [];
|
||||||
this.__iterator__ = function () Iterator(sheets);
|
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);
|
let errors = checkSyntax(css);
|
||||||
if (errors.length)
|
if (errors.length)
|
||||||
return errors.map(function (e) "CSS: " + filter + ": " + e).join("\n");
|
return errors.map(function (e) "CSS: " + filter + ": " + e).join("\n");
|
||||||
@@ -70,11 +82,16 @@ liberator.Buffer = function () //{{{
|
|||||||
filter = filter.split(",");
|
filter = filter.split(",");
|
||||||
sheets.push([filter, css]);
|
sheets.push([filter, css]);
|
||||||
this.registerSheet(cssUri(wrapCSS(filter, css)));
|
this.registerSheet(cssUri(wrapCSS(filter, css)));
|
||||||
|
|
||||||
|
if (filter.indexOf("chrome") > -1)
|
||||||
|
storage.fireEvent(name, "chrome-added")
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.removeSheet = function (filter, index)
|
this.removeSheet = function (filter, index, system)
|
||||||
{
|
{
|
||||||
|
let sheets = system ? systemSheets : userSheets;
|
||||||
|
|
||||||
if (filter == undefined)
|
if (filter == undefined)
|
||||||
filter = "";
|
filter = "";
|
||||||
/* Find all sheets which match the filter */
|
/* Find all sheets which match the filter */
|
||||||
@@ -87,15 +104,25 @@ liberator.Buffer = function () //{{{
|
|||||||
else if (index)
|
else if (index)
|
||||||
matches = [m for each (m in matches) if (m[1][1] == index)];
|
matches = [m for each (m in matches) if (m[1][1] == index)];
|
||||||
|
|
||||||
|
let foundChrome = false;
|
||||||
for (let [,[i, sheet]] in Iterator(matches.reverse()))
|
for (let [,[i, sheet]] in Iterator(matches.reverse()))
|
||||||
{
|
{
|
||||||
|
let sites = sheet[0];
|
||||||
this.unregisterSheet(cssUri(wrapCSS(sheet[0], sheet[1])));
|
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))
|
if (sheet[0].length && isNaN(filter))
|
||||||
this.registerSheet(cssUri(wrapCSS(sheet[0], sheet[1])));
|
this.registerSheet(cssUri(wrapCSS(sheet[0], sheet[1])));
|
||||||
else
|
else
|
||||||
sheets.splice(i, 1);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,6 +211,15 @@ liberator.Buffer = function () //{{{
|
|||||||
|
|
||||||
let styles = liberator.storage.newObject("styles", Styles, false);
|
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. */
|
/* FIXME: This doesn't belong here. */
|
||||||
let mainWindowID = liberator.config.mainWindowID || "main-window";
|
let mainWindowID = liberator.config.mainWindowID || "main-window";
|
||||||
let fontSize = document.defaultView.getComputedStyle(document.getElementById(mainWindowID), null)
|
let fontSize = document.defaultView.getComputedStyle(document.getElementById(mainWindowID), null)
|
||||||
@@ -192,7 +228,7 @@ liberator.Buffer = function () //{{{
|
|||||||
let name = liberator.config.name.toLowerCase();
|
let name = liberator.config.name.toLowerCase();
|
||||||
styles.registerSheet("chrome://" + name + "/skin/vimperator.css");
|
styles.registerSheet("chrome://" + name + "/skin/vimperator.css");
|
||||||
let error = styles.addSheet("chrome://" + name + "/content/buffer.xhtml",
|
let error = styles.addSheet("chrome://" + name + "/content/buffer.xhtml",
|
||||||
"body { font-size: " + fontSize + "}");
|
"body { font-size: " + fontSize + "}", true);
|
||||||
|
|
||||||
function setZoom(value, fullZoom)
|
function setZoom(value, fullZoom)
|
||||||
{
|
{
|
||||||
@@ -862,7 +898,7 @@ liberator.Buffer = function () //{{{
|
|||||||
nFeed++;
|
nFeed++;
|
||||||
var type = feedTypes[feed.type] || feedTypes["application/rss+xml"];
|
var type = feedTypes[feed.type] || feedTypes["application/rss+xml"];
|
||||||
if (verbose)
|
if (verbose)
|
||||||
yield [feed.title, liberator.util.highlightURL(feed.href, true) + <span style="color: gray;"> ({type})</span>];
|
yield [feed.title, liberator.util.highlightURL(feed.href, true) + <span class="extra-info"> ({type})</span>];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1947,10 +1983,10 @@ liberator.template = {
|
|||||||
<a href="#" class="hl-URL">{item.url}</a> 
|
<a href="#" class="hl-URL">{item.url}</a> 
|
||||||
{
|
{
|
||||||
!(item.extra && item.extra.length) ? "" :
|
!(item.extra && item.extra.length) ? "" :
|
||||||
<span style="color: gray;">
|
<span class="extra-info">
|
||||||
({
|
({
|
||||||
liberator.template.map(item.extra, function (e)
|
liberator.template.map(item.extra, function (e)
|
||||||
<>{e[0]}: <span style={"color: " + e[2]}>{e[1]}</span></>,
|
<>{e[0]}: <span class={e[2]}>{e[1]}</span></>,
|
||||||
<![CDATA[ ]]>/* Non-breaking space */)
|
<![CDATA[ ]]>/* Non-breaking space */)
|
||||||
})
|
})
|
||||||
</span>
|
</span>
|
||||||
@@ -1971,7 +2007,7 @@ liberator.template = {
|
|||||||
{
|
{
|
||||||
this.map2(elems, function (idx, val)
|
this.map2(elems, function (idx, val)
|
||||||
<tr>
|
<tr>
|
||||||
<td style="color: blue;">{idx == index ? ">" : ""}</td>
|
<td class="indicator">{idx == index ? ">" : ""}</td>
|
||||||
<td>{Math.abs(idx - index)}</td>
|
<td>{Math.abs(idx - index)}</td>
|
||||||
<td style="width: 250px; max-width: 500px; overflow: hidden;">{val.title}</td>
|
<td style="width: 250px; max-width: 500px; overflow: hidden;">{val.title}</td>
|
||||||
<td><a href="#" class="hl-URL jump-list">{val.URI.spec}</a></td>
|
<td><a href="#" class="hl-URL jump-list">{val.URI.spec}</a></td>
|
||||||
@@ -1992,7 +2028,7 @@ liberator.template = {
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<span style={opt.isDefault ? "" : "font-weight: bold"}>{opt.pre}{opt.name}{opt.value}</span>
|
<span style={opt.isDefault ? "" : "font-weight: bold"}>{opt.pre}{opt.name}{opt.value}</span>
|
||||||
{opt.isDefault || opt.default == null ? "" : <span style="color: gray"> (default: {opt.default})</span>}
|
{opt.isDefault || opt.default == null ? "" : <span class="extra-info"> (default: {opt.default})</span>}
|
||||||
</td>
|
</td>
|
||||||
</tr>)
|
</tr>)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -454,9 +454,9 @@ const liberator = (function () //{{{
|
|||||||
<tr class="hl-Title" align="left">
|
<tr class="hl-Title" align="left">
|
||||||
<th colspan="3">Code execution summary</th>
|
<th colspan="3">Code execution summary</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td> Executed:</td><td align="right"><span style="color: green">{count}</span></td><td>times</td></tr>
|
<tr><td> Executed:</td><td align="right"><span class="times-executed">{count}</span></td><td>times</td></tr>
|
||||||
<tr><td> Average time:</td><td align="right"><span style="color: green">{each.toFixed(2)}</span></td><td>{eachUnits}</td></tr>
|
<tr><td> Average time:</td><td align="right"><span class="time-average">{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>
|
<tr><td> Total time:</td><td align="right"><span class="time-total">{total.toFixed(2)}</span></td><td>{totalUnits}</td></tr>
|
||||||
</table>);
|
</table>);
|
||||||
liberator.commandline.echo(str, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
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);
|
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
|
// with (liberator) means, liberator is the default namespace "inside" eval
|
||||||
eval: function (str)
|
eval: function (str)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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);"/>
|
oncommandupdate="if (typeof liberator.events != 'undefined') liberator.events.onSelectionChange(event);"/>
|
||||||
|
|
||||||
<vbox class="liberator-container" hidden="false" collapsed="true">
|
<vbox class="liberator-container" hidden="false" collapsed="true">
|
||||||
<iframe id="liberator-multiline-output" src="about:blank" flex="1" height="10px" hidden="false" collapsed="false"
|
<iframe id="liberator-multiline-output" src="chrome://muttator/content/buffer.xhtml"
|
||||||
|
flex="1" height="10px" hidden="false" collapsed="false"
|
||||||
onclick="liberator.commandline.onMultilineOutputEvent(event)"/>
|
onclick="liberator.commandline.onMultilineOutputEvent(event)"/>
|
||||||
</vbox>
|
</vbox>
|
||||||
|
|
||||||
<vbox class="liberator-container" hidden="false" collapsed="true">
|
<vbox class="liberator-container" hidden="false" collapsed="true">
|
||||||
<iframe id="liberator-completions" src="about:blank" flex="1" height="250px" hidden="false" collapsed="false"
|
<iframe id="liberator-completions" src="chrome://muttator/content/buffer.xhtml"
|
||||||
|
flex="1" height="250px" hidden="false" collapsed="false"
|
||||||
onclick="liberator.commandline.onMultilineOutputEvent(event)"/>
|
onclick="liberator.commandline.onMultilineOutputEvent(event)"/>
|
||||||
</vbox>
|
</vbox>
|
||||||
|
|
||||||
|
|||||||
@@ -89,12 +89,14 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
|||||||
</statusbar>
|
</statusbar>
|
||||||
|
|
||||||
<vbox class="liberator-container" hidden="false" collapsed="true">
|
<vbox class="liberator-container" hidden="false" collapsed="true">
|
||||||
<iframe id="liberator-multiline-output" src="about:blank" flex="1" height="10px" hidden="false" collapsed="false"
|
<iframe id="liberator-multiline-output" "chrome://muttator/content/buffer.xhtml"
|
||||||
|
flex="1" height="10px" hidden="false" collapsed="false"
|
||||||
onclick="liberator.commandline.onMultilineOutputEvent(event)"/>
|
onclick="liberator.commandline.onMultilineOutputEvent(event)"/>
|
||||||
</vbox>
|
</vbox>
|
||||||
|
|
||||||
<vbox class="liberator-container" hidden="false" collapsed="true">
|
<vbox class="liberator-container" hidden="false" collapsed="true">
|
||||||
<iframe id="liberator-completions" src="about:blank" flex="1" height="250px" hidden="false" collapsed="false"
|
<iframe id="liberator-completions" src="chrome://muttator/content/buffer.xhtml"
|
||||||
|
flex="1" height="250px" hidden="false" collapsed="false"
|
||||||
onclick="liberator.commandline.onMultilineOutputEvent(event)"/>
|
onclick="liberator.commandline.onMultilineOutputEvent(event)"/>
|
||||||
</vbox>
|
</vbox>
|
||||||
|
|
||||||
|
|||||||
@@ -724,7 +724,7 @@ liberator.Tabs = function () //{{{
|
|||||||
items.* +=
|
items.* +=
|
||||||
<tr>
|
<tr>
|
||||||
<td align="right"> {number}</td>
|
<td align="right"> {number}</td>
|
||||||
<td><span style="color: blue"> {indicator} </span></td>
|
<td><span class="indicator"> {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>
|
<td><a href="#" class="hl-URL buffer-list">{item[1]}</a></td>
|
||||||
</tr>;
|
</tr>;
|
||||||
|
|||||||
119
content/ui.js
119
content/ui.js
@@ -105,7 +105,7 @@ liberator.CommandLine = function () //{{{
|
|||||||
var wildIndex = 0; // keep track how often we press <Tab> in a row
|
var wildIndex = 0; // keep track how often we press <Tab> in a row
|
||||||
var startHints = false; // whether we're waiting to start hints mode
|
var startHints = false; // whether we're waiting to start hints mode
|
||||||
|
|
||||||
var statusTimer = new liberator.util.Timer(50, 100, function ()
|
var statusTimer = new liberator.util.Timer(51, 100, function ()
|
||||||
liberator.statusline.updateProgress("match " + (completionIndex + 1) + " of " + completions.length));
|
liberator.statusline.updateProgress("match " + (completionIndex + 1) + " of " + completions.length));
|
||||||
var autocompleteTimer = new liberator.util.Timer(50, 100, function (command) {
|
var autocompleteTimer = new liberator.util.Timer(50, 100, function (command) {
|
||||||
let res = liberator.completion.ex(command);
|
let res = liberator.completion.ex(command);
|
||||||
@@ -121,7 +121,7 @@ liberator.CommandLine = function () //{{{
|
|||||||
|
|
||||||
// the widget used for multiline output
|
// the widget used for multiline output
|
||||||
var multilineOutputWidget = document.getElementById("liberator-multiline-output");
|
var multilineOutputWidget = document.getElementById("liberator-multiline-output");
|
||||||
liberator.util.blankDocument(multilineOutputWidget, "liberator-multiline-output-content");
|
multilineOutputWidget.contentDocument.body.id = "liberator-multiline-output-content";
|
||||||
|
|
||||||
var outputContainer = multilineOutputWidget.parentNode;
|
var outputContainer = multilineOutputWidget.parentNode;
|
||||||
|
|
||||||
@@ -1193,15 +1193,17 @@ liberator.ItemList = function (id) //{{{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var doc;
|
var doc = iframe.contentDocument;
|
||||||
var container = iframe.parentNode;
|
var container = iframe.parentNode;
|
||||||
|
|
||||||
liberator.util.blankDocument(iframe, id + "-content");
|
doc.body.id = id + "-content";
|
||||||
|
|
||||||
var completions = []; // a reference to the Array of completions
|
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
|
var startIndex = -1; // The index of the first displayed item
|
||||||
var listIndex = -1; // listOffset + listIndex = completions[item]
|
var endIndex = -1; // The index one *after* the last displayed item
|
||||||
var selectedElement = null;
|
var selIndex = -1; // The index of the currently selected element
|
||||||
|
var completionBody = null;
|
||||||
|
var completionElements = null;
|
||||||
var minHeight = 0;
|
var minHeight = 0;
|
||||||
|
|
||||||
// TODO: temporary, to be changed/removed
|
// TODO: temporary, to be changed/removed
|
||||||
@@ -1231,9 +1233,9 @@ liberator.ItemList = function (id) //{{{
|
|||||||
if (completionElements.length == 0)
|
if (completionElements.length == 0)
|
||||||
return Math.max(minHeight, doc.height);
|
return Math.max(minHeight, doc.height);
|
||||||
|
|
||||||
var wanted = Math.min(maxItems + listOffset,
|
minHeight = Math.max(minHeight,
|
||||||
completionElements.length);
|
completionElements[completionElements.length - 1]
|
||||||
minHeight = Math.max(minHeight, completionElements[wanted - 1].getBoundingClientRect().bottom);
|
.getBoundingClientRect().bottom);
|
||||||
return minHeight;
|
return minHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1252,37 +1254,33 @@ liberator.ItemList = function (id) //{{{
|
|||||||
*/
|
*/
|
||||||
function fill(offset)
|
function fill(offset)
|
||||||
{
|
{
|
||||||
if (listOffset == offset || offset < 0 || offset >= completions.length && completions.length)
|
let diff = offset - startIndex;
|
||||||
|
if (diff == 0 || offset < 0 || completions.length && offset >= completions.length)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (listIndex > -1 && offset == listOffset + 1)
|
startIndex = offset;
|
||||||
{
|
endIndex = Math.min(startIndex + maxItems, completions.length);
|
||||||
let item = completions[offset + maxItems - 1];
|
|
||||||
listOffset = offset;
|
|
||||||
var row = createRow(item[0], item[1], item[2], true);
|
|
||||||
var e = doc.getElementsByTagName("tbody");
|
|
||||||
e = e[e.length - 1];
|
|
||||||
|
|
||||||
e.removeChild(e.firstChild);
|
if (selIndex > -1 && Math.abs(diff) == 1) /* Scroll one position */
|
||||||
e.appendChild(row);
|
{
|
||||||
completionElements = e.children;
|
let tbody = completionBody;
|
||||||
|
|
||||||
|
if (diff == 1) /* Scroll down */
|
||||||
|
{
|
||||||
|
let item = completions[endIndex - 1];
|
||||||
|
let row = createRow(item[0], item[1], item[2], true);
|
||||||
|
tbody.removeChild(tbody.firstChild);
|
||||||
|
tbody.appendChild(row);
|
||||||
|
}
|
||||||
|
else /* Scroll up */
|
||||||
|
{
|
||||||
|
let item = completions[offset];
|
||||||
|
let row = createRow(item[0], item[1], item[2], true);
|
||||||
|
tbody.removeChild(tbody.lastChild);
|
||||||
|
tbody.insertBefore(row, tbody.firstChild);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (listIndex > -1 && offset == listOffset - 1)
|
|
||||||
{
|
|
||||||
let item = completions[offset];
|
|
||||||
listOffset = offset;
|
|
||||||
var row = createRow(item[0], item[1], item[2], true);
|
|
||||||
var e = doc.getElementsByTagName("tbody");
|
|
||||||
e = e[e.length - 1];
|
|
||||||
|
|
||||||
e.removeChild(e.lastChild);
|
|
||||||
e.insertBefore(row, e.firstChild);
|
|
||||||
completionElements = e.children;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
listOffset = offset;
|
|
||||||
|
|
||||||
// do a full refill of the list:
|
// do a full refill of the list:
|
||||||
doc.body.innerHTML = "";
|
doc.body.innerHTML = "";
|
||||||
@@ -1292,18 +1290,20 @@ liberator.ItemList = function (id) //{{{
|
|||||||
<span class="hl-Title" style="font-weight: bold">Completions:</span>
|
<span class="hl-Title" style="font-weight: bold">Completions:</span>
|
||||||
<table width="100%" style="table-layout: fixed; width: 100%"><tbody/></table>
|
<table width="100%" style="table-layout: fixed; width: 100%"><tbody/></table>
|
||||||
</div>;
|
</div>;
|
||||||
let tbody = div..tbody;
|
|
||||||
|
|
||||||
for (let i in liberator.util.range(offset, Math.min(offset + maxItems,
|
let tbody = div..tbody;
|
||||||
completions.length)))
|
for (let i in liberator.util.range(offset, endIndex))
|
||||||
{
|
{
|
||||||
let elem = completions[i];
|
let elem = completions[i];
|
||||||
tbody.* += createRow(elem[0], elem[1], elem[2]);
|
tbody.* += createRow(elem[0], elem[1], elem[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
doc.body.appendChild(liberator.util.xmlToDom(div, doc));
|
let dom = liberator.util.xmlToDom(div, doc);
|
||||||
|
doc.body.appendChild(dom);
|
||||||
|
|
||||||
|
completionBody = dom.getElementsByTagName("tbody")[0];
|
||||||
|
completionElements = completionBody.childNodes;
|
||||||
|
|
||||||
completionElements = doc.getElementsByClassName("compitem");
|
|
||||||
autoSize();
|
autoSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1332,8 +1332,7 @@ liberator.ItemList = function (id) //{{{
|
|||||||
// if @param selectedItem is given, show the list and select that item
|
// if @param selectedItem is given, show the list and select that item
|
||||||
setItems: function (items, selectedItem)
|
setItems: function (items, selectedItem)
|
||||||
{
|
{
|
||||||
doc = iframe.contentDocument;
|
startIndex = endIndex = selIndex = -1;
|
||||||
listOffset = listIndex = -1;
|
|
||||||
completions = items || [];
|
completions = items || [];
|
||||||
if (typeof selectedItem == "number")
|
if (typeof selectedItem == "number")
|
||||||
{
|
{
|
||||||
@@ -1350,37 +1349,31 @@ liberator.ItemList = function (id) //{{{
|
|||||||
|
|
||||||
if (index == -1 || index == completions.length) // wrapped around
|
if (index == -1 || index == completions.length) // wrapped around
|
||||||
{
|
{
|
||||||
if (listIndex >= 0)
|
if (selIndex >= 0)
|
||||||
completionElements[listIndex - listOffset].style.backgroundColor = "";
|
completionElements[selIndex - startIndex].removeAttribute("selected");
|
||||||
else // list is shown the first time
|
else // list is shown the first time
|
||||||
fill(0);
|
fill(0);
|
||||||
|
selIndex = -1;
|
||||||
listIndex = index;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// find start index
|
// find start index
|
||||||
var newOffset = 0;
|
let newOffset = startIndex;
|
||||||
if (index >= listOffset + maxItems - CONTEXT_LINES)
|
if (index >= endIndex - CONTEXT_LINES)
|
||||||
newOffset = index - maxItems + CONTEXT_LINES + 1;
|
newOffset = index + CONTEXT_LINES - maxItems + 1;
|
||||||
else if (index <= listOffset + CONTEXT_LINES)
|
else if (index <= startIndex + CONTEXT_LINES)
|
||||||
newOffset = index - CONTEXT_LINES;
|
newOffset = index - CONTEXT_LINES;
|
||||||
else
|
|
||||||
newOffset = listOffset;
|
|
||||||
|
|
||||||
if (newOffset + maxItems > completions.length)
|
newOffset = Math.min(newOffset, completions.length - maxItems);
|
||||||
newOffset = completions.length - maxItems;
|
newOffset = Math.max(newOffset, 0);
|
||||||
if (newOffset < 0)
|
|
||||||
newOffset = 0;
|
if (selIndex > -1)
|
||||||
|
completionElements[selIndex - startIndex].removeAttribute("selected");
|
||||||
|
|
||||||
fill(newOffset);
|
fill(newOffset);
|
||||||
|
selIndex = index;
|
||||||
|
completionElements[index - startIndex].setAttribute("selected", "true");
|
||||||
|
|
||||||
if (selectedElement)
|
|
||||||
selectedElement.removeAttribute("selected");
|
|
||||||
selectedElement = completionElements[index - newOffset];
|
|
||||||
selectedElement.setAttribute("selected", "true");
|
|
||||||
|
|
||||||
listIndex = index;
|
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -45,16 +45,18 @@ liberator.util = { //{{{
|
|||||||
{
|
{
|
||||||
if (arg !== undefined)
|
if (arg !== undefined)
|
||||||
this.arg = arg;
|
this.arg = arg;
|
||||||
|
|
||||||
|
let now = Date.now();
|
||||||
if (this.doneAt == -1)
|
if (this.doneAt == -1)
|
||||||
timer.cancel();
|
timer.cancel();
|
||||||
else if (Date.now() >= this.doneAt)
|
else if (now >= this.doneAt || now >= this.latest)
|
||||||
return this.notify();
|
return this.notify();
|
||||||
|
|
||||||
let timeout = minInterval;
|
let timeout = minInterval;
|
||||||
if (this.latest)
|
if (this.latest)
|
||||||
timeout = Math.min(minInterval, this.latest - Date.now());
|
timeout = Math.min(minInterval, this.latest - now);
|
||||||
else
|
else
|
||||||
this.latest = Date.now() + maxInterval;
|
this.latest = now + maxInterval;
|
||||||
timer.initWithCallback(this, timeout, timer.TYPE_ONE_SHOT);
|
timer.initWithCallback(this, timeout, timer.TYPE_ONE_SHOT);
|
||||||
this.doneAt = -1;
|
this.doneAt = -1;
|
||||||
}
|
}
|
||||||
@@ -77,12 +79,6 @@ liberator.util = { //{{{
|
|||||||
yield ary[i];
|
yield ary[i];
|
||||||
},
|
},
|
||||||
|
|
||||||
blankDocument: function (iframe, bodyId)
|
|
||||||
{
|
|
||||||
iframe.addEventListener("load", function () { iframe.contentDocument.body.setAttribute("id", bodyId) }, true);
|
|
||||||
iframe.setAttribute("src", "chrome://" + liberator.config.name.toLowerCase() + "/content/buffer.xhtml");
|
|
||||||
},
|
|
||||||
|
|
||||||
clip: function (str, length)
|
clip: function (str, length)
|
||||||
{
|
{
|
||||||
return str.length <= length ? str : str.substr(0, length - 3) + "...";
|
return str.length <= length ? str : str.substr(0, length - 3) + "...";
|
||||||
@@ -100,22 +96,22 @@ liberator.util = { //{{{
|
|||||||
{
|
{
|
||||||
if (type == "number")
|
if (type == "number")
|
||||||
{
|
{
|
||||||
return <span style="color: red;">{arg}</span>;
|
return <span class="hl-Number">{arg}</span>;
|
||||||
}
|
}
|
||||||
else if (type == "string")
|
else if (type == "string")
|
||||||
{
|
{
|
||||||
if (processStrings)
|
if (processStrings)
|
||||||
arg = <>"{arg.replace(/\n/, "\\n")}"</>;
|
arg = <>"{arg.replace(/\n/, "\\n")}"</>;
|
||||||
|
|
||||||
return <span style="color: green;">{arg}</span>;
|
return <span class="hl-String">{arg}</span>;
|
||||||
}
|
}
|
||||||
else if (type == "boolean")
|
else if (type == "boolean")
|
||||||
{
|
{
|
||||||
return <span style="color: blue;">{arg}</span>;
|
return <span class="hl-Boolean">{arg}</span>;
|
||||||
}
|
}
|
||||||
else if (arg == null || arg == "undefined")
|
else if (arg == null || arg == "undefined")
|
||||||
{
|
{
|
||||||
return <span style="color: blue;">{arg}</span>;
|
return <span class="hl-Null">{arg}</span>;
|
||||||
}
|
}
|
||||||
else if (type == "object" || type == "function")
|
else if (type == "object" || type == "function")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -81,12 +81,14 @@ the terms of any one of the MPL, the GPL or the LGPL.
|
|||||||
<!-- As of Firefox 3.1pre, <iframe>.height changes do not seem to have immediate effect,
|
<!-- As of Firefox 3.1pre, <iframe>.height changes do not seem to have immediate effect,
|
||||||
therefore we need to put them into a <vbox> for which that works just fine -->
|
therefore we need to put them into a <vbox> for which that works just fine -->
|
||||||
<vbox class="liberator-container" hidden="false" collapsed="true">
|
<vbox class="liberator-container" hidden="false" collapsed="true">
|
||||||
<iframe id="liberator-multiline-output" src="about:blank" flex="1" hidden="false" collapsed="false"
|
<iframe id="liberator-multiline-output" src="chrome://vimperator/content/buffer.xhtml"
|
||||||
|
flex="1" hidden="false" collapsed="false"
|
||||||
onclick="liberator.commandline.onMultilineOutputEvent(event)"/>
|
onclick="liberator.commandline.onMultilineOutputEvent(event)"/>
|
||||||
</vbox>
|
</vbox>
|
||||||
|
|
||||||
<vbox class="liberator-container" hidden="false" collapsed="true">
|
<vbox class="liberator-container" hidden="false" collapsed="true">
|
||||||
<iframe id="liberator-completions" src="about:blank" flex="1" hidden="false" collapsed="false"
|
<iframe id="liberator-completions" src="chrome://vimperator/content/buffer.xhtml"
|
||||||
|
flex="1" hidden="false" collapsed="false"
|
||||||
onclick="liberator.commandline.onMultilineOutputEvent(event)"/>
|
onclick="liberator.commandline.onMultilineOutputEvent(event)"/>
|
||||||
</vbox>
|
</vbox>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user