Showing with 1,046 additions and 1,335 deletions.
  1. +1 −0 .npmignore
  2. +10 −0 AUTHORS
  3. +2 −1 README.md
  4. +47 −0 addon/display/autorefresh.js
  5. +6 −3 addon/edit/closetag.js
  6. +1 −1 addon/hint/anyword-hint.js
  7. +46 −0 addon/lint/html-lint.js
  8. +8 −2 addon/lint/lint.js
  9. +2 −2 addon/merge/merge.js
  10. +11 −0 addon/search/search.js
  11. +6 −5 addon/tern/tern.js
  12. +2 −0 demo/theme.html
  13. +1 −0 doc/compress.html
  14. +23 −3 doc/manual.html
  15. +2 −1 doc/realworld.html
  16. +14 −0 doc/releases.html
  17. +1 −1 index.html
  18. +12 −10 lib/codemirror.css
  19. +54 −20 lib/codemirror.js
  20. +26 −10 mode/css/css.js
  21. +6 −0 mode/css/test.js
  22. +2 −2 mode/cypher/cypher.js
  23. +4 −1 mode/dockerfile/dockerfile.js
  24. +1 −1 mode/go/go.js
  25. +1 −6 mode/javascript/javascript.js
  26. +0 −7 mode/javascript/test.js
  27. +1 −0 mode/meta.js
  28. +6 −5 mode/php/php.js
  29. +13 −9 mode/rust/index.html
  30. +39 −432 mode/rust/rust.js
  31. +40 −0 mode/rust/test.js
  32. +10 −9 mode/stylus/stylus.js
  33. +1 −1 package.json
  34. +3 −0 test/index.html
  35. +20 −20 theme/3024-day.css
  36. +20 −20 theme/3024-night.css
  37. +32 −0 theme/abcdef.css
  38. +7 −9 theme/ambiance.css
  39. +24 −24 theme/base16-dark.css
  40. +24 −24 theme/base16-light.css
  41. +5 −5 theme/blackboard.css
  42. +4 −4 theme/cobalt.css
  43. +3 −3 theme/colorforth.css
  44. +25 −71 theme/dracula.css
  45. +21 −21 theme/eclipse.css
  46. +12 −12 theme/elegant.css
  47. +4 −4 theme/erlang-dark.css
  48. +29 −29 theme/icecoder.css
  49. +14 −14 theme/lesser-dark.css
  50. +5 −5 theme/liquibyte.css
  51. +28 −80 theme/material.css
  52. +23 −23 theme/mbo.css
  53. +6 −6 theme/mdn-like.css
  54. +22 −24 theme/midnight.css
  55. +21 −21 theme/monokai.css
  56. +3 −3 theme/neat.css
  57. +7 −7 theme/neo.css
  58. +4 −4 theme/night.css
  59. +24 −24 theme/paraiso-dark.css
  60. +24 −24 theme/paraiso-light.css
  61. +3 −3 theme/pastel-on-dark.css
  62. +3 −3 theme/rubyblue.css
  63. +25 −69 theme/seti.css
  64. +7 −9 theme/solarized.css
  65. +21 −21 theme/the-matrix.css
  66. +24 −24 theme/tomorrow-night-bright.css
  67. +24 −24 theme/tomorrow-night-eighties.css
  68. +45 −46 theme/ttcn.css
  69. +7 −7 theme/twilight.css
  70. +9 −9 theme/vibrant-ink.css
  71. +20 −20 theme/xq-dark.css
  72. +18 −18 theme/xq-light.css
  73. +24 −66 theme/yeti.css
  74. +3 −3 theme/zenburn.css
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/demo
/doc
/test
/test*.html
/index.html
/mode/*/*test.js
/mode/*/*.html
Expand Down
10 changes: 10 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Alexandre Bique
alexey-k
Alex Piggott
Aliaksei Chapyzhenka
Allen Sarkisyan
Amin Shali
Amsul
amuntean
Expand All @@ -34,8 +35,10 @@ anaran
AndersMad
Anders Nawroth
Anderson Mesquita
Anders Wåglund
Andrea G
Andreas Reischuck
Andres Taylor
Andre von Houck
Andrey Fedorov
Andrey Klyuchnikov
Expand Down Expand Up @@ -299,6 +302,7 @@ Mason Malone
Mateusz Paprocki
Mathias Bynens
mats cronqvist
Matt Gaide
Matthew Beale
Matthew Rathbone
Matthias Bussonnier
Expand All @@ -315,6 +319,7 @@ Max Xiantu
mbarkhau
Metatheos
Micah Dubinko
Michael
Michael Grey
Michael Kaminsky
Michael Lehenbauer
Expand Down Expand Up @@ -377,6 +382,7 @@ peteguhl
Peter Flynn
peterkroon
Peter Kroon
Philip Stadermann
prasanthj
Prasanth J
Radek Piórkowski
Expand All @@ -387,6 +393,7 @@ Randy Edmunds
Rasmus Erik Voel Jensen
ray ratchup
Ray Ratchup
Richard Denton
Richard van der Meer
Richard Z.H. Wang
Robert Crossfield
Expand All @@ -409,9 +416,11 @@ SCLINIC\jdecker
Scott Aikin
Scott Goodhew
Sebastian Zaha
Se-Won Kim
shaund
shaun gilchrist
Shawn A
Shea Bunge
sheopory
Shiv Deepak
Shmuel Englard
Expand All @@ -435,6 +444,7 @@ Tarmil
tel
tfjgeorge
Thaddee Tyl
thanasis
TheHowl
think
Thomas Dvornik
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CodeMirror
[![Build Status](https://travis-ci.org/codemirror/CodeMirror.svg)](https://travis-ci.org/codemirror/CodeMirror)
[![NPM version](https://img.shields.io/npm/v/codemirror.svg)](https://www.npmjs.org/package/codemirror)
[![NPM version](https://img.shields.io/npm/v/codemirror.svg)](https://www.npmjs.org/package/codemirror)
[![Join the chat at https://gitter.im/codemirror/CodeMirror](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/codemirror/CodeMirror)
[Funding status: ![maintainer happiness](https://marijnhaverbeke.nl/fund/status_s.png?again)](https://marijnhaverbeke.nl/fund/)

CodeMirror is a versatile text editor implemented in JavaScript for
Expand Down
47 changes: 47 additions & 0 deletions addon/display/autorefresh.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE

(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("autoRefresh", false, function(cm, val) {
if (cm.state.autoRefresh) {
stopListening(cm, cm.state.autoRefresh)
cm.state.autoRefresh = null
}
if (val && cm.display.wrapper.offsetHeight == 0)
startListening(cm, cm.state.autoRefresh = {delay: val.delay || 250})
})

function startListening(cm, state) {
function check() {
if (cm.display.wrapper.offsetHeight) {
stopListening(cm, state)
if (cm.display.lastWrapHeight != cm.display.wrapper.clientHeight)
cm.refresh()
} else {
state.timeout = setTimeout(check, state.delay)
}
}
state.timeout = setTimeout(check, state.delay)
state.hurry = function() {
clearTimeout(state.timeout)
state.timeout = setTimeout(check, 50)
}
CodeMirror.on(window, "mouseup", state.hurry)
CodeMirror.on(window, "keyup", state.hurry)
}

function stopListening(_cm, state) {
clearTimeout(state.timeout)
CodeMirror.off(window, "mouseup", state.hurry)
CodeMirror.off(window, "keyup", state.hurry)
}
});
9 changes: 6 additions & 3 deletions addon/edit/closetag.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,22 @@
// when completing in JS/CSS snippet in htmlmixed mode. Does not
// work for other XML embedded languages (there is no general
// way to go from a mixed mode to its current XML state).
var replacement;
if (inner.mode.name != "xml") {
if (cm.getMode().name == "htmlmixed" && inner.mode.name == "javascript")
replacements[i] = head + "script>";
replacement = head + "script";
else if (cm.getMode().name == "htmlmixed" && inner.mode.name == "css")
replacements[i] = head + "style>";
replacement = head + "style";
else
return CodeMirror.Pass;
} else {
if (!state.context || !state.context.tagName ||
closingTagExists(cm, state.context.tagName, pos, state))
return CodeMirror.Pass;
replacements[i] = head + state.context.tagName + ">";
replacement = head + state.context.tagName;
}
if (cm.getLine(pos.line).charAt(tok.end) != ">") replacement += ">";
replacements[i] = replacement;
}
cm.replaceSelections(replacements);
ranges = cm.listSelections();
Expand Down
2 changes: 1 addition & 1 deletion addon/hint/anyword-hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
while (start && word.test(curLine.charAt(start - 1))) --start;
var curWord = start != end && curLine.slice(start, end);

var list = [], seen = {};
var list = options && options.list || [], seen = {};
var re = new RegExp(word.source, "g");
for (var dir = -1; dir <= 1; dir += 2) {
var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir;
Expand Down
46 changes: 46 additions & 0 deletions addon/lint/html-lint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE

// Depends on htmlhint.js from http://htmlhint.com/js/htmlhint.js

// declare global: HTMLHint

(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"), require("htmlhint"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror", "htmlhint"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";

var defaultRules = {
"tagname-lowercase": true,
"attr-lowercase": true,
"attr-value-double-quotes": true,
"doctype-first": false,
"tag-pair": true,
"spec-char-escape": true,
"id-unique": true,
"src-not-empty": true,
"attr-no-duplication": true
};

CodeMirror.registerHelper("lint", "html", function(text, options) {
var found = [];
if (!window.HTMLHint) return found;
var messages = HTMLHint.verify(text, options && options.rules || defaultRules);
for (var i = 0; i < messages.length; i++) {
var message = messages[i];
var startLine = message.line - 1, endLine = message.line - 1, startCol = message.col - 1, endCol = message.col;
found.push({
from: CodeMirror.Pos(startLine, startCol),
to: CodeMirror.Pos(endLine, endCol),
message: message.message,
severity : message.type
});
}
return found;
});
});
10 changes: 8 additions & 2 deletions addon/lint/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@
CodeMirror.defineOption("lint", false, function(cm, val, old) {
if (old && old != CodeMirror.Init) {
clearMarks(cm);
cm.off("change", onChange);
if (cm.state.lint.options.lintOnChange !== false)
cm.off("change", onChange);
CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver);
clearTimeout(cm.state.lint.timeout);
delete cm.state.lint;
Expand All @@ -197,11 +198,16 @@
var gutters = cm.getOption("gutters"), hasLintGutter = false;
for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true;
var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter);
cm.on("change", onChange);
if (state.options.lintOnChange !== false)
cm.on("change", onChange);
if (state.options.tooltips != false)
CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);

startLinting(cm);
}
});

CodeMirror.defineExtension("performLint", function() {
if (this.state.lint) startLinting(this);
});
});
4 changes: 2 additions & 2 deletions addon/merge/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror", "diff_match_patch"], mod);
else // Plain browser env
mod(CodeMirror, diff_match_patch);
})(function(CodeMirror, diff_match_patch) {
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
var Pos = CodeMirror.Pos;
var svgNS = "http://www.w3.org/2000/svg";
Expand Down
11 changes: 11 additions & 0 deletions addon/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,21 @@
else if (confirm(shortText)) fs[0]();
}

function parseString(string) {
return string.replace(/\\(.)/g, function(_, ch) {
if (ch == "n") return "\n"
if (ch == "r") return "\r"
return ch
})
}

function parseQuery(query) {
var isRE = query.match(/^\/(.*)\/([a-z]*)$/);
if (isRE) {
try { query = new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i"); }
catch(e) {} // Not a regular expression after all, do a string search
} else {
query = parseString(query)
}
if (typeof query == "string" ? query == "" : query.test(""))
query = /x^/;
Expand Down Expand Up @@ -157,6 +167,7 @@
if (!query) return;
query = parseQuery(query);
dialog(cm, replacementQueryDialog, "Replace with:", "", function(text) {
text = parseString(text)
if (all) {
cm.operation(function() {
for (var cursor = getSearchCursor(cm, query); cursor.findNext();) {
Expand Down
11 changes: 6 additions & 5 deletions addon/tern/tern.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
child.target = "_blank";
}
}
tempTooltip(cm, tip);
tempTooltip(cm, tip, ts);
if (c) c();
}, pos);
}
Expand Down Expand Up @@ -466,11 +466,12 @@
ts.request(cm, {type: "refs"}, function(error, data) {
if (error) return showError(ts, cm, error);
var ranges = [], cur = 0;
var curPos = cm.getCursor();
for (var i = 0; i < data.refs.length; i++) {
var ref = data.refs[i];
if (ref.file == name) {
ranges.push({anchor: ref.start, head: ref.end});
if (cmpPos(cur, ref.start) >= 0 && cmpPos(cur, ref.end) <= 0)
if (cmpPos(curPos, ref.start) >= 0 && cmpPos(curPos, ref.end) <= 0)
cur = ranges.length - 1;
}
}
Expand Down Expand Up @@ -592,7 +593,7 @@

// Tooltips

function tempTooltip(cm, content) {
function tempTooltip(cm, content, ts) {
if (cm.state.ternTooltip) remove(cm.state.ternTooltip);
var where = cm.cursorCoords();
var tip = cm.state.ternTooltip = makeTooltip(where.right + 1, where.bottom, content);
Expand All @@ -616,7 +617,7 @@
else mouseOnTip = false;
}
});
setTimeout(maybeClear, 1700);
setTimeout(maybeClear, ts.options.hintDelay ? ts.options.hintDelay : 1700);
cm.on("cursorActivity", clear);
cm.on('blur', clear);
cm.on('scroll', clear);
Expand Down Expand Up @@ -644,7 +645,7 @@
if (ts.options.showError)
ts.options.showError(cm, msg);
else
tempTooltip(cm, String(msg));
tempTooltip(cm, String(msg), ts);
}

function closeArgHints(ts) {
Expand Down
2 changes: 2 additions & 0 deletions demo/theme.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<link rel="stylesheet" href="../lib/codemirror.css">
<link rel="stylesheet" href="../theme/3024-day.css">
<link rel="stylesheet" href="../theme/3024-night.css">
<link rel="stylesheet" href="../theme/abcdef.css">
<link rel="stylesheet" href="../theme/ambiance.css">
<link rel="stylesheet" href="../theme/base16-dark.css">
<link rel="stylesheet" href="../theme/base16-light.css">
Expand Down Expand Up @@ -84,6 +85,7 @@ <h2>Theme Demo</h2>
<option selected>default</option>
<option>3024-day</option>
<option>3024-night</option>
<option>abcdef</option>
<option>ambiance</option>
<option>base16-dark</option>
<option>base16-light</option>
Expand Down
1 change: 1 addition & 0 deletions doc/compress.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ <h2>Script compression helper</h2>
<input type="hidden" id="download" name="download" value="codemirror-compressed.js"/>
<p>Version: <select id="version" onchange="setVersion(this);" style="padding: 1px;">
<option value="http://codemirror.net/">HEAD</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.6.0;f=">5.6</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.5.0;f=">5.5</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.4.0;f=">5.4</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.3.0;f=">5.3</option>
Expand Down
Loading