diff --git a/ChangeLog b/ChangeLog index 7fbd7282..53127bd8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@
2007-07-02:
* version 0.5
+ * Ctrl-U/Ctrl-D for scrolling the window up/down and the associated
+ 'scroll' option
* files in ~/.vimperator/plugin/ are auto-sourced
* :winopen support (multiple windows still very very experimental)
* 'activate' option implemented
diff --git a/chrome/content/vimperator/buffers.js b/chrome/content/vimperator/buffers.js
index cfd265b8..6d398ee3 100644
--- a/chrome/content/vimperator/buffers.js
+++ b/chrome/content/vimperator/buffers.js
@@ -75,6 +75,11 @@ function Buffer() //{{{
return window.content.document.location.href;
});
+ this.__defineGetter__("pageHeight", function()
+ {
+ return getBrowser().mPanelContainer.boxObject.height; // FIXME: best way to do this?
+ });
+
this.__defineGetter__("textZoom", function()
{
return zoom_manager.textZoom;
diff --git a/chrome/content/vimperator/commands.js b/chrome/content/vimperator/commands.js
index 0c856761..20754eac 100644
--- a/chrome/content/vimperator/commands.js
+++ b/chrome/content/vimperator/commands.js
@@ -892,7 +892,7 @@ function Commands() //{{{
if (oper == '-') num = cur_val - num;
// FIXME
if (option.validator != null && option.validator.call(this, num) == false)
- vimperator.echoerr("E521: Number required after =: " + option.name + "=" + val);
+ vimperator.echoerr("E474: Invalid argument: " + option.name + "=" + val); // FIXME: need to be able to specify unique parse error messages
else // all checks passed, execute option handler
option.value = num;
}
diff --git a/chrome/content/vimperator/mappings.js b/chrome/content/vimperator/mappings.js
index cc24dae4..12cc045d 100644
--- a/chrome/content/vimperator/mappings.js
+++ b/chrome/content/vimperator/mappings.js
@@ -308,7 +308,7 @@ function Mappings() //{{{
function(count) { vimperator.buffer.shiftFrameFocus(count > 1 ? count : 1, true); },
{
short_help: "Focus next frame",
- help: "Transfers keyboard focus to the [count]th next frame in order. The newly focused frame is briefly colored red.",
+ help: "Transfers keyboard focus to the [count]th next frame in order. The newly focused frame is briefly colored red.",
flags: Mappings.flags.COUNT
}
));
@@ -316,7 +316,7 @@ function Mappings() //{{{
function(count) { vimperator.buffer.shiftFrameFocus(count > 1 ? count : 1, false); },
{
short_help: "Focus previous frame",
- help: "Transfers keyboard focus to the [count]th previous frame in order. The newly focused frame is briefly colored red.",
+ help: "Transfers keyboard focus to the [count]th previous frame in order. The newly focused frame is briefly colored red.",
flags: Mappings.flags.COUNT
}
));
@@ -673,6 +673,39 @@ function Mappings() //{{{
flags: Mappings.flags.COUNT
}
));
+ function getScrollSize(count)
+ {
+ var lines;
+
+ if (count > 1)
+ vimperator.options["scroll"] = count;
+
+ if (vimperator.options["scroll"] == 0) // the default value of half a page
+ // FIXME: when updating the scroll methods in v.buffer!
+ lines = vimperator.buffer.pageHeight / (2 * 20); // NOTE: a line is currently 20 pixels rather than a true line.
+ else
+ lines = vimperator.options["scroll"];
+
+ return lines;
+ }
+ addDefaultMap(new Map(vimperator.modes.NORMAL, [""],
+ function(count) { vimperator.buffer.scrollRelative(0, getScrollSize(count)); },
+ {
+ short_help: "Scroll window downwards in the buffer",
+ help: "The number of lines is set by the 'scroll' option which defaults to half a page. " +
+ "If [count] is given 'scroll' is first set to this value.",
+ flags: Mappings.flags.COUNT
+ }
+ ));
+ addDefaultMap(new Map(vimperator.modes.NORMAL, [""],
+ function(count) { vimperator.buffer.scrollRelative(0, -getScrollSize(count)); },
+ {
+ short_help: "Scroll window upwards in the buffer",
+ help: "The number of lines is set by the 'scroll' option which defaults to half a page. " +
+ "If [count] is given 'scroll' is first set to this value.",
+ flags: Mappings.flags.COUNT
+ }
+ ));
addDefaultMap(new Map(vimperator.modes.NORMAL, ["l", ""],
function(count) { vimperator.buffer.scrollRelative(count > 1 ? count : 1, 0); },
{
@@ -682,14 +715,14 @@ function Mappings() //{{{
flags: Mappings.flags.COUNT
}
));
- addDefaultMap(new Map(vimperator.modes.NORMAL, ["", "", "", ""],
+ addDefaultMap(new Map(vimperator.modes.NORMAL, ["", "", ""],
function() { goDoCommand('cmd_scrollPageUp'); },
{
short_help: "Scroll up a full page of the current document",
help: "No count support for now."
}
));
- addDefaultMap(new Map(vimperator.modes.NORMAL, ["", "", "", ""],
+ addDefaultMap(new Map(vimperator.modes.NORMAL, ["", "", ""],
function() { goDoCommand('cmd_scrollPageDown'); },
{
short_help: "Scroll down a full page of the current document",
diff --git a/chrome/content/vimperator/options.js b/chrome/content/vimperator/options.js
index 67a3b750..eff0acf9 100644
--- a/chrome/content/vimperator/options.js
+++ b/chrome/content/vimperator/options.js
@@ -421,6 +421,14 @@ function Options() //{{{
validator: function (value) { if (value>=1 && value <=50) return true; else return false; }
}
));
+ addOption(new Option(["scroll", "scr"], "number",
+ {
+ short_help: "Number of lines to scroll with C-u and C-d commands",
+ help: "TODO",
+ default_value: 0,
+ validator: function (value) { if (value >= 0) return true; else return false; }
+ }
+ ));
addOption(new Option(["showmode", "smd"], "boolean",
{
short_help: "Show the current mode in the command line",
@@ -436,7 +444,7 @@ function Options() //{{{
"1: Show the link in the status line " +
"2: Show the link in the command line ",
default_value: 1,
- validator: function (value) { if (value>=0 && value <=2) return true; else return false; }
+ validator: function (value) { if (value >= 0 && value <= 2) return true; else return false; }
}
));
addOption(new Option(["showtabline", "stal"], "number",