all repos — NoPaste @ 29b774f090102303e43cf939b38ac2083e62d9f1

Resurrected - The PussTheCat.org fork of NoPaste

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

 1<!doctype html>
 2
 3<title>CodeMirror: Swift mode</title>
 4<meta charset="utf-8"/>
 5<link rel=stylesheet href="../../doc/docs.css">
 6
 7<link rel="stylesheet" href="../../lib/codemirror.css">
 8<script src="../../lib/codemirror.js"></script>
 9<script src="../../addon/edit/matchbrackets.js"></script>
10<script src="./swift.js"></script>
11<style>
12	.CodeMirror { border: 2px inset #dee; }
13    </style>
14<div id=nav>
15  <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a>
16
17  <ul>
18    <li><a href="../../index.html">Home</a>
19    <li><a href="../../doc/manual.html">Manual</a>
20    <li><a href="https://github.com/codemirror/codemirror">Code</a>
21  </ul>
22  <ul>
23    <li><a href="../index.html">Language modes</a>
24    <li><a class=active href="#">Swift</a>
25  </ul>
26</div>
27
28<article>
29<h2>Swift mode</h2>
30<form><textarea id="code" name="code">
31protocol HeaderViewProtocol {
32    func setTitle(_ string: String)
33}
34
35struct AnyHeaderView {
36    let view: UIView
37    let headerView: HeaderViewProtocol
38    init<T: UIView>(view: T) where T: HeaderViewProtocol {
39        self.view = view
40        self.headerView = view
41    }
42}
43
44let header = AnyHeaderView(view: myView)
45header.headerView.setTitle("hi")
46
47struct HeaderView {
48    let view: UIView
49    let setTitle: (String) -> ()
50}
51
52var label = UILabel()
53let header = HeaderView(view: label) { str in
54    label.text = str
55}
56header.setTitle("hello")
57</textarea></form>
58
59    <script>
60      var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
61        lineNumbers: true,
62        matchBrackets: true,
63        mode: "text/x-swift"
64      });
65    </script>
66
67    <p>A simple mode for Swift</p>
68
69    <p><strong>MIME types defined:</strong> <code>text/x-swift</code> (Swift code)</p>
70  </article>