support page down/up navigation
This commit is contained in:
parent
a1dd52ebc8
commit
03d5b56989
2 changed files with 42 additions and 0 deletions
30
Editor.js
30
Editor.js
|
|
@ -3,6 +3,8 @@ var keys = {
|
|||
RIGHT: 39,
|
||||
DOWN: 40,
|
||||
LEFT: 37,
|
||||
PAGEUP: 33,
|
||||
PAGEDOWN: 34,
|
||||
POS1: 36,
|
||||
END: 35,
|
||||
DELETE: 46,
|
||||
|
|
@ -67,6 +69,14 @@ function KeyBinding(element, host)
|
|||
}
|
||||
return lib.stopEvent(e);
|
||||
|
||||
case keys.PAGEDOWN:
|
||||
host.scrollPageDown();
|
||||
return lib.stopEvent(e);
|
||||
|
||||
case keys.PAGEUP:
|
||||
host.scrollPageUp();
|
||||
return lib.stopEvent(e);
|
||||
|
||||
case keys.POS1:
|
||||
if (e.shiftKey) {
|
||||
host.selectLineStart();
|
||||
|
|
@ -350,6 +360,26 @@ function Editor(doc, renderer)
|
|||
this.removeLeft();
|
||||
},
|
||||
|
||||
getPageDownRow : function() {
|
||||
return this.renderer.getLastVisibleRow() - 1;
|
||||
},
|
||||
|
||||
getPageUpRow : function()
|
||||
{
|
||||
var firstRow = this.renderer.getFirstVisibleRow();
|
||||
var lastRow = this.renderer.getLastVisibleRow();
|
||||
|
||||
return firstRow - (lastRow-firstRow) + 1;
|
||||
},
|
||||
|
||||
scrollPageDown : function() {
|
||||
this.renderer.scrollToRow(this.getPageDownRow());
|
||||
},
|
||||
|
||||
scrollPageUp : function() {
|
||||
this.renderer.scrollToRow(this.getPageUpRow());
|
||||
},
|
||||
|
||||
navigateUp : function()
|
||||
{
|
||||
this.clearSelection();
|
||||
|
|
|
|||
|
|
@ -46,6 +46,14 @@ VirtualRenderer.prototype.getContainerElement = function() {
|
|||
return this.container;
|
||||
};
|
||||
|
||||
VirtualRenderer.prototype.getFirstVisibleRow = function() {
|
||||
return this.layerConfig.firstRow || 0;
|
||||
};
|
||||
|
||||
VirtualRenderer.prototype.getLastVisibleRow = function() {
|
||||
return this.layerConfig.lastRow || 0;
|
||||
};
|
||||
|
||||
VirtualRenderer.prototype.updateLines = function(firstRow, lastRow)
|
||||
{
|
||||
var layerConfig = this.layerConfig;
|
||||
|
|
@ -157,6 +165,10 @@ VirtualRenderer.prototype.getScrollTop = function() {
|
|||
return this.scrollTop;
|
||||
};
|
||||
|
||||
VirtualRenderer.prototype.scrollToRow = function(row) {
|
||||
this.scrollToY(row*this.lineHeight);
|
||||
}
|
||||
|
||||
VirtualRenderer.prototype.scrollToY = function(scrollTop)
|
||||
{
|
||||
var maxHeight = this.lines.length * this.lineHeight - this.scroller.clientHeight;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue