1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 03:47:57 +01:00

began moving some mappings from mappings.js -> buffer.js; Also the constructors of Mail() and Buffer() accept an argument in which mode they should add the mapping

This commit is contained in:
Martin Stubenschrott
2008-02-14 15:00:05 +00:00
parent e652d53e5d
commit 3b461b18c2
5 changed files with 68 additions and 53 deletions

View File

@@ -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. the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
vimperator.Buffer = function () //{{{ vimperator.Buffer = function (browserModes) //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
var modes = browserModes || [vimperator.modes.NORMAL];
var zoomLevels = [ 1, 10, 25, 50, 75, 90, 100, var zoomLevels = [ 1, 10, 25, 50, 75, 90, 100,
120, 150, 200, 300, 500, 1000, 2000 ]; 120, 150, 200, 300, 500, 1000, 2000 ];
@@ -139,19 +140,6 @@ vimperator.Buffer = function () //{{{
win.scrollTo(h, v); 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 ///////////////////////////////////////////////// ////////////////////// OPTIONS /////////////////////////////////////////////////
@@ -194,6 +182,42 @@ vimperator.Buffer = function () //{{{
getter: function () { return getMarkupDocumentViewer().authorStyleDisabled; }, getter: function () { return getMarkupDocumentViewer().authorStyleDisabled; },
}); });
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// MAPPINGS ////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
vimperator.mappings.add(modes, ["i", "<Insert>"],
"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", "<Down>", "<C-e>"],
"Scroll document down",
function (count) { vimperator.buffer.scrollLines(count > 1 ? count : 1); },
{ flags: vimperator.Mappings.flags.COUNT });
vimperator.mappings.add(modes, ["k", "<Up>", "<C-y>"],
"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 ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{

View File

@@ -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. the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
vimperator.Mail = function () vimperator.Mail = function (validModes)
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
var modes = validModes || [vimperator.modes.NORMAL];
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// OPTIONS ///////////////////////////////////////////////// ////////////////////// OPTIONS /////////////////////////////////////////////////
@@ -48,20 +48,33 @@ vimperator.Mail = function ()
////////////////////// MAPPINGS //////////////////////////////////////////////// ////////////////////// MAPPINGS ////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
vimperator.mappings.add([vimperator.modes.NORMAL], ["<Return>", "<Space>"], vimperator.mappings.add(modes, ["<Return>", "i"],
"Focus message", "Focus message",
function () { content.focus(); } function () { content.focus(); });
);
// FIXME:the following mappings do not yet work! vimperator.mappings.add(modes, ["d", "<Del>"],
vimperator.mappings.add([vimperator.modes.NORMAL], ["r"],
"Reply to sender",
function () { goDoCommand("cmd_reply"); }
);
vimperator.mappings.add([vimperator.modes.NORMAL], ["d", "<Del>"],
"Move mail to Trash folder", "Move mail to Trash folder",
function () { goDoCommand("cmd_delete"); } function () { goDoCommand("cmd_delete"); });
);
vimperator.mappings.add(modes, ["j", "<Right>"],
"Select next message",
function () { goDoCommand("cmd_nextMsg"); });
vimperator.mappings.add(modes, ["J", "<Tab>"],
"Select next unread message",
function () { goDoCommand("cmd_nextUnreadMsg"); });
vimperator.mappings.add(modes, ["k", "<Left>"],
"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 ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////

View File

@@ -379,15 +379,6 @@ vimperator.Mappings = function () //{{{
{ shortHelp: "Rewind keyboard focus" } { shortHelp: "Rewind keyboard focus" }
)); ));
addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["i", "<Insert>"],
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, ["<C-q>"], addDefaultMap(new vimperator.Map(vimperator.modes.all, ["<C-q>"],
function () { vimperator.modes.passAllKeys = true; }, function () { vimperator.modes.passAllKeys = true; },
{ shortHelp: "Temporarily quit Vimperator mode" } { shortHelp: "Temporarily quit Vimperator mode" }
@@ -762,20 +753,6 @@ vimperator.Mappings = function () //{{{
flags: vimperator.Mappings.flags.COUNT flags: vimperator.Mappings.flags.COUNT
} }
)); ));
addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["j", "<Down>", "<C-e>"],
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", "<Up>", "<C-y>"],
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], ["<C-d>"], addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["<C-d>"],
function (count) { vimperator.buffer.scrollByScrollSize(count, 1); }, function (count) { vimperator.buffer.scrollByScrollSize(count, 1); },
{ {

View File

@@ -29,9 +29,10 @@ the terms of any one of the MPL, the GPL or the LGPL.
vimperator.config = { vimperator.config = {
/*** required options, no checks done if they really exist, so be careful ***/ /*** required options, no checks done if they really exist, so be careful ***/
name: "Muttator", name: "Muttator",
hostApplication: "Thunderbird", hostApplication: "Thunderbird", // TODO: can this be found out otherwise?
/*** optional options, there are checked for existance and a fallback provided ***/ /*** optional options, there are checked for existance and a fallback provided ***/
get browserModes() { return [vimperator.modes.MESSAGE]; },
features: ["mail", "hints"], features: ["mail", "hints"],
get mainWidget() { return GetThreadTree(); }, // focusContent() focuses this widget get mainWidget() { return GetThreadTree(); }, // focusContent() focuses this widget
mainWindowID: "messengerWindow", // used for :set titlestring mainWindowID: "messengerWindow", // used for :set titlestring

View File

@@ -496,13 +496,13 @@ const vimperator = (function () //{{{
vimperator.log("Loading module statusline...", 3); vimperator.log("Loading module statusline...", 3);
vimperator.statusline = vimperator.StatusLine(); vimperator.statusline = vimperator.StatusLine();
vimperator.log("Loading module buffer...", 3); 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.log("Loading module editor...", 3);
vimperator.editor = vimperator.Editor(); vimperator.editor = vimperator.Editor();
if (vimperator.has("mail")) if (vimperator.has("mail"))
{ {
vimperator.log("Loading module mail...", 3); vimperator.log("Loading module mail...", 3);
vimperator.mail = vimperator.Mail(); vimperator.mail = vimperator.Mail(vimperator.config.mailModes || [vimperator.modes.NORMAL]);
} }
if (vimperator.has("tabs")) if (vimperator.has("tabs"))
{ {