all repos — NoPaste @ 4d5201f1a9fd36bf5ab4e04de97fc70c12081b9a

Resurrected - The PussTheCat.org fork of NoPaste

scripts/CodeMirror/mode/dart/index.html (view raw)

 1<!doctype html>
 2
 3<title>CodeMirror: Dart mode</title>
 4<meta charset="utf-8"/>
 5<link rel=stylesheet href="../../doc/docs.css">
 6<link rel="stylesheet" href="../../lib/codemirror.css">
 7<script src="../../lib/codemirror.js"></script>
 8<script src="../clike/clike.js"></script>
 9<script src="dart.js"></script>
10<style>.CodeMirror {border: 1px solid #dee;}</style>
11<div id=nav>
12  <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a>
13
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="#">Dart</a>
22  </ul>
23</div>
24
25<article>
26<h2>Dart mode</h2>
27<form>
28<textarea id="code" name="code">
29import 'dart:math' show Random;
30
31void main() {
32  print(new Die(n: 12).roll());
33}
34
35// Define a class.
36class Die {
37  // Define a class variable.
38  static Random shaker = new Random();
39
40  // Define instance variables.
41  int sides, value;
42
43  // Define a method using shorthand syntax.
44  String toString() => '$value';
45
46  // Define a constructor.
47  Die({int n: 6}) {
48    if (4 <= n && n <= 20) {
49      sides = n;
50    } else {
51      // Support for errors and exceptions.
52      throw new ArgumentError(/* */);
53    }
54  }
55
56  // Define an instance method.
57  int roll() {
58    return value = shaker.nextInt(sides) + 1;
59  }
60}
61</textarea>
62</form>
63
64<script>
65  var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
66    lineNumbers: true,
67    mode: "application/dart"
68  });
69</script>
70
71</article>