File modules/editor/codemirror/mode/swift/index.html

Last commit: Sun Dec 17 01:14:09 2017 +0100	Jan Dankert	Integration eines weiteren Code-Editors: Codemirror. Demnächst müssen wir hier mal aufräumen und andere Editoren rauswerfen.
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="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></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"> 31 // 32 // TipCalculatorModel.swift 33 // TipCalculator 34 // 35 // Created by Main Account on 12/18/14. 36 // Copyright (c) 2014 Razeware LLC. All rights reserved. 37 // 38 39 import Foundation 40 41 class TipCalculatorModel { 42 43 var total: Double 44 var taxPct: Double 45 var subtotal: Double { 46 get { 47 return total / (taxPct + 1) 48 } 49 } 50 51 init(total: Double, taxPct: Double) { 52 self.total = total 53 self.taxPct = taxPct 54 } 55 56 func calcTipWithTipPct(tipPct: Double) -> Double { 57 return subtotal * tipPct 58 } 59 60 func returnPossibleTips() -> [Int: Double] { 61 62 let possibleTipsInferred = [0.15, 0.18, 0.20] 63 let possibleTipsExplicit:[Double] = [0.15, 0.18, 0.20] 64 65 var retval = [Int: Double]() 66 for possibleTip in possibleTipsInferred { 67 let intPct = Int(possibleTip*100) 68 retval[intPct] = calcTipWithTipPct(possibleTip) 69 } 70 return retval 71 72 } 73 74 } 75 </textarea></form> 76 77 <script> 78 var editor = CodeMirror.fromTextArea(document.getElementById("code"), { 79 lineNumbers: true, 80 matchBrackets: true, 81 mode: "text/x-swift" 82 }); 83 </script> 84 85 <p>A simple mode for Swift</p> 86 87 <p><strong>MIME types defined:</strong> <code>text/x-swift</code> (Swift code)</p> 88 </article>
Download modules/editor/codemirror/mode/swift/index.html
History Sun, 17 Dec 2017 01:14:09 +0100 Jan Dankert Integration eines weiteren Code-Editors: Codemirror. Demnächst müssen wir hier mal aufräumen und andere Editoren rauswerfen.