diff --git a/common/content/buffer.js b/common/content/buffer.js
index 7767d64c..af099e74 100644
--- a/common/content/buffer.js
+++ b/common/content/buffer.js
@@ -302,7 +302,7 @@ var Buffer = Module("buffer", {
* section's output.
*/
addPageInfoSection: function addPageInfoSection(option, title, func) {
- this.pageInfo[option] = [func, title]; // TODO: are these reversed intentionally? --djk
+ this.pageInfo[option] = Buffer.PageInfo(option, title, func);
},
/**
@@ -802,7 +802,7 @@ var Buffer = Module("buffer", {
let title = content.document.title || "[No Title]";
let info = template.map("gf",
- function (opt) template.map(buffer.pageInfo[opt][0](), util.identity, ", "),
+ function (opt) template.map(buffer.pageInfo[opt].action(), util.identity, ", "),
", ");
if (bookmarkcache.isBookmarked(this.URL))
@@ -814,8 +814,8 @@ var Buffer = Module("buffer", {
}
let list = template.map(sections || options["pageinfo"], function (option) {
- let [data, title] = buffer.pageInfo[option];
- return template.table(title, data(true));
+ let { action, title } = buffer.pageInfo[option];
+ return template.table(title, action(true));
},
);
dactyl.echo(list, commandline.FORCE_MULTILINE);
},
@@ -1029,6 +1029,9 @@ var Buffer = Module("buffer", {
scrollTo: deprecated("Buffer.scrollTo", function scrollTo(x, y) content.scrollTo(x, y)),
textZoom: deprecated("buffer.zoomValue and buffer.fullZoom", function textZoom() config.browser.markupDocumentViewer.textZoom * 100)
}, {
+ PageInfo: Struct("PageInfo", "name", "title", "action")
+ .localize("title"),
+
ZOOM_MIN: Class.memoize(function () prefs.get("zoom.minPercent")),
ZOOM_MAX: Class.memoize(function () prefs.get("zoom.maxPercent")),
@@ -1827,7 +1830,7 @@ var Buffer = Module("buffer", {
options.add(["pageinfo", "pa"],
"Define which sections are shown by the :pageinfo command",
"charlist", "gfm",
- { get values() [[k, v[1]] for ([k, v] in Iterator(buffer.pageInfo))] });
+ { get values() values(buffer.pageInfo).toObject() });
options.add(["scroll", "scr"],
"Number of lines to scroll with and commands",
diff --git a/common/locale/en-US/messages.properties b/common/locale/en-US/messages.properties
index 22982567..d0177d5b 100644
--- a/common/locale/en-US/messages.properties
+++ b/common/locale/en-US/messages.properties
@@ -1,4 +1,4 @@
-# TODO: normalise this debacle of Vim legacy messages
+# TODO: normalize this debacle of Vim legacy messages
# : are we losing the error code prefixes? --djk
abbrev.noSuch = No such abbreviation
diff --git a/common/modules/base.jsm b/common/modules/base.jsm
index 280d1313..9c2a8ede 100644
--- a/common/modules/base.jsm
+++ b/common/modules/base.jsm
@@ -1021,8 +1021,14 @@ Module.INIT = {
* @returns {function} The constructor for the new Struct.
*/
function Struct() {
- let args = Array.slice(arguments);
- const Struct = Class("Struct", StructBase, {
+ if (!/^[A-Z]/.test(arguments[0]))
+ var args = Array.slice(arguments, 0);
+ else {
+ var className = arguments[0];
+ args = Array.slice(arguments, 1);
+ }
+
+ const Struct = Class(className || "Struct", StructBase, {
length: args.length,
members: array.toObject(args.map(function (v, k) [v, k]))
});
@@ -1075,6 +1081,13 @@ let StructBase = Class("StructBase", Array, {
this.prototype.__defineGetter__(i, function () (this[i] = val.call(this)));
this.prototype.__defineSetter__(i, function (value)
Class.replaceProperty(this, i, value));
+ return this;
+ },
+
+ localize: function localize(key, defaultValue) {
+ let i = this.prototype.members[key];
+ Object.defineProperty(this.prototype, i, require("messages").Messages.Localized(defaultValue).init(key, this.prototype));
+ return this;
}
});