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

move Mappings() to the vimperator namespace

This commit is contained in:
Doug Kearns
2007-10-22 06:38:07 +00:00
parent 160035e9ee
commit af360fbc77
3 changed files with 56 additions and 56 deletions

View File

@@ -625,7 +625,7 @@ vimperator.Events = function() //{{{
vimperator.input.count = parseInt(count_str, 10);
if (isNaN(vimperator.input.count))
vimperator.input.count = -1;
if (map.flags & Mappings.flags.ARGUMENT)
if (map.flags & vimperator.Mappings.flags.ARGUMENT)
{
vimperator.input.pendingArgMap = map;
vimperator.input.buffer += key;
@@ -640,7 +640,7 @@ vimperator.Events = function() //{{{
vimperator.input.buffer = "";
}
// no count support for these commands yet
else if (map.flags & Mappings.flags.MOTION)
else if (map.flags & vimperator.Mappings.flags.MOTION)
{
vimperator.input.pendingMotionMap = map;
vimperator.input.buffer = "";

View File

@@ -46,9 +46,9 @@ vimperator.Map = function(mode, cmds, action, extra_info) //{{{
else
{
this.usage = this.names[0]; // only the first command name
if (this.flags & Mappings.flags.COUNT)
if (this.flags & vimperator.Mappings.flags.COUNT)
this.usage = "[count]" + this.usage;
if (this.flags & Mappings.flags.ARGUMENT)
if (this.flags & vimperator.Mappings.flags.ARGUMENT)
this.usage += " {arg}";
this.usage = [this.usage]; // FIXME: usage an array - needed for the help
}
@@ -81,17 +81,17 @@ vimperator.Map.prototype.hasName = function(name)
vimperator.Map.prototype.execute = function(motion, count, argument)
{
var args = [];
if (this.flags & Mappings.flags.MOTION)
if (this.flags & vimperator.Mappings.flags.MOTION)
args.push(motion);
if (this.flags & Mappings.flags.COUNT)
if (this.flags & vimperator.Mappings.flags.COUNT)
args.push(count);
if (this.flags & Mappings.flags.ARGUMENT)
if (this.flags & vimperator.Mappings.flags.ARGUMENT)
args.push(argument);
this.action.apply(this, args);
}
//}}}
function Mappings() //{{{
vimperator.Mappings = function() //{{{
{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -173,7 +173,7 @@ function Mappings() //{{{
////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
Mappings.flags = {
vimperator.Mappings.flags = {
MOTION: 1 << 0,
COUNT: 1 << 1,
ARGUMENT: 1 << 2
@@ -363,7 +363,7 @@ function Mappings() //{{{
{
short_help: "Focus next frame",
help: "Transfers keyboard focus to the <code class=\"argument\">[count]</code>th next frame in order. The newly focused frame is briefly colored red. Does not wrap.",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["[f"],
@@ -371,7 +371,7 @@ function Mappings() //{{{
{
short_help: "Focus previous frame",
help: "Transfers keyboard focus to the <code class=\"argument\">[count]</code>th previous frame in order. The newly focused frame is briefly colored red. Does not wrap.",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["b"],
@@ -394,7 +394,7 @@ function Mappings() //{{{
{
short_help: "Repeat last :buffer[!] command",
help: "This is useful to quickly jump between buffers which have a similar URL or title.",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["gB"],
@@ -402,7 +402,7 @@ function Mappings() //{{{
{
short_help: "Repeat last :buffer[!] command in reverse direction",
help: "Just like <code class=\"mapping\">gb</code> but in the other direction.",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["d"],
@@ -411,7 +411,7 @@ function Mappings() //{{{
short_help: "Delete current buffer (=tab)",
help: "Count is supported, <code class=\"mapping\">2d</code> removes the current and next tab and the one to the right is selected. " +
"Does not wrap if <code class=\"argument\">[count]</code> is larger than available tabs to the right.",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["D"],
@@ -420,7 +420,7 @@ function Mappings() //{{{
short_help: "Delete current buffer (=tab)",
help: "Count is supported, <code class=\"mapping\">2D</code> removes the current and previous tab and the one to the left is selected. " +
"Does not wrap if <code class=\"argument\">[count]</code> is larger than available tabs to the left.",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["gh"],
@@ -450,7 +450,7 @@ function Mappings() //{{{
usage: ["go{a-zA-Z0-9}"],
help: "Open any QuickMark in the current tab. You can mark any URLs with <code class=\"mapping\">M{a-zA-Z0-9}</code>. " +
"These QuickMarks are persistent across browser sessions.",
flags: Mappings.flags.ARGUMENT
flags: vimperator.Mappings.flags.ARGUMENT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["gn"],
@@ -466,7 +466,7 @@ function Mappings() //{{{
help: "Works like <code class=\"mapping\">go{a-zA-Z0-9}</code> but opens the QuickMark in a new tab. " +
"Whether the new tab is activated or not depends on the <code class=\"option\">'activate'</code> option.<br/>" +
"Mnemonic: Go in a new tab. <code class=\"mapping\">gt</code> would make more sense but is already taken.",
flags: Mappings.flags.ARGUMENT
flags: vimperator.Mappings.flags.ARGUMENT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["gP"],
@@ -486,7 +486,7 @@ function Mappings() //{{{
{
short_help: "Go to the next tab",
help: "Cycles to the first tab, when the last is selected.<br/>Count is supported: <code class=\"mapping\">3gt</code> goes to the third tab.",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["gT", "<C-p>", "<C-S-Tab>"],
@@ -494,7 +494,7 @@ function Mappings() //{{{
{
short_help: "Go to the previous tab",
help: "Cycles to the last tab, when the first is selected.<br/>Count is supported: <code class=\"mapping\">3gT</code> goes to the third tab.",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ['<C-^>', '<C-6>'],
@@ -539,7 +539,7 @@ function Mappings() //{{{
short_help: "Set mark at the cursor position",
usage: ["m{a-zA-Z}"],
help: "Marks a-z are local to the buffer, whereas A-Z are valid between buffers.",
flags: Mappings.flags.ARGUMENT
flags: vimperator.Mappings.flags.ARGUMENT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["'", "`"],
@@ -548,7 +548,7 @@ function Mappings() //{{{
short_help: "Jump to the mark in the current buffer",
usage: ["'{a-zA-Z}"],
help: "Marks a-z are local to the buffer, whereas A-Z are valid between buffers.",
flags: Mappings.flags.ARGUMENT
flags: vimperator.Mappings.flags.ARGUMENT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["M"],
@@ -567,7 +567,7 @@ function Mappings() //{{{
usage: ["M{a-zA-Z0-9}"],
help: "You can go to a marked URL in the current tab with <code class=\"mapping\">go{a-zA-Z0-9}</code> or in a new tab with <code class=\"mapping\">gn{a-zA-Z0-9}</code>. " +
"These QuickMarks are persistent across browser sessions.",
flags: Mappings.flags.ARGUMENT
flags: vimperator.Mappings.flags.ARGUMENT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["o"],
@@ -638,7 +638,7 @@ function Mappings() //{{{
{
short_help: "Undo closing of a tab",
help: "If a count is given, don't close the last but the <code class=\"argument\">[count]</code>th last tab.",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["y"],
@@ -668,28 +668,28 @@ function Mappings() //{{{
function(count) { vimperator.buffer.zoomIn(count > 1 ? count : 1); },
{
short_help: "Zoom in current web page by 25%",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["zI"],
function(count) { vimperator.buffer.zoomIn((count > 1 ? count : 1) * 4); },
{
short_help: "Zoom in current web page by 100%",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["zo", "-"],
function(count) { vimperator.buffer.zoomOut(count > 1 ? count : 1); },
{
short_help: "Zoom out current web page by 25%",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["zO"],
function(count) { vimperator.buffer.zoomOut((count > 1 ? count : 1) * 4); },
{
short_help: "Zoom out current web page by 100%",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["zz"],
@@ -697,7 +697,7 @@ function Mappings() //{{{
{
short_help: "Set zoom value of the web page",
help: "Zoom value can be between 1 and 2000%. If it is omitted, zoom is reset to 100%.",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["ZQ"],
@@ -735,7 +735,7 @@ function Mappings() //{{{
{
short_help: "Goto the top of the document",
help: "When used with <code class=\"argument\">[count]</code> like in <code class=\"mapping\">35gg</code>, it scrolls to 35% of the document.",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["G", "<End>"],
@@ -743,7 +743,7 @@ function Mappings() //{{{
{
short_help: "Goto the end of the document",
help: "When used with <code class=\"argument\">[count]</code> like in <code class=\"mapping\">35G</code>, it scrolls to 35% of the document.",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["h", "<Left>"],
@@ -752,7 +752,7 @@ function Mappings() //{{{
short_help: "Scroll document to the left",
help: "Count is supported: <code class=\"mapping\">10h</code> will move 10 times as much to the left.<br/>" +
"If the document cannot scroll more, a beep is emitted (unless <code class=\"option\">'beep'</code> is turned off).",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["j", "<Down>", "<C-e>"],
@@ -761,7 +761,7 @@ function Mappings() //{{{
short_help: "Scroll document down",
help: "Count is supported: <code class=\"mapping\">10j</code> will move 10 times as much down.<br/>" +
"If the document cannot scroll more, a beep is emitted (unless <code class=\"option\">'beep'</code> is turned off).",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["k", "<Up>", "<C-y>"],
@@ -770,7 +770,7 @@ function Mappings() //{{{
short_help: "Scroll document up",
help: "Count is supported: <code class=\"mapping\">10k</code> will move 10 times as much up.<br/>" +
"If the document cannot scroll more, a beep is emitted (unless <code class=\"option\">'beep'</code> is turned off).",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
function scrollByScrollSize(count, direction)
@@ -795,7 +795,7 @@ function Mappings() //{{{
short_help: "Scroll window downwards in the buffer",
help: "The number of lines is set by the <code class=\"option\">'scroll'</code> option which defaults to half a page. " +
"If <code class=\"argument\">[count]</code> is given <code class=\"option\">'scroll'</code> is first set to this value.",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["<C-u>"],
@@ -804,7 +804,7 @@ function Mappings() //{{{
short_help: "Scroll window upwards in the buffer",
help: "The number of lines is set by the <code class=\"option\">'scroll'</code> option which defaults to half a page. " +
"If <code class=\"argument\">[count]</code> is given <code class=\"option\">'scroll'</code> is first set to this value.",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["l", "<Right>"],
@@ -813,7 +813,7 @@ function Mappings() //{{{
short_help: "Scroll document to the right",
help: "Count is supported: <code class=\"mapping\">10l</code> will move 10 times as much to the right.<br/>" +
"If the document cannot scroll more, a beep is emitted (unless <code class=\"option\">'beep'</code> is turned off).",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["<C-b>", "<PageUp>", "<S-Space>"],
@@ -821,7 +821,7 @@ function Mappings() //{{{
{
short_help: "Scroll up a full page",
help: "Scroll window <code class=\"argument\">[count]</code> pages Backwards (upwards) in the buffer.",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["<C-f>", "<PageDown>", "<Space>"],
@@ -829,7 +829,7 @@ function Mappings() //{{{
{
short_help: "Scroll down a full page",
help: "Scroll window <code class=\"argument\">[count]</code> pages Forwards (downwards) in the buffer.",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
@@ -839,7 +839,7 @@ function Mappings() //{{{
{
short_help: "Go to an older position in the jump list",
help: "The jump list is just the browser history for now.",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["<C-i>"],
@@ -847,7 +847,7 @@ function Mappings() //{{{
{
short_help: "Go to a newer position in the jump list",
help: "The jump list is just the browser history for now.",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["H", "<A-Left>", "<M-Left>"],
@@ -855,7 +855,7 @@ function Mappings() //{{{
{
short_help: "Go back in the browser history",
help: "Count is supported: <code class=\"mapping\">3H</code> goes back 3 steps.",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["L", "<A-Right>", "<M-Right>"],
@@ -863,7 +863,7 @@ function Mappings() //{{{
{
short_help: "Go forward in the browser history",
help: "Count is supported: <code class=\"mapping\">3L</code> goes forward 3 steps.",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
function isDirectory(url)
@@ -903,7 +903,7 @@ function Mappings() //{{{
{
short_help: "Go to parent directory",
help: "Count is supported: <code class=\"mapping\">2gu</code> on <code>http://www.example.com/dir1/dir2/file.htm</code> would open <code>http://www.example.com/dir1/</code>.",
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.NORMAL, ["gU", "<C-BS>"],
@@ -1076,7 +1076,7 @@ function Mappings() //{{{
{
cancel_mode: false,
always_active: true,
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, ["<C-y>"],
@@ -1084,7 +1084,7 @@ function Mappings() //{{{
{
cancel_mode: false,
always_active: true,
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, ["<Home>"],
@@ -1106,7 +1106,7 @@ function Mappings() //{{{
{
cancel_mode: false,
always_active: true,
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, ["<PageDown>", "<C-f>"],
@@ -1114,7 +1114,7 @@ function Mappings() //{{{
{
cancel_mode: false,
always_active: true,
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, ["<Left>"],
@@ -1122,7 +1122,7 @@ function Mappings() //{{{
{
cancel_mode: false,
always_active: true,
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, ["<Down>"],
@@ -1130,7 +1130,7 @@ function Mappings() //{{{
{
cancel_mode: false,
always_active: true,
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, ["<Up>"],
@@ -1138,7 +1138,7 @@ function Mappings() //{{{
{
cancel_mode: false,
always_active: true,
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, ["<Right>"],
@@ -1146,7 +1146,7 @@ function Mappings() //{{{
{
cancel_mode: false,
always_active: true,
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
@@ -1172,7 +1172,7 @@ function Mappings() //{{{
{
cancel_mode: false,
always_active: true,
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, ["<C-i>"],
@@ -1180,7 +1180,7 @@ function Mappings() //{{{
{
cancel_mode: false,
always_active: true,
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, ["<C-h>"],
@@ -1188,7 +1188,7 @@ function Mappings() //{{{
{
cancel_mode: false,
always_active: true,
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, ["<C-l>"],
@@ -1196,7 +1196,7 @@ function Mappings() //{{{
{
cancel_mode: false,
always_active: true,
flags: Mappings.flags.COUNT
flags: vimperator.Mappings.flags.COUNT
}
));
addDefaultMap(new vimperator.Map(vimperator.modes.HINTS, ["<C-d>"],

View File

@@ -702,7 +702,7 @@ const vimperator = (function() //{{{
vimperator.log("Loading module buffer window...", 3);
vimperator.bufferwindow = new vimperator.InformationList("vimperator-bufferwindow", { incremental_fill: false, max_items: 10 });
vimperator.log("Loading module mappings...", 3);
vimperator.mappings = new Mappings();
vimperator.mappings = new vimperator.Mappings();
vimperator.log("Loading module statusline...", 3);
vimperator.statusline = new vimperator.StatusLine();
vimperator.log("Loading module buffer...", 3);