emit events on copy, cut and paste
This commit is contained in:
parent
b8237e3f4b
commit
9505a85237
1 changed files with 13 additions and 7 deletions
|
|
@ -405,20 +405,23 @@ var Editor =function(renderer, session) {
|
|||
};
|
||||
|
||||
this.getCopyText = function() {
|
||||
if (!this.selection.isEmpty()) {
|
||||
return this.session.getTextRange(this.getSelectionRange());
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
var text = "";
|
||||
if (!this.selection.isEmpty())
|
||||
text = this.session.getTextRange(this.getSelectionRange());
|
||||
|
||||
this._emit("copy", text);
|
||||
return text;
|
||||
};
|
||||
|
||||
this.onCut = function() {
|
||||
if (this.$readOnly)
|
||||
return;
|
||||
|
||||
var range = this.getSelectionRange();
|
||||
this._emit("cut", range);
|
||||
|
||||
if (!this.selection.isEmpty()) {
|
||||
this.session.remove(this.getSelectionRange())
|
||||
this.session.remove(range)
|
||||
this.clearSelection();
|
||||
}
|
||||
};
|
||||
|
|
@ -521,6 +524,9 @@ var Editor =function(renderer, session) {
|
|||
};
|
||||
|
||||
this.onTextInput = function(text, notPasted) {
|
||||
if (!notPasted)
|
||||
this._emit("paste", text);
|
||||
|
||||
// In case the text was not pasted and we got only one character, then
|
||||
// handel it as a command key stroke.
|
||||
if (notPasted && text.length == 1) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue