don't use the global ace module so often
This commit is contained in:
parent
4b98351e50
commit
a330594890
17 changed files with 77 additions and 69 deletions
|
|
@ -5,7 +5,7 @@
|
|||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @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) {
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -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 = [];
|
||||
|
|
|
|||
|
|
@ -6,8 +6,10 @@
|
|||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*/
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -6,10 +6,11 @@
|
|||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*/
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @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) {
|
||||
|
||||
|
|
@ -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();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @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) {
|
||||
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");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @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) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
});
|
||||
|
|
@ -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() {
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue