Showing with 2,144 additions and 929 deletions.
  1. +23 −0 AUTHORS
  2. +16 −3 addon/comment/continuecomment.js
  3. +1 −0 addon/dialog/dialog.js
  4. +47 −0 addon/display/rulers.js
  5. +1 −0 addon/edit/closetag.js
  6. +6 −0 addon/fold/foldcode.js
  7. +34 −0 addon/fold/markdown-fold.js
  8. +2 −2 addon/hint/anyword-hint.js
  9. +25 −18 addon/hint/show-hint.js
  10. +14 −0 addon/lint/yaml-lint.js
  11. +1 −1 addon/merge/dep/diff_match_patch.js
  12. +2 −2 addon/runmode/runmode.node.js
  13. +2 −0 addon/scroll/scrollpastend.js
  14. +9 −3 addon/search/search.js
  15. +1 −1 bin/release
  16. +1 −1 bin/source-highlight
  17. +1 −2 demo/changemode.html
  18. +16 −1 demo/folding.html
  19. +29 −76 demo/fullscreen.html
  20. +1 −2 demo/preview.html
  21. +54 −0 demo/rulers.html
  22. +30 −37 demo/search.html
  23. +2 −0 demo/theme.html
  24. +6 −6 demo/variableheight.html
  25. +5 −0 doc/compress.html
  26. +3 −1 doc/docs.css
  27. +38 −13 doc/manual.html
  28. +4 −0 doc/realworld.html
  29. +12 −1 doc/releases.html
  30. +7 −6 index.html
  31. +126 −54 keymap/vim.js
  32. +12 −11 lib/codemirror.css
  33. +87 −43 lib/codemirror.js
  34. +6 −5 mode/clojure/clojure.js
  35. +19 −9 mode/css/css.js
  36. +0 −1 mode/eiffel/index.html
  37. +1 −1 mode/gas/gas.js
  38. +1 −3 mode/htmlembedded/index.html
  39. +4 −1 mode/htmlmixed/htmlmixed.js
  40. +1 −1 mode/htmlmixed/index.html
  41. +2 −0 mode/index.html
  42. +5 −3 mode/javascript/index.html
  43. +11 −3 mode/javascript/javascript.js
  44. +72 −0 mode/javascript/json-ld.html
  45. +38 −0 mode/javascript/test.js
  46. +0 −1 mode/julia/index.html
  47. +47 −23 mode/julia/julia.js
  48. +1 −1 mode/livescript/index.html
  49. +0 −1 mode/lua/index.html
  50. +5 −3 mode/markdown/markdown.js
  51. +15 −15 mode/markdown/test.js
  52. +3 −0 mode/meta.js
  53. +2 −3 mode/mirc/index.html
  54. +4 −16 mode/octave/index.html
  55. +6 −4 mode/octave/octave.js
  56. +1 −3 mode/php/index.html
  57. +121 −0 mode/puppet/index.html
  58. +204 −0 mode/puppet/puppet.js
  59. +0 −2 mode/python/index.html
  60. +4 −0 mode/python/python.js
  61. +1 −2 mode/rpm/changes/index.html
  62. +1 −0 mode/rst/index.html
  63. +520 −517 mode/rst/rst.js
  64. +0 −1 mode/ruby/index.html
  65. +1 −0 mode/ruby/ruby.js
  66. +11 −0 mode/ruby/test.js
  67. +1 −2 mode/rust/index.html
  68. +57 −0 mode/solr/index.html
  69. +89 −0 mode/solr/solr.js
  70. +0 −1 mode/sparql/index.html
  71. +2 −2 mode/sql/sql.js
  72. +7 −8 mode/tcl/index.html
  73. +0 −1 mode/tiddlywiki/index.html
  74. +0 −1 mode/turtle/index.html
  75. +1 −2 mode/vb/index.html
  76. +0 −1 mode/velocity/index.html
  77. +2 −1 mode/xml/xml.js
  78. +1 −1 package.json
  79. +1 −0 test/index.html
  80. +32 −5 test/test.js
  81. +181 −1 test/vim_test.js
  82. +44 −0 theme/mdn-like.css
  83. +1 −0 theme/solarized.css
