Skip to content

Commit

Permalink
use _signal where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
nightwing committed Feb 1, 2014
1 parent 750d38a commit 9cbcfb3
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion lib/ace/anchor.js
Expand Up @@ -191,7 +191,7 @@ var Anchor = exports.Anchor = function(doc, row, column) {

this.row = pos.row;
this.column = pos.column;
this._emit("change", {
this._signal("change", {
old: old,
value: pos
});
Expand Down
2 changes: 1 addition & 1 deletion lib/ace/background_tokenizer.js
Expand Up @@ -150,7 +150,7 @@ var BackgroundTokenizer = function(tokenizer, editor) {
first: firstRow,
last: lastRow
};
this._emit("update", {data: data});
this._signal("update", {data: data});
};

/**
Expand Down
12 changes: 6 additions & 6 deletions lib/ace/document.js
Expand Up @@ -326,7 +326,7 @@ var Document = function(text) {
range: range,
lines: lines
};
this._emit("change", { data: delta });
this._signal("change", { data: delta });
return end || range.end;
};

Expand Down Expand Up @@ -356,7 +356,7 @@ var Document = function(text) {
range: Range.fromPoints(position, end),
text: this.getNewLineCharacter()
};
this._emit("change", { data: delta });
this._signal("change", { data: delta });

return end;
};
Expand Down Expand Up @@ -390,7 +390,7 @@ var Document = function(text) {
range: Range.fromPoints(position, end),
text: text
};
this._emit("change", { data: delta });
this._signal("change", { data: delta });

return end;
};
Expand Down Expand Up @@ -458,7 +458,7 @@ var Document = function(text) {
range: range,
text: removed
};
this._emit("change", { data: delta });
this._signal("change", { data: delta });
return range.start;
};

Expand All @@ -485,7 +485,7 @@ var Document = function(text) {
nl: this.getNewLineCharacter(),
lines: removed
};
this._emit("change", { data: delta });
this._signal("change", { data: delta });
return removed;
};

Expand All @@ -508,7 +508,7 @@ var Document = function(text) {
range: range,
text: this.getNewLineCharacter()
};
this._emit("change", { data: delta });
this._signal("change", { data: delta });
};

/**
Expand Down
44 changes: 22 additions & 22 deletions lib/ace/edit_session.js
Expand Up @@ -163,7 +163,7 @@ var EditSession = function(text, mode) {

config.resetOptions(this);
this.setMode(mode);
config._emit("session", this);
config._signal("session", this);
};


Expand Down Expand Up @@ -269,7 +269,7 @@ var EditSession = function(text, mode) {
}

this.bgTokenizer.$updateOnChange(delta);
this._emit("change", e);
this._signal("change", e);
};

/**
Expand Down Expand Up @@ -528,7 +528,7 @@ var EditSession = function(text, mode) {
if (!this.$decorations[row])
this.$decorations[row] = "";
this.$decorations[row] += " " + className;
this._emit("changeBreakpoint", {});
this._signal("changeBreakpoint", {});
};

/**
Expand All @@ -540,7 +540,7 @@ var EditSession = function(text, mode) {
**/
this.removeGutterDecoration = function(row, className) {
this.$decorations[row] = (this.$decorations[row] || "").replace(" " + className, "");
this._emit("changeBreakpoint", {});
this._signal("changeBreakpoint", {});
};

/**
Expand All @@ -563,15 +563,15 @@ var EditSession = function(text, mode) {
for (var i=0; i<rows.length; i++) {
this.$breakpoints[rows[i]] = "ace_breakpoint";
}
this._emit("changeBreakpoint", {});
this._signal("changeBreakpoint", {});
};

/**
* Removes all breakpoints on the rows. This function also emites the `'changeBreakpoint'` event.
**/
this.clearBreakpoints = function() {
this.$breakpoints = [];
this._emit("changeBreakpoint", {});
this._signal("changeBreakpoint", {});
};

/**
Expand All @@ -588,7 +588,7 @@ var EditSession = function(text, mode) {
this.$breakpoints[row] = className;
else
delete this.$breakpoints[row];
this._emit("changeBreakpoint", {});
this._signal("changeBreakpoint", {});
};

/**
Expand All @@ -599,7 +599,7 @@ var EditSession = function(text, mode) {
**/
this.clearBreakpoint = function(row) {
delete this.$breakpoints[row];
this._emit("changeBreakpoint", {});
this._signal("changeBreakpoint", {});
};

/**
Expand All @@ -626,10 +626,10 @@ var EditSession = function(text, mode) {

if (inFront) {
this.$frontMarkers[id] = marker;
this._emit("changeFrontMarker")
this._signal("changeFrontMarker")
} else {
this.$backMarkers[id] = marker;
this._emit("changeBackMarker")
this._signal("changeBackMarker")
}

return id;
Expand All @@ -652,10 +652,10 @@ var EditSession = function(text, mode) {

if (inFront) {
this.$frontMarkers[id] = marker;
this._emit("changeFrontMarker")
this._signal("changeFrontMarker")
} else {
this.$backMarkers[id] = marker;
this._emit("changeBackMarker")
this._signal("changeBackMarker")
}

return marker;
Expand All @@ -676,7 +676,7 @@ var EditSession = function(text, mode) {
var markers = marker.inFront ? this.$frontMarkers : this.$backMarkers;
if (marker) {
delete (markers[markerId]);
this._emit(marker.inFront ? "changeFrontMarker" : "changeBackMarker");
this._signal(marker.inFront ? "changeFrontMarker" : "changeBackMarker");
}
};

Expand Down Expand Up @@ -728,7 +728,7 @@ var EditSession = function(text, mode) {
**/
this.setAnnotations = function(annotations) {
this.$annotations = annotations;
this._emit("changeAnnotation", {});
this._signal("changeAnnotation", {});
};

/**
Expand Down Expand Up @@ -858,7 +858,7 @@ var EditSession = function(text, mode) {
this.onReloadTokenizer = function(e) {
var rows = e.data;
this.bgTokenizer.start(rows.first);
this._emit("tokenizerUpdate", e);
this._signal("tokenizerUpdate", e);
};

this.$modes = {};
Expand Down Expand Up @@ -937,7 +937,7 @@ var EditSession = function(text, mode) {
this.bgTokenizer = new BackgroundTokenizer(tokenizer);
var _self = this;
this.bgTokenizer.addEventListener("update", function(e) {
_self._emit("tokenizerUpdate", e);
_self._signal("tokenizerUpdate", e);
});
} else {
this.bgTokenizer.setTokenizer(tokenizer);
Expand Down Expand Up @@ -1563,7 +1563,7 @@ var EditSession = function(text, mode) {
this.$updateWrapData(0, len - 1);
}

this._emit("changeWrapMode");
this._signal("changeWrapMode");
}
};

Expand Down Expand Up @@ -1594,7 +1594,7 @@ var EditSession = function(text, mode) {
};
this.$modified = true;
// This will force a recalculation of the wrap limit
this._emit("changeWrapMode");
this._signal("changeWrapMode");
}
};

Expand All @@ -1616,7 +1616,7 @@ var EditSession = function(text, mode) {
if (this.$useWrapMode) {
this.$updateWrapData(0, this.getLength() - 1);
this.$resetRowCache(0);
this._emit("changeWrapLimit");
this._signal("changeWrapLimit");
}
return true;
}
Expand Down Expand Up @@ -2507,7 +2507,7 @@ config.defineOptions(EditSession.prototype, "session", {
initialValue: "auto"
},
firstLineNumber: {
set: function() {this._emit("changeBreakpoint");},
set: function() {this._signal("changeBreakpoint");},
initialValue: 1
},
useWorker: {
Expand All @@ -2528,13 +2528,13 @@ config.defineOptions(EditSession.prototype, "session", {
this.$modified = true;
this.$rowLengthCache = [];
this.$tabSize = tabSize;
this._emit("changeTabSize");
this._signal("changeTabSize");
},
initialValue: 4,
handlesSet: true
},
overwrite: {
set: function(val) {this._emit("changeOverwrite");},
set: function(val) {this._signal("changeOverwrite");},
initialValue: false
},
newLineMode: {
Expand Down
16 changes: 8 additions & 8 deletions lib/ace/editor.js
Expand Up @@ -102,7 +102,7 @@ var Editor = function(renderer, session) {

this.setSession(session || new EditSession(""));
config.resetOptions(this);
config._emit("editor", this);
config._signal("editor", this);
};

(function(){
Expand Down Expand Up @@ -384,7 +384,7 @@ var Editor = function(renderer, session) {
this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
this.renderer.updateFull();

this._emit("changeSession", {
this._signal("changeSession", {
session: session,
oldSession: oldSession
});
Expand Down Expand Up @@ -617,7 +617,7 @@ var Editor = function(renderer, session) {
lastRow = Infinity;
this.renderer.updateLines(range.start.row, lastRow);

this._emit("change", e);
this._signal("change", e);

// update cursor because tab characters can influence the cursor position
this.$cursorChange();
Expand Down Expand Up @@ -650,7 +650,7 @@ var Editor = function(renderer, session) {

this.$highlightBrackets();
this.$updateHighlightActiveLine();
this._emit("changeSelection");
this._signal("changeSelection");
};

this.$updateHighlightActiveLine = function() {
Expand All @@ -675,7 +675,7 @@ var Editor = function(renderer, session) {
session.$highlightLineMarker.start.row = highlight.row;
session.$highlightLineMarker.end.row = highlight.row;
session.$highlightLineMarker.start.column = highlight.column;
session._emit("changeBackMarker");
session._signal("changeBackMarker");
}
};

Expand All @@ -698,7 +698,7 @@ var Editor = function(renderer, session) {
var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp();
this.session.highlight(re);

this._emit("changeSelection");
this._signal("changeSelection");
};

this.$getSelectionHighLightRegexp = function() {
Expand Down Expand Up @@ -2302,7 +2302,7 @@ var Editor = function(renderer, session) {
**/
this.destroy = function() {
this.renderer.destroy();
this._emit("destroy", this);
this._signal("destroy", this);
};

/**
Expand Down Expand Up @@ -2379,7 +2379,7 @@ config.defineOptions(Editor.prototype, "editor", {
selectionStyle: {
set: function(style) {
this.onSelectionChange();
this._emit("changeSelectionStyle", {data: style});
this._signal("changeSelectionStyle", {data: style});
},
initialValue: "line"
},
Expand Down
8 changes: 4 additions & 4 deletions lib/ace/multi_select.js
Expand Up @@ -100,7 +100,7 @@ var EditSession = require("./edit_session").EditSession;
this.$onRemoveRange(removed);

if (this.rangeCount > 1 && !this.inMultiSelectMode) {
this._emit("multiSelect");
this._signal("multiSelect");
this.inMultiSelectMode = true;
this.session.$undoSelect = false;
this.rangeList.attach(this.session);
Expand Down Expand Up @@ -150,7 +150,7 @@ var EditSession = require("./edit_session").EditSession;
this.$onAddRange = function(range) {
this.rangeCount = this.rangeList.ranges.length;
this.ranges.unshift(range);
this._emit("addRange", {range: range});
this._signal("addRange", {range: range});
};

this.$onRemoveRange = function(removed) {
Expand All @@ -166,11 +166,11 @@ var EditSession = require("./edit_session").EditSession;
this.ranges.splice(index, 1);
}

this._emit("removeRange", {ranges: removed});
this._signal("removeRange", {ranges: removed});

if (this.rangeCount == 0 && this.inMultiSelectMode) {
this.inMultiSelectMode = false;
this._emit("singleSelect");
this._signal("singleSelect");
this.session.$undoSelect = true;
this.rangeList.detach(this.session);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ace/worker/worker.js
Expand Up @@ -176,7 +176,7 @@ window.onmessage = function(e) {
main = new clazz(sender);
}
else if (msg.event && sender) {
sender._emit(msg.event, msg.data);
sender._signal(msg.event, msg.data);
}
};
})(this);
6 changes: 3 additions & 3 deletions lib/ace/worker/worker_client.js
Expand Up @@ -96,7 +96,7 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
break;

case "event":
this._emit(msg.name, {data: msg.data});
this._signal(msg.name, {data: msg.data});
break;

case "call":
Expand All @@ -121,7 +121,7 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
};

this.terminate = function() {
this._emit("terminate", {});
this._signal("terminate", {});
this.deltaQueue = null;
this.$worker.terminate();
this.$worker = null;
Expand Down Expand Up @@ -217,7 +217,7 @@ var UIWorkerClient = function(topLevelNamespaces, mod, classname) {
if (msg.command)
main[msg.command].apply(main, msg.args);
else if (msg.event)
sender._emit(msg.event, msg.data);
sender._signal(msg.event, msg.data);
};

sender.postMessage = function(msg) {
Expand Down

0 comments on commit 9cbcfb3

Please sign in to comment.