codemirror-rails 2.21 → 2.21.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -35,6 +35,14 @@ Additional syntax modes can be added to your application.js:
35
35
  //= require codemirror/modes/ruby
36
36
  ```
37
37
 
38
+ ### Adding a keymap
39
+
40
+ Additional keymap bindings can be added to your application.js:
41
+
42
+ ```js
43
+ //= require codemirror/keymaps/vim
44
+ ```
45
+
38
46
  ### Adding a theme
39
47
 
40
48
  Additional CSS themes can be added to your application.css
@@ -1,6 +1,6 @@
1
1
  module Codemirror
2
2
  module Rails
3
- VERSION = '2.21'
3
+ VERSION = '2.21.1'
4
4
  CODEMIRROR_VERSION = '2.21'
5
5
  end
6
6
  end
@@ -0,0 +1,29 @@
1
+ // TODO number prefixes
2
+ (function() {
3
+ // Really primitive kill-ring implementation.
4
+ var killRing = [];
5
+ function addToRing(str) {
6
+ killRing.push(str);
7
+ if (killRing.length > 50) killRing.shift();
8
+ }
9
+ function getFromRing() { return killRing[killRing.length - 1] || ""; }
10
+ function popFromRing() { if (killRing.length > 1) killRing.pop(); return getFromRing(); }
11
+
12
+ CodeMirror.keyMap.emacs = {
13
+ "Ctrl-X": function(cm) {cm.setOption("keyMap", "emacs-Ctrl-X");},
14
+ "Ctrl-W": function(cm) {addToRing(cm.getSelection()); cm.replaceSelection("");},
15
+ "Ctrl-Alt-W": function(cm) {addToRing(cm.getSelection()); cm.replaceSelection("");},
16
+ "Alt-W": function(cm) {addToRing(cm.getSelection());},
17
+ "Ctrl-Y": function(cm) {cm.replaceSelection(getFromRing());},
18
+ "Alt-Y": function(cm) {cm.replaceSelection(popFromRing());},
19
+ "Ctrl-/": "undo", "Shift-Ctrl--": "undo", "Shift-Alt-,": "goDocStart", "Shift-Alt-.": "goDocEnd",
20
+ "Ctrl-S": "findNext", "Ctrl-R": "findPrev", "Ctrl-G": "clearSearch", "Shift-Alt-5": "replace",
21
+ "Ctrl-Z": "undo", "Cmd-Z": "undo",
22
+ fallthrough: ["basic", "emacsy"]
23
+ };
24
+
25
+ CodeMirror.keyMap["emacs-Ctrl-X"] = {
26
+ "Ctrl-S": "save", "Ctrl-W": "save", "S": "saveAll", "F": "open", "U": "undo", "K": "close",
27
+ auto: "emacs", catchall: function(cm) {/*ignore*/}
28
+ };
29
+ })();
@@ -0,0 +1,347 @@
1
+ (function() {
2
+ var count = "";
3
+ var sdir = "f";
4
+ var buf = "";
5
+ var yank = 0;
6
+ var mark = [];
7
+ function emptyBuffer() { buf = ""; }
8
+ function pushInBuffer(str) { buf += str; };
9
+ function pushCountDigit(digit) { return function(cm) {count += digit;} }
10
+ function popCount() { var i = parseInt(count); count = ""; return i || 1; }
11
+ function countTimes(func) {
12
+ if (typeof func == "string") func = CodeMirror.commands[func];
13
+ return function(cm) { for (var i = 0, c = popCount(); i < c; ++i) func(cm); }
14
+ }
15
+
16
+ function iterObj(o, f) {
17
+ for (var prop in o) if (o.hasOwnProperty(prop)) f(prop, o[prop]);
18
+ }
19
+
20
+ var word = [/\w/, /[^\w\s]/], bigWord = [/\S/];
21
+ function findWord(line, pos, dir, regexps) {
22
+ var stop = 0, next = -1;
23
+ if (dir > 0) { stop = line.length; next = 0; }
24
+ var start = stop, end = stop;
25
+ // Find bounds of next one.
26
+ outer: for (; pos != stop; pos += dir) {
27
+ for (var i = 0; i < regexps.length; ++i) {
28
+ if (regexps[i].test(line.charAt(pos + next))) {
29
+ start = pos;
30
+ for (; pos != stop; pos += dir) {
31
+ if (!regexps[i].test(line.charAt(pos + next))) break;
32
+ }
33
+ end = pos;
34
+ break outer;
35
+ }
36
+ }
37
+ }
38
+ return {from: Math.min(start, end), to: Math.max(start, end)};
39
+ }
40
+ function moveToWord(cm, regexps, dir, where) {
41
+ var cur = cm.getCursor(), ch = cur.ch, line = cm.getLine(cur.line), word;
42
+ while (true) {
43
+ word = findWord(line, ch, dir, regexps);
44
+ ch = word[where == "end" ? "to" : "from"];
45
+ if (ch == cur.ch && word.from != word.to) ch = word[dir < 0 ? "from" : "to"];
46
+ else break;
47
+ }
48
+ cm.setCursor(cur.line, word[where == "end" ? "to" : "from"], true);
49
+ }
50
+ function joinLineNext(cm) {
51
+ var cur = cm.getCursor(), ch = cur.ch, line = cm.getLine(cur.line);
52
+ CodeMirror.commands.goLineEnd(cm);
53
+ if (cur.line != cm.lineCount()) {
54
+ CodeMirror.commands.goLineEnd(cm);
55
+ cm.replaceSelection(" ", "end");
56
+ CodeMirror.commands.delCharRight(cm);
57
+ }
58
+ }
59
+ function editCursor(mode) {
60
+ if (mode == "vim-insert") {
61
+ // put in your cursor css changing code
62
+ } else if (mode == "vim") {
63
+ // put in your cursor css changing code
64
+ }
65
+ }
66
+ function delTillMark(cm, cHar) {
67
+ var i = mark[cHar], l = cm.getCursor().line, start = i > l ? l : i, end = i > l ? i : l;
68
+ cm.setCursor(start);
69
+ for (var c = start; c <= end; c++) {
70
+ pushInBuffer("\n"+cm.getLine(start));
71
+ cm.removeLine(start);
72
+ }
73
+ }
74
+ function yankTillMark(cm, cHar) {
75
+ var i = mark[cHar], l = cm.getCursor().line, start = i > l ? l : i, end = i > l ? i : l;
76
+ for (var c = start; c <= end; c++) {
77
+ pushInBuffer("\n"+cm.getLine(c));
78
+ }
79
+ cm.setCursor(start);
80
+ }
81
+
82
+ var map = CodeMirror.keyMap.vim = {
83
+ "0": function(cm) {count.length > 0 ? pushCountDigit("0")(cm) : CodeMirror.commands.goLineStart(cm);},
84
+ "A": function(cm) {popCount(); cm.setCursor(cm.getCursor().line, cm.getCursor().ch+1, true); cm.setOption("keyMap", "vim-insert"); editCursor("vim-insert");},
85
+ "Shift-A": function(cm) {popCount(); CodeMirror.commands.goLineEnd(cm); cm.setOption("keyMap", "vim-insert"); editCursor("vim-insert");},
86
+ "I": function(cm) {popCount(); cm.setOption("keyMap", "vim-insert"); editCursor("vim-insert");},
87
+ "Shift-I": function(cm) {popCount(); CodeMirror.commands.goLineStartSmart(cm); cm.setOption("keyMap", "vim-insert"); editCursor("vim-insert");},
88
+ "O": function(cm) {popCount(); CodeMirror.commands.goLineEnd(cm); cm.replaceSelection("\n", "end"); cm.setOption("keyMap", "vim-insert"); editCursor("vim-insert");},
89
+ "Shift-O": function(cm) {popCount(); CodeMirror.commands.goLineStart(cm); cm.replaceSelection("\n", "start"); cm.setOption("keyMap", "vim-insert"); editCursor("vim-insert");},
90
+ "G": function(cm) {cm.setOption("keyMap", "vim-prefix-g");},
91
+ "D": function(cm) {cm.setOption("keyMap", "vim-prefix-d"); emptyBuffer();},
92
+ "M": function(cm) {cm.setOption("keyMap", "vim-prefix-m"); mark = [];},
93
+ "Y": function(cm) {cm.setOption("keyMap", "vim-prefix-y"); emptyBuffer(); yank = 0;},
94
+ "/": function(cm) {var f = CodeMirror.commands.find; f && f(cm); sdir = "f"},
95
+ "Shift-/": function(cm) {
96
+ var f = CodeMirror.commands.find;
97
+ if (f) { f(cm); CodeMirror.commands.findPrev(cm); sdir = "r"; }
98
+ },
99
+ "N": function(cm) {
100
+ var fn = CodeMirror.commands.findNext;
101
+ if (fn) sdir != "r" ? fn(cm) : CodeMirror.commands.findPrev(cm);
102
+ },
103
+ "Shift-N": function(cm) {
104
+ var fn = CodeMirror.commands.findNext;
105
+ if (fn) sdir != "r" ? CodeMirror.commands.findPrev(cm) : fn.findNext(cm);
106
+ },
107
+ "Shift-G": function(cm) {count == "" ? cm.setCursor(cm.lineCount()) : cm.setCursor(parseInt(count)-1); popCount(); CodeMirror.commands.goLineStart(cm);},
108
+ catchall: function(cm) {/*ignore*/}
109
+ };
110
+ // Add bindings for number keys
111
+ for (var i = 1; i < 10; ++i) map[i] = pushCountDigit(i);
112
+ // Add bindings that are influenced by number keys
113
+ iterObj({"H": "goColumnLeft", "L": "goColumnRight", "J": "goLineDown", "K": "goLineUp",
114
+ "Left": "goColumnLeft", "Right": "goColumnRight", "Down": "goLineDown", "Up": "goLineUp",
115
+ "Backspace": "goCharLeft", "Space": "goCharRight",
116
+ "B": function(cm) {moveToWord(cm, word, -1, "end");},
117
+ "E": function(cm) {moveToWord(cm, word, 1, "end");},
118
+ "W": function(cm) {moveToWord(cm, word, 1, "start");},
119
+ "Shift-B": function(cm) {moveToWord(cm, bigWord, -1, "end");},
120
+ "Shift-E": function(cm) {moveToWord(cm, bigWord, 1, "end");},
121
+ "Shift-W": function(cm) {moveToWord(cm, bigWord, 1, "start");},
122
+ "X": function(cm) {CodeMirror.commands.delCharRight(cm)},
123
+ "P": function(cm) {
124
+ var cur = cm.getCursor().line;
125
+ if (buf!= "") {
126
+ CodeMirror.commands.goLineEnd(cm);
127
+ cm.replaceSelection(buf, "end");
128
+ }
129
+ cm.setCursor(cur+1);
130
+ },
131
+ "Shift-X": function(cm) {CodeMirror.commands.delCharLeft(cm)},
132
+ "Shift-J": function(cm) {joinLineNext(cm)},
133
+ "Shift-`": function(cm) {
134
+ var cur = cm.getCursor(), cHar = cm.getRange({line: cur.line, ch: cur.ch}, {line: cur.line, ch: cur.ch+1});
135
+ cHar = cHar != cHar.toLowerCase() ? cHar.toLowerCase() : cHar.toUpperCase();
136
+ cm.replaceRange(cHar, {line: cur.line, ch: cur.ch}, {line: cur.line, ch: cur.ch+1});
137
+ cm.setCursor(cur.line, cur.ch+1);
138
+ },
139
+ "Ctrl-B": function(cm) {CodeMirror.commands.goPageUp(cm)},
140
+ "Ctrl-F": function(cm) {CodeMirror.commands.goPageDown(cm)},
141
+ "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
142
+ "U": "undo", "Ctrl-R": "redo", "Shift-4": "goLineEnd"},
143
+ function(key, cmd) { map[key] = countTimes(cmd); });
144
+
145
+ CodeMirror.keyMap["vim-prefix-g"] = {
146
+ "E": countTimes(function(cm) { moveToWord(cm, word, -1, "start");}),
147
+ "Shift-E": countTimes(function(cm) { moveToWord(cm, bigWord, -1, "start");}),
148
+ auto: "vim",
149
+ catchall: function(cm) {/*ignore*/}
150
+ };
151
+
152
+ CodeMirror.keyMap["vim-prefix-m"] = {
153
+ "A": function(cm) {mark["A"] = cm.getCursor().line;},
154
+ "Shift-A": function(cm) {mark["Shift-A"] = cm.getCursor().line;},
155
+ "B": function(cm) {mark["B"] = cm.getCursor().line;},
156
+ "Shift-B": function(cm) {mark["Shift-B"] = cm.getCursor().line;},
157
+ "C": function(cm) {mark["C"] = cm.getCursor().line;},
158
+ "Shift-C": function(cm) {mark["Shift-C"] = cm.getCursor().line;},
159
+ "D": function(cm) {mark["D"] = cm.getCursor().line;},
160
+ "Shift-D": function(cm) {mark["Shift-D"] = cm.getCursor().line;},
161
+ "E": function(cm) {mark["E"] = cm.getCursor().line;},
162
+ "Shift-E": function(cm) {mark["Shift-E"] = cm.getCursor().line;},
163
+ "F": function(cm) {mark["F"] = cm.getCursor().line;},
164
+ "Shift-F": function(cm) {mark["Shift-F"] = cm.getCursor().line;},
165
+ "G": function(cm) {mark["G"] = cm.getCursor().line;},
166
+ "Shift-G": function(cm) {mark["Shift-G"] = cm.getCursor().line;},
167
+ "H": function(cm) {mark["H"] = cm.getCursor().line;},
168
+ "Shift-H": function(cm) {mark["Shift-H"] = cm.getCursor().line;},
169
+ "I": function(cm) {mark["I"] = cm.getCursor().line;},
170
+ "Shift-I": function(cm) {mark["Shift-I"] = cm.getCursor().line;},
171
+ "J": function(cm) {mark["J"] = cm.getCursor().line;},
172
+ "Shift-J": function(cm) {mark["Shift-J"] = cm.getCursor().line;},
173
+ "K": function(cm) {mark["K"] = cm.getCursor().line;},
174
+ "Shift-K": function(cm) {mark["Shift-K"] = cm.getCursor().line;},
175
+ "L": function(cm) {mark["L"] = cm.getCursor().line;},
176
+ "Shift-L": function(cm) {mark["Shift-L"] = cm.getCursor().line;},
177
+ "M": function(cm) {mark["M"] = cm.getCursor().line;},
178
+ "Shift-M": function(cm) {mark["Shift-M"] = cm.getCursor().line;},
179
+ "N": function(cm) {mark["N"] = cm.getCursor().line;},
180
+ "Shift-N": function(cm) {mark["Shift-N"] = cm.getCursor().line;},
181
+ "O": function(cm) {mark["O"] = cm.getCursor().line;},
182
+ "Shift-O": function(cm) {mark["Shift-O"] = cm.getCursor().line;},
183
+ "P": function(cm) {mark["P"] = cm.getCursor().line;},
184
+ "Shift-P": function(cm) {mark["Shift-P"] = cm.getCursor().line;},
185
+ "Q": function(cm) {mark["Q"] = cm.getCursor().line;},
186
+ "Shift-Q": function(cm) {mark["Shift-Q"] = cm.getCursor().line;},
187
+ "R": function(cm) {mark["R"] = cm.getCursor().line;},
188
+ "Shift-R": function(cm) {mark["Shift-R"] = cm.getCursor().line;},
189
+ "S": function(cm) {mark["S"] = cm.getCursor().line;},
190
+ "Shift-S": function(cm) {mark["Shift-S"] = cm.getCursor().line;},
191
+ "T": function(cm) {mark["T"] = cm.getCursor().line;},
192
+ "Shift-T": function(cm) {mark["Shift-T"] = cm.getCursor().line;},
193
+ "U": function(cm) {mark["U"] = cm.getCursor().line;},
194
+ "Shift-U": function(cm) {mark["Shift-U"] = cm.getCursor().line;},
195
+ "V": function(cm) {mark["V"] = cm.getCursor().line;},
196
+ "Shift-V": function(cm) {mark["Shift-V"] = cm.getCursor().line;},
197
+ "W": function(cm) {mark["W"] = cm.getCursor().line;},
198
+ "Shift-W": function(cm) {mark["Shift-W"] = cm.getCursor().line;},
199
+ "X": function(cm) {mark["X"] = cm.getCursor().line;},
200
+ "Shift-X": function(cm) {mark["Shift-X"] = cm.getCursor().line;},
201
+ "Y": function(cm) {mark["Y"] = cm.getCursor().line;},
202
+ "Shift-Y": function(cm) {mark["Shift-Y"] = cm.getCursor().line;},
203
+ "Z": function(cm) {mark["Z"] = cm.getCursor().line;},
204
+ "Shift-Z": function(cm) {mark["Shift-Z"] = cm.getCursor().line;},
205
+ auto: "vim",
206
+ catchall: function(cm) {/*ignore*/}
207
+ }
208
+
209
+ CodeMirror.keyMap["vim-prefix-d"] = {
210
+ "D": countTimes(function(cm) { pushInBuffer("\n"+cm.getLine(cm.getCursor().line)); cm.removeLine(cm.getCursor().line); }),
211
+ "'": function(cm) {cm.setOption("keyMap", "vim-prefix-d'"); emptyBuffer();},
212
+ auto: "vim",
213
+ catchall: function(cm) {/*ignore*/}
214
+ };
215
+
216
+ CodeMirror.keyMap["vim-prefix-d'"] = {
217
+ "A": function(cm) {delTillMark(cm,"A");},
218
+ "Shift-A": function(cm) {delTillMark(cm,"Shift-A");},
219
+ "B": function(cm) {delTillMark(cm,"B");},
220
+ "Shift-B": function(cm) {delTillMark(cm,"Shift-B");},
221
+ "C": function(cm) {delTillMark(cm,"C");},
222
+ "Shift-C": function(cm) {delTillMark(cm,"Shift-C");},
223
+ "D": function(cm) {delTillMark(cm,"D");},
224
+ "Shift-D": function(cm) {delTillMark(cm,"Shift-D");},
225
+ "E": function(cm) {delTillMark(cm,"E");},
226
+ "Shift-E": function(cm) {delTillMark(cm,"Shift-E");},
227
+ "F": function(cm) {delTillMark(cm,"F");},
228
+ "Shift-F": function(cm) {delTillMark(cm,"Shift-F");},
229
+ "G": function(cm) {delTillMark(cm,"G");},
230
+ "Shift-G": function(cm) {delTillMark(cm,"Shift-G");},
231
+ "H": function(cm) {delTillMark(cm,"H");},
232
+ "Shift-H": function(cm) {delTillMark(cm,"Shift-H");},
233
+ "I": function(cm) {delTillMark(cm,"I");},
234
+ "Shift-I": function(cm) {delTillMark(cm,"Shift-I");},
235
+ "J": function(cm) {delTillMark(cm,"J");},
236
+ "Shift-J": function(cm) {delTillMark(cm,"Shift-J");},
237
+ "K": function(cm) {delTillMark(cm,"K");},
238
+ "Shift-K": function(cm) {delTillMark(cm,"Shift-K");},
239
+ "L": function(cm) {delTillMark(cm,"L");},
240
+ "Shift-L": function(cm) {delTillMark(cm,"Shift-L");},
241
+ "M": function(cm) {delTillMark(cm,"M");},
242
+ "Shift-M": function(cm) {delTillMark(cm,"Shift-M");},
243
+ "N": function(cm) {delTillMark(cm,"N");},
244
+ "Shift-N": function(cm) {delTillMark(cm,"Shift-N");},
245
+ "O": function(cm) {delTillMark(cm,"O");},
246
+ "Shift-O": function(cm) {delTillMark(cm,"Shift-O");},
247
+ "P": function(cm) {delTillMark(cm,"P");},
248
+ "Shift-P": function(cm) {delTillMark(cm,"Shift-P");},
249
+ "Q": function(cm) {delTillMark(cm,"Q");},
250
+ "Shift-Q": function(cm) {delTillMark(cm,"Shift-Q");},
251
+ "R": function(cm) {delTillMark(cm,"R");},
252
+ "Shift-R": function(cm) {delTillMark(cm,"Shift-R");},
253
+ "S": function(cm) {delTillMark(cm,"S");},
254
+ "Shift-S": function(cm) {delTillMark(cm,"Shift-S");},
255
+ "T": function(cm) {delTillMark(cm,"T");},
256
+ "Shift-T": function(cm) {delTillMark(cm,"Shift-T");},
257
+ "U": function(cm) {delTillMark(cm,"U");},
258
+ "Shift-U": function(cm) {delTillMark(cm,"Shift-U");},
259
+ "V": function(cm) {delTillMark(cm,"V");},
260
+ "Shift-V": function(cm) {delTillMark(cm,"Shift-V");},
261
+ "W": function(cm) {delTillMark(cm,"W");},
262
+ "Shift-W": function(cm) {delTillMark(cm,"Shift-W");},
263
+ "X": function(cm) {delTillMark(cm,"X");},
264
+ "Shift-X": function(cm) {delTillMark(cm,"Shift-X");},
265
+ "Y": function(cm) {delTillMark(cm,"Y");},
266
+ "Shift-Y": function(cm) {delTillMark(cm,"Shift-Y");},
267
+ "Z": function(cm) {delTillMark(cm,"Z");},
268
+ "Shift-Z": function(cm) {delTillMark(cm,"Shift-Z");},
269
+ auto: "vim",
270
+ catchall: function(cm) {/*ignore*/}
271
+ };
272
+
273
+ CodeMirror.keyMap["vim-prefix-y'"] = {
274
+ "A": function(cm) {yankTillMark(cm,"A");},
275
+ "Shift-A": function(cm) {yankTillMark(cm,"Shift-A");},
276
+ "B": function(cm) {yankTillMark(cm,"B");},
277
+ "Shift-B": function(cm) {yankTillMark(cm,"Shift-B");},
278
+ "C": function(cm) {yankTillMark(cm,"C");},
279
+ "Shift-C": function(cm) {yankTillMark(cm,"Shift-C");},
280
+ "D": function(cm) {yankTillMark(cm,"D");},
281
+ "Shift-D": function(cm) {yankTillMark(cm,"Shift-D");},
282
+ "E": function(cm) {yankTillMark(cm,"E");},
283
+ "Shift-E": function(cm) {yankTillMark(cm,"Shift-E");},
284
+ "F": function(cm) {yankTillMark(cm,"F");},
285
+ "Shift-F": function(cm) {yankTillMark(cm,"Shift-F");},
286
+ "G": function(cm) {yankTillMark(cm,"G");},
287
+ "Shift-G": function(cm) {yankTillMark(cm,"Shift-G");},
288
+ "H": function(cm) {yankTillMark(cm,"H");},
289
+ "Shift-H": function(cm) {yankTillMark(cm,"Shift-H");},
290
+ "I": function(cm) {yankTillMark(cm,"I");},
291
+ "Shift-I": function(cm) {yankTillMark(cm,"Shift-I");},
292
+ "J": function(cm) {yankTillMark(cm,"J");},
293
+ "Shift-J": function(cm) {yankTillMark(cm,"Shift-J");},
294
+ "K": function(cm) {yankTillMark(cm,"K");},
295
+ "Shift-K": function(cm) {yankTillMark(cm,"Shift-K");},
296
+ "L": function(cm) {yankTillMark(cm,"L");},
297
+ "Shift-L": function(cm) {yankTillMark(cm,"Shift-L");},
298
+ "M": function(cm) {yankTillMark(cm,"M");},
299
+ "Shift-M": function(cm) {yankTillMark(cm,"Shift-M");},
300
+ "N": function(cm) {yankTillMark(cm,"N");},
301
+ "Shift-N": function(cm) {yankTillMark(cm,"Shift-N");},
302
+ "O": function(cm) {yankTillMark(cm,"O");},
303
+ "Shift-O": function(cm) {yankTillMark(cm,"Shift-O");},
304
+ "P": function(cm) {yankTillMark(cm,"P");},
305
+ "Shift-P": function(cm) {yankTillMark(cm,"Shift-P");},
306
+ "Q": function(cm) {yankTillMark(cm,"Q");},
307
+ "Shift-Q": function(cm) {yankTillMark(cm,"Shift-Q");},
308
+ "R": function(cm) {yankTillMark(cm,"R");},
309
+ "Shift-R": function(cm) {yankTillMark(cm,"Shift-R");},
310
+ "S": function(cm) {yankTillMark(cm,"S");},
311
+ "Shift-S": function(cm) {yankTillMark(cm,"Shift-S");},
312
+ "T": function(cm) {yankTillMark(cm,"T");},
313
+ "Shift-T": function(cm) {yankTillMark(cm,"Shift-T");},
314
+ "U": function(cm) {yankTillMark(cm,"U");},
315
+ "Shift-U": function(cm) {yankTillMark(cm,"Shift-U");},
316
+ "V": function(cm) {yankTillMark(cm,"V");},
317
+ "Shift-V": function(cm) {yankTillMark(cm,"Shift-V");},
318
+ "W": function(cm) {yankTillMark(cm,"W");},
319
+ "Shift-W": function(cm) {yankTillMark(cm,"Shift-W");},
320
+ "X": function(cm) {yankTillMark(cm,"X");},
321
+ "Shift-X": function(cm) {yankTillMark(cm,"Shift-X");},
322
+ "Y": function(cm) {yankTillMark(cm,"Y");},
323
+ "Shift-Y": function(cm) {yankTillMark(cm,"Shift-Y");},
324
+ "Z": function(cm) {yankTillMark(cm,"Z");},
325
+ "Shift-Z": function(cm) {yankTillMark(cm,"Shift-Z");},
326
+ auto: "vim",
327
+ catchall: function(cm) {/*ignore*/}
328
+ };
329
+
330
+ CodeMirror.keyMap["vim-prefix-y"] = {
331
+ "Y": countTimes(function(cm) { pushInBuffer("\n"+cm.getLine(cm.getCursor().line+yank)); yank++; }),
332
+ "'": function(cm) {cm.setOption("keyMap", "vim-prefix-y'"); emptyBuffer();},
333
+ auto: "vim",
334
+ catchall: function(cm) {/*ignore*/}
335
+ };
336
+
337
+ CodeMirror.keyMap["vim-insert"] = {
338
+ "Esc": function(cm) {
339
+ cm.setCursor(cm.getCursor().line, cm.getCursor().ch-1, true);
340
+ cm.setOption("keyMap", "vim");
341
+ editCursor("vim");
342
+ },
343
+ "Ctrl-N": function(cm) {/* Code to bring up autocomplete hint */},
344
+ "Ctrl-P": function(cm) {/* Code to bring up autocomplete hint */},
345
+ fallthrough: ["default"]
346
+ };
347
+ })();
@@ -1,194 +1,194 @@
1
- CodeMirror.defineMode("verilog", function(config, parserConfig) {
2
- var indentUnit = config.indentUnit,
3
- keywords = parserConfig.keywords || {},
4
- blockKeywords = parserConfig.blockKeywords || {},
5
- atoms = parserConfig.atoms || {},
6
- hooks = parserConfig.hooks || {},
7
- multiLineStrings = parserConfig.multiLineStrings;
8
- var isOperatorChar = /[&|~><!\)\(*#%@+\/=?\:;}{,\.\^\-\[\]]/;
9
-
10
- var curPunc;
11
-
12
- function tokenBase(stream, state) {
13
- var ch = stream.next();
14
- if (hooks[ch]) {
15
- var result = hooks[ch](stream, state);
16
- if (result !== false) return result;
17
- }
18
- if (ch == '"') {
19
- state.tokenize = tokenString(ch);
20
- return state.tokenize(stream, state);
21
- }
22
- if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
23
- curPunc = ch;
24
- return null
25
- }
26
- if (/[\d']/.test(ch)) {
27
- stream.eatWhile(/[\w\.']/);
28
- return "number";
29
- }
30
- if (ch == "/") {
31
- if (stream.eat("*")) {
32
- state.tokenize = tokenComment;
33
- return tokenComment(stream, state);
34
- }
35
- if (stream.eat("/")) {
36
- stream.skipToEnd();
37
- return "comment";
38
- }
39
- }
40
- if (isOperatorChar.test(ch)) {
41
- stream.eatWhile(isOperatorChar);
42
- return "operator";
43
- }
44
- stream.eatWhile(/[\w\$_]/);
45
- var cur = stream.current();
46
- if (keywords.propertyIsEnumerable(cur)) {
47
- if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
48
- return "keyword";
49
- }
50
- if (atoms.propertyIsEnumerable(cur)) return "atom";
51
- return "word";
52
- }
53
-
54
- function tokenString(quote) {
55
- return function(stream, state) {
56
- var escaped = false, next, end = false;
57
- while ((next = stream.next()) != null) {
58
- if (next == quote && !escaped) {end = true; break;}
59
- escaped = !escaped && next == "\\";
60
- }
61
- if (end || !(escaped || multiLineStrings))
62
- state.tokenize = tokenBase;
63
- return "string";
64
- };
65
- }
66
-
67
- function tokenComment(stream, state) {
68
- var maybeEnd = false, ch;
69
- while (ch = stream.next()) {
70
- if (ch == "/" && maybeEnd) {
71
- state.tokenize = tokenBase;
72
- break;
73
- }
74
- maybeEnd = (ch == "*");
75
- }
76
- return "comment";
77
- }
78
-
79
- function Context(indented, column, type, align, prev) {
80
- this.indented = indented;
81
- this.column = column;
82
- this.type = type;
83
- this.align = align;
84
- this.prev = prev;
85
- }
86
- function pushContext(state, col, type) {
87
- return state.context = new Context(state.indented, col, type, null, state.context);
88
- }
89
- function popContext(state) {
90
- var t = state.context.type;
91
- if (t == ")" || t == "]" || t == "}")
92
- state.indented = state.context.indented;
93
- return state.context = state.context.prev;
94
- }
95
-
96
- // Interface
97
-
98
- return {
99
- startState: function(basecolumn) {
100
- return {
101
- tokenize: null,
102
- context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
103
- indented: 0,
104
- startOfLine: true
105
- };
106
- },
107
-
108
- token: function(stream, state) {
109
- var ctx = state.context;
110
- if (stream.sol()) {
111
- if (ctx.align == null) ctx.align = false;
112
- state.indented = stream.indentation();
113
- state.startOfLine = true;
114
- }
115
- if (stream.eatSpace()) return null;
116
- curPunc = null;
117
- var style = (state.tokenize || tokenBase)(stream, state);
118
- if (style == "comment" || style == "meta") return style;
119
- if (ctx.align == null) ctx.align = true;
120
-
121
- if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
122
- else if (curPunc == "{") pushContext(state, stream.column(), "}");
123
- else if (curPunc == "[") pushContext(state, stream.column(), "]");
124
- else if (curPunc == "(") pushContext(state, stream.column(), ")");
125
- else if (curPunc == "}") {
126
- while (ctx.type == "statement") ctx = popContext(state);
127
- if (ctx.type == "}") ctx = popContext(state);
128
- while (ctx.type == "statement") ctx = popContext(state);
129
- }
130
- else if (curPunc == ctx.type) popContext(state);
131
- else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
132
- pushContext(state, stream.column(), "statement");
133
- state.startOfLine = false;
134
- return style;
135
- },
136
-
137
- indent: function(state, textAfter) {
138
- if (state.tokenize != tokenBase && state.tokenize != null) return 0;
139
- var firstChar = textAfter && textAfter.charAt(0), ctx = state.context, closing = firstChar == ctx.type;
140
- if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
141
- else if (ctx.align) return ctx.column + (closing ? 0 : 1);
142
- else return ctx.indented + (closing ? 0 : indentUnit);
143
- },
144
-
145
- electricChars: "{}"
146
- };
147
- });
148
-
149
- (function() {
150
- function words(str) {
151
- var obj = {}, words = str.split(" ");
152
- for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
153
- return obj;
154
- }
155
-
156
- var verilogKeywords = "always and assign automatic begin buf bufif0 bufif1 case casex casez cell cmos config " +
157
- "deassign default defparam design disable edge else end endcase endconfig endfunction endgenerate endmodule " +
158
- "endprimitive endspecify endtable endtask event for force forever fork function generate genvar highz0 " +
159
- "highz1 if ifnone incdir include initial inout input instance integer join large liblist library localparam " +
160
- "macromodule medium module nand negedge nmos nor noshowcancelled not notif0 notif1 or output parameter pmos " +
161
- "posedge primitive pull0 pull1 pulldown pullup pulsestyle_onevent pulsestyle_ondetect rcmos real realtime " +
162
- "reg release repeat rnmos rpmos rtran rtranif0 rtranif1 scalared showcancelled signed small specify specparam " +
163
- "strong0 strong1 supply0 supply1 table task time tran tranif0 tranif1 tri tri0 tri1 triand trior trireg " +
164
- "unsigned use vectored wait wand weak0 weak1 while wire wor xnor xor";
165
-
166
- var verilogBlockKeywords = "begin bufif0 bufif1 case casex casez config else end endcase endconfig endfunction " +
167
- "endgenerate endmodule endprimitive endspecify endtable endtask for forever function generate if ifnone " +
168
- "macromodule module primitive repeat specify table task while";
169
-
170
- function metaHook(stream, state) {
171
- stream.eatWhile(/[\w\$_]/);
172
- return "meta";
173
- }
174
-
175
- // C#-style strings where "" escapes a quote.
176
- function tokenAtString(stream, state) {
177
- var next;
178
- while ((next = stream.next()) != null) {
179
- if (next == '"' && !stream.eat('"')) {
180
- state.tokenize = null;
181
- break;
182
- }
183
- }
184
- return "string";
185
- }
186
-
187
- CodeMirror.defineMIME("text/x-verilog", {
188
- name: "verilog",
189
- keywords: words(verilogKeywords),
190
- blockKeywords: words(verilogBlockKeywords),
191
- atoms: words("null"),
192
- hooks: {"`": metaHook, "$": metaHook}
193
- });
194
- }());
1
+ CodeMirror.defineMode("verilog", function(config, parserConfig) {
2
+ var indentUnit = config.indentUnit,
3
+ keywords = parserConfig.keywords || {},
4
+ blockKeywords = parserConfig.blockKeywords || {},
5
+ atoms = parserConfig.atoms || {},
6
+ hooks = parserConfig.hooks || {},
7
+ multiLineStrings = parserConfig.multiLineStrings;
8
+ var isOperatorChar = /[&|~><!\)\(*#%@+\/=?\:;}{,\.\^\-\[\]]/;
9
+
10
+ var curPunc;
11
+
12
+ function tokenBase(stream, state) {
13
+ var ch = stream.next();
14
+ if (hooks[ch]) {
15
+ var result = hooks[ch](stream, state);
16
+ if (result !== false) return result;
17
+ }
18
+ if (ch == '"') {
19
+ state.tokenize = tokenString(ch);
20
+ return state.tokenize(stream, state);
21
+ }
22
+ if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
23
+ curPunc = ch;
24
+ return null
25
+ }
26
+ if (/[\d']/.test(ch)) {
27
+ stream.eatWhile(/[\w\.']/);
28
+ return "number";
29
+ }
30
+ if (ch == "/") {
31
+ if (stream.eat("*")) {
32
+ state.tokenize = tokenComment;
33
+ return tokenComment(stream, state);
34
+ }
35
+ if (stream.eat("/")) {
36
+ stream.skipToEnd();
37
+ return "comment";
38
+ }
39
+ }
40
+ if (isOperatorChar.test(ch)) {
41
+ stream.eatWhile(isOperatorChar);
42
+ return "operator";
43
+ }
44
+ stream.eatWhile(/[\w\$_]/);
45
+ var cur = stream.current();
46
+ if (keywords.propertyIsEnumerable(cur)) {
47
+ if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
48
+ return "keyword";
49
+ }
50
+ if (atoms.propertyIsEnumerable(cur)) return "atom";
51
+ return "word";
52
+ }
53
+
54
+ function tokenString(quote) {
55
+ return function(stream, state) {
56
+ var escaped = false, next, end = false;
57
+ while ((next = stream.next()) != null) {
58
+ if (next == quote && !escaped) {end = true; break;}
59
+ escaped = !escaped && next == "\\";
60
+ }
61
+ if (end || !(escaped || multiLineStrings))
62
+ state.tokenize = tokenBase;
63
+ return "string";
64
+ };
65
+ }
66
+
67
+ function tokenComment(stream, state) {
68
+ var maybeEnd = false, ch;
69
+ while (ch = stream.next()) {
70
+ if (ch == "/" && maybeEnd) {
71
+ state.tokenize = tokenBase;
72
+ break;
73
+ }
74
+ maybeEnd = (ch == "*");
75
+ }
76
+ return "comment";
77
+ }
78
+
79
+ function Context(indented, column, type, align, prev) {
80
+ this.indented = indented;
81
+ this.column = column;
82
+ this.type = type;
83
+ this.align = align;
84
+ this.prev = prev;
85
+ }
86
+ function pushContext(state, col, type) {
87
+ return state.context = new Context(state.indented, col, type, null, state.context);
88
+ }
89
+ function popContext(state) {
90
+ var t = state.context.type;
91
+ if (t == ")" || t == "]" || t == "}")
92
+ state.indented = state.context.indented;
93
+ return state.context = state.context.prev;
94
+ }
95
+
96
+ // Interface
97
+
98
+ return {
99
+ startState: function(basecolumn) {
100
+ return {
101
+ tokenize: null,
102
+ context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
103
+ indented: 0,
104
+ startOfLine: true
105
+ };
106
+ },
107
+
108
+ token: function(stream, state) {
109
+ var ctx = state.context;
110
+ if (stream.sol()) {
111
+ if (ctx.align == null) ctx.align = false;
112
+ state.indented = stream.indentation();
113
+ state.startOfLine = true;
114
+ }
115
+ if (stream.eatSpace()) return null;
116
+ curPunc = null;
117
+ var style = (state.tokenize || tokenBase)(stream, state);
118
+ if (style == "comment" || style == "meta") return style;
119
+ if (ctx.align == null) ctx.align = true;
120
+
121
+ if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
122
+ else if (curPunc == "{") pushContext(state, stream.column(), "}");
123
+ else if (curPunc == "[") pushContext(state, stream.column(), "]");
124
+ else if (curPunc == "(") pushContext(state, stream.column(), ")");
125
+ else if (curPunc == "}") {
126
+ while (ctx.type == "statement") ctx = popContext(state);
127
+ if (ctx.type == "}") ctx = popContext(state);
128
+ while (ctx.type == "statement") ctx = popContext(state);
129
+ }
130
+ else if (curPunc == ctx.type) popContext(state);
131
+ else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
132
+ pushContext(state, stream.column(), "statement");
133
+ state.startOfLine = false;
134
+ return style;
135
+ },
136
+
137
+ indent: function(state, textAfter) {
138
+ if (state.tokenize != tokenBase && state.tokenize != null) return 0;
139
+ var firstChar = textAfter && textAfter.charAt(0), ctx = state.context, closing = firstChar == ctx.type;
140
+ if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
141
+ else if (ctx.align) return ctx.column + (closing ? 0 : 1);
142
+ else return ctx.indented + (closing ? 0 : indentUnit);
143
+ },
144
+
145
+ electricChars: "{}"
146
+ };
147
+ });
148
+
149
+ (function() {
150
+ function words(str) {
151
+ var obj = {}, words = str.split(" ");
152
+ for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
153
+ return obj;
154
+ }
155
+
156
+ var verilogKeywords = "always and assign automatic begin buf bufif0 bufif1 case casex casez cell cmos config " +
157
+ "deassign default defparam design disable edge else end endcase endconfig endfunction endgenerate endmodule " +
158
+ "endprimitive endspecify endtable endtask event for force forever fork function generate genvar highz0 " +
159
+ "highz1 if ifnone incdir include initial inout input instance integer join large liblist library localparam " +
160
+ "macromodule medium module nand negedge nmos nor noshowcancelled not notif0 notif1 or output parameter pmos " +
161
+ "posedge primitive pull0 pull1 pulldown pullup pulsestyle_onevent pulsestyle_ondetect rcmos real realtime " +
162
+ "reg release repeat rnmos rpmos rtran rtranif0 rtranif1 scalared showcancelled signed small specify specparam " +
163
+ "strong0 strong1 supply0 supply1 table task time tran tranif0 tranif1 tri tri0 tri1 triand trior trireg " +
164
+ "unsigned use vectored wait wand weak0 weak1 while wire wor xnor xor";
165
+
166
+ var verilogBlockKeywords = "begin bufif0 bufif1 case casex casez config else end endcase endconfig endfunction " +
167
+ "endgenerate endmodule endprimitive endspecify endtable endtask for forever function generate if ifnone " +
168
+ "macromodule module primitive repeat specify table task while";
169
+
170
+ function metaHook(stream, state) {
171
+ stream.eatWhile(/[\w\$_]/);
172
+ return "meta";
173
+ }
174
+
175
+ // C#-style strings where "" escapes a quote.
176
+ function tokenAtString(stream, state) {
177
+ var next;
178
+ while ((next = stream.next()) != null) {
179
+ if (next == '"' && !stream.eat('"')) {
180
+ state.tokenize = null;
181
+ break;
182
+ }
183
+ }
184
+ return "string";
185
+ }
186
+
187
+ CodeMirror.defineMIME("text/x-verilog", {
188
+ name: "verilog",
189
+ keywords: words(verilogKeywords),
190
+ blockKeywords: words(verilogBlockKeywords),
191
+ atoms: words("null"),
192
+ hooks: {"`": metaHook, "$": metaHook}
193
+ });
194
+ }());
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codemirror-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.21'
4
+ version: 2.21.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-27 00:00:00.000000000Z
12
+ date: 2012-02-02 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
16
- requirement: &2168664600 !ruby/object:Gem::Requirement
16
+ requirement: &2153355080 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '3.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2168664600
24
+ version_requirements: *2153355080
25
25
  description: This gem provides CodeMirror assets for your Rails 3 application.
26
26
  email: nathan@fixler.org
27
27
  executables: []
@@ -41,6 +41,8 @@ files:
41
41
  - lib/codemirror/rails/version.rb
42
42
  - lib/generators/codemirror/install/install_generator.rb
43
43
  - vendor/assets/javascripts/codemirror.js
44
+ - vendor/assets/javascripts/codemirror/keymaps/emacs.js
45
+ - vendor/assets/javascripts/codemirror/keymaps/vim.js
44
46
  - vendor/assets/javascripts/codemirror/modes/clike.js
45
47
  - vendor/assets/javascripts/codemirror/modes/clojure.js
46
48
  - vendor/assets/javascripts/codemirror/modes/coffeescript.js