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.

52 lines
1.6 KiB

7 months ago
  1. <!doctype html>
  2. <title>CodeMirror: Closebrackets 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="../addon/edit/closebrackets.js"></script>
  8. <script src="../mode/javascript/javascript.js"></script>
  9. <style>
  10. .CodeMirror {border-top: 1px solid #888; border-bottom: 1px solid #888;}
  11. </style>
  12. <div id=nav>
  13. <a href="https://codemirror.net/5"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
  14. <ul>
  15. <li><a href="../index.html">Home</a>
  16. <li><a href="../doc/manual.html">Manual</a>
  17. <li><a href="https://github.com/codemirror/codemirror5">Code</a>
  18. </ul>
  19. <ul>
  20. <li><a class=active href="#">Closebrackets</a>
  21. </ul>
  22. </div>
  23. <article>
  24. <h2>Closebrackets Demo</h2>
  25. <form><textarea id="code" name="code">function Grid(width, height) {
  26. this.width = width;
  27. this.height = height;
  28. this.cells = new Array(width * height);
  29. }
  30. Grid.prototype.valueAt = function(point) {
  31. return this.cells[point.y * this.width + point.x];
  32. };
  33. Grid.prototype.setValueAt = function(point, value) {
  34. this.cells[point.y * this.width + point.x] = value;
  35. };
  36. Grid.prototype.isInside = function(point) {
  37. return point.x >= 0 && point.y >= 0 &&
  38. point.x < this.width && point.y < this.height;
  39. };
  40. Grid.prototype.moveValue = function(from, to) {
  41. this.setValueAt(to, this.valueAt(from));
  42. this.setValueAt(from, undefined);
  43. };</textarea></form>
  44. <script>
  45. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {autoCloseBrackets: true});
  46. </script>
  47. </article>