index.html 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <!doctype html>
  2. <title>CodeMirror: Forth mode</title>
  3. <meta charset="utf-8"/>
  4. <link rel=stylesheet href="../../doc/docs.css">
  5. <link href='http://fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
  6. <link rel="stylesheet" href="../../lib/codemirror.css">
  7. <link rel=stylesheet href="../../theme/colorforth.css">
  8. <script src="../../lib/codemirror.js"></script>
  9. <script src="forth.js"></script>
  10. <style>
  11. .CodeMirror {
  12. font-family: 'Droid Sans Mono', monospace;
  13. font-size: 14px;
  14. }
  15. </style>
  16. <div id=nav>
  17. <a href="http://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 href="../index.html">Language modes</a>
  25. <li><a class=active href="#">Forth</a>
  26. </ul>
  27. </div>
  28. <article>
  29. <h2>Forth mode</h2>
  30. <form><textarea id="code" name="code">
  31. \ Insertion sort
  32. : cell- 1 cells - ;
  33. : insert ( start end -- start )
  34. dup @ >r ( r: v )
  35. begin
  36. 2dup <
  37. while
  38. r@ over cell- @ <
  39. while
  40. cell-
  41. dup @ over cell+ !
  42. repeat then
  43. r> swap ! ;
  44. : sort ( array len -- )
  45. 1 ?do
  46. dup i cells + insert
  47. loop drop ;</textarea>
  48. </form>
  49. <script>
  50. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  51. lineNumbers: true,
  52. lineWrapping: true,
  53. indentUnit: 2,
  54. tabSize: 2,
  55. autofocus: true,
  56. theme: "colorforth",
  57. mode: "text/x-forth"
  58. });
  59. </script>
  60. <p>Simple mode that handle Forth-Syntax (<a href="http://en.wikipedia.org/wiki/Forth_%28programming_language%29">Forth on WikiPedia</a>).</p>
  61. <p><strong>MIME types defined:</strong> <code>text/x-forth</code>.</p>
  62. </article>