diff --git a/common/content/abbreviations.js b/common/content/abbreviations.js index 9a76fa37..ccc666e8 100644 --- a/common/content/abbreviations.js +++ b/common/content/abbreviations.js @@ -203,9 +203,9 @@ var Abbreviations = Module("abbreviations", { let list = - - + + + { @@ -224,7 +224,7 @@ var Abbreviations = Module("abbreviations", { // TODO: Move this to an ItemList to show this automatically if (list.*.length() === list.text().length() + 2) - dactyl.echomsg(_("abbrev.none")); + dactyl.echomsg(_("abbreviation.none")); else commandline.commandOutput(list); } @@ -301,7 +301,7 @@ var Abbreviations = Module("abbreviations", { if (args.bang) args["-group"].clear(modes); else if (!args["-group"].remove(modes, args[0])) - return dactyl.echoerr(_("abbrev.noSuch")); + return dactyl.echoerr(_("abbreviation.noSuch")); }, { argCount: "?", bang: true, diff --git a/common/content/bookmarks.js b/common/content/bookmarks.js index a7e9bbad..65691e1f 100644 --- a/common/content/bookmarks.js +++ b/common/content/bookmarks.js @@ -404,7 +404,7 @@ var Bookmarks = Module("bookmarks", { let frames = buffer.allFrames(); if (!args.bang) return [ - [win.document.title, frames.length == 1 ? "Current Location" : "Frame: " + win.location.href] + [win.document.title, frames.length == 1 ? /*L*/"Current Location" : /*L*/"Frame: " + win.location.href] for ([, win] in Iterator(frames))]; context.keys.text = "title"; context.keys.description = "url"; @@ -464,7 +464,7 @@ var Bookmarks = Module("bookmarks", { context.title = ["Page URL"]; let frames = buffer.allFrames(); context.completions = [ - [win.document.documentURI, frames.length == 1 ? "Current Location" : "Frame: " + win.document.title] + [win.document.documentURI, frames.length == 1 ? /*L*/"Current Location" : /*L*/"Frame: " + win.document.title] for ([, win] in Iterator(frames))]; return; } @@ -511,7 +511,7 @@ var Bookmarks = Module("bookmarks", { function (resp) { if (resp && resp.match(/^y(es)?$/i)) { bookmarks.remove(Object.keys(bookmarkcache.bookmarks)); - dactyl.echomsg(_("bookmark.allGone")); + dactyl.echomsg(_("bookmark.allDeleted")); } }); else { @@ -626,7 +626,7 @@ var Bookmarks = Module("bookmarks", { if (item && item.url.indexOf("%s") > -1) context.fork("keyword/" + keyword, keyword.length + space.length, null, function (context) { context.format = history.format; - context.title = [keyword + " Quick Search"]; + context.title = [/*L*/keyword + " Quick Search"]; // context.background = true; context.compare = CompletionContext.Sort.unsorted; context.generate = function () { @@ -671,7 +671,7 @@ var Bookmarks = Module("bookmarks", { return; let ctxt = context.fork(name, 0); - ctxt.title = [engine.description + " Suggestions"]; + ctxt.title = [/*L*/engine.description + " Suggestions"]; ctxt.keys = { text: util.identity, description: function () "" }; ctxt.compare = CompletionContext.Sort.unsorted; ctxt.filterFunc = null; diff --git a/common/content/buffer.js b/common/content/buffer.js index 74799ba0..cc2f1eae 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -75,7 +75,7 @@ var Buffer = Module("buffer", { } if (!verbose && nFeed) - yield nFeed + " feed" + (nFeed > 1 ? "s" : ""); + yield nFeed + /*L*/" feed" + (nFeed > 1 ? "s" : ""); }); this.addPageInfoSection("g", "General Info", function (verbose) { @@ -110,7 +110,7 @@ var Buffer = Module("buffer", { if (!verbose) { if (pageSize[0]) - yield (pageSize[1] || pageSize[0]) + " bytes"; + yield (pageSize[1] || pageSize[0]) + /*L*/" bytes"; yield lastMod; return; } @@ -141,6 +141,41 @@ var Buffer = Module("buffer", { .sort(function (a, b) util.compareIgnoreCase(a[0], b[0])); }); + let identity = window.gIdentityHandler; + this.addPageInfoSection("s", "Security", function (verbose) { + if (!verbose || !identity) + return; // For now + + // Modified from Firefox + function location(data) array.compact([ + data.city, data.state, data.country + ]).join(", "); + + switch (statusline.security) { + case "secure": + case "extended": + var data = identity.getIdentityData(); + + yield ["Host", identity.getEffectiveHost()]; + + if (statusline.security === "extended") + yield ["Owner", data.subjectOrg] + else + yield ["Owner", _("pageinfo.s.ownerUnverified", data.subjectOrg)] + + if (location(data).length) + yield ["Location", location(data)]; + + yield ["Verified by", data.caOrg]; + + if (identity._overrideService.hasMatchingOverride(identity._lastLocation.hostname, + (identity._lastLocation.port || 443), + data.cert, {}, {})) + yield ["User exception", /*L*/"true"] + break; + } + }); + dactyl.commands["buffer.viewSource"] = function (event) { let elem = event.originalTarget; buffer.viewSource([elem.getAttribute("href"), Number(elem.getAttribute("line"))]); @@ -544,9 +579,7 @@ var Buffer = Module("buffer", { * @property {nsISelectionController} The current document's selection * controller. */ - get selectionController() config.browser.docShell - .QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsISelectionDisplay) - .QueryInterface(Ci.nsISelectionController), + get selectionController() util.selectionController(this.focusedFrame), /** * Opens the appropriate context menu for *elem*. @@ -572,7 +605,7 @@ var Buffer = Module("buffer", { try { window.urlSecurityCheck(uri.spec, doc.nodePrincipal); - io.CommandFileMode("Save link: ", { + io.CommandFileMode(_("buffer.prompt.saveLink") + " ", { onSubmit: function (path) { let file = io.File(path); if (file.exists() && file.isDirectory()) @@ -796,7 +829,7 @@ var Buffer = Module("buffer", { * @param {Node} elem The element to query. */ showElementInfo: function showElementInfo(elem) { - dactyl.echo(<>Element:
{util.objectToString(elem, true)}, commandline.FORCE_MULTILINE); + dactyl.echo(<>Element:
{util.objectToString(elem, true)}, commandline.FORCE_MULTILINE); }, /** @@ -1038,7 +1071,7 @@ var Buffer = Module("buffer", { scrollColumns: deprecated("buffer.scrollHorizontal", function scrollColumns(cols) buffer.scrollHorizontal("columns", cols)), scrollPages: deprecated("buffer.scrollHorizontal", function scrollPages(pages) buffer.scrollVertical("pages", pages)), 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) + textZoom: deprecated("buffer.zoomValue/buffer.fullZoom", function textZoom() config.browser.markupDocumentViewer.textZoom * 100) }, { PageInfo: Struct("PageInfo", "name", "title", "action") .localize("title"), @@ -1090,13 +1123,13 @@ var Buffer = Module("buffer", { var names = []; if (node.title) - names.push([node.title, "Page Name"]); + names.push([node.title, /*L*/"Page Name"]); if (node.alt) - names.push([node.alt, "Alternate Text"]); + names.push([node.alt, /*L*/"Alternate Text"]); if (!isinstance(node, Document) && node.textContent) - names.push([node.textContent, "Link Text"]); + names.push([node.textContent, /*L*/"Link Text"]); names.push([decodeURIComponent(url.replace(/.*?([^\/]*)\/*$/, "$1")), "File Name"]); @@ -1249,7 +1282,7 @@ var Buffer = Module("buffer", { // FIXME: arg handling is a bit of a mess, check for filename dactyl.assert(!arg || arg[0] == ">" && !util.OS.isWindows, - _("error.trailing")); + _("error.trailingCharacters")); prefs.withContext(function () { if (arg) { @@ -1428,7 +1461,7 @@ var Buffer = Module("buffer", { level = Math.constrain(level, Buffer.ZOOM_MIN, Buffer.ZOOM_MAX); } else - dactyl.assert(false, _("error.trailing")); + dactyl.assert(false, _("error.trailingCharacters")); buffer.setZoom(level, args.bang); }, @@ -1499,7 +1532,7 @@ var Buffer = Module("buffer", { i = i + 1; return { - text: [i + ": " + (tab.label || "(Untitled)"), i + ": " + url], + text: [i + ": " + (tab.label || /*L*/"(Untitled)"), i + ": " + url], tab: tab, id: i - 1, url: url, @@ -1850,7 +1883,7 @@ var Buffer = Module("buffer", { options.add(["pageinfo", "pa"], "Define which sections are shown by the :pageinfo command", - "charlist", "gfm", + "charlist", "gsfm", { get values() values(buffer.pageInfo).toObject() }); options.add(["scroll", "scr"], diff --git a/common/content/commandline.js b/common/content/commandline.js index ab82fb36..5cf8a9bc 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -301,7 +301,7 @@ var CommandWidgets = Class("CommandWidgets", { }); var CommandMode = Class("CommandMode", { - init: function init() { + init: function CM_init() { this.keepCommand = userContext.hidden_option_command_afterimage; }, @@ -311,9 +311,9 @@ var CommandMode = Class("CommandMode", { get prompt() this.widgets.prompt, set prompt(val) this.widgets.prompt = val, - open: function (command) { + open: function CM_open(command) { dactyl.assert(isinstance(this.mode, modes.COMMAND_LINE), - "Not opening command line in non-command-line mode."); + /*L*/"Not opening command line in non-command-line mode."); this.messageCount = commandline.messageCount; modes.push(this.mode, this.extendedMode, this.closure); @@ -341,7 +341,7 @@ var CommandMode = Class("CommandMode", { get widgets() commandline.widgets, - enter: function (stack) { + enter: function CM_enter(stack) { commandline.commandSession = this; if (stack.pop && commandline.command) { this.onChange(commandline.command); @@ -350,7 +350,7 @@ var CommandMode = Class("CommandMode", { } }, - leave: function (stack) { + leave: function CM_leave(stack) { if (!stack.push) { commandline.commandSession = null; this.input.dactylKeyPress = undefined; @@ -375,7 +375,7 @@ var CommandMode = Class("CommandMode", { }, events: { - input: function onInput(event) { + input: function CM_onInput(event) { if (this.completions) { this.resetCompletions(); @@ -383,7 +383,7 @@ var CommandMode = Class("CommandMode", { } this.onChange(commandline.command); }, - keyup: function onKeyUp(event) { + keyup: function CM_onKeyUp(event) { let key = events.toString(event); if (/-?Tab>$/.test(key) && this.completions) this.completions.tabTimer.flush(); @@ -392,7 +392,7 @@ var CommandMode = Class("CommandMode", { keepCommand: false, - onKeyPress: function onKeyPress(events) { + onKeyPress: function CM_onKeyPress(events) { if (this.completions) this.completions.previewClear(); @@ -407,7 +407,7 @@ var CommandMode = Class("CommandMode", { onSubmit: function (value) {}, - resetCompletions: function resetCompletions() { + resetCompletions: function CM_resetCompletions() { if (this.completions) { this.completions.context.cancelAll(); this.completions.wildIndex = -1; @@ -426,12 +426,12 @@ var CommandExMode = Class("CommandExMode", CommandMode, { prompt: ["Normal", ":"], - complete: function complete(context) { + complete: function CEM_complete(context) { context.fork("ex", 0, completion, "ex"); }, - onSubmit: function onSubmit(command) { - contexts.withContext({ file: "[Command Line]", line: 1 }, + onSubmit: function CEM_onSubmit(command) { + contexts.withContext({ file: /*L*/"[Command Line]", line: 1 }, function _onSubmit() { io.withSavedValues(["readHeredoc"], function _onSubmit() { this.readHeredoc = commandline.readHeredoc; @@ -449,7 +449,7 @@ var CommandPromptMode = Class("CommandPromptMode", CommandMode, { init.supercall(this); }, - complete: function (context) { + complete: function CPM_complete(context) { if (this.completer) context.forkapply("prompt", 0, this, "completer", Array.slice(arguments, 1)); }, @@ -586,6 +586,9 @@ var CommandLine = Module("commandline", { get completionList() { let node = this.widgets.active.commandline; + if (this.commandSession && this.commandSession.completionList) + node = document.getElementById(this.commandSession.completionList); + if (!node.completionList) { let elem = document.getElementById("dactyl-completions-" + node.id); util.waitFor(bind(this.widgets._ready, null, elem)); @@ -648,10 +651,9 @@ var CommandLine = Module("commandline", { * @param {XML} xml The output as an E4X XML object. */ commandOutput: function commandOutput(xml) { - XML.ignoreWhitespace = false; - XML.prettyPrinting = false; + XML.ignoreWhitespace = XML.prettyPrinting = false; if (this.command) - this.echo(<>:{this.command}{xml}, this.HIGHLIGHT_NORMAL, this.FORCE_MULTILINE); + this.echo(<>
:{this.command}
{xml}, this.HIGHLIGHT_NORMAL, this.FORCE_MULTILINE); else this.echo(xml, this.HIGHLIGHT_NORMAL, this.FORCE_MULTILINE); this.command = null; @@ -1627,7 +1629,7 @@ var ItemList = Class("ItemList", { _init: function _init() { this._div = this._dom(
-
No Completions
+
No Completions
{ diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 35e8e588..1bb6a68a 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -197,7 +197,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { argCount: "*", completer: function (context, args) { context.keys.text = util.identity; - context.keys.description = function () seen[this.text] + " matching items"; + context.keys.description = function () seen[this.text] + /*L*/" matching items"; let seen = {}; context.completions = array(item.description.toLowerCase().split(/[()\s]+/) for (item in params.iterate(args))) @@ -605,6 +605,10 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { * Initialize the help system. */ initHelp: function (force) { + // Waits for the add-on to become available, if necessary. + config.addon; + config.version; + if (force || !this.helpInitialized) { if ("noscriptOverlay" in window) { noscriptOverlay.safeAllow("chrome-data:", true, false); @@ -685,7 +689,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { unescape(encodeURI( // UTF-8 handling hack. -

Using Plugins

+

Using Plugins

{body} @@ -1010,7 +1014,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { { obj.description ? br +

{template.linkifyHelp(obj.description.replace(/\.?$/, "."), true)}

: "" }{ extraHelp ? br + extraHelp : "" }{ - !(extraHelp || obj.description) ? br +

Sorry, no help available.

: "" } + !(extraHelp || obj.description) ? br +

Sorry, no help available.

: "" }
; @@ -1073,7 +1077,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { * These are set and accessed with the "g:" prefix. */ _globalVariables: {}, - globalVariables: deprecated("the options system", { + globalVariables: deprecated(/*L*/"the options system", { get: function globalVariables() this._globalVariables }), @@ -1160,7 +1164,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { onExecute: function onExecute(event) { let cmd = event.originalTarget.getAttribute("dactyl-execute"); commands.execute(cmd, null, false, null, - { file: "[Command Line]", line: 1 }); + { file: /*L*/"[Command Line]", line: 1 }); }, /** @@ -1962,7 +1966,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { commandline.commandOutput(
- ModeAbbrevReplacementModeAbbrevReplacement
- + diff --git a/common/content/editor.js b/common/content/editor.js index 6e9069ef..3fd78fbe 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -243,7 +243,7 @@ var Editor = Module("editor", { let args = options.get("editor").format(args); - dactyl.assert(args.length >= 1, _("editor.noEditor")); + dactyl.assert(args.length >= 1, _("option.notSet", "editor")); io.run(args.shift(), args, blocking); }, @@ -272,10 +272,10 @@ var Editor = Module("editor", { column = 1 + pre.replace(/[^]*\n/, "").length; } else { - var editor = window.GetCurrentEditor ? GetCurrentEditor() - : Editor.getEditor(document.commandDispatcher.focusedWindow); - dactyl.assert(editor); - text = Array.map(editor.rootElement.childNodes, function (e) util.domToString(e, true)).join(""); + var editor_ = window.GetCurrentEditor ? GetCurrentEditor() + : Editor.getEditor(document.commandDispatcher.focusedWindow); + dactyl.assert(editor_); + text = Array.map(editor_.rootElement.childNodes, function (e) util.domToString(e, true)).join(""); } let origGroup = textBox && textBox.getAttributeNS(NS, "highlight") || ""; @@ -312,16 +312,16 @@ var Editor = Module("editor", { if (textBox) textBox.value = val; else { - while (editor.rootElement.firstChild) - editor.rootElement.removeChild(editor.rootElement.firstChild); - editor.rootElement.innerHTML = val; + while (editor_.rootElement.firstChild) + editor_.rootElement.removeChild(editor_.rootElement.firstChild); + editor_.rootElement.innerHTML = val; } } try { var tmpfile = io.createTempFile(); if (!tmpfile) - throw Error("Couldn't create temporary file"); + throw Error(/*L*/"Couldn't create temporary file"); if (textBox) { highlight.highlightNode(textBox, origGroup + " EditorEditing"); @@ -329,7 +329,7 @@ var Editor = Module("editor", { } if (!tmpfile.write(text)) - throw Error("Input contains characters not valid in the current " + + throw Error(/*L*/"Input contains characters not valid in the current " + "file encoding"); var lastUpdate = Date.now(); diff --git a/common/content/events.js b/common/content/events.js index 21b44758..1f13aefa 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -322,7 +322,7 @@ var EventHive = Class("EventHive", Contexts.Hive, { var [self, events] = [null, array.toObject([[event, callback]])]; else { [self, events] = [event, event[callback || "events"]]; - [,, capture, allowUntrusted] = arguments; + [, , capture, allowUntrusted] = arguments; } if (set.has(events, "input") && !set.has(events, "dactyl-input")) @@ -669,12 +669,15 @@ var Events = Module("events", { let doc = document.commandDispatcher.focusedWindow.document; let event = events.create(doc, type, evt); + let target = dactyl.focusedElement + || ["complete", "interactive"].indexOf(doc.readyState) >= 0 && doc.documentElement + || doc.defaultView; + + if (target instanceof Element && !Events.isInputElement(target)) + target = target.ownerDocument.documentElement; if (!evt_obj.dactylString && !mode) - events.dispatch(dactyl.focusedElement - || ["complete", "interactive"].indexOf(doc.readyState) >= 0 && doc.documentElement - || doc.defaultView, - event, evt); + events.dispatch(target, event, evt); else if (type === "keypress") events.events.keypress.call(events, event); } @@ -1259,7 +1262,7 @@ var Events = Module("events", { else ignore = true; - if (ignore && !Events.isEscape(key)) + if (ignore) modes.pop(); } else if (!event.isMacro && !event.noremap && events.shouldPass(event)) @@ -1487,14 +1490,16 @@ var Events = Module("events", { key === "" || key === "", isHidden: function isHidden(elem, aggressive) { - for (let e = elem; e instanceof Element; e = e.parentNode) { - if (util.computedStyle(e).visibility !== "visible" || - aggressive && !/set$/.test(e.localName) - && e.boxObject && e.boxObject.height === 0) - return true; - else if (e.namespaceURI == XUL && e.localName === "panel") - break; - } + if (util.computedStyle(elem).visibility !== "visible") + return true; + + if (aggressive) + for (let e = elem; e instanceof Element; e = e.parentNode) { + if (!/set$/.test(e.localName) && e.boxObject && e.boxObject.height === 0) + return true; + else if (e.namespaceURI == XUL && e.localName === "panel") + break; + } return false; }, @@ -1530,7 +1535,7 @@ var Events = Module("events", { literal: 0 }); - commands.add(["macros"], + commands.add(["mac[ros]"], "List all macros", function (args) { completion.listCompleter("macro", args[0]); }, { argCount: "?", @@ -1660,7 +1665,7 @@ var Events = Module("events", { filter.keys = events.fromString(vals[0]).map(events.closure.toString); filter.commandKeys = vals.slice(1).map(events.closure.canonicalKeys); - filter.inputKeys = filter.commandKeys.filter(/^<[ACM]-/); + filter.inputKeys = filter.commandKeys.filter(bind("test", /^<[ACM]-/)); }); this.flush(); return values; diff --git a/common/content/help.xsl b/common/content/help.xsl index 3dcdf215..8514f92e 100644 --- a/common/content/help.xsl +++ b/common/content/help.xsl @@ -185,7 +185,7 @@
-

Contents

+

Contents

@@ -240,7 +240,7 @@ - (empty) + (empty) @@ -430,7 +430,7 @@

- Deprecated: + Deprecated:

@@ -439,7 +439,7 @@

- Note: + Note:

@@ -448,7 +448,7 @@

- Warning: + Warning:

diff --git a/common/content/hints.js b/common/content/hints.js index 079cdadf..cc59d101 100644 --- a/common/content/hints.js +++ b/common/content/hints.js @@ -472,7 +472,7 @@ var HintSession = Class("HintSession", CommandMode, { else if (n) hints.setClass(elem, n % 2); else - hints.setClass(elem, this.validHints[Math.max(0, this.hintNumber-1)].elem === elem); + hints.setClass(elem, this.validHints[Math.max(0, this.hintNumber - 1)].elem === elem); if (n--) this.timeout(next, 50); @@ -1189,7 +1189,7 @@ var Hints = Module("hints", { "XPath or CSS selector strings of hintable elements for extended hint modes", "regexpmap", { "[iI]": "img", - "[asOTivVWy]": ["a[href]", "area[href]", "img[src]", "iframe[src]"], + "[asOTvVWy]": ["a[href]", "area[href]", "img[src]", "iframe[src]"], "[f]": "body", "[F]": ["body", "code", "div", "html", "p", "pre", "span"], "[S]": ["input:not([type=hidden])", "textarea", "button", "select"] diff --git a/common/content/history.js b/common/content/history.js index cf985d99..0d34acc7 100644 --- a/common/content/history.js +++ b/common/content/history.js @@ -219,7 +219,7 @@ var History = Module("history", { description: "The sort order of the results", completer: function (context, args) { context.compare = CompletionContext.Sort.unsorted; - return array.flatten([ + return /*L*/array.flatten([ "annotation", "date", "date added", diff --git a/common/content/mappings.js b/common/content/mappings.js index 99b6e9af..e7badaa8 100644 --- a/common/content/mappings.js +++ b/common/content/mappings.js @@ -168,7 +168,7 @@ var MapHive = Class("MapHive", Contexts.Hive, { modes = Array.concat(modes); if (!modes.every(util.identity)) - throw TypeError("Invalid modes: " + modes); + throw TypeError(/*L*/"Invalid modes: " + modes); let map = Map(modes, keys, description, action, extra); map.definedAt = contexts.getCaller(Components.stack.caller); @@ -431,9 +431,9 @@ var Mappings = Module("mappings", { let list =
Code execution summaryCode execution summary
  Executed:{count}times
  Average time:{each.toFixed(2)}{eachUnits}
- - + + + { @@ -531,7 +531,7 @@ var Mappings = Module("mappings", { { names: ["-description", "-desc", "-d"], description: "A description of this mapping", - default: "User-defined mapping", + default: /*L*/"User-defined mapping", type: CommandOption.STRING }, { diff --git a/common/content/marks.js b/common/content/marks.js index c5a3ef04..1cb3e957 100644 --- a/common/content/marks.js +++ b/common/content/marks.js @@ -146,7 +146,7 @@ var Marks = Module("marks", { let mark = (this._localMarks.get(this.localURI) || {})[char]; dactyl.assert(mark, _("mark.unset", char)); - dactyl.log(_("marks.jumpingToLocal", Marks.markToString(char, mark)), 5); + dactyl.log(_("mark.jumpingToLocal", Marks.markToString(char, mark)), 5); buffer.scrollToPercent(mark.position.x * 100, mark.position.y * 100); } else @@ -249,7 +249,7 @@ var Marks = Module("marks", { "Mark current location within the web page", function (args) { let mark = args[0] || ""; - dactyl.assert(mark.length <= 1, _("error.trailing")); + dactyl.assert(mark.length <= 1, _("error.trailingCharacters")); dactyl.assert(/[a-zA-Z]/.test(mark), _("mark.invalid")); marks.add(mark); diff --git a/common/content/modes.js b/common/content/modes.js index 2840ea6c..f9b93625 100644 --- a/common/content/modes.js +++ b/common/content/modes.js @@ -207,6 +207,51 @@ var Modes = Module("modes", { } }); + + function makeTree() { + let list = modes.all.filter(function (m) m.name !== m.description); + + let tree = {}; + + for (let mode in values(list)) + tree[mode.name] = {}; + + for (let mode in values(list)) + for (let base in values(mode.bases)) + tree[base.name][mode.name] = tree[mode.name]; + + let roots = iter([m.name, tree[m.name]] for (m in values(list)) if (!m.bases.length)).toObject(); + + default xml namespace = NS; + function rec(obj) { + XML.ignoreWhitespace = XML.prettyPrinting = false; + + let res = , @@ -282,11 +282,11 @@ var AddonList = Class("AddonList", { XML.ignoreWhitespace = true; util.xmlToDom(
- ModeCommandActionModeCommandAction
{_("addon.action.On")} {_("addon.action.Off")} - {_("addon.action.Del")} - {_("addon.action.Upd")} - {_("addon.action.Opt")} + {_("addon.action.Delete")} + {_("addon.action.Update")} + {_("addon.action.Options")}
- - - + + + +
NameVersionStatusNameVersionStatus - DescriptionDescription
, 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")); diff --git a/common/modules/base.jsm b/common/modules/base.jsm index f39f17bf..724dfb3c 100644 --- a/common/modules/base.jsm +++ b/common/modules/base.jsm @@ -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))); }; diff --git a/common/modules/bookmarkcache.jsm b/common/modules/bookmarkcache.jsm index 8f12b6a4..e85a7c6c 100644 --- a/common/modules/bookmarkcache.jsm +++ b/common/modules/bookmarkcache.jsm @@ -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 = {}; diff --git a/common/modules/bootstrap.jsm b/common/modules/bootstrap.jsm index 005ba162..6945b05b 100644 --- a/common/modules/bootstrap.jsm +++ b/common/modules/bootstrap.jsm @@ -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"); diff --git a/common/modules/commands.jsm b/common/modules/commands.jsm index e422a908..bb184933 100644 --- a/common/modules/commands.jsm +++ b/common/modules/commands.jsm @@ -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 = + + + + + + + + + + { + template.map(hives, function ([hive, cmds]) let (i = 0) + + + template.map(cmds, function (cmd) + template.map(cmd.names, function (name) + + + + + + + + + )) + + ) + } +
+ NameArgsRangeCompleteDefinition
{!i++ ? hive.name : ""}{cmd.bang ? "!" : " "}{cmd.name}{cmd.argCount}{cmd.count ? "0c" : ""}{completerToString(cmd.completer)}{cmd.replacementText || "function () { ... }"}
; + + if (list.*.length() === list.text().length() + 2) dactyl.echomsg(_("command.none")); else - commandline.commandOutput( - - - - - - - - - - - { - template.map(this.userHives, function (hive) let (i = 0) - + - template.map(hive, function (cmd) - template.map(cmd.names, function (name) - - - - - - - - - )) + - ) - } -
- NameArgsRangeCompleteDefinition
{!i++ ? hive.name : ""}{cmd.bang ? "!" : " "}{cmd.name}{cmd.argCount}{cmd.count ? "0c" : ""}{completerToString(cmd.completer)}{cmd.replacementText || "function () { ... }"}
); + 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 : "")), diff --git a/common/modules/completion.jsm b/common/modules/completion.jsm index 74e8cf15..2e29c638 100644 --- a/common/modules/completion.jsm +++ b/common/modules/completion.jsm @@ -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, diff --git a/common/modules/config.jsm b/common/modules/config.jsm index 310545e6..61766ad3 100644 --- a/common/modules/config.jsm +++ b/common/modules/config.jsm @@ -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(); + + 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%; diff --git a/common/modules/downloads.jsm b/common/modules/downloads.jsm index 39441259..b4d8e070 100644 --- a/common/modules/downloads.jsm +++ b/common/modules/downloads.jsm @@ -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( - Title - Status + Title + Status - Progress + Progress - Time remaining - Source + Time remaining + Source
- + - - + + + @@ -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"); } }, diff --git a/common/modules/template.jsm b/common/modules/template.jsm index 8a398c2e..b979e709 100644 --- a/common/modules/template.jsm +++ b/common/modules/template.jsm @@ -363,7 +363,9 @@ var Template = Module("Template", { // return
Totals: Totals:  - Clear + Clear ", "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(["", "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({result.output}); @@ -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" }); } } diff --git a/common/modules/javascript.jsm b/common/modules/javascript.jsm index 49feed58..7d8de811 100644 --- a/common/modules/javascript.jsm +++ b/common/modules/javascript.jsm @@ -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); diff --git a/common/modules/options.jsm b/common/modules/options.jsm index de033724..dc73558a 100644 --- a/common/modules/options.jsm +++ b/common/modules/options.jsm @@ -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; } diff --git a/common/modules/prefs.jsm b/common/modules/prefs.jsm index e9b85bbb..1fa898b2 100644 --- a/common/modules/prefs.jsm +++ b/common/modules/prefs.jsm @@ -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)); }, diff --git a/common/modules/sanitizer.jsm b/common/modules/sanitizer.jsm index f6b79a27..924aa4db 100644 --- a/common/modules/sanitizer.jsm +++ b/common/modules/sanitizer.jsm @@ -183,7 +183,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef append: { SanitizeDialogPane: -
+ { @@ -204,7 +204,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef function (win) prefOverlay(branch, false, { append: { itemList: <> - + { template.map(ourItems(), function ([item, desc])
- NameFilterCSSNameFilterCSS
- + + + { 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") + - Defined at {sourceLink(frame)} + Defined at {sourceLink(frame)} } { item.columns ? template.map(item.columns, function (c) ) : "" } diff --git a/common/modules/util.jsm b/common/modules/util.jsm index 52a768b2..0a64fd2f 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -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()); } diff --git a/common/skin/dactyl.css b/common/skin/dactyl.css index 57b01d3c..42377000 100644 --- a/common/skin/dactyl.css +++ b/common/skin/dactyl.css @@ -9,6 +9,7 @@ [dactyl|highlight~=hints] { -moz-binding: url(resource://dactyl-content/bindings.xml#hints) !important; + position: static !important; } [dactyl|highlight~=HintImage], diff --git a/common/tests/functional/testCommands.js b/common/tests/functional/testCommands.js index 59724b55..e247359e 100644 --- a/common/tests/functional/testCommands.js +++ b/common/tests/functional/testCommands.js @@ -301,7 +301,7 @@ var tests = { }, if: {}, // Skip for now javascript: { - noOutput: ["''", "'\\n'", "
foo bar
", "window"], + noOutput: ["''", "'\\n'", "
foo bar
", "window", "<
jumptitleURIJumpTitleURI
{c}