diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000000..67fd2fdcb0 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,244 @@ +List of CodeMirror contributors. Updated before every release. + +4r2r +Aaron Brooks +Adam King +adanlobato +Adán Lobato +aeroson +Ahmad Amireh +Ahmad M. Zawawi +ahoward +Akeksandr Motsjonov +Albert Xing +Alexander Pavlov +Alexander Schepanovski +alexey-k +Alex Piggott +Amy +Ananya Sen +Andre von Houck +Andrey Lushnikov +Andy Kimball +Andy Li +angelozerr +angelo.zerr@gmail.com +Ankit Ahuja +Ansel Santosa +Anthony Grimes +areos +Atul Bhouraskar +Aurelian Oancea +Bastian Müller +benbro +Benjamin DeCoste +Ben Keen +boomyjee +borawjm +Brandon Frohs +Brian Sletten +Bruce Mitchener +Chandra Sekhar Pydi +Charles Skelton +Chris Coyier +Chris Granger +Chris Morgan +Christopher Brown +CodeAnimal +ComFreek +dagsta +Dan Heberden +Daniel, Dao Quang Minh +Daniel Faust +Daniel Huigens +Daniel Neel +Daniel Parnell +Danny Yoo +David Mignot +David Pathakjee +deebugger +Deep Thought +Dominator008 +Domizio Demichelis +Drew Bratcher +Drew Hintz +Drew Khoury +Dror BG +duralog +edsharp +ekhaled +Eric Allam +eustas +Fauntleroy +fbuchinger +feizhang365 +Felipe Lalanne +Felix Raab +Filip Noetzel +flack +Ford_Lawnmower +Gabriel Nahmias +galambalazs +Gautam Mehta +Glenn Ruehle +Golevka +Gordon Smith +greengiant +Guillaume Massé +Hans Engel +Hardest +Hasan Karahan +Hocdoc +Ian Beck +Ian Wehrman +Ian Wetherbee +Ice White +ICHIKAWA, Yuji +Ingo Richter +Irakli Gozalishvili +Ivan Kurnosov +Jacob Lee +Jakub Vrana +James Campos +James Thorne +Jamie Hill +Jan Jongboom +jankeromnes +Jan Keromnes +Jan T. Sott +Jason +Jason Grout +Jason Johnston +Jason San Jose +Jason Siefken +Jean Boussier +jeffkenton +Jeff Pickhardt +jem (graphite) +Jochen Berger +John Connor +John Lees-Miller +John Snelson +jongalloway +Joost-Wim Boekesteijn +Joseph Pecoraro +Joshua Newman +jots +Juan Benavides Romero +Jucovschi Constantin +jwallers@gmail.com +kaniga +Ken Newman +Ken Rockot +Kevin Sawicki +Klaus Silveira +Koh Zi Han, Cliff +komakino +Konstantin Lopuhin +koops +ks-ifware +Lanny +leaf corcoran +Leonya Khachaturov +Liam Newman +List of contributors. Updated before every release. +LM +Lorenzo Stoakes +lynschinzer +Maksim Lin +Maksym Taran +Marat Dreizin +Marco Aurélio +Marijn Haverbeke +Mario Pietsch +Mark Lentczner +Mason Malone +Mateusz Paprocki +mats cronqvist +Matthew Beale +Matthias BUSSONNIER +Matt McDonald +Matt Pass +Matt Sacks +Maximilian Hils +Max Kirsch +mbarkhau +Metatheos +Micah Dubinko +Michael Lehenbauer +Michael Zhou +Mighty Guava +Miguel Castillo +Mike +Mike Brevoort +Mike Diaz +Mike Ivanov +Mike Kadin +MinRK +misfo +mps +Narciso Jaramillo +Nathan Williams +nerbert +nguillaumin +Niels van Groningen +Nikita Beloglazov +Nikita Vasilyev +nlwillia +pablo +Page +Patrick Strawderman +Paul Garvin +Paul Ivanov +Pavel Feldman +Paweł Bartkiewicz +peteguhl +peterkroon +Peter Kroon +prasanthj +Prasanth J +Rahul +Randy Edmunds +Richard Z.H. Wang +robertop23 +Robert Plummer +Ruslan Osmanov +sabaca +Samuel Ainsworth +sandeepshetty +santec +Sascha Peilicke +satchmorun +sathyamoorthi +SCLINIC\jdecker +shaund +shaun gilchrist +Shmuel Englard +sonson +spastorelli +Stas Kobzar +Stefan Borsje +Steffen Beyer +Steve O'Hara +Tarmil +tfjgeorge +Thaddee Tyl +think +Thomas Dvornik +Thomas Schmid +Tim Baumann +Timothy Farrell +Timothy Hatcher +Tomas Varaneckas +Tom Erik Støwer +Tom MacWright +Tony Jian +Vestimir Markov +vf +Volker Mische +William Jamieson +Wojtek Ptak +Xavier Mendez +Yunchi Luo +Yuvi Panda +Zachary Dremann diff --git a/LICENSE b/LICENSE index 482d55eb73..ade341ca6e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (C) 2013 by Marijn Haverbeke +Copyright (C) 2013 by Marijn Haverbeke 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 diff --git a/addon/edit/continuecomment.js b/addon/comment/continuecomment.js similarity index 94% rename from addon/edit/continuecomment.js rename to addon/comment/continuecomment.js index 308026229f..9dba156189 100644 --- a/addon/edit/continuecomment.js +++ b/addon/comment/continuecomment.js @@ -10,7 +10,7 @@ var mode = CodeMirror.innerMode(cm.getMode(), token.state).mode; var space; - if (token.type == "comment" && mode.blockCommentStart) { + if (token.type == "comment" && 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) { diff --git a/addon/display/fullscreen.css b/addon/display/fullscreen.css new file mode 100644 index 0000000000..00ad677ff5 --- /dev/null +++ b/addon/display/fullscreen.css @@ -0,0 +1,6 @@ +.CodeMirror-fullscreen { + position: fixed; + top: 0; left: 0; right: 0; bottom: 0; + height: auto; + z-index: 9999; +} diff --git a/addon/display/fullscreen.js b/addon/display/fullscreen.js new file mode 100644 index 0000000000..3c31e97a33 --- /dev/null +++ b/addon/display/fullscreen.js @@ -0,0 +1,30 @@ +(function() { + "use strict"; + + CodeMirror.defineOption("fullScreen", false, function(cm, val, old) { + if (old == CodeMirror.Init) old = false; + if (!old == !val) return; + if (val) setFullscreen(cm); + else setNormal(cm); + }); + + function setFullscreen(cm) { + var wrap = cm.getWrapperElement(); + cm.state.fullScreenRestore = {scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset, + width: wrap.style.width, height: wrap.style.height}; + wrap.style.width = wrap.style.height = ""; + wrap.className += " CodeMirror-fullscreen"; + document.documentElement.style.overflow = "hidden"; + cm.refresh(); + } + + function setNormal(cm) { + var wrap = cm.getWrapperElement(); + wrap.className = wrap.className.replace(/\s*CodeMirror-fullscreen\b/, ""); + document.documentElement.style.overflow = ""; + var info = cm.state.fullScreenRestore; + wrap.style.width = info.width; wrap.style.height = info.height; + window.scrollTo(info.scrollLeft, info.scrollTop); + cm.refresh(); + } +})(); diff --git a/addon/fold/brace-fold.js b/addon/fold/brace-fold.js index 0b4d7dc34d..2560b2b94c 100644 --- a/addon/fold/brace-fold.js +++ b/addon/fold/brace-fold.js @@ -4,7 +4,7 @@ CodeMirror.registerHelper("fold", "brace", function(cm, start) { function findOpening(openCh) { for (var at = start.ch, pass = 0;;) { - var found = lineText.lastIndexOf(openCh, at - 1); + var found = at <= 0 ? -1 : lineText.lastIndexOf(openCh, at - 1); if (found == -1) { if (pass == 1) break; pass = 1; @@ -12,7 +12,7 @@ CodeMirror.registerHelper("fold", "brace", function(cm, start) { continue; } if (pass == 1 && found < start.ch) break; - tokenType = cm.getTokenAt(CodeMirror.Pos(line, found + 1)).type; + tokenType = cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1)); if (!/^(comment|string)/.test(tokenType)) return found + 1; at = found - 1; } @@ -34,7 +34,7 @@ CodeMirror.registerHelper("fold", "brace", function(cm, start) { if (nextClose < 0) nextClose = text.length; pos = Math.min(nextOpen, nextClose); if (pos == text.length) break; - if (cm.getTokenAt(CodeMirror.Pos(i, pos + 1)).type == tokenType) { + if (cm.getTokenTypeAt(CodeMirror.Pos(i, pos + 1)) == tokenType) { if (pos == nextOpen) ++count; else if (!--count) { end = i; endCh = pos; break outer; } } diff --git a/addon/fold/comment-fold.js b/addon/fold/comment-fold.js new file mode 100644 index 0000000000..a064cf8f57 --- /dev/null +++ b/addon/fold/comment-fold.js @@ -0,0 +1,40 @@ +CodeMirror.registerHelper("fold", "comment", function(cm, start) { + var mode = cm.getModeAt(start), startToken = mode.blockCommentStart, endToken = mode.blockCommentEnd; + if (!startToken || !endToken) return; + var line = start.line, lineText = cm.getLine(line); + + var startCh; + for (var at = start.ch, pass = 0;;) { + var found = at <= 0 ? -1 : lineText.lastIndexOf(startToken, at - 1); + if (found == -1) { + if (pass == 1) return; + pass = 1; + at = lineText.length; + continue; + } + if (pass == 1 && found < start.ch) return; + if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1)))) { + startCh = found + startToken.length; + break; + } + at = found - 1; + } + + var depth = 1, lastLine = cm.lastLine(), end, endCh; + outer: for (var i = line; i <= lastLine; ++i) { + var text = cm.getLine(i), pos = i == line ? startCh : 0; + for (;;) { + var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos); + if (nextOpen < 0) nextOpen = text.length; + if (nextClose < 0) nextClose = text.length; + pos = Math.min(nextOpen, nextClose); + if (pos == text.length) break; + if (pos == nextOpen) ++depth; + else if (!--depth) { end = i; endCh = pos; break outer; } + ++pos; + } + } + if (end == null || line == end && endCh == startCh) return; + return {from: CodeMirror.Pos(line, startCh), + to: CodeMirror.Pos(end, endCh)}; +}); diff --git a/addon/hint/show-hint.js b/addon/hint/show-hint.js index 300f68831d..a33c4c3559 100644 --- a/addon/hint/show-hint.js +++ b/addon/hint/show-hint.js @@ -67,15 +67,11 @@ finished = true; completion.close(); completion.cm.off("cursorActivity", activity); - CodeMirror.signal(data, "close"); - } - function isDone() { - if (finished) return true; - if (!completion.widget) { done(); return true; } + if (data) CodeMirror.signal(data, "close"); } function update() { - if (isDone()) return; + if (finished) return; CodeMirror.signal(data, "update"); if (completion.options.async) completion.getHints(completion.cm, finishUpdate, completion.options); @@ -84,9 +80,8 @@ } function finishUpdate(data_) { data = data_; - if (isDone()) return; + if (finished) return; if (!data || !data.list.length) return done(); - completion.widget.close(); completion.widget = new Widget(completion, data); } @@ -95,10 +90,12 @@ var pos = completion.cm.getCursor(), line = completion.cm.getLine(pos.line); if (pos.line != startPos.line || line.length - pos.ch != startLen - startPos.ch || pos.ch < startPos.ch || completion.cm.somethingSelected() || - (pos.ch && closeOn.test(line.charAt(pos.ch - 1)))) + (pos.ch && closeOn.test(line.charAt(pos.ch - 1)))) { completion.close(); - else + } else { debounce = setTimeout(update, 170); + if (completion.widget) completion.widget.close(); + } } this.cm.on("cursorActivity", activity); this.onClose = done; diff --git a/addon/scroll/scrollpastend.js b/addon/scroll/scrollpastend.js new file mode 100644 index 0000000000..14d7d5aeee --- /dev/null +++ b/addon/scroll/scrollpastend.js @@ -0,0 +1,34 @@ +(function() { + "use strict"; + + CodeMirror.defineOption("scrollPastEnd", false, function(cm, val, old) { + if (old && old != CodeMirror.Init) { + cm.off("change", onChange); + cm.display.lineSpace.parentNode.style.paddingBottom = ""; + cm.state.scrollPastEndPadding = null; + } + if (val) { + cm.on("change", onChange); + updateBottomMargin(cm); + } + }); + + function onChange(cm, change) { + if (CodeMirror.changeEnd(change).line == cm.lastLine()) + updateBottomMargin(cm); + } + + function updateBottomMargin(cm) { + var padding = ""; + if (cm.lineCount() > 1) { + var totalH = cm.display.scroller.clientHeight - 30, + lastLineH = cm.getLineHandle(cm.lastLine()).height; + padding = (totalH - lastLineH) + "px"; + } + if (cm.state.scrollPastEndPadding != padding) { + cm.state.scrollPastEndPadding = padding; + cm.display.lineSpace.parentNode.style.paddingBottom = padding; + cm.setSize(); + } + } +})(); diff --git a/addon/search/match-highlighter.js b/addon/search/match-highlighter.js index 3df6985984..e5cbeacab2 100644 --- a/addon/search/match-highlighter.js +++ b/addon/search/match-highlighter.js @@ -15,15 +15,18 @@ (function() { var DEFAULT_MIN_CHARS = 2; var DEFAULT_TOKEN_STYLE = "matchhighlight"; + var DEFAULT_DELAY = 100; function State(options) { if (typeof options == "object") { this.minChars = options.minChars; this.style = options.style; this.showToken = options.showToken; + this.delay = options.delay; } 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; this.overlay = this.timeout = null; } @@ -45,7 +48,7 @@ function cursorActivity(cm) { var state = cm.state.matchHighlighter; clearTimeout(state.timeout); - state.timeout = setTimeout(function() {highlightMatches(cm);}, 100); + state.timeout = setTimeout(function() {highlightMatches(cm);}, state.delay); } function highlightMatches(cm) { diff --git a/bin/authors.sh b/bin/authors.sh new file mode 100755 index 0000000000..b3ee99c6dd --- /dev/null +++ b/bin/authors.sh @@ -0,0 +1,6 @@ +# Combine existing list of authors with everyone known in git, sort, add header. +tail --lines=+3 AUTHORS > AUTHORS.tmp +git log --format='%aN' >> AUTHORS.tmp +echo -e "List of CodeMirror contributors. Updated before every release.\n" > AUTHORS +sort -u AUTHORS.tmp >> AUTHORS +rm -f AUTHORS.tmp diff --git a/bower.json b/bower.json index fae2426c89..451d654c0c 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "CodeMirror", - "version": "3.15.0", + "version": "3.16.0", "main": ["lib/codemirror.js", "lib/codemirror.css"], "ignore": [ "**/.*", diff --git a/demo/activeline.html b/demo/activeline.html index b0ea9b9070..14851c35e4 100644 --- a/demo/activeline.html +++ b/demo/activeline.html @@ -1,23 +1,32 @@ - - - - CodeMirror: Active Line Demo - - - - - - - - -

