Fix: merge conflict
[myslice.git] / to-be-integrated / third-party / codemirror-3.15 / demo / emacs.html
1 <!doctype html>
2 <html>
3   <head>
4     <meta charset="utf-8">
5     <title>CodeMirror: Emacs bindings demo</title>
6     <link rel="stylesheet" href="../lib/codemirror.css">
7     <script src="../lib/codemirror.js"></script>
8     <script src="../mode/clike/clike.js"></script>
9     <script src="../keymap/emacs.js"></script>
10     <script src="../addon/edit/matchbrackets.js"></script>
11     <script src="../addon/comment/comment.js"></script>
12     <script src="../addon/dialog/dialog.js"></script>
13     <script src="../addon/search/searchcursor.js"></script>
14     <script src="../addon/search/search.js"></script>
15     <link rel="stylesheet" href="../addon/dialog/dialog.css">
16     <link rel="stylesheet" href="../doc/docs.css">
17
18     <style type="text/css">
19       .CodeMirror {border-top: 1px solid #eee; border-bottom: 1px solid #eee;}
20     </style>
21   </head>
22   <body>
23     <h1>CodeMirror: Emacs bindings demo</h1>
24
25     <form><textarea id="code" name="code">
26 #include "syscalls.h"
27 /* getchar:  simple buffered version */
28 int getchar(void)
29 {
30   static char buf[BUFSIZ];
31   static char *bufp = buf;
32   static int n = 0;
33   if (n == 0) {  /* buffer is empty */
34     n = read(0, buf, sizeof buf);
35     bufp = buf;
36   }
37   return (--n >= 0) ? (unsigned char) *bufp++ : EOF;
38 }
39 </textarea></form>
40
41 <p>The emacs keybindings are enabled by
42 including <a href="../keymap/emacs.js">keymap/emacs.js</a> and setting
43 the <code>keyMap</code> option to <code>"emacs"</code>. Because
44 CodeMirror's internal API is quite different from Emacs, they are only
45 a loose approximation of actual emacs bindings, though.</p>
46
47 <p>Also note that a lot of browsers disallow certain keys from being
48 captured. For example, Chrome blocks both Ctrl-W and Ctrl-N, with the
49 result that idiomatic use of Emacs keys will constantly close your tab
50 or open a new window.</p>
51
52     <script>
53       CodeMirror.commands.save = function() {
54         var elt = editor.getWrapperElement();
55         elt.style.background = "#def";
56         setTimeout(function() { elt.style.background = ""; }, 300);
57       };
58       var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
59         lineNumbers: true,
60         mode: "text/x-csrc",
61         keyMap: "emacs"
62       });
63     </script>
64
65   </body>
66 </html>