Showing with 1,144 additions and 270 deletions.
  1. +12 −0 AUTHORS
  2. +3 −3 CONTRIBUTING.md
  3. +1 −1 LICENSE
  4. +1 −1 addon/edit/closebrackets.js
  5. +2 −2 addon/fold/foldgutter.js
  6. +32 −11 addon/search/match-highlighter.js
  7. +1 −3 demo/btree.html
  8. +60 −4 demo/matchhighlighter.html
  9. +2 −2 demo/tern.html
  10. +2 −2 demo/xmlcomplete.html
  11. +3 −1 doc/compress.html
  12. +2 −1 doc/internals.html
  13. +21 −19 doc/manual.html
  14. +3 −1 doc/realworld.html
  15. +12 −1 doc/releases.html
  16. +1 −1 index.html
  17. +15 −12 lib/codemirror.js
  18. +1 −2 mode/asn.1/index.html
  19. +1 −3 mode/clike/clike.js
  20. +8 −3 mode/clojure/clojure.js
  21. +3 −0 mode/clojure/index.html
  22. +14 −13 mode/css/css.js
  23. +2 −2 mode/css/less_test.js
  24. +1 −1 mode/css/scss_test.js
  25. +3 −4 mode/django/django.js
  26. +2 −3 mode/handlebars/index.html
  27. +43 −0 mode/haskell-literate/haskell-literate.js
  28. +282 −0 mode/haskell-literate/index.html
  29. +2 −2 mode/index.html
  30. +3 −3 mode/jade/jade.js
  31. +15 −4 mode/javascript/javascript.js
  32. +4 −0 mode/javascript/test.js
  33. +89 −0 mode/jsx/index.html
  34. +147 −0 mode/jsx/jsx.js
  35. +69 −0 mode/jsx/test.js
  36. +143 −78 mode/julia/julia.js
  37. +1 −1 mode/markdown/markdown.js
  38. +3 −0 mode/meta.js
  39. +2 −2 mode/mumps/index.html
  40. +2 −2 mode/nginx/index.html
  41. +1 −1 mode/nginx/nginx.js
  42. +1 −3 mode/pig/index.html
  43. +1 −1 mode/ruby/ruby.js
  44. +42 −3 mode/swift/swift.js
  45. +1 −1 mode/tiki/tiki.css
  46. +78 −69 mode/xml/xml.js
  47. +1 −1 mode/yaml-frontmatter/yaml-frontmatter.js
  48. +1 −1 package.json
  49. +2 −0 test/index.html
  50. +1 −1 test/mode_test.js
  51. +1 −1 theme/mbo.css
  52. +1 −0 theme/monokai.css
12 changes: 12 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Alex Piggott
Aliaksei Chapyzhenka
Allen Sarkisyan
Amin Shali
Amin Ullah Khan
amshali@google.com
Amsul
amuntean
Expand Down Expand Up @@ -60,6 +61,7 @@ Anthony Grimes
Anton Kovalyov
AQNOUCH Mohammed
areos
Arnab Bose
as3boyan
AtomicPages LLC
Atul Bhouraskar
Expand Down Expand Up @@ -96,6 +98,7 @@ Chandra Sekhar Pydi
Charles Skelton
Cheah Chu Yeow
Chris Coyier
Chris Ford
Chris Granger
Chris Houseknecht
Chris Lohfink
Expand Down Expand Up @@ -135,6 +138,7 @@ David Pathakjee
David Vázquez
deebugger
Deep Thought
Devin Abbott
Devon Carew
dignifiedquire
Dimage Sapelkin
Expand Down Expand Up @@ -177,13 +181,15 @@ Gabriel Horner
Gabriel Nahmias
galambalazs
Gautam Mehta
Gavin Douglas
gekkoe
Gerard Braad
Gergely Hegykozi
Giovanni Calò
Glenn Jorde
Glenn Ruehle
Golevka
Google Inc.
Gordon Smith
Grant Skinner
greengiant
Expand Down Expand Up @@ -398,6 +404,7 @@ noragrossman
Norman Rzepka
Oreoluwa Onatemowo
pablo
pabloferz
Page
Panupong Pasupat
paris
Expand All @@ -416,10 +423,13 @@ Peter Flynn
peterkroon
Peter Kroon
Philip Stadermann
Piët Delport
prasanthj
Prasanth J
Prayag Verma
Radek Piórkowski
Rahul
Rahul Anand
ramwin1
Randall Mason
Randy Burden
Expand Down Expand Up @@ -513,10 +523,12 @@ wenli
Wes Cossick
Wesley Wiser
Will Binns-Smith
Will Dean
William Jamieson
William Stein
Willy
Wojtek Ptak
Wu Cheng-Han
Xavier Mendez
Yassin N. Hassan
YNH Webdev
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# How to contribute

