emacs: add contents of copy/cut editor events to killring
This commit is contained in:
parent
259d48ea1a
commit
ee76ccad19
1 changed files with 11 additions and 0 deletions
|
|
@ -112,6 +112,8 @@ exports.handler.attach = function(editor) {
|
||||||
editor.commands.addCommands(commands);
|
editor.commands.addCommands(commands);
|
||||||
exports.handler.platform = editor.commands.platform;
|
exports.handler.platform = editor.commands.platform;
|
||||||
editor.$emacsModeHandler = this;
|
editor.$emacsModeHandler = this;
|
||||||
|
editor.addEventListener('copy', this.onCopy);
|
||||||
|
editor.addEventListener('paste', this.onPaste);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handler.detach = function(editor) {
|
exports.handler.detach = function(editor) {
|
||||||
|
|
@ -122,6 +124,8 @@ exports.handler.detach = function(editor) {
|
||||||
editor.removeEventListener("changeSession", $kbSessionChange);
|
editor.removeEventListener("changeSession", $kbSessionChange);
|
||||||
editor.unsetStyle("emacs-mode");
|
editor.unsetStyle("emacs-mode");
|
||||||
editor.commands.removeCommands(commands);
|
editor.commands.removeCommands(commands);
|
||||||
|
editor.removeEventListener('copy', this.onCopy);
|
||||||
|
editor.removeEventListener('paste', this.onPaste);
|
||||||
};
|
};
|
||||||
|
|
||||||
var $kbSessionChange = function(e) {
|
var $kbSessionChange = function(e) {
|
||||||
|
|
@ -157,6 +161,13 @@ combinations.forEach(function(c) {
|
||||||
eMods[hashId] = c.toLowerCase() + "-";
|
eMods[hashId] = c.toLowerCase() + "-";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
exports.handler.onCopy = function(e, editor) {
|
||||||
|
if (editor.$handlesEmacsOnCopy) return;
|
||||||
|
editor.$handlesEmacsOnCopy = true;
|
||||||
|
exports.handler.commands.killRingSave.exec(editor);
|
||||||
|
delete editor.$handlesEmacsOnCopy;
|
||||||
|
}
|
||||||
|
|
||||||
exports.handler.bindKey = function(key, command) {
|
exports.handler.bindKey = function(key, command) {
|
||||||
if (!key)
|
if (!key)
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue