diff --git a/demo/editor.html b/demo/editor.html
index 20bc64a7..6505694e 100644
--- a/demo/editor.html
+++ b/demo/editor.html
@@ -19,7 +19,7 @@
-
+
diff --git a/src/BackgroundTokenizer.js b/src/BackgroundTokenizer.js
index 6b441601..4698b31c 100644
--- a/src/BackgroundTokenizer.js
+++ b/src/BackgroundTokenizer.js
@@ -1,5 +1,4 @@
-if (!window.ace)
- ace = {};
+ace.provide("ace.BackgroundTokenizer");
ace.BackgroundTokenizer = function(tokenizer, onUpdate, onComplete) {
this.running = false;
diff --git a/src/CursorLayer.js b/src/CursorLayer.js
index 76ef0640..dcf4c2a7 100644
--- a/src/CursorLayer.js
+++ b/src/CursorLayer.js
@@ -1,5 +1,4 @@
-if (!window.ace)
- ace = {};
+ace.provide("ace.CursorLayer");
ace.CursorLayer = function(parentEl) {
this.element = document.createElement("div");
diff --git a/src/Editor.js b/src/Editor.js
index 0cd9e1a7..58353809 100644
--- a/src/Editor.js
+++ b/src/Editor.js
@@ -1,5 +1,4 @@
-if (!window.ace)
- ace = {};
+ace.provide("ace.Editor");
ace.Editor = function(doc, renderer) {
var container = renderer.getContainerElement();
diff --git a/src/GutterLayer.js b/src/GutterLayer.js
index 42e027cd..4256a4e9 100644
--- a/src/GutterLayer.js
+++ b/src/GutterLayer.js
@@ -1,5 +1,4 @@
-if (!window.ace)
- ace = {};
+ace.provide("ace.GutterLayer");
ace.GutterLayer = function(parentEl) {
this.element = document.createElement("div");
diff --git a/src/JavaScript.js b/src/JavaScript.js
index 254e6e94..f6747ffe 100644
--- a/src/JavaScript.js
+++ b/src/JavaScript.js
@@ -1,114 +1,111 @@
-if (!window.ace)
- ace = {};
+ace.provide("ace.JavaScript");
(function() {
- ace.JavaScript = {};
+var keywords = {
+ "break" : 1,
+ "case" : 1,
+ "catch" : 1,
+ "continue" : 1,
+ "default" : 1,
+ "delete" : 1,
+ "do" : 1,
+ "else" : 1,
+ "finally" : 1,
+ "for" : 1,
+ "function" : 1,
+ "if" : 1,
+ "in" : 1,
+ "instanceof" : 1,
+ "new" : 1,
+ "return" : 1,
+ "switch" : 1,
+ "throw" : 1,
+ "try" : 1,
+ "typeof" : 1,
+ "var" : 1,
+ "while" : 1,
+ "with" : 1
+};
- var keywords = {
- "break" : 1,
- "case" : 1,
- "catch" : 1,
- "continue" : 1,
- "default" : 1,
- "delete" : 1,
- "do" : 1,
- "else" : 1,
- "finally" : 1,
- "for" : 1,
- "function" : 1,
- "if" : 1,
- "in" : 1,
- "instanceof" : 1,
- "new" : 1,
- "return" : 1,
- "switch" : 1,
- "throw" : 1,
- "try" : 1,
- "typeof" : 1,
- "var" : 1,
- "while" : 1,
- "with" : 1
- };
+// regexp must not have capturing parentheses
+// regexps are ordered -> the first match is used
- // regexp must not have capturing parentheses
- // regexps are ordered -> the first match is used
-
- ace.JavaScript.RULES = {
- start : [ {
- token : "comment",
- regex : "\\/\\/.*$"
- }, {
- token : "comment", // multi line comment in one line
- regex : "\\/\\*.*?\\*\\/"
- }, {
- token : "comment", // multi line comment start
- regex : "\\/\\*.*$",
- next : "comment"
- }, {
- token : "string", // single line
- regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
- }, {
- token : "string", // multi line string start
- regex : '["].*\\\\$',
- next : "qqstring"
- }, {
- token : "string", // single line
- regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
- }, {
- token : "string", // multi line string start
- regex : "['].*\\\\$",
- next : "qstring"
- }, {
- token : "number", // hex
- regex : "0[xX][0-9a-fA-F]+\\b"
- }, {
- token : "number", // float
- regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
- }, {
- token : function(value) {
- if (keywords[value]) {
- return "keyword";
- }
- else {
- return "identifier";
- }
- },
- regex : "[a-zA-Z_][a-zA-Z0-9_]*\\b"
- }, {
- token : function(value) {
- // return parens[value];
- return "text";
+ace.JavaScript.RULES = {
+ start : [ {
+ token : "comment",
+ regex : "\\/\\/.*$"
+ }, {
+ token : "comment", // multi line comment in one line
+ regex : "\\/\\*.*?\\*\\/"
+ }, {
+ token : "comment", // multi line comment start
+ regex : "\\/\\*.*$",
+ next : "comment"
+ }, {
+ token : "string", // single line
+ regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
+ }, {
+ token : "string", // multi line string start
+ regex : '["].*\\\\$',
+ next : "qqstring"
+ }, {
+ token : "string", // single line
+ regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
+ }, {
+ token : "string", // multi line string start
+ regex : "['].*\\\\$",
+ next : "qstring"
+ }, {
+ token : "number", // hex
+ regex : "0[xX][0-9a-fA-F]+\\b"
+ }, {
+ token : "number", // float
+ regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
+ }, {
+ token : function(value) {
+ if (keywords[value]) {
+ return "keyword";
+ }
+ else {
+ return "identifier";
+ }
},
- regex : "[\\[\\]\\(\\)\\{\\}]"
- }, {
- token : "text",
- regex : "\\s+"
- } ],
- "comment" : [ {
- token : "comment", // closing comment
- regex : ".*?\\*\\/",
- next : "start"
- }, {
- token : "comment", // comment spanning whole line
- regex : ".+"
- } ],
- "qqstring" : [ {
- token : "string",
- regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
- next : "start"
- }, {
- token : "string",
- regex : '.+'
- } ],
- "qstring" : [ {
- token : "string",
- regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
- next : "start"
- }, {
- token : "string",
- regex : '.+'
- } ]
- };
+ regex : "[a-zA-Z_][a-zA-Z0-9_]*\\b"
+ }, {
+ token : function(value) {
+ // return parens[value];
+ return "text";
+ },
+ regex : "[\\[\\]\\(\\)\\{\\}]"
+ }, {
+ token : "text",
+ regex : "\\s+"
+ } ],
+ "comment" : [ {
+ token : "comment", // closing comment
+ regex : ".*?\\*\\/",
+ next : "start"
+ }, {
+ token : "comment", // comment spanning whole line
+ regex : ".+"
+ } ],
+ "qqstring" : [ {
+ token : "string",
+ regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
+ next : "start"
+ }, {
+ token : "string",
+ regex : '.+'
+ } ],
+ "qstring" : [ {
+ token : "string",
+ regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
+ next : "start"
+ }, {
+ token : "string",
+ regex : '.+'
+ } ]
+};
})();
\ No newline at end of file
diff --git a/src/KeyBinding.js b/src/KeyBinding.js
index 1e09a731..f7dd006c 100644
--- a/src/KeyBinding.js
+++ b/src/KeyBinding.js
@@ -1,5 +1,4 @@
-if (!window.ace)
- ace = {};
+ace.provide("ace.KeyBinding");
(function() {
diff --git a/src/MarkerLayer.js b/src/MarkerLayer.js
index 4a10916c..cfa019e2 100644
--- a/src/MarkerLayer.js
+++ b/src/MarkerLayer.js
@@ -1,5 +1,4 @@
-if (!window.ace)
- ace = {};
+ace.provide("ace.MarkerLayer");
ace.MarkerLayer = function(parentEl) {
this.element = document.createElement("div");
diff --git a/src/TextDocument.js b/src/TextDocument.js
index 5c286081..f8d26198 100644
--- a/src/TextDocument.js
+++ b/src/TextDocument.js
@@ -1,5 +1,4 @@
-if (!window.ace)
- ace = {};
+ace.provide("ace.TextDocument");
ace.TextDocument = function(text) {
this.lines = this._split(text);
diff --git a/src/TextInput.js b/src/TextInput.js
index ede8a9bd..4a3c3c25 100644
--- a/src/TextInput.js
+++ b/src/TextInput.js
@@ -1,5 +1,4 @@
-if (!window.ace)
- ace = {};
+ace.provide("ace.TextInput");
ace.TextInput = function(parentNode, host) {
diff --git a/src/TextLayer.js b/src/TextLayer.js
index bfa95410..d91ba5ed 100644
--- a/src/TextLayer.js
+++ b/src/TextLayer.js
@@ -1,5 +1,4 @@
-if (!window.ace)
- ace = {};
+ace.provide("ace.TextLayer");
ace.TextLayer = function(parentEl) {
this.element = document.createElement("div");
diff --git a/src/Tokenizer.js b/src/Tokenizer.js
index 923f605e..fb1d539e 100644
--- a/src/Tokenizer.js
+++ b/src/Tokenizer.js
@@ -1,5 +1,4 @@
-if (!window.ace)
- ace = {};
+ace.provide("ace.Tokenizer");
ace.Tokenizer = function(rules) {
this.rules = rules;
diff --git a/src/VirtualRenderer.js b/src/VirtualRenderer.js
index 1d07c96e..001adbe5 100644
--- a/src/VirtualRenderer.js
+++ b/src/VirtualRenderer.js
@@ -1,5 +1,4 @@
-if (!window.ace)
- ace = {};
+ace.provide("ace.VirtualRenderer");
ace.VirtualRenderer = function(container) {
this.container = container;
diff --git a/src/XML.js b/src/XML.js
index 96389128..842f4497 100644
--- a/src/XML.js
+++ b/src/XML.js
@@ -1,75 +1,72 @@
-if (!window.ace)
- ace = {};
+ace.provide("ace.XML");
(function() {
- ace.XML = {};
+// regexp must not have capturing parentheses
+// regexps are ordered -> the first match is used
- // regexp must not have capturing parentheses
- // regexps are ordered -> the first match is used
+ace.XML.RULES = {
+ start : [ {
+ token : "text",
+ regex : "<\\!\\[CDATA\\[",
+ next : "cdata"
+ }, {
+ token : "xml_pe",
+ regex : "<\\?.*?\\?>"
+ }, {
+ token : "comment",
+ regex : "<\\!--",
+ next : "comment"
+ }, {
+ token : "text", // opening tag
+ regex : "<",
+ next : "tag"
+ }, {
+ token : "text",
+ regex : "\\s+"
+ }, {
+ token : "text",
+ regex : ".+"
+ } ],
- ace.XML.RULES = {
- start : [ {
- token : "text",
- regex : "<\\!\\[CDATA\\[",
- next : "cdata"
- }, {
- token : "xml_pe",
- regex : "<\\?.*?\\?>"
- }, {
- token : "comment",
- regex : "<\\!--",
- next : "comment"
- }, {
- token : "text", // opening tag
- regex : "<",
- next : "tag"
- }, {
- token : "text",
- regex : "\\s+"
- }, {
- token : "text",
- regex : ".+"
- } ],
+ tag : [ {
+ token : "text",
+ regex : ">",
+ next : "start"
+ }, {
+ token : "keyword",
+ regex : "[-_a-zA-Z0-9:]+"
+ }, {
+ token : "text",
+ regex : "\\s+"
+ }, {
+ token : "string",
+ regex : '".*?"'
+ }, {
+ token : "string",
+ regex : "'.*?'"
+ } ],
- tag : [ {
- token : "text",
- regex : ">",
- next : "start"
- }, {
- token : "keyword",
- regex : "[-_a-zA-Z0-9:]+"
- }, {
- token : "text",
- regex : "\\s+"
- }, {
- token : "string",
- regex : '".*?"'
- }, {
- token : "string",
- regex : "'.*?'"
- } ],
+ cdata : [ {
+ token : "text",
+ regex : "\\]\\]>",
+ next : "start"
+ }, {
+ token : "text",
+ regex : "\\s+"
+ }, {
+ token : "text",
+ regex : ".+"
+ } ],
- cdata : [ {
- token : "text",
- regex : "\\]\\]>",
- next : "start"
- }, {
- token : "text",
- regex : "\\s+"
- }, {
- token : "text",
- regex : ".+"
- } ],
-
- comment : [ {
- token : "comment",
- regex : ".*?-->",
- next : "start"
- }, {
- token : "comment",
- regex : ".+"
- } ]
- };
+ comment : [ {
+ token : "comment",
+ regex : ".*?-->",
+ next : "start"
+ }, {
+ token : "comment",
+ regex : ".+"
+ } ]
+};
})();
\ No newline at end of file
diff --git a/src/ace.js b/src/ace.js
new file mode 100644
index 00000000..ebcef88a
--- /dev/null
+++ b/src/ace.js
@@ -0,0 +1,171 @@
+if (!window.ace)
+ ace = {};
+
+ace.provide = function(namespace) {
+ var parts = namespace.split(".");
+ var obj = window;
+ for (var i=0; i