diff --git a/css/editor.css b/css/editor.css
index d30aac52..79d7ac30 100644
--- a/css/editor.css
+++ b/css/editor.css
@@ -33,7 +33,7 @@
font-size: 12px;
-webkit-box-sizing: border-box;
- box-sizing: border-box;
+ box-sizing: border-box;
}
.layer {
@@ -74,6 +74,18 @@
color: blue;
}
+.line .buildin-constant {
+ color: rgb(88, 72, 246);
+}
+
+.line .library-constant {
+ color: rgb(6, 150, 14);
+}
+
+.line .buildin-function {
+ color: rgb(60, 76, 114);
+}
+
.line .string {
color: rgb(3, 106, 7);
}
diff --git a/demo/editor.html b/demo/editor.html
index 9f1e9a7f..7b5e060e 100644
--- a/demo/editor.html
+++ b/demo/editor.html
@@ -38,6 +38,8 @@
+
+
@@ -65,6 +67,7 @@
+
@@ -92,6 +95,7 @@ var modes = {
text: new ace.mode.Text(),
xml: new ace.mode.Xml(),
html: new ace.mode.Html(),
+ css: new ace.mode.Css(),
javascript: new ace.mode.JavaScript()
};
@@ -138,15 +142,17 @@ ace.addListener(container, "drop", function(e) {
if (window.FileReader) {
var reader = new FileReader();
reader.onload = function(e) {
- editor.clearSelection();
- editor.moveCursorTo(0, 0);
- editor.selectFileEnd();
+ editor.getSelection().selectAll();
var mode = "text";
if (/^.*\.js$/i.test(file.name)) {
mode = "javascript";
} else if (/^.*\.xml$/i.test(file.name)) {
mode = "xml";
+ } else if (/^.*\.html$/i.test(file.name)) {
+ mode = "html";
+ } else if (/^.*\.css$/i.test(file.name)) {
+ mode = "css";
}
editor.onTextInput(reader.result);
diff --git a/jsTestDriver.conf b/jsTestDriver.conf
index 48f4c221..507fb0c7 100644
--- a/jsTestDriver.conf
+++ b/jsTestDriver.conf
@@ -3,6 +3,7 @@ server: http://localhost:4224
load:
- src/ace.js
+ - src/MEventEmitter.js
- src/mode/Text.js
- src/mode/*.js
- src/*.js
diff --git a/src/Tokenizer.js b/src/Tokenizer.js
index 8313e900..194ce446 100644
--- a/src/Tokenizer.js
+++ b/src/Tokenizer.js
@@ -39,7 +39,7 @@ ace.Tokenizer.prototype.getLineTokens = function(line, startState) {
if (re.lastIndex == lastIndex) { throw new Error("tokenizer error"); }
lastIndex = re.lastIndex;
-// window.LOG && jstestdriver.console.log(currentState, match);
+ window.LOG && jstestdriver.console.log(currentState, match);
for ( var i = 0; i < state.length; i++) {
if (match[i + 1]) {
@@ -79,7 +79,7 @@ ace.Tokenizer.prototype.getLineTokens = function(line, startState) {
tokens.push(token);
}
-// window.LOG && jstestdriver.console.log(tokens, currentState);
+ window.LOG && jstestdriver.console.log(tokens, currentState);
return {
tokens : tokens,
diff --git a/src/mode/Css.js b/src/mode/Css.js
new file mode 100644
index 00000000..d4683c6b
--- /dev/null
+++ b/src/mode/Css.js
@@ -0,0 +1,6 @@
+ace.provide("ace.mode.Css");
+
+ace.mode.Css = function() {
+ this.$tokenizer = new ace.Tokenizer(new ace.mode.CssHighlightRules().getRules());
+};
+ace.inherits(ace.mode.Css, ace.mode.Text);
diff --git a/src/mode/CssHighlightRules.js b/src/mode/CssHighlightRules.js
new file mode 100644
index 00000000..2044974f
--- /dev/null
+++ b/src/mode/CssHighlightRules.js
@@ -0,0 +1,174 @@
+ace.provide("ace.mode.CssHighlightRules");
+
+ace.mode.CssHighlightRules = function() {
+
+ var properties = {
+ "width": 1,
+ "height": 1,
+ "top": 1,
+ "left": 1,
+ "right": 1,
+ "bottom": 1,
+ "overflow": 1,
+ "overflow-x": 1,
+ "overflow-y": 1,
+ "background": 1,
+ "font": 1,
+ "font-style": 1,
+ "font-family": 1,
+ "font-size": 1,
+ "text-align": 1,
+ "white-space": 1,
+ "color": 1,
+ "z-index": 1,
+ "position": 1,
+ "cursor": 1,
+ "box-sizing": 1,
+ "-webkit-box-sizing": 1,
+ "-moz-box-sizing": 1,
+ "margin": 1,
+ "padding": 1,
+ "padding-top": 1,
+ "padding-right": 1,
+ "padding-bottom": 1,
+ "padding-left": 1,
+ "border": 1,
+ "border-top": 1,
+ "border-right": 1,
+ "border-left": 1,
+ "border-bottom": 1
+ };
+
+ var functions = {
+ "rgb": 1,
+ "rgba": 1
+ };
+
+ var constants = {
+ "absolute": 1,
+ "relative": 1,
+ "fixed": 1,
+ "solid": 1,
+ "hidden": 1,
+ "scroll": 1,
+ "no-wrap": 1
+ };
+
+ // regexp must not have capturing parentheses. Use (?:) instead.
+ // regexps are ordered -> the first match is used
+
+ var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
+
+ function ic(str) {
+ var re = [];
+ var chars = str.split("");
+ for (var i=0; i |