codemirror-rails 3.00 → 3.02

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/README.md +5 -2
  2. data/lib/codemirror/rails/version.rb +2 -2
  3. data/test/dummy/config/database.yml +25 -0
  4. data/test/dummy/db/.gitkeep +0 -0
  5. data/test/integration/codemirror_rails_integration_test.rb +1 -1
  6. data/vendor/assets/javascripts/codemirror.js +385 -152
  7. data/vendor/assets/javascripts/codemirror/keymaps/vim.js +279 -66
  8. data/vendor/assets/javascripts/codemirror/modes/apl.js +160 -0
  9. data/vendor/assets/javascripts/codemirror/modes/asterisk.js +183 -0
  10. data/vendor/assets/javascripts/codemirror/modes/clike.js +2 -0
  11. data/vendor/assets/javascripts/codemirror/modes/clojure.js +3 -3
  12. data/vendor/assets/javascripts/codemirror/modes/css.js +2 -2
  13. data/vendor/assets/javascripts/codemirror/modes/d.js +205 -0
  14. data/vendor/assets/javascripts/codemirror/modes/gfm.js +2 -1
  15. data/vendor/assets/javascripts/codemirror/modes/javascript.js +13 -2
  16. data/vendor/assets/javascripts/codemirror/modes/markdown.js +8 -7
  17. data/vendor/assets/javascripts/codemirror/modes/properties.js +0 -0
  18. data/vendor/assets/javascripts/codemirror/modes/sass.js +349 -0
  19. data/vendor/assets/javascripts/codemirror/modes/sieve.js +37 -10
  20. data/vendor/assets/javascripts/codemirror/modes/sql.js +268 -0
  21. data/vendor/assets/javascripts/codemirror/modes/xquery.js +8 -8
  22. data/vendor/assets/javascripts/codemirror/utils/collapserange.js +68 -0
  23. data/vendor/assets/javascripts/codemirror/utils/dialog.js +1 -0
  24. data/vendor/assets/javascripts/codemirror/utils/foldcode.js +2 -1
  25. data/vendor/assets/javascripts/codemirror/utils/formatting.js +9 -3
  26. data/vendor/assets/javascripts/codemirror/utils/javascript-hint.js +5 -4
  27. data/vendor/assets/javascripts/codemirror/utils/python-hint.js +93 -0
  28. data/vendor/assets/javascripts/codemirror/utils/runmode-standalone.js +51 -10
  29. data/vendor/assets/javascripts/codemirror/utils/search.js +20 -8
  30. data/vendor/assets/javascripts/codemirror/utils/searchcursor.js +17 -10
  31. data/vendor/assets/stylesheets/codemirror.css +10 -9
  32. metadata +47 -15
  33. data/vendor/assets/javascripts/codemirror/modes/xmlpure.js +0 -490
  34. data/vendor/assets/stylesheets/codemirror/modes/diff.css +0 -3
