Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
malwaredllc
GitHub Repository: malwaredllc/byob
Path: blob/master/web-gui/buildyourownbotnet/assets/js/codemirror/mode/properties/properties.js
1293 views
1
CodeMirror.defineMode("properties", function() {
2
return {
3
token: function(stream, state) {
4
var sol = stream.sol() || state.afterSection;
5
var eol = stream.eol();
6
7
state.afterSection = false;
8
9
if (sol) {
10
if (state.nextMultiline) {
11
state.inMultiline = true;
12
state.nextMultiline = false;
13
} else {
14
state.position = "def";
15
}
16
}
17
18
if (eol && ! state.nextMultiline) {
19
state.inMultiline = false;
20
state.position = "def";
21
}
22
23
if (sol) {
24
while(stream.eatSpace());
25
}
26
27
var ch = stream.next();
28
29
if (sol && (ch === "#" || ch === "!" || ch === ";")) {
30
state.position = "comment";
31
stream.skipToEnd();
32
return "comment";
33
} else if (sol && ch === "[") {
34
state.afterSection = true;
35
stream.skipTo("]"); stream.eat("]");
36
return "header";
37
} else if (ch === "=" || ch === ":") {
38
state.position = "quote";
39
return null;
40
} else if (ch === "\\" && state.position === "quote") {
41
if (stream.next() !== "u") { // u = Unicode sequence \u1234
42
// Multiline value
43
state.nextMultiline = true;
44
}
45
}
46
47
return state.position;
48
},
49
50
startState: function() {
51
return {
52
position : "def", // Current position, "def", "quote" or "comment"
53
nextMultiline : false, // Is the next line multiline value
54
inMultiline : false, // Is the current line a multiline value
55
afterSection : false // Did we just open a section
56
};
57
}
58
59
};
60
});
61
62
CodeMirror.defineMIME("text/x-properties", "properties");
63
CodeMirror.defineMIME("text/x-ini", "properties");
64
65