Permalink
Browse files

Put codemirror in the master branch as well

People having problems using js-beautifier checkout locally.

If anyone's willing to update CodeMirror to a recent version, they're
most welcome.

I'm not using git externals, as they seem to bork the github page
generation silently and completely, if used under gh-pages branch (which
is exactly what I'd need) (an up-to-date copy, not a silent complete
bork, that is).
  • Loading branch information...
1 parent 1c865b7 commit 5d486b4612eaf387fcbd788a26392418e97296de @einars einars committed Dec 21, 2012
Showing with 25,711 additions and 0 deletions.
  1. +23 −0 third-party/codemirror2/LICENSE
  2. +6 −0 third-party/codemirror2/README.md
  3. +72 −0 third-party/codemirror2/demo/activeline.html
  4. +50 −0 third-party/codemirror2/demo/changemode.html
  5. +65 −0 third-party/codemirror2/demo/closetag.html
  6. +70 −0 third-party/codemirror2/demo/complete.html
  7. +59 −0 third-party/codemirror2/demo/emacs.html
  8. +61 −0 third-party/codemirror2/demo/folding.html
  9. +80 −0 third-party/codemirror2/demo/formatting.html
  10. +152 −0 third-party/codemirror2/demo/fullscreen.html
  11. +39 −0 third-party/codemirror2/demo/loadmode.html
  12. +52 −0 third-party/codemirror2/demo/marker.html
  13. +37 −0 third-party/codemirror2/demo/matchhighlighter.html
  14. +57 −0 third-party/codemirror2/demo/mustache.html
  15. +76 −0 third-party/codemirror2/demo/preview.html
  16. +43 −0 third-party/codemirror2/demo/resize.html
  17. +49 −0 third-party/codemirror2/demo/runmode.html
  18. +83 −0 third-party/codemirror2/demo/search.html
  19. +76 −0 third-party/codemirror2/demo/theme.html
  20. +50 −0 third-party/codemirror2/demo/vim.html
  21. +61 −0 third-party/codemirror2/demo/visibletabs.html
  22. BIN third-party/codemirror2/doc/baboon.png
  23. +153 −0 third-party/codemirror2/doc/baboon_vector.svg
  24. +146 −0 third-party/codemirror2/doc/compress.html
  25. +154 −0 third-party/codemirror2/doc/docs.css
  26. +494 −0 third-party/codemirror2/doc/internals.html
  27. +1,100 −0 third-party/codemirror2/doc/manual.html
  28. +251 −0 third-party/codemirror2/doc/oldrelease.html
  29. +57 −0 third-party/codemirror2/doc/reporting.html
  30. +95 −0 third-party/codemirror2/doc/upgrade_v2.2.html
  31. +400 −0 third-party/codemirror2/index.html
  32. +29 −0 third-party/codemirror2/keymap/emacs.js
  33. +500 −0 third-party/codemirror2/keymap/vim.js
  34. +126 −0 third-party/codemirror2/lib/codemirror.css
  35. +3,080 −0 third-party/codemirror2/lib/codemirror.js
  36. +146 −0 third-party/codemirror2/lib/util/closetag.js
  37. +23 −0 third-party/codemirror2/lib/util/dialog.css
  38. +63 −0 third-party/codemirror2/lib/util/dialog.js
  39. +191 −0 third-party/codemirror2/lib/util/foldcode.js
  40. +294 −0 third-party/codemirror2/lib/util/formatting.js
  41. +134 −0 third-party/codemirror2/lib/util/javascript-hint.js
  42. +51 −0 third-party/codemirror2/lib/util/loadmode.js
  43. +44 −0 third-party/codemirror2/lib/util/match-highlighter.js
  44. +51 −0 third-party/codemirror2/lib/util/overlay.js
  45. +49 −0 third-party/codemirror2/lib/util/runmode.js
  46. +114 −0 third-party/codemirror2/lib/util/search.js
  47. +117 −0 third-party/codemirror2/lib/util/searchcursor.js
  48. +16 −0 third-party/codemirror2/lib/util/simple-hint.css
  49. +72 −0 third-party/codemirror2/lib/util/simple-hint.js
  50. +234 −0 third-party/codemirror2/mode/clike/clike.js
  51. +101 −0 third-party/codemirror2/mode/clike/index.html
  52. +207 −0 third-party/codemirror2/mode/clojure/clojure.js
  53. +66 −0 third-party/codemirror2/mode/clojure/index.html
  54. +22 −0 third-party/codemirror2/mode/coffeescript/LICENSE
  55. +341 −0 third-party/codemirror2/mode/coffeescript/coffeescript.js
  56. +721 −0 third-party/codemirror2/mode/coffeescript/index.html
  57. +124 −0 third-party/codemirror2/mode/css/css.js
  58. +55 −0 third-party/codemirror2/mode/css/index.html
  59. +32 −0 third-party/codemirror2/mode/diff/diff.js
  60. +104 −0 third-party/codemirror2/mode/diff/index.html
  61. +203 −0 third-party/codemirror2/mode/ecl/ecl.js
  62. +42 −0 third-party/codemirror2/mode/ecl/index.html
  63. +250 −0 third-party/codemirror2/mode/erlang/erlang.js
  64. +61 −0 third-party/codemirror2/mode/erlang/index.html
  65. +108 −0 third-party/codemirror2/mode/gfm/gfm.js
  66. +47 −0 third-party/codemirror2/mode/gfm/index.html
  67. +170 −0 third-party/codemirror2/mode/go/go.js
  68. +72 −0 third-party/codemirror2/mode/go/index.html
  69. +210 −0 third-party/codemirror2/mode/groovy/groovy.js
  70. +71 −0 third-party/codemirror2/mode/groovy/index.html
  71. +242 −0 third-party/codemirror2/mode/haskell/haskell.js
  72. +60 −0 third-party/codemirror2/mode/haskell/index.html
  73. +68 −0 third-party/codemirror2/mode/htmlembedded/htmlembedded.js
  74. +49 −0 third-party/codemirror2/mode/htmlembedded/index.html
  75. +85 −0 third-party/codemirror2/mode/htmlmixed/htmlmixed.js
  76. +51 −0 third-party/codemirror2/mode/htmlmixed/index.html
  77. +77 −0 third-party/codemirror2/mode/javascript/index.html
  78. +361 −0 third-party/codemirror2/mode/javascript/javascript.js
  79. +37 −0 third-party/codemirror2/mode/jinja2/index.html
  80. +42 −0 third-party/codemirror2/mode/jinja2/jinja2.js
  81. +618 −0 third-party/codemirror2/mode/less/index.html
  82. +232 −0 third-party/codemirror2/mode/less/less.js
  83. +72 −0 third-party/codemirror2/mode/lua/index.html
  84. +140 −0 third-party/codemirror2/mode/lua/lua.js
  85. +338 −0 third-party/codemirror2/mode/markdown/index.html
  86. +245 −0 third-party/codemirror2/mode/markdown/markdown.js
  87. +41 −0 third-party/codemirror2/mode/mysql/index.html
  88. +188 −0 third-party/codemirror2/mode/mysql/mysql.js
  89. +32 −0 third-party/codemirror2/mode/ntriples/index.html
  90. +172 −0 third-party/codemirror2/mode/ntriples/ntriples.js
  91. +7 −0 third-party/codemirror2/mode/pascal/LICENSE
  92. +48 −0 third-party/codemirror2/mode/pascal/index.html
  93. +94 −0 third-party/codemirror2/mode/pascal/pascal.js
  94. +19 −0 third-party/codemirror2/mode/perl/LICENSE
  95. +62 −0 third-party/codemirror2/mode/perl/index.html
  96. +816 −0 third-party/codemirror2/mode/perl/perl.js
  97. +48 −0 third-party/codemirror2/mode/php/index.html
  98. +150 −0 third-party/codemirror2/mode/php/php.js
  99. +42 −0 third-party/codemirror2/mode/pig/index.html
  100. +172 −0 third-party/codemirror2/mode/pig/pig.js
  101. +62 −0 third-party/codemirror2/mode/plsql/index.html
  102. +217 −0 third-party/codemirror2/mode/plsql/plsql.js
  103. +40 −0 third-party/codemirror2/mode/properties/index.html
  104. +63 −0 third-party/codemirror2/mode/properties/properties.js
  105. +21 −0 third-party/codemirror2/mode/python/LICENSE.txt
  106. +122 −0 third-party/codemirror2/mode/python/index.html
  107. +338 −0 third-party/codemirror2/mode/python/python.js
  108. +24 −0 third-party/codemirror2/mode/r/LICENSE
  109. +73 −0 third-party/codemirror2/mode/r/index.html
  110. +141 −0 third-party/codemirror2/mode/r/r.js
  111. +19 −0 third-party/codemirror2/mode/rpm/changes/changes.js
  112. +53 −0 third-party/codemirror2/mode/rpm/changes/index.html
  113. +99 −0 third-party/codemirror2/mode/rpm/spec/index.html
  114. +5 −0 third-party/codemirror2/mode/rpm/spec/spec.css
  115. +66 −0 third-party/codemirror2/mode/rpm/spec/spec.js
  116. +525 −0 third-party/codemirror2/mode/rst/index.html
  117. +326 −0 third-party/codemirror2/mode/rst/rst.js
  118. +24 −0 third-party/codemirror2/mode/ruby/LICENSE
  119. +171 −0 third-party/codemirror2/mode/ruby/index.html
  120. +200 −0 third-party/codemirror2/mode/ruby/ruby.js
  121. +48 −0 third-party/codemirror2/mode/rust/index.html
  122. +432 −0 third-party/codemirror2/mode/rust/rust.js
  123. +64 −0 third-party/codemirror2/mode/scheme/index.html
  124. +199 −0 third-party/codemirror2/mode/scheme/scheme.js
  125. +50 −0 third-party/codemirror2/mode/shell/index.html
  126. +103 −0 third-party/codemirror2/mode/shell/shell.js
  127. +55 −0 third-party/codemirror2/mode/smalltalk/index.html
  128. +139 −0 third-party/codemirror2/mode/smalltalk/smalltalk.js
  129. +82 −0 third-party/codemirror2/mode/smarty/index.html
  130. +148 −0 third-party/codemirror2/mode/smarty/smarty.js
  131. +40 −0 third-party/codemirror2/mode/sparql/index.html
  132. +143 −0 third-party/codemirror2/mode/sparql/sparql.js
  133. +95 −0 third-party/codemirror2/mode/stex/index.html
  134. +180 −0 third-party/codemirror2/mode/stex/stex.js
  135. +251 −0 third-party/codemirror2/mode/stex/test.html
  136. +140 −0 third-party/codemirror2/mode/tiddlywiki/index.html
  137. +14 −0 third-party/codemirror2/mode/tiddlywiki/tiddlywiki.css
  138. +384 −0 third-party/codemirror2/mode/tiddlywiki/tiddlywiki.js
  139. +82 −0 third-party/codemirror2/mode/tiki/index.html
  140. +26 −0 third-party/codemirror2/mode/tiki/tiki.css
  141. +316 −0 third-party/codemirror2/mode/tiki/tiki.js
  142. +42 −0 third-party/codemirror2/mode/vbscript/index.html
  143. +26 −0 third-party/codemirror2/mode/vbscript/vbscript.js
  144. +103 −0 third-party/codemirror2/mode/velocity/index.html
  145. +146 −0 third-party/codemirror2/mode/velocity/velocity.js
  146. +210 −0 third-party/codemirror2/mode/verilog/index.html
  147. +194 −0 third-party/codemirror2/mode/verilog/verilog.js
  148. +44 −0 third-party/codemirror2/mode/xml/index.html
  149. +325 −0 third-party/codemirror2/mode/xml/xml.js
  150. +20 −0 third-party/codemirror2/mode/xquery/LICENSE
  151. +222 −0 third-party/codemirror2/mode/xquery/index.html
  152. +27 −0 third-party/codemirror2/mode/xquery/test/index.html
  153. +42 −0 third-party/codemirror2/mode/xquery/test/testBase.js
  154. +16 −0 third-party/codemirror2/mode/xquery/test/testEmptySequenceKeyword.js
  155. +16 −0 third-party/codemirror2/mode/xquery/test/testMultiAttr.js
  156. +91 −0 third-party/codemirror2/mode/xquery/test/testNamespaces.js
  157. +16 −0 third-party/codemirror2/mode/xquery/test/testProcessingInstructions.js
  158. +19 −0 third-party/codemirror2/mode/xquery/test/testQuotes.js
  159. +448 −0 third-party/codemirror2/mode/xquery/xquery.js
  160. +67 −0 third-party/codemirror2/mode/yaml/index.html
  161. +95 −0 third-party/codemirror2/mode/yaml/yaml.js
  162. +28 −0 third-party/codemirror2/test/index.html
  163. +22 −0 third-party/codemirror2/test/mode_test.css
  164. +164 −0 third-party/codemirror2/test/mode_test.js
  165. +337 −0 third-party/codemirror2/test/test.js
  166. +82 −0 third-party/codemirror2/theme/ambiance.css
  167. +25 −0 third-party/codemirror2/theme/blackboard.css
  168. +18 −0 third-party/codemirror2/theme/cobalt.css
  169. +25 −0 third-party/codemirror2/theme/eclipse.css
  170. +10 −0 third-party/codemirror2/theme/elegant.css
  171. +21 −0 third-party/codemirror2/theme/erlang-dark.css
  172. +45 −0 third-party/codemirror2/theme/lesser-dark.css
  173. +28 −0 third-party/codemirror2/theme/monokai.css
  174. +9 −0 third-party/codemirror2/theme/neat.css
  175. +21 −0 third-party/codemirror2/theme/night.css
  176. +21 −0 third-party/codemirror2/theme/rubyblue.css
  177. +46 −0 third-party/codemirror2/theme/xq-dark.css
