all repos — NoPaste @ 5c12c8a8f515faa64a6cd1d3f04d9aa60561322d

Resurrected - The PussTheCat.org fork of NoPaste

scripts/CodeMirror/mode/erlang/index.html (view raw)

 1<!doctype html>
 2
 3<title>CodeMirror: Erlang 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<link rel="stylesheet" href="../../theme/erlang-dark.css">
 9<script src="../../lib/codemirror.js"></script>
10<script src="../../addon/edit/matchbrackets.js"></script>
11<script src="erlang.js"></script>
12<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
13<div id=nav>
14  <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a>
15
16  <ul>
17    <li><a href="../../index.html">Home</a>
18    <li><a href="../../doc/manual.html">Manual</a>
19    <li><a href="https://github.com/codemirror/codemirror">Code</a>
20  </ul>
21  <ul>
22    <li><a href="../index.html">Language modes</a>
23    <li><a class=active href="#">Erlang</a>
24  </ul>
25</div>
26
27<article>
28<h2>Erlang mode</h2>
29<form><textarea id="code" name="code">
30%% -*- mode: erlang; erlang-indent-level: 2 -*-
31%%% Created :  7 May 2012 by mats cronqvist <masse@klarna.com>
32
33%% @doc
34%% Demonstrates how to print a record.
35%% @end
36
37-module('ex').
38-author('mats cronqvist').
39-export([demo/0,
40         rec_info/1]).
41
42-record(demo,{a="One",b="Two",c="Three",d="Four"}).
43
44rec_info(demo) -> record_info(fields,demo).
45
46demo() -> expand_recs(?MODULE,#demo{a="A",b="BB"}).
47
48expand_recs(M,List) when is_list(List) ->
49  [expand_recs(M,L)||L<-List];
50expand_recs(M,Tup) when is_tuple(Tup) ->
51  case tuple_size(Tup) of
52    L when L < 1 -> Tup;
53    L ->
54      try
55        Fields = M:rec_info(element(1,Tup)),
56        L = length(Fields)+1,
57        lists:zip(Fields,expand_recs(M,tl(tuple_to_list(Tup))))
58      catch
59        _:_ -> list_to_tuple(expand_recs(M,tuple_to_list(Tup)))
60      end
61  end;
62expand_recs(_,Term) ->
63  Term.
64</textarea></form>
65
66    <script>
67      var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
68        lineNumbers: true,
69        matchBrackets: true,
70        extraKeys: {"Tab":  "indentAuto"},
71        theme: "erlang-dark"
72      });
73    </script>
74
75    <p><strong>MIME types defined:</strong> <code>text/x-erlang</code>.</p>
76  </article>