- [Getting help](#getting-help-)
- [Submitting bug reports](#submitting-bug-reports-)
- [Contributing code](#contributing-code-)
- [Getting help](#getting-help)
- [Submitting bug reports](#submitting-bug-reports)
- [Contributing code](#contributing-code)

## Getting help

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 2015 by Marijn Haverbeke <marijnh@gmail.com> and others
Copyright (C) 2016 by Marijn Haverbeke <marijnh@gmail.com> and others

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion addon/edit/closebrackets.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
}
for (var i = ranges.length - 1; i >= 0; i--) {
var cur = ranges[i].head;
cm.replaceRange("", Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1));
cm.replaceRange("", Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1), "+delete");
}
}

Expand Down
4 changes: 2 additions & 2 deletions addon/fold/foldgutter.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
cm.off("viewportChange", onViewportChange);
cm.off("fold", onFold);
cm.off("unfold", onFold);
cm.off("swapDoc", updateInViewport);
cm.off("swapDoc", onChange);
}
if (val) {
cm.state.foldGutter = new State(parseOptions(val));
Expand All @@ -30,7 +30,7 @@
cm.on("viewportChange", onViewportChange);
cm.on("fold", onFold);
cm.on("unfold", onFold);
cm.on("swapDoc", updateInViewport);
cm.on("swapDoc", onChange);
}
});

Expand Down
43 changes: 32 additions & 11 deletions addon/search/match-highlighter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
// highlighted only if the selected text is a word. showToken, when enabled,
// will cause the current token to be highlighted when nothing is selected.
// delay is used to specify how much time to wait, in milliseconds, before
// highlighting the matches.
// highlighting the matches. If annotateScrollbar is enabled, the occurances
// will be highlighted on the scrollbar via the matchesonscrollbar addon.

(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
mod(require("../../lib/codemirror"), require("./matchesonscrollbar"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
define(["../../lib/codemirror", "./matchesonscrollbar"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
Expand All @@ -40,18 +41,19 @@
this.showToken = options.showToken;
this.delay = options.delay;
this.wordsOnly = options.wordsOnly;
this.annotateScrollbar = options.annotateScrollbar;
}
if (this.style == null) this.style = DEFAULT_TOKEN_STYLE;
if (this.minChars == null) this.minChars = DEFAULT_MIN_CHARS;
if (this.delay == null) this.delay = DEFAULT_DELAY;
if (this.wordsOnly == null) this.wordsOnly = DEFAULT_WORDS_ONLY;
this.overlay = this.timeout = null;
this.matchesonscroll = null;
}

CodeMirror.defineOption("highlightSelectionMatches", false, function(cm, val, old) {
if (old && old != CodeMirror.Init) {
var over = cm.state.matchHighlighter.overlay;
if (over) cm.removeOverlay(over);
removeOverlay(cm);
clearTimeout(cm.state.matchHighlighter.timeout);
cm.state.matchHighlighter = null;
cm.off("cursorActivity", cursorActivity);
Expand All @@ -69,28 +71,47 @@
state.timeout = setTimeout(function() {highlightMatches(cm);}, state.delay);
}

function addOverlay(cm, query, hasBoundary, style) {
var state = cm.state.matchHighlighter;
cm.addOverlay(state.overlay = makeOverlay(query, hasBoundary, style));
if (state.annotateScrollbar) {
var searchFor = hasBoundary ? new RegExp("\\b" + query + "\\b") : query;
state.matchesonscroll = cm.showMatchesOnScrollbar(searchFor, true,
{className: "CodeMirror-selection-highlight-scrollbar"});
}
}

function removeOverlay(cm) {
var state = cm.state.matchHighlighter;
if (state.overlay) {
cm.removeOverlay(state.overlay);
state.overlay = null;
if (state.annotateScrollbar) {
state.matchesonscroll.clear();
state.matchesonscroll = null;
}
}
}

function highlightMatches(cm) {
cm.operation(function() {
var state = cm.state.matchHighlighter;
if (state.overlay) {
cm.removeOverlay(state.overlay);
state.overlay = null;
}
removeOverlay(cm);
if (!cm.somethingSelected() && state.showToken) {
var re = state.showToken === true ? /[\w$]/ : state.showToken;
var cur = cm.getCursor(), line = cm.getLine(cur.line), start = cur.ch, end = start;
while (start && re.test(line.charAt(start - 1))) --start;
while (end < line.length && re.test(line.charAt(end))) ++end;
if (start < end)
cm.addOverlay(state.overlay = makeOverlay(line.slice(start, end), re, state.style));
addOverlay(cm, line.slice(start, end), re, state.style);
return;
}
var from = cm.getCursor("from"), to = cm.getCursor("to");
if (from.line != to.line) return;
if (state.wordsOnly && !isWord(cm, from, to)) return;
var selection = cm.getRange(from, to).replace(/^\s+|\s+$/g, "");
if (selection.length >= state.minChars)
cm.addOverlay(state.overlay = makeOverlay(selection, false, state.style));
addOverlay(cm, selection, false, state.style);
});
}

Expand Down
4 changes: 1 addition & 3 deletions demo/btree.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!doctype html>

<title>CodeMirror: B-Tree visualization</title>
<meta charset="utf-8"/>
Expand Down Expand Up @@ -26,9 +26,7 @@
<article>
<h2>B-Tree visualization</h2>
<form><textarea id="code" name="code">type here, see a summary of the document b-tree below</textarea></form>
</div>
<div style="display: inline-block; height: 402px; overflow-y: auto" id="output"></div>
</div>

<script id="me">
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
Expand Down
64 changes: 60 additions & 4 deletions demo/matchhighlighter.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

<link rel="stylesheet" href="../lib/codemirror.css">
<script src="../lib/codemirror.js"></script>
<script src="../addon/scroll/annotatescrollbar.js"></script>
<script src="../addon/search/matchesonscrollbar.js"></script>
<script src="../addon/search/searchcursor.js"></script>
<script src="../addon/search/match-highlighter.js"></script>
<style type="text/css">
Expand All @@ -15,6 +17,8 @@
background-position: bottom;
background-repeat: repeat-x;
}
.cm-matchhighlight {background-color: lightgreen}
.CodeMirror-selection-highlight-scrollbar {background-color: green}
</style>
<div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
Expand All @@ -31,14 +35,66 @@

<article>
<h2>Match Highlighter Demo</h2>
<form><textarea id="code" name="code">Select this text: hardToSpotVar
And everywhere else in your code where hardToSpotVar appears will automatically illuminate.
Give it a try! No more hardToSpotVars.</textarea></form>
<form><textarea id="code" name="code">Select this text: hardtospot
And everywhere else in your code where hardtospot appears will
automatically illuminate. Give it a try! No more hard to spot
variables - stay in context of your code all the time.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut pharetra
interdum dui eu pulvinar. Mauris maximus ligula venenatis tempus
interdum. Cras hendrerit, ipsum sed ultrices pharetra, ligula diam
porttitor lacus, ac tempor eros est a massa. Nam orci elit, vulputate
in tristique quis, consectetur vitae metus. Pellentesque et enim
elementum, lobortis augue in, lacinia sapien. Morbi eu nunc semper,
sagittis felis a, pellentesque mauris. Lorem ipsum dolor sit amet,
consectetur adipiscing elit. Aenean quis diam turpis.

Fusce lobortis nisl quis aliquet euismod. Aenean vitae nulla non ipsum
efficitur scelerisque. Curabitur auctor, lorem non rhoncus porttitor,
augue ligula lacinia dolor, et vehicula magna lorem imperdiet velit.
Fusce risus sem, hardtospot commodo eleifend hendrerit vitae, mollis
quis risus. Cras tincidunt, justo vitae hendrerit venenatis, urna
dolor placerat tortor, eu lobortis lectus dolor in ligula. Nullam non
erat non nisl vulputate ultrices sit amet vestibulum dolor. Quisque in
tortor porta, pellentesque odio nec, malesuada nibh.

In a dui feugiat, ullamcorper urna in, accumsan magna. Donec egestas
sem nec eros rhoncus, vel gravida purus ornare. Nulla orci mauris,
porta nec pharetra sed, ornare et lorem. Donec luctus turpis nunc,
eget dictum felis mollis et. Sed sodales hardtospot nunc vitae leo
rhoncus imperdiet. Donec elementum malesuada velit quis placerat.
Proin accumsan lorem id nisi volutpat ullamcorper. Vivamus laoreet
dolor ac sem malesuada, ac scelerisque ex efficitur. Aliquam tempus
libero velit, vel tristique augue vulputate nec.

Mauris ultrices leo felis, sit amet congue augue aliquam condimentum.
Vivamus purus leo, mattis vitae dignissim vel, ultricies ac ex. Mauris
eu dolor eu purus ultricies ultrices. Sed euismod feugiat ex et
mattis. Morbi cursus laoreet pharetra. Donec eu dolor sodales,
ultricies nisi et, malesuada urna. Praesent sit amet fringilla felis.
Nam rhoncus, est blandit auctor auctor, lorem ipsum laoreet ipsum,
quis sodales libero odio in lorem. Phasellus odio dolor, elementum
sagittis nibh non, fermentum semper libero. Mauris hendrerit
hardtospot lectus sit amet commodo eleifend. Morbi pulvinar eget nisl
at eleifend. Fusce eget porta erat, vitae lobortis libero.

Phasellus sit amet massa in massa pharetra malesuada. Vestibulum at
quam vel libero aliquam volutpat at ut dui. Praesent scelerisque vel
mauris sit amet vehicula. Phasellus at mi nec ligula cursus interdum
sit amet non quam. Aliquam tempus sollicitudin euismod. Nulla euismod
mollis enim tincidunt placerat. Proin ac scelerisque enim, quis
sollicitudin metus. Pellentesque congue nec sapien ut rhoncus. Sed
eget ornare diam, ut consectetur ante. Aenean eleifend mauris quis
ornare accumsan. In hac habitasse hardtospot platea dictumst.

</textarea></form>

<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
highlightSelectionMatches: {showToken: /\w/}
// To highlight on scrollbars as well, pass annotateScrollbar in options
// as below.
highlightSelectionMatches: {showToken: /\w/, annotateScrollbar: true}
});
</script>

Expand Down
4 changes: 2 additions & 2 deletions demo/tern.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!doctype html>

<title>CodeMirror: Tern Demo</title>
<meta charset="utf-8"/>
Expand Down Expand Up @@ -76,7 +76,7 @@ <h2>Tern Demo</h2>

var randomStr = myMod.randomElt(myMod.strList);
var randomInt = myMod.randomElt(myMod.intList);
</textarea></p>
</textarea></form>

<p>Demonstrates integration of <a href="http://ternjs.net/">Tern</a>
and CodeMirror. The following keys are bound:</p>
Expand Down
4 changes: 2 additions & 2 deletions demo/xmlcomplete.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!doctype html>

<title>CodeMirror: XML Autocomplete Demo</title>
<meta charset="utf-8"/>
Expand Down Expand Up @@ -31,7 +31,7 @@ <h2>XML Autocomplete Demo</h2>
<form><textarea id="code" name="code"><!-- write some xml below -->
</textarea></form>

<p>Press <strong>ctrl-space</strong>, or type a '<' character to
<p>Press <strong>ctrl-space</strong>, or type a '&lt;' character to
activate autocompletion. This demo defines a simple schema that
guides completion. The schema can be customized—see
the <a href="../doc/manual.html#addon_xml-hint">manual</a>.</p>
Expand Down
4 changes: 3 additions & 1 deletion 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.11.0;f=">5.11</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.10.0;f=">5.10</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.9.0;f=">5.9</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.8.0;f=">5.8</option>
Expand Down Expand Up @@ -149,6 +150,7 @@ <h2>Script compression helper</h2>
<option value="http://codemirror.net/mode/haml/haml.js">haml.js</option>
<option value="http://codemirror.net/mode/handlebars/handlebars.js">handlebars.js</option>
<option value="http://codemirror.net/mode/haskell/haskell.js">haskell.js</option>
<option value="http://codemirror.net/mode/haskell-literate/haskell-literate.js">haskell-literate.js</option>
<option value="http://codemirror.net/mode/haxe/haxe.js">haxe.js</option>
<option value="http://codemirror.net/mode/htmlembedded/htmlembedded.js">htmlembedded.js</option>
<option value="http://codemirror.net/mode/htmlmixed/htmlmixed.js">htmlmixed.js</option>
Expand All @@ -158,7 +160,7 @@ <h2>Script compression helper</h2>
<option value="http://codemirror.net/mode/javascript/javascript.js">javascript.js</option>
<option value="http://codemirror.net/mode/jinja2/jinja2.js">jinja2.js</option>
<option value="http://codemirror.net/mode/julia/julia.js">julia.js</option>
<option value="http://codemirror.net/mode/livescript/livescript.js">livescript.js</option>
<option value="http://codemirror.net/mode/jsx/jsx.js">jsx.js</option>
<option value="http://codemirror.net/mode/lua/lua.js">lua.js</option>
<option value="http://codemirror.net/mode/markdown/markdown.js">markdown.js</option>
<option value="http://codemirror.net/mode/mathematica/mathematica.js">mathematica.js</option>
Expand Down
3 changes: 2 additions & 1 deletion doc/internals.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!doctype html>

<title>CodeMirror: Internals</title>
<meta charset="utf-8"/>
Expand Down Expand Up @@ -500,4 +500,5 @@ <h2>Keymaps</h2>
is updated <em>during</em> composition. So we poll, whenever the
editor is focused, to provide immediate updates of the display.</p>

</section>
</article>
Loading