Browse code
Moar language support
Ed L authored on 09/05/2016 02:38:22
Showing 6 changed files
Showing 6 changed files
... | ... |
@@ -12,6 +12,7 @@ |
12 | 12 |
"use strict"; |
13 | 13 |
|
14 | 14 |
CodeMirror.defineMode("commonlisp", function (config) { |
15 |
+ var specialForm = /^(block|let*|return-from|catch|load-time-value|setq|eval-when|locally|symbol-macrolet|flet|macrolet|tagbody|function|multiple-value-call|the|go|multiple-value-prog1|throw|if|progn|unwind-protect|labels|progv|let|quote)$/; |
|
15 | 16 |
var assumeBody = /^with|^def|^do|^prog|case$|^cond$|bind$|when$|unless$/; |
16 | 17 |
var numLiteral = /^(?:[+\-]?(?:\d+|\d*\.\d+)(?:[efd][+\-]?\d+)?|[+\-]?\d+(?:\/[+\-]?\d+)?|#b[+\-]?[01]+|#o[+\-]?[0-7]+|#x[+\-]?[\da-f]+)/; |
17 | 18 |
var symbol = /[^\s'`,@()\[\]";]/; |
... | ... |
@@ -52,8 +53,8 @@ CodeMirror.defineMode("commonlisp", function (config) { |
52 | 53 |
var name = readSym(stream); |
53 | 54 |
if (name == ".") return null; |
54 | 55 |
type = "symbol"; |
55 |
- if (name == "nil" || name == "t") return "atom"; |
|
56 |
- if (name.charAt(0) == ":") return "keyword"; |
|
56 |
+ if (name == "nil" || name == "t" || name.charAt(0) == ":") return "atom"; |
|
57 |
+ if (state.lastType == "open" && (specialForm.test(name) || assumeBody.test(name))) return "keyword"; |
|
57 | 58 |
if (name.charAt(0) == "&") return "variable-2"; |
58 | 59 |
return "variable"; |
59 | 60 |
} |
... | ... |
@@ -80,7 +81,7 @@ CodeMirror.defineMode("commonlisp", function (config) { |
80 | 81 |
|
81 | 82 |
return { |
82 | 83 |
startState: function () { |
83 |
- return {ctx: {prev: null, start: 0, indentTo: 0}, tokenize: base}; |
|
84 |
+ return {ctx: {prev: null, start: 0, indentTo: 0}, lastType: null, tokenize: base}; |
|
84 | 85 |
}, |
85 | 86 |
|
86 | 87 |
token: function (stream, state) { |
... | ... |
@@ -98,6 +99,7 @@ CodeMirror.defineMode("commonlisp", function (config) { |
98 | 99 |
} else if (state.ctx.indentTo == "next") { |
99 | 100 |
state.ctx.indentTo = stream.column(); |
100 | 101 |
} |
102 |
+ state.lastType = type; |
|
101 | 103 |
} |
102 | 104 |
if (type == "open") state.ctx = {prev: state.ctx, start: stream.column(), indentTo: null}; |
103 | 105 |
else if (type == "close") state.ctx = state.ctx.prev || state.ctx; |
... | ... |
@@ -109,6 +111,7 @@ CodeMirror.defineMode("commonlisp", function (config) { |
109 | 111 |
return typeof i == "number" ? i : state.ctx.start + 1; |
110 | 112 |
}, |
111 | 113 |
|
114 |
+ closeBrackets: {pairs: "()[]{}\"\""}, |
|
112 | 115 |
lineComment: ";;", |
113 | 116 |
blockCommentStart: "#|", |
114 | 117 |
blockCommentEnd: "|#" |
115 | 118 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,160 @@ |
1 |
+// CodeMirror, copyright (c) by Marijn Haverbeke and others |
|
2 |
+// Distributed under an MIT license: http://codemirror.net/LICENSE |
|
3 |
+ |
|
4 |
+(function(mod) { |
|
5 |
+ if (typeof exports == "object" && typeof module == "object") // CommonJS |
|
6 |
+ mod(require("../../lib/codemirror")); |
|
7 |
+ else if (typeof define == "function" && define.amd) // AMD |
|
8 |
+ define(["../../lib/codemirror"], mod); |
|
9 |
+ else // Plain browser env |
|
10 |
+ mod(CodeMirror); |
|
11 |
+})(function(CodeMirror) { |
|
12 |
+"use strict"; |
|
13 |
+ |
|
14 |
+CodeMirror.defineMode("eiffel", function() { |
|
15 |
+ function wordObj(words) { |
|
16 |
+ var o = {}; |
|
17 |
+ for (var i = 0, e = words.length; i < e; ++i) o[words[i]] = true; |
|
18 |
+ return o; |
|
19 |
+ } |
|
20 |
+ var keywords = wordObj([ |
|
21 |
+ 'note', |
|
22 |
+ 'across', |
|
23 |
+ 'when', |
|
24 |
+ 'variant', |
|
25 |
+ 'until', |
|
26 |
+ 'unique', |
|
27 |
+ 'undefine', |
|
28 |
+ 'then', |
|
29 |
+ 'strip', |
|
30 |
+ 'select', |
|
31 |
+ 'retry', |
|
32 |
+ 'rescue', |
|
33 |
+ 'require', |
|
34 |
+ 'rename', |
|
35 |
+ 'reference', |
|
36 |
+ 'redefine', |
|
37 |
+ 'prefix', |
|
38 |
+ 'once', |
|
39 |
+ 'old', |
|
40 |
+ 'obsolete', |
|
41 |
+ 'loop', |
|
42 |
+ 'local', |
|
43 |
+ 'like', |
|
44 |
+ 'is', |
|
45 |
+ 'inspect', |
|
46 |
+ 'infix', |
|
47 |
+ 'include', |
|
48 |
+ 'if', |
|
49 |
+ 'frozen', |
|
50 |
+ 'from', |
|
51 |
+ 'external', |
|
52 |
+ 'export', |
|
53 |
+ 'ensure', |
|
54 |
+ 'end', |
|
55 |
+ 'elseif', |
|
56 |
+ 'else', |
|
57 |
+ 'do', |
|
58 |
+ 'creation', |
|
59 |
+ 'create', |
|
60 |
+ 'check', |
|
61 |
+ 'alias', |
|
62 |
+ 'agent', |
|
63 |
+ 'separate', |
|
64 |
+ 'invariant', |
|
65 |
+ 'inherit', |
|
66 |
+ 'indexing', |
|
67 |
+ 'feature', |
|
68 |
+ 'expanded', |
|
69 |
+ 'deferred', |
|
70 |
+ 'class', |
|
71 |
+ 'Void', |
|
72 |
+ 'True', |
|
73 |
+ 'Result', |
|
74 |
+ 'Precursor', |
|
75 |
+ 'False', |
|
76 |
+ 'Current', |
|
77 |
+ 'create', |
|
78 |
+ 'attached', |
|
79 |
+ 'detachable', |
|
80 |
+ 'as', |
|
81 |
+ 'and', |
|
82 |
+ 'implies', |
|
83 |
+ 'not', |
|
84 |
+ 'or' |
|
85 |
+ ]); |
|
86 |
+ var operators = wordObj([":=", "and then","and", "or","<<",">>"]); |
|
87 |
+ |
|
88 |
+ function chain(newtok, stream, state) { |
|
89 |
+ state.tokenize.push(newtok); |
|
90 |
+ return newtok(stream, state); |
|
91 |
+ } |
|
92 |
+ |
|
93 |
+ function tokenBase(stream, state) { |
|
94 |
+ if (stream.eatSpace()) return null; |
|
95 |
+ var ch = stream.next(); |
|
96 |
+ if (ch == '"'||ch == "'") { |
|
97 |
+ return chain(readQuoted(ch, "string"), stream, state); |
|
98 |
+ } else if (ch == "-"&&stream.eat("-")) { |
|
99 |
+ stream.skipToEnd(); |
|
100 |
+ return "comment"; |
|
101 |
+ } else if (ch == ":"&&stream.eat("=")) { |
|
102 |
+ return "operator"; |
|
103 |
+ } else if (/[0-9]/.test(ch)) { |
|
104 |
+ stream.eatWhile(/[xXbBCc0-9\.]/); |
|
105 |
+ stream.eat(/[\?\!]/); |
|
106 |
+ return "ident"; |
|
107 |
+ } else if (/[a-zA-Z_0-9]/.test(ch)) { |
|
108 |
+ stream.eatWhile(/[a-zA-Z_0-9]/); |
|
109 |
+ stream.eat(/[\?\!]/); |
|
110 |
+ return "ident"; |
|
111 |
+ } else if (/[=+\-\/*^%<>~]/.test(ch)) { |
|
112 |
+ stream.eatWhile(/[=+\-\/*^%<>~]/); |
|
113 |
+ return "operator"; |
|
114 |
+ } else { |
|
115 |
+ return null; |
|
116 |
+ } |
|
117 |
+ } |
|
118 |
+ |
|
119 |
+ function readQuoted(quote, style, unescaped) { |
|
120 |
+ return function(stream, state) { |
|
121 |
+ var escaped = false, ch; |
|
122 |
+ while ((ch = stream.next()) != null) { |
|
123 |
+ if (ch == quote && (unescaped || !escaped)) { |
|
124 |
+ state.tokenize.pop(); |
|
125 |
+ break; |
|
126 |
+ } |
|
127 |
+ escaped = !escaped && ch == "%"; |
|
128 |
+ } |
|
129 |
+ return style; |
|
130 |
+ }; |
|
131 |
+ } |
|
132 |
+ |
|
133 |
+ return { |
|
134 |
+ startState: function() { |
|
135 |
+ return {tokenize: [tokenBase]}; |
|
136 |
+ }, |
|
137 |
+ |
|
138 |
+ token: function(stream, state) { |
|
139 |
+ var style = state.tokenize[state.tokenize.length-1](stream, state); |
|
140 |
+ if (style == "ident") { |
|
141 |
+ var word = stream.current(); |
|
142 |
+ style = keywords.propertyIsEnumerable(stream.current()) ? "keyword" |
|
143 |
+ : operators.propertyIsEnumerable(stream.current()) ? "operator" |
|
144 |
+ : /^[A-Z][A-Z_0-9]*$/g.test(word) ? "tag" |
|
145 |
+ : /^0[bB][0-1]+$/g.test(word) ? "number" |
|
146 |
+ : /^0[cC][0-7]+$/g.test(word) ? "number" |
|
147 |
+ : /^0[xX][a-fA-F0-9]+$/g.test(word) ? "number" |
|
148 |
+ : /^([0-9]+\.[0-9]*)|([0-9]*\.[0-9]+)$/g.test(word) ? "number" |
|
149 |
+ : /^[0-9]+$/g.test(word) ? "number" |
|
150 |
+ : "variable"; |
|
151 |
+ } |
|
152 |
+ return style; |
|
153 |
+ }, |
|
154 |
+ lineComment: "--" |
|
155 |
+ }; |
|
156 |
+}); |
|
157 |
+ |
|
158 |
+CodeMirror.defineMIME("text/x-eiffel", "eiffel"); |
|
159 |
+ |
|
160 |
+}); |
... | ... |
@@ -16,8 +16,8 @@ pre { |
16 | 16 |
code { |
17 | 17 |
padding: 2pt 4pt; |
18 | 18 |
color: #d14; |
19 |
- background-color: #f7f7f9; |
|
20 |
- border: 1pt solid #e1e1e8; |
|
19 |
+ background-color: lighten(@bodyBackground, 15%); |
|
20 |
+ border: 1pt solid lighten(@bodyBackground, 10%); |
|
21 | 21 |
} |
22 | 22 |
|
23 | 23 |
// Blocks of code |
... | ... |
@@ -31,7 +31,7 @@ pre { |
31 | 31 |
word-wrap: break-word; |
32 | 32 |
white-space: pre; |
33 | 33 |
white-space: pre-wrap; |
34 |
- background-color: lighten(@bodyBackground, 5%); |
|
34 |
+ background-color: lighten(@bodyBackground, 50%); |
|
35 | 35 |
border: 1pt solid #ccc; // fallback for IE7-8 |
36 | 36 |
border: 1pt solid rgba(0,0,0,.15); |
37 | 37 |
.border-radius(4pt); |
... | ... |
@@ -52,7 +52,7 @@ |
52 | 52 |
.CodeMirror-gutter { |
53 | 53 |
position: absolute; left: 0; top: 0; |
54 | 54 |
z-index: 10; |
55 |
- background-color: lighten(@bodyBackground, 10%); |
|
55 |
+ background-color: lighten(@bodyBackground, 25%); |
|
56 | 56 |
border-right: 1pt solid #eee; |
57 | 57 |
min-width: 2em; |
58 | 58 |
height: 100%; |
... | ... |
@@ -173,7 +173,6 @@ http://ethanschoonover.com/solarized/img/solarized-palette.png |
173 | 173 |
.cm-s-solarized.cm-s-dark { |
174 | 174 |
color: #839496; |
175 | 175 |
background-color: #002b36; |
176 |
- text-shadow: #002b36 0 1px; |
|
177 | 176 |
} |
178 | 177 |
.cm-s-solarized.cm-s-light { |
179 | 178 |
background-color: #fdf6e3; |
... | ... |
@@ -11,7 +11,9 @@ |
11 | 11 |
<div class="source-header"> |
12 | 12 |
<div class="meta"></div> |
13 | 13 |
|
14 |
+ <script src="http://code.jquery.com/jquery-2.2.3.js"></script> |
|
14 | 15 |
<div class="btn-group pull-right"> |
16 |
+ <button type="button" id="colorswitch" class="btn btn-small">Light/Dark</button> |
|
15 | 17 |
<a href="{{ path('blob_raw', {repo: repo, commitishPath: branch ~ '/' ~ file}) }}" class="btn btn-small"><i class="icon-file"></i> Raw</a> |
16 | 18 |
<a href="{{ path('blame', {repo: repo, commitishPath: branch ~ '/' ~ file}) }}" class="btn btn-small"><i class="icon-bullhorn"></i> Blame</a> |
17 | 19 |
<a href="{{ path('commits', {repo: repo, commitishPath: branch ~ '/' ~ file}) }}" class="btn btn-small"><i class="icon-list-alt"></i> History</a> |
... | ... |
@@ -28,5 +30,19 @@ |
28 | 30 |
{% endif %} |
29 | 31 |
</div> |
30 | 32 |
|
33 |
+ <script type="text/javascript"> |
|
34 |
+ function flip () { |
|
35 |
+ var oldClass = 'cm-s-dark', newClass = 'cm-s-light'; |
|
36 |
+ var $target = $('.CodeMirror-scroll'); |
|
37 |
+ if ($target.hasClass('cm-s-light')) { |
|
38 |
+ oldClass = newClass; |
|
39 |
+ newClass = 'cm-s-dark'; |
|
40 |
+ } |
|
41 |
+ |
|
42 |
+ $target.removeClass(oldClass).addClass(newClass); |
|
43 |
+ } |
|
44 |
+ |
|
45 |
+ jQuery('#colorswitch').click(flip); |
|
46 |
+ </script> |
|
31 | 47 |
<hr /> |
32 | 48 |
{% endblock %} |
... | ... |
@@ -4,25 +4,28 @@ |
4 | 4 |
<meta charset="UTF-8" /> |
5 | 5 |
<title>{% block title %}Welcome!{% endblock %}</title> |
6 | 6 |
<link rel="stylesheet" type="text/css" href="{{ app.request.basepath }}/themes/{{ app.theme }}/css/style.css"> |
7 |
- <link rel="apple-touch-icon" sizes="57x57" href="/themes/ed/img/apple-touch-icon-57x57.png"> |
|
8 |
- <link rel="apple-touch-icon" sizes="114x114" href="/themes/ed/img/apple-touch-icon-114x114.png"> |
|
9 |
- <link rel="apple-touch-icon" sizes="72x72" href="/themes/ed/img/apple-touch-icon-72x72.png"> |
|
10 |
- <link rel="apple-touch-icon" sizes="144x144" href="/themes/ed/img/apple-touch-icon-144x144.png"> |
|
11 |
- <link rel="apple-touch-icon" sizes="60x60" href="/themes/ed/img/apple-touch-icon-60x60.png"> |
|
12 |
- <link rel="apple-touch-icon" sizes="120x120" href="/themes/ed/img/apple-touch-icon-120x120.png"> |
|
13 |
- <link rel="apple-touch-icon" sizes="76x76" href="/themes/ed/img/apple-touch-icon-76x76.png"> |
|
14 |
- <link rel="apple-touch-icon" sizes="152x152" href="/themes/ed/img/apple-touch-icon-152x152.png"> |
|
15 |
- <link rel="apple-touch-icon" sizes="180x180" href="/themes/ed/img/apple-touch-icon-180x180.png"> |
|
16 |
- <link rel="icon" type="image/png" href="/themes/ed/img/favicon-192x192.png" sizes="192x192"> |
|
17 |
- <link rel="icon" type="image/png" href="/themes/ed/img/favicon-160x160.png" sizes="160x160"> |
|
18 |
- <link rel="icon" type="image/png" href="/themes/ed/img/favicon-96x96.png" sizes="96x96"> |
|
19 |
- <link rel="icon" type="image/png" href="/themes/ed/img/favicon-16x16.png" sizes="16x16"> |
|
20 |
- <link rel="icon" type="image/png" href="/themes/ed/img/favicon-32x32.png" sizes="32x32"> |
|
21 |
- <link rel="icon" type="image/png" href="/themes/ed/img/favicon-48x48.png" sizes="48x48"> |
|
22 |
- <link rel="shortcut icon" href="/themes/ed/img/favicon.ico"> |
|
23 |
- <meta name="msapplication-TileColor" content="#6fc8d4"> |
|
24 |
- <meta name="msapplication-TileImage" content="/themes/ed/img/mstile-144x144.png"> |
|
25 |
- <meta name="msapplication-config" content="/themes/ed/img/browserconfig.xml"> |
|
7 |
+ <link rel="apple-touch-icon" sizes="57x57" href="{{app.request.basepath}}/themes/{app.theme}}/img/apple-touch-icon-57x57.png?v=wAAMKqR7RG"> |
|
8 |
+ <link rel="apple-touch-icon" sizes="60x60" href="{{app.request.basepath}}/themes/{app.theme}}/img/apple-touch-icon-60x60.png?v=wAAMKqR7RG"> |
|
9 |
+ <link rel="apple-touch-icon" sizes="72x72" href="{{app.request.basepath}}/themes/{app.theme}}/img/apple-touch-icon-72x72.png?v=wAAMKqR7RG"> |
|
10 |
+ <link rel="apple-touch-icon" sizes="76x76" href="{{app.request.basepath}}/themes/{app.theme}}/img/apple-touch-icon-76x76.png?v=wAAMKqR7RG"> |
|
11 |
+ <link rel="apple-touch-icon" sizes="114x114" href="{{app.request.basepath}}/themes/{{app.theme}}/img/apple-touch-icon-114x114.png?v=wAAMKqR7RG"> |
|
12 |
+ <link rel="apple-touch-icon" sizes="120x120" href="{{app.request.basepath}}/themes/{{app.theme}}/img/apple-touch-icon-120x120.png?v=wAAMKqR7RG"> |
|
13 |
+ <link rel="apple-touch-icon" sizes="144x144" href="{{app.request.basepath}}/themes/{{app.theme}}/img/apple-touch-icon-144x144.png?v=wAAMKqR7RG"> |
|
14 |
+ <link rel="apple-touch-icon" sizes="152x152" href="{{app.request.basepath}}/themes/{{app.theme}}/img/apple-touch-icon-152x152.png?v=wAAMKqR7RG"> |
|
15 |
+ <link rel="apple-touch-icon" sizes="180x180" href="{{app.request.basepath}}/themes/{{app.theme}}/img/apple-touch-icon-180x180.png?v=wAAMKqR7RG"> |
|
16 |
+ <link rel="icon" type="image/png" href="{{app.request.basepath}}/themes/{{app.theme}}/img/favicon-32x32.png?v=wAAMKqR7RG" sizes="32x32"> |
|
17 |
+ <link rel="icon" type="image/png" href="{{app.request.basepath}}/themes/{{app.theme}}/img/favicon-194x194.png?v=wAAMKqR7RG" sizes="194x194"> |
|
18 |
+ <link rel="icon" type="image/png" href="{{app.request.basepath}}/themes/{{app.theme}}/img/favicon-96x96.png?v=wAAMKqR7RG" sizes="96x96"> |
|
19 |
+ <link rel="icon" type="image/png" href="{{app.request.basepath}}/themes/{{app.theme}}/img/android-chrome-192x192.png?v=wAAMKqR7RG" sizes="192x192"> |
|
20 |
+ <link rel="icon" type="image/png" href="{{app.request.basepath}}/themes/{{app.theme}}/img/favicon-16x16.png?v=wAAMKqR7RG" sizes="16x16"> |
|
21 |
+ <link rel="manifest" href="{{app.request.basepath}}/themes/{{app.theme}}/img/manifest.json?v=wAAMKqR7RG"> |
|
22 |
+ <link rel="shortcut icon" href="{{app.request.basepath}}/themes/{{app.theme}}/img/favicon.ico?v=wAAMKqR7RG"> |
|
23 |
+ <meta name="apple-mobile-web-app-title" content="Whitespace"> |
|
24 |
+ <meta name="application-name" content="Whitespace"> |
|
25 |
+ <meta name="msapplication-TileColor" content="#ffffff"> |
|
26 |
+ <meta name="msapplication-TileImage" content="{{app.request.basepath}}/themes/{{app.theme}}/img/mstile-144x144.png?v=wAAMKqR7RG"> |
|
27 |
+ <meta name="msapplication-config" content="{{app.request.basepath}}/themes/{{app.theme}}/img/browserconfig.xml?v=wAAMKqR7RG"> |
|
28 |
+ <meta name="theme-color" content="#ffffff"> |
|
26 | 29 |
<!--[if lt IE 9]> |
27 | 30 |
<script src="{{ app.request.basepath }}/themes/{{ app.theme }}/js/html5.js"></script> |
28 | 31 |
<![endif]--> |
... | ... |
@@ -44,11 +47,18 @@ |
44 | 47 |
<script src="{{ app.request.basepath }}/themes/{{ app.theme }}/js/raphael.js"></script> |
45 | 48 |
<script src="{{ app.request.basepath }}/themes/{{ app.theme }}/js/bootstrap.js"></script> |
46 | 49 |
<script src="{{ app.request.basepath }}/themes/{{ app.theme }}/js/codemirror.js"></script> |
50 |
+ <script src="{{ app.request.basepath }}/themes/{{ app.theme }}/js/eiffel.js"></script> |
|
47 | 51 |
<script src="{{ app.request.basepath }}/themes/{{ app.theme }}/js/commonlisp.js"></script> |
48 | 52 |
<script src="{{ app.request.basepath }}/themes/{{ app.theme }}/js/showdown.js"></script> |
49 | 53 |
<script src="{{ app.request.basepath }}/themes/{{ app.theme }}/js/table.js"></script> |
50 | 54 |
<script src="{{ app.request.basepath }}/themes/{{ app.theme }}/js/list.min.js"></script> |
51 | 55 |
<script src="{{ app.request.basepath }}/themes/{{ app.theme }}/js/main.js"></script> |
52 | 56 |
<script src="{{ app.request.basepath }}/themes/{{ app.theme }}/js/networkGraph.js"></script> |
57 |
+ <script type="text/javascript"> |
|
58 |
+ if (flip !== undefined && window.location.hash === "#light") { |
|
59 |
+ console.log('let it be light!'); |
|
60 |
+ flip(); |
|
61 |
+ } |
|
62 |
+ </script> |
|
53 | 63 |
</body> |
54 | 64 |
</html> |