From 671d2b94996ac71d56b2d05d5fe694ed7d84fa59 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 4 Apr 2012 12:27:35 -0700 Subject: upgrading to CodeMirror 2.23, since it has an important fix to Not close Ninja, if backspace is pressed while autocomplete dropdown is open. Signed-off-by: Ananya Sen --- imports/codemirror/mode/properties/index.html | 4 ++-- imports/codemirror/mode/properties/properties.css | 3 --- imports/codemirror/mode/properties/properties.js | 28 ++++++++++++++--------- 3 files changed, 19 insertions(+), 16 deletions(-) delete mode 100755 imports/codemirror/mode/properties/properties.css (limited to 'imports/codemirror/mode/properties') diff --git a/imports/codemirror/mode/properties/index.html b/imports/codemirror/mode/properties/index.html index 3df6a3ae..4f0c269c 100755 --- a/imports/codemirror/mode/properties/index.html +++ b/imports/codemirror/mode/properties/index.html @@ -5,7 +5,6 @@ - @@ -34,7 +33,8 @@ spaces\ in\ keys=Not very common... var editor = CodeMirror.fromTextArea(document.getElementById("code"), {}); -

MIME types defined: text/x-properties.

+

MIME types defined: text/x-properties, + text/x-ini.

diff --git a/imports/codemirror/mode/properties/properties.css b/imports/codemirror/mode/properties/properties.css deleted file mode 100755 index d975375c..00000000 --- a/imports/codemirror/mode/properties/properties.css +++ /dev/null @@ -1,3 +0,0 @@ -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 index 2529505b..d3a13c76 100755 --- a/imports/codemirror/mode/properties/properties.js +++ b/imports/codemirror/mode/properties/properties.js @@ -1,21 +1,23 @@ CodeMirror.defineMode("properties", function() { return { token: function(stream, state) { - var sol = stream.sol(); + var sol = stream.sol() || state.afterSection; var eol = stream.eol(); + state.afterSection = false; + if (sol) { if (state.nextMultiline) { state.inMultiline = true; state.nextMultiline = false; } else { - state.position = "key"; + state.position = "def"; } } if (eol && ! state.nextMultiline) { state.inMultiline = false; - state.position = "key"; + state.position = "def"; } if (sol) { @@ -24,16 +26,18 @@ CodeMirror.defineMode("properties", function() { var ch = stream.next(); - if (sol && (ch === "#" || ch === "!")) { + if (sol && (ch === "#" || ch === "!" || ch === ";")) { state.position = "comment"; stream.skipToEnd(); return "comment"; - + } else if (sol && ch === "[") { + state.afterSection = true; + stream.skipTo("]"); stream.eat("]"); + return "header"; } else if (ch === "=" || ch === ":") { - state.position = "value"; - return "equals"; - - } else if (ch === "\\" && state.position === "value") { + state.position = "quote"; + return null; + } else if (ch === "\\" && state.position === "quote") { if (stream.next() !== "u") { // u = Unicode sequence \u1234 // Multiline value state.nextMultiline = true; @@ -45,9 +49,10 @@ CodeMirror.defineMode("properties", function() { startState: function() { return { - position : "key", // Current position, "key", "value" or "comment" + position : "def", // Current position, "def", "quote" or "comment" nextMultiline : false, // Is the next line multiline value - inMultiline : false // Is the current line a multiline value + inMultiline : false, // Is the current line a multiline value + afterSection : false // Did we just open a section }; } @@ -55,3 +60,4 @@ CodeMirror.defineMode("properties", function() { }); CodeMirror.defineMIME("text/x-properties", "properties"); +CodeMirror.defineMIME("text/x-ini", "properties"); -- cgit v1.2.3