@@ -0,0 +1,268 @@
1
+ CodeMirror.defineMode("sql", function(config, parserConfig) {
2
+ "use strict";
3
+
4
+ var client = parserConfig.client || {},
5
+ atoms = parserConfig.atoms || {"false": true, "true": true, "null": true},
6
+ builtin = parserConfig.builtin || {},
7
+ keywords = parserConfig.keywords,
8
+ operatorChars = parserConfig.operatorChars || /^[*+\-%<>!=&|~^]/,
9
+ support = parserConfig.support || {},
10
+ hooks = parserConfig.hooks || {},
11
+ dateSQL = parserConfig.dateSQL || {"date" : true, "time" : true, "timestamp" : true};
12
+
13
+ function tokenBase(stream, state) {
14
+ var ch = stream.next();
15
+
16
+ // call hooks from the mime type
17
+ if (hooks[ch]) {
18
+ var result = hooks[ch](stream, state);
19
+ if (result !== false) return result;
20
+ }
21
+
22
+ if ((ch == "0" && stream.match(/^[xX][0-9a-fA-F]+/))
23
+ || (ch == "x" || ch == "X") && stream.match(/^'[0-9a-fA-F]+'/)) {
24
+ // hex
25
+ return "number";
26
+ } else if (((ch == "b" || ch == "B") && stream.match(/^'[01]+'/))
27
+ || (ch == "0" && stream.match(/^b[01]+/))) {
28
+ // bitstring
29
+ return "number";
30
+ } else if (ch.charCodeAt(0) > 47 && ch.charCodeAt(0) < 58) {
31
+ // numbers
32
+ stream.match(/^[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/);
33
+ return "number";
34
+ } else if (ch == "?" && (stream.eatSpace() || stream.eol() || stream.eat(";"))) {
35
+ // placeholders
36
+ return "variable-3";
37
+ } else if (ch == '"' || ch == "'") {
38
+ // strings
39
+ state.tokenize = tokenLiteral(ch);
40
+ return state.tokenize(stream, state);
41
+ } else if (/^[\(\),\;\[\]]/.test(ch)) {
42
+ // no highlightning
43
+ return null;
44
+ } else if (ch == "#" || (ch == "-" && stream.eat("-") && stream.eat(" "))) {
45
+ // 1-line comments
46
+ stream.skipToEnd();
47
+ return "comment";
48
+ } else if (ch == "/" && stream.eat("*")) {
49
+ // multi-line comments
50
+ state.tokenize = tokenComment;
51
+ return state.tokenize(stream, state);
52
+ } else if (ch == ".") {
53
+ // .1 for 0.1
54
+ if (stream.match(/^[0-9eE]+/) && support.zerolessFloat == true) {
55
+ return "number";
56
+ }
57
+ // .table_name (ODBC)
58
+ if (stream.match(/^[a-zA-Z_]+/) && support.ODBCdotTable == true) {
59
+ return "variable-2";
60
+ }
61
+ } else if (operatorChars.test(ch)) {
62
+ // operators
63
+ stream.eatWhile(operatorChars);
64
+ return null;
65
+ } else if (ch == '{' &&
66
+ (stream.match(/^( )*(d|D|t|T|ts|TS)( )*'[^']*'( )*}/) || stream.match(/^( )*(d|D|t|T|ts|TS)( )*"[^"]*"( )*}/))) {
67
+ // dates (weird ODBC syntax)
68
+ return "number";
69
+ } else {
70
+ stream.eatWhile(/^[_\w\d]/);
71
+ var word = stream.current().toLowerCase();
72
+ // dates (standard SQL syntax)
73
+ if (dateSQL.hasOwnProperty(word) && (stream.match(/^( )+'[^']*'/) || stream.match(/^( )+"[^"]*"/)))
74
+ return "number";
75
+ if (atoms.hasOwnProperty(word)) return "atom";
76
+ if (builtin.hasOwnProperty(word)) return "builtin";
77
+ if (keywords.hasOwnProperty(word)) return "keyword";
78
+ if (client.hasOwnProperty(word)) return "string-2";
79
+ return null;
80
+ }
81
+ }
82
+
83
+ // 'string', with char specified in quote escaped by '\'
84
+ function tokenLiteral(quote) {
85
+ return function(stream, state) {
86
+ var escaped = false, ch;
87
+ while ((ch = stream.next()) != null) {
88
+ if (ch == quote && !escaped) {
89
+ state.tokenize = tokenBase;
90
+ break;
91
+ }
92
+ escaped = !escaped && ch == "\\";
93
+ }
94
+ return "string";
95
+ };
96
+ }
97
+ function tokenComment(stream, state) {
98
+ while (true) {
99
+ if (stream.skipTo("*")) {
100
+ stream.next();
101
+ if (stream.eat("/")) {
102
+ state.tokenize = tokenBase;
103
+ break;
104
+ }
105
+ } else {
106
+ stream.skipToEnd();
107
+ break;
108
+ }
109
+ }
110
+ return "comment";
111
+ }
112
+
113
+ function pushContext(stream, state, type) {
114
+ state.context = {
115
+ prev: state.context,
116
+ indent: stream.indentation(),
117
+ col: stream.column(),
118
+ type: type
119
+ };
120
+ }
121
+
122
+ function popContext(state) {
123
+ state.indent = state.context.indent;
124
+ state.context = state.context.prev;
125
+ }
126
+
127
+ return {
128
+ startState: function() {
129
+ return {tokenize: tokenBase, context: null};
130
+ },
131
+
132
+ token: function(stream, state) {
133
+ if (stream.sol()) {
134
+ if (state.context && state.context.align == null)
135
+ state.context.align = false;
136
+ }
137
+ if (stream.eatSpace()) return null;
138
+
139
+ var style = state.tokenize(stream, state);
140
+ if (style == "comment") return style;
141
+
142
+ if (state.context && state.context.align == null)
143
+ state.context.align = true;
144
+
145
+ var tok = stream.current();
146
+ if (tok == "(")
147
+ pushContext(stream, state, ")");
148
+ else if (tok == "[")
149
+ pushContext(stream, state, "]");
150
+ else if (state.context && state.context.type == tok)
151
+ popContext(state);
152
+ return style;
153
+ },
154
+
155
+ indent: function(state, textAfter) {
156
+ var cx = state.context;
157
+ if (!cx) return CodeMirror.Pass;
158
+ if (cx.align) return cx.col + (textAfter.charAt(0) == cx.type ? 0 : 1);
159
+ else return cx.indent + config.indentUnit;
160
+ }
161
+ };
162
+ });
163
+
164
+ (function() {
165
+ "use strict";
166
+
167
+ // `identifier`
168
+ function hookIdentifier(stream) {
169
+ var escaped = false, ch;
170
+ while ((ch = stream.next()) != null) {
171
+ if (ch == "`" && !escaped) return "variable-2";
172
+ escaped = !escaped && ch == "`";
173
+ }
174
+ return null;
175
+ }
176
+
177
+ // variable token
178
+ function hookVar(stream) {
179
+ // variables
180
+ // @@ and prefix
181
+ if (stream.eat("@")) {
182
+ stream.match(/^session\./);
183
+ stream.match(/^local\./);
184
+ stream.match(/^global\./);
185
+ }
186
+
187
+ if (stream.eat("'")) {
188
+ stream.match(/^.*'/);
189
+ return "variable-2";
190
+ } else if (stream.eat('"')) {
191
+ stream.match(/^.*"/);
192
+ return "variable-2";
193
+ } else if (stream.eat("`")) {
194
+ stream.match(/^.*`/);
195
+ return "variable-2";
196
+ } else if (stream.match(/^[0-9a-zA-Z$\.\_]+/)) {
197
+ return "variable-2";
198
+ }
199
+ return null;
200
+ };
201
+
202
+ // short client keyword token
203
+ function hookClient(stream) {
204
+ // \g, etc
205
+ return stream.match(/^[a-zA-Z]\b/) ? "variable-2" : null;
206
+ }
207
+
208
+ var sqlKeywords = "alter and as asc between by count create delete desc distinct drop from having in insert into is join like not on or order select set table union update values where ";
209
+
210
+ function set(str) {
211
+ var obj = {}, words = str.split(" ");
212
+ for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
213
+ return obj;
214
+ }
215
+
216
+ CodeMirror.defineMIME("text/x-sql", {
217
+ name: "sql",
218
+ keywords: set(sqlKeywords + "begin"),
219
+ builtin: set("bool boolean bit blob enum long longblob longtext medium mediumblob mediumint mediumtext time timestamp tinyblob tinyint tinytext text bigint int int1 int2 int3 int4 int8 integer float float4 float8 double char varbinary varchar varcharacter precision real date datetime year unsigned signed decimal numeric"),
220
+ atoms: set("false true null unknown"),
221
+ operatorChars: /^[*+\-%<>!=]/,
222
+ dateSQL: set("date time timestamp"),
223
+ support: set("ODBCdotTable")
224
+ });
225
+
226
+ CodeMirror.defineMIME("text/x-mysql", {
227
+ name: "sql",
228
+ client: set("charset clear connect edit ego exit go help nopager notee nowarning pager print prompt quit rehash source status system tee"),
229
+ keywords: set(sqlKeywords + "accessible action add after algorithm all analyze asensitive at authors auto_increment autocommit avg avg_row_length before binary binlog both btree cache call cascade cascaded case catalog_name chain change changed character check checkpoint checksum class_origin client_statistics close coalesce code collate collation collations column columns comment commit committed completion concurrent condition connection consistent constraint contains continue contributors convert cross current_date current_time current_timestamp current_user cursor data database databases day_hour day_microsecond day_minute day_second deallocate dec declare default delay_key_write delayed delimiter des_key_file describe deterministic dev_pop dev_samp deviance directory disable discard distinctrow div dual dumpfile each elseif enable enclosed end ends engine engines enum errors escape escaped even event events every execute exists exit explain extended fast fetch field fields first flush for force foreign found_rows full fulltext function general global grant grants group groupby_concat handler hash help high_priority hosts hour_microsecond hour_minute hour_second if ignore ignore_server_ids import index index_statistics infile inner innodb inout insensitive insert_method interval invoker isolation iterate key keys kill language last leading leave left level limit linear lines list load local localtime localtimestamp lock logs low_priority master master_heartbeat_period master_ssl_verify_server_cert masters match max max_rows maxvalue message_text middleint migrate min min_rows minute_microsecond minute_second mod mode modifies modify mutex mysql_errno natural next no no_write_to_binlog offline offset one online open optimize option optionally out outer outfile pack_keys parser partition partitions password phase plugin plugins prepare preserve prev primary privileges procedure processlist profile profiles purge query quick range read read_write reads real rebuild recover references regexp relaylog release remove rename reorganize repair repeatable replace require resignal restrict resume return returns revoke right rlike rollback rollup row row_format rtree savepoint schedule schema schema_name schemas second_microsecond security sensitive separator serializable server session share show signal slave slow smallint snapshot spatial specific sql sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_no_cache sql_small_result sqlexception sqlstate sqlwarning ssl start starting starts status std stddev stddev_pop stddev_samp storage straight_join subclass_origin sum suspend table_name table_statistics tables tablespace temporary terminated to trailing transaction trigger triggers truncate uncommitted undo unique unlock upgrade usage use use_frm user user_resources user_statistics using utc_date utc_time utc_timestamp value variables varying view views warnings when while with work write xa xor year_month zerofill begin do then else loop repeat"),
230
+ builtin: set("bool boolean bit blob decimal double enum float long longblob longtext medium mediumblob mediumint mediumtext time timestamp tinyblob tinyint tinytext text bigint int int1 int2 int3 int4 int8 integer float float4 float8 double char varbinary varchar varcharacter precision date datetime year unsigned signed numeric"),
231
+ atoms: set("false true null unknown"),
232
+ operatorChars: /^[*+\-%<>!=&|^]/,
233
+ dateSQL: set("date time timestamp"),
234
+ support: set("ODBCdotTable zerolessFloat"),
235
+ hooks: {
236
+ "@": hookVar,
237
+ "`": hookIdentifier,
238
+ "\\": hookClient
239
+ }
240
+ });
241
+
242
+ CodeMirror.defineMIME("text/x-mariadb", {
243
+ name: "sql",
244
+ client: set("charset clear connect edit ego exit go help nopager notee nowarning pager print prompt quit rehash source status system tee"),
245
+ keywords: set(sqlKeywords + "accessible action add after algorithm all always analyze asensitive at authors auto_increment autocommit avg avg_row_length before binary binlog both btree cache call cascade cascaded case catalog_name chain change changed character check checkpoint checksum class_origin client_statistics close coalesce code collate collation collations column columns comment commit committed completion concurrent condition connection consistent constraint contains continue contributors convert cross current_date current_time current_timestamp current_user cursor data database databases day_hour day_microsecond day_minute day_second deallocate dec declare default delay_key_write delayed delimiter des_key_file describe deterministic dev_pop dev_samp deviance directory disable discard distinctrow div dual dumpfile each elseif enable enclosed end ends engine engines enum errors escape escaped even event events every execute exists exit explain extended fast fetch field fields first flush for force foreign found_rows full fulltext function general generated global grant grants group groupby_concat handler hash help high_priority hosts hour_microsecond hour_minute hour_second if ignore ignore_server_ids import index index_statistics infile inner innodb inout insensitive insert_method interval invoker isolation iterate key keys kill language last leading leave left level limit linear lines list load local localtime localtimestamp lock logs low_priority master master_heartbeat_period master_ssl_verify_server_cert masters match max max_rows maxvalue message_text middleint migrate min min_rows minute_microsecond minute_second mod mode modifies modify mutex mysql_errno natural next no no_write_to_binlog offline offset one online open optimize option optionally out outer outfile pack_keys parser partition partitions password persistent phase plugin plugins prepare preserve prev primary privileges procedure processlist profile profiles purge query quick range read read_write reads real rebuild recover references regexp relaylog release remove rename reorganize repair repeatable replace require resignal restrict resume return returns revoke right rlike rollback rollup row row_format rtree savepoint schedule schema schema_name schemas second_microsecond security sensitive separator serializable server session share show signal slave slow smallint snapshot spatial specific sql sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_no_cache sql_small_result sqlexception sqlstate sqlwarning ssl start starting starts status std stddev stddev_pop stddev_samp storage straight_join subclass_origin sum suspend table_name table_statistics tables tablespace temporary terminated to trailing transaction trigger triggers truncate uncommitted undo unique unlock upgrade usage use use_frm user user_resources user_statistics using utc_date utc_time utc_timestamp value variables varying view views virtual warnings when while with work write xa xor year_month zerofill begin do then else loop repeat"),
246
+ builtin: set("bool boolean bit blob decimal double enum float long longblob longtext medium mediumblob mediumint mediumtext time timestamp tinyblob tinyint tinytext text bigint int int1 int2 int3 int4 int8 integer float float4 float8 double char varbinary varchar varcharacter precision date datetime year unsigned signed numeric"),
247
+ atoms: set("false true null unknown"),
248
+ operatorChars: /^[*+\-%<>!=&|^]/,
249
+ dateSQL: set("date time timestamp"),
250
+ support: set("ODBCdotTable zerolessFloat"),
251
+ hooks: {
252
+ "@": hookVar,
253
+ "`": hookIdentifier,
254
+ "\\": hookClient
255
+ }
256
+ });
257
+
258
+ // this is based on Peter Raganitsch's 'plsql' mode
259
+ CodeMirror.defineMIME("text/x-plsql", {
260
+ name: "sql",
261
+ client: set("appinfo arraysize autocommit autoprint autorecovery autotrace blockterminator break btitle cmdsep colsep compatibility compute concat copycommit copytypecheck define describe echo editfile embedded escape exec execute feedback flagger flush heading headsep instance linesize lno loboffset logsource long longchunksize markup native newpage numformat numwidth pagesize pause pno recsep recsepchar release repfooter repheader serveroutput shiftinout show showmode size spool sqlblanklines sqlcase sqlcode sqlcontinue sqlnumber sqlpluscompatibility sqlprefix sqlprompt sqlterminator suffix tab term termout time timing trimout trimspool ttitle underline verify version wrap"),
262
+ keywords: set("abort accept access add all alter and any array arraylen as asc assert assign at attributes audit authorization avg base_table begin between binary_integer body boolean by case cast char char_base check close cluster clusters colauth column comment commit compress connect connected constant constraint crash create current currval cursor data_base database date dba deallocate debugoff debugon decimal declare default definition delay delete desc digits dispose distinct do drop else elsif enable end entry escape exception exception_init exchange exclusive exists exit external fast fetch file for force form from function generic goto grant group having identified if immediate in increment index indexes indicator initial initrans insert interface intersect into is key level library like limited local lock log logging long loop master maxextents maxtrans member minextents minus mislabel mode modify multiset new next no noaudit nocompress nologging noparallel not nowait number_base object of off offline on online only open option or order out package parallel partition pctfree pctincrease pctused pls_integer positive positiven pragma primary prior private privileges procedure public raise range raw read rebuild record ref references refresh release rename replace resource restrict return returning reverse revoke rollback row rowid rowlabel rownum rows run savepoint schema segment select separate session set share snapshot some space split sql start statement storage subtype successful synonym tabauth table tables tablespace task terminate then to trigger truncate type union unique unlimited unrecoverable unusable update use using validate value values variable view views when whenever where while with work"),
263
+ functions: set("abs acos add_months ascii asin atan atan2 average bfilename ceil chartorowid chr concat convert cos cosh count decode deref dual dump dup_val_on_index empty error exp false floor found glb greatest hextoraw initcap instr instrb isopen last_day least lenght lenghtb ln lower lpad ltrim lub make_ref max min mod months_between new_time next_day nextval nls_charset_decl_len nls_charset_id nls_charset_name nls_initcap nls_lower nls_sort nls_upper nlssort no_data_found notfound null nvl others power rawtohex reftohex round rowcount rowidtochar rpad rtrim sign sin sinh soundex sqlcode sqlerrm sqrt stddev substr substrb sum sysdate tan tanh to_char to_date to_label to_multi_byte to_number to_single_byte translate true trunc uid upper user userenv variance vsize"),
264
+ builtin: set("bfile blob character clob dec float int integer mlslabel natural naturaln nchar nclob number numeric nvarchar2 real rowtype signtype smallint string varchar varchar2"),
265
+ operatorChars: /^[*+\-%<>!=~]/,
266
+ dateSQL: set("date time timestamp")
267
+ });
268
+ }());
@@ -33,7 +33,7 @@ CodeMirror.defineMode("xquery", function() {
33
33
  , C = kw("keyword c")
34
34
  , operator = kw("operator")
35
35
  , atom = {type: "atom", style: "atom"}
36
- , punctuation = {type: "punctuation", style: ""}
36
+ , punctuation = {type: "punctuation", style: null}
37
37
  , qualifier = {type: "axis_specifier", style: "qualifier"};
38
38
 
39
39
  // kwObj is what is return from this function at the end
@@ -121,12 +121,12 @@ CodeMirror.defineMode("xquery", function() {
121
121
  // start code block
122
122
  else if(ch == "{") {
123
123
  pushStateStack(state,{ type: "codeblock"});
124
- return ret("", "");
124
+ return ret("", null);
125
125
  }
126
126
  // end code block
127
127
  else if(ch == "}") {
128
128
  popStateStack(state);
129
- return ret("", "");
129
+ return ret("", null);
130
130
  }
131
131
  // if we're in an XML block
132
132
  else if(isInXmlBlock(state)) {
@@ -163,22 +163,22 @@ CodeMirror.defineMode("xquery", function() {
163
163
  // open paren
164
164
  else if(ch === "(") {
165
165
  pushStateStack(state, { type: "paren"});
166
- return ret("", "");
166
+ return ret("", null);
167
167
  }
168
168
  // close paren
169
169
  else if(ch === ")") {
170
170
  popStateStack(state);
171
- return ret("", "");
171
+ return ret("", null);
172
172
  }
173
173
  // open paren
174
174
  else if(ch === "[") {
175
175
  pushStateStack(state, { type: "bracket"});
176
- return ret("", "");
176
+ return ret("", null);
177
177
  }
178
178
  // close paren
179
179
  else if(ch === "]") {
180
180
  popStateStack(state);
181
- return ret("", "");
181
+ return ret("", null);
182
182
  }
183
183
  else {
184
184
  var known = keywords.propertyIsEnumerable(ch) && keywords[ch];
@@ -342,7 +342,7 @@ CodeMirror.defineMode("xquery", function() {
342
342
  return ret("tag", "tag");
343
343
  }
344
344
  if(ch == "=")
345
- return ret("", "");
345
+ return ret("", null);
346
346
  // quoted string
347
347
  if (ch == '"' || ch == "'")
348
348
  return chain(stream, state, tokenString(ch, tokenAttribute));
@@ -0,0 +1,68 @@
1
+ (function() {
2
+ CodeMirror.defineOption("collapseRange", false, function(cm, val, old) {
3
+ var wasOn = old && old != CodeMirror.Init;
4
+ if (val && !wasOn)
5
+ enableRangeCollapsing(cm);
6
+ else if (!val && wasOn)
7
+ disableRangeCollapsing(cm);
8
+ });
9
+
10
+ var gutterClass = "CodeMirror-collapserange";
11
+
12
+ function enableRangeCollapsing(cm) {
13
+ cm.on("gutterClick", gutterClick);
14
+ cm.setOption("gutters", (cm.getOption("gutters") || []).concat([gutterClass]));
15
+ }
16
+
17
+ function disableRangeCollapsing(cm) {
18
+ cm.rangeCollapseStart = null;
19
+ cm.off("gutterClick", gutterClick);
20
+ var gutters = cm.getOption("gutters");
21
+ for (var i = 0; i < gutters.length && gutters[i] != gutterClass; ++i) {}
22
+ cm.setOption("gutters", gutters.slice(0, i).concat(gutters.slice(i + 1)));
23
+ }
24
+
25
+ function gutterClick(cm, line, gutter) {
26
+ if (gutter != gutterClass) return;
27
+
28
+ var start = cm.rangeCollapseStart;
29
+ if (start) {
30
+ var old = cm.getLineNumber(start);
31
+ cm.setGutterMarker(start, gutterClass, null);
32
+ cm.rangeCollapseStart = null;
33
+ var from = Math.min(old, line), to = Math.max(old, line);
34
+ if (from != to) {
35
+ // Finish this fold
36
+ var fold = cm.markText({line: from + 1, ch: 0}, {line: to - 1}, {
37
+ collapsed: true,
38
+ inclusiveLeft: true,
39
+ inclusiveRight: true,
40
+ clearOnEnter: true
41
+ });
42
+ var clear = function() {
43
+ cm.setGutterMarker(topLine, gutterClass, null);
44
+ cm.setGutterMarker(botLine, gutterClass, null);
45
+ fold.clear();
46
+ };
47
+ var topLine = cm.setGutterMarker(from, gutterClass, makeMarker(true, true, clear));
48
+ var botLine = cm.setGutterMarker(to, gutterClass, makeMarker(false, true, clear));
49
+ CodeMirror.on(fold, "clear", clear);
50
+
51
+ return;
52
+ }
53
+ }
54
+
55
+ // Start a new fold
56
+ cm.rangeCollapseStart = cm.setGutterMarker(line, gutterClass, makeMarker(true, false));
57
+ }
58
+
59
+ function makeMarker(isTop, isFinished, handler) {
60
+ var node = document.createElement("div");
61
+ node.innerHTML = isTop ? "\u25bc" : "\u25b2";
62
+ if (!isFinished) node.style.color = "red";
63
+ node.style.fontSize = "85%";
64
+ node.style.cursor = "pointer";
65
+ if (handler) CodeMirror.on(node, "mousedown", handler);
66
+ return node;
67
+ }
68
+ })();
@@ -32,6 +32,7 @@
32
32
  if (e.keyCode == 13) callback(inp.value);
33
33
  }
34
34
  });
35
+ if (options && options.value) inp.value = options.value;
35
36
  inp.focus();
36
37
  CodeMirror.on(inp, "blur", close);
37
38
  } else if (button = dialog.getElementsByTagName("button")[0]) {
@@ -142,7 +142,8 @@ CodeMirror.indentRangeFinder = function(cm, start) {
142
142
  var myIndent = CodeMirror.countColumn(firstLine, null, tabSize);
143
143
  for (var i = start.line + 1, end = cm.lineCount(); i < end; ++i) {
144
144
  var curLine = cm.getLine(i);
145
- if (CodeMirror.countColumn(curLine, null, tabSize) < myIndent)
145
+ if (CodeMirror.countColumn(curLine, null, tabSize) < myIndent &&
146
+ CodeMirror.countColumn(cm.getLine(i-1), null, tabSize) > myIndent)
146
147
  return {from: {line: start.line, ch: firstLine.length},
147
148
  to: {line: i, ch: curLine.length}};
148
149
  }
@@ -22,11 +22,17 @@
22
22
  }
23
23
  });
24
24
 
25
+ var inlineElements = /^(a|abbr|acronym|area|base|bdo|big|br|button|caption|cite|code|col|colgroup|dd|del|dfn|em|frame|hr|iframe|img|input|ins|kbd|label|legend|link|map|object|optgroup|option|param|q|samp|script|select|small|span|strong|sub|sup|textarea|tt|var)$/;
26
+
25
27
  CodeMirror.extendMode("xml", {
26
28
  commentStart: "<!--",
27
29
  commentEnd: "-->",
28
- newlineAfterToken: function(type, content, textAfter) {
29
- return type == "tag" && />$/.test(content) || /^</.test(textAfter);
30
+ newlineAfterToken: function(type, content, textAfter, state) {
31
+ var inline = false;
32
+ if (this.configuration == "html")
33
+ inline = state.context ? inlineElements.test(state.context.tagName) : false;
34
+ return !inline && ((type == "tag" && />$/.test(content) && state.context) ||
35
+ /^</.test(textAfter));
30
36
  }
31
37
  });
32
38
 
@@ -95,7 +101,7 @@
95
101
  newline();
96
102
  }
97
103
  if (!stream.pos && outer.blankLine) outer.blankLine(state);
98
- if (!atSol) newline();
104
+ if (!atSol && i < text.length - 1) newline();
99
105
  }
100
106
 
101
107
  cm.operation(function () {
@@ -40,8 +40,8 @@
40
40
  }
41
41
  } while (level > 0);
42
42
  tprop = getToken(editor, {line: cur.line, ch: tprop.start});
43
- if (tprop.type == 'variable')
44
- tprop.type = 'function';
43
+ if (tprop.type.indexOf("variable") === 0)
44
+ tprop.type = "function";
45
45
  else return; // no clue
46
46
  }
47
47
  if (!context) var context = [];
@@ -106,7 +106,7 @@
106
106
  // If this is a property, see if it belongs to some object we can
107
107
  // find in the current environment.
108
108
  var obj = context.pop(), base;
109
- if (obj.type == "variable") {
109
+ if (obj.type.indexOf("variable") === 0) {
110
110
  if (options && options.additionalContext)
111
111
  base = options.additionalContext[obj.string];
112
112
  base = base || window[obj.string];
@@ -127,8 +127,9 @@
127
127
  }
128
128
  else {
129
129
  // If not, just look in the window object and any local scope
130
- // (reading into JS mode internals to get at the local variables)
130
+ // (reading into JS mode internals to get at the local and global variables)
131
131
  for (var v = token.state.localVars; v; v = v.next) maybeAdd(v.name);
132
+ for (var v = token.state.globalVars; v; v = v.next) maybeAdd(v.name);
132
133
  gatherCompletions(window);
133
134
  forEach(keywords, maybeAdd);
134
135
  }