add page up/down selection support

This commit is contained in:
Fabian Jakobs 2010-04-12 08:46:06 +02:00
commit 40fa64995d

View file

@ -70,11 +70,19 @@ function KeyBinding(element, host)
return lib.stopEvent(e); return lib.stopEvent(e);
case keys.PAGEDOWN: case keys.PAGEDOWN:
host.scrollPageDown(); if (e.shiftKey) {
host.selectPageDown();
} else {
host.scrollPageDown();
}
return lib.stopEvent(e); return lib.stopEvent(e);
case keys.PAGEUP: case keys.PAGEUP:
host.scrollPageUp(); if (e.shiftKey) {
host.selectPageUp();
} else {
host.scrollPageUp();
}
return lib.stopEvent(e); return lib.stopEvent(e);
case keys.POS1: case keys.POS1:
@ -360,6 +368,14 @@ function Editor(doc, renderer)
this.removeLeft(); this.removeLeft();
}, },
getFirstVisibleRow : function() {
return this.renderer.getFirstVisibleRow();
},
getLastVisibleRow : function() {
return this.renderer.getLastVisibleRow();
},
getPageDownRow : function() { getPageDownRow : function() {
return this.renderer.getLastVisibleRow() - 1; return this.renderer.getLastVisibleRow() - 1;
}, },
@ -600,6 +616,30 @@ function Editor(doc, renderer)
this._moveSelection(this.moveCursorLineEnd); this._moveSelection(this.moveCursorLineEnd);
}, },
selectPageDown : function()
{
var visibleRows = this.getLastVisibleRow() - this.getFirstVisibleRow();
var row = this.getPageDownRow() + Math.round(visibleRows / 2);
this.scrollPageDown();
this._moveSelection(function() {
this.moveCursorTo(row, this.cursor.column);
});
},
selectPageUp : function()
{
var visibleRows = this.getLastVisibleRow() - this.getFirstVisibleRow();
var row = this.getPageUpRow() + Math.round(visibleRows / 2);
this.scrollPageUp();
this._moveSelection(function() {
this.moveCursorTo(row, this.cursor.column);
});
},
selectCurrentLine : function() selectCurrentLine : function()
{ {
this.setSelectionAnchor(this.cursor.row, 0); this.setSelectionAnchor(this.cursor.row, 0);