196 changes: 196 additions & 0 deletions doc/oldrelease.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,202 @@ <h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMi
</pre>
</div>

<h2 id=releases>Releases</h2>

<p class="rel">20-11-2012: <a href="http://codemirror.net/codemirror-3.0rc2.zip">Version 3.0, release candidate 2</a>:</p>

<p class="rel-note"><strong>New major version</strong>. Only
partially backwards-compatible. See
the <a href="http://codemirror.net/3/doc/upgrade_v3.html">upgrading guide</a> for more
information. Changes since release candidate 1:</p>

<ul class="rel-note">
<li>New mode: <a href="../mode/http/index.html">HTTP</a>.</li>
<li>Improved handling of selection anchor position.</li>
<li>Improve IE performance on longer lines.</li>
<li>Reduce gutter glitches during horiz. scrolling.</li>
<li>Add <a href="http://codemirror.net/3/doc/manual.html#addKeyMap"><code>addKeyMap</code></a> and <a href="http://codemirror.net/3/doc/manual.html#removeKeyMap"><code>removeKeyMap</code></a> methods.</li>
<li>Rewrite <code>formatting</code> and <code>closetag</code> add-ons.</li>
</ul>

<p class="rel">20-11-2012: <a href="http://codemirror.net/codemirror-2.36.zip">Version 2.36</a>:</p>

<ul class="rel-note">
<li>New mode: <a href="../mode/z80/index.html">Z80 assembly</a>.</li>
<li>New theme: <a href="../demo/theme.html?twilight">Twilight</a>.</li>
<li>Add command-line compression helper.</li>
<li>Make <a href="manual.html#scrollIntoView"><code>scrollIntoView</code></a> public.</li>
<li>Add <a href="manual.html#defaultTextHeight"><code>defaultTextHeight</code></a> method.</li>
<li>Various extensions to the vim keymap.</li>
<li>Make <a href="../mode/php/index.html">PHP mode</a> build on <a href="../mode/htmlmixed/index.html">mixed HTML mode</a>.</li>
<li>Add <a href="manual.html#util_continuecomment">comment-continuing</a> add-on.</li>
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v2.35...v2.36">list of patches</a>.</li>
</ul>

<p class="rel">20-11-2012: <a href="http://codemirror.net/codemirror-3.0rc1.zip">Version 3.0, release candidate 1</a>:</p>

<ul class="rel-note">
<li>New theme: <a href="http://codemirror.net/3/demo/theme.html?solarized%20light">Solarized</a>.</li>
<li>Introduce <a href="http://codemirror.net/3/doc/manual.html#addLineClass"><code>addLineClass</code></a>
and <a href="http://codemirror.net/3/doc/manual.html#removeLineClass"><code>removeLineClass</code></a>,
drop <code>setLineClass</code>.</li>
<li>Add a <em>lot</em> of
new <a href="http://codemirror.net/3/doc/manual.html#markText">options for marked text</a>
(read-only, atomic, collapsed, widget replacement).</li>
<li>Remove the old code folding interface in favour of these new ranges.</li>
<li>Add <a href="http://codemirror.net/3/doc/manual.html#isClean"><code>isClean</code></a>/<a href="http://codemirror.net/3/doc/manual.html#markClean"><code>markClean</code></a> methods.</li>
<li>Remove <code>compoundChange</code> method, use better undo-event-combining heuristic.</li>
<li>Improve scrolling performance smoothness.</li>
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v3.0beta2...v3.0rc1">list of patches</a>.</li>
</ul>

<p class="rel">22-10-2012: <a href="http://codemirror.net/codemirror-2.35.zip">Version 2.35</a>:</p>

<ul class="rel-note">
<li>New (sub) mode: <a href="../mode/javascript/typescript.html">TypeScript</a>.</li>
<li>Don't overwrite (insert key) when pasting.</li>
<li>Fix several bugs in <a href="manual.html#markText"><code>markText</code></a>/undo interaction.</li>
<li>Better indentation of JavaScript code without semicolons.</li>
<li>Add <a href="manual.html#defineInitHook"><code>defineInitHook</code></a> function.</li>
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v2.34...v2.35">list of patches</a>.</li>
</ul>

<p class="rel">22-10-2012: <a href="http://codemirror.net/codemirror-3.0beta2.zip">Version 3.0, beta 2</a>:</p>

<ul class="rel-note">
<li>Fix page-based coordinate computation.</li>
<li>Fix firing of <a href="http://codemirror.net/3/doc/manual.html#event_gutterClick"><code>gutterClick</code></a> event.</li>
<li>Add <a href="http://codemirror.net/3/doc/manual.html#option_cursorHeight"><code>cursorHeight</code></a> option.</li>
<li>Fix bi-directional text regression.</li>
<li>Add <a href="http://codemirror.net/3/doc/manual.html#option_viewportMargin"><code>viewportMargin</code></a> option.</li>
<li>Directly handle mousewheel events (again, hopefully better).</li>
<li>Make vertical cursor movement more robust (through widgets, big line gaps).</li>
<li>Add <a href="http://codemirror.net/3/doc/manual.html#option_flattenSpans"><code>flattenSpans</code></a> option.</li>
<li>Initialization in hidden state works again.</li>
<li>Many optimizations. Poor responsiveness should be fixed.</li>
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v3.0beta1...v3.0beta2">list of patches</a>.</li>
</ul>

<p class="rel">19-09-2012: <a href="http://codemirror.net/codemirror-2.34.zip">Version 2.34</a>:</p>

<ul class="rel-note">
<li>New mode: <a href="../mode/commonlisp/index.html">Common Lisp</a>.</li>
<li>Fix right-click select-all on most browsers.</li>
<li>Change the way highlighting happens:<br>&nbsp; Saves memory and CPU cycles.<br>&nbsp; <code>compareStates</code> is no longer needed.<br>&nbsp; <code>onHighlightComplete</code> no longer works.</li>
<li>Integrate mode (Markdown, XQuery, CSS, sTex) tests in central testsuite.</li>
<li>Add a <a href="manual.html#version"><code>CodeMirror.version</code></a> property.</li>
<li>More robust handling of nested modes in <a href="../demo/formatting.html">formatting</a> and <a href="../demo/closetag.html">closetag</a> plug-ins.</li>
<li>Un/redo now preserves <a href="manual.html#markText">marked text</a> and bookmarks.</li>
<li><a href="https://github.com/marijnh/CodeMirror/compare/v2.33...v2.34">Full list</a> of patches.</li>
</ul>

<p class="rel">19-09-2012: <a href="http://codemirror.net/codemirror-3.0beta1.zip">Version 3.0, beta 1</a>:</p>

<ul class="rel-note">
<li>Bi-directional text support.</li>
<li>More powerful gutter model.</li>
<li>Support for arbitrary text/widget height.</li>
<li>In-line widgets.</li>
<li>Generalized event handling.</li>
</ul>

<p class="rel">23-08-2012: <a href="http://codemirror.net/codemirror-2.33.zip">Version 2.33</a>:</p>

<ul class="rel-note">
<li>New mode: <a href="../mode/sieve/index.html">Sieve</a>.</li>
<li>New <a href="manual.html#getViewport"><code>getViewPort</code></a> and <a href="manual.html#option_onViewportChange"><code>onViewportChange</code></a> API.</li>
<li><a href="manual.html#option_cursorBlinkRate">Configurable</a> cursor blink rate.</li>
<li>Make binding a key to <code>false</code> disabling handling (again).</li>
<li>Show non-printing characters as red dots.</li>
<li>More tweaks to the scrolling model.</li>
<li>Expanded testsuite. Basic linter added.</li>
<li>Remove most uses of <code>innerHTML</code>. Remove <code>CodeMirror.htmlEscape</code>.</li>
<li><a href="https://github.com/marijnh/CodeMirror/compare/v2.32...v2.33">Full list</a> of patches.</li>
</ul>

<p class="rel">23-07-2012: <a href="http://codemirror.net/codemirror-2.32.zip">Version 2.32</a>:</p>

<p class="rel-note">Emergency fix for a bug where an editor with
line wrapping on IE will break when there is <em>no</em>
scrollbar.</p>

<p class="rel">20-07-2012: <a href="http://codemirror.net/codemirror-2.31.zip">Version 2.31</a>:</p>

<ul class="rel-note">
<li>New modes: <a href="../mode/ocaml/index.html">OCaml</a>, <a href="../mode/haxe/index.html">Haxe</a>, and <a href="../mode/vb/index.html">VB.NET</a>.</li>
<li>Several fixes to the new scrolling model.</li>
<li>Add a <a href="manual.html#setSize"><code>setSize</code></a> method for programmatic resizing.</li>
<li>Add <a href="manual.html#getHistory"><code>getHistory</code></a> and <a href="manual.html#setHistory"><code>setHistory</code></a> methods.</li>
<li>Allow custom line separator string in <a href="manual.html#getValue"><code>getValue</code></a> and <a href="manual.html#getRange"><code>getRange</code></a>.</li>
<li>Support double- and triple-click drag, double-clicking whitespace.</li>
<li>And more... <a href="https://github.com/marijnh/CodeMirror/compare/v2.3...v2.31">(all patches)</a></li>
</ul>

<p class="rel">22-06-2012: <a href="http://codemirror.net/codemirror-2.3.zip">Version 2.3</a>:</p>

<ul class="rel-note">
<li><strong>New scrollbar implementation</strong>. Should flicker less. Changes DOM structure of the editor.</li>
<li>New theme: <a href="../demo/theme.html?vibrant-ink">vibrant-ink</a>.</li>
<li>Many extensions to the VIM keymap (including text objects).</li>
<li>Add <a href="../demo/multiplex.html">mode-multiplexing</a> utility script.</li>
<li>Fix bug where right-click paste works in read-only mode.</li>
<li>Add a <a href="manual.html#getScrollInfo"><code>getScrollInfo</code></a> method.</li>
<li>Lots of other <a href="https://github.com/marijnh/CodeMirror/compare/v2.25...v2.3">fixes</a>.</li>
</ul>

<p class="rel">23-05-2012: <a href="http://codemirror.net/codemirror-2.25.zip">Version 2.25</a>:</p>

<ul class="rel-note">
<li>New mode: <a href="../mode/erlang/index.html">Erlang</a>.</li>
<li><strong>Remove xmlpure mode</strong> (use <a href="../mode/xml/index.html">xml.js</a>).</li>
<li>Fix line-wrapping in Opera.</li>
<li>Fix X Windows middle-click paste in Chrome.</li>
<li>Fix bug that broke pasting of huge documents.</li>
<li>Fix backspace and tab key repeat in Opera.</li>
</ul>

<p class="rel">23-04-2012: <a href="http://codemirror.net/codemirror-2.24.zip">Version 2.24</a>:</p>

