fix page up/down
This commit is contained in:
parent
2538e85780
commit
acdb23c828
2 changed files with 26 additions and 37 deletions
2
doc/wiki
2
doc/wiki
|
|
@ -1 +1 @@
|
|||
Subproject commit d2a65d0addc2e5ab922bbff9cb6022a4652b4f13
|
||||
Subproject commit cc5ccde4565f7b21c81345f47e941e011e94b810
|
||||
|
|
@ -959,62 +959,51 @@ var Editor = function(renderer, session) {
|
|||
return this.renderer.getScrollBottomRow() - this.renderer.getScrollTopRow() + 1;
|
||||
};
|
||||
|
||||
this.$getPageDownRow = function() {
|
||||
return this.renderer.getScrollBottomRow();
|
||||
};
|
||||
this.$moveByPage = function(dir, select) {
|
||||
var renderer = this.renderer;
|
||||
var config = this.renderer.layerConfig;
|
||||
var rows = dir * Math.floor(config.height / config.lineHeight);
|
||||
|
||||
this.$getPageUpRow = function() {
|
||||
var firstRow = this.renderer.getScrollTopRow();
|
||||
var lastRow = this.renderer.getScrollBottomRow();
|
||||
renderer.scrollBy(0, rows * config.lineHeight);
|
||||
|
||||
return firstRow - (lastRow - firstRow);
|
||||
if (select == null)
|
||||
return;
|
||||
|
||||
this.$blockScrolling++;
|
||||
if (select) {
|
||||
this.selection.$moveSelection(function(){
|
||||
this.moveCursorBy(rows, 0);
|
||||
});
|
||||
} else {
|
||||
this.selection.moveCursorBy(rows, 0);
|
||||
this.selection.clearSelection();
|
||||
}
|
||||
|
||||
this.$blockScrolling--;
|
||||
};
|
||||
|
||||
this.selectPageDown = function() {
|
||||
var row = this.$getPageDownRow() + Math.floor(this.$getVisibleRowCount() / 2);
|
||||
|
||||
this.scrollPageDown();
|
||||
|
||||
var selection = this.getSelection();
|
||||
var leadScreenPos = this.session.documentToScreenPosition(selection.getSelectionLead());
|
||||
var dest = this.session.screenToDocumentPosition(row, leadScreenPos.column);
|
||||
selection.selectTo(dest.row, dest.column);
|
||||
this.$moveByPage(1, true);
|
||||
};
|
||||
|
||||
this.selectPageUp = function() {
|
||||
var visibleRows = this.renderer.getScrollTopRow() - this.renderer.getScrollBottomRow();
|
||||
var row = this.$getPageUpRow() + Math.round(visibleRows / 2);
|
||||
|
||||
this.scrollPageUp();
|
||||
|
||||
var selection = this.getSelection();
|
||||
var leadScreenPos = this.session.documentToScreenPosition(selection.getSelectionLead());
|
||||
var dest = this.session.screenToDocumentPosition(row, leadScreenPos.column);
|
||||
selection.selectTo(dest.row, dest.column);
|
||||
this.$moveByPage(-1, true);
|
||||
};
|
||||
|
||||
this.gotoPageDown = function() {
|
||||
var row = this.$getPageDownRow();
|
||||
var column = this.getCursorPositionScreen().column;
|
||||
|
||||
this.$gotoLine(row, column);
|
||||
this.clearSelection();
|
||||
this.$moveByPage(1, false);
|
||||
};
|
||||
|
||||
this.gotoPageUp = function() {
|
||||
var row = this.$getPageUpRow();
|
||||
var column = this.getCursorPositionScreen().column;
|
||||
|
||||
this.$gotoLine(row, column);
|
||||
this.clearSelection();
|
||||
this.$moveByPage(-1, false);
|
||||
};
|
||||
|
||||
this.scrollPageDown = function() {
|
||||
this.scrollToLine(this.$getPageDownRow());
|
||||
this.$moveByPage(1);
|
||||
};
|
||||
|
||||
this.scrollPageUp = function() {
|
||||
this.scrollToLine(this.$getPageUpRow());
|
||||
this.$moveByPage(-1);
|
||||
};
|
||||
|
||||
this.scrollToRow = function(row) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue