Fix: merge conflict
[myslice.git] / to-be-integrated / third-party / codemirror-3.15 / mode / erlang / index.html
1 <!doctype html>
2 <html>
3   <head>
4     <meta charset="utf-8">
5     <title>CodeMirror: Erlang mode</title>
6     <link rel="stylesheet" href="../../lib/codemirror.css">
7     <script src="../../lib/codemirror.js"></script>
8     <script src="../../addon/edit/matchbrackets.js"></script>
9     <script src="erlang.js"></script>
10     <link rel="stylesheet" href="../../theme/erlang-dark.css">
11     <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
12     <link rel="stylesheet" href="../../doc/docs.css">
13   </head>
14   <body>
15     <h1>CodeMirror: Erlang mode</h1>
16
17 <form><textarea id="code" name="code">
18 %% -*- mode: erlang; erlang-indent-level: 2 -*-
19 %%% Created :  7 May 2012 by mats cronqvist <masse@klarna.com>
20
21 %% @doc
22 %% Demonstrates how to print a record.
23 %% @end
24
25 -module('ex').
26 -author('mats cronqvist').
27 -export([demo/0,
28          rec_info/1]).
29
30 -record(demo,{a="One",b="Two",c="Three",d="Four"}).
31
32 rec_info(demo) -> record_info(fields,demo).
33
34 demo() -> expand_recs(?MODULE,#demo{a="A",b="BB"}).
35   
36 expand_recs(M,List) when is_list(List) ->
37   [expand_recs(M,L)||L<-List];
38 expand_recs(M,Tup) when is_tuple(Tup) ->
39   case tuple_size(Tup) of
40     L when L < 1 -> Tup;
41     L ->
42       try Fields = M:rec_info(element(1,Tup)),
43           L = length(Fields)+1,
44           lists:zip(Fields,expand_recs(M,tl(tuple_to_list(Tup))))
45       catch _:_ ->
46           list_to_tuple(expand_recs(M,tuple_to_list(Tup)))
47       end
48   end;
49 expand_recs(_,Term) ->
50   Term.
51 </textarea></form>
52
53     <script>
54       var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
55         lineNumbers: true,
56         matchBrackets: true,
57         extraKeys: {"Tab":  "indentAuto"},
58         theme: "erlang-dark"
59       });
60     </script>
61
62     <p><strong>MIME types defined:</strong> <code>text/x-erlang</code>.</p>
63   </body>
64 </html>