From c2805e03c84b6e598556fd06d1ede7aaeea7ce9c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 6 Mar 2012 16:17:54 -0800 Subject: Squashed commit FileIO-Build-Candidate into Master Fixing issues with HTML and CSS URLs. Adjusted RegEx logic. Also code a mirror update and undo/redo changes were merged into this request. Signed-off-by: Valerio Virgillito --- 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