Showing with 7,776 additions and 4,042 deletions.
  1. +12 −0 AUTHORS
  2. +24 −4 addon/comment/comment.js
  3. +47 −32 addon/comment/continuecomment.js
  4. +9 −2 addon/dialog/dialog.js
  5. +9 −2 addon/display/fullscreen.js
  6. +9 −2 addon/display/placeholder.js
  7. +9 −2 addon/display/rulers.js
  8. +76 −37 addon/edit/closebrackets.js
  9. +59 −37 addon/edit/closetag.js
  10. +25 −17 addon/edit/continuelist.js
  11. +67 −46 addon/edit/matchbrackets.js
  12. +10 −3 addon/edit/matchtags.js
  13. +23 −14 addon/edit/trailingspace.js
  14. +12 −3 addon/fold/brace-fold.js
  15. +12 −0 addon/fold/comment-fold.js
  16. +28 −3 addon/fold/foldcode.js
  17. +9 −2 addon/fold/foldgutter.js
  18. +12 −1 addon/fold/indent-fold.js
  19. +12 −0 addon/fold/markdown-fold.js
  20. +9 −4 addon/fold/xml-fold.js
  21. +9 −2 addon/hint/anyword-hint.js
  22. +9 −2 addon/hint/css-hint.js
  23. +11 −3 addon/hint/html-hint.js
  24. +9 −4 addon/hint/javascript-hint.js
  25. +11 −3 addon/hint/python-hint.js
  26. +10 −3 addon/hint/show-hint.js
  27. +9 −2 addon/hint/sql-hint.js
  28. +9 −3 addon/hint/xml-hint.js
  29. +12 −1 addon/lint/coffeescript-lint.js
  30. +12 −0 addon/lint/css-lint.js
  31. +9 −3 addon/lint/javascript-lint.js
  32. +12 −1 addon/lint/json-lint.js
  33. +12 −8 addon/lint/lint.js
  34. +12 −1 addon/lint/yaml-lint.js
  35. +9 −2 addon/merge/merge.js
  36. +9 −2 addon/mode/loadmode.js
  37. +12 −0 addon/mode/multiplex.js
  38. +13 −2 addon/mode/overlay.js
  39. +11 −3 addon/runmode/colorize.js
  40. +0 −2 addon/runmode/runmode-standalone.js
  41. +12 −0 addon/runmode/runmode.js
  42. +4 −0 addon/runmode/runmode.node.js
  43. +9 −2 addon/scroll/scrollpastend.js
  44. +12 −3 addon/search/match-highlighter.js
  45. +10 −2 addon/search/search.js
  46. +21 −2 addon/search/searchcursor.js
  47. +38 −17 addon/selection/active-line.js
  48. +16 −9 addon/selection/mark-selection.js
  49. +33 −5 addon/tern/tern.js
  50. +27 −2 addon/wrap/hardwrap.js
  51. +3 −13 bin/source-highlight
  52. +0 −1 demo/btree.html
  53. +19 −30 demo/closebrackets.html
  54. +79 −0 demo/sublime.html
  55. +2 −0 demo/tern.html
  56. +0 −1 demo/theme.html
  57. +13 −4 doc/activebookmark.js
  58. +4 −4 doc/compress.html
  59. +6 −2 doc/docs.css
  60. +387 −128 doc/manual.html
  61. +18 −0 doc/releases.html
  62. +147 −0 doc/upgrade_v4.html
  63. +3 −2 index.html
  64. +12 −5 keymap/emacs.js
  65. +0 −43 keymap/extra.js
  66. +505 −0 keymap/sublime.js
  67. +92 −81 keymap/vim.js
  68. +12 −6 lib/codemirror.css
  69. +2,995 −1,764 lib/codemirror.js
  70. +12 −0 mode/apl/apl.js
  71. +12 −0 mode/asterisk/asterisk.js
  72. +12 −0 mode/clike/clike.js
  73. +13 −0 mode/clojure/clojure.js
  74. +12 −0 mode/cobol/cobol.js
  75. +12 −0 mode/coffeescript/coffeescript.js
  76. +12 −0 mode/commonlisp/commonlisp.js
  77. +12 −4 mode/css/css.js
  78. +12 −2 mode/d/d.js
  79. +12 −0 mode/diff/diff.js
  80. +12 −0 mode/dtd/dtd.js
  81. +12 −0 mode/ecl/ecl.js
  82. +12 −0 mode/eiffel/eiffel.js
  83. +12 −0 mode/erlang/erlang.js
  84. +12 −0 mode/fortran/fortran.js
  85. +12 −0 mode/gas/gas.js
  86. +12 −0 mode/gfm/gfm.js
  87. +12 −0 mode/gherkin/gherkin.js
  88. +12 −0 mode/go/go.js
  89. +12 −0 mode/groovy/groovy.js
  90. +12 −0 mode/haml/haml.js
  91. +12 −0 mode/haskell/haskell.js
  92. +15 −2 mode/haxe/haxe.js
  93. +12 −0 mode/htmlembedded/htmlembedded.js
  94. +12 −0 mode/htmlmixed/htmlmixed.js
  95. +12 −0 mode/http/http.js
  96. +2 −2 mode/index.html
  97. +12 −0 mode/jade/jade.js
  98. +15 −2 mode/javascript/javascript.js
  99. +39 −28 mode/jinja2/jinja2.js
  100. +12 −0 mode/julia/julia.js
  101. +0 −753 mode/less/index.html
  102. +0 −347 mode/less/less.js
  103. +13 −0 mode/livescript/livescript.js
  104. +12 −0 mode/lua/lua.js
  105. +12 −0 mode/markdown/markdown.js
  106. +13 −2 mode/meta.js
  107. +13 −0 mode/mirc/mirc.js
  108. +12 −1 mode/mllike/mllike.js
  109. +12 −0 mode/nginx/nginx.js
  110. +13 −0 mode/ntriples/ntriples.js
  111. +12 −0 mode/octave/octave.js
  112. +12 −0 mode/pascal/pascal.js
  113. +12 −0 mode/pegjs/pegjs.js
  114. +84 −73 mode/perl/perl.js
  115. +11 −2 mode/php/php.js
  116. +12 −0 mode/pig/pig.js
  117. +12 −0 mode/properties/properties.js
  118. +13 −0 mode/puppet/puppet.js
  119. +21 −11 mode/python/python.js
  120. +12 −0 mode/q/q.js
  121. +12 −0 mode/r/r.js
  122. +0 −19 mode/rpm/changes/changes.js
  123. +51 −16 mode/rpm/{spec → }/index.html
  124. +34 −2 mode/rpm/{spec/spec.js → rpm.js}
  125. +0 −5 mode/rpm/spec/spec.css
  126. +12 −0 mode/rst/rst.js
  127. +11 −0 mode/ruby/ruby.js
  128. +12 −0 mode/rust/rust.js
  129. +12 −0 mode/sass/sass.js
  130. +13 −0 mode/scheme/scheme.js
  131. +12 −0 mode/shell/shell.js
  132. +11 −4 mode/sieve/sieve.js
  133. +12 −0 mode/smalltalk/smalltalk.js
  134. +13 −0 mode/smarty/smarty.js
  135. +14 −2 mode/smartymixed/smartymixed.js
  136. +12 −0 mode/solr/solr.js
  137. +12 −0 mode/sparql/sparql.js
  138. +12 −0 mode/sql/sql.js
  139. +12 −0 mode/stex/stex.js
  140. +13 −0 mode/tcl/tcl.js
  141. +13 −0 mode/tiddlywiki/tiddlywiki.js
  142. +12 −0 mode/tiki/tiki.js
  143. +12 −0 mode/toml/toml.js
  144. +12 −0 mode/turtle/turtle.js
  145. +12 −0 mode/vb/vb.js
  146. +13 −0 mode/vbscript/vbscript.js
  147. +12 −0 mode/velocity/velocity.js
  148. +12 −2 mode/verilog/verilog.js
  149. +13 −0 mode/xml/xml.js
  150. +12 −0 mode/xquery/xquery.js
  151. +12 −0 mode/yaml/yaml.js
  152. +12 −0 mode/z80/z80.js
  153. +1 −1 package.json
  154. +19 −0 test/doc_test.js
  155. +20 −13 test/driver.js
  156. +4 −0 test/index.html
  157. +430 −241 test/lint/acorn.js
  158. +32 −10 test/lint/lint.js
  159. +150 −53 test/lint/walk.js
  160. +285 −0 test/multi_test.js
  161. +297 −0 test/sublime_test.js
  162. +248 −58 test/test.js
  163. +14 −3 test/vim_test.js
12 changes: 12 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ List of CodeMirror contributors. Updated before every release.
4r2r
Aaron Brooks
Abe Fettig
Adam Ahmed
Adam King
adanlobato
Adán Lobato
Adrian Aichner
aeroson
Ahmad Amireh
Ahmad M. Zawawi
ahoward
Akeksandr Motsjonov
Alberto González Palomo
Alberto Pose
Albert Xing
Alexander Pavlov
Expand Down Expand Up @@ -46,6 +49,8 @@ Benjamin DeCoste
Ben Keen
Bernhard Sirlinger
Billy Moon
binny
B Krishna Chaitanya
Blaine G
boomyjee
borawjm
Expand Down Expand Up @@ -79,6 +84,7 @@ David Mignot
David Pathakjee
deebugger
Deep Thought
dignifiedquire
domagoj412
Dominator008
Domizio Demichelis
Expand Down Expand Up @@ -106,6 +112,7 @@ ForbesLindesay
Forbes Lindesay
Ford_Lawnmower
Frank Wiegand
Gabriel Horner
Gabriel Nahmias
galambalazs
Gautam Mehta
Expand Down Expand Up @@ -192,6 +199,7 @@ Luciano Longo
lynschinzer
Maksim Lin
Maksym Taran
Malay Majithia
Manuel Rego Casasnovas
Marat Dreizin
Marco Aurélio
Expand Down Expand Up @@ -238,6 +246,7 @@ ndr
nerbert
nextrevision
nguillaumin
Ng Zhi An
Nicholas Bollweg
Niels van Groningen
Nikita Beloglazov
Expand All @@ -246,6 +255,7 @@ Nikolay Kostov
nlwillia
pablo
Page
Patil Arpith
Patrick Strawderman
Paul Garvin
Paul Ivanov
Expand Down Expand Up @@ -283,6 +293,7 @@ Shmuel Englard
soliton4
sonson
spastorelli
srajanpaliwal
Stanislav Oaserele
Stas Kobzar
Stefan Borsje
Expand All @@ -307,6 +318,7 @@ Tom MacWright
Tony Jian
Travis Heppe
Triangle717
twifkak
Vestimir Markov
vf
Volker Mische
Expand Down
28 changes: 24 additions & 4 deletions addon/comment/comment.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
(function() {
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";

var noOptions = {};
Expand All @@ -11,8 +18,21 @@
}

CodeMirror.commands.toggleComment = function(cm) {
var from = cm.getCursor("start"), to = cm.getCursor("end");
cm.uncomment(from, to) || cm.lineComment(from, to);
var minLine = Infinity, ranges = cm.listSelections(), mode = null;
for (var i = ranges.length - 1; i >= 0; i--) {
var from = ranges[i].from(), to = ranges[i].to();
if (from.line >= minLine) continue;
if (to.line >= minLine) to = Pos(minLine, 0);
minLine = from.line;
if (mode == null) {
if (cm.uncomment(from, to)) mode = "un";
else { cm.lineComment(from, to); mode = "line"; }
} else if (mode == "un") {
cm.uncomment(from, to);
} else {
cm.lineComment(from, to);
}
}
};

CodeMirror.defineExtension("lineComment", function(from, to, options) {
Expand Down Expand Up @@ -146,4 +166,4 @@
});
return true;
});
})();
});
79 changes: 47 additions & 32 deletions addon/comment/continuecomment.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,61 @@
(function() {
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
var modes = ["clike", "css", "javascript"];

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

function continueComment(cm) {
var pos = cm.getCursor(), token = cm.getTokenAt(pos);
if (token.type != "comment" || cm.getOption("disableInput")) return CodeMirror.Pass;
var mode = CodeMirror.innerMode(cm.getMode(), token.state).mode;
if (cm.getOption("disableInput")) return CodeMirror.Pass;
var ranges = cm.listSelections(), mode, inserts = [];
for (var i = 0; i < ranges.length; i++) {
var pos = ranges[i].head, token = cm.getTokenAt(pos);
if (token.type != "comment") return CodeMirror.Pass;
var modeHere = CodeMirror.innerMode(cm.getMode(), token.state).mode;
if (!mode) mode = modeHere;
else if (mode != modeHere) return CodeMirror.Pass;

var insert;
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 && pos.ch >= end) {
// Comment ended, don't continue it
} else if (token.string.indexOf(mode.blockCommentStart) == 0) {
insert = full.slice(0, token.start);
if (!/^\s*$/.test(insert)) {
insert = "";
for (var i = 0; i < token.start; ++i) insert += " ";
var insert = null;
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 && pos.ch >= end) {
// Comment ended, don't continue it
} else if (token.string.indexOf(mode.blockCommentStart) == 0) {
insert = full.slice(0, token.start);
if (!/^\s*$/.test(insert)) {
insert = "";
for (var j = 0; j < token.start; ++j) insert += " ";
}
} else if ((found = full.indexOf(mode.blockCommentContinue)) != -1 &&
found + mode.blockCommentContinue.length > token.start &&
/^\s*$/.test(full.slice(0, found))) {
insert = full.slice(0, found);
}
} else if ((found = full.indexOf(mode.blockCommentContinue)) != -1 &&
found + mode.blockCommentContinue.length > token.start &&
/^\s*$/.test(full.slice(0, found))) {
insert = full.slice(0, found);
if (insert != null) insert += mode.blockCommentContinue;
}
if (insert != null) insert += mode.blockCommentContinue;
}
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);
if (/\S/.test(insert)) insert = null;
else insert += mode.lineComment + line.slice(found + mode.lineComment.length).match(/^\s*/)[0];
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);
if (/\S/.test(insert)) insert = null;
else insert += mode.lineComment + line.slice(found + mode.lineComment.length).match(/^\s*/)[0];
}
}
if (insert == null) return CodeMirror.Pass;
inserts[i] = "\n" + insert;
}

if (insert != null)
cm.replaceSelection("\n" + insert, "end");
else
return CodeMirror.Pass;
cm.operation(function() {
for (var i = ranges.length - 1; i >= 0; i--)
cm.replaceRange(inserts[i], ranges[i].from(), ranges[i].to(), "+insert");
});
}

function continueLineCommentEnabled(cm) {
Expand All @@ -64,4 +79,4 @@
cm.addKeyMap(map);
}
});
})();
});
11 changes: 9 additions & 2 deletions addon/dialog/dialog.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
// Open simple dialogs on top of an editor. Relies on dialog.css.

(function() {
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
function dialogDiv(cm, template, bottom) {
var wrap = cm.getWrapperElement();
var dialog;
Expand Down Expand Up @@ -120,4 +127,4 @@
if (duration)
doneTimer = setTimeout(close, options.duration);
});
})();
});
11 changes: 9 additions & 2 deletions addon/display/fullscreen.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
(function() {
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";

CodeMirror.defineOption("fullScreen", false, function(cm, val, old) {
Expand Down Expand Up @@ -28,4 +35,4 @@
window.scrollTo(info.scrollLeft, info.scrollTop);
cm.refresh();
}
})();
});
11 changes: 9 additions & 2 deletions addon/display/placeholder.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
(function() {
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
CodeMirror.defineOption("placeholder", "", function(cm, val, old) {
var prev = old && old != CodeMirror.Init;
if (val && !prev) {
Expand Down Expand Up @@ -45,4 +52,4 @@
function isEmpty(cm) {
return (cm.lineCount() === 1) && (cm.getLine(0) === "");
}
})();
});
11 changes: 9 additions & 2 deletions addon/display/rulers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
(function() {
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";

CodeMirror.defineOption("rulers", false, function(cm, val, old) {
Expand Down Expand Up @@ -44,4 +51,4 @@
clearRulers(cm);
setRulers(cm);
}
})();
});
Loading