implement center selection in view port command
This commit is contained in:
parent
3715e90501
commit
e1fef748e8
2 changed files with 10 additions and 0 deletions
|
|
@ -261,6 +261,9 @@ canon.addCommand({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
canon.addCommand({
|
canon.addCommand({
|
||||||
|
name: "centerselection",
|
||||||
|
exec: function(env, args, request) { env.editor.centerSelection(); }
|
||||||
|
});
|
||||||
canon.addCommand({
|
canon.addCommand({
|
||||||
name: "splitline",
|
name: "splitline",
|
||||||
exec: function(env, args, request) { env.editor.splitLine(); }
|
exec: function(env, args, request) { env.editor.splitLine(); }
|
||||||
|
|
@ -270,4 +273,5 @@ canon.addCommand({
|
||||||
exec: function(env, args, request) { env.editor.transposeLetters(); }
|
exec: function(env, args, request) { env.editor.transposeLetters(); }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -824,6 +824,12 @@ var Editor =function(renderer, session) {
|
||||||
this.scrollToLine = function(line, center) {
|
this.scrollToLine = function(line, center) {
|
||||||
this.renderer.scrollToLine(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() {
|
this.getCursorPosition = function() {
|
||||||
return this.selection.getCursor();
|
return this.selection.getCursor();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue