codemirror-rails 2.35 → 2.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/codemirror/rails/version.rb +2 -2
- data/vendor/assets/javascripts/codemirror.js +22 -16
- data/vendor/assets/javascripts/codemirror/keymaps/emacs.js +2 -1
- data/vendor/assets/javascripts/codemirror/keymaps/vim.js +263 -154
- data/vendor/assets/javascripts/codemirror/modes/clike.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/gfm.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +3 -1
- data/vendor/assets/javascripts/codemirror/modes/mysql.js +23 -6
- data/vendor/assets/javascripts/codemirror/modes/php.js +13 -33
- data/vendor/assets/javascripts/codemirror/modes/python.js +5 -3
- data/vendor/assets/javascripts/codemirror/modes/xml.js +5 -3
- data/vendor/assets/javascripts/codemirror/modes/z80.js +113 -0
- data/vendor/assets/javascripts/codemirror/utils/continuecomment.js +36 -0
- data/vendor/assets/javascripts/codemirror/utils/formatting.js +10 -7
- data/vendor/assets/javascripts/codemirror/utils/xml-hint.js +0 -6
- data/vendor/assets/stylesheets/codemirror/themes/ambiance-mobile.css +6 -0
- data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +1 -1
- data/vendor/assets/stylesheets/codemirror/themes/twilight.css +26 -0
- metadata +16 -12
@@ -133,7 +133,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|
133
133
|
while (ctx.type == "statement") ctx = popContext(state);
|
134
134
|
}
|
135
135
|
else if (curPunc == ctx.type) popContext(state);
|
136
|
-
else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
|
136
|
+
else if (((ctx.type == "}" || ctx.type == "top") && curPunc != ';') || (ctx.type == "statement" && curPunc == "newstatement"))
|
137
137
|
pushContext(state, stream.column(), "statement");
|
138
138
|
state.startOfLine = false;
|
139
139
|
return style;
|
@@ -22,7 +22,7 @@ CodeMirror.defineMode("htmlmixed", function(config) {
|
|
22
22
|
var close = cur.search(pat), m;
|
23
23
|
if (close > -1) stream.backUp(cur.length - close);
|
24
24
|
else if (m = cur.match(/<\/?$/)) {
|
25
|
-
stream.backUp(cur
|
25
|
+
stream.backUp(cur.length);
|
26
26
|
if (!stream.match(pat, false)) stream.match(cur[0]);
|
27
27
|
}
|
28
28
|
return style;
|
@@ -56,12 +56,13 @@ CodeMirror.defineMode("mysql", function(config) {
|
|
56
56
|
curPunc = ch;
|
57
57
|
return null;
|
58
58
|
}
|
59
|
-
else if (ch == "-") {
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
59
|
+
else if (ch == "-" && stream.eat("-")) {
|
60
|
+
stream.skipToEnd();
|
61
|
+
return "comment";
|
62
|
+
}
|
63
|
+
else if (ch == "/" && stream.eat("*")) {
|
64
|
+
state.tokenize = tokenComment;
|
65
|
+
return state.tokenize(stream, state);
|
65
66
|
}
|
66
67
|
else if (operatorChars.test(ch)) {
|
67
68
|
stream.eatWhile(operatorChars);
|
@@ -115,6 +116,22 @@ CodeMirror.defineMode("mysql", function(config) {
|
|
115
116
|
};
|
116
117
|
}
|
117
118
|
|
119
|
+
function tokenComment(stream, state) {
|
120
|
+
for (;;) {
|
121
|
+
if (stream.skipTo("*")) {
|
122
|
+
stream.next();
|
123
|
+
if (stream.eat("/")) {
|
124
|
+
state.tokenize = tokenBase;
|
125
|
+
break;
|
126
|
+
}
|
127
|
+
} else {
|
128
|
+
stream.skipToEnd();
|
129
|
+
break;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
return "comment";
|
133
|
+
}
|
134
|
+
|
118
135
|
|
119
136
|
function pushContext(state, type, col) {
|
120
137
|
state.context = {prev: state.context, indent: state.indent, col: col, type: type};
|
@@ -50,19 +50,16 @@
|
|
50
50
|
};
|
51
51
|
|
52
52
|
CodeMirror.defineMode("php", function(config, parserConfig) {
|
53
|
-
var htmlMode = CodeMirror.getMode(config,
|
54
|
-
var jsMode = CodeMirror.getMode(config, "javascript");
|
55
|
-
var cssMode = CodeMirror.getMode(config, "css");
|
53
|
+
var htmlMode = CodeMirror.getMode(config, "text/html");
|
56
54
|
var phpMode = CodeMirror.getMode(config, phpConfig);
|
57
55
|
|
58
|
-
function dispatch(stream, state) {
|
56
|
+
function dispatch(stream, state) {
|
59
57
|
var isPHP = state.curMode == phpMode;
|
60
58
|
if (stream.sol() && state.pending != '"') state.pending = null;
|
61
|
-
if (
|
59
|
+
if (!isPHP) {
|
62
60
|
if (stream.match(/^<\?\w*/)) {
|
63
61
|
state.curMode = phpMode;
|
64
62
|
state.curState = state.php;
|
65
|
-
state.curClose = "?>";
|
66
63
|
return "meta";
|
67
64
|
}
|
68
65
|
if (state.pending == '"') {
|
@@ -80,51 +77,33 @@
|
|
80
77
|
if (style == "string" && /\"$/.test(cur) && !/\?>/.test(cur)) state.pending = '"';
|
81
78
|
else state.pending = {end: stream.pos, style: style};
|
82
79
|
stream.backUp(cur.length - openPHP);
|
83
|
-
} else if (style == "tag" && stream.current() == ">" && state.curState.context) {
|
84
|
-
if (/^script$/i.test(state.curState.context.tagName)) {
|
85
|
-
state.curMode = jsMode;
|
86
|
-
state.curState = jsMode.startState(htmlMode.indent(state.curState, ""));
|
87
|
-
state.curClose = /^<\/\s*script\s*>/i;
|
88
|
-
}
|
89
|
-
else if (/^style$/i.test(state.curState.context.tagName)) {
|
90
|
-
state.curMode = cssMode;
|
91
|
-
state.curState = cssMode.startState(htmlMode.indent(state.curState, ""));
|
92
|
-
state.curClose = /^<\/\s*style\s*>/i;
|
93
|
-
}
|
94
80
|
}
|
95
81
|
return style;
|
96
|
-
} else if (
|
97
|
-
stream.match(state.curClose, isPHP)) {
|
82
|
+
} else if (isPHP && state.php.tokenize == null && stream.match("?>")) {
|
98
83
|
state.curMode = htmlMode;
|
99
84
|
state.curState = state.html;
|
100
|
-
|
101
|
-
if (isPHP) return "meta";
|
102
|
-
else return dispatch(stream, state);
|
85
|
+
return "meta";
|
103
86
|
} else {
|
104
|
-
return
|
87
|
+
return phpMode.token(stream, state.curState);
|
105
88
|
}
|
106
89
|
}
|
107
90
|
|
108
91
|
return {
|
109
92
|
startState: function() {
|
110
|
-
var html = htmlMode.startState();
|
93
|
+
var html = CodeMirror.startState(htmlMode), php = CodeMirror.startState(phpMode);
|
111
94
|
return {html: html,
|
112
|
-
php:
|
95
|
+
php: php,
|
113
96
|
curMode: parserConfig.startOpen ? phpMode : htmlMode,
|
114
|
-
curState: parserConfig.startOpen ?
|
115
|
-
curClose: parserConfig.startOpen ? /^\?>/ : null,
|
116
|
-
mode: parserConfig.startOpen ? "php" : "html",
|
97
|
+
curState: parserConfig.startOpen ? php : html,
|
117
98
|
pending: null};
|
118
99
|
},
|
119
100
|
|
120
101
|
copyState: function(state) {
|
121
102
|
var html = state.html, htmlNew = CodeMirror.copyState(htmlMode, html),
|
122
103
|
php = state.php, phpNew = CodeMirror.copyState(phpMode, php), cur;
|
123
|
-
if (state.
|
124
|
-
else
|
125
|
-
else cur = CodeMirror.copyState(state.curMode, state.curState);
|
104
|
+
if (state.curMode == htmlMode) cur = htmlNew;
|
105
|
+
else cur = phpNew;
|
126
106
|
return {html: htmlNew, php: phpNew, curMode: state.curMode, curState: cur,
|
127
|
-
curClose: state.curClose, mode: state.mode,
|
128
107
|
pending: state.pending};
|
129
108
|
},
|
130
109
|
|
@@ -141,7 +120,8 @@
|
|
141
120
|
|
142
121
|
innerMode: function(state) { return {state: state.curState, mode: state.curMode}; }
|
143
122
|
};
|
144
|
-
}, "
|
123
|
+
}, "htmlmixed");
|
124
|
+
|
145
125
|
CodeMirror.defineMIME("application/x-httpd-php", "php");
|
146
126
|
CodeMirror.defineMIME("application/x-httpd-php-open", {name: "php", startOpen: true});
|
147
127
|
CodeMirror.defineMIME("text/x-php", phpConfig);
|
@@ -160,7 +160,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|
160
160
|
var singleline = delimiter.length == 1;
|
161
161
|
var OUTCLASS = 'string';
|
162
162
|
|
163
|
-
|
163
|
+
function tokenString(stream, state) {
|
164
164
|
while (!stream.eol()) {
|
165
165
|
stream.eatWhile(/[^'"\\]/);
|
166
166
|
if (stream.eat('\\')) {
|
@@ -183,7 +183,9 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|
183
183
|
}
|
184
184
|
}
|
185
185
|
return OUTCLASS;
|
186
|
-
}
|
186
|
+
}
|
187
|
+
tokenString.isString = true;
|
188
|
+
return tokenString;
|
187
189
|
}
|
188
190
|
|
189
191
|
function indent(stream, state, type) {
|
@@ -325,7 +327,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
|
|
325
327
|
|
326
328
|
indent: function(state, textAfter) {
|
327
329
|
if (state.tokenize != tokenBase) {
|
328
|
-
return 0;
|
330
|
+
return state.tokenize.isString ? CodeMirror.Pass : 0;
|
329
331
|
}
|
330
332
|
|
331
333
|
return state.scopes[0].offset;
|
@@ -70,11 +70,12 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
|
70
70
|
return "meta";
|
71
71
|
}
|
72
72
|
else {
|
73
|
-
|
74
|
-
stream.eatSpace();
|
73
|
+
var isClose = stream.eat("/");
|
75
74
|
tagName = "";
|
76
75
|
var c;
|
77
76
|
while ((c = stream.eat(/[^\s\u00a0=<>\"\'\/?]/))) tagName += c;
|
77
|
+
if (!tagName) return "error";
|
78
|
+
type = isClose ? "closeTag" : "openTag";
|
78
79
|
state.tokenize = inTag;
|
79
80
|
return "tag";
|
80
81
|
}
|
@@ -114,7 +115,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
|
114
115
|
return state.tokenize(stream, state);
|
115
116
|
}
|
116
117
|
else {
|
117
|
-
stream.eatWhile(/[^\s\u00a0=<>\"\'
|
118
|
+
stream.eatWhile(/[^\s\u00a0=<>\"\']/);
|
118
119
|
return "word";
|
119
120
|
}
|
120
121
|
}
|
@@ -255,6 +256,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
|
|
255
256
|
function attribute(type) {
|
256
257
|
if (type == "equals") return cont(attvalue, attributes);
|
257
258
|
if (!Kludges.allowMissing) setStyle = "error";
|
259
|
+
else if (type == "word") setStyle = "attribute";
|
258
260
|
return (type == "endTag" || type == "selfcloseTag") ? pass() : cont();
|
259
261
|
}
|
260
262
|
function attvalue(type) {
|
@@ -0,0 +1,113 @@
|
|
1
|
+
CodeMirror.defineMode('z80', function()
|
2
|
+
{
|
3
|
+
var keywords1 = /^(exx?|(ld|cp|in)([di]r?)?|pop|push|ad[cd]|cpl|daa|dec|inc|neg|sbc|sub|and|bit|[cs]cf|x?or|res|set|r[lr]c?a?|r[lr]d|s[lr]a|srl|djnz|nop|rst|[de]i|halt|im|ot[di]r|out[di]?)\b/i;
|
4
|
+
var keywords2 = /^(call|j[pr]|ret[in]?)\b/i;
|
5
|
+
var keywords3 = /^b_?(call|jump)\b/i;
|
6
|
+
var variables1 = /^(af?|bc?|c|de?|e|hl?|l|i[xy]?|r|sp)\b/i;
|
7
|
+
var variables2 = /^(n?[zc]|p[oe]?|m)\b/i;
|
8
|
+
var errors = /^([hl][xy]|i[xy][hl]|slia|sll)\b/i;
|
9
|
+
var numbers = /^([\da-f]+h|[0-7]+o|[01]+b|\d+)\b/i;
|
10
|
+
|
11
|
+
return {startState: function()
|
12
|
+
{
|
13
|
+
return {context: 0};
|
14
|
+
}, token: function(stream, state)
|
15
|
+
{
|
16
|
+
if (!stream.column())
|
17
|
+
state.context = 0;
|
18
|
+
|
19
|
+
if (stream.eatSpace())
|
20
|
+
return null;
|
21
|
+
|
22
|
+
var w;
|
23
|
+
|
24
|
+
if (stream.eatWhile(/\w/))
|
25
|
+
{
|
26
|
+
w = stream.current();
|
27
|
+
|
28
|
+
if (stream.indentation())
|
29
|
+
{
|
30
|
+
if (state.context == 1 && variables1.test(w))
|
31
|
+
return 'variable-2';
|
32
|
+
|
33
|
+
if (state.context == 2 && variables2.test(w))
|
34
|
+
return 'variable-3';
|
35
|
+
|
36
|
+
if (keywords1.test(w))
|
37
|
+
{
|
38
|
+
state.context = 1;
|
39
|
+
return 'keyword';
|
40
|
+
}
|
41
|
+
else if (keywords2.test(w))
|
42
|
+
{
|
43
|
+
state.context = 2;
|
44
|
+
return 'keyword';
|
45
|
+
}
|
46
|
+
else if (keywords3.test(w))
|
47
|
+
{
|
48
|
+
state.context = 3;
|
49
|
+
return 'keyword';
|
50
|
+
}
|
51
|
+
|
52
|
+
if (errors.test(w))
|
53
|
+
return 'error';
|
54
|
+
}
|
55
|
+
else if (numbers.test(w))
|
56
|
+
{
|
57
|
+
return 'number';
|
58
|
+
}
|
59
|
+
else
|
60
|
+
{
|
61
|
+
return null;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
else if (stream.eat(';'))
|
65
|
+
{
|
66
|
+
stream.skipToEnd();
|
67
|
+
return 'comment';
|
68
|
+
}
|
69
|
+
else if (stream.eat('"'))
|
70
|
+
{
|
71
|
+
while (w = stream.next())
|
72
|
+
{
|
73
|
+
if (w == '"')
|
74
|
+
break;
|
75
|
+
|
76
|
+
if (w == '\\')
|
77
|
+
stream.next();
|
78
|
+
}
|
79
|
+
|
80
|
+
return 'string';
|
81
|
+
}
|
82
|
+
else if (stream.eat('\''))
|
83
|
+
{
|
84
|
+
if (stream.match(/\\?.'/))
|
85
|
+
return 'number';
|
86
|
+
}
|
87
|
+
else if (stream.eat('.') || stream.sol() && stream.eat('#'))
|
88
|
+
{
|
89
|
+
state.context = 4;
|
90
|
+
|
91
|
+
if (stream.eatWhile(/\w/))
|
92
|
+
return 'def';
|
93
|
+
}
|
94
|
+
else if (stream.eat('$'))
|
95
|
+
{
|
96
|
+
if (stream.eatWhile(/[\da-f]/i))
|
97
|
+
return 'number';
|
98
|
+
}
|
99
|
+
else if (stream.eat('%'))
|
100
|
+
{
|
101
|
+
if (stream.eatWhile(/[01]/))
|
102
|
+
return 'number';
|
103
|
+
}
|
104
|
+
else
|
105
|
+
{
|
106
|
+
stream.next();
|
107
|
+
}
|
108
|
+
|
109
|
+
return null;
|
110
|
+
}};
|
111
|
+
});
|
112
|
+
|
113
|
+
CodeMirror.defineMIME("text/x-z80", "z80");
|
@@ -0,0 +1,36 @@
|
|
1
|
+
(function() {
|
2
|
+
var modes = ["clike", "css", "javascript"];
|
3
|
+
for (var i = 0; i < modes.length; ++i)
|
4
|
+
CodeMirror.extendMode(modes[i], {blockCommentStart: "/*",
|
5
|
+
blockCommentEnd: "*/",
|
6
|
+
blockCommentContinue: " * "});
|
7
|
+
|
8
|
+
CodeMirror.commands.newlineAndIndentContinueComment = function(cm) {
|
9
|
+
var pos = cm.getCursor(), token = cm.getTokenAt(pos);
|
10
|
+
var mode = CodeMirror.innerMode(cm.getMode(), token.state).mode;
|
11
|
+
var space;
|
12
|
+
|
13
|
+
if (token.className == "comment" && mode.blockCommentStart) {
|
14
|
+
var end = token.string.indexOf(mode.blockCommentEnd);
|
15
|
+
var full = cm.getRange({line: pos.line, ch: 0}, {line: pos.line, ch: token.end}), found;
|
16
|
+
if (end != -1 && end == token.string.length - mode.blockCommentEnd.length) {
|
17
|
+
// Comment ended, don't continue it
|
18
|
+
} else if (token.string.indexOf(mode.blockCommentStart) == 0) {
|
19
|
+
space = full.slice(0, token.start);
|
20
|
+
if (!/^\s*$/.test(space)) {
|
21
|
+
space = "";
|
22
|
+
for (var i = 0; i < token.start; ++i) space += " ";
|
23
|
+
}
|
24
|
+
} else if ((found = full.indexOf(mode.blockCommentContinue)) != -1 &&
|
25
|
+
found + mode.blockCommentContinue.length > token.start &&
|
26
|
+
/^\s*$/.test(full.slice(0, found))) {
|
27
|
+
space = full.slice(0, found);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
if (space != null)
|
32
|
+
cm.replaceSelection("\n" + space + mode.blockCommentContinue, "end");
|
33
|
+
else
|
34
|
+
cm.execCommand("newlineAndIndent");
|
35
|
+
};
|
36
|
+
})();
|
@@ -47,13 +47,16 @@
|
|
47
47
|
|
48
48
|
autoFormatLineBreaks: function (text) {
|
49
49
|
var curPos = 0;
|
50
|
-
var
|
51
|
-
|
50
|
+
var split = this.jsonMode ? function(str) {
|
51
|
+
return str.replace(/([,{])/g, "$1\n").replace(/}/g, "\n}");
|
52
|
+
} : function(str) {
|
53
|
+
return str.replace(/(;|\{|\})([^\r\n;])/g, "$1\n$2");
|
54
|
+
};
|
55
|
+
var nonBreakableBlocks = jsNonBreakableBlocks(text), res = "";
|
52
56
|
if (nonBreakableBlocks != null) {
|
53
|
-
var res = "";
|
54
57
|
for (var i = 0; i < nonBreakableBlocks.length; i++) {
|
55
58
|
if (nonBreakableBlocks[i].start > curPos) { // Break lines till the block
|
56
|
-
res += text.substring(curPos, nonBreakableBlocks[i].start)
|
59
|
+
res += split(text.substring(curPos, nonBreakableBlocks[i].start));
|
57
60
|
curPos = nonBreakableBlocks[i].start;
|
58
61
|
}
|
59
62
|
if (nonBreakableBlocks[i].start <= curPos
|
@@ -63,11 +66,11 @@
|
|
63
66
|
}
|
64
67
|
}
|
65
68
|
if (curPos < text.length)
|
66
|
-
res += text.substr(curPos)
|
67
|
-
return res;
|
69
|
+
res += split(text.substr(curPos));
|
68
70
|
} else {
|
69
|
-
|
71
|
+
res = split(text);
|
70
72
|
}
|
73
|
+
return res.replace(/^\n*|\n*$/, "");
|
71
74
|
}
|
72
75
|
});
|
73
76
|
|
@@ -12,13 +12,7 @@
|
|
12
12
|
cm.setCursor(cursor);
|
13
13
|
}
|
14
14
|
|
15
|
-
// dirty hack for simple-hint to receive getHint event on space
|
16
|
-
var getTokenAt = editor.getTokenAt;
|
17
|
-
|
18
|
-
editor.getTokenAt = function() { return 'disabled'; };
|
19
15
|
CodeMirror.simpleHint(cm, getHint);
|
20
|
-
|
21
|
-
editor.getTokenAt = getTokenAt;
|
22
16
|
};
|
23
17
|
|
24
18
|
var getHint = function(cm) {
|