1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 18:37:58 +01:00

Death to E4X and stuff.

This commit is contained in:
Kris Maglione
2012-11-29 19:06:52 -08:00
parent 810eda169a
commit 0c4a25ca86
8 changed files with 60 additions and 18 deletions

View File

@@ -37,7 +37,7 @@ var Bookmarks = Module("bookmarks", {
anchored: false, anchored: false,
title: ["URL", "Info"], title: ["URL", "Info"],
keys: { text: "url", description: "title", icon: "icon", extra: "extra", tags: "tags", isURI: function () true }, keys: { text: "url", description: "title", icon: "icon", extra: "extra", tags: "tags", isURI: function () true },
process: [template.icon, template.bookmarkDescription] process: [template_.icon, template_.bookmarkDescription]
}), }),
// TODO: why is this a filter? --djk // TODO: why is this a filter? --djk

View File

@@ -316,7 +316,7 @@ var History = Module("history", {
.concat(jumps) .concat(jumps)
.concat(sh.slice(sh.index + 1)); .concat(sh.slice(sh.index + 1));
commandline.commandOutput(template.jumps(index, list)); commandline.commandOutput(template_.jumps(index, list));
}, },
{ argCount: "0" }); { argCount: "0" });

View File

@@ -1039,11 +1039,12 @@ var Tabs = Module("tabs", {
group[1].push([i, tab.linkedBrowser]); group[1].push([i, tab.linkedBrowser]);
}); });
context.pushProcessor(0, function (item, text, next) <> context.pushProcessor(0, function (item, text, next) [
<span highlight="Indicator" style="display: inline-block;">{item.indicator}</span> ["span", { highlight: "Indicator", style: "display: inline-block;" },
{ next.call(this, item, text) } item.indicator],
</>); next.call(this, item, text)
context.process[1] = function (item, text) template.bookmarkDescription(item, template.highlightFilter(text, this.filter)); ]);
context.process[1] = function (item, text) template_.bookmarkDescription(item, template_.highlightFilter(text, this.filter));
context.anchored = false; context.anchored = false;
context.keys = { context.keys = {

View File

@@ -2429,7 +2429,7 @@ Buffer.addPageInfoSection("f", "Feeds", function (verbose) {
nFeed++; nFeed++;
let type = feedTypes[feed.type] || "RSS"; let type = feedTypes[feed.type] || "RSS";
if (verbose) if (verbose)
yield [feed.title, [template.highlightURL(feed.href, true), yield [feed.title, [template_.highlightURL(feed.href, true),
["span", { class: "extra-info" }, " (" + type + ")"]]]; ["span", { class: "extra-info" }, " (" + type + ")"]]];
} }
} }

View File

