diff --git a/content/buffer.js b/content/buffer.js index b5f6575f..a6c5fc14 100644 --- a/content/buffer.js +++ b/content/buffer.js @@ -26,11 +26,12 @@ the provisions above, a recipient may use your version of this file under the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ -vimperator.Buffer = function () //{{{ +vimperator.Buffer = function (browserModes) //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ + var modes = browserModes || [vimperator.modes.NORMAL]; var zoomLevels = [ 1, 10, 25, 50, 75, 90, 100, 120, 150, 200, 300, 500, 1000, 2000 ]; @@ -139,19 +140,6 @@ vimperator.Buffer = function () //{{{ win.scrollTo(h, v); } - vimperator.commands.addUserCommand(new vimperator.Command(["test"], - function (args, special) - { - alert(args) - }, - { - shortHelp: "Test command" - } - )); - vimperator.mappings.add([vimperator.modes.NORMAL], ["w"], "Test", - function () { alert("test"); } - ); - /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// OPTIONS ///////////////////////////////////////////////// @@ -194,6 +182,42 @@ vimperator.Buffer = function () //{{{ getter: function () { return getMarkupDocumentViewer().authorStyleDisabled; }, }); + /////////////////////////////////////////////////////////////////////////////}}} + ////////////////////// MAPPINGS //////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ + + vimperator.mappings.add(modes, ["i", ""], + "Start caret mode", + function () + { + // setting this option triggers an observer which takes care of the mode setting + vimperator.options.setPref("accessibility.browsewithcaret", true); + }); + + vimperator.mappings.add(modes, ["j", "", ""], + "Scroll document down", + function (count) { vimperator.buffer.scrollLines(count > 1 ? count : 1); }, + { flags: vimperator.Mappings.flags.COUNT }); + + vimperator.mappings.add(modes, ["k", "", ""], + "Scroll document up", + function (count) { vimperator.buffer.scrollLines(-(count > 1 ? count : 1)); }, + { flags: vimperator.Mappings.flags.COUNT }); + + /////////////////////////////////////////////////////////////////////////////}}} + ////////////////////// COMMANDS //////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ + + vimperator.commands.addUserCommand(new vimperator.Command(["test"], + function (args, special) + { + alert(args) + }, + { + shortHelp: "Test command" + } + )); + /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ diff --git a/content/mail.js b/content/mail.js index a5ec28b3..2bb5b6cd 100644 --- a/content/mail.js +++ b/content/mail.js @@ -26,12 +26,12 @@ the provisions above, a recipient may use your version of this file under the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ -vimperator.Mail = function () +vimperator.Mail = function (validModes) { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - + var modes = validModes || [vimperator.modes.NORMAL]; /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// OPTIONS ///////////////////////////////////////////////// @@ -48,20 +48,33 @@ vimperator.Mail = function () ////////////////////// MAPPINGS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - vimperator.mappings.add([vimperator.modes.NORMAL], ["", ""], + vimperator.mappings.add(modes, ["", "i"], "Focus message", - function () { content.focus(); } - ); + function () { content.focus(); }); - // FIXME:the following mappings do not yet work! - vimperator.mappings.add([vimperator.modes.NORMAL], ["r"], - "Reply to sender", - function () { goDoCommand("cmd_reply"); } - ); - vimperator.mappings.add([vimperator.modes.NORMAL], ["d", ""], + vimperator.mappings.add(modes, ["d", ""], "Move mail to Trash folder", - function () { goDoCommand("cmd_delete"); } - ); + function () { goDoCommand("cmd_delete"); }); + + vimperator.mappings.add(modes, ["j", ""], + "Select next message", + function () { goDoCommand("cmd_nextMsg"); }); + + vimperator.mappings.add(modes, ["J", ""], + "Select next unread message", + function () { goDoCommand("cmd_nextUnreadMsg"); }); + + vimperator.mappings.add(modes, ["k", ""], + "Select previous message", + function () { goDoCommand("cmd_previousMsg"); }); + + vimperator.mappings.add(modes, ["K"], + "Select previous unread message", + function () { goDoCommand("cmd_previousUnreadMsg"); }); + + vimperator.mappings.add(modes, ["r"], + "Reply to sender", + function () { goDoCommand("cmd_reply"); }); /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// diff --git a/content/mappings.js b/content/mappings.js index d446af7a..492a7155 100644 --- a/content/mappings.js +++ b/content/mappings.js @@ -379,15 +379,6 @@ vimperator.Mappings = function () //{{{ { shortHelp: "Rewind keyboard focus" } )); - addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["i", ""], - function () - { - // setting this option triggers an observer - // which takes care of the mode setting - vimperator.options.setPref("accessibility.browsewithcaret", true); - }, - { shortHelp: "Start caret mode" } - )); addDefaultMap(new vimperator.Map(vimperator.modes.all, [""], function () { vimperator.modes.passAllKeys = true; }, { shortHelp: "Temporarily quit Vimperator mode" } @@ -762,20 +753,6 @@ vimperator.Mappings = function () //{{{ flags: vimperator.Mappings.flags.COUNT } )); - addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["j", "", ""], - function (count) { vimperator.buffer.scrollLines(count > 1 ? count : 1); }, - { - shortHelp: "Scroll document down", - flags: vimperator.Mappings.flags.COUNT - } - )); - addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["k", "", ""], - function (count) { vimperator.buffer.scrollLines(-(count > 1 ? count : 1)); }, - { - shortHelp: "Scroll document up", - flags: vimperator.Mappings.flags.COUNT - } - )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], [""], function (count) { vimperator.buffer.scrollByScrollSize(count, 1); }, { diff --git a/content/muttator.js b/content/muttator.js index be243a0d..8fed178a 100644 --- a/content/muttator.js +++ b/content/muttator.js @@ -29,9 +29,10 @@ the terms of any one of the MPL, the GPL or the LGPL. vimperator.config = { /*** required options, no checks done if they really exist, so be careful ***/ name: "Muttator", - hostApplication: "Thunderbird", + hostApplication: "Thunderbird", // TODO: can this be found out otherwise? /*** optional options, there are checked for existance and a fallback provided ***/ + get browserModes() { return [vimperator.modes.MESSAGE]; }, features: ["mail", "hints"], get mainWidget() { return GetThreadTree(); }, // focusContent() focuses this widget mainWindowID: "messengerWindow", // used for :set titlestring diff --git a/content/vim.js b/content/vim.js index f2144098..d9f21440 100644 --- a/content/vim.js +++ b/content/vim.js @@ -496,13 +496,13 @@ const vimperator = (function () //{{{ vimperator.log("Loading module statusline...", 3); vimperator.statusline = vimperator.StatusLine(); vimperator.log("Loading module buffer...", 3); - vimperator.buffer = vimperator.Buffer(); + vimperator.buffer = vimperator.Buffer(vimperator.config.browserModes || [vimperator.modes.NORMAL]); vimperator.log("Loading module editor...", 3); vimperator.editor = vimperator.Editor(); if (vimperator.has("mail")) { vimperator.log("Loading module mail...", 3); - vimperator.mail = vimperator.Mail(); + vimperator.mail = vimperator.Mail(vimperator.config.mailModes || [vimperator.modes.NORMAL]); } if (vimperator.has("tabs")) {