support start of file and end of file scrolling

This commit is contained in:
Fabian Jakobs 2010-04-12 12:43:45 +02:00
commit 2b88ca2c71

View file

@ -34,7 +34,9 @@ var KeyBinding = function(element, host)
break; break;
case keys.UP: case keys.UP:
if (e.shiftKey) { if (e.metaKey) {
host.navigateFileStart();
} if (e.shiftKey) {
host.selectUp(); host.selectUp();
} else { } else {
host.navigateUp(); host.navigateUp();
@ -42,7 +44,9 @@ var KeyBinding = function(element, host)
return ace.stopEvent(e); return ace.stopEvent(e);
case keys.DOWN: case keys.DOWN:
if (e.shiftKey) { if (e.metaKey) {
host.navigateFileEnd();
} if (e.shiftKey) {
host.selectDown(); host.selectDown();
} else{ } else{
host.navigateDown(); host.navigateDown();
@ -391,13 +395,17 @@ ace.Editor.prototype.getPageUpRow = function()
}; };
ace.Editor.prototype.scrollPageDown = function() { ace.Editor.prototype.scrollPageDown = function() {
this.renderer.scrollToRow(this.getPageDownRow()); this.scrollToRow(this.getPageDownRow());
}; };
ace.Editor.prototype.scrollPageUp = function() { ace.Editor.prototype.scrollPageUp = function() {
this.renderer.scrollToRow(this.getPageUpRow()); this.renderer.scrollToRow(this.getPageUpRow());
}; };
ace.Editor.prototype.scrollToRow = function(row) {
this.renderer.scrollToRow(row);
};
ace.Editor.prototype.navigateUp = function() ace.Editor.prototype.navigateUp = function()
{ {
this.clearSelection(); this.clearSelection();
@ -451,6 +459,20 @@ ace.Editor.prototype.navigateLineEnd = function()
this.renderer.scrollCursorIntoView(); this.renderer.scrollCursorIntoView();
}; };
ace.Editor.prototype.navigateFileEnd = function()
{
this.clearSelection();
this.moveCursorFileEnd();
this.renderer.scrollCursorIntoView();
},
ace.Editor.prototype.navigateFileStart = function()
{
this.clearSelection();
this.moveCursorFileStart();
this.renderer.scrollCursorIntoView();
},
ace.Editor.prototype.moveCursorUp = function() { ace.Editor.prototype.moveCursorUp = function() {
this.moveCursorBy(-1, 0); this.moveCursorBy(-1, 0);
}; };
@ -479,18 +501,24 @@ ace.Editor.prototype.moveCursorRight = function()
} else { } else {
this.moveCursorBy(0, 1); this.moveCursorBy(0, 1);
} }
this.renderer.scrollCursorIntoView();
}; };
ace.Editor.prototype.moveCursorLineStart = function() ace.Editor.prototype.moveCursorLineStart = function() {
{
this.moveCursorTo(this.cursor.row, 0); this.moveCursorTo(this.cursor.row, 0);
this.renderer.scrollCursorIntoView();
}; };
ace.Editor.prototype.moveCursorLineEnd = function() { ace.Editor.prototype.moveCursorLineEnd = function() {
this.moveCursorTo(this.cursor.row, this.doc.getLine(this.cursor.row).length); this.moveCursorTo(this.cursor.row, this.doc.getLine(this.cursor.row).length);
this.renderer.scrollCursorIntoView(); };
ace.Editor.prototype.moveCursorFileEnd = function() {
var row = this.doc.getLength() - 1;
var column = this.doc.getLine(row).length;
this.moveCursorTo(row, column);
};
ace.Editor.prototype.moveCursorFileStart = function() {
this.moveCursorTo(0, 0);
}; };
ace.Editor.prototype.moveCursorBy = function(rows, chars) { ace.Editor.prototype.moveCursorBy = function(rows, chars) {
@ -512,6 +540,14 @@ ace.Editor.prototype.moveCursorTo = function(row, column)
this.updateCursor(); this.updateCursor();
}; };
ace.Editor.prototype.getCursorPosition = function()
{
return {
row: this.cursor.row,
column: this.cursor.column
}
};
ace.Editor.prototype.hasSelection = function() { ace.Editor.prototype.hasSelection = function() {
return !!this.selectionLead; return !!this.selectionLead;
}; };