From a330594890b77bc595de2b4cc9e677aabb7edf15 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Sat, 25 Sep 2010 10:52:58 +0200 Subject: [PATCH] don't use the global ace module so often --- src/ace/BackgroundTokenizer.js | 6 +++--- src/ace/Document.js | 11 ++++++----- src/ace/Search.js | 10 ++++++---- src/ace/Selection.js | 9 +++++---- src/ace/TextInput.js | 24 ++++++++++++------------ src/ace/VirtualRenderer.js | 8 +++++--- src/ace/layer/Cursor.js | 6 +++--- src/ace/layer/Text.js | 6 +++--- src/ace/mode/Css.js | 6 +++--- src/ace/mode/CssHighlightRules.js | 13 +++++++------ src/ace/mode/DocCommentHighlightRules.js | 6 +++--- src/ace/mode/Html.js | 6 +++--- src/ace/mode/HtmlHighlightRules.js | 6 +++--- src/ace/mode/JavaScript.js | 11 ++++++----- src/ace/mode/JavaScriptHighlightRules.js | 6 +++--- src/ace/mode/Xml.js | 6 +++--- src/ace/mode/XmlHighlightRules.js | 6 +++--- 17 files changed, 77 insertions(+), 69 deletions(-) diff --git a/src/ace/BackgroundTokenizer.js b/src/ace/BackgroundTokenizer.js index 6aa7a6fe..a4074926 100644 --- a/src/ace/BackgroundTokenizer.js +++ b/src/ace/BackgroundTokenizer.js @@ -5,7 +5,7 @@ * @license LGPLv3 * @author Fabian Jakobs */ -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) { this.running = false; @@ -44,7 +44,7 @@ var BackgroundTokenizer = function(tokenizer) { (function(){ - ace.implement(this, MEventEmitter); + oop.implement(this, MEventEmitter); this.setTokenizer = function(tokenizer) { this.tokenizer = tokenizer; @@ -98,7 +98,7 @@ var BackgroundTokenizer = function(tokenizer) { state = this.lines[row - 1].state; } - // TODO find a proper way to cache every line + // TODO find a proper way to cache every line var tokens = this.tokenizer.getLineTokens(this.textLines[row] || "", state || "start"); if (state) { this.lines[row] = tokens; diff --git a/src/ace/Document.js b/src/ace/Document.js index 7410ee35..f6474764 100644 --- a/src/ace/Document.js +++ b/src/ace/Document.js @@ -7,12 +7,13 @@ */ require.def("ace/Document", [ - "ace/ace", + "ace/lib/oop", + "ace/lib/lang", "ace/MEventEmitter", "ace/Selection", "ace/mode/Text", "ace/Range" - ], function(ace, MEventEmitter, Selection, TextMode, Range) { + ], function(oop, lang, MEventEmitter, Selection, TextMode, Range) { var Document = function(text, mode) { this.modified = true; @@ -25,7 +26,7 @@ var Document = function(text, mode) { this.setMode(mode); } - if (ace.isArray(text)) { + if (lang.isArray(text)) { this.$insertLines(0, text); } else { this.$insert({row: 0, column: 0}, text); @@ -34,7 +35,7 @@ var Document = function(text, mode) { (function() { - ace.implement(this, MEventEmitter); + oop.implement(this, MEventEmitter); this.$undoManager = null; @@ -76,7 +77,7 @@ var Document = function(text, mode) { if (undoManager) { undoManager.setDocument(this); var self = this; - this.$informUndoManager = ace.deferredCall(function() { + this.$informUndoManager = lang.deferredCall(function() { if (self.$deltas.length > 0) undoManager.notify(self.$deltas); self.$deltas = []; diff --git a/src/ace/Search.js b/src/ace/Search.js index f41be559..0712cf53 100644 --- a/src/ace/Search.js +++ b/src/ace/Search.js @@ -6,8 +6,10 @@ * @author Fabian Jakobs */ require.def("ace/Search", - ["ace/ace", "ace/Range"], - function(ace, Range) { + ["ace/lib/lang", + "ace/lib/oop", + "ace/Range"], + function(lang, oop, Range) { var Search = function() { this.$options = { @@ -27,7 +29,7 @@ Search.SELECTION = 2; (function() { this.set = function(options) { - ace.mixin(this.$options, options); + oop.mixin(this.$options, options); return this; }; @@ -156,7 +158,7 @@ Search.SELECTION = 2; if (this.$options.regExp) { var needle = this.$options.needle; } else { - needle = ace.escapeRegExp(this.$options.needle); + needle = lang.escapeRegExp(this.$options.needle); } if (this.$options.wholeWord) { diff --git a/src/ace/Selection.js b/src/ace/Selection.js index 13465bf3..b781e42e 100644 --- a/src/ace/Selection.js +++ b/src/ace/Selection.js @@ -6,10 +6,11 @@ * @author Fabian Jakobs */ require.def("ace/Selection", [ - "ace/ace", + "ace/lib/oop", + "ace/lib/lang", "ace/MEventEmitter", "ace/Range" -], function(ace, MEventEmitter, Range) { +], function(oop, lang, MEventEmitter, Range) { var Selection = function(doc) { this.doc = doc; @@ -23,7 +24,7 @@ var Selection = function(doc) { (function() { - ace.implement(this, MEventEmitter); + oop.implement(this, MEventEmitter); this.isEmpty = function() { return (!this.selectionAnchor || @@ -328,7 +329,7 @@ var Selection = function(doc) { var row = this.selectionLead.row; var column = this.selectionLead.column; var line = this.doc.getLine(row); - var leftOfCursor = ace.stringReverse(line.substring(0, column)); + var leftOfCursor = lang.stringReverse(line.substring(0, column)); var match; this.nonTokenRe.lastIndex = 0; diff --git a/src/ace/TextInput.js b/src/ace/TextInput.js index ca58a185..69c590c3 100644 --- a/src/ace/TextInput.js +++ b/src/ace/TextInput.js @@ -5,7 +5,7 @@ * @license LGPLv3 * @author Fabian Jakobs */ -require.def("ace/TextInput", ["ace/ace"], function(ace) { +require.def("ace/TextInput", ["ace/lib/event"], function(event) { var TextInput = function(parentNode, host) { @@ -60,23 +60,23 @@ var TextInput = function(parentNode, host) { text.select(); }; - ace.addListener(text, "keypress", onTextInput); - ace.addListener(text, "textInput", onTextInput); - ace.addListener(text, "paste", onTextInput); - ace.addListener(text, "propertychange", onTextInput); + event.addListener(text, "keypress", onTextInput); + event.addListener(text, "textInput", onTextInput); + event.addListener(text, "paste", onTextInput); + event.addListener(text, "propertychange", onTextInput); - ace.addListener(text, "copy", onCopy); - ace.addListener(text, "cut", onCut); + event.addListener(text, "copy", onCopy); + event.addListener(text, "cut", onCut); - ace.addListener(text, "compositionstart", onCompositionStart); - ace.addListener(text, "compositionupdate", onCompositionUpdate); - ace.addListener(text, "compositionend", onCompositionEnd); + event.addListener(text, "compositionstart", onCompositionStart); + event.addListener(text, "compositionupdate", onCompositionUpdate); + event.addListener(text, "compositionend", onCompositionEnd); - ace.addListener(text, "blur", function() { + event.addListener(text, "blur", function() { host.onBlur(); }); - ace.addListener(text, "focus", function() { + event.addListener(text, "focus", function() { host.onFocus(); }); diff --git a/src/ace/VirtualRenderer.js b/src/ace/VirtualRenderer.js index 1e4032b1..c07ac76f 100644 --- a/src/ace/VirtualRenderer.js +++ b/src/ace/VirtualRenderer.js @@ -8,6 +8,8 @@ require.def("ace/VirtualRenderer", [ "ace/ace", + "ace/lang/oop", + "ace/lang/lang", "ace/layer/Gutter", "ace/layer/Marker", "ace/layer/Text", @@ -46,7 +48,7 @@ var VirtualRenderer = function(container) { this.layers = [ this.$markerLayer, textLayer, this.$cursorLayer ]; 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; @@ -66,8 +68,8 @@ var VirtualRenderer = function(container) { self.lineHeight = textLayer.getLineHeight(); self.onResize(); }); - ace.addListener(this.$gutter, "click", ace.bind(this.$onGutterClick, this)); - ace.addListener(this.$gutter, "dblclick", ace.bind(this.$onGutterClick, this)); + ace.addListener(this.$gutter, "click", lang.bind(this.$onGutterClick, this)); + ace.addListener(this.$gutter, "dblclick", lang.bind(this.$onGutterClick, this)); }; (function() { diff --git a/src/ace/layer/Cursor.js b/src/ace/layer/Cursor.js index aa11fdfd..e39b6e61 100644 --- a/src/ace/layer/Cursor.js +++ b/src/ace/layer/Cursor.js @@ -5,7 +5,7 @@ * @license LGPLv3 * @author Fabian Jakobs */ -require.def("ace/layer/Cursor", ["ace/ace"], function(ace) { +require.def("ace/layer/Cursor", ["ace/lib/dom"], function(dom) { var Cursor = function(parentEl) { this.element = document.createElement("div"); @@ -30,9 +30,9 @@ var Cursor = function(parentEl) { column : this.doc.documentToScreenColumn(position.row, position.column) }; if (overwrite) { - ace.addCssClass(this.cursor, "ace_overwrite"); + dom.addCssClass(this.cursor, "ace_overwrite"); } else { - ace.removeCssClass(this.cursor, "ace_overwrite"); + dom.removeCssClass(this.cursor, "ace_overwrite"); } }; diff --git a/src/ace/layer/Text.js b/src/ace/layer/Text.js index 0e87ecb4..278f1e67 100644 --- a/src/ace/layer/Text.js +++ b/src/ace/layer/Text.js @@ -5,7 +5,7 @@ * @license LGPLv3 * @author Fabian Jakobs */ -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) { this.element = document.createElement("div"); @@ -18,7 +18,7 @@ var Text = function(parentEl) { (function() { - ace.implement(this, MEventEmitter); + oop.implement(this, MEventEmitter); this.EOF_CHAR = "¶"; this.EOL_CHAR = "¬"; @@ -67,7 +67,7 @@ var Text = function(parentEl) { style.overflow = "visible"; for (var prop in this.$fontStyles) { - var value = ace.computedStyle(this.element, prop); + var value = dom.computedStyle(this.element, prop); style[prop] = value; } diff --git a/src/ace/mode/Css.js b/src/ace/mode/Css.js index 97b98900..652c8229 100644 --- a/src/ace/mode/Css.js +++ b/src/ace/mode/Css.js @@ -7,18 +7,18 @@ */ require.def("ace/mode/Css", [ - "ace/ace", + "ace/lib/oop", "ace/mode/Text", "ace/Tokenizer", "ace/mode/CssHighlightRules", "ace/mode/MatchingBraceOutdent" - ], function(ace, TextMode, Tokenizer, CssHighlightRules, MatchingBraceOutdent) { + ], function(oop, TextMode, Tokenizer, CssHighlightRules, MatchingBraceOutdent) { var Css = function() { this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules()); this.$outdent = new MatchingBraceOutdent(); }; -ace.inherits(Css, TextMode); +oop.inherits(Css, TextMode); (function() { diff --git a/src/ace/mode/CssHighlightRules.js b/src/ace/mode/CssHighlightRules.js index 06b9c39b..a0a99f85 100644 --- a/src/ace/mode/CssHighlightRules.js +++ b/src/ace/mode/CssHighlightRules.js @@ -7,13 +7,14 @@ */ require.def("ace/mode/CssHighlightRules", [ - "ace/ace", + "ace/lib/oop", + "ace/lib/lang", "ace/mode/TextHighlightRules" - ], function(ace, TextHighlightRules) { + ], function(oop, lang, TextHighlightRules) { var CssHighlightRules = function() { - var properties = ace.arrayToMap( + var properties = lang.arrayToMap( ("azimuth|background-attachment|background-color|background-image|" + "background-position|background-repeat|background|border-bottom-color|" + "border-bottom-style|border-bottom-width|border-bottom|border-collapse|" + @@ -40,11 +41,11 @@ var CssHighlightRules = function() { "z-index").split("|") ); - var functions = ace.arrayToMap( + var functions = lang.arrayToMap( ("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|" + "block|bold|bolder|both|bottom|break-all|break-word|capitalize|center|" + "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; }); diff --git a/src/ace/mode/DocCommentHighlightRules.js b/src/ace/mode/DocCommentHighlightRules.js index 69301f86..675a37e3 100644 --- a/src/ace/mode/DocCommentHighlightRules.js +++ b/src/ace/mode/DocCommentHighlightRules.js @@ -7,9 +7,9 @@ */ require.def("ace/mode/DocCommentHighlightRules", [ - "ace/ace", + "oop/oop", "ace/mode/TextHighlightRules" - ], function(ace, TextHighlightRules) { + ], function(oop, TextHighlightRules) { var DocCommentHighlightRules = function() { @@ -34,7 +34,7 @@ var DocCommentHighlightRules = function() { }; }; -ace.inherits(DocCommentHighlightRules, TextHighlightRules); +oop.inherits(DocCommentHighlightRules, TextHighlightRules); (function() { diff --git a/src/ace/mode/Html.js b/src/ace/mode/Html.js index 435fdac6..87c8e33c 100644 --- a/src/ace/mode/Html.js +++ b/src/ace/mode/Html.js @@ -7,13 +7,13 @@ */ require.def("ace/mode/Html", [ - "ace/ace", + "ace/lib/oop", "ace/mode/Text", "ace/mode/JavaScript", "ace/mode/Css", "ace/Tokenizer", "ace/mode/HtmlHighlightRules" - ], function(ace, TextMode, JavaScriptMode, CssMode, Tokenizer, HtmlHighlightRules) { + ], function(oop, TextMode, JavaScriptMode, CssMode, Tokenizer, HtmlHighlightRules) { var Html = function() { this.$tokenizer = new Tokenizer(new HtmlHighlightRules().getRules()); @@ -21,7 +21,7 @@ var Html = function() { this.$js = new JavaScriptMode(); this.$css = new CssMode(); }; -ace.inherits(Html, TextMode); +oop.inherits(Html, TextMode); (function() { diff --git a/src/ace/mode/HtmlHighlightRules.js b/src/ace/mode/HtmlHighlightRules.js index 58da4eda..21e7b07c 100644 --- a/src/ace/mode/HtmlHighlightRules.js +++ b/src/ace/mode/HtmlHighlightRules.js @@ -7,11 +7,11 @@ */ require.def("ace/mode/HtmlHighlightRules", [ - "ace/ace", + "ace/lib/oop", "ace/mode/CssHighlightRules", "ace/mode/JavaScriptHighlightRules", "ace/mode/TextHighlightRules" - ], function(ace, CssHighlightRules, JavaScriptHighlightRules, TextHighlightRules) { + ], function(oop, CssHighlightRules, JavaScriptHighlightRules, TextHighlightRules) { var HtmlHighlightRules = function() { @@ -147,7 +147,7 @@ var HtmlHighlightRules = function() { }); }; -ace.inherits(HtmlHighlightRules, TextHighlightRules); +oop.inherits(HtmlHighlightRules, TextHighlightRules); return HtmlHighlightRules; }); diff --git a/src/ace/mode/JavaScript.js b/src/ace/mode/JavaScript.js index 9aab2c8f..c5833baa 100644 --- a/src/ace/mode/JavaScript.js +++ b/src/ace/mode/JavaScript.js @@ -7,18 +7,19 @@ */ require.def("ace/mode/JavaScript", [ - "ace/ace", + "ace/lib/oop", "ace/mode/Text", "ace/Tokenizer", "ace/mode/JavaScriptHighlightRules", - "ace/mode/MatchingBraceOutdent" - ], function(ace, TextMode, Tokenizer, JavaScriptHighlightRules, MatchingBraceOutdent) { + "ace/mode/MatchingBraceOutdent", + "ace/Range" + ], function(oop, TextMode, Tokenizer, JavaScriptHighlightRules, MatchingBraceOutdent, Range) { var JavaScript = function() { this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules()); this.$outdent = new MatchingBraceOutdent(); }; -ace.inherits(JavaScript, TextMode); +oop.inherits(JavaScript, TextMode); (function() { @@ -35,7 +36,7 @@ ace.inherits(JavaScript, TextMode); } 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++) { var line = doc.getLine(i).replace(re, "$1"); diff --git a/src/ace/mode/JavaScriptHighlightRules.js b/src/ace/mode/JavaScriptHighlightRules.js index 7483ecfd..c79d73d8 100644 --- a/src/ace/mode/JavaScriptHighlightRules.js +++ b/src/ace/mode/JavaScriptHighlightRules.js @@ -7,10 +7,10 @@ */ require.def("ace/mode/JavaScriptHighlightRules", [ - "ace/ace", + "ace/lib/oop", "ace/mode/DocCommentHighlightRules", "ace/mode/TextHighlightRules" - ], function(ace, DocCommentHighlightRules, TextHighlightRules) { + ], function(oop, DocCommentHighlightRules, TextHighlightRules) { JavaScriptHighlightRules = function() { @@ -126,7 +126,7 @@ JavaScriptHighlightRules = function() { this.$rules["doc-start"][0].next = "start"; }; -ace.inherits(JavaScriptHighlightRules, TextHighlightRules); +oop.inherits(JavaScriptHighlightRules, TextHighlightRules); return JavaScriptHighlightRules; }); \ No newline at end of file diff --git a/src/ace/mode/Xml.js b/src/ace/mode/Xml.js index a334a1d3..37417386 100644 --- a/src/ace/mode/Xml.js +++ b/src/ace/mode/Xml.js @@ -7,17 +7,17 @@ */ require.def("ace/mode/Xml", [ - "ace/ace", + "ace/lib/oop", "ace/mode/Text", "ace/Tokenizer", "ace/mode/XmlHighlightRules" - ], function(ace, TextMode, Tokenizer, XmlHighlightRules) { + ], function(oop, TextMode, Tokenizer, XmlHighlightRules) { var Xml = function() { this.$tokenizer = new Tokenizer(new XmlHighlightRules().getRules()); }; -ace.inherits(Xml, TextMode); +oop.inherits(Xml, TextMode); (function() { diff --git a/src/ace/mode/XmlHighlightRules.js b/src/ace/mode/XmlHighlightRules.js index f56eb9eb..e0670ee7 100644 --- a/src/ace/mode/XmlHighlightRules.js +++ b/src/ace/mode/XmlHighlightRules.js @@ -7,9 +7,9 @@ */ require.def("ace/mode/XmlHighlightRules", [ - "ace/ace", + "ace/lib/oop", "ace/mode/TextHighlightRules" - ], function(ace, TextHighlightRules) { + ], function(oop, TextHighlightRules) { var XmlHighlightRules = function() { @@ -81,7 +81,7 @@ var XmlHighlightRules = function() { }; }; -ace.inherits(XmlHighlightRules, TextHighlightRules); +oop.inherits(XmlHighlightRules, TextHighlightRules); return XmlHighlightRules; }); \ No newline at end of file