add page up/down selection support
This commit is contained in:
parent
28887f1e6b
commit
40fa64995d
1 changed files with 42 additions and 2 deletions
44
Editor.js
44
Editor.js
|
|
@ -70,11 +70,19 @@ function KeyBinding(element, host)
|
|||
return lib.stopEvent(e);
|
||||
|
||||
case keys.PAGEDOWN:
|
||||
host.scrollPageDown();
|
||||
if (e.shiftKey) {
|
||||
host.selectPageDown();
|
||||
} else {
|
||||
host.scrollPageDown();
|
||||
}
|
||||
return lib.stopEvent(e);
|
||||
|
||||
case keys.PAGEUP:
|
||||
host.scrollPageUp();
|
||||
if (e.shiftKey) {
|
||||
host.selectPageUp();
|
||||
} else {
|
||||
host.scrollPageUp();
|
||||
}
|
||||
return lib.stopEvent(e);
|
||||
|
||||
case keys.POS1:
|
||||
|
|
@ -360,6 +368,14 @@ function Editor(doc, renderer)
|
|||
this.removeLeft();
|
||||
},
|
||||
|
||||
getFirstVisibleRow : function() {
|
||||
return this.renderer.getFirstVisibleRow();
|
||||
},
|
||||
|
||||
getLastVisibleRow : function() {
|
||||
return this.renderer.getLastVisibleRow();
|
||||
},
|
||||
|
||||
getPageDownRow : function() {
|
||||
return this.renderer.getLastVisibleRow() - 1;
|
||||
},
|
||||
|
|
@ -600,6 +616,30 @@ function Editor(doc, renderer)
|
|||
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()
|
||||
{
|
||||
this.setSelectionAnchor(this.cursor.row, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue