Mercurial
comparison .cms/lib/codemirror/mode/dart/index.html @ 0:78edf6b517a0 draft
24.10
author | Coffee CMS <info@coffee-cms.ru> |
---|---|
date | Fri, 11 Oct 2024 22:40:23 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:78edf6b517a0 |
---|---|
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/5"><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/codemirror5">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"> | |
29 import 'dart:math' show Random; | |
30 | |
31 void main() { | |
32 print(Die(n: 12).roll()); | |
33 } | |
34 | |
35 // Define a class. | |
36 class Die { | |
37 // Define a class variable. | |
38 static final Random shaker = Random(); | |
39 | |
40 // Define instance variables. | |
41 final int sides; | |
42 int? lastRoll; | |
43 | |
44 // Define a constructor. | |
45 Die({int n = 6}) : sides = n { | |
46 if (4 > n || n > 20) { | |
47 // Support for errors and exceptions. | |
48 throw ArgumentError(/* */); | |
49 } | |
50 } | |
51 | |
52 // Define a method using shorthand syntax. | |
53 @override | |
54 String toString() => '$lastRoll'; | |
55 | |
56 // Define an instance method. | |
57 int roll() { | |
58 return lastRoll = 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> |