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/index.html | 40 ++++++++++++++++ imports/codemirror/mode/properties/properties.css | 3 ++ imports/codemirror/mode/properties/properties.js | 57 +++++++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100755 imports/codemirror/mode/properties/index.html create mode 100755 imports/codemirror/mode/properties/properties.css create mode 100755 imports/codemirror/mode/properties/properties.js (limited to 'imports/codemirror/mode/properties') diff --git a/imports/codemirror/mode/properties/index.html b/imports/codemirror/mode/properties/index.html new file mode 100755 index 00000000..3df6a3ae --- /dev/null +++ b/imports/codemirror/mode/properties/index.html @@ -0,0 +1,40 @@ + + + + CodeMirror: Properties files mode + + + + + + + + +

CodeMirror: Properties files mode

+
+ + +

MIME types defined: text/x-properties.

+ + + diff --git a/imports/codemirror/mode/properties/properties.css b/imports/codemirror/mode/properties/properties.css new file mode 100755 index 00000000..d975375c --- /dev/null +++ b/imports/codemirror/mode/properties/properties.css @@ -0,0 +1,3 @@ +span.cm-key {color: #00c;} +span.cm-equals {color: #a11;} +span.cm-value {color: #170;} 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