github.com/elliott5/community@v0.14.1-0.20160709191136-823126fb026a/app/public/codemirror/mode/crystal/index.html (about) 1 <!doctype html> 2 3 <title>CodeMirror: Crystal 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="crystal.js"></script> 11 <style> 12 .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;} 13 .cm-s-default span.cm-arrow { color: red; } 14 </style> 15 16 <div id=nav> 17 <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> 18 19 <ul> 20 <li><a href="../../index.html">Home</a> 21 <li><a href="../../doc/manual.html">Manual</a> 22 <li><a href="https://github.com/codemirror/codemirror">Code</a> 23 </ul> 24 <ul> 25 <li><a href="../index.html">Language modes</a> 26 <li><a class=active href="#">Crystal</a> 27 </ul> 28 </div> 29 30 <article> 31 <h2>Crystal mode</h2> 32 <form><textarea id="code" name="code"> 33 # Features of Crystal 34 # - Ruby-inspired syntax. 35 # - Statically type-checked but without having to specify the type of variables or method arguments. 36 # - Be able to call C code by writing bindings to it in Crystal. 37 # - Have compile-time evaluation and generation of code, to avoid boilerplate code. 38 # - Compile to efficient native code. 39 40 # A very basic HTTP server 41 require "http/server" 42 43 server = HTTP::Server.new(8080) do |request| 44 HTTP::Response.ok "text/plain", "Hello world, got #{request.path}!" 45 end 46 47 puts "Listening on http://0.0.0.0:8080" 48 server.listen 49 50 module Foo 51 def initialize(@foo); end 52 53 abstract def abstract_method : String 54 55 @[AlwaysInline] 56 def with_foofoo 57 with Foo.new(self) yield 58 end 59 60 struct Foo 61 def initialize(@foo); end 62 63 def hello_world 64 @foo.abstract_method 65 end 66 end 67 end 68 69 class Bar 70 include Foo 71 72 @@foobar = 12345 73 74 def initialize(@bar) 75 super(@bar.not_nil! + 100) 76 end 77 78 macro alias_method(name, method) 79 def {{ name }}(*args) 80 {{ method }}(*args) 81 end 82 end 83 84 def a_method 85 "Hello, World" 86 end 87 88 alias_method abstract_method, a_method 89 90 macro def show_instance_vars : Nil 91 {% for var in @type.instance_vars %} 92 puts "@{{ var }} = #{ @{{ var }} }" 93 {% end %} 94 nil 95 end 96 end 97 98 class Baz < Bar; end 99 100 lib LibC 101 fun c_puts = "puts"(str : Char*) : Int 102 end 103 104 $baz = Baz.new(100) 105 $baz.show_instance_vars 106 $baz.with_foofoo do 107 LibC.c_puts hello_world 108 end 109 </textarea></form> 110 <script> 111 var editor = CodeMirror.fromTextArea(document.getElementById("code"), { 112 mode: "text/x-crystal", 113 matchBrackets: true, 114 indentUnit: 2 115 }); 116 </script> 117 118 <p><strong>MIME types defined:</strong> <code>text/x-crystal</code>.</p> 119 </article>