marker.html 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <!doctype html>
  2. <title>CodeMirror: Breakpoint Demo</title>
  3. <meta charset="utf-8"/>
  4. <link rel=stylesheet href="../doc/docs.css">
  5. <link rel="stylesheet" href="../lib/codemirror.css">
  6. <script src="../lib/codemirror.js"></script>
  7. <script src="../mode/javascript/javascript.js"></script>
  8. <style type="text/css">
  9. .breakpoints {width: .8em;}
  10. .breakpoint { color: #822; }
  11. .CodeMirror {border: 1px solid #aaa;}
  12. </style>
  13. <div id=nav>
  14. <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
  15. <ul>
  16. <li><a href="../index.html">Home</a>
  17. <li><a href="../doc/manual.html">Manual</a>
  18. <li><a href="https://github.com/codemirror/codemirror">Code</a>
  19. </ul>
  20. <ul>
  21. <li><a class=active href="#">Breakpoint</a>
  22. </ul>
  23. </div>
  24. <article>
  25. <h2>Breakpoint Demo</h2>
  26. <form><textarea id="code" name="code">
  27. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  28. lineNumbers: true,
  29. gutters: ["CodeMirror-linenumbers", "breakpoints"]
  30. });
  31. editor.on("gutterClick", function(cm, n) {
  32. var info = cm.lineInfo(n);
  33. cm.setGutterMarker(n, "breakpoints", info.gutterMarkers ? null : makeMarker());
  34. });
  35. function makeMarker() {
  36. var marker = document.createElement("div");
  37. marker.style.color = "#822";
  38. marker.innerHTML = "●";
  39. return marker;
  40. }
  41. </textarea></form>
  42. <p>Click the line-number gutter to add or remove 'breakpoints'.</p>
  43. <script>eval(document.getElementById("code").value);</script>
  44. </article>