Showing with 2,702 additions and 1,406 deletions.
  1. +37 −66 demo/closetag.html
  2. +2 −1 demo/vim.html
  3. +2 −0 doc/compress.html
  4. +47 −10 doc/manual.html
  5. +42 −0 doc/oldrelease.html
  6. +4 −0 doc/upgrade_v3.html
  7. +18 −47 index.html
  8. +1,515 −835 keymap/vim.js
  9. +2 −0 lib/codemirror.css
  10. +240 −159 lib/codemirror.js
  11. +85 −143 lib/util/closetag.js
  12. +43 −131 lib/util/formatting.js
  13. +1 −1 lib/util/searchcursor.js
  14. +14 −2 mode/clike/clike.js
  15. +2 −2 mode/diff/diff.js
  16. +1 −1 mode/htmlmixed/htmlmixed.js
  17. +98 −0 mode/http/http.js
  18. +32 −0 mode/http/index.html
  19. +1 −1 mode/php/index.html
  20. +1 −0 mode/php/php.js
  21. +9 −5 mode/xml/xml.js
  22. +1 −1 package.json
  23. +2 −0 test/index.html
  24. +69 −0 test/test.js
  25. +433 −0 test/vim_test.js
  26. +1 −1 theme/twilight.css
103 changes: 37 additions & 66 deletions demo/closetag.html
Original file line number Diff line number Diff line change
@@ -1,66 +1,37 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: Close-Tag Demo</title>
<link rel="stylesheet" href="../lib/codemirror.css">
<script src="../lib/codemirror.js"></script>
<script src="../lib/util/closetag.js"></script>
<script src="../mode/xml/xml.js"></script>
<script src="../mode/javascript/javascript.js"></script>
<script src="../mode/css/css.js"></script>
<script src="../mode/htmlmixed/htmlmixed.js"></script>
<link rel="stylesheet" href="../doc/docs.css">
<style type="text/css">
.CodeMirror {border-top: 1px solid #eee; border-bottom: 1px solid #eee;}
</style>
</head>
<body>

<h1>Close-Tag Demo</h1>
<ul>
<li>Type an html tag. When you type '>' or '/', the tag will auto-close/complete. Block-level tags will indent.</li>
<li>There are options for disabling tag closing or customizing the list of tags to indent.</li>
<li>Works with "text/html" (based on htmlmixed.js or xml.js) mode.</li>
<li>View source for key binding details.</li>
</p>

<form><textarea id="code" name="code"></textarea></form>

<script type="text/javascript">
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
mode: 'text/html',

//closeTagEnabled: false, // Set this option to disable tag closing behavior without having to remove the key bindings.
//closeTagIndent: false, // Pass false or an array of tag names to override the default indentation behavior.

extraKeys: {
"'>'": function(cm) { cm.closeTag(cm, '>'); },
"'/'": function(cm) { cm.closeTag(cm, '/'); }
},

/*
// extraKeys is the easier way to go, but if you need native key event processing, this should work too.
onKeyEvent: function(cm, e) {
if (e.type == 'keydown') {
var c = e.keyCode || e.which;
if (c == 190 || c == 191) {
try {
cm.closeTag(cm, c == 190 ? '>' : '/');
e.stop();
return true;
} catch (e) {
if (e != CodeMirror.Pass) throw e;
}
}
}
return false;
},
*/

wordWrap: true
});
</script>

</body>
</html>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: Close-Tag Demo</title>
<link rel="stylesheet" href="../lib/codemirror.css">
<script src="../lib/codemirror.js"></script>
<script src="../lib/util/closetag.js"></script>
<script src="../mode/xml/xml.js"></script>
<script src="../mode/javascript/javascript.js"></script>
<script src="../mode/css/css.js"></script>
<script src="../mode/htmlmixed/htmlmixed.js"></script>
<link rel="stylesheet" href="../doc/docs.css">
<style type="text/css">
.CodeMirror {border-top: 1px solid #888; border-bottom: 1px solid #888;}
</style>
</head>
<body>

<h1>Close-Tag Demo</h1>
<ul>
<li>Type an html tag. When you type '>' or '/', the tag will auto-close/complete. Block-level tags will indent.</li>
<li>There are options for disabling tag closing or customizing the list of tags to indent.</li>
<li>Works with "text/html" (based on htmlmixed.js or xml.js) mode.</li>
<li>View source for key binding details.</li>
</ul>

<form><textarea id="code" name="code"><html</textarea></form>

<script type="text/javascript">
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
mode: 'text/html',
autoCloseTags: true
});
</script>
</body>
</html>
3 changes: 2 additions & 1 deletion demo/vim.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ <h1>CodeMirror: Vim bindings demo</h1>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
mode: "text/x-csrc",
keyMap: "vim"
keyMap: "vim",
showCursorWhenSelecting: true
});
</script>