23 changes: 23 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ Alexander Schepanovski
Alexander Solovyov
alexey-k
Alex Piggott
Amsul
Amy
Ananya Sen
anaran
AndersMad
Anderson Mesquita
Andre von Houck
Expand All @@ -42,6 +44,9 @@ benbro
Beni Cherniavsky-Paskin
Benjamin DeCoste
Ben Keen
Bernhard Sirlinger
Billy Moon
Blaine G
boomyjee
borawjm
Brandon Frohs
Expand All @@ -53,11 +58,13 @@ Chandra Sekhar Pydi
Charles Skelton
Chris Coyier
Chris Granger
Chris Houseknecht
Chris Morgan
Christopher Brown
ciaranj
CodeAnimal
ComFreek
Curtis Gagliardi
dagsta
Dan Heberden
Daniel, Dao Quang Minh
Expand All @@ -72,6 +79,7 @@ David Mignot
David Pathakjee
deebugger
Deep Thought
domagoj412
Dominator008
Domizio Demichelis
Drew Bratcher
Expand All @@ -85,6 +93,7 @@ ekhaled
Enam Mijbah Noor
Eric Allam
eustas
Fabien O'Carroll
Fabio Zendhi Nagao
Fauntleroy
fbuchinger
Expand All @@ -96,13 +105,15 @@ flack
ForbesLindesay
Forbes Lindesay
Ford_Lawnmower
Frank Wiegand
Gabriel Nahmias
galambalazs
Gautam Mehta
Glenn Jorde
Glenn Ruehle
Golevka
Gordon Smith
Grant Skinner
greengiant
Guillaume Massé
Guillaume Massé
Expand All @@ -122,6 +133,7 @@ Ingo Richter
Irakli Gozalishvili
Ivan Kurnosov
Jacob Lee
Jakob Miland
Jakub Vrana
James Campos
James Thorne
Expand All @@ -146,6 +158,7 @@ John Connor
John Lees-Miller
John Snelson
John Van Der Loo
Jonathan Malmaud
jongalloway
Jon Malmaud
Joost-Wim Boekesteijn
Expand Down Expand Up @@ -179,8 +192,10 @@ Luciano Longo
lynschinzer
Maksim Lin
Maksym Taran
Manuel Rego Casasnovas
Marat Dreizin
Marco Aurélio
Marco Munizaga
Marijn Haverbeke
Mario Pietsch
Mark Lentczner
Expand Down Expand Up @@ -216,10 +231,14 @@ Miraculix87
misfo
mloginov
mps
mtaran-google
Narciso Jaramillo
Nathan Williams
ndr
nerbert
nextrevision
nguillaumin
Nicholas Bollweg
Niels van Groningen
Nikita Beloglazov
Nikita Vasilyev
Expand All @@ -240,10 +259,12 @@ prasanthj
Prasanth J
Rahul
Randy Edmunds
Rasmus Erik Voel Jensen
Richard Z.H. Wang
robertop23
Robert Plummer
Ruslan Osmanov
Ryan Prior
sabaca
Samuel Ainsworth
sandeepshetty
Expand All @@ -256,6 +277,7 @@ Sebastian Zaha
shaund
shaun gilchrist
Shawn A
sheopory
Shiv Deepak
Shmuel Englard
soliton4
Expand Down Expand Up @@ -284,6 +306,7 @@ Tom Erik Støwer
Tom MacWright
Tony Jian
Travis Heppe
Triangle717
Vestimir Markov
vf
Volker Mische
Expand Down
19 changes: 16 additions & 3 deletions addon/comment/continuecomment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(function() {
var modes = ["clike", "css", "javascript"];

for (var i = 0; i < modes.length; ++i)
CodeMirror.extendMode(modes[i], {blockCommentContinue: " * "});

Expand All @@ -12,7 +13,7 @@
if (mode.blockCommentStart && mode.blockCommentContinue) {
var end = token.string.indexOf(mode.blockCommentEnd);
var full = cm.getRange(CodeMirror.Pos(pos.line, 0), CodeMirror.Pos(pos.line, token.end)), found;
if (end != -1 && end == token.string.length - mode.blockCommentEnd.length) {
if (end != -1 && end == token.string.length - mode.blockCommentEnd.length && pos.ch >= end) {
// Comment ended, don't continue it
} else if (token.string.indexOf(mode.blockCommentStart) == 0) {
insert = full.slice(0, token.start);
Expand All @@ -27,7 +28,7 @@
}
if (insert != null) insert += mode.blockCommentContinue;
}
if (insert == null && mode.lineComment) {
if (insert == null && mode.lineComment && continueLineCommentEnabled(cm)) {
var line = cm.getLine(pos.line), found = line.indexOf(mode.lineComment);
if (found > -1) {
insert = line.slice(0, found);
Expand All @@ -42,12 +43,24 @@
return CodeMirror.Pass;
}

function continueLineCommentEnabled(cm) {
var opt = cm.getOption("continueComments");
if (opt && typeof opt == "object")
return opt.continueLineComment !== false;
return true;
}

CodeMirror.defineOption("continueComments", null, function(cm, val, prev) {
if (prev && prev != CodeMirror.Init)
cm.removeKeyMap("continueComment");
if (val) {
var key = "Enter";
if (typeof val == "string")
key = val;
else if (typeof val == "object" && val.key)
key = val.key;
var map = {name: "continueComment"};
map[typeof val == "string" ? val : "Enter"] = continueComment;
map[key] = continueComment;
cm.addKeyMap(map);
}
});
Expand Down
1 change: 1 addition & 0 deletions addon/dialog/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
CodeMirror.on(inp, "keydown", function(e) {
if (options && options.onKeyDown && options.onKeyDown(e, inp.value, close)) { return; }
if (e.keyCode == 13 || e.keyCode == 27) {
inp.blur();
CodeMirror.e_stop(e);
close();
me.focus();
Expand Down
47 changes: 47 additions & 0 deletions addon/display/rulers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
(function() {
"use strict";

CodeMirror.defineOption("rulers", false, function(cm, val, old) {
if (old && old != CodeMirror.Init) {
clearRulers(cm);
cm.off("refresh", refreshRulers);
}
if (val && val.length) {
setRulers(cm);
cm.on("refresh", refreshRulers);
}
});

function clearRulers(cm) {
for (var i = cm.display.lineSpace.childNodes.length - 1; i >= 0; i--) {
var node = cm.display.lineSpace.childNodes[i];
if (/(^|\s)CodeMirror-ruler($|\s)/.test(node.className))
node.parentNode.removeChild(node);
}
}

function setRulers(cm) {
var val = cm.getOption("rulers");
var cw = cm.defaultCharWidth();
var left = cm.charCoords(CodeMirror.Pos(cm.firstLine(), 0), "div").left;
var bot = -cm.display.scroller.offsetHeight;
for (var i = 0; i < val.length; i++) {
var elt = document.createElement("div");
var col, cls = null;
if (typeof val[i] == "number") {
col = val[i];
} else {
col = val[i].column;
cls = val[i].className;
}
elt.className = "CodeMirror-ruler" + (cls ? " " + cls : "");
elt.style.cssText = "left: " + (left + col * cw) + "px; top: -50px; bottom: " + bot + "px";
cm.display.lineSpace.insertBefore(elt, cm.display.cursorDiv);
}
}

function refreshRulers(cm) {
clearRulers(cm);
setRulers(cm);
}
})();
1 change: 1 addition & 0 deletions addon/edit/closetag.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@

var tagName = state.context && state.context.tagName;
if (tagName) cm.replaceSelection("/" + tagName + ">", "end");
else return CodeMirror.Pass;
}

function indexOf(collection, elt) {
Expand Down
6 changes: 6 additions & 0 deletions addon/fold/foldcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
doFold(this, pos, options, force);
});

CodeMirror.defineExtension("isFolded", function(pos) {
var marks = this.findMarksAt(pos);
for (var i = 0; i < marks.length; ++i)
if (marks[i].__isFold) return true;
});

CodeMirror.commands.fold = function(cm) {
cm.foldCode(cm.getCursor());
};
Expand Down
34 changes: 34 additions & 0 deletions addon/fold/markdown-fold.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
CodeMirror.registerHelper("fold", "markdown", function(cm, start) {
var maxDepth = 100;

function isHeader(lineNo) {
var tokentype = cm.getTokenTypeAt(CodeMirror.Pos(lineNo, 0));
return tokentype && /\bheader\b/.test(tokentype);
}

function headerLevel(lineNo, line, nextLine) {
var match = line && line.match(/^#+/);
if (match && isHeader(lineNo)) return match[0].length;
match = nextLine && nextLine.match(/^[=\-]+\s*$/);
if (match && isHeader(lineNo + 1)) return nextLine[0] == "=" ? 1 : 2;
return maxDepth;
}

var firstLine = cm.getLine(start.line), nextLine = cm.getLine(start.line + 1);
var level = headerLevel(start.line, firstLine, nextLine);
if (level === maxDepth) return undefined;

var lastLineNo = cm.lastLine();
var end = start.line, nextNextLine = cm.getLine(end + 2);
while (end < lastLineNo) {
if (headerLevel(end + 1, nextLine, nextNextLine) <= level) break;
++end;
nextLine = nextNextLine;
nextNextLine = cm.getLine(end + 2);
}

return {
from: CodeMirror.Pos(start.line, firstLine.length),
to: CodeMirror.Pos(end, cm.getLine(end).length)
};
});
4 changes: 2 additions & 2 deletions addon/hint/anyword-hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
var list = [], seen = {};
var re = new RegExp(word.source, "g");
for (var dir = -1; dir <= 1; dir += 2) {
var line = cur.line, end = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir;
for (; line != end; line += dir) {
var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir;
for (; line != endLine; line += dir) {
var text = editor.getLine(line), m;
while (m = re.exec(text)) {
if (line == cur.line && m[0] === curWord) continue;
Expand Down
43 changes: 25 additions & 18 deletions addon/hint/show-hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
pick: function(data, i) {
var completion = data.list[i];
if (completion.hint) completion.hint(this.cm, data, completion);
else this.cm.replaceRange(getText(completion), data.from, data.to);
else this.cm.replaceRange(getText(completion), completion.from||data.from, completion.to||data.to);
CodeMirror.signal(data, "pick", completion);
this.close();
},
Expand Down Expand Up @@ -193,34 +193,40 @@
var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
(options.container || document.body).appendChild(hints);
var box = hints.getBoundingClientRect();
var overlapX = box.right - winW, overlapY = box.bottom - winH;
var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
if (overlapY > 0) {
var height = box.bottom - box.top, curTop = box.top - (pos.bottom - pos.top);
if (curTop - height > 0) { // Fits above cursor
hints.style.top = (top = curTop - height) + "px";
below = false;
} else if (height > winH) {
hints.style.height = (winH - 5) + "px";
hints.style.top = (top = pos.bottom - box.top) + "px";
var cursor = cm.getCursor();
if (data.from.ch != cursor.ch) {
pos = cm.cursorCoords(cursor);
hints.style.left = (left = pos.left) + "px";
box = hints.getBoundingClientRect();
}
}
}
var overlapX = box.left - winW;
if (overlapX > 0) {
if (box.right - box.left > winW) {
hints.style.width = (winW - 5) + "px";
overlapX -= (box.right - box.left) - winW;
}
hints.style.left = (left = pos.left - overlapX) + "px";
}
if (overlapY > 0) {
var height = box.bottom - box.top;
if (box.top - (pos.bottom - pos.top) - height > 0) {
overlapY = height + (pos.bottom - pos.top);
below = false;
} else if (height > winH) {
hints.style.height = (winH - 5) + "px";
overlapY -= height - winH;
}
hints.style.top = (top = pos.bottom - overlapY) + "px";
}

cm.addKeyMap(this.keyMap = buildKeyMap(options, {
moveFocus: function(n, avoidWrap) { widget.changeActive(widget.selectedHint + n, avoidWrap); },
setFocus: function(n) { widget.changeActive(n); },
menuSize: function() { return widget.screenAmount(); },
length: completions.length,
close: function() { completion.close(); },
pick: function() { widget.pick(); }
pick: function() { widget.pick(); },
data: data
}));

if (options.closeOnUnfocus !== false) {
Expand Down Expand Up @@ -303,15 +309,16 @@
};

CodeMirror.registerHelper("hint", "auto", function(cm, options) {
var helpers = cm.getHelpers(cm.getCursor(), "hint");
var helpers = cm.getHelpers(cm.getCursor(), "hint"), words;
if (helpers.length) {
for (var i = 0; i < helpers.length; i++) {
var cur = helpers[i](cm, options);
if (cur && cur.list.length) return cur;
}
} else {
var words = cm.getHelper(cm.getCursor(), "hintWords");
} else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
if (words) return CodeMirror.hint.fromList(cm, {words: words});
} else if (CodeMirror.hint.anyword) {
return CodeMirror.hint.anyword(cm, options);
}
});

Expand Down
Loading