|
1 (function(mod) { |
|
2 if (typeof exports == "object" && typeof module == "object") // CommonJS |
|
3 mod(require("../../lib/codemirror")); |
|
4 else if (typeof define == "function" && define.amd) // AMD |
|
5 define(["../../lib/codemirror"], mod); |
|
6 else // Plain browser env |
|
7 mod(CodeMirror); |
|
8 })(function(CodeMirror) { |
|
9 CodeMirror.defineOption("showTrailingSpace", false, function(cm, val, prev) { |
|
10 if (prev == CodeMirror.Init) prev = false; |
|
11 if (prev && !val) |
|
12 cm.removeOverlay("trailingspace"); |
|
13 else if (!prev && val) |
|
14 cm.addOverlay({ |
|
15 token: function(stream) { |
|
16 for (var l = stream.string.length, i = l; i && /\s/.test(stream.string.charAt(i - 1)); --i) {} |
|
17 if (i > stream.pos) { stream.pos = i; return null; } |
|
18 stream.pos = l; |
|
19 return "trailingspace"; |
|
20 }, |
|
21 name: "trailingspace" |
|
22 }); |
|
23 }); |
|
24 }); |