visibletabs.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <!doctype html>
  2. <title>CodeMirror: Visible tabs 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/clike/clike.js"></script>
  8. <style>
  9. .CodeMirror {border-top: 1px solid #eee; border-bottom: 1px solid #eee;}
  10. .cm-tab {
  11. background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAMCAYAAAAkuj5RAAAAAXNSR0IArs4c6QAAAGFJREFUSMft1LsRQFAQheHPowAKoACx3IgEKtaEHujDjORSgWTH/ZOdnZOcM/sgk/kFFWY0qV8foQwS4MKBCS3qR6ixBJvElOobYAtivseIE120FaowJPN75GMu8j/LfMwNjh4HUpwg4LUAAAAASUVORK5CYII=);
  12. background-position: right;
  13. background-repeat: no-repeat;
  14. }
  15. </style>
  16. <div id=nav>
  17. <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
  18. <ul>
  19. <li><a href="../index.html">Home</a>
  20. <li><a href="../doc/manual.html">Manual</a>
  21. <li><a href="https://github.com/codemirror/codemirror">Code</a>
  22. </ul>
  23. <ul>
  24. <li><a class=active href="#">Visible tabs</a>
  25. </ul>
  26. </div>
  27. <article>
  28. <h2>Visible tabs demo</h2>
  29. <form><textarea id="code" name="code">
  30. #include "syscalls.h"
  31. /* getchar: simple buffered version */
  32. int getchar(void)
  33. {
  34. static char buf[BUFSIZ];
  35. static char *bufp = buf;
  36. static int n = 0;
  37. if (n == 0) { /* buffer is empty */
  38. n = read(0, buf, sizeof buf);
  39. bufp = buf;
  40. }
  41. return (--n >= 0) ? (unsigned char) *bufp++ : EOF;
  42. }
  43. </textarea></form>
  44. <p>Tabs inside the editor are spans with the
  45. class <code>cm-tab</code>, and can be styled.</p>
  46. <script>
  47. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  48. lineNumbers: true,
  49. tabSize: 4,
  50. indentUnit: 4,
  51. indentWithTabs: true,
  52. mode: "text/x-csrc"
  53. });
  54. </script>
  55. </article>