diff options
author | Jose Antonio Marquez | 2012-02-15 20:37:48 -0800 |
---|---|---|
committer | Jose Antonio Marquez | 2012-02-15 20:37:48 -0800 |
commit | 89b5e793ea88ef235b54b6e1d1c379698d3e612b (patch) | |
tree | 4d29118f35df77ca6b423119a4ff61694a442cbf /imports/codemirror/keymap/emacs.js | |
parent | 9d2c2a80483415d7560b00cda5519153db23e241 (diff) | |
parent | d366c0bd1af6471511217ed574083e15059519b5 (diff) | |
download | ninja-89b5e793ea88ef235b54b6e1d1c379698d3e612b.tar.gz |
Merge branch 'refs/heads/NinjaInternal' into Color
Diffstat (limited to 'imports/codemirror/keymap/emacs.js')
-rwxr-xr-x | imports/codemirror/keymap/emacs.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/imports/codemirror/keymap/emacs.js b/imports/codemirror/keymap/emacs.js new file mode 100755 index 00000000..8fd3564e --- /dev/null +++ b/imports/codemirror/keymap/emacs.js | |||
@@ -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 | })(); | ||