Expand Down
2 changes: 2 additions & 0 deletions doc/compress.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ <h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMi
<input type="hidden" id="download" name="download" value="codemirror-compressed.js"/>
<p>Version: <select id="version" onchange="setVersion(this);" style="padding: 1px">
<option value="http://codemirror.net/">HEAD</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v3.0rc2;f=">3.0rc2</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v3.0rc1;f=">3.0rc1</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v3.0beta2;f=">3.0beta2</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=v3.0beta1;f=">3.0beta1</option>
Expand Down Expand Up @@ -80,6 +81,7 @@ <h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMi
<option value="http://codemirror.net/mode/haxe/haxe.js">haxe.js</option>
<option value="http://codemirror.net/mode/htmlembedded/htmlembedded.js">htmlembedded.js</option>
<option value="http://codemirror.net/mode/htmlmixed/htmlmixed.js">htmlmixed.js</option>
<option value="http://codemirror.net/mode/http/http.js">http.js</option>
<option value="http://codemirror.net/mode/javascript/javascript.js">javascript.js</option>
<option value="http://codemirror.net/mode/jinja2/jinja2.js">jinja2.js</option>
<option value="http://codemirror.net/mode/less/less.js">less.js</option>
Expand Down
57 changes: 47 additions & 10 deletions doc/manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,6 @@ <h2 id="config">Configuration</h2>
indentation (only works if the mode supports indentation).
Default is true.</dd>

<dt id="option_autoClearEmptyLines"><code>autoClearEmptyLines (boolean)</code></dt>
<dd>When turned on (default is off), this will
automatically clear lines consisting only of whitespace when the
cursor leaves them. This is mostly useful to prevent auto
indentation from introducing trailing whitespace in a file.</dd>

<dt id="option_keyMap"><code>keyMap (string)</code></dt>
<dd>Configures the keymap to use. The default
is <code>"default"</code>, which is the only keymap defined
Expand Down Expand Up @@ -218,6 +212,10 @@ <h2 id="config">Configuration</h2>
simply <code>true</code>), focusing of the editor is also
disallowed.</dd>

<dt id="option_showCursorWhenSelecting"><code>showCursorWhenSelecting (boolean)</code></dt>
<dd>Whether the cursor should be drawn when a selection is
active. Defaults to false.</dd>

<dt id="option_undoDepth"><code>undoDepth (integer)</code></dt>
<dd>The maximum number of undo levels that the editor stores.
Defaults to 40.</dd>
Expand Down Expand Up @@ -591,16 +589,22 @@ <h2 id="api">Programming API</h2>
or the end of the selection must be retrieved. If it is not
given, the current cursor pos, i.e. the side of the selection
that would move if you pressed an arrow key, is chosen.
A <code>{line, ch}</code> object will be returned.</dd>
Alternatively, you can pass one of the
strings <code>"start"</code>, <code>"end"</code>, <code>"head"</code>
(same as not passing anything), or <code>"anchor"</code> (the
opposite). A <code>{line, ch}</code> object will be
returned.</dd>
<dt id="somethingSelected"><code>somethingSelected() → boolean</code></dt>
<dd>Return true if any text is selected.</dd>
<dt id="setCursor"><code>setCursor(pos)</code></dt>
<dd>Set the cursor position. You can either pass a
single <code>{line, ch}</code> object, or the line and the
character as two separate parameters.</dd>
<dt id="setSelection"><code>setSelection(start, end)</code></dt>
<dd>Set the selection range. <code>start</code>
and <code>end</code> should be <code>{line, ch}</code> objects.</dd>
<dt id="setSelection"><code>setSelection(anchor, head)</code></dt>
<dd>Set the selection range. <code>anchor</code>
and <code>head</code> should be <code>{line, ch}</code>
objects. <code>head</code> defaults to <code>anchor</code> when
not givne.</dd>

