emacs: adding mark-ring
This commit is contained in:
parent
0a774fbb37
commit
1172f5cb3d
1 changed files with 22 additions and 0 deletions
|
|
@ -96,15 +96,31 @@ exports.handler.attach = function(editor) {
|
|||
editor.session.$useEmacsStyleLineStart = true;
|
||||
|
||||
editor.session.$emacsMark = null;
|
||||
editor.session.$emacsMarkRing = editor.session.$emacsMarkRing || [];
|
||||
|
||||
editor.emacsMarkMode = function() {
|
||||
return this.session.$emacsMark;
|
||||
}
|
||||
|
||||
editor.setEmacsMarkMode = function(p) {
|
||||
var prevMark = this.session.$emacsMark;
|
||||
if (prevMark)
|
||||
this.session.$emacsMarkRing.push(prevMark);
|
||||
this.session.$emacsMark = p;
|
||||
}
|
||||
|
||||
editor.pushEmacsMark = function(p, activate) {
|
||||
var prevMark = this.session.$emacsMark;
|
||||
if (prevMark)
|
||||
this.session.$emacsMarkRing.push(prevMark);
|
||||
if (activate) this.session.$emacsMark = p;
|
||||
else this.session.$emacsMarkRing.push(p);
|
||||
}
|
||||
|
||||
editor.getLastEmacsMark = function(p) {
|
||||
return this.session.$emacsMark || this.session.$emacsMarkRing.reverse()[0];
|
||||
}
|
||||
|
||||
editor.on("click", $resetMarkMode);
|
||||
editor.on("changeSession", $kbSessionChange);
|
||||
editor.renderer.screenToTextCoordinates = screenToTextBlockCoordinates;
|
||||
|
|
@ -141,6 +157,8 @@ var $kbSessionChange = function(e) {
|
|||
|
||||
if (!e.session.hasOwnProperty('$emacsMark'))
|
||||
e.session.$emacsMark = null;
|
||||
if (!e.session.hasOwnProperty('$emacsMarkRing'))
|
||||
e.session.$emacsMarkRing = [];
|
||||
}
|
||||
|
||||
var $resetMarkMode = function(e) {
|
||||
|
|
@ -168,6 +186,10 @@ exports.handler.onCopy = function(e, editor) {
|
|||
delete editor.$handlesEmacsOnCopy;
|
||||
}
|
||||
|
||||
exports.handler.onPaste = function(e, editor) {
|
||||
editor.pushEmacsMark(editor.getCursorPosition());
|
||||
}
|
||||
|
||||
exports.handler.bindKey = function(key, command) {
|
||||
if (!key)
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue