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

moved allModes from mappings.js to vimperator.modes.all

This commit is contained in:
Martin Stubenschrott
2008-02-12 13:33:37 +00:00
parent 63b66497e9
commit 76c161a0f4
2 changed files with 29 additions and 39 deletions

View File

@@ -198,6 +198,7 @@ vimperator.Mappings = function () //{{{
return user[mode].some(function (map) { return map.hasName(cmd); });
},
// TODO: rename to add, and change add to addUser(Map)
addDefault: function (modes, keys, description, action, extra)
{
addMap (new vimperator.Map(modes, keys,
@@ -349,37 +350,21 @@ vimperator.Mappings = function () //{{{
////////////////////// DEFAULT MAPPINGS ////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
var allModes = [vimperator.modes.NONE,
vimperator.modes.NORMAL,
vimperator.modes.INSERT,
vimperator.modes.VISUAL,
vimperator.modes.HINTS,
vimperator.modes.COMMAND_LINE,
vimperator.modes.MESSAGE,
vimperator.modes.CARET,
vimperator.modes.TEXTAREA];
var noninsertModes = [vimperator.modes.NORMAL,
vimperator.modes.VISUAL,
vimperator.modes.HINTS,
vimperator.modes.MESSAGE,
vimperator.modes.CARET,
vimperator.modes.TEXTAREA];
//
// NORMAL mode
// {{{
// vimperator management
addDefaultMap(new vimperator.Map(allModes, ["<F1>"],
addDefaultMap(new vimperator.Map(vimperator.modes.all, ["<F1>"],
function () { vimperator.commands.help(); },
{ shortHelp: "Open help window" }
));
addDefaultMap(new vimperator.Map(allModes, ["<Esc>", "<C-[>"],
addDefaultMap(new vimperator.Map(vimperator.modes.all, ["<Esc>", "<C-[>"],
function () { vimperator.events.onEscape() },
{ shortHelp: "Focus content" }
));
addDefaultMap(new vimperator.Map(noninsertModes, [":"],
// add the ":" mapping in all but insert mode mappings
addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL, vimperator.modes.VISUAL, vimperator.modes.HINTS, vimperator.modes.MESSAGE, vimperator.modes.CARET, vimperator.modes.TEXTAREA], [":"],
function () { vimperator.commandline.open(":", "", vimperator.modes.EX); },
{ shortHelp: "Start command line mode" }
));
@@ -402,11 +387,11 @@ vimperator.Mappings = function () //{{{
},
{ shortHelp: "Start caret mode" }
));
addDefaultMap(new vimperator.Map(allModes, ["<C-q>"],
addDefaultMap(new vimperator.Map(vimperator.modes.all, ["<C-q>"],
function () { vimperator.modes.passAllKeys = true; },
{ shortHelp: "Temporarily quit Vimperator mode" }
));
addDefaultMap(new vimperator.Map(allModes, ["<C-v>"],
addDefaultMap(new vimperator.Map(vimperator.modes.all, ["<C-v>"],
function () { vimperator.modes.passNextKey = true; },
{ shortHelp: "Pass through next key" }
));
@@ -414,7 +399,7 @@ vimperator.Mappings = function () //{{{
function() { BrowserStop(); },
{ shortHelp: "Stop loading" }
));
addDefaultMap(new vimperator.Map(allModes, ["<Nop>"],
addDefaultMap(new vimperator.Map(vimperator.modes.all, ["<Nop>"],
function () { return; },
{ shortHelp: "Do nothing" }
));

View File

@@ -179,8 +179,7 @@ vimperator.modes = (function () //{{{
__iterator__: function ()
{
var modes = [this.NONE, this.NORMAL, this.INSERT, this.VISUAL, this.HINTS,
this.COMMAND_LINE, this.CARET, this.TEXTAREA, this.MESSAGE, this.CUSTOM];
var modes = this.all;
for (var i = 0; i < modes.length; i++)
yield modes[i];
@@ -188,12 +187,11 @@ vimperator.modes = (function () //{{{
throw StopIteration;
},
// keeps recording state
reset: function (silent)
{
this.set(vimperator.modes.NORMAL, vimperator.modes.NONE, silent);
},
get all() { return [this.NONE, this.NORMAL, this.INSERT, this.VISUAL,
this.HINTS, this.COMMAND_LINE, this.CARET,
this.TEXTAREA, this.MESSAGE, this.CUSTOM]; },
// show the current mode string in the command line
show: function ()
{
if (!vimperator.options["showmode"])
@@ -207,12 +205,11 @@ vimperator.modes = (function () //{{{
vimperator.commandline.DISALLOW_MULTILINE);
},
setCustomMode: function (modestr, oneventfunc, stopfunc)
// add/remove always work on the extended mode only
add: function (mode)
{
// TODO this.plugin[id]... ('id' maybe submode or what..)
vimperator.plugins.mode = modestr;
vimperator.plugins.onEvent = oneventfunc;
vimperator.plugins.stop = stopfunc;
extended |= mode;
this.show();
},
// helper function to set both modes in one go
@@ -237,12 +234,20 @@ vimperator.modes = (function () //{{{
this.show();
},
// add/remove always work on the extended mode only
add: function (mode)
setCustomMode: function (modestr, oneventfunc, stopfunc)
{
extended |= mode;
this.show();
// TODO this.plugin[id]... ('id' maybe submode or what..)
vimperator.plugins.mode = modestr;
vimperator.plugins.onEvent = oneventfunc;
vimperator.plugins.stop = stopfunc;
},
// keeps recording state
reset: function (silent)
{
this.set(vimperator.modes.NORMAL, vimperator.modes.NONE, silent);
},
remove: function (mode)
{
extended = (extended | mode) ^ mode;