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

Normalise the count arg of map actions with Math.max.

Passing an arg object to these actions as is done for commands might be
better.
This commit is contained in:
Doug Kearns
2009-05-06 21:33:21 +10:00
parent 8021953f0f
commit 4912348398
7 changed files with 32 additions and 32 deletions

View File

@@ -266,22 +266,22 @@ function Buffer() //{{{
// scrolling // scrolling
mappings.add(myModes, ["j", "<Down>", "<C-e>"], mappings.add(myModes, ["j", "<Down>", "<C-e>"],
"Scroll document down", "Scroll document down",
function (count) { buffer.scrollLines(count > 1 ? count : 1); }, function (count) { buffer.scrollLines(Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, ["k", "<Up>", "<C-y>"], mappings.add(myModes, ["k", "<Up>", "<C-y>"],
"Scroll document up", "Scroll document up",
function (count) { buffer.scrollLines(-(count > 1 ? count : 1)); }, function (count) { buffer.scrollLines(-Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, liberator.has("mail") ? ["h"] : ["h", "<Left>"], mappings.add(myModes, liberator.has("mail") ? ["h"] : ["h", "<Left>"],
"Scroll document to the left", "Scroll document to the left",
function (count) { buffer.scrollColumns(-(count > 1 ? count : 1)); }, function (count) { buffer.scrollColumns(-Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, liberator.has("mail") ? ["l"] : ["l", "<Right>"], mappings.add(myModes, liberator.has("mail") ? ["l"] : ["l", "<Right>"],
"Scroll document to the right", "Scroll document to the right",
function (count) { buffer.scrollColumns(count > 1 ? count : 1); }, function (count) { buffer.scrollColumns(Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, ["0", "^"], mappings.add(myModes, ["0", "^"],
@@ -294,7 +294,7 @@ function Buffer() //{{{
mappings.add(myModes, ["gg", "<Home>"], mappings.add(myModes, ["gg", "<Home>"],
"Go to the top of the document", "Go to the top of the document",
function (count) { buffer.scrollToPercentile(count > 0 ? count : 0); }, function (count) { buffer.scrollToPercentile(Math.max(count, 0)); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, ["G", "<End>"], mappings.add(myModes, ["G", "<End>"],
@@ -325,22 +325,22 @@ function Buffer() //{{{
mappings.add(myModes, ["<C-b>", "<PageUp>", "<S-Space>"], mappings.add(myModes, ["<C-b>", "<PageUp>", "<S-Space>"],
"Scroll up a full page", "Scroll up a full page",
function (count) { buffer.scrollPages(-(count > 1 ? count : 1)); }, function (count) { buffer.scrollPages(-Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, ["<C-f>", "<PageDown>", "<Space>"], mappings.add(myModes, ["<C-f>", "<PageDown>", "<Space>"],
"Scroll down a full page", "Scroll down a full page",
function (count) { buffer.scrollPages(count > 1 ? count : 1); }, function (count) { buffer.scrollPages(Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, ["]f"], mappings.add(myModes, ["]f"],
"Focus next frame", "Focus next frame",
function (count) { buffer.shiftFrameFocus(count > 1 ? count : 1, true); }, function (count) { buffer.shiftFrameFocus(Math.max(count, 1), true); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, ["[f"], mappings.add(myModes, ["[f"],
"Focus previous frame", "Focus previous frame",
function (count) { buffer.shiftFrameFocus(count > 1 ? count : 1, false); }, function (count) { buffer.shiftFrameFocus(Math.max(count, 1), false); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, ["]]"], mappings.add(myModes, ["]]"],
@@ -453,22 +453,22 @@ function Buffer() //{{{
// zooming // zooming
mappings.add(myModes, ["zi", "+"], mappings.add(myModes, ["zi", "+"],
"Enlarge text zoom of current web page", "Enlarge text zoom of current web page",
function (count) { buffer.zoomIn(count > 1 ? count : 1, false); }, function (count) { buffer.zoomIn(Math.max(count, 1), false); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, ["zm"], mappings.add(myModes, ["zm"],
"Enlarge text zoom of current web page by a larger amount", "Enlarge text zoom of current web page by a larger amount",
function (count) { buffer.zoomIn((count > 1 ? count : 1) * 3, false); }, function (count) { buffer.zoomIn(Math.max(count, 1) * 3, false); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, ["zo", "-"], mappings.add(myModes, ["zo", "-"],
"Reduce text zoom of current web page", "Reduce text zoom of current web page",
function (count) { buffer.zoomOut(count > 1 ? count : 1, false); }, function (count) { buffer.zoomOut(Math.max(count, 1), false); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, ["zr"], mappings.add(myModes, ["zr"],
"Reduce text zoom of current web page by a larger amount", "Reduce text zoom of current web page by a larger amount",
function (count) { buffer.zoomOut((count > 1 ? count : 1) * 3, false); }, function (count) { buffer.zoomOut(Math.max(count, 1) * 3, false); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, ["zz"], mappings.add(myModes, ["zz"],
@@ -478,22 +478,22 @@ function Buffer() //{{{
mappings.add(myModes, ["zI"], mappings.add(myModes, ["zI"],
"Enlarge full zoom of current web page", "Enlarge full zoom of current web page",
function (count) { buffer.zoomIn(count > 1 ? count : 1, true); }, function (count) { buffer.zoomIn(Math.max(count, 1), true); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, ["zM"], mappings.add(myModes, ["zM"],
"Enlarge full zoom of current web page by a larger amount", "Enlarge full zoom of current web page by a larger amount",
function (count) { buffer.zoomIn((count > 1 ? count : 1) * 3, true); }, function (count) { buffer.zoomIn(Math.max(count, 1) * 3, true); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, ["zO"], mappings.add(myModes, ["zO"],
"Reduce full zoom of current web page", "Reduce full zoom of current web page",
function (count) { buffer.zoomOut(count > 1 ? count : 1, true); }, function (count) { buffer.zoomOut(Math.max(count, 1), true); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, ["zR"], mappings.add(myModes, ["zR"],
"Reduce full zoom of current web page by a larger amount", "Reduce full zoom of current web page by a larger amount",
function (count) { buffer.zoomOut((count > 1 ? count : 1) * 3, true); }, function (count) { buffer.zoomOut(Math.max(count, 1) * 3, true); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, ["zZ"], mappings.add(myModes, ["zZ"],

View File

@@ -334,7 +334,7 @@ function Tabs() //{{{
liberator.echoerr("E94: No matching tab for " + arg); liberator.echoerr("E94: No matching tab for " + arg);
} }
else // just remove the current tab else // just remove the current tab
tabs.remove(tabs.getTab(), count > 0 ? count : 1, special, 0); tabs.remove(tabs.getTab(), Math.max(count, 1), special, 0);
}, },
{ {
argCount: "?", argCount: "?",

View File

@@ -374,12 +374,12 @@ function Mail() //{{{
// SCROLLING // SCROLLING
mappings.add(myModes, ["<Down>"], mappings.add(myModes, ["<Down>"],
"Scroll message down", "Scroll message down",
function (count) { buffer.scrollLines(count > 1 ? count : 1); }, function (count) { buffer.scrollLines(Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, ["<Up>"], mappings.add(myModes, ["<Up>"],
"Scroll message up", "Scroll message up",
function (count) { buffer.scrollLines(-(count > 1 ? count : 1)); }, function (count) { buffer.scrollLines(-Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add([modes.MESSAGE], ["<Left>"], mappings.add([modes.MESSAGE], ["<Left>"],

View File

@@ -663,22 +663,22 @@ function History() //{{{
mappings.add(myModes, mappings.add(myModes,
["<C-o>"], "Go to an older position in the jump list", ["<C-o>"], "Go to an older position in the jump list",
function (count) { history.stepTo(-(count > 1 ? count : 1)); }, function (count) { history.stepTo(-Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, mappings.add(myModes,
["<C-i>"], "Go to a newer position in the jump list", ["<C-i>"], "Go to a newer position in the jump list",
function (count) { history.stepTo(count > 1 ? count : 1); }, function (count) { history.stepTo(Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, mappings.add(myModes,
["H", "<A-Left>", "<M-Left>"], "Go back in the browser history", ["H", "<A-Left>", "<M-Left>"], "Go back in the browser history",
function (count) { history.stepTo(-(count > 1 ? count : 1)); }, function (count) { history.stepTo(-Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, mappings.add(myModes,
["L", "<A-Right>", "<M-Right>"], "Go forward in the browser history", ["L", "<A-Right>", "<M-Right>"], "Go forward in the browser history",
function (count) { history.stepTo(count > 1 ? count : 1); }, function (count) { history.stepTo(Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}

View File

@@ -226,12 +226,12 @@ const config = { //{{{
mappings.add([modes.NORMAL], mappings.add([modes.NORMAL],
["<C-a>"], "Increment last number in URL", ["<C-a>"], "Increment last number in URL",
function (count) { incrementURL(count > 1 ? count : 1); }, function (count) { incrementURL(Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add([modes.NORMAL], mappings.add([modes.NORMAL],
["<C-x>"], "Decrement last number in URL", ["<C-x>"], "Decrement last number in URL",
function (count) { incrementURL(-(count > 1 ? count : 1)); }, function (count) { incrementURL(-Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add([modes.NORMAL], ["~"], mappings.add([modes.NORMAL], ["~"],

View File

@@ -732,22 +732,22 @@ function History() //{{{
mappings.add(myModes, mappings.add(myModes,
["<C-o>"], "Go to an older position in the jump list", ["<C-o>"], "Go to an older position in the jump list",
function (count) { history.stepTo(-(count > 1 ? count : 1)); }, function (count) { history.stepTo(-Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, mappings.add(myModes,
["<C-i>"], "Go to a newer position in the jump list", ["<C-i>"], "Go to a newer position in the jump list",
function (count) { history.stepTo(count > 1 ? count : 1); }, function (count) { history.stepTo(Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, mappings.add(myModes,
["H", "<A-Left>", "<M-Left>"], "Go back in the browser history", ["H", "<A-Left>", "<M-Left>"], "Go back in the browser history",
function (count) { history.stepTo(-(count > 1 ? count : 1)); }, function (count) { history.stepTo(-Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add(myModes, mappings.add(myModes,
["L", "<A-Right>", "<M-Right>"], "Go forward in the browser history", ["L", "<A-Right>", "<M-Right>"], "Go forward in the browser history",
function (count) { history.stepTo(count > 1 ? count : 1); }, function (count) { history.stepTo(Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}

View File

@@ -325,12 +325,12 @@ const config = { //{{{
mappings.add([modes.NORMAL], mappings.add([modes.NORMAL],
["<C-a>"], "Increment last number in URL", ["<C-a>"], "Increment last number in URL",
function (count) { incrementURL(count > 1 ? count : 1); }, function (count) { incrementURL(Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add([modes.NORMAL], mappings.add([modes.NORMAL],
["<C-x>"], "Decrement last number in URL", ["<C-x>"], "Decrement last number in URL",
function (count) { incrementURL(-(count > 1 ? count : 1)); }, function (count) { incrementURL(-Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
mappings.add([modes.NORMAL], ["~"], mappings.add([modes.NORMAL], ["~"],