mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-24 07:42:26 +01:00
Get rid of template.map overloading, add standard "usage" template for ex/vi/option
This commit is contained in:
@@ -1558,8 +1558,9 @@ 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))
|
||||
|
||||
@@ -931,7 +931,7 @@ liberator.Editor = function () //{{{
|
||||
let list =
|
||||
<table>
|
||||
{
|
||||
liberator.template.map(abbrev, function (lhs, rhs)
|
||||
liberator.template.map(abbrev, function ([lhs, rhs])
|
||||
liberator.template.map(rhs, function (abbr)
|
||||
searchFilter.indexOf(abbr[0]) < 0 ? undefined :
|
||||
<tr>
|
||||
|
||||
@@ -233,7 +233,7 @@ liberator.AutoCommands = function () //{{{
|
||||
<td class="hl-Title" colspan="2">----- Auto Commands -----</td>
|
||||
</tr>
|
||||
{
|
||||
liberator.template.map(cmds, function (event, items)
|
||||
liberator.template.map(cmds, function ([event, items])
|
||||
<tr>
|
||||
<td class="hl-Title" colspan="2">{event}</td>
|
||||
</tr>
|
||||
|
||||
@@ -280,15 +280,7 @@ const liberator = (function () //{{{
|
||||
else
|
||||
{
|
||||
// TODO: clicking on these should open the help
|
||||
var usage = <table>
|
||||
{
|
||||
liberator.template.map(liberator.commands, function (command)
|
||||
<tr>
|
||||
<td class="hl-Title" style="padding-right: 20px">{command.name}</td>
|
||||
<td>{command.description}</td>
|
||||
</tr>)
|
||||
}
|
||||
</table>;
|
||||
var usage = liberator.template.usage(liberator.commands);
|
||||
liberator.echo(usage, liberator.commandline.FORCE_MULTILINE);
|
||||
}
|
||||
},
|
||||
@@ -361,15 +353,7 @@ const liberator = (function () //{{{
|
||||
else
|
||||
{
|
||||
// TODO: clicking on these should open the help
|
||||
var usage = <table>
|
||||
{
|
||||
liberator.template.map(liberator.options, function (option)
|
||||
<tr>
|
||||
<td class="hl-Title" style="padding-right: 20px">{option.name}</td>
|
||||
<td>{option.description}</td>
|
||||
</tr>)
|
||||
}
|
||||
</table>;
|
||||
var usage = liberator.template.usage(liberator.options);
|
||||
liberator.echo(usage, liberator.commandline.FORCE_MULTILINE);
|
||||
}
|
||||
},
|
||||
@@ -523,15 +507,7 @@ const liberator = (function () //{{{
|
||||
else
|
||||
{
|
||||
// TODO: clicking on these should open the help
|
||||
var usage = <table>
|
||||
{
|
||||
liberator.template.add(liberator.mappings, function (mapping)
|
||||
<tr>
|
||||
<td class="hl-Title" style="padding-right: 20px"> {mapping.names[0]}</td>
|
||||
<td>{mapping.description}</td>
|
||||
</tr>)
|
||||
}
|
||||
</table>;
|
||||
var usage = liberator.template.usage(liberator.mappings);
|
||||
liberator.echo(usage, liberator.commandline.FORCE_MULTILINE);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -284,7 +284,7 @@ liberator.Options = function () //{{{
|
||||
var str =
|
||||
<table>
|
||||
{
|
||||
liberator.template.map(liberator.globalVariables, function (i, value) {
|
||||
liberator.template.map(liberator.globalVariables, function ([i, value]) {
|
||||
let prefix = typeof value == "number" ? "#" :
|
||||
typeof value == "function" ? "*" :
|
||||
" ";
|
||||
|
||||
@@ -5,17 +5,11 @@ liberator.template = {
|
||||
|
||||
map: function (iter, fn, sep)
|
||||
{
|
||||
if (fn.length > 1)
|
||||
{
|
||||
iter = Iterator(iter);
|
||||
let oldfn = fn;
|
||||
fn = function (x) oldfn.apply(null, x);
|
||||
}
|
||||
else if (iter.length) /* Kludge? */
|
||||
if (iter.length) /* Kludge? */
|
||||
iter = liberator.util.arrayIter(iter);
|
||||
let ret = <></>;
|
||||
let n = 0;
|
||||
for each (let i in iter)
|
||||
for each (let i in Iterator(iter))
|
||||
{
|
||||
let val = fn(i);
|
||||
if (val == undefined)
|
||||
@@ -215,12 +209,26 @@ liberator.template = {
|
||||
this.map(iter, function (row)
|
||||
<tr>
|
||||
{
|
||||
liberator.template.map(row, function (i, d)
|
||||
liberator.template.map(Iterator(row), function ([i, d])
|
||||
<td style={style[i] || ""}>{d}</td>)
|
||||
}
|
||||
</tr>)
|
||||
}
|
||||
</table>);
|
||||
},
|
||||
|
||||
usage: function (iter)
|
||||
{
|
||||
return this.generic(
|
||||
<table>
|
||||
{
|
||||
this.map(iter, function (item)
|
||||
<tr>
|
||||
<td class="hl-Title" style="padding-right: 20px">{item.name || item.names[0]}</td>
|
||||
<td>{item.description}</td>
|
||||
</tr>)
|
||||
}
|
||||
</table>);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user