emacs recenter-top-bottom
This commit is contained in:
parent
e00da55c92
commit
393e42b439
2 changed files with 19 additions and 2 deletions
|
|
@ -212,7 +212,8 @@ exports.emacsKeys = {
|
|||
"S-C-Home" : "selecttostart",
|
||||
"S-C-End" : "selecttoend",
|
||||
|
||||
"C-l|M-s" : "centerselection",
|
||||
"C-l" : "recenterTopBottom",
|
||||
"M-s" : "centerselection",
|
||||
"M-g": "gotoline",
|
||||
"C-x C-p": "selectall",
|
||||
|
||||
|
|
@ -270,6 +271,20 @@ exports.emacsKeys = {
|
|||
exports.handler.bindKeys(exports.emacsKeys);
|
||||
|
||||
exports.handler.addCommands({
|
||||
recenterTopBottom: function(editor) {
|
||||
var renderer = editor.renderer;
|
||||
var pos = renderer.$cursorLayer.getPixelPosition();
|
||||
var h = renderer.$size.scrollerHeight - renderer.lineHeight;
|
||||
var scrollTop = renderer.scrollTop;
|
||||
if (Math.abs(pos.top - scrollTop) < 2) {
|
||||
scrollTop = pos.top - h;
|
||||
} else if (Math.abs(pos.top - scrollTop - h * 0.5) < 2) {
|
||||
scrollTop = pos.top;
|
||||
} else {
|
||||
scrollTop = pos.top - h * 0.5;
|
||||
}
|
||||
editor.session.setScrollTop(scrollTop);
|
||||
},
|
||||
selectRectangularRegion: function(editor) {
|
||||
editor.multiSelect.toggleBlockSelection();
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1038,9 +1038,11 @@ var VirtualRenderer = function(container, theme) {
|
|||
cursor = {row: cursor, column: 0};
|
||||
|
||||
var pos = this.$cursorLayer.getPixelPosition(cursor);
|
||||
var offset = pos.top - this.$size.scrollerHeight * (alignment || 0);
|
||||
var h = this.$size.scrollerHeight - this.lineHeight;
|
||||
var offset = pos.top - h * (alignment || 0);
|
||||
|
||||
this.session.setScrollTop(offset);
|
||||
return offset;
|
||||
};
|
||||
|
||||
this.STEPS = 8;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue