diff options
author | Valerio Virgillito | 2012-02-14 11:07:21 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-14 11:07:21 -0800 |
commit | f060190a3bffd9a16718f2ce0499699103d46372 (patch) | |
tree | a308fe7eacec2156c8212dff0892a3de925d5f9a /js/codemirror/mode/css | |
parent | f766cc203f30ea43ae8b83cf4b65d45cc4435ee9 (diff) | |
parent | 33bc9d62b8e6694500bf14d5b18187bd99a520a3 (diff) | |
download | ninja-f060190a3bffd9a16718f2ce0499699103d46372.tar.gz |
Merge branch 'FileIO' of https://github.com/joseeight/ninja-internal into integration
Diffstat (limited to 'js/codemirror/mode/css')
-rw-r--r-- | js/codemirror/mode/css/css.js | 124 | ||||
-rw-r--r-- | js/codemirror/mode/css/index.html | 56 |
2 files changed, 0 insertions, 180 deletions
diff --git a/js/codemirror/mode/css/css.js b/js/codemirror/mode/css/css.js deleted file mode 100644 index 6c239fcc..00000000 --- a/js/codemirror/mode/css/css.js +++ /dev/null | |||
@@ -1,124 +0,0 @@ | |||
1 | CodeMirror.defineMode("css", function(config) { | ||
2 | var indentUnit = config.indentUnit, type; | ||
3 | function ret(style, tp) {type = tp; return style;} | ||
4 | |||
5 | function tokenBase(stream, state) { | ||
6 | var ch = stream.next(); | ||
7 | if (ch == "@") {stream.eatWhile(/\w/); return ret("meta", stream.current());} | ||
8 | else if (ch == "/" && stream.eat("*")) { | ||
9 | state.tokenize = tokenCComment; | ||
10 | return tokenCComment(stream, state); | ||
11 | } | ||
12 | else if (ch == "<" && stream.eat("!")) { | ||
13 | state.tokenize = tokenSGMLComment; | ||
14 | return tokenSGMLComment(stream, state); | ||
15 | } | ||
16 | else if (ch == "=") ret(null, "compare"); | ||
17 | else if ((ch == "~" || ch == "|") && stream.eat("=")) return ret(null, "compare"); | ||
18 | else if (ch == "\"" || ch == "'") { | ||
19 | state.tokenize = tokenString(ch); | ||
20 | return state.tokenize(stream, state); | ||
21 | } | ||
22 | else if (ch == "#") { | ||
23 | stream.eatWhile(/\w/); | ||
24 | return ret("atom", "hash"); | ||
25 | } | ||
26 | else if (ch == "!") { | ||
27 | stream.match(/^\s*\w*/); | ||
28 | return ret("keyword", "important"); | ||
29 | } | ||
30 | else if (/\d/.test(ch)) { | ||
31 | stream.eatWhile(/[\w.%]/); | ||
32 | return ret("number", "unit"); | ||
33 | } | ||
34 | else if (/[,.+>*\/]/.test(ch)) { | ||
35 | return ret(null, "select-op"); | ||
36 | } | ||
37 | else if (/[;{}:\[\]]/.test(ch)) { | ||
38 | return ret(null, ch); | ||
39 | } | ||
40 | else { | ||
41 | stream.eatWhile(/[\w\\\-_]/); | ||
42 | return ret("variable", "variable"); | ||
43 | } | ||
44 | } | ||
45 | |||
46 | function tokenCComment(stream, state) { | ||
47 | var maybeEnd = false, ch; | ||
48 | while ((ch = stream.next()) != null) { | ||
49 | if (maybeEnd && ch == "/") { | ||
50 | state.tokenize = tokenBase; | ||
51 | break; | ||
52 | } | ||
53 | maybeEnd = (ch == "*"); | ||
54 | } | ||
55 | return ret("comment", "comment"); | ||
56 | } | ||
57 | |||
58 | function tokenSGMLComment(stream, state) { | ||
59 | var dashes = 0, ch; | ||
60 | while ((ch = stream.next()) != null) { | ||
61 | if (dashes >= 2 && ch == ">") { | ||
62 | state.tokenize = tokenBase; | ||
63 | break; | ||
64 | } | ||
65 | dashes = (ch == "-") ? dashes + 1 : 0; | ||
66 | } | ||
67 | return ret("comment", "comment"); | ||
68 | } | ||
69 | |||
70 | function tokenString(quote) { | ||
71 | return function(stream, state) { | ||
72 | var escaped = false, ch; | ||
73 | while ((ch = stream.next()) != null) { | ||
74 | if (ch == quote && !escaped) | ||
75 | break; | ||
76 | escaped = !escaped && ch == "\\"; | ||
77 | } | ||
78 | if (!escaped) state.tokenize = tokenBase; | ||
79 | return ret("string", "string"); | ||
80 | }; | ||
81 | } | ||
82 | |||
83 | return { | ||
84 | startState: function(base) { | ||
85 | return {tokenize: tokenBase, | ||
86 | baseIndent: base || 0, | ||
87 | stack: []}; | ||
88 | }, | ||
89 | |||
90 | token: function(stream, state) { | ||
91 | if (stream.eatSpace()) return null; | ||
92 | var style = state.tokenize(stream, state); | ||
93 | |||
94 | var context = state.stack[state.stack.length-1]; | ||
95 | if (type == "hash" && context == "rule") style = "atom"; | ||
96 | else if (style == "variable") { | ||
97 | if (context == "rule") style = "number"; | ||
98 | else if (!context || context == "@media{") style = "tag"; | ||
99 | } | ||
100 | |||
101 | if (context == "rule" && /^[\{\};]$/.test(type)) | ||
102 | state.stack.pop(); | ||
103 | if (type == "{") { | ||
104 | if (context == "@media") state.stack[state.stack.length-1] = "@media{"; | ||
105 | else state.stack.push("{"); | ||
106 | } | ||
107 | else if (type == "}") state.stack.pop(); | ||
108 | else if (type == "@media") state.stack.push("@media"); | ||
109 | else if (context == "{" && type != "comment") state.stack.push("rule"); | ||
110 | return style; | ||
111 | }, | ||
112 | |||
113 | indent: function(state, textAfter) { | ||
114 | var n = state.stack.length; | ||
115 | if (/^\}/.test(textAfter)) | ||
116 | n -= state.stack[state.stack.length-1] == "rule" ? 2 : 1; | ||
117 | return state.baseIndent + n * indentUnit; | ||
118 | }, | ||
119 | |||
120 | electricChars: "}" | ||
121 | }; | ||
122 | }); | ||
123 | |||
124 | CodeMirror.defineMIME("text/css", "css"); | ||
diff --git a/js/codemirror/mode/css/index.html b/js/codemirror/mode/css/index.html deleted file mode 100644 index 7d01e366..00000000 --- a/js/codemirror/mode/css/index.html +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | <!doctype html> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>CodeMirror 2: CSS mode</title> | ||
5 | <link rel="stylesheet" href="../../lib/codemirror.css"> | ||
6 | <script src="../../lib/codemirror.js"></script> | ||
7 | <script src="css.js"></script> | ||
8 | <link rel="stylesheet" href="../../theme/default.css"> | ||
9 | <style>.CodeMirror {background: #f8f8f8;}</style> | ||
10 | <link rel="stylesheet" href="../../css/docs.css"> | ||
11 | </head> | ||
12 | <body> | ||
13 | <h1>CodeMirror 2: CSS mode</h1> | ||
14 | <form><textarea id="code" name="code"> | ||
15 | /* Some example CSS */ | ||
16 | |||
17 | @import url("something.css"); | ||
18 | |||
19 | body { | ||
20 | margin: 0; | ||
21 | padding: 3em 6em; | ||
22 | font-family: tahoma, arial, sans-serif; | ||
23 | color: #000; | ||
24 | } | ||
25 | |||
26 | #navigation a { | ||
27 | font-weight: bold; | ||
28 | text-decoration: none !important; | ||
29 | } | ||
30 | |||
31 | h1 { | ||
32 | font-size: 2.5em; | ||
33 | } | ||
34 | |||
35 | h2 { | ||
36 | font-size: 1.7em; | ||
37 | } | ||
38 | |||
39 | h1:before, h2:before { | ||
40 | content: "::"; | ||
41 | } | ||
42 | |||
43 | code { | ||
44 | font-family: courier, monospace; | ||
45 | font-size: 80%; | ||
46 | color: #418A8A; | ||
47 | } | ||
48 | </textarea></form> | ||
49 | <script> | ||
50 | var editor = CodeMirror.fromTextArea(document.getElementById("code"), {}); | ||
51 | </script> | ||
52 | |||
53 | <p><strong>MIME types defined:</strong> <code>text/css</code>.</p> | ||
54 | |||
55 | </body> | ||
56 | </html> | ||