summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Kearns <dougkearns@gmail.com>2009-05-06 21:33:21 +1000
committerDoug Kearns <dougkearns@gmail.com>2009-05-06 21:45:03 +1000
commit4912348398a373394f20e8f8350532555e23cf3e (patch)
treea02dee1687e494aa8149194f17c7d3e6574b11c1
parent8021953f0f4cba7b65ffe55d0a1a217a91f3b01e (diff)
downloadpentadactyl-4912348398a373394f20e8f8350532555e23cf3e.tar.gz
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.
-rw-r--r--common/content/buffer.js34
-rw-r--r--common/content/tabs.js2
-rw-r--r--muttator/content/mail.js4
-rw-r--r--vimperator/content/bookmarks.js8
-rw-r--r--vimperator/content/config.js4
-rw-r--r--xulmus/content/bookmarks.js8
-rw-r--r--xulmus/content/config.js4
7 files changed, 32 insertions, 32 deletions
diff --git a/common/content/buffer.js b/common/content/buffer.js
index b4927118..512a541a 100644
--- a/common/content/buffer.js
+++ b/common/content/buffer.js
@@ -266,22 +266,22 @@ function Buffer() //{{{
// scrolling
mappings.add(myModes, ["j", "<Down>", "<C-e>"],
"Scroll document down",
- function (count) { buffer.scrollLines(count > 1 ? count : 1); },
+ function (count) { buffer.scrollLines(Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT });
mappings.add(myModes, ["k", "<Up>", "<C-y>"],
"Scroll document up",
- function (count) { buffer.scrollLines(-(count > 1 ? count : 1)); },
+ function (count) { buffer.scrollLines(-Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT });
mappings.add(myModes, liberator.has("mail") ? ["h"] : ["h", "<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 });
mappings.add(myModes, liberator.has("mail") ? ["l"] : ["l", "<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 });
mappings.add(myModes, ["0", "^"],
@@ -294,7 +294,7 @@ function Buffer() //{{{
mappings.add(myModes, ["gg", "<Home>"],
"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 });
mappings.add(myModes, ["G", "<End>"],
@@ -325,22 +325,22 @@ function Buffer() //{{{
mappings.add(myModes, ["<C-b>", "<PageUp>", "<S-Space>"],
"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 });
mappings.add(myModes, ["<C-f>", "<PageDown>", "<Space>"],
"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 });
mappings.add(myModes, ["]f"],
"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 });
mappings.add(myModes, ["[f"],
"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 });
mappings.add(myModes, ["]]"],
@@ -453,22 +453,22 @@ function Buffer() //{{{
// zooming
mappings.add(myModes, ["zi", "+"],
"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 });
mappings.add(myModes, ["zm"],
"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 });
mappings.add(myModes, ["zo", "-"],
"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 });
mappings.add(myModes, ["zr"],
"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 });
mappings.add(myModes, ["zz"],
@@ -478,22 +478,22 @@ function Buffer() //{{{
mappings.add(myModes, ["zI"],
"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 });
mappings.add(myModes, ["zM"],
"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 });
mappings.add(myModes, ["zO"],
"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 });
mappings.add(myModes, ["zR"],
"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 });
mappings.add(myModes, ["zZ"],
diff --git a/common/content/tabs.js b/common/content/tabs.js
index a1158fd5..ec0f6471 100644
--- a/common/content/tabs.js
+++ b/common/content/tabs.js
@@ -334,7 +334,7 @@ function Tabs() //{{{
liberator.echoerr("E94: No matching tab for " + arg);
}
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: "?",
diff --git a/muttator/content/mail.js b/muttator/content/mail.js
index 576498b5..7f93316b 100644
--- a/muttator/content/mail.js
+++ b/muttator/content/mail.js
@@ -374,12 +374,12 @@ function Mail() //{{{
// SCROLLING
mappings.add(myModes, ["<Down>"],
"Scroll message down",
- function (count) { buffer.scrollLines(count > 1 ? count : 1); },
+ function (count) { buffer.scrollLines(Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT });
mappings.add(myModes, ["<Up>"],
"Scroll message up",
- function (count) { buffer.scrollLines(-(count > 1 ? count : 1)); },
+ function (count) { buffer.scrollLines(-Math.max(count, 1)); },
{ flags: Mappings.flags.COUNT });
mappings.add([modes.MESSAGE], ["<Left>"],
diff --git a/vimperator/content/bookmarks.js b/vimperator/content/bookmarks.js
index 1d362a20..cec44ff3 100644
--- a/vimperator/content/bookmarks.js
+++ b/vimperator/content/bookmarks.js
@@ -663,22 +663,22 @@ function History() //{{{
mappings.add(myModes,
["<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 });
mappings.add(myModes,
["<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 });
mappings.add(myModes,
["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 });
mappings.add(myModes,
["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 });
/////////////////////////////////////////////////////////////////////////////}}}
diff --git a/vimperator/content/config.js b/vimperator/content/config.js
index ea4f5df7..64165c86 100644
--- a/vimperator/content/config.js
+++ b/vimperator/content/config.js
@@ -226,12 +226,12 @@ const config = { //{{{
mappings.add([modes.NORMAL],
["<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 });
mappings.add([modes.NORMAL],
["<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 });
mappings.add([modes.NORMAL], ["~"],
diff --git a/xulmus/content/bookmarks.js b/xulmus/content/bookmarks.js
index c7beb02a..184457e6 100644
--- a/xulmus/content/bookmarks.js
+++ b/xulmus/content/bookmarks.js
@@ -732,22 +732,22 @@ function History() //{{{
mappings.add(myModes,
["<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 });
mappings.add(myModes,
["<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 });
mappings.add(myModes,
["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 });
mappings.add(myModes,
["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 });
/////////////////////////////////////////////////////////////////////////////}}}
diff --git a/xulmus/content/config.js b/xulmus/content/config.js
index 19e0c330..64a9b04c 100644
--- a/xulmus/content/config.js
+++ b/xulmus/content/config.js
@@ -325,12 +325,12 @@ const config = { //{{{
mappings.add([modes.NORMAL],
["<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 });
mappings.add([modes.NORMAL],
["<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 });
mappings.add([modes.NORMAL], ["~"],