@@ -0,0 +1,23 @@
+Copyright (C) 2012 by Marijn Haverbeke <marijnh@gmail.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+Please note that some subdirectories of the CodeMirror distribution
+include their own LICENSE files, and are released under different
+licences.
@@ -0,0 +1,6 @@
+# CodeMirror 2
+
+CodeMirror 2 is a rewrite of [CodeMirror
+1](http://github.com/marijnh/CodeMirror). The docs live
+[here](http://codemirror.net/doc/manual.html), and the project page is
+[http://codemirror.net/](http://codemirror.net/).
@@ -0,0 +1,72 @@
+<!doctype html>
+<html>
+ <head>
+ <title>CodeMirror: Active Line Demo</title>
+ <link rel="stylesheet" href="../lib/codemirror.css">
+ <script src="../lib/codemirror.js"></script>
+ <script src="../mode/xml/xml.js"></script>
+ <link rel="stylesheet" href="../doc/docs.css">
+
+ <style type="text/css">
+ .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
+ .activeline {background: #e8f2ff !important;}
+ </style>
+ </head>
+ <body>
+ <h1>CodeMirror: Active Line Demo</h1>
+
+ <form><textarea id="code" name="code">
+<?xml version="1.0" encoding="UTF-8"?>
+<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"
+ xmlns:georss="http://www.georss.org/georss"
+ xmlns:twitter="http://api.twitter.com">
+ <channel>
+ <title>Twitter / codemirror</title>
+ <link>http://twitter.com/codemirror</link>
+ <atom:link type="application/rss+xml"
+ href="http://twitter.com/statuses/user_timeline/242283288.rss" rel="self"/>
+ <description>Twitter updates from CodeMirror / codemirror.</description>
+ <language>en-us</language>
+ <ttl>40</ttl>
+ <item>
+ <title>codemirror: http://cloud-ide.com &#8212; they're springing up like mushrooms. This one
+ uses CodeMirror as its editor.</title>
+ <description>codemirror: http://cloud-ide.com &#8212; they're springing up like mushrooms. This
+ one uses CodeMirror as its editor.</description>
+ <pubDate>Thu, 17 Mar 2011 23:34:47 +0000</pubDate>
+ <guid>http://twitter.com/codemirror/statuses/48527733722058752</guid>
+ <link>http://twitter.com/codemirror/statuses/48527733722058752</link>
+ <twitter:source>web</twitter:source>
+ <twitter:place/>
+ </item>
+ <item>
+ <title>codemirror: Posted a description of the CodeMirror 2 internals at
+ http://codemirror.net/2/internals.html</title>
+ <description>codemirror: Posted a description of the CodeMirror 2 internals at
+ http://codemirror.net/2/internals.html</description>
+ <pubDate>Wed, 02 Mar 2011 12:15:09 +0000</pubDate>
+ <guid>http://twitter.com/codemirror/statuses/42920879788789760</guid>
+ <link>http://twitter.com/codemirror/statuses/42920879788789760</link>
+ <twitter:source>web</twitter:source>
+ <twitter:place/>
+ </item>
+ </channel>
+</rss></textarea></form>
+
+ <script>
+var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ mode: "application/xml",
+ lineNumbers: true,
+ lineWrapping: true,
+ onCursorActivity: function() {
+ editor.setLineClass(hlLine, null, null);
+ hlLine = editor.setLineClass(editor.getCursor().line, null, "activeline");
+ }
+});
+var hlLine = editor.setLineClass(0, "activeline");
+</script>
+
+ <p>Styling the current cursor line.</p>
+
+ </body>
+</html>
@@ -0,0 +1,50 @@
+<!doctype html>
+<html>
+ <head>
+ <title>CodeMirror: Mode-Changing Demo</title>
+ <link rel="stylesheet" href="../lib/codemirror.css">
+ <script src="../lib/codemirror.js"></script>
+ <script src="../mode/javascript/javascript.js"></script>
+ <script src="../mode/scheme/scheme.js"></script>
+ <link rel="stylesheet" href="../doc/docs.css">
+
+ <style type="text/css">
+ .CodeMirror {border: 1px solid black;}
+ </style>
+ </head>
+ <body>
+ <h1>CodeMirror: Mode-Changing demo</h1>
+
+ <form><textarea id="code" name="code">
+;; If there is Scheme code in here, the editor will be in Scheme mode.
+;; If you put in JS instead, it'll switch to JS mode.
+
+(define (double x)
+ (* x x))
+</textarea></form>
+
+<p>On changes to the content of the above editor, a (crude) script
+tries to auto-detect the language used, and switches the editor to
+either JavaScript or Scheme mode based on that.</p>
+
+<script>
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ mode: "scheme",
+ lineNumbers: true,
+ matchBrackets: true,
+ tabMode: "indent",
+ onChange: function() {
+ clearTimeout(pending);
+ setTimeout(update, 400);
+ }
+ });
+ var pending;
+ function looksLikeScheme(code) {
+ return !/^\s*\(\s*function\b/.test(code) && /^\s*[;\(]/.test(code);
+ }
+ function update() {
+ editor.setOption("mode", looksLikeScheme(editor.getValue()) ? "scheme" : "javascript");
+ }
+</script>
+ </body>
+</html>
@@ -0,0 +1,65 @@
+<!doctype html>
+<html>
+ <head>
+ <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>
@@ -0,0 +1,70 @@
+<!doctype html>
+<html>
+ <head>
+ <title>CodeMirror: Autocomplete Demo</title>
+ <link rel="stylesheet" href="../lib/codemirror.css">
+ <script src="../lib/codemirror.js"></script>
+ <script src="../lib/util/simple-hint.js"></script>
+ <link rel="stylesheet" href="../lib/util/simple-hint.css">
+ <script src="../lib/util/javascript-hint.js"></script>
+ <script src="../mode/javascript/javascript.js"></script>
+ <link rel="stylesheet" href="../doc/docs.css">
+ <style type="text/css">.CodeMirror {border: 1px solid #eee;} .CodeMirror-scroll { height: 100% }</style>
+ </head>
+ <body>
+ <h1>CodeMirror: Autocomplete demo</h1>
+
+ <form><textarea id="code" name="code">
+function getCompletions(token, context) {
+ var found = [], start = token.string;
+ function maybeAdd(str) {
+ if (str.indexOf(start) == 0) found.push(str);
+ }
+ function gatherCompletions(obj) {
+ if (typeof obj == "string") forEach(stringProps, maybeAdd);
+ else if (obj instanceof Array) forEach(arrayProps, maybeAdd);
+ else if (obj instanceof Function) forEach(funcProps, maybeAdd);
+ for (var name in obj) maybeAdd(name);
+ }
+
+ if (context) {
+ // 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 == "js-variable")
+ base = window[obj.string];
+ else if (obj.className == "js-string")
+ base = "";
+ else if (obj.className == "js-atom")
+ base = 1;
+ while (base != null && context.length)
+ base = base[context.pop().string];
+ if (base != null) gatherCompletions(base);
+ }
+ else {
+ // If not, just look in the window object and any local scope
+ // (reading into JS mode internals to get at the local variables)
+ for (var v = token.state.localVars; v; v = v.next) maybeAdd(v.name);
+ gatherCompletions(window);
+ forEach(keywords, maybeAdd);
+ }
+ return found;
+}
+</textarea></form>
+
+<p>Press <strong>ctrl-space</strong> to activate autocompletion. See
+the code (<a href="../lib/util/simple-hint.js">here</a>
+and <a href="../lib/util/javascript-hint.js">here</a>) to figure out
+how it works.</p>
+
+ <script>
+ CodeMirror.commands.autocomplete = function(cm) {
+ CodeMirror.simpleHint(cm, CodeMirror.javascriptHint);
+ }
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ extraKeys: {"Ctrl-Space": "autocomplete"}
+ });
+ </script>
+ </body>
+</html>
@@ -0,0 +1,59 @@
+<!doctype html>
+<html>
+ <head>
+ <title>CodeMirror: Emacs bindings demo</title>
+ <link rel="stylesheet" href="../lib/codemirror.css">
+ <script src="../lib/codemirror.js"></script>
+ <script src="../mode/clike/clike.js"></script>
+ <script src="../keymap/emacs.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>CodeMirror: Emacs bindings demo</h1>
+
+ <form><textarea id="code" name="code">
+#include "syscalls.h"
+/* getchar: simple buffered version */
+int getchar(void)
+{
+ static char buf[BUFSIZ];
+ static char *bufp = buf;
+ static int n = 0;
+ if (n == 0) { /* buffer is empty */
+ n = read(0, buf, sizeof buf);
+ bufp = buf;
+ }
+ return (--n >= 0) ? (unsigned char) *bufp++ : EOF;
+}
+</textarea></form>
+
+<p>The emacs keybindings are enabled by
+including <a href="../keymap/emacs.js">keymap/emacs.js</a> and setting
+the <code>keyMap</code> option to <code>"emacs"</code>. Because
+CodeMirror's internal API is quite different from Emacs, they are only
+a loose approximation of actual emacs bindings, though.</p>
+
+<p>Also note that a lot of browsers disallow certain keys from being
+captured. For example, Chrome blocks both Ctrl-W and Ctrl-N, with the
+result that idiomatic use of Emacs keys will constantly close your tab
+or open a new window.</p>
+
+ <script>
+ CodeMirror.commands.save = function() {
+ var elt = editor.getWrapperElement();
+ elt.style.background = "#def";
+ setTimeout(function() { elt.style.background = ""; }, 300);
+ };
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ mode: "text/x-csrc",
+ keyMap: "emacs"
+ });
+ </script>
+
+ </body>
+</html>
Oops, something went wrong.

0 comments on commit 5d486b4

Please sign in to comment.