aced_rails 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. data/README.md +59 -11
  2. data/lib/aced_rails.rb +2 -0
  3. data/lib/aced_rails/config.rb +43 -0
  4. data/lib/aced_rails/engine.rb +4 -0
  5. data/lib/aced_rails/helpers.rb +13 -0
  6. data/lib/aced_rails/version.rb +1 -1
  7. data/lib/generators/aced_rails/install_generator.rb +12 -0
  8. data/lib/generators/aced_rails/templates/aced_rails.rb +23 -0
  9. data/vendor/assets/javascripts/ace/ace-noconflict.js +1 -1
  10. data/vendor/assets/javascripts/ace/ace-uncompressed-noconflict.js +594 -2
  11. data/vendor/assets/javascripts/ace/ace-uncompressed.js +594 -2
  12. data/vendor/assets/javascripts/ace/ace.js +1 -1
  13. data/vendor/assets/javascripts/ace/keybinding-emacs-noconflict.js +1 -1
  14. data/vendor/assets/javascripts/ace/keybinding-emacs-uncompressed-noconflict.js +0 -255
  15. data/vendor/assets/javascripts/ace/keybinding-emacs-uncompressed.js +0 -255
  16. data/vendor/assets/javascripts/ace/keybinding-emacs.js +1 -1
  17. data/vendor/assets/javascripts/ace/keybinding-vim-noconflict.js +1 -1
  18. data/vendor/assets/javascripts/ace/keybinding-vim-uncompressed-noconflict.js +0 -255
  19. data/vendor/assets/javascripts/ace/keybinding-vim-uncompressed.js +0 -255
  20. data/vendor/assets/javascripts/ace/keybinding-vim.js +1 -1
  21. data/vendor/assets/javascripts/ace/mode-coldfusion-noconflict.js +1 -1
  22. data/vendor/assets/javascripts/ace/mode-coldfusion-uncompressed-noconflict.js +35 -5
  23. data/vendor/assets/javascripts/ace/mode-coldfusion-uncompressed.js +35 -5
  24. data/vendor/assets/javascripts/ace/mode-coldfusion.js +1 -1
  25. data/vendor/assets/javascripts/ace/mode-css-noconflict.js +1 -1
  26. data/vendor/assets/javascripts/ace/mode-css-uncompressed-noconflict.js +16 -4
  27. data/vendor/assets/javascripts/ace/mode-css-uncompressed.js +16 -4
  28. data/vendor/assets/javascripts/ace/mode-css.js +1 -1
  29. data/vendor/assets/javascripts/ace/mode-groovy-noconflict.js +1 -1
  30. data/vendor/assets/javascripts/ace/mode-groovy-uncompressed-noconflict.js +19 -1
  31. data/vendor/assets/javascripts/ace/mode-groovy-uncompressed.js +19 -1
  32. data/vendor/assets/javascripts/ace/mode-groovy.js +1 -1
  33. data/vendor/assets/javascripts/ace/mode-html-noconflict.js +1 -1
  34. data/vendor/assets/javascripts/ace/mode-html-uncompressed-noconflict.js +35 -5
  35. data/vendor/assets/javascripts/ace/mode-html-uncompressed.js +35 -5
  36. data/vendor/assets/javascripts/ace/mode-html.js +1 -1
  37. data/vendor/assets/javascripts/ace/mode-java-noconflict.js +1 -1
  38. data/vendor/assets/javascripts/ace/mode-java-uncompressed-noconflict.js +19 -1
  39. data/vendor/assets/javascripts/ace/mode-java-uncompressed.js +19 -1
  40. data/vendor/assets/javascripts/ace/mode-java.js +1 -1
  41. data/vendor/assets/javascripts/ace/mode-javascript-noconflict.js +1 -1
  42. data/vendor/assets/javascripts/ace/mode-javascript-uncompressed-noconflict.js +19 -1
  43. data/vendor/assets/javascripts/ace/mode-javascript-uncompressed.js +19 -1
  44. data/vendor/assets/javascripts/ace/mode-javascript.js +1 -1
  45. data/vendor/assets/javascripts/ace/mode-markdown-noconflict.js +1 -1
  46. data/vendor/assets/javascripts/ace/mode-markdown-uncompressed-noconflict.js +35 -5
  47. data/vendor/assets/javascripts/ace/mode-markdown-uncompressed.js +35 -5
  48. data/vendor/assets/javascripts/ace/mode-markdown.js +1 -1
  49. data/vendor/assets/javascripts/ace/mode-php-noconflict.js +1 -1
  50. data/vendor/assets/javascripts/ace/mode-php-uncompressed-noconflict.js +7 -7
  51. data/vendor/assets/javascripts/ace/mode-php-uncompressed.js +7 -7
  52. data/vendor/assets/javascripts/ace/mode-php.js +1 -1
  53. data/vendor/assets/javascripts/ace/mode-scala-noconflict.js +1 -1
  54. data/vendor/assets/javascripts/ace/mode-scala-uncompressed-noconflict.js +19 -1
  55. data/vendor/assets/javascripts/ace/mode-scala-uncompressed.js +19 -1
  56. data/vendor/assets/javascripts/ace/mode-scala.js +1 -1
  57. data/vendor/assets/javascripts/ace/mode-sh-noconflict.js +1 -1
  58. data/vendor/assets/javascripts/ace/mode-sh-uncompressed-noconflict.js +20 -7
  59. data/vendor/assets/javascripts/ace/mode-sh-uncompressed.js +20 -7
  60. data/vendor/assets/javascripts/ace/mode-sh.js +1 -1
  61. data/vendor/assets/javascripts/ace/mode-svg-noconflict.js +1 -1
  62. data/vendor/assets/javascripts/ace/mode-svg-uncompressed-noconflict.js +19 -1
  63. data/vendor/assets/javascripts/ace/mode-svg-uncompressed.js +19 -1
  64. data/vendor/assets/javascripts/ace/mode-svg.js +1 -1
  65. data/vendor/assets/javascripts/ace/mode-xquery-noconflict.js +1 -0
  66. data/vendor/assets/javascripts/ace/mode-xquery-uncompressed-noconflict.js +538 -0
  67. data/vendor/assets/javascripts/ace/mode-xquery-uncompressed.js +538 -0
  68. data/vendor/assets/javascripts/ace/mode-xquery.js +1 -0
  69. data/vendor/assets/javascripts/ace/theme-clouds-noconflict.js +1 -1
  70. data/vendor/assets/javascripts/ace/theme-clouds-uncompressed-noconflict.js +1 -1
  71. data/vendor/assets/javascripts/ace/theme-clouds-uncompressed.js +1 -1
  72. data/vendor/assets/javascripts/ace/theme-clouds.js +1 -1
  73. data/vendor/assets/javascripts/ace/theme-clouds_midnight-noconflict.js +1 -1
  74. data/vendor/assets/javascripts/ace/theme-clouds_midnight-uncompressed-noconflict.js +1 -1
  75. data/vendor/assets/javascripts/ace/theme-clouds_midnight-uncompressed.js +1 -1
  76. data/vendor/assets/javascripts/ace/theme-clouds_midnight.js +1 -1
  77. data/vendor/assets/javascripts/ace/theme-cobalt-noconflict.js +1 -1
  78. data/vendor/assets/javascripts/ace/theme-cobalt-uncompressed-noconflict.js +6 -2
  79. data/vendor/assets/javascripts/ace/theme-cobalt-uncompressed.js +6 -2
  80. data/vendor/assets/javascripts/ace/theme-cobalt.js +1 -1
  81. data/vendor/assets/javascripts/ace/theme-dawn-noconflict.js +1 -1
  82. data/vendor/assets/javascripts/ace/theme-dawn-uncompressed-noconflict.js +6 -2
  83. data/vendor/assets/javascripts/ace/theme-dawn-uncompressed.js +6 -2
  84. data/vendor/assets/javascripts/ace/theme-dawn.js +1 -1
  85. data/vendor/assets/javascripts/ace/theme-idle_fingers-noconflict.js +1 -1
  86. data/vendor/assets/javascripts/ace/theme-idle_fingers-uncompressed-noconflict.js +6 -2
  87. data/vendor/assets/javascripts/ace/theme-idle_fingers-uncompressed.js +6 -2
  88. data/vendor/assets/javascripts/ace/theme-idle_fingers.js +1 -1
  89. data/vendor/assets/javascripts/ace/theme-kr_theme-noconflict.js +1 -1
  90. data/vendor/assets/javascripts/ace/theme-kr_theme-uncompressed-noconflict.js +6 -2
  91. data/vendor/assets/javascripts/ace/theme-kr_theme-uncompressed.js +6 -2
  92. data/vendor/assets/javascripts/ace/theme-kr_theme.js +1 -1
  93. data/vendor/assets/javascripts/ace/theme-merbivore-noconflict.js +1 -1
  94. data/vendor/assets/javascripts/ace/theme-merbivore-uncompressed-noconflict.js +6 -2
  95. data/vendor/assets/javascripts/ace/theme-merbivore-uncompressed.js +6 -2
  96. data/vendor/assets/javascripts/ace/theme-merbivore.js +1 -1
  97. data/vendor/assets/javascripts/ace/theme-merbivore_soft-noconflict.js +1 -1
  98. data/vendor/assets/javascripts/ace/theme-merbivore_soft-uncompressed-noconflict.js +6 -2
  99. data/vendor/assets/javascripts/ace/theme-merbivore_soft-uncompressed.js +6 -2
  100. data/vendor/assets/javascripts/ace/theme-merbivore_soft.js +1 -1
  101. data/vendor/assets/javascripts/ace/theme-mono_industrial-noconflict.js +1 -1
  102. data/vendor/assets/javascripts/ace/theme-mono_industrial-uncompressed-noconflict.js +10 -2
  103. data/vendor/assets/javascripts/ace/theme-mono_industrial-uncompressed.js +10 -2
  104. data/vendor/assets/javascripts/ace/theme-mono_industrial.js +1 -1
  105. data/vendor/assets/javascripts/ace/theme-monokai-noconflict.js +1 -1
  106. data/vendor/assets/javascripts/ace/theme-monokai-uncompressed-noconflict.js +14 -2
  107. data/vendor/assets/javascripts/ace/theme-monokai-uncompressed.js +14 -2
  108. data/vendor/assets/javascripts/ace/theme-monokai.js +1 -1
  109. data/vendor/assets/javascripts/ace/theme-pastel_on_dark-noconflict.js +1 -1
  110. data/vendor/assets/javascripts/ace/theme-pastel_on_dark-uncompressed-noconflict.js +2 -2
  111. data/vendor/assets/javascripts/ace/theme-pastel_on_dark-uncompressed.js +2 -2
  112. data/vendor/assets/javascripts/ace/theme-pastel_on_dark.js +1 -1
  113. data/vendor/assets/javascripts/ace/theme-solarized_dark-noconflict.js +1 -1
  114. data/vendor/assets/javascripts/ace/theme-solarized_dark-uncompressed-noconflict.js +9 -1
  115. data/vendor/assets/javascripts/ace/theme-solarized_dark-uncompressed.js +9 -1
  116. data/vendor/assets/javascripts/ace/theme-solarized_dark.js +1 -1
  117. data/vendor/assets/javascripts/ace/theme-solarized_light-noconflict.js +1 -1
  118. data/vendor/assets/javascripts/ace/theme-solarized_light-uncompressed-noconflict.js +9 -1
  119. data/vendor/assets/javascripts/ace/theme-solarized_light-uncompressed.js +9 -1
  120. data/vendor/assets/javascripts/ace/theme-solarized_light.js +1 -1
  121. data/vendor/assets/javascripts/ace/theme-tomorrow-noconflict.js +1 -1
  122. data/vendor/assets/javascripts/ace/theme-tomorrow-uncompressed-noconflict.js +14 -2
  123. data/vendor/assets/javascripts/ace/theme-tomorrow-uncompressed.js +14 -2
  124. data/vendor/assets/javascripts/ace/theme-tomorrow.js +1 -1
  125. data/vendor/assets/javascripts/ace/theme-tomorrow_night-noconflict.js +1 -1
  126. data/vendor/assets/javascripts/ace/theme-tomorrow_night-uncompressed-noconflict.js +14 -2
  127. data/vendor/assets/javascripts/ace/theme-tomorrow_night-uncompressed.js +14 -2
  128. data/vendor/assets/javascripts/ace/theme-tomorrow_night.js +1 -1
  129. data/vendor/assets/javascripts/ace/theme-tomorrow_night_blue-noconflict.js +1 -1
  130. data/vendor/assets/javascripts/ace/theme-tomorrow_night_blue-uncompressed-noconflict.js +14 -2
  131. data/vendor/assets/javascripts/ace/theme-tomorrow_night_blue-uncompressed.js +14 -2
  132. data/vendor/assets/javascripts/ace/theme-tomorrow_night_blue.js +1 -1
  133. data/vendor/assets/javascripts/ace/theme-tomorrow_night_bright-noconflict.js +1 -1
  134. data/vendor/assets/javascripts/ace/theme-tomorrow_night_bright-uncompressed-noconflict.js +14 -2
  135. data/vendor/assets/javascripts/ace/theme-tomorrow_night_bright-uncompressed.js +14 -2
  136. data/vendor/assets/javascripts/ace/theme-tomorrow_night_bright.js +1 -1
  137. data/vendor/assets/javascripts/ace/theme-tomorrow_night_eighties-noconflict.js +1 -1
  138. data/vendor/assets/javascripts/ace/theme-tomorrow_night_eighties-uncompressed-noconflict.js +14 -2
  139. data/vendor/assets/javascripts/ace/theme-tomorrow_night_eighties-uncompressed.js +14 -2
  140. data/vendor/assets/javascripts/ace/theme-tomorrow_night_eighties.js +1 -1
  141. data/vendor/assets/javascripts/ace/theme-twilight-noconflict.js +1 -1
  142. data/vendor/assets/javascripts/ace/theme-twilight-uncompressed-noconflict.js +10 -2
  143. data/vendor/assets/javascripts/ace/theme-twilight-uncompressed.js +10 -2
  144. data/vendor/assets/javascripts/ace/theme-twilight.js +1 -1
  145. data/vendor/assets/javascripts/ace/theme-vibrant_ink-noconflict.js +1 -1
  146. data/vendor/assets/javascripts/ace/theme-vibrant_ink-uncompressed-noconflict.js +6 -2
  147. data/vendor/assets/javascripts/ace/theme-vibrant_ink-uncompressed.js +6 -2
  148. data/vendor/assets/javascripts/ace/theme-vibrant_ink.js +1 -1
  149. data/vendor/assets/javascripts/ace/worker-coffee.js +1 -1
  150. data/vendor/assets/javascripts/ace/worker-css.js +1 -1
  151. data/vendor/assets/javascripts/ace/worker-javascript.js +1 -1
  152. data/vendor/assets/javascripts/ace/worker-json.js +1 -1
  153. data/vendor/assets/javascripts/aced-api.js.coffee +114 -0
  154. metadata +13 -4
@@ -241,7 +241,7 @@ exportAce(ACE_NAMESPACE);
241
241
  *
242
242
  * ***** END LICENSE BLOCK ***** */
243
243
 
244
- define('ace/ace', ['require', 'exports', 'module' , 'ace/lib/fixoldbrowsers', 'ace/lib/dom', 'ace/lib/event', 'ace/editor', 'ace/edit_session', 'ace/undomanager', 'ace/virtual_renderer', 'ace/worker/worker_client', 'ace/config', 'ace/theme/textmate'], function(require, exports, module) {
244
+ define('ace/ace', ['require', 'exports', 'module' , 'ace/lib/fixoldbrowsers', 'ace/lib/dom', 'ace/lib/event', 'ace/editor', 'ace/edit_session', 'ace/undomanager', 'ace/virtual_renderer', 'ace/worker/worker_client', 'ace/keyboard/hash_handler', 'ace/keyboard/state_handler', 'ace/lib/net', 'ace/placeholder', 'ace/config', 'ace/theme/textmate'], function(require, exports, module) {
245
245
  "use strict";
246
246
 
247
247
  require("./lib/fixoldbrowsers");
@@ -254,7 +254,12 @@ var EditSession = require("./edit_session").EditSession;
254
254
  var UndoManager = require("./undomanager").UndoManager;
255
255
  var Renderer = require("./virtual_renderer").VirtualRenderer;
256
256
 
257
+ // The following require()s are for inclusion in the built ace file
257
258
  require("./worker/worker_client");
259
+ require("./keyboard/hash_handler");
260
+ require("./keyboard/state_handler");
261
+ require("./lib/net");
262
+ require("./placeholder");
258
263
  require("./config").init();
259
264
 
260
265
  exports.edit = function(el) {
@@ -9125,7 +9130,7 @@ var Document = function(text) {
9125
9130
 
9126
9131
  position = this.$clipPosition(position);
9127
9132
 
9128
- if (this.getLength() <= 1)
9133
+ if (this.getLength() >= 1)
9129
9134
  this.$detectNewLine(text);
9130
9135
 
9131
9136
  var lines = this.$split(text);
@@ -14435,6 +14440,593 @@ var WorkerClient = function(topLevelNamespaces, packagedJs, mod, classname) {
14435
14440
 
14436
14441
  exports.WorkerClient = WorkerClient;
14437
14442
 
14443
+ });
14444
+ /* ***** BEGIN LICENSE BLOCK *****
14445
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
14446
+ *
14447
+ * The contents of this file are subject to the Mozilla Public License Version
14448
+ * 1.1 (the "License"); you may not use this file except in compliance with
14449
+ * the License. You may obtain a copy of the License at
14450
+ * http://www.mozilla.org/MPL/
14451
+ *
14452
+ * Software distributed under the License is distributed on an "AS IS" basis,
14453
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14454
+ * for the specific language governing rights and limitations under the
14455
+ * License.
14456
+ *
14457
+ * The Original Code is Mozilla Skywriter.
14458
+ *
14459
+ * The Initial Developer of the Original Code is
14460
+ * Mozilla.
14461
+ * Portions created by the Initial Developer are Copyright (C) 2009
14462
+ * the Initial Developer. All Rights Reserved.
14463
+ *
14464
+ * Contributor(s):
14465
+ * Fabian Jakobs <fabian AT ajax DOT org>
14466
+ * Julian Viereck (julian.viereck@gmail.com)
14467
+ *
14468
+ * Alternatively, the contents of this file may be used under the terms of
14469
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
14470
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
14471
+ * in which case the provisions of the GPL or the LGPL are applicable instead
14472
+ * of those above. If you wish to allow use of your version of this file only
14473
+ * under the terms of either the GPL or the LGPL, and not to allow others to
14474
+ * use your version of this file under the terms of the MPL, indicate your
14475
+ * decision by deleting the provisions above and replace them with the notice
14476
+ * and other provisions required by the GPL or the LGPL. If you do not delete
14477
+ * the provisions above, a recipient may use your version of this file under
14478
+ * the terms of any one of the MPL, the GPL or the LGPL.
14479
+ *
14480
+ * ***** END LICENSE BLOCK ***** */
14481
+
14482
+ define('ace/keyboard/hash_handler', ['require', 'exports', 'module' , 'ace/lib/keys'], function(require, exports, module) {
14483
+ "use strict";
14484
+
14485
+ var keyUtil = require("../lib/keys");
14486
+
14487
+ function HashHandler(config) {
14488
+ this.setConfig(config);
14489
+ }
14490
+
14491
+ (function() {
14492
+ function splitSafe(s, separator, limit, bLowerCase) {
14493
+ return (bLowerCase && s.toLowerCase() || s)
14494
+ .replace(/(?:^\s+|\n|\s+$)/g, "")
14495
+ .split(new RegExp("[\\s ]*" + separator + "[\\s ]*", "g"), limit || 999);
14496
+ }
14497
+
14498
+ function parseKeys(keys, val, ret) {
14499
+ var key,
14500
+ hashId = 0,
14501
+ parts = splitSafe(keys, "\\-", null, true),
14502
+ i = 0,
14503
+ l = parts.length;
14504
+
14505
+ for (; i < l; ++i) {
14506
+ if (keyUtil.KEY_MODS[parts[i]])
14507
+ hashId = hashId | keyUtil.KEY_MODS[parts[i]];
14508
+ else
14509
+ key = parts[i] || "-"; //when empty, the splitSafe removed a '-'
14510
+ }
14511
+
14512
+ (ret[hashId] || (ret[hashId] = {}))[key] = val;
14513
+ return ret;
14514
+ }
14515
+
14516
+ function objectReverse(obj, keySplit) {
14517
+ var i, j, l, key,
14518
+ ret = {};
14519
+ for (i in obj) {
14520
+ key = obj[i];
14521
+ if (keySplit && typeof key == "string") {
14522
+ key = key.split(keySplit);
14523
+ for (j = 0, l = key.length; j < l; ++j)
14524
+ parseKeys.call(this, key[j], i, ret);
14525
+ }
14526
+ else {
14527
+ parseKeys.call(this, key, i, ret);
14528
+ }
14529
+ }
14530
+ return ret;
14531
+ }
14532
+
14533
+ this.setConfig = function(config) {
14534
+ this.$config = config;
14535
+ if (typeof this.$config.reverse == "undefined")
14536
+ this.$config.reverse = objectReverse.call(this, this.$config, "|");
14537
+ };
14538
+
14539
+ /**
14540
+ * This function is called by keyBinding.
14541
+ */
14542
+ this.handleKeyboard = function(data, hashId, textOrKey, keyCode) {
14543
+ // Figure out if a commandKey was pressed or just some text was insert.
14544
+ if (hashId != 0 || keyCode != 0) {
14545
+ return {
14546
+ command: (this.$config.reverse[hashId] || {})[textOrKey]
14547
+ }
14548
+ } else {
14549
+ return {
14550
+ command: "inserttext",
14551
+ args: {
14552
+ text: textOrKey
14553
+ }
14554
+ }
14555
+ }
14556
+ }
14557
+ }).call(HashHandler.prototype)
14558
+
14559
+ exports.HashHandler = HashHandler;
14560
+ });
14561
+ /* ***** BEGIN LICENSE BLOCK *****
14562
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
14563
+ *
14564
+ * The contents of this file are subject to the Mozilla Public License Version
14565
+ * 1.1 (the "License"); you may not use this file except in compliance with
14566
+ * the License. You may obtain a copy of the License at
14567
+ * http://www.mozilla.org/MPL/
14568
+ *
14569
+ * Software distributed under the License is distributed on an "AS IS" basis,
14570
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14571
+ * for the specific language governing rights and limitations under the
14572
+ * License.
14573
+ *
14574
+ * The Original Code is Mozilla Skywriter.
14575
+ *
14576
+ * The Initial Developer of the Original Code is
14577
+ * Mozilla.
14578
+ * Portions created by the Initial Developer are Copyright (C) 2009
14579
+ * the Initial Developer. All Rights Reserved.
14580
+ *
14581
+ * Contributor(s):
14582
+ * Julian Viereck (julian.viereck@gmail.com)
14583
+ *
14584
+ * Alternatively, the contents of this file may be used under the terms of
14585
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
14586
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
14587
+ * in which case the provisions of the GPL or the LGPL are applicable instead
14588
+ * of those above. If you wish to allow use of your version of this file only
14589
+ * under the terms of either the GPL or the LGPL, and not to allow others to
14590
+ * use your version of this file under the terms of the MPL, indicate your
14591
+ * decision by deleting the provisions above and replace them with the notice
14592
+ * and other provisions required by the GPL or the LGPL. If you do not delete
14593
+ * the provisions above, a recipient may use your version of this file under
14594
+ * the terms of any one of the MPL, the GPL or the LGPL.
14595
+ *
14596
+ * ***** END LICENSE BLOCK ***** */
14597
+
14598
+ define('ace/keyboard/state_handler', ['require', 'exports', 'module' ], function(require, exports, module) {
14599
+ "use strict";
14600
+
14601
+ // If you're developing a new keymapping and want to get an idea what's going
14602
+ // on, then enable debugging.
14603
+ var DEBUG = false;
14604
+
14605
+ function StateHandler(keymapping) {
14606
+ this.keymapping = this.$buildKeymappingRegex(keymapping);
14607
+ }
14608
+
14609
+ StateHandler.prototype = {
14610
+ /**
14611
+ * Build the RegExp from the keymapping as RegExp can't stored directly
14612
+ * in the metadata JSON and as the RegExp used to match the keys/buffer
14613
+ * need to be adapted.
14614
+ */
14615
+ $buildKeymappingRegex: function(keymapping) {
14616
+ for (var state in keymapping) {
14617
+ this.$buildBindingsRegex(keymapping[state]);
14618
+ }
14619
+ return keymapping;
14620
+ },
14621
+
14622
+ $buildBindingsRegex: function(bindings) {
14623
+ // Escape a given Regex string.
14624
+ bindings.forEach(function(binding) {
14625
+ if (binding.key) {
14626
+ binding.key = new RegExp('^' + binding.key + '$');
14627
+ } else if (Array.isArray(binding.regex)) {
14628
+ if (!('key' in binding))
14629
+ binding.key = new RegExp('^' + binding.regex[1] + '$');
14630
+ binding.regex = new RegExp(binding.regex.join('') + '$');
14631
+ } else if (binding.regex) {
14632
+ binding.regex = new RegExp(binding.regex + '$');
14633
+ }
14634
+ });
14635
+ },
14636
+
14637
+ $composeBuffer: function(data, hashId, key, e) {
14638
+ // Initialize the data object.
14639
+ if (data.state == null || data.buffer == null) {
14640
+ data.state = "start";
14641
+ data.buffer = "";
14642
+ }
14643
+
14644
+ var keyArray = [];
14645
+ if (hashId & 1) keyArray.push("ctrl");
14646
+ if (hashId & 8) keyArray.push("command");
14647
+ if (hashId & 2) keyArray.push("option");
14648
+ if (hashId & 4) keyArray.push("shift");
14649
+ if (key) keyArray.push(key);
14650
+
14651
+ var symbolicName = keyArray.join("-");
14652
+ var bufferToUse = data.buffer + symbolicName;
14653
+
14654
+ // Don't add the symbolic name to the key buffer if the alt_ key is
14655
+ // part of the symbolic name. If it starts with alt_, this means
14656
+ // that the user hit an alt keycombo and there will be a single,
14657
+ // new character detected after this event, which then will be
14658
+ // added to the buffer (e.g. alt_j will result in ∆).
14659
+ //
14660
+ // We test for 2 and not for & 2 as we only want to exclude the case where
14661
+ // the option key is pressed alone.
14662
+ if (hashId != 2) {
14663
+ data.buffer = bufferToUse;
14664
+ }
14665
+
14666
+ var bufferObj = {
14667
+ bufferToUse: bufferToUse,
14668
+ symbolicName: symbolicName,
14669
+ };
14670
+
14671
+ if (e) {
14672
+ bufferObj.keyIdentifier = e.keyIdentifier
14673
+ }
14674
+
14675
+ return bufferObj;
14676
+ },
14677
+
14678
+ $find: function(data, buffer, symbolicName, hashId, key, keyIdentifier) {
14679
+ // Holds the command to execute and the args if a command matched.
14680
+ var result = {};
14681
+
14682
+ // Loop over all the bindings of the keymap until a match is found.
14683
+ this.keymapping[data.state].some(function(binding) {
14684
+ var match;
14685
+
14686
+ // Check if the key matches.
14687
+ if (binding.key && !binding.key.test(symbolicName)) {
14688
+ return false;
14689
+ }
14690
+
14691
+ // Check if the regex matches.
14692
+ if (binding.regex && !(match = binding.regex.exec(buffer))) {
14693
+ return false;
14694
+ }
14695
+
14696
+ // Check if the match function matches.
14697
+ if (binding.match && !binding.match(buffer, hashId, key, symbolicName, keyIdentifier)) {
14698
+ return false;
14699
+ }
14700
+
14701
+ // Check for disallowed matches.
14702
+ if (binding.disallowMatches) {
14703
+ for (var i = 0; i < binding.disallowMatches.length; i++) {
14704
+ if (!!match[binding.disallowMatches[i]]) {
14705
+ return false;
14706
+ }
14707
+ }
14708
+ }
14709
+
14710
+ // If there is a command to execute, then figure out the
14711
+ // command and the arguments.
14712
+ if (binding.exec) {
14713
+ result.command = binding.exec;
14714
+
14715
+ // Build the arguments.
14716
+ if (binding.params) {
14717
+ var value;
14718
+ result.args = {};
14719
+ binding.params.forEach(function(param) {
14720
+ if (param.match != null && match != null) {
14721
+ value = match[param.match] || param.defaultValue;
14722
+ } else {
14723
+ value = param.defaultValue;
14724
+ }
14725
+
14726
+ if (param.type === 'number') {
14727
+ value = parseInt(value);
14728
+ }
14729
+
14730
+ result.args[param.name] = value;
14731
+ });
14732
+ }
14733
+ data.buffer = "";
14734
+ }
14735
+
14736
+ // Handle the 'then' property.
14737
+ if (binding.then) {
14738
+ data.state = binding.then;
14739
+ data.buffer = "";
14740
+ }
14741
+
14742
+ // If no command is set, then execute the "null" fake command.
14743
+ if (result.command == null) {
14744
+ result.command = "null";
14745
+ }
14746
+
14747
+ if (DEBUG) {
14748
+ console.log("KeyboardStateMapper#find", binding);
14749
+ }
14750
+ return true;
14751
+ });
14752
+
14753
+ if (result.command) {
14754
+ return result;
14755
+ } else {
14756
+ data.buffer = "";
14757
+ return false;
14758
+ }
14759
+ },
14760
+
14761
+ /**
14762
+ * This function is called by keyBinding.
14763
+ */
14764
+ handleKeyboard: function(data, hashId, key, keyCode, e) {
14765
+ // If we pressed any command key but no other key, then ignore the input.
14766
+ // Otherwise "shift-" is added to the buffer, and later on "shift-g"
14767
+ // which results in "shift-shift-g" which doesn't make sense.
14768
+ if (hashId != 0 && (key == "" || key == String.fromCharCode(0))) {
14769
+ return null;
14770
+ }
14771
+
14772
+ // Compute the current value of the keyboard input buffer.
14773
+ var r = this.$composeBuffer(data, hashId, key, e);
14774
+ var buffer = r.bufferToUse;
14775
+ var symbolicName = r.symbolicName;
14776
+ var keyId = r.keyIdentifier;
14777
+
14778
+ r = this.$find(data, buffer, symbolicName, hashId, key, keyId);
14779
+ if (DEBUG) {
14780
+ console.log("KeyboardStateMapper#match", buffer, symbolicName, r);
14781
+ }
14782
+
14783
+ return r;
14784
+ }
14785
+ }
14786
+
14787
+ /**
14788
+ * This is a useful matching function and therefore is defined here so that
14789
+ * users of KeyboardStateMapper can use it.
14790
+ *
14791
+ * @return boolean
14792
+ * If no command key (Command|Option|Shift|Ctrl) is pressed, it
14793
+ * returns true. If the only the Shift key is pressed + a character
14794
+ * true is returned as well. Otherwise, false is returned.
14795
+ * Summing up, the function returns true whenever the user typed
14796
+ * a normal character on the keyboard and no shortcut.
14797
+ */
14798
+ exports.matchCharacterOnly = function(buffer, hashId, key, symbolicName) {
14799
+ // If no command keys are pressed, then catch the input.
14800
+ if (hashId == 0) {
14801
+ return true;
14802
+ }
14803
+ // If only the shift key is pressed and a character key, then
14804
+ // catch that input as well.
14805
+ else if ((hashId == 4) && key.length == 1) {
14806
+ return true;
14807
+ }
14808
+ // Otherwise, we let the input got through.
14809
+ else {
14810
+ return false;
14811
+ }
14812
+ };
14813
+
14814
+ exports.StateHandler = StateHandler;
14815
+ });
14816
+ /* ***** BEGIN LICENSE BLOCK *****
14817
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
14818
+ *
14819
+ * The contents of this file are subject to the Mozilla Public License Version
14820
+ * 1.1 (the "License"); you may not use this file except in compliance with
14821
+ * the License. You may obtain a copy of the License at
14822
+ * http://www.mozilla.org/MPL/
14823
+ *
14824
+ * Software distributed under the License is distributed on an "AS IS" basis,
14825
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14826
+ * for the specific language governing rights and limitations under the
14827
+ * License.
14828
+ *
14829
+ * The Original Code is Ajax.org Code Editor (ACE).
14830
+ *
14831
+ * The Initial Developer of the Original Code is
14832
+ * Ajax.org B.V.
14833
+ * Portions created by the Initial Developer are Copyright (C) 2010
14834
+ * the Initial Developer. All Rights Reserved.
14835
+ *
14836
+ * Contributor(s):
14837
+ * Zef Hemel <zef@c9.io>
14838
+ *
14839
+ * Alternatively, the contents of this file may be used under the terms of
14840
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
14841
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
14842
+ * in which case the provisions of the GPL or the LGPL are applicable instead
14843
+ * of those above. If you wish to allow use of your version of this file only
14844
+ * under the terms of either the GPL or the LGPL, and not to allow others to
14845
+ * use your version of this file under the terms of the MPL, indicate your
14846
+ * decision by deleting the provisions above and replace them with the notice
14847
+ * and other provisions required by the GPL or the LGPL. If you do not delete
14848
+ * the provisions above, a recipient may use your version of this file under
14849
+ * the terms of any one of the MPL, the GPL or the LGPL.
14850
+ *
14851
+ * ***** END LICENSE BLOCK ***** */
14852
+ define('ace/placeholder', ['require', 'exports', 'module' , 'ace/range', 'ace/lib/event_emitter', 'ace/lib/oop'], function(require, exports, module) {
14853
+ "use strict";
14854
+
14855
+ var Range = require('./range').Range;
14856
+ var EventEmitter = require("./lib/event_emitter").EventEmitter;
14857
+ var oop = require("./lib/oop");
14858
+
14859
+ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) {
14860
+ var _self = this;
14861
+ this.length = length;
14862
+ this.session = session;
14863
+ this.doc = session.getDocument();
14864
+ this.mainClass = mainClass;
14865
+ this.othersClass = othersClass;
14866
+ this.$onUpdate = this.onUpdate.bind(this);
14867
+ this.doc.on("change", this.$onUpdate);
14868
+ this.$others = others;
14869
+
14870
+ this.$onCursorChange = function() {
14871
+ setTimeout(function() {
14872
+ _self.onCursorChange();
14873
+ });
14874
+ };
14875
+
14876
+ this.$pos = pos;
14877
+ // Used for reset
14878
+ var undoStack = session.getUndoManager().$undoStack || session.getUndoManager().$undostack || {length: -1};
14879
+ this.$undoStackDepth = undoStack.length;
14880
+ this.setup();
14881
+
14882
+ session.selection.on("changeCursor", this.$onCursorChange);
14883
+ };
14884
+
14885
+ (function() {
14886
+
14887
+ oop.implement(this, EventEmitter);
14888
+
14889
+ this.setup = function() {
14890
+ var _self = this;
14891
+ var doc = this.doc;
14892
+ var session = this.session;
14893
+ var pos = this.$pos;
14894
+
14895
+ this.pos = doc.createAnchor(pos.row, pos.column);
14896
+ this.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column + this.length), this.mainClass, null, false);
14897
+ this.pos.on("change", function(event) {
14898
+ session.removeMarker(_self.markerId);
14899
+ _self.markerId = session.addMarker(new Range(event.value.row, event.value.column, event.value.row, event.value.column+_self.length), _self.mainClass, null, false);
14900
+ });
14901
+ this.others = [];
14902
+ this.$others.forEach(function(other) {
14903
+ var anchor = doc.createAnchor(other.row, other.column);
14904
+ _self.others.push(anchor);
14905
+ });
14906
+ session.setUndoSelect(false);
14907
+ };
14908
+
14909
+ this.showOtherMarkers = function() {
14910
+ if(this.othersActive) return;
14911
+ var session = this.session;
14912
+ var _self = this;
14913
+ this.othersActive = true;
14914
+ this.others.forEach(function(anchor) {
14915
+ anchor.markerId = session.addMarker(new Range(anchor.row, anchor.column, anchor.row, anchor.column+_self.length), _self.othersClass, null, false);
14916
+ anchor.on("change", function(event) {
14917
+ session.removeMarker(anchor.markerId);
14918
+ anchor.markerId = session.addMarker(new Range(event.value.row, event.value.column, event.value.row, event.value.column+_self.length), _self.othersClass, null, false);
14919
+ });
14920
+ });
14921
+ };
14922
+
14923
+ this.hideOtherMarkers = function() {
14924
+ if(!this.othersActive) return;
14925
+ this.othersActive = false;
14926
+ for (var i = 0; i < this.others.length; i++) {
14927
+ this.session.removeMarker(this.others[i].markerId);
14928
+ }
14929
+ };
14930
+
14931
+ this.onUpdate = function(event) {
14932
+ var delta = event.data;
14933
+ var range = delta.range;
14934
+ if(range.start.row !== range.end.row) return;
14935
+ if(range.start.row !== this.pos.row) return;
14936
+ if (this.$updating) return;
14937
+ this.$updating = true;
14938
+ var lengthDiff = delta.action === "insertText" ? range.end.column - range.start.column : range.start.column - range.end.column;
14939
+
14940
+ if(range.start.column >= this.pos.column && range.start.column <= this.pos.column + this.length + 1) {
14941
+ var distanceFromStart = range.start.column - this.pos.column;
14942
+ this.length += lengthDiff;
14943
+ if(!this.session.$fromUndo) {
14944
+ if(delta.action === "insertText") {
14945
+ for (var i = this.others.length - 1; i >= 0; i--) {
14946
+ var otherPos = this.others[i];
14947
+ var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
14948
+ if(otherPos.row === range.start.row && range.start.column < otherPos.column)
14949
+ newPos.column += lengthDiff;
14950
+ this.doc.insert(newPos, delta.text);
14951
+ }
14952
+ } else if(delta.action === "removeText") {
14953
+ for (var i = this.others.length - 1; i >= 0; i--) {
14954
+ var otherPos = this.others[i];
14955
+ var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
14956
+ if(otherPos.row === range.start.row && range.start.column < otherPos.column)
14957
+ newPos.column += lengthDiff;
14958
+ this.doc.remove(new Range(newPos.row, newPos.column, newPos.row, newPos.column - lengthDiff));
14959
+ }
14960
+ }
14961
+ // Special case: insert in beginning
14962
+ if(range.start.column === this.pos.column && delta.action === "insertText") {
14963
+ setTimeout(function() {
14964
+ this.pos.setPosition(this.pos.row, this.pos.column - lengthDiff);
14965
+ for (var i = 0; i < this.others.length; i++) {
14966
+ var other = this.others[i];
14967
+ var newPos = {row: other.row, column: other.column - lengthDiff};
14968
+ if(other.row === range.start.row && range.start.column < other.column)
14969
+ newPos.column += lengthDiff;
14970
+ other.setPosition(newPos.row, newPos.column);
14971
+ }
14972
+ }.bind(this), 0);
14973
+ }
14974
+ else if(range.start.column === this.pos.column && delta.action === "removeText") {
14975
+ setTimeout(function() {
14976
+ for (var i = 0; i < this.others.length; i++) {
14977
+ var other = this.others[i];
14978
+ if(other.row === range.start.row && range.start.column < other.column) {
14979
+ other.setPosition(other.row, other.column - lengthDiff);
14980
+ }
14981
+ }
14982
+ }.bind(this), 0);
14983
+ }
14984
+ }
14985
+ this.pos._emit("change", {value: this.pos});
14986
+ for (var i = 0; i < this.others.length; i++) {
14987
+ this.others[i]._emit("change", {value: this.others[i]});
14988
+ }
14989
+ }
14990
+ this.$updating = false;
14991
+ };
14992
+
14993
+ this.onCursorChange = function(event) {
14994
+ if (this.$updating) return;
14995
+ var pos = this.session.selection.getCursor();
14996
+ if(pos.row === this.pos.row && pos.column >= this.pos.column && pos.column <= this.pos.column + this.length) {
14997
+ this.showOtherMarkers();
14998
+ this._emit("cursorEnter", event);
14999
+ } else {
15000
+ this.hideOtherMarkers();
15001
+ this._emit("cursorLeave", event);
15002
+ }
15003
+ };
15004
+
15005
+ this.detach = function() {
15006
+ this.session.removeMarker(this.markerId);
15007
+ this.hideOtherMarkers();
15008
+ this.doc.removeEventListener("change", this.$onUpdate);
15009
+ this.session.selection.removeEventListener("changeCursor", this.$onCursorChange);
15010
+ this.pos.detach();
15011
+ for (var i = 0; i < this.others.length; i++) {
15012
+ this.others[i].detach();
15013
+ }
15014
+ this.session.setUndoSelect(true);
15015
+ };
15016
+
15017
+ this.cancel = function() {
15018
+ if(this.$undoStackDepth === -1)
15019
+ throw Error("Canceling placeholders only supported with undo manager attached to session.");
15020
+ var undoManager = this.session.getUndoManager();
15021
+ var undosRequired = (undoManager.$undoStack || undoManager.$undostack).length - this.$undoStackDepth;
15022
+ for (var i = 0; i < undosRequired; i++) {
15023
+ undoManager.undo(true);
15024
+ }
15025
+ };
15026
+ }).call(PlaceHolder.prototype);
15027
+
15028
+
15029
+ exports.PlaceHolder = PlaceHolder;
14438
15030
  });
14439
15031
  /* ***** BEGIN LICENSE BLOCK *****
14440
15032
  * Version: MPL 1.1/GPL 2.0/LGPL 2.1