<ul class="rel-note">
<li><strong>Drop support for Internet Explorer 6</strong>.</li>
<li>New
modes: <a href="../mode/shell/index.html">Shell</a>, <a href="../mode/tiki/index.html">Tiki
wiki</a>, <a href="../mode/pig/index.html">Pig Latin</a>.</li>
<li>New themes: <a href="../demo/theme.html?ambiance">Ambiance</a>, <a href="../demo/theme.html?blackboard">Blackboard</a>.</li>
<li>More control over drag/drop
with <a href="manual.html#option_dragDrop"><code>dragDrop</code></a>
and <a href="manual.html#option_onDragEvent"><code>onDragEvent</code></a>
options.</li>
<li>Make HTML mode a bit less pedantic.</li>
<li>Add <a href="manual.html#compoundChange"><code>compoundChange</code></a> API method.</li>
<li>Several fixes in undo history and line hiding.</li>
<li>Remove (broken) support for <code>catchall</code> in key maps,
add <code>nofallthrough</code> boolean field instead.</li>
</ul>

<p class="rel">26-03-2012: <a href="http://codemirror.net/codemirror-2.23.zip">Version 2.23</a>:</p>

<ul class="rel-note">
<li>Change <strong>default binding for tab</strong> <a href="javascript:void(document.getElementById('tabbinding').style.display='')">[more]</a>
<div style="display: none" id=tabbinding>
Starting in 2.23, these bindings are default:
<ul><li>Tab: Insert tab character</li>
<li>Shift-tab: Reset line indentation to default</li>
<li>Ctrl/Cmd-[: Reduce line indentation (old tab behaviour)</li>
<li>Ctrl/Cmd-]: Increase line indentation (old shift-tab behaviour)</li>
</ul>
</div>
</li>
<li>New modes: <a href="../mode/xquery/index.html">XQuery</a> and <a href="../mode/vbscript/index.html">VBScript</a>.</li>
<li>Two new themes: <a href="../mode/less/index.html">lesser-dark</a> and <a href="../mode/xquery/index.html">xq-dark</a>.</li>
<li>Differentiate between background and text styles in <a href="manual.html#setLineClass"><code>setLineClass</code></a>.</li>
<li>Fix drag-and-drop in IE9+.</li>
<li>Extend <a href="manual.html#charCoords"><code>charCoords</code></a>
and <a href="manual.html#cursorCoords"><code>cursorCoords</code></a> with a <code>mode</code> argument.</li>
<li>Add <a href="manual.html#option_autofocus"><code>autofocus</code></a> option.</li>
<li>Add <a href="manual.html#findMarksAt"><code>findMarksAt</code></a> method.</li>
</ul>

<p class="rel">27-02-2012: <a href="http://codemirror.net/codemirror-2.22.zip">Version 2.22</a>:</p>

<ul class="rel-note">
Expand Down
2 changes: 2 additions & 0 deletions doc/realworld.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ <h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMi
<li><a href="http://tour.golang.org">Go language tour</a></li>
<li><a href="https://github.com/github/android">GitHub's Android app</a></li>
<li><a href="https://script.google.com/">Google Apps Script</a></li>
<li><a href="http://web.uvic.ca/~siefkenj/graphit/graphit.html">Graphit</a> (function graphing)</li>
<li><a href="http://try.haxe.org">Haxe</a> (Haxe Playground) </li>
<li><a href="http://haxpad.com/">HaxPad</a> (editor for Win RT)</li>
<li><a href="http://megafonweblab.github.com/histone-javascript/">Histone template engine playground</a></li>
<li><a href="http://icecoder.net">ICEcoder</a> (web IDE)</li>
<li><a href="http://extensions.joomla.org/extensions/edition/editors/8723">Joomla plugin</a></li>
Expand Down
197 changes: 9 additions & 188 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,19 @@ <h2 style="margin-top: 0">Supported modes:</h2>
<li><a href="mode/haxe/index.html">Haxe</a></li>
<li><a href="mode/htmlembedded/index.html">HTML embedded scripts</a></li>
<li><a href="mode/htmlmixed/index.html">HTML mixed-mode</a></li>
<li><a href="mode/http/index.html">HTTP</a></li>
<li><a href="mode/clike/index.html">Java</a></li>
<li><a href="mode/javascript/index.html">JavaScript</a></li>
<li><a href="mode/jinja2/index.html">Jinja2</a></li>
<li><a href="mode/less/index.html">LESS</a></li>
<li><a href="mode/lua/index.html">Lua</a></li>
<li><a href="mode/markdown/index.html">Markdown</a> (<a href="mode/gfm/index.html">GitHub-flavour</a>)</li>
<li><a href="mode/mysql/index.html">MySQL</a></li>
<li><a href="mode/ntriples/index.html">NTriples</a></li>
<li><a href="mode/ocaml/index.html">OCaml</a></li>
<li><a href="mode/pascal/index.html">Pascal</a></li>
<li><a href="mode/perl/index.html">Perl</a></li>
<li><a href="mode/php/index.html">PHP</a></li>
<li><a href="mode/pig/index.html">Pig Latin</a></li>
<li><a href="mode/plsql/index.html">PL/SQL</a></li>
<li><a href="mode/properties/index.html">Properties files</a></li>
<li><a href="mode/python/index.html">Python</a></li>
<li><a href="mode/r/index.html">R</a></li>
Expand All @@ -76,6 +75,7 @@ <h2 style="margin-top: 0">Supported modes:</h2>
<li><a href="mode/sieve/index.html">Sieve</a></li>
<li><a href="mode/smalltalk/index.html">Smalltalk</a></li>
<li><a href="mode/smarty/index.html">Smarty</a></li>
<li><a href="mode/sql/index.html">SQL</a> (several dialects)</li>
<li><a href="mode/sparql/index.html">SPARQL</a></li>
<li><a href="mode/stex/index.html">sTeX, LaTeX</a></li>
<li><a href="mode/tiddlywiki/index.html">Tiddlywiki</a></li>
Expand Down Expand Up @@ -208,7 +208,7 @@ <h2 id="supported">Supported browsers</h2>
<p>The following <em>desktop</em> browsers are able to run CodeMirror:</p>

<ul>
<li>Firefox 2 or higher</li>
<li>Firefox 3 or higher</li>
<li>Chrome, any version</li>
<li>Safari 3 or higher</li>
<li>Opera 9 or higher (with some key-handling problems on OS X)</li>
Expand Down Expand Up @@ -250,7 +250,11 @@ <h2 id="commercial">Commercial support</h2>

<div class="right blk">

<a href="http://codemirror.net/codemirror.zip" class="download">Download the latest release</a>
<a href="http://codemirror.net/" class="download">Current project page</a>

<p class="rel-note">This is old project page for CodeMirror version 2.x. Go
to <a href="http://codemirror.net/">codemirror.net</a> for current
releases and events.</p>

<h2>Support CodeMirror</h2>

Expand Down Expand Up @@ -280,190 +284,7 @@ <h2>Reading material</h2>
<li><a href="http://github.com/marijnh/CodeMirror">Browse the code</a></li>
</ul>

<h2 id=releases>Releases</h2>

<p class="rel">20-11-2012: <a href="http://codemirror.net/codemirror-2.36.zip">Version 2.36</a>:</p>

<ul class="rel-note">
<li>New mode: <a href="mode/z80/index.html">Z80 assembly</a>.</li>
<li>New theme: <a href="demo/theme.html?twilight">Twilight</a>.</li>
<li>Add command-line compression helper.</li>
<li>Make <a href="doc/manual.html#scrollIntoView"><code>scrollIntoView</code></a> public.</li>
<li>Add <a href="doc/manual.html#defaultTextHeight"><code>defaultTextHeight</code></a> method.</li>
<li>Various extensions to the vim keymap.</li>
<li>Make <a href="mode/php/index.html">PHP mode</a> build on <a href="mode/htmlmixed/index.html">mixed HTML mode</a>.</li>
<li>Add <a href="doc/manual.html#util_continuecomment">comment-continuing</a> add-on.</li>
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v2.35...v2.36">list of patches</a>.</li>
</ul>

<p class="rel">20-11-2012: <a href="http://codemirror.net/codemirror-3.0rc1.zip">Version 3.0, release candidate 1</a>:</p>

<p class="rel-note"><strong>New major version</strong>. Only partially
backwards-compatible. See
the <a href="http://codemirror.net/3/doc/upgrade_v3.html">upgrading
guide</a> for more information. Changes since beta 2:</p>

<ul class="rel-note">
<li>New theme: <a href="http://codemirror.net/3/demo/theme.html?solarized%20light">Solarized</a>.</li>
<li>Introduce <a href="http://codemirror.net/3/doc/manual.html#addLineClass"><code>addLineClass</code></a>
and <a href="http://codemirror.net/3/doc/manual.html#removeLineClass"><code>removeLineClass</code></a>,
drop <code>setLineClass</code>.</li>
<li>Add a <em>lot</em> of
new <a href="http://codemirror.net/3/doc/manual.html#markText">options for marked text</a>
(read-only, atomic, collapsed, widget replacement).</li>
<li>Remove the old code folding interface in favour of these new ranges.</li>
<li>Add <a href="http://codemirror.net/3/doc/manual.html#isClean"><code>isClean</code></a>/<a href="http://codemirror.net/3/doc/manual.html#markClean"><code>markClean</code></a> methods.</li>
<li>Remove <code>compoundChange</code> method, use better undo-event-combining heuristic.</li>
<li>Improve scrolling performance smoothness.</li>
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v3.0beta2...v3.0rc1">list of patches</a>.</li>
</ul>

<p class="rel">22-10-2012: <a href="http://codemirror.net/codemirror-2.35.zip">Version 2.35</a>:</p>

<ul class="rel-note">
<li>New (sub) mode: <a href="mode/javascript/typescript.html">TypeScript</a>.</li>
<li>Don't overwrite (insert key) when pasting.</li>
<li>Fix several bugs in <a href="doc/manual.html#markText"><code>markText</code></a>/undo interaction.</li>
<li>Better indentation of JavaScript code without semicolons.</li>
<li>Add <a href="doc/manual.html#defineInitHook"><code>defineInitHook</code></a> function.</li>
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v2.34...v2.35">list of patches</a>.</li>
</ul>

<p class="rel">22-10-2012: <a href="http://codemirror.net/codemirror-3.0beta2.zip">Version 3.0, beta 2</a>:</p>

<ul class="rel-note">
<li>Fix page-based coordinate computation.</li>
<li>Fix firing of <a href="http://codemirror.net/3/doc/manual.html#event_gutterClick"><code>gutterClick</code></a> event.</li>
<li>Add <a href="http://codemirror.net/3/doc/manual.html#option_cursorHeight"><code>cursorHeight</code></a> option.</li>
<li>Fix bi-directional text regression.</li>
<li>Add <a href="http://codemirror.net/3/doc/manual.html#option_viewportMargin"><code>viewportMargin</code></a> option.</li>
<li>Directly handle mousewheel events (again, hopefully better).</li>
<li>Make vertical cursor movement more robust (through widgets, big line gaps).</li>
<li>Add <a href="http://codemirror.net/3/doc/manual.html#option_flattenSpans"><code>flattenSpans</code></a> option.</li>
<li>Initialization in hidden state works again.</li>
<li>Many optimizations. Poor responsiveness should be fixed.</li>
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v3.0beta1...v3.0beta2">list of patches</a>.</li>
</ul>

