add editor getSelectedText method

This commit is contained in:
nightwing 2013-08-26 18:31:51 +04:00
commit 3b5d742feb
2 changed files with 12 additions and 14 deletions

View file

@ -739,25 +739,24 @@ var Editor = function(renderer, session) {
this.renderer.updateFull();
};
/**
* Returns the string of text currently highlighted.
* @returns {String}
**/
this.getSelectedText = function() {
return this.session.getTextRange(this.getSelectionRange());
};
/**
* Emitted when text is copied.
* @event copy
* @param {String} text The copied text
*
*
**/
/**
*
* Returns the string of text currently highlighted.
* @returns {String}
**/
this.getCopyText = function() {
var text = "";
if (!this.selection.isEmpty())
text = this.session.getTextRange(this.getSelectionRange());
this._emit("copy", text);
var text = this.getSelectedText();
this._signal("copy", text);
return text;
};

View file

@ -519,7 +519,7 @@ var Editor = require("./editor").Editor;
this.multiSelect.toSingleRange();
};
this.getCopyText = function() {
this.getSelectedText = function() {
var text = "";
if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
var ranges = this.multiSelect.rangeList.ranges;
@ -534,7 +534,6 @@ var Editor = require("./editor").Editor;
} else if (!this.selection.isEmpty()) {
text = this.session.getTextRange(this.getSelectionRange());
}
this._signal("copy", text);
return text;
};