File modules/editor/codemirror/mode/groovy/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: Groovy 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="groovy.js"></script> 11 <style>.CodeMirror {border-top: 1px solid #500; border-bottom: 1px solid #500;}</style> 12 <div id=nav> 13 <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> 14 15 <ul> 16 <li><a href="../../index.html">Home</a> 17 <li><a href="../../doc/manual.html">Manual</a> 18 <li><a href="https://github.com/codemirror/codemirror">Code</a> 19 </ul> 20 <ul> 21 <li><a href="../index.html">Language modes</a> 22 <li><a class=active href="#">Groovy</a> 23 </ul> 24 </div> 25 26 <article> 27 <h2>Groovy mode</h2> 28 <form><textarea id="code" name="code"> 29 //Pattern for groovy script 30 def p = ~/.*\.groovy/ 31 new File( 'd:\\scripts' ).eachFileMatch(p) {f -> 32 // imports list 33 def imports = [] 34 f.eachLine { 35 // condition to detect an import instruction 36 ln -> if ( ln =~ '^import .*' ) { 37 imports << "${ln - 'import '}" 38 } 39 } 40 // print thmen 41 if ( ! imports.empty ) { 42 println f 43 imports.each{ println " $it" } 44 } 45 } 46 47 /* Coin changer demo code from http://groovy.codehaus.org */ 48 49 enum UsCoin { 50 quarter(25), dime(10), nickel(5), penny(1) 51 UsCoin(v) { value = v } 52 final value 53 } 54 55 enum OzzieCoin { 56 fifty(50), twenty(20), ten(10), five(5) 57 OzzieCoin(v) { value = v } 58 final value 59 } 60 61 def plural(word, count) { 62 if (count == 1) return word 63 word[-1] == 'y' ? word[0..-2] + "ies" : word + "s" 64 } 65 66 def change(currency, amount) { 67 currency.values().inject([]){ list, coin -> 68 int count = amount / coin.value 69 amount = amount % coin.value 70 list += "$count ${plural(coin.toString(), count)}" 71 } 72 } 73 </textarea></form> 74 75 <script> 76 var editor = CodeMirror.fromTextArea(document.getElementById("code"), { 77 lineNumbers: true, 78 matchBrackets: true, 79 mode: "text/x-groovy" 80 }); 81 </script> 82 83 <p><strong>MIME types defined:</strong> <code>text/x-groovy</code></p> 84 </article>
Download modules/editor/codemirror/mode/groovy/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.