<p class="rel">19-09-2012: <a href="http://codemirror.net/codemirror-2.34.zip">Version 2.34</a>:</p>

<ul class="rel-note">
<li>New mode: <a href="mode/commonlisp/index.html">Common Lisp</a>.</li>
<li>Fix right-click select-all on most browsers.</li>
<li>Change the way highlighting happens:<br>&nbsp; Saves memory and CPU cycles.<br>&nbsp; <code>compareStates</code> is no longer needed.<br>&nbsp; <code>onHighlightComplete</code> no longer works.</li>
<li>Integrate mode (Markdown, XQuery, CSS, sTex) tests in central testsuite.</li>
<li>Add a <a href="doc/manual.html#version"><code>CodeMirror.version</code></a> property.</li>
<li>More robust handling of nested modes in <a href="demo/formatting.html">formatting</a> and <a href="demo/closetag.html">closetag</a> plug-ins.</li>
<li>Un/redo now preserves <a href="doc/manual.html#markText">marked text</a> and bookmarks.</li>
<li><a href="https://github.com/marijnh/CodeMirror/compare/v2.33...v2.34">Full list</a> of patches.</li>
</ul>

<p class="rel">19-09-2012: <a href="http://codemirror.net/codemirror-3.0beta1.zip">Version 3.0, beta 1</a>:</p>

<ul class="rel-note">
<li>Bi-directional text support.</li>
<li>More powerful gutter model.</li>
<li>Support for arbitrary text/widget height.</li>
<li>In-line widgets.</li>
<li>Generalized event handling.</li>
</ul>

<p class="rel">23-08-2012: <a href="http://codemirror.net/codemirror-2.33.zip">Version 2.33</a>:</p>

<ul class="rel-note">
<li>New mode: <a href="mode/sieve/index.html">Sieve</a>.</li>
<li>New <a href="doc/manual.html#getViewport"><code>getViewPort</code></a> and <a href="doc/manual.html#option_onViewportChange"><code>onViewportChange</code></a> API.</li>
<li><a href="doc/manual.html#option_cursorBlinkRate">Configurable</a> cursor blink rate.</li>
<li>Make binding a key to <code>false</code> disabling handling (again).</li>
<li>Show non-printing characters as red dots.</li>
<li>More tweaks to the scrolling model.</li>
<li>Expanded testsuite. Basic linter added.</li>
<li>Remove most uses of <code>innerHTML</code>. Remove <code>CodeMirror.htmlEscape</code>.</li>
<li><a href="https://github.com/marijnh/CodeMirror/compare/v2.32...v2.33">Full list</a> of patches.</li>
</ul>

<p class="rel">23-07-2012: <a href="http://codemirror.net/codemirror-2.32.zip">Version 2.32</a>:</p>

<p class="rel-note">Emergency fix for a bug where an editor with
line wrapping on IE will break when there is <em>no</em>
scrollbar.</p>

<p class="rel">20-07-2012: <a href="http://codemirror.net/codemirror-2.31.zip">Version 2.31</a>:</p>

<ul class="rel-note">
<li>New modes: <a href="mode/ocaml/index.html">OCaml</a>, <a href="mode/haxe/index.html">Haxe</a>, and <a href="mode/vb/index.html">VB.NET</a>.</li>
<li>Several fixes to the new scrolling model.</li>
<li>Add a <a href="doc/manual.html#setSize"><code>setSize</code></a> method for programmatic resizing.</li>
<li>Add <a href="doc/manual.html#getHistory"><code>getHistory</code></a> and <a href="doc/manual.html#setHistory"><code>setHistory</code></a> methods.</li>
<li>Allow custom line separator string in <a href="doc/manual.html#getValue"><code>getValue</code></a> and <a href="doc/manual.html#getRange"><code>getRange</code></a>.</li>
<li>Support double- and triple-click drag, double-clicking whitespace.</li>
<li>And more... <a href="https://github.com/marijnh/CodeMirror/compare/v2.3...v2.31">(all patches)</a></li>
</ul>

<p class="rel">22-06-2012: <a href="http://codemirror.net/codemirror-2.3.zip">Version 2.3</a>:</p>

<ul class="rel-note">
<li><strong>New scrollbar implementation</strong>. Should flicker less. Changes DOM structure of the editor.</li>
<li>New theme: <a href="demo/theme.html?vibrant-ink">vibrant-ink</a>.</li>
<li>Many extensions to the VIM keymap (including text objects).</li>
<li>Add <a href="demo/multiplex.html">mode-multiplexing</a> utility script.</li>
<li>Fix bug where right-click paste works in read-only mode.</li>
<li>Add a <a href="doc/manual.html#getScrollInfo"><code>getScrollInfo</code></a> method.</li>
<li>Lots of other <a href="https://github.com/marijnh/CodeMirror/compare/v2.25...v2.3">fixes</a>.</li>
</ul>

<p class="rel">23-05-2012: <a href="http://codemirror.net/codemirror-2.25.zip">Version 2.25</a>:</p>

<ul class="rel-note">
<li>New mode: <a href="mode/erlang/index.html">Erlang</a>.</li>
<li><strong>Remove xmlpure mode</strong> (use <a href="mode/xml/index.html">xml.js</a>).</li>
<li>Fix line-wrapping in Opera.</li>
<li>Fix X Windows middle-click paste in Chrome.</li>
<li>Fix bug that broke pasting of huge documents.</li>
<li>Fix backspace and tab key repeat in Opera.</li>
</ul>

<p class="rel">23-04-2012: <a href="http://codemirror.net/codemirror-2.24.zip">Version 2.24</a>:</p>

<ul class="rel-note">
<li><strong>Drop support for Internet Explorer 6</strong>.</li>
<li>New
modes: <a href="mode/shell/index.html">Shell</a>, <a href="mode/tiki/index.html">Tiki
wiki</a>, <a href="mode/pig/index.html">Pig Latin</a>.</li>
<li>New themes: <a href="demo/theme.html?ambiance">Ambiance</a>, <a href="demo/theme.html?blackboard">Blackboard</a>.</li>
<li>More control over drag/drop
with <a href="doc/manual.html#option_dragDrop"><code>dragDrop</code></a>
and <a href="doc/manual.html#option_onDragEvent"><code>onDragEvent</code></a>
options.</li>
<li>Make HTML mode a bit less pedantic.</li>
<li>Add <a href="doc/manual.html#compoundChange"><code>compoundChange</code></a> API method.</li>
<li>Several fixes in undo history and line hiding.</li>
<li>Remove (broken) support for <code>catchall</code> in key maps,
add <code>nofallthrough</code> boolean field instead.</li>
</ul>

<p class="rel">26-03-2012: <a href="http://codemirror.net/codemirror-2.23.zip">Version 2.23</a>:</p>

<ul class="rel-note">
<li>Change <strong>default binding for tab</strong> <a href="javascript:void(document.getElementById('tabbinding').style.display='')">[more]</a>
<div style="display: none" id=tabbinding>
Starting in 2.23, these bindings are default:
<ul><li>Tab: Insert tab character</li>
<li>Shift-tab: Reset line indentation to default</li>
<li>Ctrl/Cmd-[: Reduce line indentation (old tab behaviour)</li>
<li>Ctrl/Cmd-]: Increase line indentation (old shift-tab behaviour)</li>
</ul>
</div>
</li>
<li>New modes: <a href="mode/xquery/index.html">XQuery</a> and <a href="mode/vbscript/index.html">VBScript</a>.</li>
<li>Two new themes: <a href="mode/less/index.html">lesser-dark</a> and <a href="mode/xquery/index.html">xq-dark</a>.</li>
<li>Differentiate between background and text styles in <a href="doc/manual.html#setLineClass"><code>setLineClass</code></a>.</li>
<li>Fix drag-and-drop in IE9+.</li>
<li>Extend <a href="doc/manual.html#charCoords"><code>charCoords</code></a>
and <a href="doc/manual.html#cursorCoords"><code>cursorCoords</code></a> with a <code>mode</code> argument.</li>
<li>Add <a href="doc/manual.html#option_autofocus"><code>autofocus</code></a> option.</li>
<li>Add <a href="doc/manual.html#findMarksAt"><code>findMarksAt</code></a> method.</li>
</ul>
<h2>Releases</h2>

<p><a href="doc/oldrelease.html">Older releases...</a></p>

