diff options
author | Pushkar Joshi | 2012-05-22 13:22:26 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-05-22 13:22:26 -0700 |
commit | 01dbc1f329a95bc7e3b93224543d88ad5bdbd315 (patch) | |
tree | ceb527713554f506c537168e36a10452cd09ad10 /imports/codemirror/mode/properties/properties.js | |
parent | b9262c831952e77135b79c2de7c455d5e7ff0589 (diff) | |
parent | c37a876b373ddc7cb19277aaeaa6bb2d2d5a50ac (diff) | |
download | ninja-01dbc1f329a95bc7e3b93224543d88ad5bdbd315.tar.gz |
Merge branch 'master' into brushtool
Diffstat (limited to 'imports/codemirror/mode/properties/properties.js')
-rwxr-xr-x | imports/codemirror/mode/properties/properties.js | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/imports/codemirror/mode/properties/properties.js b/imports/codemirror/mode/properties/properties.js index 2529505b..d3a13c76 100755 --- a/imports/codemirror/mode/properties/properties.js +++ b/imports/codemirror/mode/properties/properties.js | |||
@@ -1,21 +1,23 @@ | |||
1 | CodeMirror.defineMode("properties", function() { | 1 | CodeMirror.defineMode("properties", function() { |
2 | return { | 2 | return { |
3 | token: function(stream, state) { | 3 | token: function(stream, state) { |
4 | var sol = stream.sol(); | 4 | var sol = stream.sol() || state.afterSection; |
5 | var eol = stream.eol(); | 5 | var eol = stream.eol(); |
6 | 6 | ||
7 | state.afterSection = false; | ||
8 | |||
7 | if (sol) { | 9 | if (sol) { |
8 | if (state.nextMultiline) { | 10 | if (state.nextMultiline) { |
9 | state.inMultiline = true; | 11 | state.inMultiline = true; |
10 | state.nextMultiline = false; | 12 | state.nextMultiline = false; |
11 | } else { | 13 | } else { |
12 | state.position = "key"; | 14 | state.position = "def"; |
13 | } | 15 | } |
14 | } | 16 | } |
15 | 17 | ||
16 | if (eol && ! state.nextMultiline) { | 18 | if (eol && ! state.nextMultiline) { |
17 | state.inMultiline = false; | 19 | state.inMultiline = false; |
18 | state.position = "key"; | 20 | state.position = "def"; |
19 | } | 21 | } |
20 | 22 | ||
21 | if (sol) { | 23 | if (sol) { |
@@ -24,16 +26,18 @@ CodeMirror.defineMode("properties", function() { | |||
24 | 26 | ||
25 | var ch = stream.next(); | 27 | var ch = stream.next(); |
26 | 28 | ||
27 | if (sol && (ch === "#" || ch === "!")) { | 29 | if (sol && (ch === "#" || ch === "!" || ch === ";")) { |
28 | state.position = "comment"; | 30 | state.position = "comment"; |
29 | stream.skipToEnd(); | 31 | stream.skipToEnd(); |
30 | return "comment"; | 32 | return "comment"; |
31 | 33 | } else if (sol && ch === "[") { | |
34 | state.afterSection = true; | ||
35 | stream.skipTo("]"); stream.eat("]"); | ||
36 | return "header"; | ||
32 | } else if (ch === "=" || ch === ":") { | 37 | } else if (ch === "=" || ch === ":") { |
33 | state.position = "value"; | 38 | state.position = "quote"; |
34 | return "equals"; | 39 | return null; |
35 | 40 | } else if (ch === "\\" && state.position === "quote") { | |
36 | } else if (ch === "\\" && state.position === "value") { | ||
37 | if (stream.next() !== "u") { // u = Unicode sequence \u1234 | 41 | if (stream.next() !== "u") { // u = Unicode sequence \u1234 |
38 | // Multiline value | 42 | // Multiline value |
39 | state.nextMultiline = true; | 43 | state.nextMultiline = true; |
@@ -45,9 +49,10 @@ CodeMirror.defineMode("properties", function() { | |||
45 | 49 | ||
46 | startState: function() { | 50 | startState: function() { |
47 | return { | 51 | return { |
48 | position : "key", // Current position, "key", "value" or "comment" | 52 | position : "def", // Current position, "def", "quote" or "comment" |
49 | nextMultiline : false, // Is the next line multiline value | 53 | nextMultiline : false, // Is the next line multiline value |
50 | inMultiline : false // Is the current line a multiline value | 54 | inMultiline : false, // Is the current line a multiline value |
55 | afterSection : false // Did we just open a section | ||
51 | }; | 56 | }; |
52 | } | 57 | } |
53 | 58 | ||
@@ -55,3 +60,4 @@ CodeMirror.defineMode("properties", function() { | |||
55 | }); | 60 | }); |
56 | 61 | ||
57 | CodeMirror.defineMIME("text/x-properties", "properties"); | 62 | CodeMirror.defineMIME("text/x-properties", "properties"); |
63 | CodeMirror.defineMIME("text/x-ini", "properties"); | ||