Showing with 1,434 additions and 289 deletions.
  1. +11 −1 AUTHORS
  2. +3 −3 CONTRIBUTING.md
  3. +0 −4 LICENSE
  4. +25 −15 addon/comment/continuecomment.js
  5. +1 −1 addon/display/fullscreen.css
  6. +28 −27 addon/edit/closetag.js
  7. +10 −5 addon/edit/matchtags.js
  8. +50 −0 addon/hint/css-hint.js
  9. +10 −7 addon/hint/show-hint.js
  10. +17 −0 addon/lint/css-lint.js
  11. +3 −27 addon/lint/lint.css
  12. +1 −1 addon/lint/lint.js
  13. +32 −6 addon/merge/merge.js
  14. +1 −1 addon/runmode/runmode-standalone.js
  15. +1 −1 addon/runmode/runmode.js
  16. +1 −1 addon/runmode/runmode.node.js
  17. +2 −2 addon/search/searchcursor.js
  18. +29 −6 addon/tern/tern.js
  19. +3 −2 bin/lint
  20. +1 −1 bower.json
  21. +1 −1 demo/complete.html
  22. +70 −0 demo/lint.html
  23. +3 −19 demo/marker.html
  24. +3 −3 demo/markselection.html
  25. +1 −1 demo/matchtags.html
  26. +8 −4 demo/merge.html
  27. +1 −1 demo/spanaffectswrapping_shim.html
  28. +7 −0 doc/compress.html
  29. +1 −0 doc/docs.css
  30. +27 −1 doc/manual.html
  31. +3 −0 doc/realworld.html
  32. +9 −0 doc/releases.html
  33. +6 −2 index.html
  34. +13 −0 keymap/vim.js
  35. +7 −3 lib/codemirror.css
  36. +104 −46 lib/codemirror.js
  37. +1 −1 mode/coffeescript/coffeescript.js
  38. +15 −13 mode/css/css.js
  39. 0 mode/d/d.js
  40. 0 mode/d/index.html
  41. +127 −0 mode/dtd/dtd.js
  42. +89 −0 mode/dtd/index.html
  43. +173 −0 mode/fortran/fortran.js
  44. +81 −0 mode/fortran/index.html
  45. +5 −1 mode/haskell/haskell.js
  46. +4 −0 mode/index.html
  47. +47 −49 mode/less/less.js
  48. +6 −0 mode/meta.js
  49. +95 −0 mode/octave/index.html
  50. +118 −0 mode/octave/octave.js
  51. +8 −5 mode/sql/sql.js
  52. +73 −0 mode/toml/index.html
  53. +71 −0 mode/toml/toml.js
  54. +1 −1 package.json
  55. +25 −3 test/test.js
  56. +2 −24 theme/solarized.css
