mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 22:07:59 +01:00
add C-u/C-d mappings and the associated 'scroll' option
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
<pre>
|
<pre>
|
||||||
2007-07-02:
|
2007-07-02:
|
||||||
* version 0.5
|
* 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
|
* files in ~/.vimperator/plugin/ are auto-sourced
|
||||||
* :winopen support (multiple windows still very very experimental)
|
* :winopen support (multiple windows still very very experimental)
|
||||||
* 'activate' option implemented
|
* 'activate' option implemented
|
||||||
|
|||||||
@@ -75,6 +75,11 @@ function Buffer() //{{{
|
|||||||
return window.content.document.location.href;
|
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()
|
this.__defineGetter__("textZoom", function()
|
||||||
{
|
{
|
||||||
return zoom_manager.textZoom;
|
return zoom_manager.textZoom;
|
||||||
|
|||||||
@@ -892,7 +892,7 @@ function Commands() //{{{
|
|||||||
if (oper == '-') num = cur_val - num;
|
if (oper == '-') num = cur_val - num;
|
||||||
// FIXME
|
// FIXME
|
||||||
if (option.validator != null && option.validator.call(this, num) == false)
|
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
|
else // all checks passed, execute option handler
|
||||||
option.value = num;
|
option.value = num;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ function Mappings() //{{{
|
|||||||
function(count) { vimperator.buffer.shiftFrameFocus(count > 1 ? count : 1, true); },
|
function(count) { vimperator.buffer.shiftFrameFocus(count > 1 ? count : 1, true); },
|
||||||
{
|
{
|
||||||
short_help: "Focus next frame",
|
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 <code class=\"argument\">[count]</code>th next frame in order. The newly focused frame is briefly colored red.",
|
||||||
flags: Mappings.flags.COUNT
|
flags: Mappings.flags.COUNT
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
@@ -316,7 +316,7 @@ function Mappings() //{{{
|
|||||||
function(count) { vimperator.buffer.shiftFrameFocus(count > 1 ? count : 1, false); },
|
function(count) { vimperator.buffer.shiftFrameFocus(count > 1 ? count : 1, false); },
|
||||||
{
|
{
|
||||||
short_help: "Focus previous frame",
|
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 <code class=\"argument\">[count]</code>th previous frame in order. The newly focused frame is briefly colored red.",
|
||||||
flags: Mappings.flags.COUNT
|
flags: Mappings.flags.COUNT
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
@@ -673,6 +673,39 @@ function Mappings() //{{{
|
|||||||
flags: Mappings.flags.COUNT
|
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, ["<C-d>"],
|
||||||
|
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 <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
|
||||||
|
}
|
||||||
|
));
|
||||||
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["<C-u>"],
|
||||||
|
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 <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
|
||||||
|
}
|
||||||
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["l", "<Right>"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["l", "<Right>"],
|
||||||
function(count) { vimperator.buffer.scrollRelative(count > 1 ? count : 1, 0); },
|
function(count) { vimperator.buffer.scrollRelative(count > 1 ? count : 1, 0); },
|
||||||
{
|
{
|
||||||
@@ -682,14 +715,14 @@ function Mappings() //{{{
|
|||||||
flags: Mappings.flags.COUNT
|
flags: Mappings.flags.COUNT
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["<C-b>", "<C-u>", "<PageUp>", "<S-Space>"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["<C-b>", "<PageUp>", "<S-Space>"],
|
||||||
function() { goDoCommand('cmd_scrollPageUp'); },
|
function() { goDoCommand('cmd_scrollPageUp'); },
|
||||||
{
|
{
|
||||||
short_help: "Scroll up a full page of the current document",
|
short_help: "Scroll up a full page of the current document",
|
||||||
help: "No count support for now."
|
help: "No count support for now."
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultMap(new Map(vimperator.modes.NORMAL, ["<C-f>", "<C-d>", "<PageDown>", "<Space>"],
|
addDefaultMap(new Map(vimperator.modes.NORMAL, ["<C-f>", "<PageDown>", "<Space>"],
|
||||||
function() { goDoCommand('cmd_scrollPageDown'); },
|
function() { goDoCommand('cmd_scrollPageDown'); },
|
||||||
{
|
{
|
||||||
short_help: "Scroll down a full page of the current document",
|
short_help: "Scroll down a full page of the current document",
|
||||||
|
|||||||
@@ -421,6 +421,14 @@ function Options() //{{{
|
|||||||
validator: function (value) { if (value>=1 && value <=50) return true; else return false; }
|
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 <code class=\"mapping\">C-u</code> and <code class=\"mapping\">C-d</code> commands",
|
||||||
|
help: "TODO",
|
||||||
|
default_value: 0,
|
||||||
|
validator: function (value) { if (value >= 0) return true; else return false; }
|
||||||
|
}
|
||||||
|
));
|
||||||
addOption(new Option(["showmode", "smd"], "boolean",
|
addOption(new Option(["showmode", "smd"], "boolean",
|
||||||
{
|
{
|
||||||
short_help: "Show the current mode in the command line",
|
short_help: "Show the current mode in the command line",
|
||||||
@@ -436,7 +444,7 @@ function Options() //{{{
|
|||||||
"<li><b>1</b>: Show the link in the status line</li>" +
|
"<li><b>1</b>: Show the link in the status line</li>" +
|
||||||
"<li><b>2</b>: Show the link in the command line</li></ul>",
|
"<li><b>2</b>: Show the link in the command line</li></ul>",
|
||||||
default_value: 1,
|
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",
|
addOption(new Option(["showtabline", "stal"], "number",
|
||||||
|
|||||||
Reference in New Issue
Block a user