diff options
author | Pushkar Joshi | 2012-02-24 12:08:49 -0800 |
---|---|---|
committer | Pushkar Joshi | 2012-02-24 12:08:49 -0800 |
commit | 03ca7a5ed13c25faaa9100bb666e062fd15335e6 (patch) | |
tree | c51112223ceb9121cd595a60335eb2795215590f /imports/codemirror/mode/groovy/index.html | |
parent | fcb12cc09eb3cd3b42bd215877ba18f449275b75 (diff) | |
parent | 053fc63a2950c7a5ee4ebf98033b64d474a3c46e (diff) | |
download | ninja-03ca7a5ed13c25faaa9100bb666e062fd15335e6.tar.gz |
Merge branch 'pentool' into brushtool
Conflicts:
imports/codemirror/mode/scheme/scheme.js
js/tools/BrushTool.js
Diffstat (limited to 'imports/codemirror/mode/groovy/index.html')
-rwxr-xr-x | imports/codemirror/mode/groovy/index.html | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/imports/codemirror/mode/groovy/index.html b/imports/codemirror/mode/groovy/index.html new file mode 100755 index 00000000..226475ca --- /dev/null +++ b/imports/codemirror/mode/groovy/index.html | |||
@@ -0,0 +1,71 @@ | |||
1 | <!doctype html> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>CodeMirror: Groovy mode</title> | ||
5 | <link rel="stylesheet" href="../../lib/codemirror.css"> | ||
6 | <script src="../../lib/codemirror.js"></script> | ||
7 | <script src="groovy.js"></script> | ||
8 | <link rel="stylesheet" href="../../doc/docs.css"> | ||
9 | <style>.CodeMirror {border-top: 1px solid #500; border-bottom: 1px solid #500;}</style> | ||
10 | </head> | ||
11 | <body> | ||
12 | <h1>CodeMirror: Groovy mode</h1> | ||
13 | |||
14 | <form><textarea id="code" name="code"> | ||
15 | //Pattern for groovy script | ||
16 | def p = ~/.*\.groovy/ | ||
17 | new File( 'd:\\scripts' ).eachFileMatch(p) {f -> | ||
18 | // imports list | ||
19 | def imports = [] | ||
20 | f.eachLine { | ||
21 | // condition to detect an import instruction | ||
22 | ln -> if ( ln =~ '^import .*' ) { | ||
23 | imports << "${ln - 'import '}" | ||
24 | } | ||
25 | } | ||
26 | // print thmen | ||
27 | if ( ! imports.empty ) { | ||
28 | println f | ||
29 | imports.each{ println " $it" } | ||
30 | } | ||
31 | } | ||
32 | |||
33 | /* Coin changer demo code from http://groovy.codehaus.org */ | ||
34 | |||
35 | enum UsCoin { | ||
36 | quarter(25), dime(10), nickel(5), penny(1) | ||
37 | UsCoin(v) { value = v } | ||
38 | final value | ||
39 | } | ||
40 | |||
41 | enum OzzieCoin { | ||
42 | fifty(50), twenty(20), ten(10), five(5) | ||
43 | OzzieCoin(v) { value = v } | ||
44 | final value | ||
45 | } | ||
46 | |||
47 | def plural(word, count) { | ||
48 | if (count == 1) return word | ||
49 | word[-1] == 'y' ? word[0..-2] + "ies" : word + "s" | ||
50 | } | ||
51 | |||
52 | def change(currency, amount) { | ||
53 | currency.values().inject([]){ list, coin -> | ||
54 | int count = amount / coin.value | ||
55 | amount = amount % coin.value | ||
56 | list += "$count ${plural(coin.toString(), count)}" | ||
57 | } | ||
58 | } | ||
59 | </textarea></form> | ||
60 | |||
61 | <script> | ||
62 | var editor = CodeMirror.fromTextArea(document.getElementById("code"), { | ||
63 | lineNumbers: true, | ||
64 | matchBrackets: true, | ||
65 | mode: "text/x-groovy" | ||
66 | }); | ||
67 | </script> | ||
68 | |||
69 | <p><strong>MIME types defined:</strong> <code>text/x-groovy</code></p> | ||
70 | </body> | ||
71 | </html> | ||