<dt id="getLine"><code>getLine(n) → string</code></dt>
<dd>Get the content of line <code>n</code>.</dd>
Expand Down Expand Up @@ -647,6 +651,23 @@ <h2 id="api">Programming API</h2>
the mode specification, rather than the resolved, instantiated
<a href="#defineMode">mode object</a>.</dd>

<dt id="addKeyMap"><code>addKeyMap(map)</code></dt>
<dd>Attach an additional <a href="#keymaps">keymap</a> to the editor. This is mostly
useful for add-ons that need to register some key handlers
without trampling on
the <a href="#option_extraKeys"><code>extraKeys</code></a>
option. Maps added in this way have a lower precedence
than <code>extraKeys</code>, a higher precedence than the
base <a href="#option_keyMap"><code>keyMap</code></a>, and
between them, the maps added earlier have a higher precedence
than those added later.</dd>
<dt id="removeKeyMap"><code>removeKeyMap(map)</code></dt>
<dd>Disable a keymap added
with <a href="#addKeyMap"><code>addKeyMap</code></a>. Either
pass in the keymap object itself, or a string, which will be
compared against the <code>name</code> property of the active
keymaps.</dd>

<dt id="on"><code>on(type, func)</code></dt>
<dd>Register an event handler for the given event type (a
string) on the editor instance. There is also
Expand Down Expand Up @@ -943,6 +964,22 @@ <h2 id="api">Programming API</h2>
it, you should probably follow up by calling this method to
ensure CodeMirror is still looking as intended.</dd>

<dt id="extendSelection"><code>extendSelection(pos, pos2)</code></dt>
<dd>Similar
to <a href="#setSelection"><code>setSelection</code></a>, but
will, if shift is held or
the <a href="#setExtending">extending</a> flag is set, move the
head of the selection while leaving the anchor at its current
place. <code>pos2</code> is optional, and can be passed to
ensure a region (for example a word or paragraph) will end up
selected (in addition to whatever lies between that region and
the current anchor).</dd>
<dt id="setExtending"><code>setExtending(bool)</code></dt>
<dd>Sets or clears the 'extending' flag, which acts similar to
the shift key, in that it will cause cursor movement and calls
to <a href="#extendSelection"><code>extendSelection</code></a>
to leave the selection anchor in place.</dd>

<dt id="getInputField"><code>getInputField() → textarea</code></dt>
<dd>Returns the hidden textarea used to read input.</dd>
<dt id="getWrapperElement"><code>getWrapperElement() → node</code></dt>
Expand Down
42 changes: 42 additions & 0 deletions doc/oldrelease.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,48 @@ <h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMi
</pre>
</div>

<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
4 changes: 4 additions & 0 deletions doc/upgrade_v3.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ <h1><span class="logo-braces">{ }</span> <a href="http://codemirror.net/">CodeMi
trouble. But it does introduce a number of incompatibilities. Please
at least skim this text before upgrading.</p>

<p>Note that <strong>version 3 drops full support for Internet
Explorer 7</strong>. The editor will mostly work on that browser, but
it'll be significantly glitchy.</p>

<h2 id=dom>DOM structure</h2>

<p>This one is the most likely to cause problems. The internal
Expand Down
65 changes: 18 additions & 47 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ <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>
Expand Down Expand Up @@ -291,6 +292,23 @@ <h2>Reading material</h2>

<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="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="doc/manual.html#addKeyMap"><code>addKeyMap</code></a> and <a href="doc/manual.html#removeKeyMap"><code>removeKeyMap</code></a> methods.</li>
<li>Rewrite <code>formatting</code> and <code>closetag</code> add-ons.</li>
<li>Full <a href="https://github.com/marijnh/CodeMirror/compare/v3.0rc1...v3.0rc2">list of patches</a>.</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">
Expand All @@ -307,11 +325,6 @@ <h2 id=releases>Releases</h2>

<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="doc/upgrade_v3.html">upgrading
guide</a> for more information. Changes since beta 2:</p>

<ul class="rel-note">
<li>New theme: <a href="demo/theme.html?solarized%20light">Solarized</a>.</li>
<li>Introduce <a href="doc/manual.html#addLineClass"><code>addLineClass</code></a>
Expand Down Expand Up @@ -432,48 +445,6 @@ <h2 id=releases>Releases</h2>
<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>

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

</div></div>
Expand Down
Loading