CodeMirror: Active Line Demo

+ -
+
+

B-Tree visualization

+
@@ -83,5 +83,4 @@

- - +
diff --git a/demo/buffers.html b/demo/buffers.html index bfd8248e43..951209cad5 100644 --- a/demo/buffers.html +++ b/demo/buffers.html @@ -1,20 +1,32 @@ - - - - CodeMirror: Multiple Buffer & Split View Demo - - - - - - - - - -

CodeMirror: Multiple Buffer & Split View Demo

+ + +
+

Multiple Buffer & Split View Demo

+
@@ -94,5 +106,4 @@ using swapDoc to use a single editor to display multiple documents.

- - +
diff --git a/demo/changemode.html b/demo/changemode.html index 364c5cdb07..61c1786074 100644 --- a/demo/changemode.html +++ b/demo/changemode.html @@ -1,22 +1,32 @@ - - - - CodeMirror: Mode-Changing Demo - - - - - - - - -

CodeMirror: Mode-Changing demo

+ -
+
+

Close-Tag Demo

+
- - +
diff --git a/demo/complete.html b/demo/complete.html index 1a65f6e0d9..56999b9cc9 100644 --- a/demo/complete.html +++ b/demo/complete.html @@ -1,20 +1,31 @@ - - - - CodeMirror: Autocomplete Demo - - - - - - - - - -

CodeMirror: Autocomplete demo

-
-

Press ctrl-space to activate autocompletion. See -the code (here -and here) to figure out -how it works.

+

Press ctrl-space to activate autocompletion. Built +on top of the show-hint +and javascript-hint +addons.

- - + diff --git a/demo/emacs.html b/demo/emacs.html index 0a8cfc5d99..5b622a9992 100644 --- a/demo/emacs.html +++ b/demo/emacs.html @@ -1,28 +1,38 @@ - - - - CodeMirror: Emacs bindings demo - - - - - - - - - - - - - - -

CodeMirror: Emacs bindings demo

+ -
HTML:
- - - + diff --git a/demo/fullscreen.html b/demo/fullscreen.html index 2709ebb4b5..827d55d0cd 100644 --- a/demo/fullscreen.html +++ b/demo/fullscreen.html @@ -1,28 +1,32 @@ - - - - CodeMirror: Full Screen Editing - - - - - - - - -

CodeMirror: Full Screen Editing

+CodeMirror: Full Screen Editing + + + + + + + + + + +