diff options
author | Nivesh Rajbhandari | 2012-03-07 10:32:20 -0800 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-03-07 10:32:20 -0800 |
commit | f5b0162a9b148589f0ccc65a0332695ea6fd6be3 (patch) | |
tree | e62ae1bc8a14dfa60cca05d40227c13dbfa2746a /imports/codemirror/mode/properties/properties.js | |
parent | 443a23289171bb72324e740d8eaa041968a1de99 (diff) | |
parent | cef07085443b7c31e878daaad083b7408c57e104 (diff) | |
download | ninja-f5b0162a9b148589f0ccc65a0332695ea6fd6be3.tar.gz |
Merge branch 'refs/heads/ninja-internal' into WebGLFixes
Diffstat (limited to 'imports/codemirror/mode/properties/properties.js')
-rwxr-xr-x | imports/codemirror/mode/properties/properties.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/imports/codemirror/mode/properties/properties.js b/imports/codemirror/mode/properties/properties.js new file mode 100755 index 00000000..2529505b --- /dev/null +++ b/imports/codemirror/mode/properties/properties.js | |||
@@ -0,0 +1,57 @@ | |||
1 | CodeMirror.defineMode("properties", function() { | ||
2 | return { | ||
3 | token: function(stream, state) { | ||
4 | var sol = stream.sol(); | ||
5 | var eol = stream.eol(); | ||
6 | |||
7 | if (sol) { | ||
8 | if (state.nextMultiline) { | ||
9 | state.inMultiline = true; | ||
10 | state.nextMultiline = false; | ||
11 | } else { | ||
12 | state.position = "key"; | ||
13 | } | ||
14 | } | ||
15 | |||
16 | if (eol && ! state.nextMultiline) { | ||
17 | state.inMultiline = false; | ||
18 | state.position = "key"; | ||
19 | } | ||
20 | |||
21 | if (sol) { | ||
22 | while(stream.eatSpace()); | ||
23 | } | ||
24 | |||
25 | var ch = stream.next(); | ||
26 | |||
27 | if (sol && (ch === "#" || ch === "!")) { | ||
28 | state.position = "comment"; | ||
29 | stream.skipToEnd(); | ||
30 | return "comment"; | ||
31 | |||
32 | } else if (ch === "=" || ch === ":") { | ||
33 | state.position = "value"; | ||
34 | return "equals"; | ||
35 | |||
36 | } else if (ch === "\\" && state.position === "value") { | ||
37 | if (stream.next() !== "u") { // u = Unicode sequence \u1234 | ||
38 | // Multiline value | ||
39 | state.nextMultiline = true; | ||
40 | } | ||
41 | } | ||
42 | |||
43 | return state.position; | ||
44 | }, | ||
45 | |||
46 | startState: function() { | ||
47 | return { | ||
48 | position : "key", // Current position, "key", "value" or "comment" | ||
49 | nextMultiline : false, // Is the next line multiline value | ||
50 | inMultiline : false // Is the current line a multiline value | ||
51 | }; | ||
52 | } | ||
53 | |||
54 | }; | ||
55 | }); | ||
56 | |||
57 | CodeMirror.defineMIME("text/x-properties", "properties"); | ||