本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
1004B

  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: https://codemirror.net/LICENSE
  3. (function(mod) {
  4. if (typeof exports == "object" && typeof module == "object") // CommonJS
  5. mod(require("../../lib/codemirror"));
  6. else if (typeof define == "function" && define.amd) // AMD
  7. define(["../../lib/codemirror"], mod);
  8. else // Plain browser env
  9. mod(CodeMirror);
  10. })(function(CodeMirror) {
  11. CodeMirror.defineOption("showTrailingSpace", false, function(cm, val, prev) {
  12. if (prev == CodeMirror.Init) prev = false;
  13. if (prev && !val)
  14. cm.removeOverlay("trailingspace");
  15. else if (!prev && val)
  16. cm.addOverlay({
  17. token: function(stream) {
  18. for (var l = stream.string.length, i = l; i && /\s/.test(stream.string.charAt(i - 1)); --i) {}
  19. if (i > stream.pos) { stream.pos = i; return null; }
  20. stream.pos = l;
  21. return "trailingspace";
  22. },
  23. name: "trailingspace"
  24. });
  25. });
  26. });
上海开阖软件有限公司 沪ICP备12045867号-1