@@ -15,7 +15,7 @@ defineModule("commands", {
lazyRequire("help", ["help"]); lazyRequire("help", ["help"]);
lazyRequire("options", ["Option"]); lazyRequire("options", ["Option"]);
lazyRequire("template", ["template"]); lazyRequire("template", ["template", "template_"]);
/** /**
* A structure representing the options available for a command. * A structure representing the options available for a command.
@@ -1712,7 +1712,7 @@ var Commands = Module("commands", {
this.iterate(args).filter(function (cmd) cmd.hive === commands.builtin || Set.has(tags, cmd.helpTag)), this.iterate(args).filter(function (cmd) cmd.hive === commands.builtin || Set.has(tags, cmd.helpTag)),
format: { format: {
headings: ["Command", "Group", "Description"], headings: ["Command", "Group", "Description"],
description: function (cmd) template.linkifyHelp(cmd.description + (cmd.replacementText ? ": " + cmd.action : "")), description: function (cmd) template_.linkifyHelp(cmd.description + (cmd.replacementText ? ": " + cmd.action : "")),
help: function (cmd) ":" + cmd.name help: function (cmd) ":" + cmd.name
} }
}); });

View File

@@ -321,7 +321,7 @@ var CompletionContext = Class("CompletionContext", {
util.trapErrors("onUpdate", this); util.trapErrors("onUpdate", this);
}, },
get createRow() this._createRow || template.completionRow, // XXX get createRow() this._createRow || template_.completionRow, // XXX
set createRow(createRow) this._createRow = createRow, set createRow(createRow) this._createRow = createRow,
get filterFunc() this._filterFunc || util.identity, get filterFunc() this._filterFunc || util.identity,
@@ -494,7 +494,7 @@ var CompletionContext = Class("CompletionContext", {
this.processor = Array.slice(this.process); this.processor = Array.slice(this.process);
if (!this.anchored) if (!this.anchored)
this.processor[0] = function (item, text) self.process[0].call(self, item, this.processor[0] = function (item, text) self.process[0].call(self, item,
template.highlightFilter(item.text, self.filter, null, item.isURI)); template_.highlightFilter(item.text, self.filter, null, item.isURI));
try { try {
// Item prototypes // Item prototypes
@@ -823,7 +823,7 @@ var CompletionContext = Class("CompletionContext", {
throw Error(); throw Error();
this.offset = 0; this.offset = 0;
this.process = [template.icon, function (item, k) k]; this.process = [template_.icon, function (item, k) k];
this.filters = [CompletionContext.Filter.text]; this.filters = [CompletionContext.Filter.text];
this.tabPressed = false; this.tabPressed = false;
this.title = ["Completions"]; this.title = ["Completions"];
@@ -937,7 +937,7 @@ var Completion = Module("completion", {
modules.commandline.commandOutput( modules.commandline.commandOutput(
["div", { highlight: "Completions" }, ["div", { highlight: "Completions" },
template_.map(contexts, function (context) template_.map(contexts, function (context)
[template.completionRow(context.title, "CompTitle"), [template_.completionRow(context.title, "CompTitle"),
template_.map(context.items, function (item) context.createRow(item), null, 100)])]); template_.map(context.items, function (item) context.createRow(item), null, 100)])]);
}, },
}), }),
@@ -1089,7 +1089,7 @@ var Completion = Module("completion", {
contains(item.title, tok))); contains(item.title, tok)));
let re = RegExp(tokens.filter(util.identity).map(util.regexp.escape).join("|"), "g"); let re = RegExp(tokens.filter(util.identity).map(util.regexp.escape).join("|"), "g");
function highlight(item, text, i) process[i].call(this, item, template.highlightRegexp(text, re)); function highlight(item, text, i) process[i].call(this, item, template_.highlightRegexp(text, re));
let process = context.process; let process = context.process;
context.process = [ context.process = [
function (item, text) highlight.call(this, item, item.text, 0), function (item, text) highlight.call(this, item, item.text, 0),
@@ -1120,9 +1120,9 @@ var Completion = Module("completion", {
function (args) { function (args) {
modules.commandline.commandOutput( modules.commandline.commandOutput(
["div", { highlight: "Completions" }, ["div", { highlight: "Completions" },
template.completionRow(["Context", "Title"], "CompTitle"), template_.completionRow(["Context", "Title"], "CompTitle"),
template_.map(completion.contextList || [], template_.map(completion.contextList || [],
function (item) template.completionRow(item, "CompItem"))]); function (item) template_.completionRow(item, "CompItem"))]);
}, },
{ {
argCount: "*", argCount: "*",

View File

@@ -353,7 +353,7 @@ var JavaScript = Module("javascript", {
if (!compl) { if (!compl) {
base.process[1] = function highlight(item, v) base.process[1] = function highlight(item, v)
template.highlight(typeof v == "xml" ? new String(v.toXMLString()) : v, true, 200); template_.highlight(typeof v == "xml" ? new String(v.toXMLString()) : v, true, 200);
// Sort in a logical fashion for object keys: // Sort in a logical fashion for object keys:
// Numbers are sorted as numbers, rather than strings, and appear first. // Numbers are sorted as numbers, rather than strings, and appear first.

View File

@@ -572,6 +572,47 @@ var Template_ = Module("Template_", {
}, },
bookmarkDescription: function (item, text) [
!(item.extra && item.extra.length) ? [] :
["span", { highlight: "URLExtra" },
" (",
this.map(item.extra, function (e)
["", e[0], ": ",
["span", { highlight: e[2] }, e[1]]],
"\u00a0"),
")\u00a0"],
["a", { identifier: item.id == null ? "" : item.id,
"dactyl:command": item.command || "",
href: item.item.url, highlight: "URL" },
text || ""]
],
filter: function (str) ["span", { highlight: "Filter" }, str],
completionRow: function completionRow(item, highlightGroup) {
if (typeof icon == "function")
icon = icon();
if (highlightGroup) {
var text = item[0] || "";
var desc = item[1] || "";
}
else {
var text = this.processor[0].call(this, item, item.result);
var desc = this.processor[1].call(this, item, item.description);
}
return ["div", { highlight: highlightGroup || "CompItem", style: "white-space: nowrap" },
/* The non-breaking spaces prevent empty elements
* from pushing the baseline down and enlarging
* the row.
*/
["li", { highlight: "CompResult " + item.highlight },
text, "\u00a0"],
["li", { highlight: "CompDesc" },
desc, "\u00a0"]];
},
helpLink: function (token, text, type) { helpLink: function (token, text, type) {
if (!help.initialized) if (!help.initialized)
util.dactyl.initHelp(); util.dactyl.initHelp();