Showing with 5,546 additions and 2,534 deletions.
  1. +1 −0 .gitignore
  2. +4 −0 addon/dialog/dialog.js
  3. +54 −0 addon/display/placeholder.js
  4. +27 −4 addon/edit/closebrackets.js
  5. +1 −2 addon/edit/closetag.js
  6. +11 −3 addon/edit/continuecomment.js
  7. +20 −23 addon/edit/continuelist.js
  8. +31 −0 addon/fold/brace-fold.js
  9. +0 −68 addon/fold/collapserange.js
  10. +0 −151 addon/fold/foldcode.js
  11. +11 −0 addon/fold/indent-fold.js
  12. +64 −0 addon/fold/xml-fold.js
  13. +0 −114 addon/format/formatting.js
  14. +582 −0 addon/hint/html-hint.js
  15. +29 −12 addon/hint/show-hint.js
  16. +0 −16 addon/hint/simple-hint.css
  17. +0 −102 addon/hint/simple-hint.js
  18. +1 −1 addon/hint/xml-hint.js
  19. +8 −2 addon/lint/javascript-lint.js
  20. +1 −0 addon/lint/lint.js
  21. +8 −9 addon/search/searchcursor.js
  22. +6 −2 demo/closebrackets.html
  23. +0 −104 demo/collapserange.html
  24. +1 −1 demo/complete.html
  25. +3 −1 demo/folding.html
  26. +0 −89 demo/formatting.html
  27. +92 −0 demo/html5complete.html
  28. +49 −0 demo/indentwrap.html
  29. +36 −0 demo/placeholder.html
  30. +5 −2 demo/resize.html
  31. +73 −0 demo/spanaffectswrapping_shim.html
  32. +2 −0 demo/theme.html
  33. +1 −1 demo/visibletabs.html
  34. +8 −5 doc/compress.html
  35. +85 −40 doc/manual.html
  36. +4 −0 doc/modes.html
  37. +16 −0 doc/oldrelease.html
  38. +2 −1 doc/realworld.html
  39. +27 −17 index.html
  40. +337 −141 keymap/vim.js
  41. +10 −9 lib/codemirror.css
  42. +263 −131 lib/codemirror.js
  43. +19 −2 mode/clojure/clojure.js
  44. +16 −7 mode/clojure/index.html
  45. +337 −235 mode/css/css.js
  46. +145 −0 mode/css/scss.html
  47. +80 −0 mode/css/scss_test.js
  48. +9 −2 mode/css/test.js
  49. +1 −0 mode/gfm/gfm.js
  50. +5 −0 mode/gfm/index.html
  51. +29 −1 mode/gfm/test.js
  52. +1 −1 mode/javascript/index.html
  53. +17 −6 mode/javascript/javascript.js
  54. +23 −0 mode/livescript/LICENSE
  55. +446 −0 mode/livescript/index.html
  56. +267 −0 mode/livescript/livescript.js
  57. +266 −0 mode/livescript/livescript.ls
  58. +76 −25 mode/markdown/markdown.js
  59. +144 −87 mode/markdown/test.js
  60. +4 −2 mode/meta.js
  61. +149 −0 mode/mirc/index.html
  62. +177 −0 mode/mirc/mirc.js
  63. +0 −43 mode/mysql/index.html
  64. +0 −203 mode/mysql/mysql.js
  65. +0 −64 mode/plsql/index.html
  66. +0 −216 mode/plsql/plsql.js
  67. +21 −0 mode/rst/LICENSE.txt
  68. +9 −11 mode/rst/index.html
  69. +486 −250 mode/rst/rst.js
  70. +1 −1 mode/sql/sql.js
  71. +192 −121 mode/stex/stex.js
  72. +13 −0 mode/stex/test.js
  73. +129 −0 mode/tcl/index.html
  74. +131 −0 mode/tcl/tcl.js
  75. +2 −2 mode/tiki/tiki.css
  76. +82 −171 mode/verilog/index.html
  77. +9 −5 mode/xml/xml.js
  78. +2 −2 package.json
  79. +1 −0 test/index.html
  80. +2 −2 test/mode_test.js
  81. +59 −4 test/test.js
  82. +274 −12 test/vim_test.js
  83. +0 −1 theme/ambiance-mobile.css
  84. +0 −1 theme/ambiance.css
  85. +1 −1 theme/eclipse.css
  86. +5 −5 theme/erlang-dark.css
  87. +43 −0 theme/xq-light.css
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/node_modules
/npm-debug.log
test.html
.tern-*
4 changes: 4 additions & 0 deletions addon/dialog/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@
var inp = dialog.getElementsByTagName("input")[0], button;
if (inp) {
CodeMirror.on(inp, "keydown", function(e) {
if (options && options.onKeyDown && options.onKeyDown(e, inp.value, close)) { return; }
if (e.keyCode == 13 || e.keyCode == 27) {
CodeMirror.e_stop(e);
close();
me.focus();
if (e.keyCode == 13) callback(inp.value);
}
});
if (options && options.onKeyUp) {
CodeMirror.on(inp, "keyup", function(e) {options.onKeyUp(e, inp.value, close);});
}
if (options && options.value) inp.value = options.value;
inp.focus();
CodeMirror.on(inp, "blur", close);
Expand Down
54 changes: 54 additions & 0 deletions addon/display/placeholder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
(function() {
CodeMirror.defineOption("placeholder", "", function(cm, val, old) {
var prev = old && old != CodeMirror.Init;
if (val && !prev) {
cm.on("focus", onFocus);
cm.on("blur", onBlur);
cm.on("change", onChange);
onChange(cm);
} else if (!val && prev) {
cm.off("focus", onFocus);
cm.off("blur", onBlur);
cm.off("change", onChange);
clearPlaceholder(cm);
var wrapper = cm.getWrapperElement();
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
}

if (val && !cm.hasFocus()) onBlur(cm);
});

function clearPlaceholder(cm) {
if (cm._placeholder) {
cm._placeholder.parentNode.removeChild(cm._placeholder);
cm._placeholder = null;
}
}
function setPlaceholder(cm) {
clearPlaceholder(cm);
var elt = cm._placeholder = document.createElement("pre");
elt.style.cssText = "height: 0; overflow: visible";
elt.className = "CodeMirror-placeholder";
elt.appendChild(document.createTextNode(cm.getOption("placeholder")));
cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
}

function onFocus(cm) {
clearPlaceholder(cm);
}
function onBlur(cm) {
if (isEmpty(cm)) setPlaceholder(cm);
}
function onChange(cm) {
var wrapper = cm.getWrapperElement(), empty = isEmpty(cm);
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + (empty ? " CodeMirror-empty" : "");

if (cm.hasFocus()) return;
if (empty) setPlaceholder(cm);
else clearPlaceholder(cm);
}

function isEmpty(cm) {
return (cm.lineCount() === 1) && (cm.getLine(0) === "");
}
})();
31 changes: 27 additions & 4 deletions addon/edit/closebrackets.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(function() {
var DEFAULT_BRACKETS = "()[]{}''\"\"";
var SPACE_CHAR_REGEX = /\s/;

CodeMirror.defineOption("autoCloseBrackets", false, function(cm, val, old) {
var wasOn = old && old != CodeMirror.Init;
Expand All @@ -10,17 +11,39 @@
});

function buildKeymap(pairs) {
var map = {name : "autoCloseBrackets"};
var map = {
name : "autoCloseBrackets",
Backspace: function(cm) {
if (cm.somethingSelected()) return CodeMirror.Pass;
var cur = cm.getCursor(), line = cm.getLine(cur.line);
if (cur.ch && cur.ch < line.length &&
pairs.indexOf(line.slice(cur.ch - 1, cur.ch + 1)) % 2 == 0)
cm.replaceRange("", CodeMirror.Pos(cur.line, cur.ch - 1), CodeMirror.Pos(cur.line, cur.ch + 1));
else
return CodeMirror.Pass;
}
};
var closingBrackets = [];
for (var i = 0; i < pairs.length; i += 2) (function(left, right) {
if (left != right) closingBrackets.push(right);
function surround(cm) {
var selection = cm.getSelection();
cm.replaceSelection(left + selection + right);
}
function maybeOverwrite(cm) {
var cur = cm.getCursor(), ahead = cm.getRange(cur, CodeMirror.Pos(cur.line, cur.ch + 1));
if (ahead != right) return CodeMirror.Pass;
if (ahead != right || cm.somethingSelected()) return CodeMirror.Pass;
else cm.execCommand("goCharRight");
}
map["'" + left + "'"] = function(cm) {
if (cm.somethingSelected()) return surround(cm);
if (left == right && maybeOverwrite(cm) != CodeMirror.Pass) return;
var cur = cm.getCursor("start"), ahead = CodeMirror.Pos(cur.line, cur.ch + 1);
cm.replaceSelection(left + right, {head: ahead, anchor: ahead});
var cur = cm.getCursor(), ahead = CodeMirror.Pos(cur.line, cur.ch + 1);
var line = cm.getLine(cur.line), nextChar = line.charAt(cur.ch);
if (line.length == cur.ch || closingBrackets.indexOf(nextChar) >= 0 || SPACE_CHAR_REGEX.test(nextChar))
cm.replaceSelection(left + right, {head: ahead, anchor: ahead});
else
return CodeMirror.Pass;
};
if (left != right) map["'" + right + "'"] = maybeOverwrite;
})(pairs.charAt(i), pairs.charAt(i + 1));
Expand Down
3 changes: 1 addition & 2 deletions addon/edit/closetag.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@
if (tok.end > pos.ch) tagName = tagName.slice(0, tagName.length - tok.end + pos.ch);
var lowerTagName = tagName.toLowerCase();
// Don't process the '>' at the end of an end-tag or self-closing tag
if (tok.type == "tag" && state.type == "closeTag" ||
/\/\s*$/.test(tok.string) ||
if (tok.type == "tag" && state.type == "closeTag" || tok.string.indexOf("/") > -1 ||
dontCloseTags && indexOf(dontCloseTags, lowerTagName) > -1)
return CodeMirror.Pass;

Expand Down
14 changes: 11 additions & 3 deletions addon/edit/continuecomment.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
blockCommentEnd: "*/",
blockCommentContinue: " * "});

CodeMirror.commands.newlineAndIndentContinueComment = function(cm) {
function continueComment(cm) {
var pos = cm.getCursor(), token = cm.getTokenAt(pos);
var mode = CodeMirror.innerMode(cm.getMode(), token.state).mode;
var space;
Expand All @@ -31,6 +31,14 @@
if (space != null)
cm.replaceSelection("\n" + space + mode.blockCommentContinue, "end");
else
cm.execCommand("newlineAndIndent");
};
return CodeMirror.Pass;
}

CodeMirror.defineOption("continueComments", null, function(cm, val, prev) {
if (prev && prev != CodeMirror.Init)
cm.removeKeyMap("continueComment");
var map = {name: "continueComment"};
map[typeof val == "string" ? val : "Enter"] = continueComment;
cm.addKeyMap(map);
});
})();
43 changes: 20 additions & 23 deletions addon/edit/continuelist.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
(function() {
'use strict';

var listRE = /^(\s*)([*+-]|(\d+)\.)(\s*)/,
unorderedBullets = '*+-';

CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
var pos = cm.getCursor(), token = cm.getTokenAt(pos);
var space;
if (token.className == "string") {
var full = cm.getRange({line: pos.line, ch: 0}, {line: pos.line, ch: token.end});
var listStart = /\*|\d+\./, listContinue;
if (token.string.search(listStart) == 0) {
var reg = /^[\W]*(\d+)\./g;
var matches = reg.exec(full);
if(matches)
listContinue = (parseInt(matches[1]) + 1) + ". ";
else
listContinue = "* ";
space = full.slice(0, token.start);
if (!/^\s*$/.test(space)) {
space = "";
for (var i = 0; i < token.start; ++i) space += " ";
}
}
var pos = cm.getCursor(),
inList = cm.getStateAfter(pos.line).list,
match;

if (!inList || !(match = cm.getLine(pos.line).match(listRE))) {
cm.execCommand('newlineAndIndent');
return;
}

if (space != null)
cm.replaceSelection("\n" + space + listContinue, "end");
else
cm.execCommand("newlineAndIndent");
var indent = match[1], after = match[4];
var bullet = unorderedBullets.indexOf(match[2]) >= 0
? match[2]
: (parseInt(match[3], 10) + 1) + '.';

cm.replaceSelection('\n' + indent + bullet + after, 'end');
};
})();

}());
31 changes: 31 additions & 0 deletions addon/fold/brace-fold.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
CodeMirror.braceRangeFinder = function(cm, start) {
var line = start.line, lineText = cm.getLine(line);
var at = lineText.length, startChar, tokenType;
for (;;) {
var found = lineText.lastIndexOf("{", at);
if (found < start.ch) break;
tokenType = cm.getTokenAt(CodeMirror.Pos(line, found + 1)).type;
if (!/^(comment|string)/.test(tokenType)) { startChar = found; break; }
at = found - 1;
}
if (startChar == null || lineText.lastIndexOf("}") > startChar) return;
var count = 1, lastLine = cm.lineCount(), end, endCh;
outer: for (var i = line + 1; i < lastLine; ++i) {
var text = cm.getLine(i), pos = 0;
for (;;) {
var nextOpen = text.indexOf("{", pos), nextClose = text.indexOf("}", pos);
if (nextOpen < 0) nextOpen = text.length;
if (nextClose < 0) nextClose = text.length;
pos = Math.min(nextOpen, nextClose);
if (pos == text.length) break;
if (cm.getTokenAt(CodeMirror.Pos(i, pos + 1)).type == tokenType) {
if (pos == nextOpen) ++count;
else if (!--count) { end = i; endCh = pos; break outer; }
}
++pos;
}
}
if (end == null || end == line + 1) return;
return {from: CodeMirror.Pos(line, startChar + 1),
to: CodeMirror.Pos(end, endCh)};
};
68 changes: 0 additions & 68 deletions addon/fold/collapserange.js

This file was deleted.

Loading