move a few things away in to-be-integrated/
[myslice.git] / to-be-integrated / third-party / codemirror-3.15 / demo / vim.html
1 <!doctype html>
2 <html>
3   <head>
4     <meta charset="utf-8">
5     <title>CodeMirror: Vim bindings demo</title>
6     <link rel="stylesheet" href="../lib/codemirror.css">
7     <script src="../lib/codemirror.js"></script>
8     <script src="../addon/dialog/dialog.js"></script>
9     <script src="../addon/search/searchcursor.js"></script>
10     <script src="../mode/clike/clike.js"></script>
11     <script src="../keymap/vim.js"></script>
12     <link rel="stylesheet" href="../doc/docs.css">
13     <link rel="stylesheet" href="../addon/dialog/dialog.css">
14
15     <style type="text/css">
16       .CodeMirror {border-top: 1px solid #eee; border-bottom: 1px solid #eee;}
17     </style>
18   </head>
19   <body>
20     <h1>CodeMirror: Vim bindings demo</h1>
21
22     <form><textarea id="code" name="code">
23 #include "syscalls.h"
24 /* getchar:  simple buffered version */
25 int getchar(void)
26 {
27   static char buf[BUFSIZ];
28   static char *bufp = buf;
29   static int n = 0;
30   if (n == 0) {  /* buffer is empty */
31     n = read(0, buf, sizeof buf);
32     bufp = buf;
33   }
34   return (--n >= 0) ? (unsigned char) *bufp++ : EOF;
35 }
36 </textarea></form>
37
38     <form><textarea id="code2" name="code2">
39         I am another file! You can yank from my neighbor and paste here.
40 </textarea></form>
41
42 <p>The vim keybindings are enabled by
43 including <a href="../keymap/vim.js">keymap/vim.js</a> and setting
44 the <code>keyMap</code> option to <code>"vim"</code>. Because
45 CodeMirror's internal API is quite different from Vim, they are only
46 a loose approximation of actual vim bindings, though.</p>
47
48     <script>
49       CodeMirror.commands.save = function(){ alert("Saving"); };
50       var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
51         lineNumbers: true,
52         mode: "text/x-csrc",
53         vimMode: true,
54         showCursorWhenSelecting: true
55       });
56       var editor2 = CodeMirror.fromTextArea(document.getElementById("code2"), {
57         lineNumbers: true,
58         mode: "text/x-csrc",
59         vimMode: true,
60         showCursorWhenSelecting: true
61       });
62     </script>
63
64   </body>
65 </html>