1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-04 03:14:11 +01:00
This commit is contained in:
Kris Maglione
2011-04-07 13:33:29 -04:00
48 changed files with 564 additions and 339 deletions

View File

@@ -110,7 +110,7 @@ var actions = {
name: "extr[ehash]",
description: "Reload an extension",
action: function (addon) {
util.assert(util.haveGecko("2b"), _("error.notUseful", config.host));
util.assert(util.haveGecko("2b"), _("command.notUseful", config.host));
util.timeout(function () {
addon.userDisabled = true;
addon.userDisabled = false;
@@ -153,9 +153,9 @@ var Addon = Class("Addon", {
<td highlight="AddonButtons Buttons">
<a highlight="Button" key="enable">{_("addon.action.On")}</a>
<a highlight="Button" key="disable">{_("addon.action.Off")}</a>
<a highlight="Button" key="delete">{_("addon.action.Del")}</a>
<a highlight="Button" key="update">{_("addon.action.Upd")}</a>
<a highlight="Button" key="options">{_("addon.action.Opt")}</a>
<a highlight="Button" key="delete">{_("addon.action.Delete")}</a>
<a highlight="Button" key="update">{_("addon.action.Update")}</a>
<a highlight="Button" key="options">{_("addon.action.Options")}</a>
</td>
<td highlight="AddonDescription" key="description"/>
</tr>,
@@ -282,11 +282,11 @@ var AddonList = Class("AddonList", {
XML.ignoreWhitespace = true;
util.xmlToDom(<table highlight="Addons" key="list" xmlns={XHTML}>
<tr highlight="AddonHead">
<td>Name</td>
<td>Version</td>
<td>Status</td>
<td><!--L-->Name</td>
<td><!--L-->Version</td>
<td><!--L-->Status</td>
<td/>
<td>Description</td>
<td><!--L-->Description</td>
</tr>
</table>, this.document, this.nodes);
@@ -418,7 +418,7 @@ var Addons = Module("addons", {
function (args) {
let name = args[0];
if (args.bang && !command.bang)
dactyl.assert(!name, _("error.trailing"));
dactyl.assert(!name, _("error.trailingCharacters"));
else
dactyl.assert(name, _("error.argumentRequired"));

View File

@@ -142,6 +142,7 @@ function defineModule(name, params, module) {
use[mod].push(module);
}
currentModule = module;
module.startTime = Date.now();
}
defineModule.loadLog = [];
@@ -163,7 +164,6 @@ defineModule.dump = function dump_() {
.replace(/^./gm, name + ": $&"));
}
defineModule.modules = [];
defineModule.times = { all: 0 };
defineModule.time = function time(major, minor, func, self) {
let time = Date.now();
if (typeof func !== "function")
@@ -176,13 +176,7 @@ defineModule.time = function time(major, minor, func, self) {
loaded.util && util.reportError(e);
}
let delta = Date.now() - time;
defineModule.times.all += delta;
defineModule.times[major] = (defineModule.times[major] || 0) + delta;
if (minor) {
defineModule.times[":" + minor] = (defineModule.times[":" + minor] || 0) + delta;
defineModule.times[major + ":" + minor] = (defineModule.times[major + ":" + minor] || 0) + delta;
}
JSMLoader.times.add(major, minor, Date.now() - time);
return res;
}
@@ -211,7 +205,7 @@ function require(obj, name, from) {
if (loaded.util)
util.reportError(e);
else
defineModule.dump(" " + (e.filename || e.fileName) + ":" + e.lineNumber + ": " + e +"\n");
defineModule.dump(" " + (e.filename || e.fileName) + ":" + e.lineNumber + ": " + e + "\n");
}
}
@@ -222,7 +216,7 @@ defineModule("base", {
"Struct", "StructBase", "Timer", "UTF8", "XPCOM", "XPCOMUtils", "XPCSafeJSObjectWrapper",
"array", "bind", "call", "callable", "ctypes", "curry", "debuggerProperties", "defineModule",
"deprecated", "endModule", "forEach", "isArray", "isGenerator", "isinstance", "isObject",
"isString", "isSubclass", "iter", "iterAll", "iterOwnProperties","keys", "memoize", "octal",
"isString", "isSubclass", "iter", "iterAll", "iterOwnProperties", "keys", "memoize", "octal",
"properties", "require", "set", "update", "values", "withCallerGlobal"
],
use: ["config", "services", "util"]
@@ -479,9 +473,13 @@ function curry(fn, length, self, acc) {
}
if (curry.bind)
var bind = function bind(func) func.bind.apply(func, Array.slice(arguments, bind.length));
var bind = function bind(meth, self) let (func = callable(meth) ? meth : self[meth])
func.bind.apply(func, Array.slice(arguments, 1));
else
var bind = function bind(func, self) {
if (!callable(func))
func = self[func];
let args = Array.slice(arguments, bind.length);
return function bound() func.apply(self, args.concat(Array.slice(arguments)));
};

View File

@@ -151,7 +151,6 @@ var BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver), {
return this.rootFolders.indexOf(root) >= 0;
},
// Should be made thread safe.
load: function load() {
let bookmarks = {};

View File

@@ -32,6 +32,26 @@ else
manager: Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar),
stale: JSMLoader ? JSMLoader.stale : {},
suffix: "",
times: {
all: 0,
add: function add(major, minor, delta) {
this.all += delta;
this[major] = (this[major] || 0) + delta;
if (minor) {
minor = ":" + minor;
this[minor] = (this[minor] || 0) + delta;
this[major + minor] = (this[major + minor] || 0) + delta;
}
},
clear: function clear() {
for (let key in this)
if (typeof this[key] !== "number")
delete this[key];
}
},
init: function init(suffix) {
this.initialized = true;
this.suffix = suffix || "";
@@ -41,6 +61,7 @@ else
this.global.JSMLoader = this;
base.JSMLoader = this;
},
getTarget: function getTarget(url) {
if (url.indexOf(":") === -1)
url = "resource://dactyl" + this.suffix + "/" + url;
@@ -49,6 +70,7 @@ else
chan.cancel(Components.results.NS_BINDING_ABORTED);
return chan.name;
},
load: function load(name, target) {
let url = name;
if (url.indexOf(":") === -1)
@@ -68,7 +90,12 @@ else
}
try {
let now = Date.now();
let global = Components.utils.import(url, target);
if (!(name in this.globals))
this.times.add("require", name, Date.now() - now);
return this.globals[name] = global;
}
catch (e) {
@@ -76,11 +103,18 @@ else
throw e;
}
},
loadSubScript: function loadSubScript() this.loader.loadSubScript.apply(this.loader, arguments),
loadSubScript: function loadSubScript(script) {
let now = Date.now();
this.loader.loadSubScript.apply(this.loader, arguments);
this.times.add("loadSubScript", script, Date.now() - now);
},
cleanup: function unregister() {
for each (let factory in this.factories.splice(0))
this.manager.unregisterFactory(factory.classID, factory);
},
purge: function purge() {
dump("dactyl: JSMLoader: purge\n");

View File

@@ -310,7 +310,7 @@ var Command = Class("Command", {
util.assert((this.length == 0 || this.command.argCount !== "0") &&
(this.length <= 1 || !/^[01?]$/.test(this.command.argCount)),
_("error.trailing"));
_("error.trailingCharacters"));
}
}
});
@@ -640,47 +640,55 @@ var Commands = Module("commands", {
/**
* Displays a list of user-defined commands.
*
* @param {string} filter Limits the list to those commands with a name
* matching this anchored substring.
*/
list: function list() {
list: function list(filter) {
const { commandline, completion } = this.modules;
function completerToString(completer) {
if (completer)
return [k for ([k, v] in Iterator(config.completers)) if (completer == completion.closure[v])][0] || "custom";
return "";
}
// TODO: allow matching of aliases?
function cmds(hive) hive._list.filter(function (cmd) cmd.name.indexOf(filter || "") == 0)
if (!this.userHives.some(function (h) h._list.length))
let hives = this.userHives.map(function (h) [h, cmds(h)]).filter(function ([h, c]) c.length);
let list = <table>
<tr highlight="Title">
<td/>
<td style="padding-right: 1em;"></td>
<td style="padding-right: 1ex;"><!--L-->Name</td>
<td style="padding-right: 1ex;"><!--L-->Args</td>
<td style="padding-right: 1ex;"><!--L-->Range</td>
<td style="padding-right: 1ex;"><!--L-->Complete</td>
<td style="padding-right: 1ex;"><!--L-->Definition</td>
</tr>
<col style="min-width: 6em; padding-right: 1em;"/>
{
template.map(hives, function ([hive, cmds]) let (i = 0)
<tr style="height: .5ex;"/> +
template.map(cmds, function (cmd)
template.map(cmd.names, function (name)
<tr>
<td highlight="Title">{!i++ ? hive.name : ""}</td>
<td>{cmd.bang ? "!" : " "}</td>
<td>{cmd.name}</td>
<td>{cmd.argCount}</td>
<td>{cmd.count ? "0c" : ""}</td>
<td>{completerToString(cmd.completer)}</td>
<td>{cmd.replacementText || "function () { ... }"}</td>
</tr>)) +
<tr style="height: .5ex;"/>)
}
</table>;
if (list.*.length() === list.text().length() + 2)
dactyl.echomsg(_("command.none"));
else
commandline.commandOutput(
<table>
<tr highlight="Title">
<td/>
<td style="padding-right: 1em;"></td>
<td style="padding-right: 1ex;">Name</td>
<td style="padding-right: 1ex;">Args</td>
<td style="padding-right: 1ex;">Range</td>
<td style="padding-right: 1ex;">Complete</td>
<td style="padding-right: 1ex;">Definition</td>
</tr>
<col style="min-width: 6em; padding-right: 1em;"/>
{
template.map(this.userHives, function (hive) let (i = 0)
<tr style="height: .5ex;"/> +
template.map(hive, function (cmd)
template.map(cmd.names, function (name)
<tr>
<td highlight="Title">{!i++ ? hive.name : ""}</td>
<td>{cmd.bang ? "!" : " "}</td>
<td>{cmd.name}</td>
<td>{cmd.argCount}</td>
<td>{cmd.count ? "0c" : ""}</td>
<td>{completerToString(cmd.completer)}</td>
<td>{cmd.replacementText || "function () { ... }"}</td>
</tr>)) +
<tr style="height: .5ex;"/>)
}
</table>);
commandline.commandOutput(list);
}
}),
@@ -863,7 +871,7 @@ var Commands = Module("commands", {
let [count, arg, quote] = Commands.parseArg(str, null, _keepQuotes);
if (quote == "\\" && !complete)
return [, , , _("error.trailing", "\\")];
return [, , , _("error.trailingCharacters", "\\")];
if (quote && !complete)
return [, , , _("error.missingQuote", quote)];
return [count, arg, quote];
@@ -1382,8 +1390,6 @@ var Commands = Module("commands", {
commands: function initCommands(dactyl, modules, window) {
const { commands, contexts } = modules;
// TODO: Vim allows commands to be defined without {rep} if there are {attr}s
// specified - useful?
commands.add(["com[mand]"],
"List or define commands",
function (args) {
@@ -1392,8 +1398,8 @@ var Commands = Module("commands", {
util.assert(!cmd || cmd.split(",").every(commands.validName.closure.test),
_("command.invalidName", cmd));
if (!args.literalArg)
commands.list();
if (args.length <= 1)
commands.list(cmd);
else {
util.assert(args["-group"].modifiable,
_("group.cantChangeBuiltin", _("command.commands")));
@@ -1488,7 +1494,7 @@ var Commands = Module("commands", {
},
{
names: ["-literal", "-l"],
description: "Process the nth ignoring any quoting or meta characters",
description: "Process the specified argument ignoring any quoting or meta characters",
type: CommandOption.INT
},
{
@@ -1573,7 +1579,7 @@ var Commands = Module("commands", {
]
})),
iterateIndex: function (args) let (tags = services["dactyl:"].HELP_TAGS)
this.iterate(args).filter(function (cmd) cmd.hive === commands.builtin || set.has(cmd.helpTag)),
this.iterate(args).filter(function (cmd) cmd.hive === commands.builtin || set.has(tags, cmd.helpTag)),
format: {
headings: ["Command", "Group", "Description"],
description: function (cmd) template.linkifyHelp(cmd.description + (cmd.replacementText ? ": " + cmd.action : "")),

View File

@@ -960,7 +960,7 @@ var Completion = Module("completion", {
context.title = ["URL", "Title"];
context.fork("additional", 0, this, function (context) {
context.title[0] += " (additional)";
context.title[0] += /*L*/" (additional)";
context.filter = context.parent.filter; // FIXME
context.completions = context.parent.completions;
// For items whose URL doesn't exactly match the filter,

View File

@@ -13,7 +13,7 @@ Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("config", {
exports: ["ConfigBase", "Config", "config"],
require: ["services", "storage", "util", "template"],
use: ["io", "messages", "prefs"]
use: ["io", "messages", "prefs", "styles"]
}, this);
var ConfigBase = Class("ConfigBase", {
@@ -33,9 +33,12 @@ var ConfigBase = Class("ConfigBase", {
loadStyles: function loadStyles() {
const { highlight } = require("highlight");
highlight.styleableChrome = this.styleableChrome;
highlight.loadCSS(this.CSS);
highlight.loadCSS(this.helpCSS);
if (!util.haveGecko("2b"))
highlight.loadCSS(<![CDATA[
!TabNumber font-weight: bold; margin: 0px; padding-right: .8ex;
@@ -46,6 +49,25 @@ var ConfigBase = Class("ConfigBase", {
text-shadow: black -1px 0 1px, black 0 1px 1px, black 1px 0 1px, black 0 -1px 1px;
}
]]>);
let hl = highlight.set("Find", "");
hl.onChange = function () {
function hex(val) ("#" + util.regexp.iterate(/\d+/g, val)
.map(function (num) ("0" + Number(num).toString(16)).slice(-2))
.join("")
).slice(0, 7);
let elem = services.appShell.hiddenDOMWindow.document.createElement("div");
elem.style.cssText = this.cssText;
let style = util.computedStyle(elem);
let keys = iter(Styles.propertyIter(this.cssText)).map(function (p) p.name).toArray();
let bg = keys.some(function (k) /^background/.test(k));
let fg = keys.indexOf("color") >= 0;
prefs[bg ? "safeSet" : "safeReset"]("ui.textHighlightBackground", hex(style.backgroundColor));
prefs[fg ? "safeSet" : "safeReset"]("ui.textHighlightForeground", hex(style.color));
};
},
get addonID() this.name + "@dactyl.googlecode.com",
@@ -132,7 +154,7 @@ var ConfigBase = Class("ConfigBase", {
*/
VCSPath: Class.memoize(function () {
if (/pre$/.test(this.addon.version)) {
let uri = this.addon.getResourceURI("../.hg");
let uri = util.newURI(this.addon.getResourceURI("").spec + "../.hg");
if (uri instanceof Ci.nsIFileURL &&
uri.file.exists() &&
io.pathSearch("hg"))
@@ -159,7 +181,7 @@ var ConfigBase = Class("ConfigBase", {
"--template=hg{rev}-" + this.branch + " ({date|isodate})"]).output;
let version = this.addon.version;
if ("@DATE@" !== "@" + "DATE@")
version += " (created: @DATE@)";
version += /*L*/" (created: @DATE@)";
return version;
}),
@@ -206,7 +228,7 @@ var ConfigBase = Class("ConfigBase", {
"version"
],
helpStyles: /^(Help|StatusLine|REPL)|^(Boolean|Indicator|MoreMsg|Number|Object|Logo|Key(word)?|String)$/,
helpStyles: /^(Help|StatusLine|REPL)|^(Boolean|Dense|Indicator|MoreMsg|Number|Object|Logo|Key(word)?|String)$/,
styleHelp: function styleHelp() {
if (!this.helpStyled) {
const { highlight } = require("highlight");
@@ -428,7 +450,6 @@ var ConfigBase = Class("ConfigBase", {
CmdInput;.dactyl-commandline-command
CmdOutput white-space: pre;
CompGroup
CompGroup:not(:first-of-type) margin-top: .5em;
CompGroup:last-of-type padding-bottom: 1.5ex;
@@ -456,6 +477,7 @@ var ConfigBase = Class("ConfigBase", {
CompMore text-align: center; height: .5ex; line-height: .5ex; margin-bottom: -.5ex;
CompMore::after content: "⌄";
Dense margin-top: 0; margin-bottom: 0;
EditorEditing;;* background: #bbb !important; -moz-user-input: none !important; -moz-user-modify: read-only !important;
EditorError;;* background: red !important;
@@ -624,7 +646,7 @@ var ConfigBase = Class("ConfigBase", {
HelpEx;;;FontCode display: inline-block; color: #527BBD;
HelpExample display: block; margin: 1em 0;
HelpExample::before content: "Example: "; font-weight: bold;
HelpExample::before content: /*L*/"Example: "; font-weight: bold;
HelpInfo display: block; width: 20em; margin-left: auto;
HelpInfoLabel display: inline-block; width: 6em; color: magenta; font-weight: bold; vertical-align: text-top;
@@ -661,7 +683,6 @@ var ConfigBase = Class("ConfigBase", {
HelpList;html|ul;dactyl://help/* display: block; list-style-position: outside; margin: 1em 0;
HelpListItem;html|li;dactyl://help/* display: list-item;
HelpNote color: red; font-weight: bold;
HelpOpt;;;FontCode color: #106326;
@@ -708,7 +729,6 @@ var ConfigBase = Class("ConfigBase", {
HelpHead4;html|h4;dactyl://help/* {
}
HelpTab;html|dl;dactyl://help/* {
display: table;
width: 100%;

View File

@@ -137,7 +137,7 @@ var Download = Class("Download", {
if (this.timeRemaining)
this.nodes.time.textContent = util.formatSeconds(this.timeRemaining);
else
this.nodes.time.textContent = "~1 second";
this.nodes.time.textContent = /*L*/"~1 second";
}
let total = this.nodes.progressTotal.textContent = this.size ? util.formatBytes(this.size, 1, true) : "Unknown";
let suffix = RegExp(/( [a-z]+)?$/i.exec(total)[0] + "$");
@@ -182,20 +182,20 @@ var DownloadList = Class("DownloadList",
util.xmlToDom(<table highlight="Downloads" key="list" xmlns={XHTML}>
<tr highlight="DownloadHead">
<span>Title</span>
<span>Status</span>
<span><!--L-->Title</span>
<span><!--L-->Status</span>
<span/>
<span>Progress</span>
<span><!--L-->Progress</span>
<span/>
<span>Time remaining</span>
<span>Source</span>
<span><!--L-->Time remaining</span>
<span><!--L-->Source</span>
</tr>
<tr highlight="Download"><span><div style="min-height: 1ex; /* FIXME */"/></span></tr>
<tr highlight="Download" key="totals" active="true">
<td><span highlight="Title">Totals:</span>&#xa0;<span key="total"/></td>
<td><span highlight="Title"><!--L-->Totals:</span>&#xa0;<span key="total"/></td>
<td/>
<td highlight="DownloadButtons">
<a highlight="Button" key="clear">Clear</a>
<a highlight="Button" key="clear"><!--L-->Clear</a>
</td>
<td highlight="DownloadProgress" key="progress">
<span highlight="DownloadProgressHave" key="progressHave"
@@ -277,7 +277,7 @@ var DownloadList = Class("DownloadList",
let active = downloads.filter(function (dl) dl.alive).length;
if (active)
this.nodes.total.textContent = active + " active";
this.nodes.total.textContent = /*L*/active + " active";
else for (let key in values(["total", "percent", "time"]))
this.nodes[key].textContent = "";
},

View File

@@ -33,6 +33,8 @@ Highlight.liveProperty = function (name, prop) {
h.style.css = h.css;
this.style[prop || name] = this[prop || name];
if (this.onChange)
this.onChange();
});
}
Highlight.liveProperty("agent");
@@ -337,7 +339,7 @@ var Highlights = Module("Highlight", {
if (!modify && /&$/.test(key))
[clear, modify, key] = [true, true, key.replace(/&$/, "")];
dactyl.assert(!(clear && css), _("error.trailing"));
dactyl.assert(!(clear && css), _("error.trailingCharacters"));
if (!modify)
modules.commandline.commandOutput(
@@ -369,7 +371,10 @@ var Highlights = Module("Highlight", {
else if (args.completeArg == 1) {
let hl = highlight.get(args[0]);
if (hl)
context.completions = [[hl.value, "Current Value"], [hl.defaultValue || "", "Default Value"]];
context.completions = [
[hl.value, _("option.currentValue")],
[hl.defaultValue || "", _("option.defaultValue")]
];
context.fork("css", 0, completion, "css");
}
},

View File

@@ -116,7 +116,7 @@ var IO = Module("io", {
outer:
for (let dir in values(dirs)) {
for (let [,path] in Iterator(paths)) {
for (let [, path] in Iterator(paths)) {
let file = dir.child(path);
dactyl.echomsg(_("io.searchingFor", file.path.quote()), 3);
@@ -208,7 +208,7 @@ var IO = Module("io", {
}
catch (e) {
dactyl.reportError(e);
let message = "Sourcing file: " + (e.echoerr || file.path + ": " + e);
let message = /*L*/"Sourcing file: " + (e.echoerr || file.path + ": " + e);
if (!params.silent)
dactyl.echoerr(message);
}
@@ -783,9 +783,13 @@ unlet s:cpo_save
commands.add(["scrip[tnames]"],
"List all sourced script names",
function () {
modules.commandline.commandOutput(
template.tabular(["<SNR>", "Filename"], ["text-align: right; padding-right: 1em;"],
([i + 1, file] for ([i, file] in Iterator(io._scriptNames))))); // TODO: add colon and remove column titles for pedantic Vim compatibility?
if (!io._scriptNames.length)
dactyl.echomsg(_("command.scriptnames.none"));
else
modules.commandline.commandOutput(
template.tabular(["<SNR>", "Filename"], ["text-align: right; padding-right: 1em;"],
([i + 1, file] for ([i, file] in Iterator(io._scriptNames))))); // TODO: add colon and remove column titles for pedantic Vim compatibility?
},
{ argCount: "0" });
@@ -831,7 +835,7 @@ unlet s:cpo_save
let result = io.system(arg);
if (result.returnValue != 0)
result.output += "\nshell returned " + result.returnValue;
result.output += "\n" + _("io.shellReturn", result.returnValue);
modules.commandline.command = "!" + arg;
modules.commandline.commandOutput(<span highlight="CmdOutput">{result.output}</span>);
@@ -981,9 +985,9 @@ unlet s:cpo_save
context.key = match.prefix;
context.advance(match.prefix.length + 1);
context.generate = function () iter({
content: "Chrome content",
locale: "Locale-specific content",
skin: "Theme-specific content"
content: /*L*/"Chrome content",
locale: /*L*/"Locale-specific content",
skin: /*L*/"Theme-specific content"
});
}
}

View File

@@ -45,7 +45,7 @@ var JavaScript = Module("javascript", {
}),
globals: Class.memoize(function () [
[this.modules.userContext, "Global Variables"],
[this.modules.userContext, /*L*/"Global Variables"],
[this.modules, "modules"],
[this.window, "window"]
]),
@@ -117,12 +117,8 @@ var JavaScript = Module("javascript", {
return cache[key];
context[JavaScript.EVAL_TMP] = tmp;
context[JavaScript.EVAL_EXPORT] = function export_(obj) cache[key] = obj;
try {
if (tmp != null) // Temporary hack until bug 609949 is fixed.
this.modules.dactyl.userEval(JavaScript.EVAL_EXPORT + "(" + arg + ")", context, "[Command Line Completion]", 1);
else
cache[key] = this.modules.dactyl.userEval(arg, context, "[Command Line Completion]", 1);
cache[key] = this.modules.dactyl.userEval(arg, context, /*L*/"[Command Line Completion]", 1);
return cache[key];
}
@@ -170,7 +166,7 @@ var JavaScript = Module("javascript", {
if (this._top.char != arg) {
this.context.highlight(this._top.offset, this._i - this._top.offset, "SPELLCHECK");
throw Error("Invalid JS");
throw Error(/*L*/"Invalid JS");
}
// The closing character of this stack frame will have pushed a new
@@ -308,7 +304,7 @@ var JavaScript = Module("javascript", {
if (this._checkFunction(prev, dot, cacheKey))
return [];
if (prev != statement && obj == null) {
this.context.message = "Error: " + cacheKey.quote() + " is " + String(obj);
this.context.message = /*L*/"Error: " + cacheKey.quote() + " is " + String(obj);
return [];
}
@@ -324,7 +320,7 @@ var JavaScript = Module("javascript", {
let end = (frame == -1 ? this._lastIdx : this._get(frame + 1).offset);
this._cacheKey = null;
let obj = [[this.cache.evalContext, "Local Variables"]].concat(this.globals);
let obj = [[this.cache.evalContext, /*L*/"Local Variables"]].concat(this.globals);
// Is this an object dereference?
if (dot < statement) // No.
dot = statement - 1;
@@ -339,7 +335,7 @@ var JavaScript = Module("javascript", {
const self = this;
if (!getOwnPropertyNames && !services.debugger.isOn && !this.context.message)
this.context.message = "For better completion data, please enable the JavaScript debugger (:set jsdebugger)";
this.context.message = /*L*/"For better completion data, please enable the JavaScript debugger (:set jsdebugger)";
let base = this.context.fork("js", this._top.offset);
base.forceAnchored = true;
@@ -419,14 +415,14 @@ var JavaScript = Module("javascript", {
objects.forEach(function (obj) {
obj.ctxt_p.split(obj[1] + "/anchored", this, function (context) {
context.anchored = true;
context.title[0] += " (prototypes)";
context.title[0] += /*L*/" (prototypes)";
});
});
objects.forEach(function (obj) {
obj.ctxt_t.split(obj[1] + "/unanchored", this, function (context) {
context.anchored = false;
context.title[0] += " (substrings)";
context.title[0] += /*L*/" (substrings)";
context.filters.push(unanchored);
});
});
@@ -434,7 +430,7 @@ var JavaScript = Module("javascript", {
objects.forEach(function (obj) {
obj.ctxt_p.split(obj[1] + "/unanchored", this, function (context) {
context.anchored = false;
context.title[0] += " (prototype substrings)";
context.title[0] += /*L*/" (prototype substrings)";
context.filters.push(unanchored);
});
});
@@ -646,7 +642,6 @@ var JavaScript = Module("javascript", {
}, {
EVAL_TMP: "__dactyl_eval_tmp",
EVAL_EXPORT: "__dactyl_eval_export",
/**
* A map of argument completion functions for named methods. The
@@ -775,8 +770,8 @@ var JavaScript = Module("javascript", {
this.js.newContext = function newContext() modules.newContext(self.context, !sandbox);
this.js.globals = [
[this.context, "REPL Variables"],
[context, "REPL Global"]
[this.context, /*L*/"REPL Variables"],
[context, /*L*/"REPL Global"]
].concat(this.js.globals.filter(function ([global]) isPrototypeOf.call(global, context)));
if (!isPrototypeOf.call(modules.jsmodules, context))
@@ -790,13 +785,14 @@ var JavaScript = Module("javascript", {
this.repl = REPL(this.context);
},
open: function open(context) {
this.updatePrompt();
modules.mow.echo(this.repl);
this.widgets.message = null;
open.superapply(this, arguments);
this.updatePrompt();
},
complete: function complete(context) {
@@ -807,6 +803,8 @@ var JavaScript = Module("javascript", {
mode: modes.REPL,
get completionList() this.widgets.statusbar.commandline.id,
accept: function accept() {
dactyl.trapErrors(function () { this.repl.addOutput(this.command) }, this);

View File

@@ -448,7 +448,7 @@ var Option = Class("Option", {
regexplist: function regexplist(k, default_) {
for (let re in values(this.value))
if (re(k))
if ((re.test || re).call(re, k))
return re.result;
return arguments.length > 1 ? default_ : null;
},
@@ -619,18 +619,23 @@ var Option = Class("Option", {
stringlist: function stringlist(operator, values, scope, invert) {
values = Array.concat(values);
function uniq(ary) {
let seen = {};
return ary.filter(function (elem) !set.add(seen, elem));
}
switch (operator) {
case "+":
return array.uniq(Array.concat(this.value, values), true);
return uniq(Array.concat(this.value, values), true);
case "^":
// NOTE: Vim doesn't prepend if there's a match in the current value
return array.uniq(Array.concat(values, this.value), true);
return uniq(Array.concat(values, this.value), true);
case "-":
return this.value.filter(function (item) values.indexOf(item) == -1);
return this.value.filter(function (item) !set.has(this, item), set(values));
case "=":
if (invert) {
let keepValues = this.value.filter(function (item) values.indexOf(item) == -1);
let addValues = values.filter(function (item) this.value.indexOf(item) == -1, this);
let keepValues = this.value.filter(function (item) !set.has(this, item), set(values));
let addValues = values.filter(function (item) !set.has(this, item), set(this.value));
return addValues.concat(keepValues);
}
return values;
@@ -870,7 +875,7 @@ var Options = Module("options", {
allPrefs: deprecated("prefs.getNames", function allPrefs() prefs.getNames.apply(prefs, arguments)),
getPref: deprecated("prefs.get", function getPref() prefs.get.apply(prefs, arguments)),
invertPref: deprecated("prefs.invert", function invertPref() prefs.invert.apply(prefs, arguments)),
listPrefs: deprecated("prefs.list", function listPrefs() { commandline.commandOutput(prefs.list.apply(prefs, arguments)); }),
listPrefs: deprecated("prefs.list", function listPrefs() { this.modules.commandline.commandOutput(prefs.list.apply(prefs, arguments)); }),
observePref: deprecated("prefs.observe", function observePref() prefs.observe.apply(prefs, arguments)),
popContext: deprecated("prefs.popContext", function popContext() prefs.popContext.apply(prefs, arguments)),
pushContext: deprecated("prefs.pushContext", function pushContext() prefs.pushContext.apply(prefs, arguments)),
@@ -1056,7 +1061,7 @@ var Options = Module("options", {
},
{ promptHighlight: "WarningMsg" });
else if (name == "all")
commandline.commandOutput(prefs.list(onlyNonDefault, ""));
modules.commandline.commandOutput(prefs.list(onlyNonDefault, ""));
else if (reset)
prefs.reset(name);
else if (invertBoolean)
@@ -1169,7 +1174,7 @@ var Options = Module("options", {
context.advance(context.filter.indexOf("="));
if (option.type == "boolean")
return error(context.filter.length, _("error.trailing"));
return error(context.filter.length, _("error.trailingCharacters"));
context.advance(1);
if (opt.error)
@@ -1235,7 +1240,7 @@ var Options = Module("options", {
if (str.text().length() == str.*.length())
dactyl.echomsg(_("variable.none"));
else
dactyl.echo(str, commandline.FORCE_MULTILINE);
dactyl.echo(str, modules.commandline.FORCE_MULTILINE);
return;
}

View File

@@ -115,7 +115,7 @@ var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
}
};
return template.options(config.host + " Preferences", prefs.call(this));
return template.options(/*L*/config.host + " Preferences", prefs.call(this));
},
/**
@@ -219,8 +219,8 @@ var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
function assertType(needType)
util.assert(type === Ci.nsIPrefBranch.PREF_INVALID || type === needType,
type === Ci.nsIPrefBranch.PREF_INT
? "E521: Number required after =: " + name + "=" + value
: "E474: Invalid argument: " + name + "=" + value);
? /*L*/"E521: Number required after =: " + name + "=" + value
: /*L*/"E474: Invalid argument: " + name + "=" + value);
let type = this.branch.getPrefType(name);
switch (typeof value) {
@@ -288,7 +288,7 @@ var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
*/
toggle: function (name) {
util.assert(this.branch.getPrefType(name) === Ci.nsIPrefBranch.PREF_BOOL,
_("error.trailing", name + "!"));
_("error.trailingCharacters", name + "!"));
this.set(name, !this.get(name));
},

View File

@@ -183,7 +183,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
append: {
SanitizeDialogPane:
<groupbox orient="horizontal" xmlns={XUL}>
<caption label={config.appName + " (see :help privacy)"}/>
<caption label={config.appName + /*L*/" (see :help privacy)"}/>
<grid flex="1">
<columns><column flex="1"/><column flex="1"/></columns>
<rows>{
@@ -204,7 +204,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
function (win) prefOverlay(branch, false, {
append: {
itemList: <>
<listitem xmlns={XUL} label="See :help privacy for the following:" disabled="true" style="font-style: italic; font-weight: bold;"/>
<listitem xmlns={XUL} label={/*L*/"See :help privacy for the following:"} disabled="true" style="font-style: italic; font-weight: bold;"/>
{
template.map(ourItems(), function ([item, desc])
<listitem xmlns={XUL} type="checkbox"
@@ -343,16 +343,18 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
deny: 2,
session: 8
},
UNPERMS: Class.memoize(function () iter(this.PERMS).map(Array.reverse).toObject()),
COMMANDS: {
unset: "Unset",
allow: "Allowed",
deny: "Denied",
session: "Allowed for the current session",
list: "List all cookies for domain",
clear: "Clear all cookies for domain",
"clear-persistent": "Clear all persistent cookies for domain",
"clear-session": "Clear all session cookies for domain"
unset: /*L*/"Unset",
allow: /*L*/"Allowed",
deny: /*L*/"Denied",
session: /*L*/"Allowed for the current session",
list: /*L*/"List all cookies for domain",
clear: /*L*/"Clear all cookies for domain",
"clear-persistent": /*L*/"Clear all persistent cookies for domain",
"clear-session": /*L*/"Clear all session cookies for domain"
},
argPrefMap: {
@@ -414,7 +416,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
args[0] = "all";
if (args.bang) {
dactyl.assert(args.length == 0, _("error.trailing"));
dactyl.assert(args.length == 0, _("error.trailingCharacters"));
items = Object.keys(sanitizer.itemMap).filter(
function (k) modules.options.get("sanitizeitems").has(k));
}

View File

@@ -59,6 +59,7 @@ var Services = Module("Services", {
this.add("stylesheet", "@mozilla.org/content/style-sheet-service;1", "nsIStyleSheetService");
this.add("subscriptLoader", "@mozilla.org/moz/jssubscript-loader;1", "mozIJSSubScriptLoader");
this.add("tagging", "@mozilla.org/browser/tagging-service;1", "nsITaggingService");
this.add("tld", "@mozilla.org/network/effective-tld-service;1", "nsIEffectiveTLDService");
this.add("threading", "@mozilla.org/thread-manager;1", "nsIThreadManager");
this.add("urifixup", "@mozilla.org/docshell/urifixup;1", "nsIURIFixup");
this.add("versionCompare", "@mozilla.org/xpcom/version-comparator;1", "nsIVersionComparator");

View File

@@ -321,9 +321,9 @@ var File = Class("File", {
*/
iterDirectory: function () {
if (!this.exists())
throw Error("File does not exist");
throw Error(/*L*/"File does not exist");
if (!this.isDirectory())
throw Error("Not a directory");
throw Error(/*L*/"Not a directory");
for (let file in iter(this.directoryEntries))
yield File(file);
},
@@ -362,7 +362,7 @@ var File = Class("File", {
*/
readDirectory: function (sort) {
if (!this.isDirectory())
throw Error("Not a directory");
throw Error(/*L*/"Not a directory");
let array = [e for (e in this.iterDirectory())];
if (sort)
@@ -515,7 +515,7 @@ var File = Class("File", {
DoesNotExist: function (path, error) ({
path: path,
exists: function () false,
__noSuchMethod__: function () { throw error || Error("Does not exist"); }
__noSuchMethod__: function () { throw error || Error(/*L*/"Does not exist"); }
}),
defaultEncoding: "UTF-8",

View File

@@ -312,9 +312,9 @@ var Styles = Module("Styles", {
<tr highlight="Title">
<td/>
<td/>
<td style="padding-right: 1em;">Name</td>
<td style="padding-right: 1em;">Filter</td>
<td style="padding-right: 1em;">CSS</td>
<td style="padding-right: 1em;"><!--L-->Name</td>
<td style="padding-right: 1em;"><!--L-->Filter</td>
<td style="padding-right: 1em;"><!--L-->CSS</td>
</tr>
<col style="min-width: 4em; padding-right: 1em;"/>
<col style="min-width: 1em; text-align: center; color: red; font-weight: bold;"/>
@@ -377,8 +377,8 @@ var Styles = Module("Styles", {
context.fork("current", 0, this, function (context) {
context.title = ["Current Site"];
context.completions = [
[content.location.host, "Current Host"],
[content.location.href, "Current URL"]
[content.location.host, /*L*/"Current Host"],
[content.location.href, /*L*/"Current URL"]
];
});
}
@@ -389,7 +389,7 @@ var Styles = Module("Styles", {
context.generate = function () values(group.sites);
context.keys.text = util.identity;
context.keys.description = function (site) this.sheets.length + " sheet" + (this.sheets.length == 1 ? "" : "s") + ": " +
context.keys.description = function (site) this.sheets.length + /*L*/" sheet" + (this.sheets.length == 1 ? "" : "s") + ": " +
array.compact(this.sheets.map(function (s) s.name)).join(", ");
context.keys.sheets = function (site) group.sheets.filter(function (s) s.sites.indexOf(site) >= 0);
context.keys.active = function (site) uris.some(Styles.matchFilter(site));
@@ -434,7 +434,7 @@ var Styles = Module("Styles", {
for (let item in Iterator({ Active: true, Inactive: false })) {
let [name, active] = item;
context.split(name, null, function (context) {
context.title[0] = name + " " + (title || "Sheets");
context.title[0] = /*L*/name + " " + (title || "Sheets");
context.filters.push(function (item) !!item.active == active);
});
}
@@ -584,7 +584,9 @@ var Styles = Module("Styles", {
}
else if (args.completeArg == 1) {
if (sheet)
context.completions = [[sheet.css, "Current Value"]];
context.completions = [
[sheet.css, _("option.currentValue")]
];
context.fork("css", 0, modules.completion, "css");
}
},

View File

@@ -363,7 +363,9 @@ var Template = Module("Template", {
// <e4x>
return <table>
<tr style="text-align: left;" highlight="Title">
<th colspan="2">jump</th><th>title</th><th>URI</th>
<th colspan="2"><!--L-->Jump</th>
<th><!--L-->Title</th>
<th><!--L-->URI</th>
</tr>
{
this.map(Iterator(elems), function ([idx, val])
@@ -494,7 +496,7 @@ var Template = Module("Template", {
let (name = item.name || item.names[0], frame = item.definedAt)
!frame ? name :
template.helpLink(help(item), name, "Title") +
<span highlight="LinkInfo" xmlns:dactyl={NS}>Defined at {sourceLink(frame)}</span>
<span highlight="LinkInfo" xmlns:dactyl={NS}><!--L-->Defined at {sourceLink(frame)}</span>
}</span>
</td>
{ item.columns ? template.map(item.columns, function (c) <td>{c}</td>) : "" }

View File

@@ -182,12 +182,12 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
// check for chars not in the accepted range
this.assert(RegExp("^[" + accepted + "-]+$").test(list),
_("error.charsOutsideRange", accepted.quote()));
_("error.charactersOutsideRange", accepted.quote()));
// check for illegal ranges
for (let [match] in this.regexp.iterate(/.-./g, list))
this.assert(match.charCodeAt(0) <= match.charCodeAt(2),
_("error.invalidCharRange", list.slice(list.indexOf(match))));
_("error.invalidCharacterRange", list.slice(list.indexOf(match))));
return RegExp("[" + util.regexp.escape(list) + "]");
},
@@ -309,7 +309,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
}
else if (char === "]") {
stack.pop();
util.assert(stack.length, "Unmatched %] in format");
util.assert(stack.length, /*L*/"Unmatched %] in format");
}
else {
let quote = function quote(obj, char) obj[char];
@@ -328,7 +328,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
if (end < format.length)
stack.top.elements.push(format.substr(end));
util.assert(stack.length === 1, "Unmatched %[ in format");
util.assert(stack.length === 1, /*L*/"Unmatched %[ in format");
return stack.top;
},
@@ -375,7 +375,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
}
else if (close) {
stack.pop();
util.assert(stack.length, "Unmatched %] in macro");
util.assert(stack.length, /*L*/"Unmatched %] in macro");
}
else {
let [, flags, name] = /^((?:[a-z]-)*)(.*)/.exec(macro);
@@ -402,7 +402,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
if (end < macro.length)
stack.top.elements.push(macro.substr(end));
util.assert(stack.length === 1, "Unmatched <{ in macro");
util.assert(stack.length === 1, /*L*/"Unmatched <{ in macro");
return stack.top;
},
@@ -759,12 +759,12 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
[hours, minutes] = div(minutes, 60);
[days, hours] = div(hours, 24);
if (days)
return days + " days " + hours + " hours"
return /*L*/days + " days " + hours + " hours"
if (hours)
return hours + "h " + minutes + "m";
return /*L*/hours + "h " + minutes + "m";
if (minutes)
return minutes + ":" + pad(2, seconds);
return seconds + "s";
return /*L*/minutes + ":" + pad(2, seconds);
return /*L*/seconds + "s";
},
/**
@@ -1246,7 +1246,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
let sentinel = "(function DactylOverlay() {}())"
value.toString = function toString() toString.toString.call(this).replace(/\}?$/, sentinel + "; $&");
value.toSource = function toSource() toString.toSource.call(this).replace(/\}?$/, sentinel + "; $&");
value.toSource = function toSource() toSource.toSource.call(this).replace(/\}?$/, sentinel + "; $&");
delete desc.value;
delete desc.writable;
@@ -1694,7 +1694,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
do {
mainThread.processNextEvent(!flush);
if (util.interrupted)
throw new Error("Interrupted");
throw Error("Interrupted");
}
while (flush === true && mainThread.hasPendingEvents());
}