diff options
-rw-r--r-- | common/content/commandline.js | 2 | ||||
-rw-r--r-- | common/content/editor.js | 63 | ||||
-rw-r--r-- | common/content/modes.js | 54 | ||||
-rw-r--r-- | common/content/mow.js | 6 | ||||
-rw-r--r-- | common/modules/buffer.jsm | 4 | ||||
-rw-r--r-- | common/modules/messages.jsm | 26 |
6 files changed, 85 insertions, 70 deletions
diff --git a/common/content/commandline.js b/common/content/commandline.js index 9f6e4c9d..473d009a 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -1502,6 +1502,8 @@ var CommandLine = Module("commandline", { }); }, modes: function initModes() { + initModes.require("editor"); + modes.addMode("COMMAND_LINE", { char: "c", description: "Active when the command line is focused", diff --git a/common/content/editor.js b/common/content/editor.js index 895269bb..854653cf 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -36,6 +36,7 @@ var Editor = Module("editor", { }, get selection() this.editor && this.editor.selection || null, + get selectionController() this.editor && this.editor.selectionController || null, get isCaret() modes.getStack(1).main == modes.CARET, get isTextEdit() modes.getStack(1).main == modes.TEXT_EDIT, @@ -514,7 +515,64 @@ var Editor = Module("editor", { return DOM(elem).editor; } }, { - mappings: function () { + modes: function init_modes() { + modes.addMode("OPERATOR", { + char: "o", + description: "Mappings which move the cursor", + bases: [] + }); + modes.addMode("VISUAL", { + char: "v", + description: "Active when text is selected", + display: function () "VISUAL" + (this._extended & modes.LINE ? " LINE" : ""), + bases: [modes.COMMAND], + ownsFocus: true + }, { + enter: function (stack) { + if (editor.selectionController) + editor.selectionController.setCaretVisibilityDuringSelection(true); + }, + leave: function (stack, newMode) { + if (newMode.main == modes.CARET) { + let selection = content.getSelection(); + if (selection && !selection.isCollapsed) + selection.collapseToStart(); + } + else if (stack.pop) + editor.deselectText(); + } + }); + modes.addMode("TEXT_EDIT", { + char: "t", + description: "Vim-like editing of input elements", + bases: [modes.COMMAND], + ownsFocus: true + }, { + onKeyPress: function (eventList) { + const KILL = false, PASS = true; + + // Hack, really. + if (eventList[0].charCode || /^<(?:.-)*(?:BS|Del|C-h|C-w|C-u|C-k)>$/.test(DOM.Event.stringify(eventList[0]))) { + dactyl.beep(); + return KILL; + } + return PASS; + } + }); + + modes.addMode("INSERT", { + char: "i", + description: "Active when an input element is focused", + insert: true, + ownsFocus: true + }); + modes.addMode("AUTOCOMPLETE", { + description: "Active when an input autocomplete pop-up is active", + display: function () "AUTOCOMPLETE (insert)", + bases: [modes.INSERT] + }); + }, + mappings: function init_mappings() { Map.types["editor"] = { preExecute: function preExecute(args) { @@ -1039,8 +1097,7 @@ var Editor = Module("editor", { bind(["<C-n>"], "Select the next autocomplete result", function () { events.feedkeys("<Down>", { skipmap: true }); }); }, - - options: function () { + options: function init_options() { options.add(["editor"], "The external text editor", "string", 'gvim -f +<line> +"sil! call cursor(0, <column>)" <file>', { diff --git a/common/content/modes.js b/common/content/modes.js index d515e544..c923c6bf 100644 --- a/common/content/modes.js +++ b/common/content/modes.js @@ -57,28 +57,6 @@ var Modes = Module("modes", { description: "Active when nothing is focused", bases: [this.COMMAND] }); - this.addMode("OPERATOR", { - char: "o", - description: "Mappings which move the cursor", - bases: [] - }); - this.addMode("VISUAL", { - char: "v", - description: "Active when text is selected", - display: function () "VISUAL" + (this._extended & modes.LINE ? " LINE" : ""), - bases: [this.COMMAND], - ownsFocus: true - }, { - leave: function (stack, newMode) { - if (newMode.main == modes.CARET) { - let selection = content.getSelection(); - if (selection && !selection.isCollapsed) - selection.collapseToStart(); - } - else if (stack.pop) - editor.deselectText(); - } - }); this.addMode("CARET", { char: "caret", description: "Active when the caret is visible in the web content", @@ -102,27 +80,6 @@ var Modes = Module("modes", { this.pref = false; } }); - this.addMode("TEXT_EDIT", { - char: "t", - description: "Vim-like editing of input elements", - bases: [this.COMMAND], - ownsFocus: true - }, { - onKeyPress: function (eventList) { - const KILL = false, PASS = true; - - // Hack, really. - if (eventList[0].charCode || /^<(?:.-)*(?:BS|Del|C-h|C-w|C-u|C-k)>$/.test(DOM.Event.stringify(eventList[0]))) { - dactyl.beep(); - return KILL; - } - return PASS; - } - }); - this.addMode("OUTPUT_MULTILINE", { - description: "Active when the multi-line output buffer is open", - bases: [this.NORMAL] - }); this.addMode("INPUT", { char: "I", @@ -130,17 +87,6 @@ var Modes = Module("modes", { bases: [this.MAIN], insert: true }); - this.addMode("INSERT", { - char: "i", - description: "Active when an input element is focused", - insert: true, - ownsFocus: true - }); - this.addMode("AUTOCOMPLETE", { - description: "Active when an input autocomplete pop-up is active", - display: function () "AUTOCOMPLETE (insert)", - bases: [this.INSERT] - }); this.addMode("EMBED", { description: "Active when an <embed> or <object> element is focused", diff --git a/common/content/mow.js b/common/content/mow.js index 799d2fb6..aa4c5b76 100644 --- a/common/content/mow.js +++ b/common/content/mow.js @@ -307,6 +307,12 @@ var MOW = Module("mow", { }) }, { }, { + modes: function initModes() { + modes.addMode("OUTPUT_MULTILINE", { + description: "Active when the multi-line output buffer is open", + bases: [modes.NORMAL] + }); + }, mappings: function initMappings() { const PASS = true; const DROP = false; diff --git a/common/modules/buffer.jsm b/common/modules/buffer.jsm index 3a59e38d..962ac352 100644 --- a/common/modules/buffer.jsm +++ b/common/modules/buffer.jsm @@ -1837,11 +1837,11 @@ var Buffer = Module("Buffer", { notificationCallbacks: Class(XPCOM([Ci.nsIChannelEventSink, Ci.nsIInterfaceRequestor]), { getInterface: function getInterface(iid) this.QueryInterface(iid), - asyncOnChannelRedirect: util.wrapCallback(function (oldChannel, newChannel, flags, callback) { + asyncOnChannelRedirect: function (oldChannel, newChannel, flags, callback) { if (newChannel instanceof Ci.nsIHttpChannel) newChannel.requestMethod = "HEAD"; callback.onRedirectVerifyCallback(Cr.NS_OK); - }) + } })() }); }; diff --git a/common/modules/messages.jsm b/common/modules/messages.jsm index a3267f2a..a6b22743 100644 --- a/common/modules/messages.jsm +++ b/common/modules/messages.jsm @@ -99,8 +99,8 @@ var Messages = Module("messages", { let { Buffer, commands, hints, io, mappings, modes, options, sanitizer } = overlay.activeModules; file = io.File(file); - function foo(base, iter_, prop) iter(function _foo() { - function key() [base, obj.identifier || obj.name].concat(Array.slice(arguments)).join(".").replace(/[:=]/g, "\\$&"); + function properties(base, iter_, prop) iter(function _properties() { + function key() [base, obj.identifier || obj.name].concat(Array.slice(arguments)).join(".").replace(/[\\:=]/g, "\\$&"); prop = prop || "description"; for (var obj in iter_) { @@ -121,14 +121,15 @@ var Messages = Module("messages", { }()).toArray(); file.write( - array(commands.allHives.map(function (h) foo("command", h))) - .concat(modes.all.map(function (m) foo("map", values(mappings.builtin.getStack(m) - .filter(function (map) map.modes[0] == m))))) - .concat(foo("mode", values(modes.all.filter(function (m) !m.hidden)))) - .concat(foo("option", options)) - .concat(foo("hintmode", values(hints.modes), "prompt")) - .concat(foo("pageinfo", values(Buffer.pageInfo), "title")) - .concat(foo("sanitizeitem", values(sanitizer.itemMap))) + array(commands.allHives.map(function (h) properties("command", h))) + .concat(modes.all.map(function (m) + properties("map", values(mappings.builtin.getStack(m) + .filter(function (map) map.modes[0] == m))))) + .concat(properties("mode", values(modes.all.filter(function (m) !m.hidden)))) + .concat(properties("option", options)) + .concat(properties("hintmode", values(hints.modes), "prompt")) + .concat(properties("pageinfo", values(Buffer.pageInfo), "title")) + .concat(properties("sanitizeitem", values(sanitizer.itemMap))) .flatten().uniq().join("\n")); } }, { @@ -154,7 +155,10 @@ var Messages = Module("messages", { function getter(key, default_) function getter() messages.get([name, key].join("."), default_); if (value != null) { - var name = [this.constructor.className.toLowerCase(), this.identifier || this.name, prop].join("."); + var name = [this.constructor.className.toLowerCase(), + this.identifier || this.name, + prop].join("."); + if (!isObject(value)) value = messages.get(name, value); else if (isArray(value)) |