12 changes: 11 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ alexey-k
Alex Piggott
Amy
Ananya Sen
AndersMad
Andre von Houck
Andrey Lushnikov
Andy Kimball
Expand All @@ -36,6 +37,7 @@ Ben Keen
boomyjee
borawjm
Brandon Frohs
Brett Zamir
Brian Sletten
Bruce Mitchener
Chandra Sekhar Pydi
Expand All @@ -44,6 +46,7 @@ Chris Coyier
Chris Granger
Chris Morgan
Christopher Brown
ciaranj
CodeAnimal
ComFreek
dagsta
Expand Down Expand Up @@ -76,6 +79,7 @@ Felipe Lalanne
Felix Raab
Filip Noetzel
flack
ForbesLindesay
Ford_Lawnmower
Gabriel Nahmias
galambalazs
Expand All @@ -85,6 +89,7 @@ Golevka
Gordon Smith
greengiant
Guillaume Massé
Guillaume Massé
Hans Engel
Hardest
Hasan Karahan
Expand Down Expand Up @@ -137,11 +142,11 @@ komakino
Konstantin Lopuhin
koops
ks-ifware
kubelsmieci
Lanny
leaf corcoran
Leonya Khachaturov
Liam Newman
List of contributors. Updated before every release.
LM
Lorenzo Stoakes
lynschinzer
Expand All @@ -152,6 +157,8 @@ Marco Aurélio
Marijn Haverbeke
Mario Pietsch
Mark Lentczner
Martin Balek
Martín Gaitán
Mason Malone
Mateusz Paprocki
mats cronqvist
Expand Down Expand Up @@ -220,6 +227,7 @@ Stas Kobzar
Stefan Borsje
Steffen Beyer
Steve O'Hara
stoskov
Tarmil
tfjgeorge
Thaddee Tyl
Expand All @@ -229,6 +237,8 @@ Thomas Schmid
Tim Baumann
Timothy Farrell
Timothy Hatcher
TobiasBg
Tomas-A
Tomas Varaneckas
Tom Erik Støwer
Tom MacWright
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
- [Submitting bug reports](#submitting-bug-reports-)
- [Contributing code](#contributing-code-)

## Getting help [^](#how-to-contribute)
## Getting help

Community discussion, questions, and informal bug reporting is done on the
[CodeMirror Google group](http://groups.google.com/group/codemirror).

## Submitting bug reports [^](#how-to-contribute)
## Submitting bug reports

The preferred way to report bugs is to use the
[GitHub issue tracker](http://github.com/marijnh/CodeMirror/issues). Before
Expand Down Expand Up @@ -45,7 +45,7 @@ should be asked on the
[jsbin.com](http://jsbin.com/ihunin/edit), enter it there, press save, and
include the resulting link in your bug report.

## Contributing code [^](#how-to-contribute)
## Contributing code

- Make sure you have a [GitHub Account](https://github.com/signup/free)
- Fork [CodeMirror](https://github.com/marijnh/CodeMirror/)
Expand Down
4 changes: 0 additions & 4 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Please note that some subdirectories of the CodeMirror distribution
include their own LICENSE files, and are released under different
licences.
40 changes: 25 additions & 15 deletions addon/comment/continuecomment.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,54 @@
(function() {
var modes = ["clike", "css", "javascript"];
for (var i = 0; i < modes.length; ++i)
CodeMirror.extendMode(modes[i], {blockCommentStart: "/*",
blockCommentEnd: "*/",
blockCommentContinue: " * "});
CodeMirror.extendMode(modes[i], {blockCommentContinue: " * "});

function continueComment(cm) {
var pos = cm.getCursor(), token = cm.getTokenAt(pos);
if (token.type != "comment") return CodeMirror.Pass;
var mode = CodeMirror.innerMode(cm.getMode(), token.state).mode;
var space;

if (token.type == "comment" && mode.blockCommentStart && mode.blockCommentContinue) {
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) {
// Comment ended, don't continue it
} else if (token.string.indexOf(mode.blockCommentStart) == 0) {
space = full.slice(0, token.start);
if (!/^\s*$/.test(space)) {
space = "";
for (var i = 0; i < token.start; ++i) space += " ";
insert = full.slice(0, token.start);
if (!/^\s*$/.test(insert)) {
insert = "";
for (var i = 0; i < token.start; ++i) insert += " ";
}
} else if ((found = full.indexOf(mode.blockCommentContinue)) != -1 &&
found + mode.blockCommentContinue.length > token.start &&
/^\s*$/.test(full.slice(0, found))) {
space = full.slice(0, found);
insert = full.slice(0, found);
}
if (insert != null) insert += mode.blockCommentContinue;
}
if (insert == null && mode.lineComment) {
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 (space != null)
cm.replaceSelection("\n" + space + mode.blockCommentContinue, "end");
if (insert != null)
cm.replaceSelection("\n" + insert, "end");
else
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);
if (val) {
var map = {name: "continueComment"};
map[typeof val == "string" ? val : "Enter"] = continueComment;
cm.addKeyMap(map);
}
});
})();
2 changes: 1 addition & 1 deletion addon/display/fullscreen.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
height: auto;
z-index: 9999;
z-index: 9;
}
55 changes: 28 additions & 27 deletions addon/edit/closetag.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
if (val && (old == CodeMirror.Init || !old)) {
var map = {name: "autoCloseTags"};
if (typeof val != "object" || val.whenClosing)
map["'/'"] = function(cm) { return autoCloseTag(cm, '/'); };
map["'/'"] = function(cm) { return autoCloseSlash(cm); };
if (typeof val != "object" || val.whenOpening)
map["'>'"] = function(cm) { return autoCloseTag(cm, '>'); };
map["'>'"] = function(cm) { return autoCloseGT(cm); };
cm.addKeyMap(map);
} else if (!val && (old != CodeMirror.Init && old)) {
cm.removeKeyMap("autoCloseTags");
Expand All @@ -41,40 +41,41 @@
var htmlIndent = ["applet", "blockquote", "body", "button", "div", "dl", "fieldset", "form", "frameset", "h1", "h2", "h3", "h4",
"h5", "h6", "head", "html", "iframe", "layer", "legend", "object", "ol", "p", "select", "table", "ul"];

function autoCloseTag(cm, ch) {
function autoCloseGT(cm) {
var pos = cm.getCursor(), tok = cm.getTokenAt(pos);
var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state;
if (inner.mode.name != "xml") return CodeMirror.Pass;
if (inner.mode.name != "xml" || !state.tagName) return CodeMirror.Pass;

var opt = cm.getOption("autoCloseTags"), html = inner.mode.configuration == "html";
var dontCloseTags = (typeof opt == "object" && opt.dontCloseTags) || (html && htmlDontClose);
var indentTags = (typeof opt == "object" && opt.indentTags) || (html && htmlIndent);

if (ch == ">" && state.tagName) {
var tagName = state.tagName;
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" ||
tok.string.indexOf("/") == (tok.string.length - 1) || // match something like <someTagName />
dontCloseTags && indexOf(dontCloseTags, lowerTagName) > -1)
return CodeMirror.Pass;
var tagName = state.tagName;
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" ||
tok.string.indexOf("/") == (tok.string.length - 1) || // match something like <someTagName />
dontCloseTags && indexOf(dontCloseTags, lowerTagName) > -1)
return CodeMirror.Pass;

var doIndent = indentTags && indexOf(indentTags, lowerTagName) > -1;
var curPos = doIndent ? CodeMirror.Pos(pos.line + 1, 0) : CodeMirror.Pos(pos.line, pos.ch + 1);
cm.replaceSelection(">" + (doIndent ? "\n\n" : "") + "</" + tagName + ">",
{head: curPos, anchor: curPos});
if (doIndent) {
cm.indentLine(pos.line + 1);
cm.indentLine(pos.line + 2);
}
return;
} else if (ch == "/" && tok.string == "<") {
var tagName = state.context && state.context.tagName;
if (tagName) cm.replaceSelection("/" + tagName + ">", "end");
return;
var doIndent = indentTags && indexOf(indentTags, lowerTagName) > -1;
var curPos = doIndent ? CodeMirror.Pos(pos.line + 1, 0) : CodeMirror.Pos(pos.line, pos.ch + 1);
cm.replaceSelection(">" + (doIndent ? "\n\n" : "") + "</" + tagName + ">",
{head: curPos, anchor: curPos});
if (doIndent) {
cm.indentLine(pos.line + 1);
cm.indentLine(pos.line + 2);
}
return CodeMirror.Pass;
}

function autoCloseSlash(cm) {
var pos = cm.getCursor(), tok = cm.getTokenAt(pos);
var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state;
if (tok.string.charAt(0) != "<" || inner.mode.name != "xml") return CodeMirror.Pass;

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

function indexOf(collection, elt) {
Expand Down
15 changes: 10 additions & 5 deletions addon/edit/matchtags.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,35 @@
clear(cm);
}
if (val) {
cm.state.matchBothTags = typeof val == "object" && val.bothTags;
cm.on("cursorActivity", doMatchTags);
cm.on("viewportChange", maybeUpdateMatch);
doMatchTags(cm);
}
});

function clear(cm) {
if (cm.state.matchedTag) {
cm.state.matchedTag.clear();
cm.state.matchedTag = null;
}
if (cm.state.tagHit) cm.state.tagHit.clear();
if (cm.state.tagOther) cm.state.tagOther.clear();
cm.state.tagHit = cm.state.tagOther = null;
}

function doMatchTags(cm) {
cm.state.failedTagMatch = false;
cm.operation(function() {
clear(cm);
if (cm.somethingSelected()) return;
var cur = cm.getCursor(), range = cm.getViewport();
range.from = Math.min(range.from, cur.line); range.to = Math.max(cur.line + 1, range.to);
var match = CodeMirror.findMatchingTag(cm, cur, range);
if (!match) return;
if (cm.state.matchBothTags) {
var hit = match.at == "open" ? match.open : match.close;
if (hit) cm.state.tagHit = cm.markText(hit.from, hit.to, {className: "CodeMirror-matchingtag"});
}
var other = match.at == "close" ? match.open : match.close;
if (other)
cm.state.matchedTag = cm.markText(other.from, other.to, {className: "CodeMirror-matchingtag"});
cm.state.tagOther = cm.markText(other.from, other.to, {className: "CodeMirror-matchingtag"});
else
cm.state.failedTagMatch = true;
});
Expand Down
50 changes: 50 additions & 0 deletions addon/hint/css-hint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
(function () {
"use strict";

function getHints(cm) {
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
var inner = CodeMirror.innerMode(cm.getMode(), token.state);
if (inner.mode.name != "css") return;

// If it's not a 'word-style' token, ignore the token.
if (!/^[\w$_-]*$/.test(token.string)) {
token = {
start: cur.ch, end: cur.ch, string: "", state: token.state,
type: null
};
var stack = token.state.stack;
var lastToken = stack && stack.length > 0 ? stack[stack.length - 1] : "";
if (token.string == ":" || lastToken.indexOf("property") == 0)
token.type = "variable";
else if (token.string == "{" || lastToken.indexOf("rule") == 0)
token.type = "property";
}

if (!token.type)
return;

var spec = CodeMirror.resolveMode("text/css");
var keywords = null;
if (token.type.indexOf("property") == 0)
keywords = spec.propertyKeywords;
else if (token.type.indexOf("variable") == 0)
keywords = spec.valueKeywords;

if (!keywords)
return;

var result = [];
for (var name in keywords) {
if (name.indexOf(token.string) == 0 /* > -1 */)
result.push(name);
}

return {
list: result,
from: CodeMirror.Pos(cur.line, token.start),
to: CodeMirror.Pos(cur.line, token.end)
};
}

CodeMirror.registerHelper("hint", "css", getHints);
})();
Loading