implement center selection in view port command

This commit is contained in:
Fabian Jakobs 2011-02-13 16:06:21 +01:00
commit e1fef748e8
2 changed files with 10 additions and 0 deletions

View file

@ -261,6 +261,9 @@ canon.addCommand({
}
});
canon.addCommand({
name: "centerselection",
exec: function(env, args, request) { env.editor.centerSelection(); }
});
canon.addCommand({
name: "splitline",
exec: function(env, args, request) { env.editor.splitLine(); }
@ -270,4 +273,5 @@ canon.addCommand({
exec: function(env, args, request) { env.editor.transposeLetters(); }
});
});

View file

@ -824,6 +824,12 @@ var Editor =function(renderer, session) {
this.scrollToLine = function(line, center) {
this.renderer.scrollToLine(line, center);
};
this.centerSelection = function() {
var range = this.getSelectionRange();
var line = Math.floor(range.start.row + (range.end.row - range.start.row) / 2);
this.renderer.scrollToLine(line, true);
};
this.getCursorPosition = function() {
return this.selection.getCursor();