From 51ed781953bc44bba3c70938aa57b856394cbc88 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Mon, 27 Feb 2012 14:41:21 -0800 Subject: updating to codemirror 2.22 Signed-off-by: Ananya Sen --- imports/codemirror/mode/properties/properties.js | 57 ++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 imports/codemirror/mode/properties/properties.js (limited to 'imports/codemirror/mode/properties/properties.js') 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 @@ +CodeMirror.defineMode("properties", function() { + return { + token: function(stream, state) { + var sol = stream.sol(); + var eol = stream.eol(); + + if (sol) { + if (state.nextMultiline) { + state.inMultiline = true; + state.nextMultiline = false; + } else { + state.position = "key"; + } + } + + if (eol && ! state.nextMultiline) { + state.inMultiline = false; + state.position = "key"; + } + + if (sol) { + while(stream.eatSpace()); + } + + var ch = stream.next(); + + if (sol && (ch === "#" || ch === "!")) { + state.position = "comment"; + stream.skipToEnd(); + return "comment"; + + } else if (ch === "=" || ch === ":") { + state.position = "value"; + return "equals"; + + } else if (ch === "\\" && state.position === "value") { + if (stream.next() !== "u") { // u = Unicode sequence \u1234 + // Multiline value + state.nextMultiline = true; + } + } + + return state.position; + }, + + startState: function() { + return { + position : "key", // Current position, "key", "value" or "comment" + nextMultiline : false, // Is the next line multiline value + inMultiline : false // Is the current line a multiline value + }; + } + + }; +}); + +CodeMirror.defineMIME("text/x-properties", "properties"); -- cgit v1.2.3