c2211097bdd3f83d85c3561d18ed1056.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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: "openCommandPallete"
  129. }, {
  130. bindKey: { mac: "Command-K|Command-S", win: "Ctrl-K|Ctrl-S" },
  131. name: "showKeyboardShortcuts"
  132. }, {
  133. bindKey: { mac: "Shift-Option-Up", win: "Alt-Shift-Up" },
  134. name: "copylinesup"
  135. }, {
  136. bindKey: { mac: "Shift-Option-Down", win: "Alt-Shift-Down" },
  137. name: "copylinesdown"
  138. }, {
  139. bindKey: { mac: "Command-Shift-K", win: "Ctrl-Shift-K" },
  140. name: "removeline"
  141. }, {
  142. bindKey: { mac: "Command-Enter", win: "Ctrl-Enter" },
  143. name: "addLineAfter"
  144. }, {
  145. bindKey: { mac: "Command-Shift-Enter", win: "Ctrl-Shift-Enter" },
  146. name: "addLineBefore"
  147. }, {
  148. bindKey: { mac: "Command-Shift-\\", win: "Ctrl-Shift-\\" },
  149. name: "jumptomatching"
  150. }, {
  151. bindKey: { mac: "Command-]", win: "Ctrl-]" },
  152. name: "blockindent"
  153. }, {
  154. bindKey: { mac: "Command-[", win: "Ctrl-[" },
  155. name: "blockoutdent"
  156. }, {
  157. bindKey: { mac: "Ctrl-PageDown", win: "Alt-PageDown" },
  158. name: "pagedown"
  159. }, {
  160. bindKey: { mac: "Ctrl-PageUp", win: "Alt-PageUp" },
  161. name: "pageup"
  162. }, {
  163. bindKey: { mac: "Shift-Option-A", win: "Shift-Alt-A" },
  164. name: "toggleBlockComment"
  165. }, {
  166. bindKey: { mac: "Option-Z", win: "Alt-Z" },
  167. name: "toggleWordWrap"
  168. }, {
  169. bindKey: { mac: "Command-G", win: "F3|Ctrl-K Ctrl-D" },
  170. name: "findnext"
  171. }, {
  172. bindKey: { mac: "Command-Shift-G", win: "Shift-F3" },
  173. name: "findprevious"
  174. }, {
  175. bindKey: { mac: "Option-Enter", win: "Alt-Enter" },
  176. name: "selectAllMatches"
  177. }, {
  178. bindKey: { mac: "Command-D", win: "Ctrl-D" },
  179. name: "selectMoreAfter"
  180. }, {
  181. bindKey: { mac: "Command-K Command-D", win: "Ctrl-K Ctrl-D" },
  182. name: "selectOrFindNext"
  183. }, {
  184. bindKey: { mac: "Shift-Option-I", win: "Shift-Alt-I" },
  185. name: "splitSelectionIntoLines"
  186. }, {
  187. bindKey: { mac: "Command-K M", win: "Ctrl-K M" },
  188. name: "modeSelect"
  189. }, {
  190. bindKey: { mac: "Command-Option-[", win: "Ctrl-Shift-[" },
  191. name: "toggleFoldWidget"
  192. }, {
  193. bindKey: { mac: "Command-Option-]", win: "Ctrl-Shift-]" },
  194. name: "toggleFoldWidget"
  195. }, {
  196. bindKey: { mac: "Command-K Command-0", win: "Ctrl-K Ctrl-0" },
  197. name: "foldall"
  198. }, {
  199. bindKey: { mac: "Command-K Command-J", win: "Ctrl-K Ctrl-J" },
  200. name: "unfoldall"
  201. }, {
  202. bindKey: { mac: "Command-K Command-1", win: "Ctrl-K Ctrl-1" },
  203. name: "foldOther"
  204. }, {
  205. bindKey: { mac: "Command-K Command-Q", win: "Ctrl-K Ctrl-Q" },
  206. name: "navigateToLastEditLocation"
  207. }, {
  208. bindKey: { mac: "Command-K Command-R|Command-K Command-S", win: "Ctrl-K Ctrl-R|Ctrl-K Ctrl-S" },
  209. name: "showKeyboardShortcuts"
  210. }, {
  211. bindKey: { mac: "Command-K Command-X", win: "Ctrl-K Ctrl-X" },
  212. name: "trimTrailingSpace"
  213. }, {
  214. bindKey: { mac: "Shift-Down|Command-Shift-Down", win: "Shift-Down|Ctrl-Shift-Down" },
  215. name: "selectdown"
  216. }, {
  217. bindKey: { mac: "Shift-Up|Command-Shift-Up", win: "Shift-Up|Ctrl-Shift-Up" },
  218. name: "selectup"
  219. }, {
  220. bindKey: { mac: "Command-Alt-Enter", win: "Ctrl-Alt-Enter" },
  221. name: "replaceAll"
  222. }, {
  223. bindKey: { mac: "Command-Shift-1", win: "Ctrl-Shift-1" },
  224. name: "replaceOne"
  225. }, {
  226. bindKey: { mac: "Option-C", win: "Alt-C" },
  227. name: "toggleFindCaseSensitive"
  228. }, {
  229. bindKey: { mac: "Option-L", win: "Alt-L" },
  230. name: "toggleFindInSelection"
  231. }, {
  232. bindKey: { mac: "Option-R", win: "Alt-R" },
  233. name: "toggleFindRegex"
  234. }, {
  235. bindKey: { mac: "Option-W", win: "Alt-W" },
  236. name: "toggleFindWholeWord"
  237. }, {
  238. bindKey: { mac: "Command-L", win: "Ctrl-L" },
  239. name: "expandtoline"
  240. }, {
  241. bindKey: { mac: "Shift-Esc", win: "Shift-Esc" },
  242. name: "removeSecondaryCursors"
  243. }
  244. ].forEach(function (binding) {
  245. var command = exports.handler.commands[binding.name];
  246. if (command)
  247. command.bindKey = binding.bindKey;
  248. exports.handler.bindKey(binding.bindKey, command || binding.name);
  249. });
  250. }); (function() {
  251. ace.require(["ace/keyboard/vscode"], function(m) {
  252. if (typeof module == "object" && typeof exports == "object" && module) {
  253. module.exports = m;
  254. }
  255. });
  256. })();