luca 0.9.89 → 0.9.91
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +11 -1
- data/Gemfile +5 -2
- data/Gemfile.lock +84 -56
- data/Rakefile +10 -2
- data/app/assets/javascripts/luca/components/application.coffee +82 -89
- data/app/assets/javascripts/luca/components/collection_view.coffee +9 -5
- data/app/assets/javascripts/luca/components/controller.coffee +72 -11
- data/app/assets/javascripts/luca/components/fields/base.coffee +61 -8
- data/app/assets/javascripts/luca/components/fields/button_field.coffee +53 -7
- data/app/assets/javascripts/luca/components/fields/checkbox_array.coffee +12 -7
- data/app/assets/javascripts/luca/components/fields/text_field.coffee +1 -1
- data/app/assets/javascripts/luca/components/form_view.coffee +2 -2
- data/app/assets/javascripts/luca/components/grid_layout_view.coffee +0 -1
- data/app/assets/javascripts/luca/components/page.coffee +1 -0
- data/app/assets/javascripts/luca/components/table_view.coffee +2 -2
- data/app/assets/javascripts/luca/concerns/dom_helpers.coffee +2 -2
- data/app/assets/javascripts/luca/containers/card_view.coffee +84 -54
- data/app/assets/javascripts/luca/containers/container.coffee +126 -46
- data/app/assets/javascripts/luca/containers/modal_view.coffee +9 -9
- data/app/assets/javascripts/luca/containers/page_controller.coffee +25 -0
- data/app/assets/javascripts/luca/containers/panel_toolbar.coffee +1 -1
- data/app/assets/javascripts/luca/containers/viewport.coffee +2 -5
- data/app/assets/javascripts/luca/core/collection.coffee +18 -4
- data/app/assets/javascripts/luca/core/model.coffee +1 -1
- data/app/assets/javascripts/luca/core/panel.coffee +1 -1
- data/app/assets/javascripts/luca/core/view.coffee +26 -7
- data/app/assets/javascripts/luca/development/code_sync_manager.coffee +51 -4
- data/app/assets/javascripts/luca/development/console.coffee +1 -1
- data/app/assets/javascripts/luca/framework.coffee +1 -1
- data/app/assets/javascripts/luca/index.coffee +1 -0
- data/app/assets/javascripts/luca/util/luca.coffee +2 -1
- data/app/assets/stylesheets/luca/components/viewport.scss +0 -4
- data/bin/luca +14 -0
- data/docs/framework.json +1 -1
- data/docs/luca-framework-documentation.js +1 -0
- data/lib/luca/cli/generate.rb +37 -0
- data/lib/luca/cli/server.rb +20 -0
- data/lib/luca/cli/sync.rb +40 -0
- data/lib/luca/cli/watch.rb +16 -0
- data/lib/luca/cli.rb +68 -0
- data/lib/luca/collection/endpoint.rb +1 -0
- data/lib/luca/component_definition.rb +23 -5
- data/lib/luca/luca_application.rb +18 -7
- data/lib/luca/rails/version.rb +1 -1
- data/lib/luca/server.rb +7 -0
- data/lib/luca/stylesheet.rb +2 -3
- data/lib/luca/version.rb +3 -0
- data/lib/luca/watcher.rb +72 -0
- data/lib/luca.rb +8 -1
- data/luca.gemspec +14 -7
- data/site/.bundle/config +2 -0
- data/site/.gitignore +5 -0
- data/site/.rvmrc +1 -0
- data/site/CHANGELOG.md +41 -0
- data/site/DOCS.md +41 -0
- data/site/Gemfile +8 -0
- data/site/Gemfile.lock +134 -0
- data/site/LICENSE.md +19 -0
- data/site/config.rb +84 -0
- data/site/helpers/site_helpers.rb +20 -0
- data/site/html5bp-docs/README.md +38 -0
- data/site/html5bp-docs/contribute.md +104 -0
- data/site/html5bp-docs/crossdomain.md +21 -0
- data/site/html5bp-docs/css.md +135 -0
- data/site/html5bp-docs/extend.md +507 -0
- data/site/html5bp-docs/faq.md +77 -0
- data/site/html5bp-docs/htaccess.md +323 -0
- data/site/html5bp-docs/html.md +170 -0
- data/site/html5bp-docs/js.md +31 -0
- data/site/html5bp-docs/misc.md +25 -0
- data/site/html5bp-docs/usage.md +109 -0
- data/site/readme.md +47 -0
- data/site/source/.htaccess +540 -0
- data/site/source/404.html +157 -0
- data/site/source/app/assets/javascripts/dependencies.js.coffee +6 -0
- data/site/source/app/assets/javascripts/docs/application.coffee +64 -0
- data/site/source/app/assets/javascripts/docs/collections/docs_documentation.coffee +17 -0
- data/site/source/app/assets/javascripts/docs/collections/github_repositories.coffee +7 -0
- data/site/source/app/assets/javascripts/docs/collections/index.coffee +1 -0
- data/site/source/app/assets/javascripts/docs/collections/luca_documentation.coffee +17 -0
- data/site/source/app/assets/javascripts/docs/collections/public_gists.coffee +4 -0
- data/site/source/app/assets/javascripts/docs/config.coffee +5 -0
- data/site/source/app/assets/javascripts/docs/index.coffee +12 -0
- data/site/source/app/assets/javascripts/docs/lib/router.coffee +3 -0
- data/site/source/app/assets/javascripts/docs/lib/util.coffee +0 -0
- data/site/source/app/assets/javascripts/docs/models/component.coffee +99 -0
- data/site/source/app/assets/javascripts/docs/models/github_repository.coffee +3 -0
- data/site/source/app/assets/javascripts/docs/models/index.coffee +1 -0
- data/site/source/app/assets/javascripts/docs/templates/component_documentation.jst.ejs +55 -0
- data/site/source/app/assets/javascripts/docs/templates/examples_browser/overview.jst.ejs +4 -0
- data/site/source/app/assets/javascripts/docs/templates/examples_browser/selector.jst.ejs +11 -0
- data/site/source/app/assets/javascripts/docs/templates/github_repository.jst.ejs +4 -0
- data/site/source/app/assets/javascripts/docs/templates/layouts/main.jst.ejs +4 -0
- data/site/source/app/assets/javascripts/docs/templates/left_navigation.jst.ejs +5 -0
- data/site/source/app/assets/javascripts/docs/templates/pages/getting_started.jst.ejs +78 -0
- data/site/source/app/assets/javascripts/docs/templates/pages/home.jst.ejs +57 -0
- data/site/source/app/assets/javascripts/docs/views/components/code_editor/index.coffee +0 -0
- data/site/source/app/assets/javascripts/docs/views/components/code_editor.coffee +45 -0
- data/site/source/app/assets/javascripts/docs/views/components/component_documentation.coffee +72 -0
- data/site/source/app/assets/javascripts/docs/views/index.coffee +3 -0
- data/site/source/app/assets/javascripts/docs/views/pages/browse_source/details.coffee +37 -0
- data/site/source/app/assets/javascripts/docs/views/pages/browse_source/list.coffee +31 -0
- data/site/source/app/assets/javascripts/docs/views/pages/browse_source.coffee +46 -0
- data/site/source/app/assets/javascripts/docs/views/pages/component_editor.coffee +10 -0
- data/site/source/app/assets/javascripts/docs/views/pages/examples_browser/docs.coffee +12 -0
- data/site/source/app/assets/javascripts/docs/views/pages/examples_browser/source.coffee +13 -0
- data/site/source/app/assets/javascripts/docs/views/pages/examples_browser.coffee +102 -0
- data/site/source/app/assets/javascripts/docs/views/pages/home.coffee +10 -0
- data/site/source/app/assets/javascripts/docs/views/views/api_browser/index.coffee +43 -0
- data/site/source/app/assets/javascripts/docs/views/views/collection_view_examples/grid_layout_view_example.coffee +14 -0
- data/site/source/app/assets/javascripts/docs/views/views/collection_view_examples/table_view_example.coffee +39 -0
- data/site/source/app/assets/javascripts/docs/views/views/form_view_examples/basic_example.coffee +38 -0
- data/site/source/app/assets/javascripts/docs/views/views/form_view_examples/complex_layout.coffee +110 -0
- data/site/source/app/assets/javascripts/docs/views/views/top_navigation.coffee +6 -0
- data/site/source/app/assets/javascripts/docs-docs.js +1 -0
- data/site/source/app/assets/javascripts/luca-docs.js +1 -0
- data/site/source/app/assets/javascripts/luca-framework-documentation.js +1 -0
- data/site/source/app/assets/javascripts/site.js.coffee +4 -0
- data/site/source/app/assets/javascripts/vendor/codemirror.js +4786 -0
- data/site/source/app/assets/javascripts/vendor/coffeescript.js +346 -0
- data/site/source/app/assets/javascripts/vendor/css.js +465 -0
- data/site/source/app/assets/javascripts/vendor/htmlmixed.js +84 -0
- data/site/source/app/assets/javascripts/vendor/javascript.js +422 -0
- data/site/source/app/assets/javascripts/vendor/js-beautify.js +1353 -0
- data/site/source/app/assets/javascripts/vendor/modernizr-2.6.1.min.js +4 -0
- data/site/source/app/assets/javascripts/vendor/vim.js +2511 -0
- data/site/source/app/assets/stylesheets/docs/api-browser.css.scss +5 -0
- data/site/source/app/assets/stylesheets/docs/application.css.scss +35 -0
- data/site/source/app/assets/stylesheets/docs/browse-source.css.scss +5 -0
- data/site/source/app/assets/stylesheets/docs/scrollable-table.css.scss +5 -0
- data/site/source/app/assets/stylesheets/site.css.scss +2 -0
- data/site/source/app/assets/stylesheets/vendor/codemirror.css +240 -0
- data/site/source/app/assets/stylesheets/vendor/prettify-tomorrow-night-bright.css +160 -0
- data/site/source/app/assets/stylesheets/vendor/twilight.css +26 -0
- data/site/source/crossdomain.xml +15 -0
- data/site/source/documentation.html.haml +1 -0
- data/site/source/favicon_base.png +0 -0
- data/site/source/humans.txt +15 -0
- data/site/source/images/background.png +0 -0
- data/site/source/images/middleman.png +0 -0
- data/site/source/index.html.haml +1 -0
- data/site/source/layouts/layout.haml +55 -0
- data/site/source/readme.md +63 -0
- data/site/source/robots.txt +3 -0
- data/spec/javascripts/components/collection_view_spec.coffee +1 -1
- data/spec/javascripts/containers/card_view_spec.coffee +58 -5
- data/spec/javascripts/core/collection_spec.coffee +1 -1
- data/spec/javascripts/core/view_spec.coffee +2 -2
- data/vendor/assets/javascripts/backbone-min.js +37 -33
- data/vendor/assets/javascripts/backbone-query.min.js +1 -1
- data/vendor/assets/javascripts/jquery.js +5 -4
- data/vendor/assets/javascripts/luca-dependencies.min.js +8 -6
- data/vendor/assets/javascripts/luca-development.min.js +1 -1
- data/vendor/assets/javascripts/luca.full.min.js +12 -10
- data/vendor/assets/javascripts/luca.min.js +5 -5
- data/vendor/assets/javascripts/underscore-min.js +1 -5
- data/vendor/assets/javascripts/underscore-string.min.js +1 -1
- data/vendor/assets/stylesheets/luca-components.css +0 -2
- data/vendor/assets/stylesheets/luca-development.css +1 -1
- metadata +215 -39
- data/app/assets/javascripts/luca/components/page_controller.coffee +0 -3
- data/app/assets/javascripts/luca/core/collection_view.coffee +0 -150
- data/site/assets/bootstrap.min.js +0 -7
- data/site/assets/dependencies.js +0 -94
- data/site/assets/glyphicons-halflings-white.png +0 -0
- data/site/assets/glyphicons-halflings.png +0 -0
- data/site/assets/luca-ui-bootstrap.css +0 -1331
- data/site/assets/luca-ui-bootstrap.js +0 -9
- data/site/assets/luca-ui-development-tools.css +0 -234
- data/site/assets/luca-ui-development-tools.js +0 -18561
- data/site/assets/luca-ui-development-tools.min.js +0 -15
- data/site/assets/luca-ui-full.min.js +0 -8
- data/site/assets/luca-ui.min.js +0 -4
- data/site/assets/sandbox.css +0 -62
- data/site/assets/sandbox.js +0 -469
- data/site/docs/application.html +0 -41
- data/site/docs/caching.html +0 -43
- data/site/docs/collection.html +0 -75
- data/site/docs/collection_manager.html +0 -71
- data/site/docs/containers.html +0 -118
- data/site/docs/events.html +0 -153
- data/site/docs/view.html +0 -128
- data/site/img/glyphicons-halflings-white.png +0 -0
- data/site/img/glyphicons-halflings.png +0 -0
- data/site/index.html +0 -20
- data/site/source-map.js +0 -1
@@ -0,0 +1,346 @@
|
|
1
|
+
/**
|
2
|
+
* Link to the project's GitHub page:
|
3
|
+
* https://github.com/pickhardt/coffeescript-codemirror-mode
|
4
|
+
*/
|
5
|
+
CodeMirror.defineMode('coffeescript', function(conf) {
|
6
|
+
var ERRORCLASS = 'error';
|
7
|
+
|
8
|
+
function wordRegexp(words) {
|
9
|
+
return new RegExp("^((" + words.join(")|(") + "))\\b");
|
10
|
+
}
|
11
|
+
|
12
|
+
var singleOperators = new RegExp("^[\\+\\-\\*/%&|\\^~<>!\?]");
|
13
|
+
var singleDelimiters = new RegExp('^[\\(\\)\\[\\]\\{\\},:`=;\\.]');
|
14
|
+
var doubleOperators = new RegExp("^((\->)|(\=>)|(\\+\\+)|(\\+\\=)|(\\-\\-)|(\\-\\=)|(\\*\\*)|(\\*\\=)|(\\/\\/)|(\\/\\=)|(==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//))");
|
15
|
+
var doubleDelimiters = new RegExp("^((\\.\\.)|(\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))");
|
16
|
+
var tripleDelimiters = new RegExp("^((\\.\\.\\.)|(//=)|(>>=)|(<<=)|(\\*\\*=))");
|
17
|
+
var identifiers = new RegExp("^[_A-Za-z$][_A-Za-z$0-9]*");
|
18
|
+
var properties = new RegExp("^(@|this\.)[_A-Za-z$][_A-Za-z$0-9]*");
|
19
|
+
|
20
|
+
var wordOperators = wordRegexp(['and', 'or', 'not',
|
21
|
+
'is', 'isnt', 'in',
|
22
|
+
'instanceof', 'typeof']);
|
23
|
+
var indentKeywords = ['for', 'while', 'loop', 'if', 'unless', 'else',
|
24
|
+
'switch', 'try', 'catch', 'finally', 'class'];
|
25
|
+
var commonKeywords = ['break', 'by', 'continue', 'debugger', 'delete',
|
26
|
+
'do', 'in', 'of', 'new', 'return', 'then',
|
27
|
+
'this', 'throw', 'when', 'until'];
|
28
|
+
|
29
|
+
var keywords = wordRegexp(indentKeywords.concat(commonKeywords));
|
30
|
+
|
31
|
+
indentKeywords = wordRegexp(indentKeywords);
|
32
|
+
|
33
|
+
|
34
|
+
var stringPrefixes = new RegExp("^('{3}|\"{3}|['\"])");
|
35
|
+
var regexPrefixes = new RegExp("^(/{3}|/)");
|
36
|
+
var commonConstants = ['Infinity', 'NaN', 'undefined', 'null', 'true', 'false', 'on', 'off', 'yes', 'no'];
|
37
|
+
var constants = wordRegexp(commonConstants);
|
38
|
+
|
39
|
+
// Tokenizers
|
40
|
+
function tokenBase(stream, state) {
|
41
|
+
// Handle scope changes
|
42
|
+
if (stream.sol()) {
|
43
|
+
var scopeOffset = state.scopes[0].offset;
|
44
|
+
if (stream.eatSpace()) {
|
45
|
+
var lineOffset = stream.indentation();
|
46
|
+
if (lineOffset > scopeOffset) {
|
47
|
+
return 'indent';
|
48
|
+
} else if (lineOffset < scopeOffset) {
|
49
|
+
return 'dedent';
|
50
|
+
}
|
51
|
+
return null;
|
52
|
+
} else {
|
53
|
+
if (scopeOffset > 0) {
|
54
|
+
dedent(stream, state);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
58
|
+
if (stream.eatSpace()) {
|
59
|
+
return null;
|
60
|
+
}
|
61
|
+
|
62
|
+
var ch = stream.peek();
|
63
|
+
|
64
|
+
// Handle docco title comment (single line)
|
65
|
+
if (stream.match("####")) {
|
66
|
+
stream.skipToEnd();
|
67
|
+
return 'comment';
|
68
|
+
}
|
69
|
+
|
70
|
+
// Handle multi line comments
|
71
|
+
if (stream.match("###")) {
|
72
|
+
state.tokenize = longComment;
|
73
|
+
return state.tokenize(stream, state);
|
74
|
+
}
|
75
|
+
|
76
|
+
// Single line comment
|
77
|
+
if (ch === '#') {
|
78
|
+
stream.skipToEnd();
|
79
|
+
return 'comment';
|
80
|
+
}
|
81
|
+
|
82
|
+
// Handle number literals
|
83
|
+
if (stream.match(/^-?[0-9\.]/, false)) {
|
84
|
+
var floatLiteral = false;
|
85
|
+
// Floats
|
86
|
+
if (stream.match(/^-?\d*\.\d+(e[\+\-]?\d+)?/i)) {
|
87
|
+
floatLiteral = true;
|
88
|
+
}
|
89
|
+
if (stream.match(/^-?\d+\.\d*/)) {
|
90
|
+
floatLiteral = true;
|
91
|
+
}
|
92
|
+
if (stream.match(/^-?\.\d+/)) {
|
93
|
+
floatLiteral = true;
|
94
|
+
}
|
95
|
+
|
96
|
+
if (floatLiteral) {
|
97
|
+
// prevent from getting extra . on 1..
|
98
|
+
if (stream.peek() == "."){
|
99
|
+
stream.backUp(1);
|
100
|
+
}
|
101
|
+
return 'number';
|
102
|
+
}
|
103
|
+
// Integers
|
104
|
+
var intLiteral = false;
|
105
|
+
// Hex
|
106
|
+
if (stream.match(/^-?0x[0-9a-f]+/i)) {
|
107
|
+
intLiteral = true;
|
108
|
+
}
|
109
|
+
// Decimal
|
110
|
+
if (stream.match(/^-?[1-9]\d*(e[\+\-]?\d+)?/)) {
|
111
|
+
intLiteral = true;
|
112
|
+
}
|
113
|
+
// Zero by itself with no other piece of number.
|
114
|
+
if (stream.match(/^-?0(?![\dx])/i)) {
|
115
|
+
intLiteral = true;
|
116
|
+
}
|
117
|
+
if (intLiteral) {
|
118
|
+
return 'number';
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
// Handle strings
|
123
|
+
if (stream.match(stringPrefixes)) {
|
124
|
+
state.tokenize = tokenFactory(stream.current(), 'string');
|
125
|
+
return state.tokenize(stream, state);
|
126
|
+
}
|
127
|
+
// Handle regex literals
|
128
|
+
if (stream.match(regexPrefixes)) {
|
129
|
+
if (stream.current() != '/' || stream.match(/^.*\//, false)) { // prevent highlight of division
|
130
|
+
state.tokenize = tokenFactory(stream.current(), 'string-2');
|
131
|
+
return state.tokenize(stream, state);
|
132
|
+
} else {
|
133
|
+
stream.backUp(1);
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
// Handle operators and delimiters
|
138
|
+
if (stream.match(tripleDelimiters) || stream.match(doubleDelimiters)) {
|
139
|
+
return 'punctuation';
|
140
|
+
}
|
141
|
+
if (stream.match(doubleOperators)
|
142
|
+
|| stream.match(singleOperators)
|
143
|
+
|| stream.match(wordOperators)) {
|
144
|
+
return 'operator';
|
145
|
+
}
|
146
|
+
if (stream.match(singleDelimiters)) {
|
147
|
+
return 'punctuation';
|
148
|
+
}
|
149
|
+
|
150
|
+
if (stream.match(constants)) {
|
151
|
+
return 'atom';
|
152
|
+
}
|
153
|
+
|
154
|
+
if (stream.match(keywords)) {
|
155
|
+
return 'keyword';
|
156
|
+
}
|
157
|
+
|
158
|
+
if (stream.match(identifiers)) {
|
159
|
+
return 'variable';
|
160
|
+
}
|
161
|
+
|
162
|
+
if (stream.match(properties)) {
|
163
|
+
return 'property';
|
164
|
+
}
|
165
|
+
|
166
|
+
// Handle non-detected items
|
167
|
+
stream.next();
|
168
|
+
return ERRORCLASS;
|
169
|
+
}
|
170
|
+
|
171
|
+
function tokenFactory(delimiter, outclass) {
|
172
|
+
var singleline = delimiter.length == 1;
|
173
|
+
return function tokenString(stream, state) {
|
174
|
+
while (!stream.eol()) {
|
175
|
+
stream.eatWhile(/[^'"\/\\]/);
|
176
|
+
if (stream.eat('\\')) {
|
177
|
+
stream.next();
|
178
|
+
if (singleline && stream.eol()) {
|
179
|
+
return outclass;
|
180
|
+
}
|
181
|
+
} else if (stream.match(delimiter)) {
|
182
|
+
state.tokenize = tokenBase;
|
183
|
+
return outclass;
|
184
|
+
} else {
|
185
|
+
stream.eat(/['"\/]/);
|
186
|
+
}
|
187
|
+
}
|
188
|
+
if (singleline) {
|
189
|
+
if (conf.mode.singleLineStringErrors) {
|
190
|
+
outclass = ERRORCLASS;
|
191
|
+
} else {
|
192
|
+
state.tokenize = tokenBase;
|
193
|
+
}
|
194
|
+
}
|
195
|
+
return outclass;
|
196
|
+
};
|
197
|
+
}
|
198
|
+
|
199
|
+
function longComment(stream, state) {
|
200
|
+
while (!stream.eol()) {
|
201
|
+
stream.eatWhile(/[^#]/);
|
202
|
+
if (stream.match("###")) {
|
203
|
+
state.tokenize = tokenBase;
|
204
|
+
break;
|
205
|
+
}
|
206
|
+
stream.eatWhile("#");
|
207
|
+
}
|
208
|
+
return "comment";
|
209
|
+
}
|
210
|
+
|
211
|
+
function indent(stream, state, type) {
|
212
|
+
type = type || 'coffee';
|
213
|
+
var indentUnit = 0;
|
214
|
+
if (type === 'coffee') {
|
215
|
+
for (var i = 0; i < state.scopes.length; i++) {
|
216
|
+
if (state.scopes[i].type === 'coffee') {
|
217
|
+
indentUnit = state.scopes[i].offset + conf.indentUnit;
|
218
|
+
break;
|
219
|
+
}
|
220
|
+
}
|
221
|
+
} else {
|
222
|
+
indentUnit = stream.column() + stream.current().length;
|
223
|
+
}
|
224
|
+
state.scopes.unshift({
|
225
|
+
offset: indentUnit,
|
226
|
+
type: type
|
227
|
+
});
|
228
|
+
}
|
229
|
+
|
230
|
+
function dedent(stream, state) {
|
231
|
+
if (state.scopes.length == 1) return;
|
232
|
+
if (state.scopes[0].type === 'coffee') {
|
233
|
+
var _indent = stream.indentation();
|
234
|
+
var _indent_index = -1;
|
235
|
+
for (var i = 0; i < state.scopes.length; ++i) {
|
236
|
+
if (_indent === state.scopes[i].offset) {
|
237
|
+
_indent_index = i;
|
238
|
+
break;
|
239
|
+
}
|
240
|
+
}
|
241
|
+
if (_indent_index === -1) {
|
242
|
+
return true;
|
243
|
+
}
|
244
|
+
while (state.scopes[0].offset !== _indent) {
|
245
|
+
state.scopes.shift();
|
246
|
+
}
|
247
|
+
return false;
|
248
|
+
} else {
|
249
|
+
state.scopes.shift();
|
250
|
+
return false;
|
251
|
+
}
|
252
|
+
}
|
253
|
+
|
254
|
+
function tokenLexer(stream, state) {
|
255
|
+
var style = state.tokenize(stream, state);
|
256
|
+
var current = stream.current();
|
257
|
+
|
258
|
+
// Handle '.' connected identifiers
|
259
|
+
if (current === '.') {
|
260
|
+
style = state.tokenize(stream, state);
|
261
|
+
current = stream.current();
|
262
|
+
if (style === 'variable') {
|
263
|
+
return 'variable';
|
264
|
+
} else {
|
265
|
+
return ERRORCLASS;
|
266
|
+
}
|
267
|
+
}
|
268
|
+
|
269
|
+
// Handle scope changes.
|
270
|
+
if (current === 'return') {
|
271
|
+
state.dedent += 1;
|
272
|
+
}
|
273
|
+
if (((current === '->' || current === '=>') &&
|
274
|
+
!state.lambda &&
|
275
|
+
state.scopes[0].type == 'coffee' &&
|
276
|
+
stream.peek() === '')
|
277
|
+
|| style === 'indent') {
|
278
|
+
indent(stream, state);
|
279
|
+
}
|
280
|
+
var delimiter_index = '[({'.indexOf(current);
|
281
|
+
if (delimiter_index !== -1) {
|
282
|
+
indent(stream, state, '])}'.slice(delimiter_index, delimiter_index+1));
|
283
|
+
}
|
284
|
+
if (indentKeywords.exec(current)){
|
285
|
+
indent(stream, state);
|
286
|
+
}
|
287
|
+
if (current == 'then'){
|
288
|
+
dedent(stream, state);
|
289
|
+
}
|
290
|
+
|
291
|
+
|
292
|
+
if (style === 'dedent') {
|
293
|
+
if (dedent(stream, state)) {
|
294
|
+
return ERRORCLASS;
|
295
|
+
}
|
296
|
+
}
|
297
|
+
delimiter_index = '])}'.indexOf(current);
|
298
|
+
if (delimiter_index !== -1) {
|
299
|
+
if (dedent(stream, state)) {
|
300
|
+
return ERRORCLASS;
|
301
|
+
}
|
302
|
+
}
|
303
|
+
if (state.dedent > 0 && stream.eol() && state.scopes[0].type == 'coffee') {
|
304
|
+
if (state.scopes.length > 1) state.scopes.shift();
|
305
|
+
state.dedent -= 1;
|
306
|
+
}
|
307
|
+
|
308
|
+
return style;
|
309
|
+
}
|
310
|
+
|
311
|
+
var external = {
|
312
|
+
startState: function(basecolumn) {
|
313
|
+
return {
|
314
|
+
tokenize: tokenBase,
|
315
|
+
scopes: [{offset:basecolumn || 0, type:'coffee'}],
|
316
|
+
lastToken: null,
|
317
|
+
lambda: false,
|
318
|
+
dedent: 0
|
319
|
+
};
|
320
|
+
},
|
321
|
+
|
322
|
+
token: function(stream, state) {
|
323
|
+
var style = tokenLexer(stream, state);
|
324
|
+
|
325
|
+
state.lastToken = {style:style, content: stream.current()};
|
326
|
+
|
327
|
+
if (stream.eol() && stream.lambda) {
|
328
|
+
state.lambda = false;
|
329
|
+
}
|
330
|
+
|
331
|
+
return style;
|
332
|
+
},
|
333
|
+
|
334
|
+
indent: function(state) {
|
335
|
+
if (state.tokenize != tokenBase) {
|
336
|
+
return 0;
|
337
|
+
}
|
338
|
+
|
339
|
+
return state.scopes[0].offset;
|
340
|
+
}
|
341
|
+
|
342
|
+
};
|
343
|
+
return external;
|
344
|
+
});
|
345
|
+
|
346
|
+
CodeMirror.defineMIME('text/x-coffeescript', 'coffeescript');
|