keydown 0.7.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.travis.yml +3 -0
- data/LICENSE +1 -1
- data/README.md +16 -15
- data/VERSION +1 -1
- data/keydown.gemspec +9 -6
- data/lib/keydown.rb +9 -22
- data/lib/keydown/html_helpers.rb +12 -0
- data/lib/keydown/{lib/slide.rb → slide.rb} +16 -19
- data/lib/keydown/{lib/slidedeck.rb → slidedeck.rb} +20 -5
- data/lib/keydown/tasks.rb +5 -0
- data/lib/keydown/tasks/base.rb +15 -0
- data/lib/keydown/tasks/generate.rb +5 -1
- data/lib/keydown/tasks/slides.rb +1 -1
- data/lib/version.rb +1 -1
- data/spec/lib/html_helpers_spec.rb +26 -0
- data/spec/lib/slide_spec.rb +29 -17
- data/spec/lib/slidedeck_spec.rb +41 -13
- data/spec/spec_helper.rb +2 -6
- data/spec/tasks/generate_spec.rb +41 -20
- data/spec/tasks/slides_spec.rb +83 -44
- data/templates/deck.js/code.html.haml +1 -0
- data/templates/deck.js/index.html.haml +54 -0
- data/templates/deck.js/slide.html.haml +6 -0
- data/templates/generate/css/%presentation_name%.css +12 -1
- data/templates/generate/deck.js/core/deck.core.css +394 -0
- data/templates/generate/deck.js/core/deck.core.js +461 -0
- data/templates/generate/deck.js/core/deck.core.scss +432 -0
- data/templates/generate/deck.js/extensions/codemirror/CONTRIBUTORS.txt +2 -0
- data/templates/generate/deck.js/extensions/codemirror/MIT-LICENSE.txt +21 -0
- data/templates/generate/deck.js/extensions/codemirror/README.md +120 -0
- data/templates/generate/deck.js/extensions/codemirror/VERSION.txt +1 -0
- data/templates/generate/deck.js/extensions/codemirror/codemirror.js +21 -0
- data/templates/generate/deck.js/extensions/codemirror/deck.codemirror.css +89 -0
- data/templates/generate/deck.js/extensions/codemirror/deck.codemirror.js +213 -0
- data/templates/generate/deck.js/extensions/codemirror/deck.codemirror.scss +107 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/clike/clike.js +247 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/clike/index.html +102 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/clojure/clojure.js +207 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/clojure/index.html +85 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/coffeescript/LICENSE +22 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/coffeescript/coffeescript.js +325 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/coffeescript/index.html +722 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/css/css.js +124 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/css/index.html +56 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/diff/diff.css +3 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/diff/diff.js +13 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/diff/index.html +99 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/haskell/haskell.js +242 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/haskell/index.html +60 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/htmlmixed/htmlmixed.js +79 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/htmlmixed/index.html +52 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/javascript/index.html +78 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/javascript/javascript.js +348 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/lua/index.html +72 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/lua/lua.js +138 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/php/index.html +49 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/php/php.js +115 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/plsql/index.html +63 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/plsql/plsql.js +217 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/python/LICENSE.txt +21 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/python/index.html +123 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/python/python.js +321 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/r/LICENSE +24 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/r/index.html +74 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/r/r.js +141 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/rst/index.html +526 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/rst/rst.css +75 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/rst/rst.js +333 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/ruby/LICENSE +24 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/ruby/index.html +172 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/ruby/ruby.js +195 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/scheme/index.html +65 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/scheme/scheme.js +202 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/smalltalk/index.html +56 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/smalltalk/smalltalk.js +122 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/sparql/index.html +41 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/sparql/sparql.js +143 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/stex/index.html +96 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/stex/stex.js +167 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/velocity/index.html +103 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/velocity/velocity.js +146 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/xml/index.html +42 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/xml/xml.js +231 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/xmlpure/index.html +60 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/xmlpure/xmlpure.js +481 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/yaml/index.html +68 -0
- data/templates/generate/deck.js/extensions/codemirror/mode/yaml/yaml.js +95 -0
- data/templates/generate/deck.js/extensions/codemirror/themes/cobalt.css +17 -0
- data/templates/generate/deck.js/extensions/codemirror/themes/default.css +19 -0
- data/templates/generate/deck.js/extensions/codemirror/themes/elegant.css +9 -0
- data/templates/generate/deck.js/extensions/codemirror/themes/neat.css +8 -0
- data/templates/generate/deck.js/extensions/codemirror/themes/night.css +20 -0
- data/templates/generate/deck.js/extensions/goto/deck.goto.css +41 -0
- data/templates/generate/deck.js/extensions/goto/deck.goto.html +6 -0
- data/templates/generate/deck.js/extensions/goto/deck.goto.js +118 -0
- data/templates/generate/deck.js/extensions/goto/deck.goto.scss +46 -0
- data/templates/generate/deck.js/extensions/hash/deck.hash.css +13 -0
- data/templates/generate/deck.js/extensions/hash/deck.hash.html +2 -0
- data/templates/generate/deck.js/extensions/hash/deck.hash.js +125 -0
- data/templates/generate/deck.js/extensions/hash/deck.hash.scss +15 -0
- data/templates/generate/deck.js/extensions/menu/deck.menu.css +24 -0
- data/templates/generate/deck.js/extensions/menu/deck.menu.js +127 -0
- data/templates/generate/deck.js/extensions/menu/deck.menu.scss +29 -0
- data/templates/generate/deck.js/extensions/navigation/deck.navigation.css +43 -0
- data/templates/generate/deck.js/extensions/navigation/deck.navigation.html +3 -0
- data/templates/generate/deck.js/extensions/navigation/deck.navigation.js +83 -0
- data/templates/generate/deck.js/extensions/navigation/deck.navigation.scss +56 -0
- data/templates/generate/deck.js/extensions/scale/deck.scale.css +16 -0
- data/templates/generate/deck.js/extensions/scale/deck.scale.js +155 -0
- data/templates/generate/deck.js/extensions/scale/deck.scale.scss +17 -0
- data/templates/generate/deck.js/extensions/status/deck.status.css +14 -0
- data/templates/generate/deck.js/extensions/status/deck.status.html +6 -0
- data/templates/generate/deck.js/extensions/status/deck.status.js +42 -0
- data/templates/generate/deck.js/extensions/status/deck.status.scss +16 -0
- data/templates/generate/deck.js/support/jquery.1.6.4.min.js +4 -0
- data/templates/generate/deck.js/support/modernizr.custom.js +4 -0
- data/templates/generate/deck.js/themes/style/neon.css +114 -0
- data/templates/generate/deck.js/themes/style/neon.scss +139 -0
- data/templates/generate/deck.js/themes/style/swiss.css +75 -0
- data/templates/generate/deck.js/themes/style/swiss.scss +91 -0
- data/templates/generate/deck.js/themes/style/web-2.0.css +187 -0
- data/templates/generate/deck.js/themes/style/web-2.0.scss +214 -0
- data/templates/generate/deck.js/themes/transition/fade.css +44 -0
- data/templates/generate/deck.js/themes/transition/fade.scss +70 -0
- data/templates/generate/deck.js/themes/transition/horizontal-slide.css +79 -0
- data/templates/generate/deck.js/themes/transition/horizontal-slide.scss +94 -0
- data/templates/generate/deck.js/themes/transition/vertical-slide.css +97 -0
- data/templates/generate/deck.js/themes/transition/vertical-slide.scss +116 -0
- data/templates/keydown.css.erb +27 -23
- metadata +171 -32
- data/Gemfile.lock +0 -41
- data/templates/generate/css/rocks.css +0 -392
- data/templates/generate/css/syntax_highlighting.css +0 -135
- data/templates/generate/js/rocks.js +0 -419
- data/templates/rocks/index.rhtml +0 -132
- data/templates/rocks/slide.rhtml +0 -10
@@ -0,0 +1,107 @@
|
|
1
|
+
.deck-container .slide {
|
2
|
+
|
3
|
+
font-weight: normal;
|
4
|
+
.deck-codemirror-result {
|
5
|
+
border: 1px solid #ddd;
|
6
|
+
border-top: none;
|
7
|
+
padding: 10px;
|
8
|
+
font-family: monospace;
|
9
|
+
}
|
10
|
+
.CodeMirror {
|
11
|
+
line-height: 1em;
|
12
|
+
font-family: monospace;
|
13
|
+
overflow: auto;
|
14
|
+
height: 100%;
|
15
|
+
border: 1px solid #ddd;
|
16
|
+
|
17
|
+
.button {
|
18
|
+
padding: 5px;
|
19
|
+
cursor: pointer;
|
20
|
+
background-color: #ddd;
|
21
|
+
position: relative;
|
22
|
+
float: right;
|
23
|
+
font-size: 11px;
|
24
|
+
line-height: 16px;
|
25
|
+
padding: 2px 6px;
|
26
|
+
margin-bottom: -20px;
|
27
|
+
margin-right: 10px;
|
28
|
+
border-radius: 4px;
|
29
|
+
-moz-border-radius: 4px;
|
30
|
+
-webkit-border-radius: 4px;
|
31
|
+
z-index: 1;
|
32
|
+
top: 8px;
|
33
|
+
}
|
34
|
+
.button:hover {
|
35
|
+
background-color: #eee;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
.CodeMirror-scroll {
|
40
|
+
/* overflow: auto; */
|
41
|
+
|
42
|
+
/* This is needed to prevent an IE[67] bug where the scrolled content
|
43
|
+
is visible outside of the scrolling box. */
|
44
|
+
position: relative;
|
45
|
+
height: auto;
|
46
|
+
overflow-y: hidden;
|
47
|
+
overflow-x: auto;
|
48
|
+
width: 100%
|
49
|
+
}
|
50
|
+
|
51
|
+
.CodeMirror-gutter {
|
52
|
+
position: absolute; left: 0; top: 0;
|
53
|
+
z-index: 10;
|
54
|
+
background-color: #f7f7f7;
|
55
|
+
border-right: 1px solid #eee;
|
56
|
+
min-width: 2em;
|
57
|
+
height: 100%;
|
58
|
+
}
|
59
|
+
|
60
|
+
.CodeMirror-gutter-text {
|
61
|
+
color: #aaa;
|
62
|
+
text-align: right;
|
63
|
+
padding: .4em .2em .4em .4em;
|
64
|
+
}
|
65
|
+
.CodeMirror-lines {
|
66
|
+
padding: .4em;
|
67
|
+
}
|
68
|
+
|
69
|
+
.CodeMirror pre {
|
70
|
+
-moz-border-radius: 0;
|
71
|
+
-webkit-border-radius: 0;
|
72
|
+
-o-border-radius: 0;
|
73
|
+
border-radius: 0;
|
74
|
+
border-width: 0; margin: 0; padding: 0; background: transparent;
|
75
|
+
font-family: inherit;
|
76
|
+
font-size: inherit;
|
77
|
+
padding: 0; margin: 0;
|
78
|
+
white-space: pre;
|
79
|
+
word-wrap: normal;
|
80
|
+
}
|
81
|
+
|
82
|
+
.CodeMirror textarea {
|
83
|
+
font-family: inherit !important;
|
84
|
+
font-size: inherit !important;
|
85
|
+
}
|
86
|
+
|
87
|
+
.CodeMirror-cursor {
|
88
|
+
z-index: 10;
|
89
|
+
position: absolute;
|
90
|
+
visibility: hidden;
|
91
|
+
border-left: 1px solid black !important;
|
92
|
+
}
|
93
|
+
.CodeMirror-focused .CodeMirror-cursor {
|
94
|
+
visibility: visible;
|
95
|
+
}
|
96
|
+
|
97
|
+
span.CodeMirror-selected {
|
98
|
+
background: #ccc !important;
|
99
|
+
color: HighlightText !important;
|
100
|
+
}
|
101
|
+
.CodeMirror-focused span.CodeMirror-selected {
|
102
|
+
background: Highlight !important;
|
103
|
+
}
|
104
|
+
|
105
|
+
.CodeMirror-matchingbracket {color: #0f0 !important;}
|
106
|
+
.CodeMirror-nonmatchingbracket {color: #f22 !important;}
|
107
|
+
}
|
@@ -0,0 +1,247 @@
|
|
1
|
+
CodeMirror.defineMode("clike", function(config, parserConfig) {
|
2
|
+
var indentUnit = config.indentUnit,
|
3
|
+
keywords = parserConfig.keywords || {},
|
4
|
+
blockKeywords = parserConfig.blockKeywords || {},
|
5
|
+
atoms = parserConfig.atoms || {},
|
6
|
+
hooks = parserConfig.hooks || {},
|
7
|
+
multiLineStrings = parserConfig.multiLineStrings;
|
8
|
+
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
|
9
|
+
|
10
|
+
var curPunc;
|
11
|
+
|
12
|
+
function tokenBase(stream, state) {
|
13
|
+
var ch = stream.next();
|
14
|
+
if (hooks[ch]) {
|
15
|
+
var result = hooks[ch](stream, state);
|
16
|
+
if (result !== false) return result;
|
17
|
+
}
|
18
|
+
if (ch == '"' || ch == "'") {
|
19
|
+
state.tokenize = tokenString(ch);
|
20
|
+
return state.tokenize(stream, state);
|
21
|
+
}
|
22
|
+
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
23
|
+
curPunc = ch;
|
24
|
+
return null
|
25
|
+
}
|
26
|
+
if (/\d/.test(ch)) {
|
27
|
+
stream.eatWhile(/[\w\.]/);
|
28
|
+
return "number";
|
29
|
+
}
|
30
|
+
if (ch == "/") {
|
31
|
+
if (stream.eat("*")) {
|
32
|
+
state.tokenize = tokenComment;
|
33
|
+
return tokenComment(stream, state);
|
34
|
+
}
|
35
|
+
if (stream.eat("/")) {
|
36
|
+
stream.skipToEnd();
|
37
|
+
return "comment";
|
38
|
+
}
|
39
|
+
}
|
40
|
+
if (isOperatorChar.test(ch)) {
|
41
|
+
stream.eatWhile(isOperatorChar);
|
42
|
+
return "operator";
|
43
|
+
}
|
44
|
+
stream.eatWhile(/[\w\$_]/);
|
45
|
+
var cur = stream.current();
|
46
|
+
if (keywords.propertyIsEnumerable(cur)) {
|
47
|
+
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
48
|
+
return "keyword";
|
49
|
+
}
|
50
|
+
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
51
|
+
return "word";
|
52
|
+
}
|
53
|
+
|
54
|
+
function tokenString(quote) {
|
55
|
+
return function(stream, state) {
|
56
|
+
var escaped = false, next, end = false;
|
57
|
+
while ((next = stream.next()) != null) {
|
58
|
+
if (next == quote && !escaped) {end = true; break;}
|
59
|
+
escaped = !escaped && next == "\\";
|
60
|
+
}
|
61
|
+
if (end || !(escaped || multiLineStrings))
|
62
|
+
state.tokenize = tokenBase;
|
63
|
+
return "string";
|
64
|
+
};
|
65
|
+
}
|
66
|
+
|
67
|
+
function tokenComment(stream, state) {
|
68
|
+
var maybeEnd = false, ch;
|
69
|
+
while (ch = stream.next()) {
|
70
|
+
if (ch == "/" && maybeEnd) {
|
71
|
+
state.tokenize = tokenBase;
|
72
|
+
break;
|
73
|
+
}
|
74
|
+
maybeEnd = (ch == "*");
|
75
|
+
}
|
76
|
+
return "comment";
|
77
|
+
}
|
78
|
+
|
79
|
+
function Context(indented, column, type, align, prev) {
|
80
|
+
this.indented = indented;
|
81
|
+
this.column = column;
|
82
|
+
this.type = type;
|
83
|
+
this.align = align;
|
84
|
+
this.prev = prev;
|
85
|
+
}
|
86
|
+
function pushContext(state, col, type) {
|
87
|
+
return state.context = new Context(state.indented, col, type, null, state.context);
|
88
|
+
}
|
89
|
+
function popContext(state) {
|
90
|
+
var t = state.context.type;
|
91
|
+
if (t == ")" || t == "]" || t == "}")
|
92
|
+
state.indented = state.context.indented;
|
93
|
+
return state.context = state.context.prev;
|
94
|
+
}
|
95
|
+
|
96
|
+
// Interface
|
97
|
+
|
98
|
+
return {
|
99
|
+
startState: function(basecolumn) {
|
100
|
+
return {
|
101
|
+
tokenize: null,
|
102
|
+
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
103
|
+
indented: 0,
|
104
|
+
startOfLine: true
|
105
|
+
};
|
106
|
+
},
|
107
|
+
|
108
|
+
token: function(stream, state) {
|
109
|
+
var ctx = state.context;
|
110
|
+
if (stream.sol()) {
|
111
|
+
if (ctx.align == null) ctx.align = false;
|
112
|
+
state.indented = stream.indentation();
|
113
|
+
state.startOfLine = true;
|
114
|
+
}
|
115
|
+
if (stream.eatSpace()) return null;
|
116
|
+
curPunc = null;
|
117
|
+
var style = (state.tokenize || tokenBase)(stream, state);
|
118
|
+
if (style == "comment" || style == "meta") return style;
|
119
|
+
if (ctx.align == null) ctx.align = true;
|
120
|
+
|
121
|
+
if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
|
122
|
+
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
123
|
+
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
124
|
+
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
125
|
+
else if (curPunc == "}") {
|
126
|
+
while (ctx.type == "statement") ctx = popContext(state);
|
127
|
+
if (ctx.type == "}") ctx = popContext(state);
|
128
|
+
while (ctx.type == "statement") ctx = popContext(state);
|
129
|
+
}
|
130
|
+
else if (curPunc == ctx.type) popContext(state);
|
131
|
+
else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
|
132
|
+
pushContext(state, stream.column(), "statement");
|
133
|
+
state.startOfLine = false;
|
134
|
+
return style;
|
135
|
+
},
|
136
|
+
|
137
|
+
indent: function(state, textAfter) {
|
138
|
+
if (state.tokenize != tokenBase && state.tokenize != null) return 0;
|
139
|
+
var firstChar = textAfter && textAfter.charAt(0), ctx = state.context, closing = firstChar == ctx.type;
|
140
|
+
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
|
141
|
+
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
|
142
|
+
else return ctx.indented + (closing ? 0 : indentUnit);
|
143
|
+
},
|
144
|
+
|
145
|
+
electricChars: "{}"
|
146
|
+
};
|
147
|
+
});
|
148
|
+
|
149
|
+
(function() {
|
150
|
+
function words(str) {
|
151
|
+
var obj = {}, words = str.split(" ");
|
152
|
+
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
153
|
+
return obj;
|
154
|
+
}
|
155
|
+
var cKeywords = "auto if break int case long char register continue return default short do sizeof " +
|
156
|
+
"double static else struct entry switch extern typedef float union for unsigned " +
|
157
|
+
"goto while enum void const signed volatile";
|
158
|
+
|
159
|
+
function cppHook(stream, state) {
|
160
|
+
if (!state.startOfLine) return false;
|
161
|
+
stream.skipToEnd();
|
162
|
+
return "meta";
|
163
|
+
}
|
164
|
+
|
165
|
+
// C#-style strings where "" escapes a quote.
|
166
|
+
function tokenAtString(stream, state) {
|
167
|
+
var next;
|
168
|
+
while ((next = stream.next()) != null) {
|
169
|
+
if (next == '"' && !stream.eat('"')) {
|
170
|
+
state.tokenize = null;
|
171
|
+
break;
|
172
|
+
}
|
173
|
+
}
|
174
|
+
return "string";
|
175
|
+
}
|
176
|
+
|
177
|
+
CodeMirror.defineMIME("text/x-csrc", {
|
178
|
+
name: "clike",
|
179
|
+
keywords: words(cKeywords),
|
180
|
+
blockKeywords: words("case do else for if switch while struct"),
|
181
|
+
atoms: words("null"),
|
182
|
+
hooks: {"#": cppHook}
|
183
|
+
});
|
184
|
+
CodeMirror.defineMIME("text/x-c++src", {
|
185
|
+
name: "clike",
|
186
|
+
keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try bool explicit new " +
|
187
|
+
"static_cast typeid catch operator template typename class friend private " +
|
188
|
+
"this using const_cast inline public throw virtual delete mutable protected " +
|
189
|
+
"wchar_t"),
|
190
|
+
blockKeywords: words("catch class do else finally for if struct switch try while"),
|
191
|
+
atoms: words("true false null"),
|
192
|
+
hooks: {"#": cppHook}
|
193
|
+
});
|
194
|
+
CodeMirror.defineMIME("text/x-java", {
|
195
|
+
name: "clike",
|
196
|
+
keywords: words("abstract assert boolean break byte case catch char class const continue default " +
|
197
|
+
"do double else enum extends final finally float for goto if implements import " +
|
198
|
+
"instanceof int interface long native new package private protected public " +
|
199
|
+
"return short static strictfp super switch synchronized this throw throws transient " +
|
200
|
+
"try void volatile while"),
|
201
|
+
blockKeywords: words("catch class do else finally for if switch try while"),
|
202
|
+
atoms: words("true false null"),
|
203
|
+
hooks: {
|
204
|
+
"@": function(stream, state) {
|
205
|
+
stream.eatWhile(/[\w\$_]/);
|
206
|
+
return "meta";
|
207
|
+
}
|
208
|
+
}
|
209
|
+
});
|
210
|
+
CodeMirror.defineMIME("text/x-csharp", {
|
211
|
+
name: "clike",
|
212
|
+
keywords: words("abstract as base bool break byte case catch char checked class const continue decimal" +
|
213
|
+
" default delegate do double else enum event explicit extern finally fixed float for" +
|
214
|
+
" foreach goto if implicit in int interface internal is lock long namespace new object" +
|
215
|
+
" operator out override params private protected public readonly ref return sbyte sealed short" +
|
216
|
+
" sizeof stackalloc static string struct switch this throw try typeof uint ulong unchecked" +
|
217
|
+
" unsafe ushort using virtual void volatile while add alias ascending descending dynamic from get" +
|
218
|
+
" global group into join let orderby partial remove select set value var yield"),
|
219
|
+
blockKeywords: words("catch class do else finally for foreach if struct switch try while"),
|
220
|
+
atoms: words("true false null"),
|
221
|
+
hooks: {
|
222
|
+
"@": function(stream, state) {
|
223
|
+
if (stream.eat('"')) {
|
224
|
+
state.tokenize = tokenAtString;
|
225
|
+
return tokenAtString(stream, state);
|
226
|
+
}
|
227
|
+
stream.eatWhile(/[\w\$_]/);
|
228
|
+
return "meta";
|
229
|
+
}
|
230
|
+
}
|
231
|
+
});
|
232
|
+
CodeMirror.defineMIME("text/x-groovy", {
|
233
|
+
name: "clike",
|
234
|
+
keywords: words("abstract as assert boolean break byte case catch char class const continue def default " +
|
235
|
+
"do double else enum extends final finally float for goto if implements import " +
|
236
|
+
"in instanceof int interface long native new package property private protected public " +
|
237
|
+
"return short static strictfp super switch synchronized this throw throws transient " +
|
238
|
+
"try void volatile while"),
|
239
|
+
atoms: words("true false null"),
|
240
|
+
hooks: {
|
241
|
+
"@": function(stream, state) {
|
242
|
+
stream.eatWhile(/[\w\$_]/);
|
243
|
+
return "meta";
|
244
|
+
}
|
245
|
+
}
|
246
|
+
});
|
247
|
+
}());
|
@@ -0,0 +1,102 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>CodeMirror 2: C-like mode</title>
|
5
|
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
6
|
+
<script src="../../lib/codemirror.js"></script>
|
7
|
+
<script src="clike.js"></script>
|
8
|
+
<link rel="stylesheet" href="../../theme/default.css">
|
9
|
+
<link rel="stylesheet" href="../../css/docs.css">
|
10
|
+
<style>.CodeMirror {border: 2px inset #dee;}</style>
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<h1>CodeMirror 2: C-like mode</h1>
|
14
|
+
|
15
|
+
<form><textarea id="code" name="code">
|
16
|
+
/* C demo code */
|
17
|
+
|
18
|
+
#include <zmq.h>
|
19
|
+
#include <pthread.h>
|
20
|
+
#include <semaphore.h>
|
21
|
+
#include <time.h>
|
22
|
+
#include <stdio.h>
|
23
|
+
#include <fcntl.h>
|
24
|
+
#include <malloc.h>
|
25
|
+
|
26
|
+
typedef struct {
|
27
|
+
void* arg_socket;
|
28
|
+
zmq_msg_t* arg_msg;
|
29
|
+
char* arg_string;
|
30
|
+
unsigned long arg_len;
|
31
|
+
int arg_int, arg_command;
|
32
|
+
|
33
|
+
int signal_fd;
|
34
|
+
int pad;
|
35
|
+
void* context;
|
36
|
+
sem_t sem;
|
37
|
+
} acl_zmq_context;
|
38
|
+
|
39
|
+
#define p(X) (context->arg_##X)
|
40
|
+
|
41
|
+
void* zmq_thread(void* context_pointer) {
|
42
|
+
acl_zmq_context* context = (acl_zmq_context*)context_pointer;
|
43
|
+
char ok = 'K', err = 'X';
|
44
|
+
int res;
|
45
|
+
|
46
|
+
while (1) {
|
47
|
+
while ((res = sem_wait(&context->sem)) == EINTR);
|
48
|
+
if (res) {write(context->signal_fd, &err, 1); goto cleanup;}
|
49
|
+
switch(p(command)) {
|
50
|
+
case 0: goto cleanup;
|
51
|
+
case 1: p(socket) = zmq_socket(context->context, p(int)); break;
|
52
|
+
case 2: p(int) = zmq_close(p(socket)); break;
|
53
|
+
case 3: p(int) = zmq_bind(p(socket), p(string)); break;
|
54
|
+
case 4: p(int) = zmq_connect(p(socket), p(string)); break;
|
55
|
+
case 5: p(int) = zmq_getsockopt(p(socket), p(int), (void*)p(string), &p(len)); break;
|
56
|
+
case 6: p(int) = zmq_setsockopt(p(socket), p(int), (void*)p(string), p(len)); break;
|
57
|
+
case 7: p(int) = zmq_send(p(socket), p(msg), p(int)); break;
|
58
|
+
case 8: p(int) = zmq_recv(p(socket), p(msg), p(int)); break;
|
59
|
+
case 9: p(int) = zmq_poll(p(socket), p(int), p(len)); break;
|
60
|
+
}
|
61
|
+
p(command) = errno;
|
62
|
+
write(context->signal_fd, &ok, 1);
|
63
|
+
}
|
64
|
+
cleanup:
|
65
|
+
close(context->signal_fd);
|
66
|
+
free(context_pointer);
|
67
|
+
return 0;
|
68
|
+
}
|
69
|
+
|
70
|
+
void* zmq_thread_init(void* zmq_context, int signal_fd) {
|
71
|
+
acl_zmq_context* context = malloc(sizeof(acl_zmq_context));
|
72
|
+
pthread_t thread;
|
73
|
+
|
74
|
+
context->context = zmq_context;
|
75
|
+
context->signal_fd = signal_fd;
|
76
|
+
sem_init(&context->sem, 1, 0);
|
77
|
+
pthread_create(&thread, 0, &zmq_thread, context);
|
78
|
+
pthread_detach(thread);
|
79
|
+
return context;
|
80
|
+
}
|
81
|
+
</textarea></form>
|
82
|
+
|
83
|
+
<script>
|
84
|
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
85
|
+
lineNumbers: true,
|
86
|
+
matchBrackets: true,
|
87
|
+
mode: "text/x-csrc"
|
88
|
+
});
|
89
|
+
</script>
|
90
|
+
|
91
|
+
<p>Simple mode that tries to handle C-like languages as well as it
|
92
|
+
can. Takes two configuration parameters: <code>keywords</code>, an
|
93
|
+
object whose property names are the keywords in the language,
|
94
|
+
and <code>useCPP</code>, which determines whether C preprocessor
|
95
|
+
directives are recognized.</p>
|
96
|
+
|
97
|
+
<p><strong>MIME types defined:</strong> <code>text/x-csrc</code>
|
98
|
+
(C code), <code>text/x-c++src</code> (C++
|
99
|
+
code), <code>text/x-java</code> (Java
|
100
|
+
code), <code>text/x-groovy</code> (Groovy code).</p>
|
101
|
+
</body>
|
102
|
+
</html>
|