use events to publish document changes
This commit is contained in:
parent
1f82e32175
commit
844a440ca8
1 changed files with 8 additions and 6 deletions
|
|
@ -6,7 +6,11 @@ ace.TextDocument = function(text) {
|
|||
this.selection = new ace.Selection(this);
|
||||
|
||||
this.listeners = [];
|
||||
|
||||
this.$initEvents();
|
||||
};
|
||||
ace.mixin(ace.TextDocument.prototype, ace.MEventEmitter);
|
||||
|
||||
|
||||
ace.TextDocument.prototype._split = function(text) {
|
||||
return text.split(/[\n\r]/);
|
||||
|
|
@ -20,14 +24,12 @@ ace.TextDocument.prototype.getSelection = function() {
|
|||
return this.selection;
|
||||
};
|
||||
|
||||
ace.TextDocument.prototype.addChangeListener = function(listener) {
|
||||
this.listeners.push(listener);
|
||||
};
|
||||
|
||||
ace.TextDocument.prototype.fireChangeEvent = function(firstRow, lastRow) {
|
||||
for ( var i = 0; i < this.listeners.length; i++) {
|
||||
this.listeners[i](firstRow, lastRow);
|
||||
var data = {
|
||||
firstRow: firstRow,
|
||||
lastRow: lastRow
|
||||
};
|
||||
this.$dispatchEvent("change", { data: data});
|
||||
};
|
||||
|
||||
ace.TextDocument.prototype.getWidth = function() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue