don't use the global ace module so often

This commit is contained in:
Fabian Jakobs 2010-09-25 10:52:58 +02:00
commit a330594890
17 changed files with 77 additions and 69 deletions

View file

@ -5,7 +5,7 @@
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt> * @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
* @author Fabian Jakobs <fabian AT ajax DOT org> * @author Fabian Jakobs <fabian AT ajax DOT org>
*/ */
require.def("ace/BackgroundTokenizer", ["ace/ace", "ace/MEventEmitter"], function(ace, MEventEmitter) { require.def("ace/BackgroundTokenizer", ["ace/lib/oop", "ace/MEventEmitter"], function(oop, MEventEmitter) {
var BackgroundTokenizer = function(tokenizer) { var BackgroundTokenizer = function(tokenizer) {
this.running = false; this.running = false;
@ -44,7 +44,7 @@ var BackgroundTokenizer = function(tokenizer) {
(function(){ (function(){
ace.implement(this, MEventEmitter); oop.implement(this, MEventEmitter);
this.setTokenizer = function(tokenizer) { this.setTokenizer = function(tokenizer) {
this.tokenizer = tokenizer; this.tokenizer = tokenizer;

View file

@ -7,12 +7,13 @@
*/ */
require.def("ace/Document", require.def("ace/Document",
[ [
"ace/ace", "ace/lib/oop",
"ace/lib/lang",
"ace/MEventEmitter", "ace/MEventEmitter",
"ace/Selection", "ace/Selection",
"ace/mode/Text", "ace/mode/Text",
"ace/Range" "ace/Range"
], function(ace, MEventEmitter, Selection, TextMode, Range) { ], function(oop, lang, MEventEmitter, Selection, TextMode, Range) {
var Document = function(text, mode) { var Document = function(text, mode) {
this.modified = true; this.modified = true;
@ -25,7 +26,7 @@ var Document = function(text, mode) {
this.setMode(mode); this.setMode(mode);
} }
if (ace.isArray(text)) { if (lang.isArray(text)) {
this.$insertLines(0, text); this.$insertLines(0, text);
} else { } else {
this.$insert({row: 0, column: 0}, text); this.$insert({row: 0, column: 0}, text);
@ -34,7 +35,7 @@ var Document = function(text, mode) {
(function() { (function() {
ace.implement(this, MEventEmitter); oop.implement(this, MEventEmitter);
this.$undoManager = null; this.$undoManager = null;
@ -76,7 +77,7 @@ var Document = function(text, mode) {
if (undoManager) { if (undoManager) {
undoManager.setDocument(this); undoManager.setDocument(this);
var self = this; var self = this;
this.$informUndoManager = ace.deferredCall(function() { this.$informUndoManager = lang.deferredCall(function() {
if (self.$deltas.length > 0) if (self.$deltas.length > 0)
undoManager.notify(self.$deltas); undoManager.notify(self.$deltas);
self.$deltas = []; self.$deltas = [];

View file

@ -6,8 +6,10 @@
* @author Fabian Jakobs <fabian AT ajax DOT org> * @author Fabian Jakobs <fabian AT ajax DOT org>
*/ */
require.def("ace/Search", require.def("ace/Search",
["ace/ace", "ace/Range"], ["ace/lib/lang",
function(ace, Range) { "ace/lib/oop",
"ace/Range"],
function(lang, oop, Range) {
var Search = function() { var Search = function() {
this.$options = { this.$options = {
@ -27,7 +29,7 @@ Search.SELECTION = 2;
(function() { (function() {
this.set = function(options) { this.set = function(options) {
ace.mixin(this.$options, options); oop.mixin(this.$options, options);
return this; return this;
}; };
@ -156,7 +158,7 @@ Search.SELECTION = 2;
if (this.$options.regExp) { if (this.$options.regExp) {
var needle = this.$options.needle; var needle = this.$options.needle;
} else { } else {
needle = ace.escapeRegExp(this.$options.needle); needle = lang.escapeRegExp(this.$options.needle);
} }
if (this.$options.wholeWord) { if (this.$options.wholeWord) {

View file

@ -6,10 +6,11 @@
* @author Fabian Jakobs <fabian AT ajax DOT org> * @author Fabian Jakobs <fabian AT ajax DOT org>
*/ */
require.def("ace/Selection", [ require.def("ace/Selection", [
"ace/ace", "ace/lib/oop",
"ace/lib/lang",
"ace/MEventEmitter", "ace/MEventEmitter",
"ace/Range" "ace/Range"
], function(ace, MEventEmitter, Range) { ], function(oop, lang, MEventEmitter, Range) {
var Selection = function(doc) { var Selection = function(doc) {
this.doc = doc; this.doc = doc;
@ -23,7 +24,7 @@ var Selection = function(doc) {
(function() { (function() {
ace.implement(this, MEventEmitter); oop.implement(this, MEventEmitter);
this.isEmpty = function() { this.isEmpty = function() {
return (!this.selectionAnchor || return (!this.selectionAnchor ||
@ -328,7 +329,7 @@ var Selection = function(doc) {
var row = this.selectionLead.row; var row = this.selectionLead.row;
var column = this.selectionLead.column; var column = this.selectionLead.column;
var line = this.doc.getLine(row); var line = this.doc.getLine(row);
var leftOfCursor = ace.stringReverse(line.substring(0, column)); var leftOfCursor = lang.stringReverse(line.substring(0, column));
var match; var match;
this.nonTokenRe.lastIndex = 0; this.nonTokenRe.lastIndex = 0;

View file

@ -5,7 +5,7 @@
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt> * @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
* @author Fabian Jakobs <fabian AT ajax DOT org> * @author Fabian Jakobs <fabian AT ajax DOT org>
*/ */
require.def("ace/TextInput", ["ace/ace"], function(ace) { require.def("ace/TextInput", ["ace/lib/event"], function(event) {
var TextInput = function(parentNode, host) { var TextInput = function(parentNode, host) {
@ -60,23 +60,23 @@ var TextInput = function(parentNode, host) {
text.select(); text.select();
}; };
ace.addListener(text, "keypress", onTextInput); event.addListener(text, "keypress", onTextInput);
ace.addListener(text, "textInput", onTextInput); event.addListener(text, "textInput", onTextInput);
ace.addListener(text, "paste", onTextInput); event.addListener(text, "paste", onTextInput);
ace.addListener(text, "propertychange", onTextInput); event.addListener(text, "propertychange", onTextInput);
ace.addListener(text, "copy", onCopy); event.addListener(text, "copy", onCopy);
ace.addListener(text, "cut", onCut); event.addListener(text, "cut", onCut);
ace.addListener(text, "compositionstart", onCompositionStart); event.addListener(text, "compositionstart", onCompositionStart);
ace.addListener(text, "compositionupdate", onCompositionUpdate); event.addListener(text, "compositionupdate", onCompositionUpdate);
ace.addListener(text, "compositionend", onCompositionEnd); event.addListener(text, "compositionend", onCompositionEnd);
ace.addListener(text, "blur", function() { event.addListener(text, "blur", function() {
host.onBlur(); host.onBlur();
}); });
ace.addListener(text, "focus", function() { event.addListener(text, "focus", function() {
host.onFocus(); host.onFocus();
}); });

View file

@ -8,6 +8,8 @@
require.def("ace/VirtualRenderer", require.def("ace/VirtualRenderer",
[ [
"ace/ace", "ace/ace",
"ace/lang/oop",
"ace/lang/lang",
"ace/layer/Gutter", "ace/layer/Gutter",
"ace/layer/Marker", "ace/layer/Marker",
"ace/layer/Text", "ace/layer/Text",
@ -46,7 +48,7 @@ var VirtualRenderer = function(container) {
this.layers = [ this.$markerLayer, textLayer, this.$cursorLayer ]; this.layers = [ this.$markerLayer, textLayer, this.$cursorLayer ];
this.scrollBar = new ScrollBar(container); this.scrollBar = new ScrollBar(container);
this.scrollBar.addEventListener("scroll", ace.bind(this.onScroll, this)); this.scrollBar.addEventListener("scroll", lang.bind(this.onScroll, this));
this.scrollTop = 0; this.scrollTop = 0;
@ -66,8 +68,8 @@ var VirtualRenderer = function(container) {
self.lineHeight = textLayer.getLineHeight(); self.lineHeight = textLayer.getLineHeight();
self.onResize(); self.onResize();
}); });
ace.addListener(this.$gutter, "click", ace.bind(this.$onGutterClick, this)); ace.addListener(this.$gutter, "click", lang.bind(this.$onGutterClick, this));
ace.addListener(this.$gutter, "dblclick", ace.bind(this.$onGutterClick, this)); ace.addListener(this.$gutter, "dblclick", lang.bind(this.$onGutterClick, this));
}; };
(function() { (function() {

View file

@ -5,7 +5,7 @@
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt> * @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
* @author Fabian Jakobs <fabian AT ajax DOT org> * @author Fabian Jakobs <fabian AT ajax DOT org>
*/ */
require.def("ace/layer/Cursor", ["ace/ace"], function(ace) { require.def("ace/layer/Cursor", ["ace/lib/dom"], function(dom) {
var Cursor = function(parentEl) { var Cursor = function(parentEl) {
this.element = document.createElement("div"); this.element = document.createElement("div");
@ -30,9 +30,9 @@ var Cursor = function(parentEl) {
column : this.doc.documentToScreenColumn(position.row, position.column) column : this.doc.documentToScreenColumn(position.row, position.column)
}; };
if (overwrite) { if (overwrite) {
ace.addCssClass(this.cursor, "ace_overwrite"); dom.addCssClass(this.cursor, "ace_overwrite");
} else { } else {
ace.removeCssClass(this.cursor, "ace_overwrite"); dom.removeCssClass(this.cursor, "ace_overwrite");
} }
}; };

View file

@ -5,7 +5,7 @@
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt> * @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
* @author Fabian Jakobs <fabian AT ajax DOT org> * @author Fabian Jakobs <fabian AT ajax DOT org>
*/ */
require.def("ace/layer/Text", ["ace/ace", "ace/MEventEmitter"], function(ace, MEventEmitter) { require.def("ace/layer/Text", ["ace/lib/oop", "ace/lib/dom", "ace/MEventEmitter"], function(oop, dom, MEventEmitter) {
var Text = function(parentEl) { var Text = function(parentEl) {
this.element = document.createElement("div"); this.element = document.createElement("div");
@ -18,7 +18,7 @@ var Text = function(parentEl) {
(function() { (function() {
ace.implement(this, MEventEmitter); oop.implement(this, MEventEmitter);
this.EOF_CHAR = "&para;"; this.EOF_CHAR = "&para;";
this.EOL_CHAR = "&not;"; this.EOL_CHAR = "&not;";
@ -67,7 +67,7 @@ var Text = function(parentEl) {
style.overflow = "visible"; style.overflow = "visible";
for (var prop in this.$fontStyles) { for (var prop in this.$fontStyles) {
var value = ace.computedStyle(this.element, prop); var value = dom.computedStyle(this.element, prop);
style[prop] = value; style[prop] = value;
} }

View file

@ -7,18 +7,18 @@
*/ */
require.def("ace/mode/Css", require.def("ace/mode/Css",
[ [
"ace/ace", "ace/lib/oop",
"ace/mode/Text", "ace/mode/Text",
"ace/Tokenizer", "ace/Tokenizer",
"ace/mode/CssHighlightRules", "ace/mode/CssHighlightRules",
"ace/mode/MatchingBraceOutdent" "ace/mode/MatchingBraceOutdent"
], function(ace, TextMode, Tokenizer, CssHighlightRules, MatchingBraceOutdent) { ], function(oop, TextMode, Tokenizer, CssHighlightRules, MatchingBraceOutdent) {
var Css = function() { var Css = function() {
this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules()); this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent(); this.$outdent = new MatchingBraceOutdent();
}; };
ace.inherits(Css, TextMode); oop.inherits(Css, TextMode);
(function() { (function() {

View file

@ -7,13 +7,14 @@
*/ */
require.def("ace/mode/CssHighlightRules", require.def("ace/mode/CssHighlightRules",
[ [
"ace/ace", "ace/lib/oop",
"ace/lib/lang",
"ace/mode/TextHighlightRules" "ace/mode/TextHighlightRules"
], function(ace, TextHighlightRules) { ], function(oop, lang, TextHighlightRules) {
var CssHighlightRules = function() { var CssHighlightRules = function() {
var properties = ace.arrayToMap( var properties = lang.arrayToMap(
("azimuth|background-attachment|background-color|background-image|" + ("azimuth|background-attachment|background-color|background-image|" +
"background-position|background-repeat|background|border-bottom-color|" + "background-position|background-repeat|background|border-bottom-color|" +
"border-bottom-style|border-bottom-width|border-bottom|border-collapse|" + "border-bottom-style|border-bottom-width|border-bottom|border-collapse|" +
@ -40,11 +41,11 @@ var CssHighlightRules = function() {
"z-index").split("|") "z-index").split("|")
); );
var functions = ace.arrayToMap( var functions = lang.arrayToMap(
("rgb|rgba|url|attr|counter|counters").split("|") ("rgb|rgba|url|attr|counter|counters").split("|")
); );
var constants = ace.arrayToMap( var constants = lang.arrayToMap(
("absolute|all-scroll|always|armenian|auto|baseline|below|bidi-override|" + ("absolute|all-scroll|always|armenian|auto|baseline|below|bidi-override|" +
"block|bold|bolder|both|bottom|break-all|break-word|capitalize|center|" + "block|bold|bolder|both|bottom|break-all|break-word|capitalize|center|" +
"char|circle|cjk-ideographic|col-resize|collapse|crosshair|dashed|" + "char|circle|cjk-ideographic|col-resize|collapse|crosshair|dashed|" +
@ -189,7 +190,7 @@ var CssHighlightRules = function() {
}; };
}; };
ace.inherits(CssHighlightRules, TextHighlightRules); oop.inherits(CssHighlightRules, TextHighlightRules);
return CssHighlightRules; return CssHighlightRules;
}); });

View file

@ -7,9 +7,9 @@
*/ */
require.def("ace/mode/DocCommentHighlightRules", require.def("ace/mode/DocCommentHighlightRules",
[ [
"ace/ace", "oop/oop",
"ace/mode/TextHighlightRules" "ace/mode/TextHighlightRules"
], function(ace, TextHighlightRules) { ], function(oop, TextHighlightRules) {
var DocCommentHighlightRules = function() { var DocCommentHighlightRules = function() {
@ -34,7 +34,7 @@ var DocCommentHighlightRules = function() {
}; };
}; };
ace.inherits(DocCommentHighlightRules, TextHighlightRules); oop.inherits(DocCommentHighlightRules, TextHighlightRules);
(function() { (function() {

View file

@ -7,13 +7,13 @@
*/ */
require.def("ace/mode/Html", require.def("ace/mode/Html",
[ [
"ace/ace", "ace/lib/oop",
"ace/mode/Text", "ace/mode/Text",
"ace/mode/JavaScript", "ace/mode/JavaScript",
"ace/mode/Css", "ace/mode/Css",
"ace/Tokenizer", "ace/Tokenizer",
"ace/mode/HtmlHighlightRules" "ace/mode/HtmlHighlightRules"
], function(ace, TextMode, JavaScriptMode, CssMode, Tokenizer, HtmlHighlightRules) { ], function(oop, TextMode, JavaScriptMode, CssMode, Tokenizer, HtmlHighlightRules) {
var Html = function() { var Html = function() {
this.$tokenizer = new Tokenizer(new HtmlHighlightRules().getRules()); this.$tokenizer = new Tokenizer(new HtmlHighlightRules().getRules());
@ -21,7 +21,7 @@ var Html = function() {
this.$js = new JavaScriptMode(); this.$js = new JavaScriptMode();
this.$css = new CssMode(); this.$css = new CssMode();
}; };
ace.inherits(Html, TextMode); oop.inherits(Html, TextMode);
(function() { (function() {

View file

@ -7,11 +7,11 @@
*/ */
require.def("ace/mode/HtmlHighlightRules", require.def("ace/mode/HtmlHighlightRules",
[ [
"ace/ace", "ace/lib/oop",
"ace/mode/CssHighlightRules", "ace/mode/CssHighlightRules",
"ace/mode/JavaScriptHighlightRules", "ace/mode/JavaScriptHighlightRules",
"ace/mode/TextHighlightRules" "ace/mode/TextHighlightRules"
], function(ace, CssHighlightRules, JavaScriptHighlightRules, TextHighlightRules) { ], function(oop, CssHighlightRules, JavaScriptHighlightRules, TextHighlightRules) {
var HtmlHighlightRules = function() { var HtmlHighlightRules = function() {
@ -147,7 +147,7 @@ var HtmlHighlightRules = function() {
}); });
}; };
ace.inherits(HtmlHighlightRules, TextHighlightRules); oop.inherits(HtmlHighlightRules, TextHighlightRules);
return HtmlHighlightRules; return HtmlHighlightRules;
}); });

View file

@ -7,18 +7,19 @@
*/ */
require.def("ace/mode/JavaScript", require.def("ace/mode/JavaScript",
[ [
"ace/ace", "ace/lib/oop",
"ace/mode/Text", "ace/mode/Text",
"ace/Tokenizer", "ace/Tokenizer",
"ace/mode/JavaScriptHighlightRules", "ace/mode/JavaScriptHighlightRules",
"ace/mode/MatchingBraceOutdent" "ace/mode/MatchingBraceOutdent",
], function(ace, TextMode, Tokenizer, JavaScriptHighlightRules, MatchingBraceOutdent) { "ace/Range"
], function(oop, TextMode, Tokenizer, JavaScriptHighlightRules, MatchingBraceOutdent, Range) {
var JavaScript = function() { var JavaScript = function() {
this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules()); this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent(); this.$outdent = new MatchingBraceOutdent();
}; };
ace.inherits(JavaScript, TextMode); oop.inherits(JavaScript, TextMode);
(function() { (function() {
@ -35,7 +36,7 @@ ace.inherits(JavaScript, TextMode);
} }
if (outdent) { if (outdent) {
var deleteRange = new ace.Range(0, 0, 0, 0); var deleteRange = new Range(0, 0, 0, 0);
for (var i=range.start.row; i<= range.end.row; i++) for (var i=range.start.row; i<= range.end.row; i++)
{ {
var line = doc.getLine(i).replace(re, "$1"); var line = doc.getLine(i).replace(re, "$1");

View file

@ -7,10 +7,10 @@
*/ */
require.def("ace/mode/JavaScriptHighlightRules", require.def("ace/mode/JavaScriptHighlightRules",
[ [
"ace/ace", "ace/lib/oop",
"ace/mode/DocCommentHighlightRules", "ace/mode/DocCommentHighlightRules",
"ace/mode/TextHighlightRules" "ace/mode/TextHighlightRules"
], function(ace, DocCommentHighlightRules, TextHighlightRules) { ], function(oop, DocCommentHighlightRules, TextHighlightRules) {
JavaScriptHighlightRules = function() { JavaScriptHighlightRules = function() {
@ -126,7 +126,7 @@ JavaScriptHighlightRules = function() {
this.$rules["doc-start"][0].next = "start"; this.$rules["doc-start"][0].next = "start";
}; };
ace.inherits(JavaScriptHighlightRules, TextHighlightRules); oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
return JavaScriptHighlightRules; return JavaScriptHighlightRules;
}); });

View file

@ -7,17 +7,17 @@
*/ */
require.def("ace/mode/Xml", require.def("ace/mode/Xml",
[ [
"ace/ace", "ace/lib/oop",
"ace/mode/Text", "ace/mode/Text",
"ace/Tokenizer", "ace/Tokenizer",
"ace/mode/XmlHighlightRules" "ace/mode/XmlHighlightRules"
], function(ace, TextMode, Tokenizer, XmlHighlightRules) { ], function(oop, TextMode, Tokenizer, XmlHighlightRules) {
var Xml = function() { var Xml = function() {
this.$tokenizer = new Tokenizer(new XmlHighlightRules().getRules()); this.$tokenizer = new Tokenizer(new XmlHighlightRules().getRules());
}; };
ace.inherits(Xml, TextMode); oop.inherits(Xml, TextMode);
(function() { (function() {

View file

@ -7,9 +7,9 @@
*/ */
require.def("ace/mode/XmlHighlightRules", require.def("ace/mode/XmlHighlightRules",
[ [
"ace/ace", "ace/lib/oop",
"ace/mode/TextHighlightRules" "ace/mode/TextHighlightRules"
], function(ace, TextHighlightRules) { ], function(oop, TextHighlightRules) {
var XmlHighlightRules = function() { var XmlHighlightRules = function() {
@ -81,7 +81,7 @@ var XmlHighlightRules = function() {
}; };
}; };
ace.inherits(XmlHighlightRules, TextHighlightRules); oop.inherits(XmlHighlightRules, TextHighlightRules);
return XmlHighlightRules; return XmlHighlightRules;
}); });