Expand Down
3,180 changes: 2,355 additions & 825 deletions keymap/vim.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/codemirror.css
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ div.CodeMirror-selected { background: #d9d9d9; }
.cm-s-default span.cm-quote {color: #090;}
.cm-s-default span.cm-hr {color: #999;}
.cm-s-default span.cm-link {color: #00c;}
span.cm-negative {color: #d44;}
span.cm-positive {color: #292;}

span.cm-header, span.cm-strong {font-weight: bold;}
span.cm-em {font-style: italic;}
Expand Down
55 changes: 38 additions & 17 deletions lib/codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ window.CodeMirror = (function() {
else if (option == "tabSize") updateDisplay(true);
else if (option == "keyMap") keyMapChanged();
else if (option == "tabindex") input.tabIndex = value;
else if (option == "showCursorWhenSelecting") updateSelection();
if (option == "lineNumbers" || option == "gutter" || option == "firstLineNumber" ||
option == "theme" || option == "lineNumberFormatter") {
gutterChanged();
Expand Down Expand Up @@ -280,7 +281,9 @@ window.CodeMirror = (function() {
lineCount: function() {return doc.size;},
clipPos: clipPos,
getCursor: function(start) {
if (start == null) start = sel.inverted;
if (start == null || start == "head") start = sel.inverted;
if (start == "anchor") start = !sel.inverted;
if (start == "end") start = false;
return copyPos(start ? sel.from : sel.to);
},
somethingSelected: function() {return !posEq(sel.from, sel.to);},
Expand Down Expand Up @@ -493,8 +496,12 @@ window.CodeMirror = (function() {

function doSelect(cur) {
if (type == "single") {
setSelectionUser(start, cur);
} else if (type == "double") {
setSelectionUser(clipPos(start), cur);
return;
}
startstart = clipPos(startstart);
startend = clipPos(startend);
if (type == "double") {
var word = findWordAt(cur);
if (posLess(cur, startstart)) setSelectionUser(word.from, startend);
else setSelectionUser(startstart, word.to);
Expand Down Expand Up @@ -619,7 +626,6 @@ window.CodeMirror = (function() {
}, 50);

var name = keyNames[e_prop(e, "keyCode")], handled = false;
var flipCtrlCmd = opera && mac;
if (name == null || e.altGraphKey) return false;
if (e_prop(e, "altKey")) name = "Alt-" + name;
if (e_prop(e, flipCtrlCmd ? "metaKey" : "ctrlKey")) name = "Ctrl-" + name;
Expand Down Expand Up @@ -979,7 +985,8 @@ window.CodeMirror = (function() {
}

function focusInput() {
if (options.readOnly != "nocursor") input.focus();
if (options.readOnly != "nocursor" && (ie_lt9 || document.activeElement != input))
input.focus();
}

function scrollCursorIntoView() {
Expand Down Expand Up @@ -1244,18 +1251,20 @@ window.CodeMirror = (function() {
var wrapOff = eltOffset(wrapper), lineOff = eltOffset(lineDiv);
inputDiv.style.top = Math.max(0, Math.min(scroller.offsetHeight, headPos.y + lineOff.top - wrapOff.top)) + "px";
inputDiv.style.left = Math.max(0, Math.min(scroller.offsetWidth, headPos.x + lineOff.left - wrapOff.left)) + "px";
if (collapsed) {
if (collapsed || options.showCursorWhenSelecting) {
cursor.style.top = headPos.y + "px";
cursor.style.left = (options.lineWrapping ? Math.min(headPos.x, lineSpace.offsetWidth) : headPos.x) + "px";
cursor.style.display = "";
selectionDiv.style.display = "none";
} else {
cursor.style.display = "none";
}
if (!collapsed) {
var sameLine = fromPos.y == toPos.y, fragment = document.createDocumentFragment();
var clientWidth = lineSpace.clientWidth || lineSpace.offsetWidth;
var clientHeight = lineSpace.clientHeight || lineSpace.offsetHeight;
var add = function(left, top, right, height) {
var rstyle = quirksMode ? "width: " + (!right ? clientWidth : clientWidth - right - left) + "px"
: "right: " + right + "px";
: "right: " + (right - 1) + "px";
fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left +
"px; top: " + top + "px; " + rstyle + "; height: " + height + "px"));
};
Expand All @@ -1270,8 +1279,9 @@ window.CodeMirror = (function() {
if ((!sameLine || !sel.from.ch) && toPos.y < clientHeight - .5 * th)
add(0, toPos.y, clientWidth - toPos.x, th);
removeChildrenAndAdd(selectionDiv, fragment);
cursor.style.display = "none";
selectionDiv.style.display = "";
} else {
selectionDiv.style.display = "none";
}
}

Expand Down Expand Up @@ -2009,6 +2019,7 @@ window.CodeMirror = (function() {
gutter: false,
fixedGutter: false,
firstLineNumber: 1,
showCursorWhenSelecting: false,
readOnly: false,
dragDrop: true,
onChange: null,
Expand Down Expand Up @@ -2060,7 +2071,11 @@ window.CodeMirror = (function() {
var modeObj = mfactory(options, spec);
if (modeExtensions.hasOwnProperty(spec.name)) {
var exts = modeExtensions[spec.name];
for (var prop in exts) if (exts.hasOwnProperty(prop)) modeObj[prop] = exts[prop];
for (var prop in exts) {
if (!exts.hasOwnProperty(prop)) continue;
if (modeObj.hasOwnProperty(prop)) modeObj["_" + prop] = modeObj[prop];
modeObj[prop] = exts[prop];
}
}
modeObj.name = spec.name;
return modeObj;
Expand Down Expand Up @@ -2236,12 +2251,12 @@ window.CodeMirror = (function() {
if (textarea.form) {
// Deplorable hack to make the submit method do the right thing.
var rmSubmit = connect(textarea.form, "submit", save, true);
var realSubmit = textarea.form.submit;
var form = textarea.form, realSubmit = form.submit;
textarea.form.submit = function wrappedSubmit() {
save();
textarea.form.submit = realSubmit;
textarea.form.submit();
textarea.form.submit = wrappedSubmit;
form.submit = realSubmit;
form.submit();
form.submit = wrappedSubmit;
};
}

Expand All @@ -2264,18 +2279,24 @@ window.CodeMirror = (function() {
return instance;
};

var gecko = /gecko\/\d{7}/i.test(navigator.userAgent);
var gecko = /gecko\/\d/i.test(navigator.userAgent);
var ie = /MSIE \d/.test(navigator.userAgent);
var ie_lt8 = /MSIE [1-7]\b/.test(navigator.userAgent);
var ie_lt9 = /MSIE [1-8]\b/.test(navigator.userAgent);
var quirksMode = ie && document.documentMode == 5;
var webkit = /WebKit\//.test(navigator.userAgent);
var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent);
var chrome = /Chrome\//.test(navigator.userAgent);
var opera = /Opera\//.test(navigator.userAgent);
var safari = /Apple Computer/.test(navigator.vendor);
var khtml = /KHTML\//.test(navigator.userAgent);
var mac_geLion = /Mac OS X 10\D([7-9]|\d\d)\D/.test(navigator.userAgent);

var opera_version = opera && navigator.userAgent.match(/Version\/(\d*\.\d*)/);
if (opera_version) opera_version = Number(opera_version[1]);
// Some browsers use the wrong event properties to signal cmd/ctrl on OS X
var flipCtrlCmd = mac && (qtwebkit || opera && (opera_version == null || opera_version < 12.11));

// Utility functions for working with state. Exported because modes
// sometimes need to do this.
function copyState(mode, state) {
Expand Down Expand Up @@ -2844,7 +2865,7 @@ window.CodeMirror = (function() {
if (line.parent == null) return null;
var cur = line.parent, no = indexOf(cur.lines, line);
for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {
for (var i = 0, e = chunk.children.length; ; ++i) {
for (var i = 0; ; ++i) {
if (chunk.children[i] == cur) break;
no += chunk.children[i].chunkSize();
}
Expand Down Expand Up @@ -3163,7 +3184,7 @@ window.CodeMirror = (function() {
for (var i = 1; i <= 12; i++) keyNames[i + 111] = keyNames[i + 63235] = "F" + i;
})();

CodeMirror.version = "2.36";
CodeMirror.version = "2.37";

return CodeMirror;
})();
329 changes: 165 additions & 164 deletions lib/util/closetag.js
Original file line number Diff line number Diff line change
@@ -1,164 +1,165 @@
/**
* Tag-closer extension for CodeMirror.
*
* This extension adds a "closeTag" utility function that can be used with key bindings to
* insert a matching end tag after the ">" character of a start tag has been typed. It can
* also complete "</" if a matching start tag is found. It will correctly ignore signal
* characters for empty tags, comments, CDATA, etc.
*
* The function depends on internal parser state to identify tags. It is compatible with the
* following CodeMirror modes and will ignore all others:
* - htmlmixed
* - xml
*
* See demos/closetag.html for a usage example.
*
* @author Nathan Williams <nathan@nlwillia.net>
* Contributed under the same license terms as CodeMirror.
*/
(function() {
/** Option that allows tag closing behavior to be toggled. Default is true. */
CodeMirror.defaults['closeTagEnabled'] = true;

/** Array of tag names to add indentation after the start tag for. Default is the list of block-level html tags. */
CodeMirror.defaults['closeTagIndent'] = ['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'];

/** Array of tag names where an end tag is forbidden. */
CodeMirror.defaults['closeTagVoid'] = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr'];

function innerState(cm, state) {
return CodeMirror.innerMode(cm.getMode(), state).state;
}


/**
* Call during key processing to close tags. Handles the key event if the tag is closed, otherwise throws CodeMirror.Pass.
* - cm: The editor instance.
* - ch: The character being processed.
* - indent: Optional. An array of tag names to indent when closing. Omit or pass true to use the default indentation tag list defined in the 'closeTagIndent' option.
* Pass false to disable indentation. Pass an array to override the default list of tag names.
* - vd: Optional. An array of tag names that should not be closed. Omit to use the default void (end tag forbidden) tag list defined in the 'closeTagVoid' option. Ignored in xml mode.
*/
CodeMirror.defineExtension("closeTag", function(cm, ch, indent, vd) {
if (!cm.getOption('closeTagEnabled')) {
throw CodeMirror.Pass;
}

/*
* Relevant structure of token:
*
* htmlmixed
* className
* state
* htmlState
* type
* tagName
* context
* tagName
* mode
*
* xml
* className
* state
* tagName
* type
*/

var pos = cm.getCursor();
var tok = cm.getTokenAt(pos);
var state = innerState(cm, tok.state);

if (state) {

if (ch == '>') {
var type = state.type;

if (tok.className == 'tag' && type == 'closeTag') {
throw CodeMirror.Pass; // Don't process the '>' at the end of an end-tag.
}

cm.replaceSelection('>'); // Mode state won't update until we finish the tag.
pos = {line: pos.line, ch: pos.ch + 1};
cm.setCursor(pos);

tok = cm.getTokenAt(cm.getCursor());
state = innerState(cm, tok.state);
if (!state) throw CodeMirror.Pass;
var type = state.type;

if (tok.className == 'tag' && type != 'selfcloseTag') {
var tagName = state.tagName;
if (tagName.length > 0 && shouldClose(cm, vd, tagName)) {
insertEndTag(cm, indent, pos, tagName);
}
return;
}

// Undo the '>' insert and allow cm to handle the key instead.
cm.setSelection({line: pos.line, ch: pos.ch - 1}, pos);
cm.replaceSelection("");

} else if (ch == '/') {
if (tok.className == 'tag' && tok.string == '<') {
var ctx = state.context, tagName = ctx ? ctx.tagName : '';
if (tagName.length > 0) {
completeEndTag(cm, pos, tagName);
return;
}
}
}

}

throw CodeMirror.Pass; // Bubble if not handled
});

function insertEndTag(cm, indent, pos, tagName) {
if (shouldIndent(cm, indent, tagName)) {
cm.replaceSelection('\n\n</' + tagName + '>', 'end');
cm.indentLine(pos.line + 1);
cm.indentLine(pos.line + 2);
cm.setCursor({line: pos.line + 1, ch: cm.getLine(pos.line + 1).length});
} else {
cm.replaceSelection('</' + tagName + '>');
cm.setCursor(pos);
}
}

function shouldIndent(cm, indent, tagName) {
if (typeof indent == 'undefined' || indent == null || indent == true) {
indent = cm.getOption('closeTagIndent');
}
if (!indent) {
indent = [];
}
return indexOf(indent, tagName.toLowerCase()) != -1;
}

function shouldClose(cm, vd, tagName) {
if (cm.getOption('mode') == 'xml') {
return true; // always close xml tags
}
if (typeof vd == 'undefined' || vd == null) {
vd = cm.getOption('closeTagVoid');
}
if (!vd) {
vd = [];
}
return indexOf(vd, tagName.toLowerCase()) == -1;
}

// C&P from codemirror.js...would be nice if this were visible to utilities.
function indexOf(collection, elt) {
if (collection.indexOf) return collection.indexOf(elt);
for (var i = 0, e = collection.length; i < e; ++i)
if (collection[i] == elt) return i;
return -1;
}

function completeEndTag(cm, pos, tagName) {
cm.replaceSelection('/' + tagName + '>');
cm.setCursor({line: pos.line, ch: pos.ch + tagName.length + 2 });
}

})();
/**
* Tag-closer extension for CodeMirror.
*
* This extension adds a "closeTag" utility function that can be used with key bindings to
* insert a matching end tag after the ">" character of a start tag has been typed. It can
* also complete "</" if a matching start tag is found. It will correctly ignore signal
* characters for empty tags, comments, CDATA, etc.
*
* The function depends on internal parser state to identify tags. It is compatible with the
* following CodeMirror modes and will ignore all others:
* - htmlmixed
* - xml
*
* See demos/closetag.html for a usage example.
*
* @author Nathan Williams <nathan@nlwillia.net>
* Contributed under the same license terms as CodeMirror.
*/
(function() {
/** Option that allows tag closing behavior to be toggled. Default is true. */
CodeMirror.defaults['closeTagEnabled'] = true;

/** Array of tag names to add indentation after the start tag for. Default is the list of block-level html tags. */
CodeMirror.defaults['closeTagIndent'] = ['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'];

/** Array of tag names where an end tag is forbidden. */
CodeMirror.defaults['closeTagVoid'] = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr'];

function innerXMLState(cm, state) {
var inner = CodeMirror.innerMode(cm.getMode(), state);
if (inner.mode.name == "xml") return inner.state;
}


/**
* Call during key processing to close tags. Handles the key event if the tag is closed, otherwise throws CodeMirror.Pass.
* - cm: The editor instance.
* - ch: The character being processed.
* - indent: Optional. An array of tag names to indent when closing. Omit or pass true to use the default indentation tag list defined in the 'closeTagIndent' option.
* Pass false to disable indentation. Pass an array to override the default list of tag names.
* - vd: Optional. An array of tag names that should not be closed. Omit to use the default void (end tag forbidden) tag list defined in the 'closeTagVoid' option. Ignored in xml mode.
*/
CodeMirror.defineExtension("closeTag", function(cm, ch, indent, vd) {
if (!cm.getOption('closeTagEnabled')) {
throw CodeMirror.Pass;
}

/*
* Relevant structure of token:
*
* htmlmixed
* className
* state
* htmlState
* type
* tagName
* context
* tagName
* mode
*
* xml
* className
* state
* tagName
* type
*/

var pos = cm.getCursor();
var tok = cm.getTokenAt(pos);
var state = innerXMLState(cm, tok.state);

if (state) {

if (ch == '>') {
var type = state.type;

if (tok.className == 'tag' && type == 'closeTag') {
throw CodeMirror.Pass; // Don't process the '>' at the end of an end-tag.
}

cm.replaceSelection('>'); // Mode state won't update until we finish the tag.
pos = {line: pos.line, ch: pos.ch + 1};
cm.setCursor(pos);

tok = cm.getTokenAt(cm.getCursor());
state = innerXMLState(cm, tok.state);
if (!state) throw CodeMirror.Pass;
var type = state.type;

if (tok.className == 'tag' && type != 'selfcloseTag') {
var tagName = state.tagName;
if (tagName.length > 0 && shouldClose(cm, vd, tagName)) {
insertEndTag(cm, indent, pos, tagName);
}
return;
}

// Undo the '>' insert and allow cm to handle the key instead.
cm.setSelection({line: pos.line, ch: pos.ch - 1}, pos);
cm.replaceSelection("");

} else if (ch == '/') {
if (tok.className == 'tag' && tok.string == '<') {
var ctx = state.context, tagName = ctx ? ctx.tagName : '';
if (tagName.length > 0) {
completeEndTag(cm, pos, tagName);
return;
}
}
}

}

throw CodeMirror.Pass; // Bubble if not handled
});

function insertEndTag(cm, indent, pos, tagName) {
if (shouldIndent(cm, indent, tagName)) {
cm.replaceSelection('\n\n</' + tagName + '>', 'end');
cm.indentLine(pos.line + 1);
cm.indentLine(pos.line + 2);
cm.setCursor({line: pos.line + 1, ch: cm.getLine(pos.line + 1).length});
} else {
cm.replaceSelection('</' + tagName + '>');
cm.setCursor(pos);
}
}

function shouldIndent(cm, indent, tagName) {
if (typeof indent == 'undefined' || indent == null || indent == true) {
indent = cm.getOption('closeTagIndent');
}
if (!indent) {
indent = [];
}
return indexOf(indent, tagName.toLowerCase()) != -1;
}

function shouldClose(cm, vd, tagName) {
if (cm.getOption('mode') == 'xml') {
return true; // always close xml tags
}
if (typeof vd == 'undefined' || vd == null) {
vd = cm.getOption('closeTagVoid');
}
if (!vd) {
vd = [];
}
return indexOf(vd, tagName.toLowerCase()) == -1;
}

// C&P from codemirror.js...would be nice if this were visible to utilities.
function indexOf(collection, elt) {
if (collection.indexOf) return collection.indexOf(elt);
for (var i = 0, e = collection.length; i < e; ++i)
if (collection[i] == elt) return i;
return -1;
}

function completeEndTag(cm, pos, tagName) {
cm.replaceSelection('/' + tagName + '>');
cm.setCursor({line: pos.line, ch: pos.ch + tagName.length + 2 });
}

})();
29 changes: 29 additions & 0 deletions lib/util/continuelist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
(function() {
CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
var pos = cm.getCursor(), token = cm.getTokenAt(pos);
var mode = CodeMirror.innerMode(cm.getMode(), token.state).mode;
var space;
if (token.className == "string") {
var full = cm.getRange({line: pos.line, ch: 0}, {line: pos.line, ch: token.end});
var listStart = /\*|\d+\./, listContinue;
if (token.string.search(listStart) == 0) {
var reg = /^[\W]*(\d+)\./g;
var matches = reg.exec(full);
if(matches)
listContinue = (parseInt(matches[1]) + 1) + ". ";
else
listContinue = "* ";
space = full.slice(0, token.start);
if (!/^\s*$/.test(space)) {
space = "";
for (var i = 0; i < token.start; ++i) space += " ";
}
}
}

if (space != null)
cm.replaceSelection("\n" + space + listContinue, "end");
else
cm.execCommand("newlineAndIndent");
};
})();
19 changes: 12 additions & 7 deletions lib/util/dialog.css
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
.CodeMirror-dialog {
position: relative;
}

.CodeMirror-dialog > div {
position: absolute;
top: 0; left: 0; right: 0;
left: 0; right: 0;
background: white;
border-bottom: 1px solid #eee;
z-index: 15;
padding: .1em .8em;
overflow: hidden;
color: #333;
}

.CodeMirror-dialog-top {
border-bottom: 1px solid #eee;
top: 0;
}

.CodeMirror-dialog-bottom {
border-top: 1px solid #eee;
bottom: 0;
}

.CodeMirror-dialog input {
border: none;
outline: none;
Expand All @@ -24,4 +29,4 @@

.CodeMirror-dialog button {
font-size: 70%;
}
}
24 changes: 15 additions & 9 deletions lib/util/dialog.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
// Open simple dialogs on top of an editor. Relies on dialog.css.

(function() {
function dialogDiv(cm, template) {
function dialogDiv(cm, template, bottom) {
var wrap = cm.getWrapperElement();
var dialog = wrap.insertBefore(document.createElement("div"), wrap.firstChild);
dialog.className = "CodeMirror-dialog";
dialog.innerHTML = '<div>' + template + '</div>';
var dialog;
dialog = wrap.appendChild(document.createElement("div"));
if (bottom) {
dialog.className = "CodeMirror-dialog CodeMirror-dialog-bottom";
} else {
dialog.className = "CodeMirror-dialog CodeMirror-dialog-top";
}
dialog.innerHTML = template;
return dialog;
}

CodeMirror.defineExtension("openDialog", function(template, callback) {
var dialog = dialogDiv(this, template);
CodeMirror.defineExtension("openDialog", function(template, callback, options) {
var dialog = dialogDiv(this, template, options && options.bottom);
var closed = false, me = this;
function close() {
if (closed) return;
Expand All @@ -27,6 +32,7 @@
if (e.keyCode == 13) callback(inp.value);
}
});
if (options && options.value) inp.value = options.value;
inp.focus();
CodeMirror.connect(inp, "blur", close);
} else if (button = dialog.getElementsByTagName("button")[0]) {
Expand All @@ -40,8 +46,8 @@
return close;
});

CodeMirror.defineExtension("openConfirm", function(template, callbacks) {
var dialog = dialogDiv(this, template);
CodeMirror.defineExtension("openConfirm", function(template, callbacks, options) {
var dialog = dialogDiv(this, template, options && options.bottom);
var buttons = dialog.getElementsByTagName("button");
var closed = false, me = this, blurring = 1;
function close() {
Expand All @@ -67,4 +73,4 @@
CodeMirror.connect(b, "focus", function() { ++blurring; });
}
});
})();
})();
174 changes: 43 additions & 131 deletions lib/util/formatting.js
Original file line number Diff line number Diff line change
@@ -1,138 +1,39 @@
// ============== Formatting extensions ============================
(function() {
// Define extensions for a few modes

CodeMirror.extendMode("css", {
commentStart: "/*",
commentEnd: "*/",
wordWrapChars: [";", "\\{", "\\}"],
autoFormatLineBreaks: function (text) {
return text.replace(new RegExp("(;|\\{|\\})([^\r\n])", "g"), "$1\n$2");
newlineAfterToken: function(type, content) {
return /^[;{}]$/.test(content);
}
});

function jsNonBreakableBlocks(text) {
var nonBreakableRegexes = [/for\s*?\((.*?)\)/,
/\"(.*?)(\"|$)/,
/\'(.*?)(\'|$)/,
/\/\*(.*?)(\*\/|$)/,
/\/\/.*/];
var nonBreakableBlocks = [];
for (var i = 0; i < nonBreakableRegexes.length; i++) {
var curPos = 0;
while (curPos < text.length) {
var m = text.substr(curPos).match(nonBreakableRegexes[i]);
if (m != null) {
nonBreakableBlocks.push({
start: curPos + m.index,
end: curPos + m.index + m[0].length
});
curPos += m.index + Math.max(1, m[0].length);
}
else { // No more matches
break;
}
}
}
nonBreakableBlocks.sort(function (a, b) {
return a.start - b.start;
});

return nonBreakableBlocks;
}

CodeMirror.extendMode("javascript", {
commentStart: "/*",
commentEnd: "*/",
wordWrapChars: [";", "\\{", "\\}"],

autoFormatLineBreaks: function (text) {
var curPos = 0;
var split = this.jsonMode ? function(str) {
return str.replace(/([,{])/g, "$1\n").replace(/}/g, "\n}");
} : function(str) {
return str.replace(/(;|\{|\})([^\r\n;])/g, "$1\n$2");
};
var nonBreakableBlocks = jsNonBreakableBlocks(text), res = "";
if (nonBreakableBlocks != null) {
for (var i = 0; i < nonBreakableBlocks.length; i++) {
if (nonBreakableBlocks[i].start > curPos) { // Break lines till the block
res += split(text.substring(curPos, nonBreakableBlocks[i].start));
curPos = nonBreakableBlocks[i].start;
}
if (nonBreakableBlocks[i].start <= curPos
&& nonBreakableBlocks[i].end >= curPos) { // Skip non-breakable block
res += text.substring(curPos, nonBreakableBlocks[i].end);
curPos = nonBreakableBlocks[i].end;
}
}
if (curPos < text.length)
res += split(text.substr(curPos));
// FIXME semicolons inside of for
newlineAfterToken: function(type, content, textAfter, state) {
if (this.jsonMode) {
return /^[\[,{]$/.test(content) || /^}/.test(textAfter);
} else {
res = split(text);
if (content == ";" && state.lexical && state.lexical.type == ")") return false;
return /^[;{}]$/.test(content) && !/^;/.test(textAfter);
}
return res.replace(/^\n*|\n*$/, "");
}
});

CodeMirror.extendMode("xml", {
commentStart: "<!--",
commentEnd: "-->",
wordWrapChars: [">"],

autoFormatLineBreaks: function (text) {
var lines = text.split("\n");
var reProcessedPortion = new RegExp("(^\\s*?<|^[^<]*?)(.+)(>\\s*?$|[^>]*?$)");
var reOpenBrackets = new RegExp("<", "g");
var reCloseBrackets = new RegExp("(>)([^\r\n])", "g");
for (var i = 0; i < lines.length; i++) {
var mToProcess = lines[i].match(reProcessedPortion);
if (mToProcess != null && mToProcess.length > 3) { // The line starts with whitespaces and ends with whitespaces
lines[i] = mToProcess[1]
+ mToProcess[2].replace(reOpenBrackets, "\n$&").replace(reCloseBrackets, "$1\n$2")
+ mToProcess[3];
continue;
}
}
return lines.join("\n");
newlineAfterToken: function(type, content, textAfter) {
return type == "tag" && />$/.test(content) || /^</.test(textAfter);
}
});

function localModeAt(cm, pos) {
return CodeMirror.innerMode(cm.getMode(), cm.getTokenAt(pos).state).mode;
}

function enumerateModesBetween(cm, line, start, end) {
var outer = cm.getMode(), text = cm.getLine(line);
if (end == null) end = text.length;
if (!outer.innerMode) return [{from: start, to: end, mode: outer}];
var state = cm.getTokenAt({line: line, ch: start}).state;
var mode = CodeMirror.innerMode(outer, state).mode;
var found = [], stream = new CodeMirror.StringStream(text);
stream.pos = stream.start = start;
for (;;) {
outer.token(stream, state);
var curMode = CodeMirror.innerMode(outer, state).mode;
if (curMode != mode) {
var cut = stream.start;
// Crappy heuristic to deal with the fact that a change in
// mode can occur both at the end and the start of a token,
// and we don't know which it was.
if (mode.name == "xml" && text.charAt(stream.pos - 1) == ">") cut = stream.pos;
found.push({from: start, to: cut, mode: mode});
start = cut;
mode = curMode;
}
if (stream.pos >= end) break;
stream.start = stream.pos;
}
if (start < end) found.push({from: start, to: end, mode: mode});
return found;
}

// Comment/uncomment the specified range
CodeMirror.defineExtension("commentRange", function (isComment, from, to) {
var curMode = localModeAt(this, from), cm = this;
this.operation(function() {
var cm = this, curMode = CodeMirror.innerMode(cm.getMode(), cm.getTokenAt(from).state).mode;
cm.operation(function() {
if (isComment) { // Comment range
cm.replaceRange(curMode.commentEnd, to);
cm.replaceRange(curMode.commentStart, from);
Expand Down Expand Up @@ -168,27 +69,38 @@
// Applies automatic formatting to the specified range
CodeMirror.defineExtension("autoFormatRange", function (from, to) {
var cm = this;
cm.operation(function () {
for (var cur = from.line, end = to.line; cur <= end; ++cur) {
var f = {line: cur, ch: cur == from.line ? from.ch : 0};
var t = {line: cur, ch: cur == end ? to.ch : null};
var modes = enumerateModesBetween(cm, cur, f.ch, t.ch), mangled = "";
var text = cm.getRange(f, t);
for (var i = 0; i < modes.length; ++i) {
var part = modes.length > 1 ? text.slice(modes[i].from, modes[i].to) : text;
if (mangled) mangled += "\n";
if (modes[i].mode.autoFormatLineBreaks) {
mangled += modes[i].mode.autoFormatLineBreaks(part);
} else mangled += text;
}
if (mangled != text) {
for (var count = 0, pos = mangled.indexOf("\n"); pos != -1; pos = mangled.indexOf("\n", pos + 1), ++count) {}
cm.replaceRange(mangled, f, t);
cur += count;
end += count;
var outer = cm.getMode(), text = cm.getRange(from, to).split("\n");
var state = CodeMirror.copyState(outer, cm.getTokenAt(from).state);
var tabSize = cm.getOption("tabSize");

var out = "", lines = 0, atSol = from.ch == 0;
function newline() {
out += "\n";
atSol = true;
++lines;
}

for (var i = 0; i < text.length; ++i) {
var stream = new CodeMirror.StringStream(text[i], tabSize);
while (!stream.eol()) {
var inner = CodeMirror.innerMode(outer, state);
var style = outer.token(stream, state), cur = stream.current();
stream.start = stream.pos;
if (!atSol || /\S/.test(cur)) {
out += cur;
atSol = false;
}
if (!atSol && inner.mode.newlineAfterToken &&
inner.mode.newlineAfterToken(style, cur, stream.string.slice(stream.pos) || text[i+1] || "", inner.state))
newline();
}
for (var cur = from.line + 1; cur <= end; ++cur)
if (!stream.pos && outer.blankLine) outer.blankLine(state);
if (!atSol) newline();
}

cm.operation(function () {
cm.replaceRange(out, from, to);
for (var cur = from.line + 1, end = from.line + lines; cur <= end; ++cur)
cm.indentLine(cur, "smart");
cm.setSelection(from, cm.getCursor(false));
});
Expand Down
30 changes: 17 additions & 13 deletions lib/util/javascript-hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
return arr.indexOf(item) != -1;
}

function scriptHint(editor, keywords, getToken) {
function scriptHint(editor, keywords, getToken, options) {
// Find the token at the cursor
var cur = editor.getCursor(), token = getToken(editor, cur), tprop = token;
// If it's not a 'word-style' token, ignore the token.
Expand Down Expand Up @@ -47,14 +47,15 @@
if (!context) var context = [];
context.push(tprop);
}
return {list: getCompletions(token, context, keywords),
return {list: getCompletions(token, context, keywords, options),
from: {line: cur.line, ch: token.start},
to: {line: cur.line, ch: token.end}};
}

CodeMirror.javascriptHint = function(editor) {
CodeMirror.javascriptHint = function(editor, options) {
return scriptHint(editor, javascriptKeywords,
function (e, cur) {return e.getTokenAt(cur);});
function (e, cur) {return e.getTokenAt(cur);},
options);
};

function getCoffeeScriptToken(editor, cur) {
Expand All @@ -75,8 +76,8 @@
return token;
}

CodeMirror.coffeescriptHint = function(editor) {
return scriptHint(editor, coffeescriptKeywords, getCoffeeScriptToken);
CodeMirror.coffeescriptHint = function(editor, options) {
return scriptHint(editor, coffeescriptKeywords, getCoffeeScriptToken, options);
};

var stringProps = ("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight " +
Expand All @@ -89,7 +90,7 @@
var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
"if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");

function getCompletions(token, context, keywords) {
function getCompletions(token, context, keywords, options) {
var found = [], start = token.string;
function maybeAdd(str) {
if (str.indexOf(start) == 0 && !arrayContains(found, str)) found.push(str);
Expand All @@ -105,13 +106,15 @@
// If this is a property, see if it belongs to some object we can
// find in the current environment.
var obj = context.pop(), base;
if (obj.className == "variable")
base = window[obj.string];
else if (obj.className == "string")
if (obj.className == "variable") {
if (options && options.additionalContext)
base = options.additionalContext[obj.string];
base = base || window[obj.string];
} else if (obj.className == "string") {
base = "";
else if (obj.className == "atom")
} else if (obj.className == "atom") {
base = 1;
else if (obj.className == "function") {
} else if (obj.className == "function") {
if (window.jQuery != null && (obj.string == '$' || obj.string == 'jQuery') &&
(typeof window.jQuery == 'function'))
base = window.jQuery();
Expand All @@ -124,8 +127,9 @@
}
else {
// If not, just look in the window object and any local scope
// (reading into JS mode internals to get at the local variables)
// (reading into JS mode internals to get at the local and global variables)
for (var v = token.state.localVars; v; v = v.next) maybeAdd(v.name);
for (var v = token.state.globalVars; v; v = v.next) maybeAdd(v.name);
gatherCompletions(window);
forEach(keywords, maybeAdd);
}
Expand Down
18 changes: 18 additions & 0 deletions lib/util/multiplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@ CodeMirror.multiplexingMode = function(outer /*, others */) {
return mode.indent(state.innerActive ? state.inner : state.outer, textAfter);
},

blankLine: function(state) {
var mode = state.innerActive ? state.innerActive.mode : outer;
if (mode.blankLine) {
mode.blankLine(state.innerActive ? state.inner : state.outer);
}
if (!state.innerActive) {
for (var i = 0; i < n_others; ++i) {
var other = others[i];
if (other.open === "\n") {
state.innerActive = other;
state.inner = CodeMirror.startState(other.mode, mode.indent ? mode.indent(state.outer, "") : 0);
}
}
} else if (mode.close === "\n") {
state.innerActive = state.inner = null;
}
},

electricChars: outer.electricChars,

innerMode: function(state) {
Expand Down
2 changes: 1 addition & 1 deletion lib/util/searchcursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
var line = cm.getLine(pos.line).slice(0, pos.ch), match = query.exec(line), start = 0;
while (match) {
start += match.index + 1;
line = line.slice(start);
line = line.slice(start);
query.lastIndex = 0;
var newmatch = query.exec(line);
if (newmatch) match = newmatch;
Expand Down
2 changes: 1 addition & 1 deletion lib/util/simple-hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
return;
}

var result = getHints(editor);
var result = getHints(editor, givenOptions);
if (!result || !result.list.length) return;
var completions = result.list;
function insert(str) {
Expand Down
26 changes: 22 additions & 4 deletions mode/clike/clike.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
CodeMirror.defineMode("clike", function(config, parserConfig) {
var indentUnit = config.indentUnit,
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
dontAlignCalls = parserConfig.dontAlignCalls,
keywords = parserConfig.keywords || {},
builtin = parserConfig.builtin || {},
blockKeywords = parserConfig.blockKeywords || {},
Expand Down Expand Up @@ -89,7 +91,10 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
this.prev = prev;
}
function pushContext(state, col, type) {
return state.context = new Context(state.indented, col, type, null, state.context);
var indent = state.indented;
if (state.context && state.context.type == "statement")
indent = state.context.indented;
return state.context = new Context(indent, col, type, null, state.context);
}
function popContext(state) {
var t = state.context.type;
Expand Down Expand Up @@ -123,7 +128,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
if (style == "comment" || style == "meta") return style;
if (ctx.align == null) ctx.align = true;

if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
if ((curPunc == ";" || curPunc == ":" || curPunc == ",") && ctx.type == "statement") popContext(state);
else if (curPunc == "{") pushContext(state, stream.column(), "}");
else if (curPunc == "[") pushContext(state, stream.column(), "]");
else if (curPunc == "(") pushContext(state, stream.column(), ")");
Expand All @@ -145,7 +150,8 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
var closing = firstChar == ctx.type;
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
else if (dontAlignCalls && ctx.type == ")" && !closing) return ctx.indented + statementIndentUnit;
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
else return ctx.indented + (closing ? 0 : indentUnit);
},
Expand All @@ -166,7 +172,19 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {

function cppHook(stream, state) {
if (!state.startOfLine) return false;
stream.skipToEnd();
for (;;) {
if (stream.skipTo("\\")) {
stream.next();
if (stream.eol()) {
state.tokenize = cppHook;
break;
}
} else {
stream.skipToEnd();
state.tokenize = null;
break;
}
}
return "meta";
}

Expand Down
23 changes: 20 additions & 3 deletions mode/css/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ CodeMirror.defineMode("css", function(config) {
else if (/[;{}\[\]\(\)]/.test(ch)) {
return ret(null, ch);
}
else if (ch == "u" && stream.match("rl(")) {
stream.backUp(1);
state.tokenize = tokenParenthesized;
return ret("property", "variable");
}
else {
stream.eatWhile(/[\w\\\-]/);
return ret("property", "variable");
Expand Down Expand Up @@ -267,19 +272,31 @@ CodeMirror.defineMode("css", function(config) {
return ret("comment", "comment");
}

function tokenString(quote) {
function tokenString(quote, nonInclusive) {
return function(stream, state) {
var escaped = false, ch;
while ((ch = stream.next()) != null) {
if (ch == quote && !escaped)
break;
escaped = !escaped && ch == "\\";
}
if (!escaped) state.tokenize = tokenBase;
if (!escaped) {
if (nonInclusive) stream.backUp(1);
state.tokenize = tokenBase;
}
return ret("string", "string");
};
}

function tokenParenthesized(stream, state) {
stream.next(); // Must be '('
if (!stream.match(/\s*[\"\']/, false))
state.tokenize = tokenString(")", true);
else
state.tokenize = tokenBase;
return ret(null, "(");
}

return {
startState: function(base) {
return {tokenize: tokenBase,
Expand Down Expand Up @@ -335,7 +352,7 @@ CodeMirror.defineMode("css", function(config) {
// sequence of selectors:
// One or more of the named type of selector chained with commas.

if (stream.eatSpace()) return null;
if (state.tokenize == tokenBase && stream.eatSpace()) return null;
var style = state.tokenize(stream, state);

// Changing style returned based on context
Expand Down
4 changes: 2 additions & 2 deletions mode/diff/diff.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
CodeMirror.defineMode("diff", function() {

var TOKEN_NAMES = {
'+': 'tag',
'-': 'string',
'+': 'positive',
'-': 'negative',
'@': 'meta'
};

Expand Down
406 changes: 203 additions & 203 deletions mode/ecl/ecl.js

Large diffs are not rendered by default.

84 changes: 42 additions & 42 deletions mode/ecl/index.html
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
<!doctype html>
<html>
<head>
<title>CodeMirror: ECL mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="ecl.js"></script>
<link rel="stylesheet" href="../../doc/docs.css">
<style>.CodeMirror {border: 1px solid black;}</style>
</head>
<body>
<h1>CodeMirror: ECL mode</h1>
<form><textarea id="code" name="code">
/*
sample useless code to demonstrate ecl syntax highlighting
this is a multiline comment!
*/

// this is a singleline comment!

import ut;
r :=
record
string22 s1 := '123';
integer4 i1 := 123;
end;
#option('tmp', true);
d := dataset('tmp::qb', r, thor);
output(d);
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
tabMode: "indent",
matchBrackets: true,
});
</script>

<p>Based on CodeMirror's clike mode. For more information see <a href="http://hpccsystems.com">HPCC Systems</a> web site.</p>
<p><strong>MIME types defined:</strong> <code>text/x-ecl</code>.</p>

</body>
</html>
<!doctype html>
<html>
<head>
<title>CodeMirror: ECL mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="ecl.js"></script>
<link rel="stylesheet" href="../../doc/docs.css">
<style>.CodeMirror {border: 1px solid black;}</style>
</head>
<body>
<h1>CodeMirror: ECL mode</h1>
<form><textarea id="code" name="code">
/*
sample useless code to demonstrate ecl syntax highlighting
this is a multiline comment!
*/

// this is a singleline comment!

import ut;
r :=
record
string22 s1 := '123';
integer4 i1 := 123;
end;
#option('tmp', true);
d := dataset('tmp::qb', r, thor);
output(d);
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
tabMode: "indent",
matchBrackets: true,
});
</script>

<p>Based on CodeMirror's clike mode. For more information see <a href="http://hpccsystems.com">HPCC Systems</a> web site.</p>
<p><strong>MIME types defined:</strong> <code>text/x-ecl</code>.</p>

</body>
</html>
6 changes: 3 additions & 3 deletions mode/htmlembedded/htmlembedded.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ CodeMirror.defineMode("htmlembedded", function(config, parserConfig) {
htmlMixedMode = htmlMixedMode || CodeMirror.getMode(config, "htmlmixed");
return {
token : parserConfig.startOpen ? scriptingDispatch : htmlDispatch,
htmlState : htmlMixedMode.startState(),
scriptState : scriptingMode.startState()
htmlState : CodeMirror.startState(htmlMixedMode),
scriptState : CodeMirror.startState(scriptingMode)
};
},

Expand All @@ -46,7 +46,7 @@ CodeMirror.defineMode("htmlembedded", function(config, parserConfig) {
indent: function(state, textAfter) {
if (state.token == htmlDispatch)
return htmlMixedMode.indent(state.htmlState, textAfter);
else
else if (scriptingMode.indent)
return scriptingMode.indent(state.scriptState, textAfter);
},

Expand Down
2 changes: 1 addition & 1 deletion mode/htmlmixed/htmlmixed.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CodeMirror.defineMode("htmlmixed", function(config) {

function html(stream, state) {
var style = htmlMode.token(stream, state.htmlState);
if (style == "tag" && stream.current() == ">" && state.htmlState.context) {
if (/(?:^|\s)tag(?:\s|$)/.test(style) && stream.current() == ">" && state.htmlState.context) {
if (/^script$/i.test(state.htmlState.context.tagName)) {
state.token = javascript;
state.localState = jsMode.startState(htmlMode.indent(state.htmlState, ""));
Expand Down
98 changes: 98 additions & 0 deletions mode/http/http.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
CodeMirror.defineMode("http", function() {
function failFirstLine(stream, state) {
stream.skipToEnd();
state.cur = header;
return "error";
}

function start(stream, state) {
if (stream.match(/^HTTP\/\d\.\d/)) {
state.cur = responseStatusCode;
return "keyword";
} else if (stream.match(/^[A-Z]+/) && /[ \t]/.test(stream.peek())) {
state.cur = requestPath;
return "keyword";
} else {
return failFirstLine(stream, state);
}
}

function responseStatusCode(stream, state) {
var code = stream.match(/^\d+/);
if (!code) return failFirstLine(stream, state);

state.cur = responseStatusText;
var status = Number(code[0]);
if (status >= 100 && status < 200) {
return "positive informational";
} else if (status >= 200 && status < 300) {
return "positive success";
} else if (status >= 300 && status < 400) {
return "positive redirect";
} else if (status >= 400 && status < 500) {
return "negative client-error";
} else if (status >= 500 && status < 600) {
return "negative server-error";
} else {
return "error";
}
}

function responseStatusText(stream, state) {
stream.skipToEnd();
state.cur = header;
return null;
}

function requestPath(stream, state) {
stream.eatWhile(/\S/);
state.cur = requestProtocol;
return "string-2";
}

function requestProtocol(stream, state) {
if (stream.match(/^HTTP\/\d\.\d$/)) {
state.cur = header;
return "keyword";
} else {
return failFirstLine(stream, state);
}
}

function header(stream, state) {
if (stream.sol() && !stream.eat(/[ \t]/)) {
if (stream.match(/^.*?:/)) {
return "atom";
} else {
stream.skipToEnd();
return "error";
}
} else {
stream.skipToEnd();
return "string";
}
}

function body(stream, state) {
stream.skipToEnd();
return null;
}

return {
token: function(stream, state) {
var cur = state.cur;
if (cur != header && cur != body && stream.eatSpace()) return null;
return cur(stream, state);
},

blankLine: function(state) {
state.cur = body;
},

startState: function() {
return {cur: start};
}
};
});

CodeMirror.defineMIME("message/http", "http");
32 changes: 32 additions & 0 deletions mode/http/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: HTTP mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="http.js"></script>
<link rel="stylesheet" href="../../doc/docs.css">
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
</head>
<body>
<h1>CodeMirror: HTTP mode</h1>

<div><textarea id="code" name="code">
POST /somewhere HTTP/1.1
Host: example.com
If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT
Content-Type: application/x-www-form-urlencoded;
charset=utf-8
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.11 (KHTML, like Gecko) Ubuntu/12.04 Chromium/20.0.1132.47 Chrome/20.0.1132.47 Safari/536.11

This is the request body!
</textarea></div>

<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
</script>

<p><strong>MIME types defined:</strong> <code>message/http</code>.</p>
</body>
</html>
12 changes: 10 additions & 2 deletions mode/javascript/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,19 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
return true;
}
function register(varname) {
function inList(list) {
for (var v = list; v; v = v.next)
if (v.name == varname) return true;
return false;
}
var state = cx.state;
if (state.context) {
cx.marked = "def";
for (var v = state.localVars; v; v = v.next)
if (v.name == varname) return;
if (inList(state.localVars)) return;
state.localVars = {name: varname, next: state.localVars};
} else {
if (inList(state.globalVars)) return;
state.globalVars = {name: varname, next: state.globalVars};
}
}

Expand Down Expand Up @@ -364,6 +371,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
cc: [],
lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
localVars: parserConfig.localVars,
globalVars: parserConfig.globalVars,
context: parserConfig.localVars && {vars: parserConfig.localVars},
indented: 0
};
Expand Down
5 changes: 3 additions & 2 deletions mode/markdown/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<title>CodeMirror: Markdown mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="../../lib/util/continuelist.js"></script>
<script src="../xml/xml.js"></script>
<script src="markdown.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
Expand Down Expand Up @@ -328,8 +329,8 @@ <h1>CodeMirror: Markdown mode</h1>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
mode: 'markdown',
lineNumbers: true,
matchBrackets: true,
theme: "default"
theme: "default",
extraKeys: {"Enter": "newlineAndIndentContinueMarkdownList"}
});
</script>

Expand Down
4 changes: 2 additions & 2 deletions mode/markdown/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
return getType(state);
}

if (ch === '!' && stream.match(/\[.*\] ?(?:\(|\[)/, false)) {
stream.match(/\[.*\]/);
if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) {
stream.match(/\[[^\]]*\]/);
state.inline = state.f = linkHref;
return image;
}
Expand Down
14 changes: 14 additions & 0 deletions mode/markdown/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,20 @@ MT.testMode(
]
);

// Inline link with image
MT.testMode(
'linkImage',
'[![foo](http://example.com/)](http://example.com/) bar',
[
'link', '[',
'tag', '![foo]',
'string', '(http://example.com/)',
'link', ']',
'string', '(http://example.com/)',
null, ' bar'
]
);

// Inline link with Em
MT.testMode(
'linkEm',
Expand Down
2 changes: 1 addition & 1 deletion mode/php/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ <h1>CodeMirror: PHP mode</h1>

<p>Simple HTML/PHP mode based on
the <a href="../clike/">C-like</a> mode. Depends on XML,
JavaScript, CSS, and C-like modes.</p>
JavaScript, CSS, HTMLMixed, and C-like modes.</p>

<p><strong>MIME types defined:</strong> <code>application/x-httpd-php</code> (HTML with PHP code), <code>text/x-php</code> (plain, non-wrapped PHP code).</p>
</body>
Expand Down
3 changes: 2 additions & 1 deletion mode/php/php.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"die echo empty exit eval include include_once isset list require require_once return " +
"print unset __halt_compiler self static parent"),
blockKeywords: keywords("catch do else elseif for foreach if switch try while"),
atoms: keywords("true false null TRUE FALSE NULL"),
atoms: keywords("true false null TRUE FALSE NULL __CLASS__ __DIR__ __FILE__ __LINE__ __METHOD__ __FUNCTION__ __NAMESPACE__"),
builtin: keywords("func_num_args func_get_arg func_get_args strlen strcmp strncmp strcasecmp strncasecmp each error_reporting define defined trigger_error user_error set_error_handler restore_error_handler get_declared_classes get_loaded_extensions extension_loaded get_extension_funcs debug_backtrace constant bin2hex sleep usleep time mktime gmmktime strftime gmstrftime strtotime date gmdate getdate localtime checkdate flush wordwrap htmlspecialchars htmlentities html_entity_decode md5 md5_file crc32 getimagesize image_type_to_mime_type phpinfo phpversion phpcredits strnatcmp strnatcasecmp substr_count strspn strcspn strtok strtoupper strtolower strpos strrpos strrev hebrev hebrevc nl2br basename dirname pathinfo stripslashes stripcslashes strstr stristr strrchr str_shuffle str_word_count strcoll substr substr_replace quotemeta ucfirst ucwords strtr addslashes addcslashes rtrim str_replace str_repeat count_chars chunk_split trim ltrim strip_tags similar_text explode implode setlocale localeconv parse_str str_pad chop strchr sprintf printf vprintf vsprintf sscanf fscanf parse_url urlencode urldecode rawurlencode rawurldecode readlink linkinfo link unlink exec system escapeshellcmd escapeshellarg passthru shell_exec proc_open proc_close rand srand getrandmax mt_rand mt_srand mt_getrandmax base64_decode base64_encode abs ceil floor round is_finite is_nan is_infinite bindec hexdec octdec decbin decoct dechex base_convert number_format fmod ip2long long2ip getenv putenv getopt microtime gettimeofday getrusage uniqid quoted_printable_decode set_time_limit get_cfg_var magic_quotes_runtime set_magic_quotes_runtime get_magic_quotes_gpc get_magic_quotes_runtime import_request_variables error_log serialize unserialize memory_get_usage var_dump var_export debug_zval_dump print_r highlight_file show_source highlight_string ini_get ini_get_all ini_set ini_alter ini_restore get_include_path set_include_path restore_include_path setcookie header headers_sent connection_aborted connection_status ignore_user_abort parse_ini_file is_uploaded_file move_uploaded_file intval floatval doubleval strval gettype settype is_null is_resource is_bool is_long is_float is_int is_integer is_double is_real is_numeric is_string is_array is_object is_scalar ereg ereg_replace eregi eregi_replace split spliti join sql_regcase dl pclose popen readfile rewind rmdir umask fclose feof fgetc fgets fgetss fread fopen fpassthru ftruncate fstat fseek ftell fflush fwrite fputs mkdir rename copy tempnam tmpfile file file_get_contents stream_select stream_context_create stream_context_set_params stream_context_set_option stream_context_get_options stream_filter_prepend stream_filter_append fgetcsv flock get_meta_tags stream_set_write_buffer set_file_buffer set_socket_blocking stream_set_blocking socket_set_blocking stream_get_meta_data stream_register_wrapper stream_wrapper_register stream_set_timeout socket_set_timeout socket_get_status realpath fnmatch fsockopen pfsockopen pack unpack get_browser crypt opendir closedir chdir getcwd rewinddir readdir dir glob fileatime filectime filegroup fileinode filemtime fileowner fileperms filesize filetype file_exists is_writable is_writeable is_readable is_executable is_file is_dir is_link stat lstat chown touch clearstatcache mail ob_start ob_flush ob_clean ob_end_flush ob_end_clean ob_get_flush ob_get_clean ob_get_length ob_get_level ob_get_status ob_get_contents ob_implicit_flush ob_list_handlers ksort krsort natsort natcasesort asort arsort sort rsort usort uasort uksort shuffle array_walk count end prev next reset current key min max in_array array_search extract compact array_fill range array_multisort array_push array_pop array_shift array_unshift array_splice array_slice array_merge array_merge_recursive array_keys array_values array_count_values array_reverse array_reduce array_pad array_flip array_change_key_case array_rand array_unique array_intersect array_intersect_assoc array_diff array_diff_assoc array_sum array_filter array_map array_chunk array_key_exists pos sizeof key_exists assert assert_options version_compare ftok str_rot13 aggregate session_name session_module_name session_save_path session_id session_regenerate_id session_decode session_register session_unregister session_is_registered session_encode session_start session_destroy session_unset session_set_save_handler session_cache_limiter session_cache_expire session_set_cookie_params session_get_cookie_params session_write_close preg_match preg_match_all preg_replace preg_replace_callback preg_split preg_quote preg_grep overload ctype_alnum ctype_alpha ctype_cntrl ctype_digit ctype_lower ctype_graph ctype_print ctype_punct ctype_space ctype_upper ctype_xdigit virtual apache_request_headers apache_note apache_lookup_uri apache_child_terminate apache_setenv apache_response_headers apache_get_version getallheaders mysql_connect mysql_pconnect mysql_close mysql_select_db mysql_create_db mysql_drop_db mysql_query mysql_unbuffered_query mysql_db_query mysql_list_dbs mysql_list_tables mysql_list_fields mysql_list_processes mysql_error mysql_errno mysql_affected_rows mysql_insert_id mysql_result mysql_num_rows mysql_num_fields mysql_fetch_row mysql_fetch_array mysql_fetch_assoc mysql_fetch_object mysql_data_seek mysql_fetch_lengths mysql_fetch_field mysql_field_seek mysql_free_result mysql_field_name mysql_field_table mysql_field_len mysql_field_type mysql_field_flags mysql_escape_string mysql_real_escape_string mysql_stat mysql_thread_id mysql_client_encoding mysql_get_client_info mysql_get_host_info mysql_get_proto_info mysql_get_server_info mysql_info mysql mysql_fieldname mysql_fieldtable mysql_fieldlen mysql_fieldtype mysql_fieldflags mysql_selectdb mysql_createdb mysql_dropdb mysql_freeresult mysql_numfields mysql_numrows mysql_listdbs mysql_listtables mysql_listfields mysql_db_name mysql_dbname mysql_tablename mysql_table_name pg_connect pg_pconnect pg_close pg_connection_status pg_connection_busy pg_connection_reset pg_host pg_dbname pg_port pg_tty pg_options pg_ping pg_query pg_send_query pg_cancel_query pg_fetch_result pg_fetch_row pg_fetch_assoc pg_fetch_array pg_fetch_object pg_fetch_all pg_affected_rows pg_get_result pg_result_seek pg_result_status pg_free_result pg_last_oid pg_num_rows pg_num_fields pg_field_name pg_field_num pg_field_size pg_field_type pg_field_prtlen pg_field_is_null pg_get_notify pg_get_pid pg_result_error pg_last_error pg_last_notice pg_put_line pg_end_copy pg_copy_to pg_copy_from pg_trace pg_untrace pg_lo_create pg_lo_unlink pg_lo_open pg_lo_close pg_lo_read pg_lo_write pg_lo_read_all pg_lo_import pg_lo_export pg_lo_seek pg_lo_tell pg_escape_string pg_escape_bytea pg_unescape_bytea pg_client_encoding pg_set_client_encoding pg_meta_data pg_convert pg_insert pg_update pg_delete pg_select pg_exec pg_getlastoid pg_cmdtuples pg_errormessage pg_numrows pg_numfields pg_fieldname pg_fieldsize pg_fieldtype pg_fieldnum pg_fieldprtlen pg_fieldisnull pg_freeresult pg_result pg_loreadall pg_locreate pg_lounlink pg_loopen pg_loclose pg_loread pg_lowrite pg_loimport pg_loexport echo print global static exit array empty eval isset unset die include require include_once require_once"),
multiLineStrings: true,
hooks: {
"$": function(stream, state) {
Expand Down
Empty file modified mode/properties/index.html
100755 → 100644
Empty file.
Empty file modified mode/properties/properties.js
100755 → 100644
Empty file.
60 changes: 60 additions & 0 deletions mode/sql/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>SQL Mode for CodeMirror</title>
<link rel="stylesheet" href="../../lib/codemirror.css" />
<script src="../../lib/codemirror.js"></script>
<script src="sql.js"></script>
<style>
.CodeMirror {
border-top: 1px solid black;
border-bottom: 1px solid black;
}
</style>
<link rel="stylesheet" href="../../doc/docs.css">
<script>
var init = function() {
var mime = 'text/x-mariadb';

// get mime type
if (window.location.href.indexOf('mime=') > -1) {
mime = window.location.href.substr(window.location.href.indexOf('mime=') + 5);
}

window.editor = CodeMirror.fromTextArea(document.getElementById('code'), {
mode: mime,
indentWithTabs: true,
smartIndent: true,
lineNumbers: true,
matchBrackets : true,
autofocus: true
});
};
</script>
</head>
<body onload="init();">
<h1>SQL Mode for CodeMirror</h1>
<form>
<textarea id="code" name="code">-- SQL Mode for CodeMirror
SELECT SQL_NO_CACHE DISTINCT
@var1 AS `val1`, @'val2', @global.'sql_mode',
1.1 AS `float_val`, 0.09e3 AS `int_with_esp`,
0xFA5 AS `hex`, x'fa5' AS `hex2`, 0b101 AS `bin`, b'101' AS `bin2`,
'myString', UNKNOWN
FROM DUAL
-- space needed after '--'
# 1 line comment
/* multiline
comment! */
LIMIT 1 OFFSET 0;
</textarea>
</form>
<p><strong>MIME types defined:</strong>
<code><a href="?mime=text/x-sql">text/x-sql</a></code>,
<code><a href="?mime=text/x-mysql">text/x-mysql</a></code>,
<code><a href="?mime=text/x-mariadb">text/x-mariadb</a></code>,
<code><a href="?mime=text/x-plsql">text/x-plsql</a></code>.
</p>
</body>
</html>
Loading