multi_select_commands.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Distributed under the BSD license:
  3. *
  4. * Copyright (c) 2010, Ajax.org B.V.
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * * Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * * Neither the name of Ajax.org B.V. nor the
  15. * names of its contributors may be used to endorse or promote products
  16. * derived from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *
  29. * ***** END LICENSE BLOCK ***** */
  30. define(function(require, exports, module) {
  31. // commands to enter multiselect mode
  32. exports.defaultCommands = [{
  33. name: "addCursorAbove",
  34. exec: function(editor) { editor.selectMoreLines(-1); },
  35. bindKey: {win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up"},
  36. scrollIntoView: "cursor",
  37. readOnly: true
  38. }, {
  39. name: "addCursorBelow",
  40. exec: function(editor) { editor.selectMoreLines(1); },
  41. bindKey: {win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down"},
  42. scrollIntoView: "cursor",
  43. readOnly: true
  44. }, {
  45. name: "addCursorAboveSkipCurrent",
  46. exec: function(editor) { editor.selectMoreLines(-1, true); },
  47. bindKey: {win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up"},
  48. scrollIntoView: "cursor",
  49. readOnly: true
  50. }, {
  51. name: "addCursorBelowSkipCurrent",
  52. exec: function(editor) { editor.selectMoreLines(1, true); },
  53. bindKey: {win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down"},
  54. scrollIntoView: "cursor",
  55. readOnly: true
  56. }, {
  57. name: "selectMoreBefore",
  58. exec: function(editor) { editor.selectMore(-1); },
  59. bindKey: {win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left"},
  60. scrollIntoView: "cursor",
  61. readOnly: true
  62. }, {
  63. name: "selectMoreAfter",
  64. exec: function(editor) { editor.selectMore(1); },
  65. bindKey: {win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right"},
  66. scrollIntoView: "cursor",
  67. readOnly: true
  68. }, {
  69. name: "selectNextBefore",
  70. exec: function(editor) { editor.selectMore(-1, true); },
  71. bindKey: {win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left"},
  72. scrollIntoView: "cursor",
  73. readOnly: true
  74. }, {
  75. name: "selectNextAfter",
  76. exec: function(editor) { editor.selectMore(1, true); },
  77. bindKey: {win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right"},
  78. scrollIntoView: "cursor",
  79. readOnly: true
  80. }, {
  81. name: "splitIntoLines",
  82. exec: function(editor) { editor.multiSelect.splitIntoLines(); },
  83. bindKey: {win: "Ctrl-Alt-L", mac: "Ctrl-Alt-L"},
  84. readOnly: true
  85. }, {
  86. name: "alignCursors",
  87. exec: function(editor) { editor.alignCursors(); },
  88. bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"},
  89. scrollIntoView: "cursor"
  90. }, {
  91. name: "findAll",
  92. exec: function(editor) { editor.findAll(); },
  93. bindKey: {win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G"},
  94. scrollIntoView: "cursor",
  95. readOnly: true
  96. }];
  97. // commands active only in multiselect mode
  98. exports.multiSelectCommands = [{
  99. name: "singleSelection",
  100. bindKey: "esc",
  101. exec: function(editor) { editor.exitMultiSelectMode(); },
  102. scrollIntoView: "cursor",
  103. readOnly: true,
  104. isAvailable: function(editor) {return editor && editor.inMultiSelectMode}
  105. }];
  106. var HashHandler = require("../keyboard/hash_handler").HashHandler;
  107. exports.keyboardHandler = new HashHandler(exports.multiSelectCommands);
  108. });