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.

67 lines
2.0 KiB

3 years ago
  1. <!doctype html>
  2. <title>CodeMirror: Modelica mode</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/matchbrackets.js"></script>
  8. <link rel="stylesheet" href="../../addon/hint/show-hint.css">
  9. <script src="../../addon/hint/show-hint.js"></script>
  10. <script src="modelica.js"></script>
  11. <style>.CodeMirror {border: 2px inset #dee;}</style>
  12. <div id=nav>
  13. <a href="http://codemirror.net"><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/codemirror">Code</a>
  18. </ul>
  19. <ul>
  20. <li><a href="../index.html">Language modes</a>
  21. <li><a class=active href="#">Modelica</a>
  22. </ul>
  23. </div>
  24. <article>
  25. <h2>Modelica mode</h2>
  26. <div><textarea id="modelica">
  27. model BouncingBall
  28. parameter Real e = 0.7;
  29. parameter Real g = 9.81;
  30. Real h(start=1);
  31. Real v;
  32. Boolean flying(start=true);
  33. Boolean impact;
  34. Real v_new;
  35. equation
  36. impact = h <= 0.0;
  37. der(v) = if flying then -g else 0;
  38. der(h) = v;
  39. when {h <= 0.0 and v <= 0.0, impact} then
  40. v_new = if edge(impact) then -e*pre(v) else 0;
  41. flying = v_new > 0;
  42. reinit(v, v_new);
  43. end when;
  44. annotation (uses(Modelica(version="3.2")));
  45. end BouncingBall;
  46. </textarea></div>
  47. <script>
  48. var modelicaEditor = CodeMirror.fromTextArea(document.getElementById("modelica"), {
  49. lineNumbers: true,
  50. matchBrackets: true,
  51. mode: "text/x-modelica"
  52. });
  53. var mac = CodeMirror.keyMap.default == CodeMirror.keyMap.macDefault;
  54. CodeMirror.keyMap.default[(mac ? "Cmd" : "Ctrl") + "-Space"] = "autocomplete";
  55. </script>
  56. <p>Simple mode that tries to handle Modelica as well as it can.</p>
  57. <p><strong>MIME types defined:</strong> <code>text/x-modelica</code>
  58. (Modlica code).</p>
  59. </article>