File modules/editor/codemirror/mode/properties/properties.js
Last commit: Sun Dec 17 01:14:09 2017 +0100 Jan Dankert Integration eines weiteren Code-Editors: Codemirror. Demnächst müssen wir hier mal aufräumen und andere Editoren rauswerfen.
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 2 // Distributed under an MIT license: http://codemirror.net/LICENSE 3 4 (function(mod) { 5 if (typeof exports == "object" && typeof module == "object") // CommonJS 6 mod(require("../../lib/codemirror")); 7 else if (typeof define == "function" && define.amd) // AMD 8 define(["../../lib/codemirror"], mod); 9 else // Plain browser env 10 mod(CodeMirror); 11 })(function(CodeMirror) { 12 "use strict"; 13 14 CodeMirror.defineMode("properties", function() { 15 return { 16 token: function(stream, state) { 17 var sol = stream.sol() || state.afterSection; 18 var eol = stream.eol(); 19 20 state.afterSection = false; 21 22 if (sol) { 23 if (state.nextMultiline) { 24 state.inMultiline = true; 25 state.nextMultiline = false; 26 } else { 27 state.position = "def"; 28 } 29 } 30 31 if (eol && ! state.nextMultiline) { 32 state.inMultiline = false; 33 state.position = "def"; 34 } 35 36 if (sol) { 37 while(stream.eatSpace()) {} 38 } 39 40 var ch = stream.next(); 41 42 if (sol && (ch === "#" || ch === "!" || ch === ";")) { 43 state.position = "comment"; 44 stream.skipToEnd(); 45 return "comment"; 46 } else if (sol && ch === "[") { 47 state.afterSection = true; 48 stream.skipTo("]"); stream.eat("]"); 49 return "header"; 50 } else if (ch === "=" || ch === ":") { 51 state.position = "quote"; 52 return null; 53 } else if (ch === "\\" && state.position === "quote") { 54 if (stream.eol()) { // end of line? 55 // Multiline value 56 state.nextMultiline = true; 57 } 58 } 59 60 return state.position; 61 }, 62 63 startState: function() { 64 return { 65 position : "def", // Current position, "def", "quote" or "comment" 66 nextMultiline : false, // Is the next line multiline value 67 inMultiline : false, // Is the current line a multiline value 68 afterSection : false // Did we just open a section 69 }; 70 } 71 72 }; 73 }); 74 75 CodeMirror.defineMIME("text/x-properties", "properties"); 76 CodeMirror.defineMIME("text/x-ini", "properties"); 77 78 });
Downloadmodules/editor/codemirror/mode/properties/properties.js
History Sun, 17 Dec 2017 01:14:09 +0100 Jan Dankert Integration eines weiteren Code-Editors: Codemirror. Demnächst müssen wir hier mal aufräumen und andere Editoren rauswerfen.