1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 16:22:27 +01:00

Add template.listCompleter to list completion results to the MOW.

This commit is contained in:
Kris Maglione
2008-11-25 07:30:23 +00:00
parent b543359408
commit 3affc98ea5
10 changed files with 105 additions and 136 deletions

View File

@@ -32,6 +32,23 @@ const template = {
return <>{xml}</>;
},
listCompleter: function (name, filter)
{
let context = new CompletionContext(filter || "");
context.fork.apply(context, ["list", 0, completion, name].concat(Array.slice(arguments, 2)));
context = context.contexts["/list"];
while (context.incomplete)
liberator.threadYield(true, true);
let list = this.generic(
<div class="hl-Completions">
{ this.completionRow(context.title, "hl-CompTitle") }
{ template.map(context.items, function (item) context.createRow(item)) }
</div>);
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
},
completionRow: function completionRow(item, class)
{
if (typeof icon == "function")
@@ -93,7 +110,7 @@ const template = {
return <span class="hl-Number">{str}</span>;
case "string":
if (processStrings)
str = <>{util.escapeString(str)}</>;
str = str.quote();
return <span class="hl-String">{str}</span>;
case "boolean":
return <span class="hl-Boolean">{str}</span>;
@@ -188,18 +205,12 @@ const template = {
// @param headers is an array of strings, the text for the header columns
genericTable: function genericTable(items, format)
{
// FIXME: Kludge.
let context = new CompletionContext("");
context.filterFunc = function (items) items;
if (format)
context.format = format;
return this.generic(
<div class="hl-Completions">
{ this.completionRow(context.title, "hl-CompTitle") }
{
this.map(items, function (item) template.completionRow.call(context, { text: context.getKey({item: item}, "text"), item: item }))
}
</div>);
this.listCompleter(function (context) {
context.filterFunc = null;
if (format)
context.format = format;
context.completions = items;
});
},
// returns a single row for a bookmark or history item