michael@0: (function(mod) { michael@0: if (typeof exports == "object" && typeof module == "object") // CommonJS michael@0: mod(require("../../lib/codemirror")); michael@0: else if (typeof define == "function" && define.amd) // AMD michael@0: define(["../../lib/codemirror"], mod); michael@0: else // Plain browser env michael@0: mod(CodeMirror); michael@0: })(function(CodeMirror) { michael@0: CodeMirror.defineOption("showTrailingSpace", false, function(cm, val, prev) { michael@0: if (prev == CodeMirror.Init) prev = false; michael@0: if (prev && !val) michael@0: cm.removeOverlay("trailingspace"); michael@0: else if (!prev && val) michael@0: cm.addOverlay({ michael@0: token: function(stream) { michael@0: for (var l = stream.string.length, i = l; i && /\s/.test(stream.string.charAt(i - 1)); --i) {} michael@0: if (i > stream.pos) { stream.pos = i; return null; } michael@0: stream.pos = l; michael@0: return "trailingspace"; michael@0: }, michael@0: name: "trailingspace" michael@0: }); michael@0: }); michael@0: });