1 CodeMirror.defineMode("properties", function() {
3 token: function(stream, state) {
4 var sol = stream.sol() || state.afterSection;
5 var eol = stream.eol();
7 state.afterSection = false;
10 if (state.nextMultiline) {
11 state.inMultiline = true;
12 state.nextMultiline = false;
14 state.position = "def";
18 if (eol && ! state.nextMultiline) {
19 state.inMultiline = false;
20 state.position = "def";
24 while(stream.eatSpace());
27 var ch = stream.next();
29 if (sol && (ch === "#" || ch === "!" || ch === ";")) {
30 state.position = "comment";
33 } else if (sol && ch === "[") {
34 state.afterSection = true;
35 stream.skipTo("]"); stream.eat("]");
37 } else if (ch === "=" || ch === ":") {
38 state.position = "quote";
40 } else if (ch === "\\" && state.position === "quote") {
41 if (stream.next() !== "u") { // u = Unicode sequence \u1234
43 state.nextMultiline = true;
47 return state.position;
50 startState: function() {
52 position : "def", // Current position, "def", "quote" or "comment"
53 nextMultiline : false, // Is the next line multiline value
54 inMultiline : false, // Is the current line a multiline value
55 afterSection : false // Did we just open a section
62 CodeMirror.defineMIME("text/x-properties", "properties");
63 CodeMirror.defineMIME("text/x-ini", "properties");