| 1 | ace.define("ace/keyboard/vscode",["require","exports","module","ace/keyboard/hash_handler","ace/config"], function(require, exports, module){"use strict"; |
| 2 | var HashHandler = require("../keyboard/hash_handler").HashHandler; |
| 3 | var config = require("../config"); |
| 4 | exports.handler = new HashHandler(); |
| 5 | exports.handler.$id = "ace/keyboard/vscode"; |
| 6 | exports.handler.addCommands([{ |
| 7 | name: "toggleWordWrap", |
| 8 | exec: function (editor) { |
| 9 | var wrapUsed = editor.session.getUseWrapMode(); |
| 10 | editor.session.setUseWrapMode(!wrapUsed); |
| 11 | }, |
| 12 | readOnly: true |
| 13 | }, { |
| 14 | name: "navigateToLastEditLocation", |
| 15 | exec: function (editor) { |
| 16 | var lastDelta = editor.session.getUndoManager().$lastDelta; |
| 17 | var range = (lastDelta.action == "remove") ? lastDelta.start : lastDelta.end; |
| 18 | editor.moveCursorTo(range.row, range.column); |
| 19 | editor.clearSelection(); |
| 20 | } |
| 21 | }, { |
| 22 | name: "replaceAll", |
| 23 | exec: function (editor) { |
| 24 | if (!editor.searchBox) { |
| 25 | config.loadModule("ace/ext/searchbox", function (e) { |
| 26 | e.Search(editor, true); |
| 27 | }); |
| 28 | } |
| 29 | else { |
| 30 | if (editor.searchBox.active === true && editor.searchBox.replaceOption.checked === true) { |
| 31 | editor.searchBox.replaceAll(); |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | }, { |
| 36 | name: "replaceOne", |
| 37 | exec: function (editor) { |
| 38 | if (!editor.searchBox) { |
| 39 | config.loadModule("ace/ext/searchbox", function (e) { |
| 40 | e.Search(editor, true); |
| 41 | }); |
| 42 | } |
| 43 | else { |
| 44 | if (editor.searchBox.active === true && editor.searchBox.replaceOption.checked === true) { |
| 45 | editor.searchBox.replace(); |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | }, { |
| 50 | name: "selectAllMatches", |
| 51 | exec: function (editor) { |
| 52 | if (!editor.searchBox) { |
| 53 | config.loadModule("ace/ext/searchbox", function (e) { |
| 54 | e.Search(editor, false); |
| 55 | }); |
| 56 | } |
| 57 | else { |
| 58 | if (editor.searchBox.active === true) { |
| 59 | editor.searchBox.findAll(); |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | }, { |
| 64 | name: "toggleFindCaseSensitive", |
| 65 | exec: function (editor) { |
| 66 | config.loadModule("ace/ext/searchbox", function (e) { |
| 67 | e.Search(editor, false); |
| 68 | var sb = editor.searchBox; |
| 69 | sb.caseSensitiveOption.checked = !sb.caseSensitiveOption.checked; |
| 70 | sb.$syncOptions(); |
| 71 | }); |
| 72 | } |
| 73 | }, { |
| 74 | name: "toggleFindInSelection", |
| 75 | exec: function (editor) { |
| 76 | config.loadModule("ace/ext/searchbox", function (e) { |
| 77 | e.Search(editor, false); |
| 78 | var sb = editor.searchBox; |
| 79 | sb.searchOption.checked = !sb.searchRange; |
| 80 | sb.setSearchRange(sb.searchOption.checked && sb.editor.getSelectionRange()); |
| 81 | sb.$syncOptions(); |
| 82 | }); |
| 83 | } |
| 84 | }, { |
| 85 | name: "toggleFindRegex", |
| 86 | exec: function (editor) { |
| 87 | config.loadModule("ace/ext/searchbox", function (e) { |
| 88 | e.Search(editor, false); |
| 89 | var sb = editor.searchBox; |
| 90 | sb.regExpOption.checked = !sb.regExpOption.checked; |
| 91 | sb.$syncOptions(); |
| 92 | }); |
| 93 | } |
| 94 | }, { |
| 95 | name: "toggleFindWholeWord", |
| 96 | exec: function (editor) { |
| 97 | config.loadModule("ace/ext/searchbox", function (e) { |
| 98 | e.Search(editor, false); |
| 99 | var sb = editor.searchBox; |
| 100 | sb.wholeWordOption.checked = !sb.wholeWordOption.checked; |
| 101 | sb.$syncOptions(); |
| 102 | }); |
| 103 | } |
| 104 | }, { |
| 105 | name: "removeSecondaryCursors", |
| 106 | exec: function (editor) { |
| 107 | var ranges = editor.selection.ranges; |
| 108 | if (ranges && ranges.length > 1) |
| 109 | editor.selection.toSingleRange(ranges[ranges.length - 1]); |
| 110 | else |
| 111 | editor.selection.clearSelection(); |
| 112 | } |
| 113 | }]); |
| 114 | [{ |
| 115 | bindKey: { mac: "Ctrl-G", win: "Ctrl-G" }, |
| 116 | name: "gotoline" |
| 117 | }, { |
| 118 | bindKey: { mac: "Command-Shift-L|Command-F2", win: "Ctrl-Shift-L|Ctrl-F2" }, |
| 119 | name: "findAll" |
| 120 | }, { |
| 121 | bindKey: { mac: "Shift-F8|Shift-Option-F8", win: "Shift-F8|Shift-Alt-F8" }, |
| 122 | name: "goToPreviousError" |
| 123 | }, { |
| 124 | bindKey: { mac: "F8|Option-F8", win: "F8|Alt-F8" }, |
| 125 | name: "goToNextError" |
| 126 | }, { |
| 127 | bindKey: { mac: "Command-Shift-P|F1", win: "Ctrl-Shift-P|F1" }, |
| 128 | name: "openCommandPalette" |
| 129 | }, { |
| 130 | bindKey: { mac: "Shift-Option-Up", win: "Alt-Shift-Up" }, |
| 131 | name: "copylinesup" |
| 132 | }, { |
| 133 | bindKey: { mac: "Shift-Option-Down", win: "Alt-Shift-Down" }, |
| 134 | name: "copylinesdown" |
| 135 | }, { |
| 136 | bindKey: { mac: "Command-Shift-K", win: "Ctrl-Shift-K" }, |
| 137 | name: "removeline" |
| 138 | }, { |
| 139 | bindKey: { mac: "Command-Enter", win: "Ctrl-Enter" }, |
| 140 | name: "addLineAfter" |
| 141 | }, { |
| 142 | bindKey: { mac: "Command-Shift-Enter", win: "Ctrl-Shift-Enter" }, |
| 143 | name: "addLineBefore" |
| 144 | }, { |
| 145 | bindKey: { mac: "Command-Shift-\\", win: "Ctrl-Shift-\\" }, |
| 146 | name: "jumptomatching" |
| 147 | }, { |
| 148 | bindKey: { mac: "Command-]", win: "Ctrl-]" }, |
| 149 | name: "blockindent" |
| 150 | }, { |
| 151 | bindKey: { mac: "Command-[", win: "Ctrl-[" }, |
| 152 | name: "blockoutdent" |
| 153 | }, { |
| 154 | bindKey: { mac: "Ctrl-PageDown", win: "Alt-PageDown" }, |
| 155 | name: "pagedown" |
| 156 | }, { |
| 157 | bindKey: { mac: "Ctrl-PageUp", win: "Alt-PageUp" }, |
| 158 | name: "pageup" |
| 159 | }, { |
| 160 | bindKey: { mac: "Shift-Option-A", win: "Shift-Alt-A" }, |
| 161 | name: "toggleBlockComment" |
| 162 | }, { |
| 163 | bindKey: { mac: "Option-Z", win: "Alt-Z" }, |
| 164 | name: "toggleWordWrap" |
| 165 | }, { |
| 166 | bindKey: { mac: "Command-G", win: "F3|Ctrl-K Ctrl-D" }, |
| 167 | name: "findnext" |
| 168 | }, { |
| 169 | bindKey: { mac: "Command-Shift-G", win: "Shift-F3" }, |
| 170 | name: "findprevious" |
| 171 | }, { |
| 172 | bindKey: { mac: "Option-Enter", win: "Alt-Enter" }, |
| 173 | name: "selectAllMatches" |
| 174 | }, { |
| 175 | bindKey: { mac: "Command-D", win: "Ctrl-D" }, |
| 176 | name: "selectMoreAfter" |
| 177 | }, { |
| 178 | bindKey: { mac: "Command-K Command-D", win: "Ctrl-K Ctrl-D" }, |
| 179 | name: "selectOrFindNext" |
| 180 | }, { |
| 181 | bindKey: { mac: "Shift-Option-I", win: "Shift-Alt-I" }, |
| 182 | name: "splitSelectionIntoLines" |
| 183 | }, { |
| 184 | bindKey: { mac: "Command-K M", win: "Ctrl-K M" }, |
| 185 | name: "modeSelect" |
| 186 | }, { |
| 187 | bindKey: { mac: "Command-Option-[", win: "Ctrl-Shift-[" }, |
| 188 | name: "toggleFoldWidget" |
| 189 | }, { |
| 190 | bindKey: { mac: "Command-Option-]", win: "Ctrl-Shift-]" }, |
| 191 | name: "toggleFoldWidget" |
| 192 | }, { |
| 193 | bindKey: { mac: "Command-K Command-0", win: "Ctrl-K Ctrl-0" }, |
| 194 | name: "foldall" |
| 195 | }, { |
| 196 | bindKey: { mac: "Command-K Command-J", win: "Ctrl-K Ctrl-J" }, |
| 197 | name: "unfoldall" |
| 198 | }, { |
| 199 | bindKey: { mac: "Command-K Command-1", win: "Ctrl-K Ctrl-1" }, |
| 200 | name: "foldOther" |
| 201 | }, { |
| 202 | bindKey: { mac: "Command-K Command-Q", win: "Ctrl-K Ctrl-Q" }, |
| 203 | name: "navigateToLastEditLocation" |
| 204 | }, { |
| 205 | bindKey: { mac: "Command-K Command-R|Command-K Command-S", win: "Ctrl-K Ctrl-R|Ctrl-K Ctrl-S" }, |
| 206 | name: "showKeyboardShortcuts" |
| 207 | }, { |
| 208 | bindKey: { mac: "Command-K Command-X", win: "Ctrl-K Ctrl-X" }, |
| 209 | name: "trimTrailingSpace" |
| 210 | }, { |
| 211 | bindKey: { mac: "Shift-Down|Command-Shift-Down", win: "Shift-Down|Ctrl-Shift-Down" }, |
| 212 | name: "selectdown" |
| 213 | }, { |
| 214 | bindKey: { mac: "Shift-Up|Command-Shift-Up", win: "Shift-Up|Ctrl-Shift-Up" }, |
| 215 | name: "selectup" |
| 216 | }, { |
| 217 | bindKey: { mac: "Command-Alt-Enter", win: "Ctrl-Alt-Enter" }, |
| 218 | name: "replaceAll" |
| 219 | }, { |
| 220 | bindKey: { mac: "Command-Shift-1", win: "Ctrl-Shift-1" }, |
| 221 | name: "replaceOne" |
| 222 | }, { |
| 223 | bindKey: { mac: "Option-C", win: "Alt-C" }, |
| 224 | name: "toggleFindCaseSensitive" |
| 225 | }, { |
| 226 | bindKey: { mac: "Option-L", win: "Alt-L" }, |
| 227 | name: "toggleFindInSelection" |
| 228 | }, { |
| 229 | bindKey: { mac: "Option-R", win: "Alt-R" }, |
| 230 | name: "toggleFindRegex" |
| 231 | }, { |
| 232 | bindKey: { mac: "Option-W", win: "Alt-W" }, |
| 233 | name: "toggleFindWholeWord" |
| 234 | }, { |
| 235 | bindKey: { mac: "Command-L", win: "Ctrl-L" }, |
| 236 | name: "expandtoline" |
| 237 | }, { |
| 238 | bindKey: { mac: "Shift-Esc", win: "Shift-Esc" }, |
| 239 | name: "removeSecondaryCursors" |
| 240 | } |
| 241 | ].forEach(function (binding) { |
| 242 | var command = exports.handler.commands[binding.name]; |
| 243 | if (command) |
| 244 | command.bindKey = binding.bindKey; |
| 245 | exports.handler.bindKey(binding.bindKey, command || binding.name); |
| 246 | }); |
| 247 | |
| 248 | }); (function() { |
| 249 | ace.require(["ace/keyboard/vscode"], function(m) { |
| 250 | if (typeof module == "object" && typeof exports == "object" && module) { |
| 251 | module.exports = m; |
| 252 | } |
| 253 | }); |
| 254 | })(); |
| 255 |