~armagetronad-ap/armagetronad/ArmaManager

« back to all changes in this revision

Viewing changes to www/codemirror/settings.js

  • Committer: zodiacsohma1 at gmail
  • Date: 2013-06-29 23:49:39 UTC
  • Revision ID: zodiacsohma1@gmail.com-20130629234939-pq3o0374pfp47b9a
Fman added in a lot of stuff but I can't be sure but hey, they are a lot! :P

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
CodeMirror.defineMode("settings", 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 === "#")) {
 
30
        state.position = "comment";
 
31
        stream.skipToEnd();
 
32
        return "comment";
 
33
      } else if (ch === " ") {
 
34
        state.position = "quote";
 
35
        return null;
 
36
      } else if (ch === "\\" && state.position === "quote") {
 
37
        if (stream.next() !== "u") {    // u = Unicode sequence \u1234
 
38
          // Multiline value
 
39
          state.nextMultiline = true;
 
40
        }
 
41
      }
 
42
 
 
43
      return state.position;
 
44
    },
 
45
 
 
46
    startState: function() {
 
47
      return {
 
48
        position : "def",       // Current position, "def", "quote" or "comment"
 
49
        nextMultiline : false,  // Is the next line multiline value
 
50
        inMultiline : false,    // Is the current line a multiline value
 
51
        afterSection : false    // Did we just open a section
 
52
      };
 
53
    }
 
54
 
 
55
  };
 
56
});