ace-rails-ap 2.0.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (301) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -4
  3. data/lib/ace/rails/version.rb +1 -1
  4. data/vendor/assets/javascripts/ace/ace.js +14194 -13349
  5. data/vendor/assets/javascripts/ace/ext-beautify.js +335 -0
  6. data/vendor/assets/javascripts/ace/ext-chromevox.js +6 -1
  7. data/vendor/assets/javascripts/ace/ext-elastic_tabstops_lite.js +8 -33
  8. data/vendor/assets/javascripts/ace/ext-emmet.js +487 -424
  9. data/vendor/assets/javascripts/ace/ext-error_marker.js +6 -0
  10. data/vendor/assets/javascripts/ace/ext-keybinding_menu.js +45 -72
  11. data/vendor/assets/javascripts/ace/ext-language_tools.js +734 -578
  12. data/vendor/assets/javascripts/ace/ext-linking.js +53 -0
  13. data/vendor/assets/javascripts/ace/ext-modelist.js +25 -10
  14. data/vendor/assets/javascripts/ace/ext-old_ie.js +93 -120
  15. data/vendor/assets/javascripts/ace/ext-searchbox.js +8 -41
  16. data/vendor/assets/javascripts/ace/ext-settings_menu.js +229 -234
  17. data/vendor/assets/javascripts/ace/ext-spellcheck.js +7 -3
  18. data/vendor/assets/javascripts/ace/ext-split.js +13 -37
  19. data/vendor/assets/javascripts/ace/ext-static_highlight.js +16 -39
  20. data/vendor/assets/javascripts/ace/ext-statusbar.js +8 -2
  21. data/vendor/assets/javascripts/ace/ext-textarea.js +254 -99
  22. data/vendor/assets/javascripts/ace/ext-themelist.js +13 -40
  23. data/vendor/assets/javascripts/ace/ext-whitespace.js +17 -41
  24. data/vendor/assets/javascripts/ace/keybinding-emacs.js +803 -788
  25. data/vendor/assets/javascripts/ace/keybinding-vim.js +1559 -1560
  26. data/vendor/assets/javascripts/ace/mode-abap.js +52 -83
  27. data/vendor/assets/javascripts/ace/mode-actionscript.js +27 -63
  28. data/vendor/assets/javascripts/ace/mode-ada.js +27 -58
  29. data/vendor/assets/javascripts/ace/mode-apache_conf.js +310 -0
  30. data/vendor/assets/javascripts/ace/mode-applescript.js +226 -0
  31. data/vendor/assets/javascripts/ace/mode-asciidoc.js +39 -70
  32. data/vendor/assets/javascripts/ace/mode-assembly_x86.js +26 -58
  33. data/vendor/assets/javascripts/ace/mode-autohotkey.js +27 -63
  34. data/vendor/assets/javascripts/ace/mode-batchfile.js +27 -63
  35. data/vendor/assets/javascripts/ace/mode-c9search.js +92 -112
  36. data/vendor/assets/javascripts/ace/mode-c_cpp.js +224 -223
  37. data/vendor/assets/javascripts/ace/mode-cirru.js +202 -0
  38. data/vendor/assets/javascripts/ace/mode-clojure.js +98 -92
  39. data/vendor/assets/javascripts/ace/mode-cobol.js +27 -58
  40. data/vendor/assets/javascripts/ace/mode-coffee.js +90 -122
  41. data/vendor/assets/javascripts/ace/mode-coldfusion.js +1908 -1464
  42. data/vendor/assets/javascripts/ace/mode-csharp.js +291 -264
  43. data/vendor/assets/javascripts/ace/mode-css.js +266 -267
  44. data/vendor/assets/javascripts/ace/mode-curly.js +796 -815
  45. data/vendor/assets/javascripts/ace/mode-d.js +64 -95
  46. data/vendor/assets/javascripts/ace/mode-dart.js +254 -256
  47. data/vendor/assets/javascripts/ace/mode-diff.js +27 -58
  48. data/vendor/assets/javascripts/ace/mode-django.js +856 -866
  49. data/vendor/assets/javascripts/ace/mode-dockerfile.js +759 -0
  50. data/vendor/assets/javascripts/ace/mode-dot.js +106 -106
  51. data/vendor/assets/javascripts/ace/mode-eiffel.js +135 -0
  52. data/vendor/assets/javascripts/ace/mode-ejs.js +931 -938
  53. data/vendor/assets/javascripts/ace/mode-erlang.js +27 -58
  54. data/vendor/assets/javascripts/ace/mode-forth.js +27 -63
  55. data/vendor/assets/javascripts/ace/mode-ftl.js +457 -508
  56. data/vendor/assets/javascripts/ace/mode-gcode.js +85 -0
  57. data/vendor/assets/javascripts/ace/mode-gherkin.js +129 -0
  58. data/vendor/assets/javascripts/ace/mode-gitignore.js +50 -0
  59. data/vendor/assets/javascripts/ace/mode-glsl.js +252 -248
  60. data/vendor/assets/javascripts/ace/mode-golang.js +206 -179
  61. data/vendor/assets/javascripts/ace/mode-groovy.js +310 -242
  62. data/vendor/assets/javascripts/ace/mode-haml.js +156 -190
  63. data/vendor/assets/javascripts/ace/mode-handlebars.js +815 -784
  64. data/vendor/assets/javascripts/ace/mode-haskell.js +27 -63
  65. data/vendor/assets/javascripts/ace/mode-haxe.js +206 -176
  66. data/vendor/assets/javascripts/ace/mode-html.js +779 -792
  67. data/vendor/assets/javascripts/ace/mode-html_ruby.js +916 -923
  68. data/vendor/assets/javascripts/ace/mode-ini.js +27 -58
  69. data/vendor/assets/javascripts/ace/mode-io.js +201 -0
  70. data/vendor/assets/javascripts/ace/mode-jack.js +169 -170
  71. data/vendor/assets/javascripts/ace/mode-jade.js +722 -774
  72. data/vendor/assets/javascripts/ace/mode-java.js +310 -245
  73. data/vendor/assets/javascripts/ace/mode-javascript.js +285 -247
  74. data/vendor/assets/javascripts/ace/mode-json.js +183 -184
  75. data/vendor/assets/javascripts/ace/mode-jsoniq.js +3211 -1274
  76. data/vendor/assets/javascripts/ace/mode-jsp.js +481 -504
  77. data/vendor/assets/javascripts/ace/mode-jsx.js +206 -176
  78. data/vendor/assets/javascripts/ace/mode-julia.js +33 -69
  79. data/vendor/assets/javascripts/ace/mode-latex.js +74 -41
  80. data/vendor/assets/javascripts/ace/mode-less.js +250 -251
  81. data/vendor/assets/javascripts/ace/mode-liquid.js +424 -475
  82. data/vendor/assets/javascripts/ace/mode-lisp.js +24 -57
  83. data/vendor/assets/javascripts/ace/mode-livescript.js +42 -41
  84. data/vendor/assets/javascripts/ace/mode-logiql.js +229 -230
  85. data/vendor/assets/javascripts/ace/mode-lsl.js +200 -441
  86. data/vendor/assets/javascripts/ace/mode-lua.js +136 -167
  87. data/vendor/assets/javascripts/ace/mode-luapage.js +904 -884
  88. data/vendor/assets/javascripts/ace/mode-lucene.js +22 -17
  89. data/vendor/assets/javascripts/ace/mode-makefile.js +162 -137
  90. data/vendor/assets/javascripts/ace/mode-markdown.js +846 -854
  91. data/vendor/assets/javascripts/ace/mode-matlab.js +98 -72
  92. data/vendor/assets/javascripts/ace/mode-mel.js +569 -0
  93. data/vendor/assets/javascripts/ace/mode-mushcode.js +84 -115
  94. data/vendor/assets/javascripts/ace/mode-mysql.js +49 -80
  95. data/vendor/assets/javascripts/ace/mode-nix.js +252 -256
  96. data/vendor/assets/javascripts/ace/mode-objectivec.js +242 -274
  97. data/vendor/assets/javascripts/ace/mode-ocaml.js +71 -102
  98. data/vendor/assets/javascripts/ace/mode-pascal.js +32 -68
  99. data/vendor/assets/javascripts/ace/mode-perl.js +67 -98
  100. data/vendor/assets/javascripts/ace/mode-pgsql.js +990 -982
  101. data/vendor/assets/javascripts/ace/mode-php.js +1878 -1900
  102. data/vendor/assets/javascripts/ace/mode-plain_text.js +3 -34
  103. data/vendor/assets/javascripts/ace/mode-powershell.js +181 -151
  104. data/vendor/assets/javascripts/ace/mode-praat.js +418 -0
  105. data/vendor/assets/javascripts/ace/mode-prolog.js +27 -63
  106. data/vendor/assets/javascripts/ace/mode-properties.js +20 -48
  107. data/vendor/assets/javascripts/ace/mode-protobuf.js +252 -259
  108. data/vendor/assets/javascripts/ace/mode-python.js +84 -115
  109. data/vendor/assets/javascripts/ace/mode-r.js +105 -140
  110. data/vendor/assets/javascripts/ace/mode-rdoc.js +84 -89
  111. data/vendor/assets/javascripts/ace/mode-rhtml.js +892 -908
  112. data/vendor/assets/javascripts/ace/mode-ruby.js +434 -98
  113. data/vendor/assets/javascripts/ace/mode-rust.js +27 -63
  114. data/vendor/assets/javascripts/ace/mode-sass.js +75 -106
  115. data/vendor/assets/javascripts/ace/mode-scad.js +219 -220
  116. data/vendor/assets/javascripts/ace/mode-scala.js +311 -243
  117. data/vendor/assets/javascripts/ace/mode-scheme.js +24 -60
  118. data/vendor/assets/javascripts/ace/mode-scss.js +250 -251
  119. data/vendor/assets/javascripts/ace/mode-sh.js +506 -118
  120. data/vendor/assets/javascripts/ace/mode-sjs.js +314 -280
  121. data/vendor/assets/javascripts/ace/mode-smarty.js +2474 -0
  122. data/vendor/assets/javascripts/ace/mode-snippets.js +89 -89
  123. data/vendor/assets/javascripts/ace/mode-soy_template.js +792 -811
  124. data/vendor/assets/javascripts/ace/mode-space.js +22 -23
  125. data/vendor/assets/javascripts/ace/mode-sql.js +31 -58
  126. data/vendor/assets/javascripts/ace/mode-stylus.js +161 -197
  127. data/vendor/assets/javascripts/ace/mode-svg.js +906 -836
  128. data/vendor/assets/javascripts/ace/mode-tcl.js +61 -92
  129. data/vendor/assets/javascripts/ace/mode-tex.js +36 -73
  130. data/vendor/assets/javascripts/ace/mode-text.js +1 -0
  131. data/vendor/assets/javascripts/ace/mode-textile.js +41 -72
  132. data/vendor/assets/javascripts/ace/mode-toml.js +26 -62
  133. data/vendor/assets/javascripts/ace/mode-twig.js +1196 -892
  134. data/vendor/assets/javascripts/ace/mode-typescript.js +313 -277
  135. data/vendor/assets/javascripts/ace/mode-vala.js +982 -0
  136. data/vendor/assets/javascripts/ace/mode-vbscript.js +25 -62
  137. data/vendor/assets/javascripts/ace/mode-velocity.js +2251 -1242
  138. data/vendor/assets/javascripts/ace/mode-verilog.js +27 -59
  139. data/vendor/assets/javascripts/ace/mode-vhdl.js +26 -55
  140. data/vendor/assets/javascripts/ace/mode-xml.js +319 -644
  141. data/vendor/assets/javascripts/ace/mode-xquery.js +2503 -588
  142. data/vendor/assets/javascripts/ace/mode-yaml.js +56 -90
  143. data/vendor/assets/javascripts/ace/snippets/abap.js +7 -0
  144. data/vendor/assets/javascripts/ace/snippets/actionscript.js +159 -0
  145. data/vendor/assets/javascripts/ace/snippets/ada.js +7 -0
  146. data/vendor/assets/javascripts/ace/snippets/apache_conf.js +7 -0
  147. data/vendor/assets/javascripts/ace/snippets/applescript.js +7 -0
  148. data/vendor/assets/javascripts/ace/snippets/asciidoc.js +7 -0
  149. data/vendor/assets/javascripts/ace/snippets/assembly_x86.js +7 -0
  150. data/vendor/assets/javascripts/ace/snippets/autohotkey.js +7 -0
  151. data/vendor/assets/javascripts/ace/snippets/batchfile.js +7 -0
  152. data/vendor/assets/javascripts/ace/snippets/c9search.js +7 -0
  153. data/vendor/assets/javascripts/ace/snippets/c_cpp.js +138 -0
  154. data/vendor/assets/javascripts/ace/snippets/cirru.js +7 -0
  155. data/vendor/assets/javascripts/ace/snippets/clojure.js +97 -0
  156. data/vendor/assets/javascripts/ace/snippets/cobol.js +7 -0
  157. data/vendor/assets/javascripts/ace/snippets/coffee.js +102 -0
  158. data/vendor/assets/javascripts/ace/snippets/coldfusion.js +7 -0
  159. data/vendor/assets/javascripts/ace/snippets/csharp.js +7 -0
  160. data/vendor/assets/javascripts/ace/snippets/css.js +974 -0
  161. data/vendor/assets/javascripts/ace/snippets/curly.js +7 -0
  162. data/vendor/assets/javascripts/ace/snippets/d.js +7 -0
  163. data/vendor/assets/javascripts/ace/snippets/dart.js +90 -0
  164. data/vendor/assets/javascripts/ace/snippets/diff.js +18 -0
  165. data/vendor/assets/javascripts/ace/snippets/django.js +115 -0
  166. data/vendor/assets/javascripts/ace/snippets/dockerfile.js +7 -0
  167. data/vendor/assets/javascripts/ace/snippets/dot.js +7 -0
  168. data/vendor/assets/javascripts/ace/snippets/eiffel.js +7 -0
  169. data/vendor/assets/javascripts/ace/snippets/ejs.js +7 -0
  170. data/vendor/assets/javascripts/ace/snippets/erlang.js +167 -0
  171. data/vendor/assets/javascripts/ace/snippets/forth.js +7 -0
  172. data/vendor/assets/javascripts/ace/snippets/ftl.js +7 -0
  173. data/vendor/assets/javascripts/ace/snippets/gcode.js +7 -0
  174. data/vendor/assets/javascripts/ace/snippets/gherkin.js +7 -0
  175. data/vendor/assets/javascripts/ace/snippets/gitignore.js +7 -0
  176. data/vendor/assets/javascripts/ace/snippets/glsl.js +7 -0
  177. data/vendor/assets/javascripts/ace/snippets/golang.js +7 -0
  178. data/vendor/assets/javascripts/ace/snippets/groovy.js +7 -0
  179. data/vendor/assets/javascripts/ace/snippets/haml.js +27 -0
  180. data/vendor/assets/javascripts/ace/snippets/handlebars.js +7 -0
  181. data/vendor/assets/javascripts/ace/snippets/haskell.js +89 -0
  182. data/vendor/assets/javascripts/ace/snippets/haxe.js +7 -0
  183. data/vendor/assets/javascripts/ace/snippets/html.js +835 -0
  184. data/vendor/assets/javascripts/ace/snippets/html_ruby.js +7 -0
  185. data/vendor/assets/javascripts/ace/snippets/ini.js +7 -0
  186. data/vendor/assets/javascripts/ace/snippets/io.js +69 -0
  187. data/vendor/assets/javascripts/ace/snippets/jack.js +7 -0
  188. data/vendor/assets/javascripts/ace/snippets/jade.js +7 -0
  189. data/vendor/assets/javascripts/ace/snippets/java.js +241 -0
  190. data/vendor/assets/javascripts/ace/snippets/javascript.js +189 -0
  191. data/vendor/assets/javascripts/ace/snippets/json.js +7 -0
  192. data/vendor/assets/javascripts/ace/snippets/jsoniq.js +68 -0
  193. data/vendor/assets/javascripts/ace/snippets/jsp.js +106 -0
  194. data/vendor/assets/javascripts/ace/snippets/jsx.js +7 -0
  195. data/vendor/assets/javascripts/ace/snippets/julia.js +7 -0
  196. data/vendor/assets/javascripts/ace/snippets/latex.js +7 -0
  197. data/vendor/assets/javascripts/ace/snippets/less.js +7 -0
  198. data/vendor/assets/javascripts/ace/snippets/liquid.js +7 -0
  199. data/vendor/assets/javascripts/ace/snippets/lisp.js +7 -0
  200. data/vendor/assets/javascripts/ace/snippets/livescript.js +7 -0
  201. data/vendor/assets/javascripts/ace/snippets/logiql.js +7 -0
  202. data/vendor/assets/javascripts/ace/snippets/lsl.js +1073 -0
  203. data/vendor/assets/javascripts/ace/snippets/lua.js +28 -0
  204. data/vendor/assets/javascripts/ace/snippets/luapage.js +7 -0
  205. data/vendor/assets/javascripts/ace/snippets/lucene.js +7 -0
  206. data/vendor/assets/javascripts/ace/snippets/makefile.js +11 -0
  207. data/vendor/assets/javascripts/ace/snippets/markdown.js +95 -0
  208. data/vendor/assets/javascripts/ace/snippets/matlab.js +7 -0
  209. data/vendor/assets/javascripts/ace/snippets/mel.js +7 -0
  210. data/vendor/assets/javascripts/ace/snippets/mushcode.js +7 -0
  211. data/vendor/assets/javascripts/ace/snippets/mysql.js +7 -0
  212. data/vendor/assets/javascripts/ace/snippets/nix.js +7 -0
  213. data/vendor/assets/javascripts/ace/snippets/objectivec.js +7 -0
  214. data/vendor/assets/javascripts/ace/snippets/ocaml.js +7 -0
  215. data/vendor/assets/javascripts/ace/snippets/pascal.js +7 -0
  216. data/vendor/assets/javascripts/ace/snippets/perl.js +354 -0
  217. data/vendor/assets/javascripts/ace/snippets/pgsql.js +7 -0
  218. data/vendor/assets/javascripts/ace/snippets/php.js +283 -0
  219. data/vendor/assets/javascripts/ace/snippets/plain_text.js +7 -0
  220. data/vendor/assets/javascripts/ace/snippets/powershell.js +7 -0
  221. data/vendor/assets/javascripts/ace/snippets/praat.js +7 -0
  222. data/vendor/assets/javascripts/ace/snippets/prolog.js +7 -0
  223. data/vendor/assets/javascripts/ace/snippets/properties.js +7 -0
  224. data/vendor/assets/javascripts/ace/snippets/protobuf.js +7 -0
  225. data/vendor/assets/javascripts/ace/snippets/python.js +165 -0
  226. data/vendor/assets/javascripts/ace/snippets/r.js +128 -0
  227. data/vendor/assets/javascripts/ace/snippets/rdoc.js +7 -0
  228. data/vendor/assets/javascripts/ace/snippets/rhtml.js +7 -0
  229. data/vendor/assets/javascripts/ace/snippets/ruby.js +935 -0
  230. data/vendor/assets/javascripts/ace/snippets/rust.js +7 -0
  231. data/vendor/assets/javascripts/ace/snippets/sass.js +7 -0
  232. data/vendor/assets/javascripts/ace/snippets/scad.js +7 -0
  233. data/vendor/assets/javascripts/ace/snippets/scala.js +7 -0
  234. data/vendor/assets/javascripts/ace/snippets/scheme.js +7 -0
  235. data/vendor/assets/javascripts/ace/snippets/scss.js +7 -0
  236. data/vendor/assets/javascripts/ace/snippets/sh.js +90 -0
  237. data/vendor/assets/javascripts/ace/snippets/sjs.js +7 -0
  238. data/vendor/assets/javascripts/ace/snippets/smarty.js +7 -0
  239. data/vendor/assets/javascripts/ace/snippets/snippets.js +16 -0
  240. data/vendor/assets/javascripts/ace/snippets/soy_template.js +7 -0
  241. data/vendor/assets/javascripts/ace/snippets/space.js +7 -0
  242. data/vendor/assets/javascripts/ace/snippets/sql.js +33 -0
  243. data/vendor/assets/javascripts/ace/snippets/stylus.js +7 -0
  244. data/vendor/assets/javascripts/ace/snippets/svg.js +7 -0
  245. data/vendor/assets/javascripts/ace/snippets/tcl.js +99 -0
  246. data/vendor/assets/javascripts/ace/snippets/tex.js +197 -0
  247. data/vendor/assets/javascripts/ace/snippets/text.js +7 -0
  248. data/vendor/assets/javascripts/ace/snippets/textile.js +37 -0
  249. data/vendor/assets/javascripts/ace/snippets/toml.js +7 -0
  250. data/vendor/assets/javascripts/ace/snippets/twig.js +7 -0
  251. data/vendor/assets/javascripts/ace/snippets/typescript.js +7 -0
  252. data/vendor/assets/javascripts/ace/snippets/vala.js +193 -0
  253. data/vendor/assets/javascripts/ace/snippets/vbscript.js +7 -0
  254. data/vendor/assets/javascripts/ace/snippets/velocity.js +36 -0
  255. data/vendor/assets/javascripts/ace/snippets/verilog.js +7 -0
  256. data/vendor/assets/javascripts/ace/snippets/vhdl.js +7 -0
  257. data/vendor/assets/javascripts/ace/snippets/xml.js +7 -0
  258. data/vendor/assets/javascripts/ace/snippets/xquery.js +68 -0
  259. data/vendor/assets/javascripts/ace/snippets/yaml.js +7 -0
  260. data/vendor/assets/javascripts/ace/theme-ambiance.js +4 -24
  261. data/vendor/assets/javascripts/ace/theme-chaos.js +2 -25
  262. data/vendor/assets/javascripts/ace/theme-chrome.js +2 -31
  263. data/vendor/assets/javascripts/ace/theme-clouds.js +1 -31
  264. data/vendor/assets/javascripts/ace/theme-clouds_midnight.js +1 -31
  265. data/vendor/assets/javascripts/ace/theme-cobalt.js +1 -31
  266. data/vendor/assets/javascripts/ace/theme-crimson_editor.js +1 -31
  267. data/vendor/assets/javascripts/ace/theme-dawn.js +1 -31
  268. data/vendor/assets/javascripts/ace/theme-dreamweaver.js +5 -31
  269. data/vendor/assets/javascripts/ace/theme-eclipse.js +7 -33
  270. data/vendor/assets/javascripts/ace/theme-github.js +2 -35
  271. data/vendor/assets/javascripts/ace/theme-idle_fingers.js +1 -31
  272. data/vendor/assets/javascripts/ace/theme-katzenmilch.js +119 -0
  273. data/vendor/assets/javascripts/ace/theme-kr.js +1 -31
  274. data/vendor/assets/javascripts/ace/theme-kr_theme.js +57 -141
  275. data/vendor/assets/javascripts/ace/theme-kuroir.js +59 -0
  276. data/vendor/assets/javascripts/ace/theme-merbivore.js +1 -31
  277. data/vendor/assets/javascripts/ace/theme-merbivore_soft.js +1 -31
  278. data/vendor/assets/javascripts/ace/theme-mono_industrial.js +1 -31
  279. data/vendor/assets/javascripts/ace/theme-monokai.js +1 -31
  280. data/vendor/assets/javascripts/ace/theme-pastel_on_dark.js +1 -31
  281. data/vendor/assets/javascripts/ace/theme-solarized_dark.js +1 -31
  282. data/vendor/assets/javascripts/ace/theme-solarized_light.js +1 -31
  283. data/vendor/assets/javascripts/ace/theme-terminal.js +1 -31
  284. data/vendor/assets/javascripts/ace/theme-textmate.js +3 -32
  285. data/vendor/assets/javascripts/ace/theme-tomorrow.js +1 -31
  286. data/vendor/assets/javascripts/ace/theme-tomorrow_night.js +1 -31
  287. data/vendor/assets/javascripts/ace/theme-tomorrow_night_blue.js +1 -31
  288. data/vendor/assets/javascripts/ace/theme-tomorrow_night_bright.js +1 -31
  289. data/vendor/assets/javascripts/ace/theme-tomorrow_night_eighties.js +1 -31
  290. data/vendor/assets/javascripts/ace/theme-twilight.js +1 -31
  291. data/vendor/assets/javascripts/ace/theme-vibrant_ink.js +1 -31
  292. data/vendor/assets/javascripts/ace/theme-xcode.js +2 -33
  293. data/vendor/assets/javascripts/ace/worker-coffee.js +5026 -5008
  294. data/vendor/assets/javascripts/ace/worker-css.js +5489 -5134
  295. data/vendor/assets/javascripts/ace/worker-html.js +11517 -0
  296. data/vendor/assets/javascripts/ace/worker-javascript.js +9810 -9501
  297. data/vendor/assets/javascripts/ace/worker-json.js +1583 -1564
  298. data/vendor/assets/javascripts/ace/worker-lua.js +2631 -2612
  299. data/vendor/assets/javascripts/ace/worker-php.js +2385 -2341
  300. data/vendor/assets/javascripts/ace/worker-xquery.js +31643 -3993
  301. metadata +147 -11
@@ -1,1759 +1,1758 @@
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
-
31
- define('ace/keyboard/vim', ['require', 'exports', 'module' , 'ace/keyboard/vim/commands', 'ace/keyboard/vim/maps/util', 'ace/lib/useragent'], function(require, exports, module) {
1
+ define("ace/keyboard/vim/registers",["require","exports","module"], function(require, exports, module) {
32
2
 
3
+ "never use strict";
33
4
 
34
- var cmds = require("./vim/commands");
35
- var coreCommands = cmds.coreCommands;
36
- var util = require("./vim/maps/util");
37
- var useragent = require("../lib/useragent");
38
-
39
- var startCommands = {
40
- "i": {
41
- command: coreCommands.start
42
- },
43
- "I": {
44
- command: coreCommands.startBeginning
45
- },
46
- "a": {
47
- command: coreCommands.append
48
- },
49
- "A": {
50
- command: coreCommands.appendEnd
51
- },
52
- "ctrl-f": {
53
- command: "gotopagedown"
54
- },
55
- "ctrl-b": {
56
- command: "gotopageup"
5
+ module.exports = {
6
+ _default: {
7
+ text: "",
8
+ isLine: false
57
9
  }
58
10
  };
59
11
 
60
- exports.handler = {
61
- $id: "ace/keyboard/vim",
62
- handleMacRepeat: function(data, hashId, key) {
63
- if (hashId == -1) {
64
- data.inputChar = key;
65
- data.lastEvent = "input";
66
- } else if (data.inputChar && data.$lastHash == hashId && data.$lastKey == key) {
67
- if (data.lastEvent == "input") {
68
- data.lastEvent = "input1";
69
- } else if (data.lastEvent == "input1") {
70
- return true;
71
- }
12
+ });
13
+
14
+ define("ace/keyboard/vim/maps/util",["require","exports","module","ace/keyboard/vim/registers","ace/lib/dom"], function(require, exports, module) {
15
+ var registers = require("../registers");
16
+
17
+ var dom = require("../../../lib/dom");
18
+ dom.importCssString('.insert-mode .ace_cursor{\
19
+ border-left: 2px solid #333333;\
20
+ }\
21
+ .ace_dark.insert-mode .ace_cursor{\
22
+ border-left: 2px solid #eeeeee;\
23
+ }\
24
+ .normal-mode .ace_cursor{\
25
+ border: 0!important;\
26
+ background-color: red;\
27
+ opacity: 0.5;\
28
+ }', 'vimMode');
29
+
30
+ module.exports = {
31
+ onVisualMode: false,
32
+ onVisualLineMode: false,
33
+ currentMode: 'normal',
34
+ noMode: function(editor) {
35
+ editor.unsetStyle('insert-mode');
36
+ editor.unsetStyle('normal-mode');
37
+ if (editor.commands.recording)
38
+ editor.commands.toggleRecording(editor);
39
+ editor.setOverwrite(false);
40
+ },
41
+ insertMode: function(editor) {
42
+ this.currentMode = 'insert';
43
+ editor.setStyle('insert-mode');
44
+ editor.unsetStyle('normal-mode');
45
+
46
+ editor.setOverwrite(false);
47
+ editor.keyBinding.$data.buffer = "";
48
+ editor.keyBinding.$data.vimState = "insertMode";
49
+ this.onVisualMode = false;
50
+ this.onVisualLineMode = false;
51
+ if(this.onInsertReplaySequence) {
52
+ editor.commands.macro = this.onInsertReplaySequence;
53
+ editor.commands.replay(editor);
54
+ this.onInsertReplaySequence = null;
55
+ this.normalMode(editor);
72
56
  } else {
73
- data.$lastHash = hashId;
74
- data.$lastKey = key;
75
- data.lastEvent = "keypress";
57
+ editor._emit("changeStatus");
58
+ if(!editor.commands.recording)
59
+ editor.commands.toggleRecording(editor);
76
60
  }
77
61
  },
78
- updateMacCompositionHandlers: function(editor, enable) {
79
- var onCompositionUpdateOverride = function(text) {
80
- if (util.currentMode !== "insert") {
81
- var el = this.textInput.getElement();
82
- el.blur();
83
- el.focus();
84
- el.value = text;
85
- } else {
86
- this.onCompositionUpdateOrig(text);
87
- }
88
- };
89
- var onCompositionStartOverride = function(text) {
90
- if (util.currentMode === "insert") {
91
- this.onCompositionStartOrig(text);
92
- }
62
+ normalMode: function(editor) {
63
+ this.currentMode = 'normal';
64
+
65
+ editor.unsetStyle('insert-mode');
66
+ editor.setStyle('normal-mode');
67
+ editor.clearSelection();
68
+
69
+ var pos;
70
+ if (!editor.getOverwrite()) {
71
+ pos = editor.getCursorPosition();
72
+ if (pos.column > 0)
73
+ editor.navigateLeft();
93
74
  }
94
- if (enable) {
95
- if (!editor.onCompositionUpdateOrig) {
96
- editor.onCompositionUpdateOrig = editor.onCompositionUpdate;
97
- editor.onCompositionUpdate = onCompositionUpdateOverride;
98
- editor.onCompositionStartOrig = editor.onCompositionStart;
99
- editor.onCompositionStart = onCompositionStartOverride;
100
- }
101
- } else {
102
- if (editor.onCompositionUpdateOrig) {
103
- editor.onCompositionUpdate = editor.onCompositionUpdateOrig;
104
- editor.onCompositionUpdateOrig = null;
105
- editor.onCompositionStart = editor.onCompositionStartOrig;
106
- editor.onCompositionStartOrig = null;
107
- }
75
+
76
+ editor.setOverwrite(true);
77
+ editor.keyBinding.$data.buffer = "";
78
+ editor.keyBinding.$data.vimState = "start";
79
+ this.onVisualMode = false;
80
+ this.onVisualLineMode = false;
81
+ editor._emit("changeStatus");
82
+ if (editor.commands.recording) {
83
+ editor.commands.toggleRecording(editor);
84
+ return editor.commands.macro;
85
+ }
86
+ else {
87
+ return [];
108
88
  }
109
89
  },
90
+ visualMode: function(editor, lineMode) {
91
+ if (
92
+ (this.onVisualLineMode && lineMode)
93
+ || (this.onVisualMode && !lineMode)
94
+ ) {
95
+ this.normalMode(editor);
96
+ return;
97
+ }
110
98
 
111
- handleKeyboard: function(data, hashId, key, keyCode, e) {
112
- if (hashId != 0 && (key == "" || key == "\x00"))
113
- return null;
114
-
115
- var editor = data.editor;
116
-
117
- if (hashId == 1)
118
- key = "ctrl-" + key;
119
- if (key == "ctrl-c") {
120
- if (!useragent.isMac && editor.getCopyText()) {
121
- editor.once("copy", function() {
122
- if (data.state == "start")
123
- coreCommands.stop.exec(editor);
124
- else
125
- editor.selection.clearSelection();
126
- });
127
- return {command: "null", passEvent: true};
128
- }
129
- return {command: coreCommands.stop};
130
- } else if ((key == "esc" && hashId == 0) || key == "ctrl-[") {
131
- return {command: coreCommands.stop};
132
- } else if (data.state == "start") {
133
- if (useragent.isMac && this.handleMacRepeat(data, hashId, key)) {
134
- hashId = -1;
135
- key = data.inputChar;
136
- }
137
-
138
- if (hashId == -1 || hashId == 1 || hashId == 0 && key.length > 1) {
139
- if (cmds.inputBuffer.idle && startCommands[key])
140
- return startCommands[key];
141
- cmds.inputBuffer.push(editor, key);
142
- return {command: "null", passEvent: false};
143
- } // if no modifier || shift: wait for input.
144
- else if (key.length == 1 && (hashId == 0 || hashId == 4)) {
145
- return {command: "null", passEvent: true};
146
- } else if (key == "esc" && hashId == 0) {
147
- return {command: coreCommands.stop};
148
- }
99
+ editor.setStyle('insert-mode');
100
+ editor.unsetStyle('normal-mode');
101
+
102
+ editor._emit("changeStatus");
103
+ if (lineMode) {
104
+ this.onVisualLineMode = true;
149
105
  } else {
150
- if (key == "ctrl-w") {
151
- return {command: "removewordleft"};
152
- }
106
+ this.onVisualMode = true;
107
+ this.onVisualLineMode = false;
153
108
  }
154
109
  },
110
+ getRightNthChar: function(editor, cursor, ch, n) {
111
+ var line = editor.getSession().getLine(cursor.row);
112
+ var matches = line.substr(cursor.column + 1).split(ch);
155
113
 
156
- attach: function(editor) {
157
- editor.on("click", exports.onCursorMove);
158
- if (util.currentMode !== "insert")
159
- cmds.coreCommands.stop.exec(editor);
160
- editor.$vimModeHandler = this;
161
-
162
- this.updateMacCompositionHandlers(editor, true);
114
+ return n < matches.length ? matches.slice(0, n).join(ch).length : null;
163
115
  },
116
+ getLeftNthChar: function(editor, cursor, ch, n) {
117
+ var line = editor.getSession().getLine(cursor.row);
118
+ var matches = line.substr(0, cursor.column).split(ch);
164
119
 
165
- detach: function(editor) {
166
- editor.removeListener("click", exports.onCursorMove);
167
- util.noMode(editor);
168
- util.currentMode = "normal";
169
- this.updateMacCompositionHandlers(editor, false);
120
+ return n < matches.length ? matches.slice(-1 * n).join(ch).length : null;
170
121
  },
122
+ toRealChar: function(ch) {
123
+ if (ch.length === 1)
124
+ return ch;
171
125
 
172
- actions: cmds.actions,
173
- getStatusText: function() {
174
- if (util.currentMode == "insert")
175
- return "INSERT";
176
- if (util.onVisualMode)
177
- return (util.onVisualLineMode ? "VISUAL LINE " : "VISUAL ") + cmds.inputBuffer.status;
178
- return cmds.inputBuffer.status;
126
+ if (/^shift-./.test(ch))
127
+ return ch[ch.length - 1].toUpperCase();
128
+ else
129
+ return "";
130
+ },
131
+ copyLine: function(editor) {
132
+ var pos = editor.getCursorPosition();
133
+ editor.selection.moveTo(pos.row, pos.column);
134
+ editor.selection.selectLine();
135
+ registers._default.isLine = true;
136
+ registers._default.text = editor.getCopyText().replace(/\n$/, "");
137
+ editor.selection.moveTo(pos.row, pos.column);
179
138
  }
180
139
  };
181
-
182
-
183
- exports.onCursorMove = function(e) {
184
- cmds.onCursorMove(e.editor, e);
185
- exports.onCursorMove.scheduled = false;
186
- };
187
-
188
140
  });
189
-
190
- define('ace/keyboard/vim/commands', ['require', 'exports', 'module' , 'ace/lib/lang', 'ace/keyboard/vim/maps/util', 'ace/keyboard/vim/maps/motions', 'ace/keyboard/vim/maps/operators', 'ace/keyboard/vim/maps/aliases', 'ace/keyboard/vim/registers'], function(require, exports, module) {
191
141
 
192
- "never use strict";
142
+ define("ace/keyboard/vim/maps/motions",["require","exports","module","ace/keyboard/vim/maps/util","ace/search","ace/range"], function(require, exports, module) {
143
+ "use strict";
193
144
 
194
- var lang = require("../../lib/lang");
195
- var util = require("./maps/util");
196
- var motions = require("./maps/motions");
197
- var operators = require("./maps/operators");
198
- var alias = require("./maps/aliases");
199
- var registers = require("./registers");
145
+ var util = require("./util");
200
146
 
201
- var NUMBER = 1;
202
- var OPERATOR = 2;
203
- var MOTION = 3;
204
- var ACTION = 4;
205
- var HMARGIN = 8; // Minimum amount of line separation between margins;
147
+ var keepScrollPosition = function(editor, fn) {
148
+ var scrollTopRow = editor.renderer.getScrollTopRow();
149
+ var initialRow = editor.getCursorPosition().row;
150
+ var diff = initialRow - scrollTopRow;
151
+ fn && fn.call(editor);
152
+ editor.renderer.scrollToRow(editor.getCursorPosition().row - diff);
153
+ };
206
154
 
207
- var repeat = function repeat(fn, count, args) {
208
- while (0 < count--)
209
- fn.apply(this, args);
155
+ function Motion(m) {
156
+ if (typeof m == "function") {
157
+ var getPos = m;
158
+ m = this;
159
+ } else {
160
+ var getPos = m.getPos;
161
+ }
162
+ m.nav = function(editor, range, count, param) {
163
+ var a = getPos(editor, range, count, param, false);
164
+ if (!a)
165
+ return;
166
+ editor.selection.moveTo(a.row, a.column);
167
+ };
168
+ m.sel = function(editor, range, count, param) {
169
+ var a = getPos(editor, range, count, param, true);
170
+ if (!a)
171
+ return;
172
+ editor.selection.selectTo(a.row, a.column);
173
+ };
174
+ return m;
175
+ }
176
+
177
+ var nonWordRe = /[\s.\/\\()\"'-:,.;<>~!@#$%^&*|+=\[\]{}`~?]/;
178
+ var wordSeparatorRe = /[.\/\\()\"'-:,.;<>~!@#$%^&*|+=\[\]{}`~?]/;
179
+ var whiteRe = /\s/;
180
+ var StringStream = function(editor, cursor) {
181
+ var sel = editor.selection;
182
+ this.range = sel.getRange();
183
+ cursor = cursor || sel.selectionLead;
184
+ this.row = cursor.row;
185
+ this.col = cursor.column;
186
+ var line = editor.session.getLine(this.row);
187
+ var maxRow = editor.session.getLength();
188
+ this.ch = line[this.col] || '\n';
189
+ this.skippedLines = 0;
190
+
191
+ this.next = function() {
192
+ this.ch = line[++this.col] || this.handleNewLine(1);
193
+ return this.ch;
194
+ };
195
+ this.prev = function() {
196
+ this.ch = line[--this.col] || this.handleNewLine(-1);
197
+ return this.ch;
198
+ };
199
+ this.peek = function(dir) {
200
+ var ch = line[this.col + dir];
201
+ if (ch)
202
+ return ch;
203
+ if (dir == -1)
204
+ return '\n';
205
+ if (this.col == line.length - 1)
206
+ return '\n';
207
+ return editor.session.getLine(this.row + 1)[0] || '\n';
208
+ };
209
+
210
+ this.handleNewLine = function(dir) {
211
+ if (dir == 1){
212
+ if (this.col == line.length)
213
+ return '\n';
214
+ if (this.row == maxRow - 1)
215
+ return '';
216
+ this.col = 0;
217
+ this.row ++;
218
+ line = editor.session.getLine(this.row);
219
+ this.skippedLines++;
220
+ return line[0] || '\n';
221
+ }
222
+ if (dir == -1) {
223
+ if (this.row === 0)
224
+ return '';
225
+ this.row --;
226
+ line = editor.session.getLine(this.row);
227
+ this.col = line.length;
228
+ this.skippedLines--;
229
+ return '\n';
230
+ }
231
+ };
232
+ this.debug = function() {
233
+ console.log(line.substring(0, this.col)+'|'+this.ch+'\''+this.col+'\''+line.substr(this.col+1));
234
+ };
210
235
  };
211
236
 
212
- var ensureScrollMargin = function(editor) {
213
- var renderer = editor.renderer;
214
- var pos = renderer.$cursorLayer.getPixelPosition();
237
+ var Search = require("../../../search").Search;
238
+ var search = new Search();
215
239
 
216
- var top = pos.top;
240
+ function find(editor, needle, dir) {
241
+ search.$options.needle = needle;
242
+ search.$options.backwards = dir == -1;
243
+ return search.find(editor.session);
244
+ }
217
245
 
218
- var margin = HMARGIN * renderer.layerConfig.lineHeight;
219
- if (2 * margin > renderer.$size.scrollerHeight)
220
- margin = renderer.$size.scrollerHeight / 2;
246
+ var Range = require("../../../range").Range;
221
247
 
222
- if (renderer.scrollTop > top - margin) {
223
- renderer.session.setScrollTop(top - margin);
224
- }
248
+ var LAST_SEARCH_MOTION = {};
225
249
 
226
- if (renderer.scrollTop + renderer.$size.scrollerHeight < top + margin + renderer.lineHeight) {
227
- renderer.session.setScrollTop(top + margin + renderer.lineHeight - renderer.$size.scrollerHeight);
228
- }
229
- };
250
+ module.exports = {
251
+ "w": new Motion(function(editor) {
252
+ var str = new StringStream(editor);
230
253
 
231
- var actions = exports.actions = {
232
- "z": {
233
- param: true,
234
- fn: function(editor, range, count, param) {
235
- switch (param) {
236
- case "z":
237
- editor.renderer.alignCursor(null, 0.5);
238
- break;
239
- case "t":
240
- editor.renderer.alignCursor(null, 0);
241
- break;
242
- case "b":
243
- editor.renderer.alignCursor(null, 1);
244
- break;
245
- case "c":
246
- editor.session.onFoldWidgetClick(range.start.row, {domEvent:{target :{}}});
247
- break;
248
- case "o":
249
- editor.session.onFoldWidgetClick(range.start.row, {domEvent:{target :{}}});
250
- break;
251
- case "C":
252
- editor.session.foldAll();
253
- break;
254
- case "O":
255
- editor.session.unfold();
256
- break;
257
- }
254
+ if (str.ch && wordSeparatorRe.test(str.ch)) {
255
+ while (str.ch && wordSeparatorRe.test(str.ch))
256
+ str.next();
257
+ } else {
258
+ while (str.ch && !nonWordRe.test(str.ch))
259
+ str.next();
260
+ }
261
+ while (str.ch && whiteRe.test(str.ch) && str.skippedLines < 2)
262
+ str.next();
263
+
264
+ str.skippedLines == 2 && str.prev();
265
+ return {column: str.col, row: str.row};
266
+ }),
267
+ "W": new Motion(function(editor) {
268
+ var str = new StringStream(editor);
269
+ while(str.ch && !(whiteRe.test(str.ch) && !whiteRe.test(str.peek(1))) && str.skippedLines < 2)
270
+ str.next();
271
+ if (str.skippedLines == 2)
272
+ str.prev();
273
+ else
274
+ str.next();
275
+
276
+ return {column: str.col, row: str.row};
277
+ }),
278
+ "b": new Motion(function(editor) {
279
+ var str = new StringStream(editor);
280
+
281
+ str.prev();
282
+ while (str.ch && whiteRe.test(str.ch) && str.skippedLines > -2)
283
+ str.prev();
284
+
285
+ if (str.ch && wordSeparatorRe.test(str.ch)) {
286
+ while (str.ch && wordSeparatorRe.test(str.ch))
287
+ str.prev();
288
+ } else {
289
+ while (str.ch && !nonWordRe.test(str.ch))
290
+ str.prev();
291
+ }
292
+ str.ch && str.next();
293
+ return {column: str.col, row: str.row};
294
+ }),
295
+ "B": new Motion(function(editor) {
296
+ var str = new StringStream(editor);
297
+ str.prev();
298
+ while(str.ch && !(!whiteRe.test(str.ch) && whiteRe.test(str.peek(-1))) && str.skippedLines > -2)
299
+ str.prev();
300
+
301
+ if (str.skippedLines == -2)
302
+ str.next();
303
+
304
+ return {column: str.col, row: str.row};
305
+ }),
306
+ "e": new Motion(function(editor) {
307
+ var str = new StringStream(editor);
308
+
309
+ str.next();
310
+ while (str.ch && whiteRe.test(str.ch))
311
+ str.next();
312
+
313
+ if (str.ch && wordSeparatorRe.test(str.ch)) {
314
+ while (str.ch && wordSeparatorRe.test(str.ch))
315
+ str.next();
316
+ } else {
317
+ while (str.ch && !nonWordRe.test(str.ch))
318
+ str.next();
319
+ }
320
+ str.ch && str.prev();
321
+ return {column: str.col, row: str.row};
322
+ }),
323
+ "E": new Motion(function(editor) {
324
+ var str = new StringStream(editor);
325
+ str.next();
326
+ while(str.ch && !(!whiteRe.test(str.ch) && whiteRe.test(str.peek(1))))
327
+ str.next();
328
+
329
+ return {column: str.col, row: str.row};
330
+ }),
331
+
332
+ "l": {
333
+ nav: function(editor) {
334
+ var pos = editor.getCursorPosition();
335
+ var col = pos.column;
336
+ var lineLen = editor.session.getLine(pos.row).length;
337
+ if (lineLen && col !== lineLen)
338
+ editor.navigateRight();
339
+ },
340
+ sel: function(editor) {
341
+ var pos = editor.getCursorPosition();
342
+ var col = pos.column;
343
+ var lineLen = editor.session.getLine(pos.row).length;
344
+ if (lineLen && col !== lineLen) //In selection mode you can select the newline
345
+ editor.selection.selectRight();
258
346
  }
259
347
  },
260
- "r": {
261
- param: true,
262
- fn: function(editor, range, count, param) {
263
- if (param && param.length) {
264
- if (param.length > 1)
265
- param = param == "return" ? "\n" : param == "tab" ? "\t" : param;
266
- repeat(function() { editor.insert(param); }, count || 1);
348
+ "h": {
349
+ nav: function(editor) {
350
+ var pos = editor.getCursorPosition();
351
+ if (pos.column > 0)
267
352
  editor.navigateLeft();
268
- }
353
+ },
354
+ sel: function(editor) {
355
+ var pos = editor.getCursorPosition();
356
+ if (pos.column > 0)
357
+ editor.selection.selectLeft();
269
358
  }
270
359
  },
271
- "R": {
272
- fn: function(editor, range, count, param) {
273
- util.insertMode(editor);
274
- editor.setOverwrite(true);
360
+ "H": {
361
+ nav: function(editor) {
362
+ var row = editor.renderer.getScrollTopRow();
363
+ editor.moveCursorTo(row);
364
+ },
365
+ sel: function(editor) {
366
+ var row = editor.renderer.getScrollTopRow();
367
+ editor.selection.selectTo(row);
275
368
  }
276
369
  },
277
- "~": {
278
- fn: function(editor, range, count) {
279
- repeat(function() {
280
- var range = editor.selection.getRange();
281
- if (range.isEmpty())
282
- range.end.column++;
283
- var text = editor.session.getTextRange(range);
284
- var toggled = text.toUpperCase();
285
- if (toggled == text)
286
- editor.navigateRight();
287
- else
288
- editor.session.replace(range, toggled);
289
- }, count || 1);
370
+ "M": {
371
+ nav: function(editor) {
372
+ var topRow = editor.renderer.getScrollTopRow();
373
+ var bottomRow = editor.renderer.getScrollBottomRow();
374
+ var row = topRow + ((bottomRow - topRow) / 2);
375
+ editor.moveCursorTo(row);
376
+ },
377
+ sel: function(editor) {
378
+ var topRow = editor.renderer.getScrollTopRow();
379
+ var bottomRow = editor.renderer.getScrollBottomRow();
380
+ var row = topRow + ((bottomRow - topRow) / 2);
381
+ editor.selection.selectTo(row);
290
382
  }
291
383
  },
292
- "*": {
293
- fn: function(editor, range, count, param) {
294
- editor.selection.selectWord();
295
- editor.findNext();
296
- ensureScrollMargin(editor);
297
- var r = editor.selection.getRange();
298
- editor.selection.setSelectionRange(r, true);
384
+ "L": {
385
+ nav: function(editor) {
386
+ var row = editor.renderer.getScrollBottomRow();
387
+ editor.moveCursorTo(row);
388
+ },
389
+ sel: function(editor) {
390
+ var row = editor.renderer.getScrollBottomRow();
391
+ editor.selection.selectTo(row);
299
392
  }
300
393
  },
301
- "#": {
302
- fn: function(editor, range, count, param) {
303
- editor.selection.selectWord();
304
- editor.findPrevious();
305
- ensureScrollMargin(editor);
306
- var r = editor.selection.getRange();
307
- editor.selection.setSelectionRange(r, true);
394
+ "k": {
395
+ nav: function(editor) {
396
+ editor.navigateUp();
397
+ },
398
+ sel: function(editor) {
399
+ editor.selection.selectUp();
308
400
  }
309
401
  },
310
- "m": {
311
- param: true,
312
- fn: function(editor, range, count, param) {
313
- var s = editor.session;
314
- var markers = s.vimMarkers || (s.vimMarkers = {});
315
- var c = editor.getCursorPosition();
316
- if (!markers[param]) {
317
- markers[param] = editor.session.doc.createAnchor(c);
318
- }
319
- markers[param].setPosition(c.row, c.column, true);
402
+ "j": {
403
+ nav: function(editor) {
404
+ editor.navigateDown();
405
+ },
406
+ sel: function(editor) {
407
+ editor.selection.selectDown();
320
408
  }
321
409
  },
322
- "n": {
323
- fn: function(editor, range, count, param) {
324
- var options = editor.getLastSearchOptions();
325
- options.backwards = false;
326
-
327
- editor.selection.moveCursorRight();
328
- editor.selection.clearSelection();
329
- editor.findNext(options);
330
410
 
331
- ensureScrollMargin(editor);
332
- var r = editor.selection.getRange();
333
- r.end.row = r.start.row;
334
- r.end.column = r.start.column;
335
- editor.selection.setSelectionRange(r, true);
411
+ "i": {
412
+ param: true,
413
+ sel: function(editor, range, count, param) {
414
+ switch (param) {
415
+ case "w":
416
+ editor.selection.selectWord();
417
+ break;
418
+ case "W":
419
+ editor.selection.selectAWord();
420
+ break;
421
+ case "(":
422
+ case "{":
423
+ case "[":
424
+ var cursor = editor.getCursorPosition();
425
+ var end = editor.session.$findClosingBracket(param, cursor, /paren/);
426
+ if (!end)
427
+ return;
428
+ var start = editor.session.$findOpeningBracket(editor.session.$brackets[param], cursor, /paren/);
429
+ if (!start)
430
+ return;
431
+ start.column ++;
432
+ editor.selection.setSelectionRange(Range.fromPoints(start, end));
433
+ break;
434
+ case "'":
435
+ case '"':
436
+ case "/":
437
+ var end = find(editor, param, 1);
438
+ if (!end)
439
+ return;
440
+ var start = find(editor, param, -1);
441
+ if (!start)
442
+ return;
443
+ editor.selection.setSelectionRange(Range.fromPoints(start.end, end.start));
444
+ break;
445
+ }
336
446
  }
337
447
  },
338
- "N": {
339
- fn: function(editor, range, count, param) {
340
- var options = editor.getLastSearchOptions();
341
- options.backwards = true;
342
-
343
- editor.findPrevious(options);
344
- ensureScrollMargin(editor);
345
- var r = editor.selection.getRange();
346
- r.end.row = r.start.row;
347
- r.end.column = r.start.column;
348
- editor.selection.setSelectionRange(r, true);
448
+ "a": {
449
+ param: true,
450
+ sel: function(editor, range, count, param) {
451
+ switch (param) {
452
+ case "w":
453
+ editor.selection.selectAWord();
454
+ break;
455
+ case "W":
456
+ editor.selection.selectAWord();
457
+ break;
458
+ case ")":
459
+ case "}":
460
+ case "]":
461
+ param = editor.session.$brackets[param];
462
+ case "(":
463
+ case "{":
464
+ case "[":
465
+ var cursor = editor.getCursorPosition();
466
+ var end = editor.session.$findClosingBracket(param, cursor, /paren/);
467
+ if (!end)
468
+ return;
469
+ var start = editor.session.$findOpeningBracket(editor.session.$brackets[param], cursor, /paren/);
470
+ if (!start)
471
+ return;
472
+ end.column ++;
473
+ editor.selection.setSelectionRange(Range.fromPoints(start, end));
474
+ break;
475
+ case "'":
476
+ case "\"":
477
+ case "/":
478
+ var end = find(editor, param, 1);
479
+ if (!end)
480
+ return;
481
+ var start = find(editor, param, -1);
482
+ if (!start)
483
+ return;
484
+ end.column ++;
485
+ editor.selection.setSelectionRange(Range.fromPoints(start.start, end.end));
486
+ break;
487
+ }
349
488
  }
350
489
  },
351
- "v": {
352
- fn: function(editor, range, count, param) {
353
- editor.selection.selectRight();
354
- util.visualMode(editor, false);
355
- },
356
- acceptsMotion: true
357
- },
358
- "V": {
359
- fn: function(editor, range, count, param) {
360
- var row = editor.getCursorPosition().row;
361
- editor.selection.clearSelection();
362
- editor.selection.moveCursorTo(row, 0);
363
- editor.selection.selectLineEnd();
364
- editor.selection.visualLineStart = row;
365
490
 
366
- util.visualMode(editor, true);
367
- },
368
- acceptsMotion: true
369
- },
370
- "Y": {
371
- fn: function(editor, range, count, param) {
372
- util.copyLine(editor);
373
- }
374
- },
375
- "p": {
376
- fn: function(editor, range, count, param) {
377
- var defaultReg = registers._default;
491
+ "f": new Motion({
492
+ param: true,
493
+ handlesCount: true,
494
+ getPos: function(editor, range, count, param, isSel, isRepeat) {
495
+ if (param == "space") param = " ";
496
+ if (!isRepeat)
497
+ LAST_SEARCH_MOTION = {ch: "f", param: param};
498
+ var cursor = editor.getCursorPosition();
499
+ var column = util.getRightNthChar(editor, cursor, param, count || 1);
378
500
 
379
- editor.setOverwrite(false);
380
- if (defaultReg.isLine) {
381
- var pos = editor.getCursorPosition();
382
- pos.column = editor.session.getLine(pos.row).length;
383
- var text = lang.stringRepeat("\n" + defaultReg.text, count || 1);
384
- editor.session.insert(pos, text);
385
- editor.moveCursorTo(pos.row + 1, 0);
386
- }
387
- else {
388
- editor.navigateRight();
389
- editor.insert(lang.stringRepeat(defaultReg.text, count || 1));
390
- editor.navigateLeft();
501
+ if (typeof column === "number") {
502
+ cursor.column += column + (isSel ? 2 : 1);
503
+ return cursor;
391
504
  }
392
- editor.setOverwrite(true);
393
- editor.selection.clearSelection();
394
505
  }
395
- },
396
- "P": {
397
- fn: function(editor, range, count, param) {
398
- var defaultReg = registers._default;
399
- editor.setOverwrite(false);
506
+ }),
507
+ "F": new Motion({
508
+ param: true,
509
+ handlesCount: true,
510
+ getPos: function(editor, range, count, param, isSel, isRepeat) {
511
+ if (param == "space") param = " ";
512
+ if (!isRepeat)
513
+ LAST_SEARCH_MOTION = {ch: "F", param: param};
514
+ var cursor = editor.getCursorPosition();
515
+ var column = util.getLeftNthChar(editor, cursor, param, count || 1);
400
516
 
401
- if (defaultReg.isLine) {
402
- var pos = editor.getCursorPosition();
403
- pos.column = 0;
404
- var text = lang.stringRepeat(defaultReg.text + "\n", count || 1);
405
- editor.session.insert(pos, text);
406
- editor.moveCursorToPosition(pos);
407
- }
408
- else {
409
- editor.insert(lang.stringRepeat(defaultReg.text, count || 1));
517
+ if (typeof column === "number") {
518
+ cursor.column -= column + 1;
519
+ return cursor;
410
520
  }
411
- editor.setOverwrite(true);
412
- editor.selection.clearSelection();
413
521
  }
414
- },
415
- "J": {
416
- fn: function(editor, range, count, param) {
417
- var session = editor.session;
418
- range = editor.getSelectionRange();
419
- var pos = {row: range.start.row, column: range.start.column};
420
- count = count || range.end.row - range.start.row;
421
- var maxRow = Math.min(pos.row + (count || 1), session.getLength() - 1);
522
+ }),
523
+ "t": new Motion({
524
+ param: true,
525
+ handlesCount: true,
526
+ getPos: function(editor, range, count, param, isSel, isRepeat) {
527
+ if (param == "space") param = " ";
528
+ if (!isRepeat)
529
+ LAST_SEARCH_MOTION = {ch: "t", param: param};
530
+ var cursor = editor.getCursorPosition();
531
+ var column = util.getRightNthChar(editor, cursor, param, count || 1);
422
532
 
423
- range.start.column = session.getLine(pos.row).length;
424
- range.end.column = session.getLine(maxRow).length;
425
- range.end.row = maxRow;
426
-
427
- var text = "";
428
- for (var i = pos.row; i < maxRow; i++) {
429
- var nextLine = session.getLine(i + 1);
430
- text += " " + /^\s*(.*)$/.exec(nextLine)[1] || "";
533
+ if (isRepeat && column == 0 && !(count > 1))
534
+ column = util.getRightNthChar(editor, cursor, param, 2);
535
+
536
+ if (typeof column === "number") {
537
+ cursor.column += column + (isSel ? 1 : 0);
538
+ return cursor;
431
539
  }
432
-
433
- session.replace(range, text);
434
- editor.moveCursorTo(pos.row, pos.column);
435
540
  }
436
- },
437
- "u": {
438
- fn: function(editor, range, count, param) {
439
- count = parseInt(count || 1, 10);
440
- for (var i = 0; i < count; i++) {
441
- editor.undo();
541
+ }),
542
+ "T": new Motion({
543
+ param: true,
544
+ handlesCount: true,
545
+ getPos: function(editor, range, count, param, isSel, isRepeat) {
546
+ if (param == "space") param = " ";
547
+ if (!isRepeat)
548
+ LAST_SEARCH_MOTION = {ch: "T", param: param};
549
+ var cursor = editor.getCursorPosition();
550
+ var column = util.getLeftNthChar(editor, cursor, param, count || 1);
551
+
552
+ if (isRepeat && column === 0 && !(count > 1))
553
+ column = util.getLeftNthChar(editor, cursor, param, 2);
554
+
555
+ if (typeof column === "number") {
556
+ cursor.column -= column;
557
+ return cursor;
442
558
  }
443
- editor.selection.clearSelection();
444
559
  }
445
- },
446
- "ctrl-r": {
447
- fn: function(editor, range, count, param) {
448
- count = parseInt(count || 1, 10);
449
- for (var i = 0; i < count; i++) {
450
- editor.redo();
451
- }
452
- editor.selection.clearSelection();
560
+ }),
561
+ ";": new Motion({
562
+ handlesCount: true,
563
+ getPos: function(editor, range, count, param, isSel) {
564
+ var ch = LAST_SEARCH_MOTION.ch;
565
+ if (!ch)
566
+ return;
567
+ return module.exports[ch].getPos(
568
+ editor, range, count, LAST_SEARCH_MOTION.param, isSel, true
569
+ );
453
570
  }
454
- },
455
- ":": {
456
- fn: function(editor, range, count, param) {
457
- var val = ":";
458
- if (count > 1)
459
- val = ".,.+" + count + val;
460
- if (editor.showCommandLine)
461
- editor.showCommandLine(val);
571
+ }),
572
+ ",": new Motion({
573
+ handlesCount: true,
574
+ getPos: function(editor, range, count, param, isSel) {
575
+ var ch = LAST_SEARCH_MOTION.ch;
576
+ if (!ch)
577
+ return;
578
+ var up = ch.toUpperCase();
579
+ ch = ch === up ? ch.toLowerCase() : up;
580
+
581
+ return module.exports[ch].getPos(
582
+ editor, range, count, LAST_SEARCH_MOTION.param, isSel, true
583
+ );
462
584
  }
463
- },
464
- "/": {
465
- fn: function(editor, range, count, param) {
466
- if (editor.showCommandLine)
467
- editor.showCommandLine("/");
585
+ }),
586
+
587
+ "^": {
588
+ nav: function(editor) {
589
+ editor.navigateLineStart();
590
+ },
591
+ sel: function(editor) {
592
+ editor.selection.selectLineStart();
468
593
  }
469
594
  },
470
- "?": {
471
- fn: function(editor, range, count, param) {
472
- if (editor.showCommandLine)
473
- editor.showCommandLine("?");
595
+ "$": {
596
+ handlesCount: true,
597
+ nav: function(editor, range, count, param) {
598
+ if (count > 1) {
599
+ editor.navigateDown(count-1);
600
+ }
601
+ editor.navigateLineEnd();
602
+ },
603
+ sel: function(editor, range, count, param) {
604
+ if (count > 1) {
605
+ editor.selection.moveCursorBy(count-1, 0);
606
+ }
607
+ editor.selection.selectLineEnd();
474
608
  }
475
609
  },
476
- ".": {
477
- fn: function(editor, range, count, param) {
478
- util.onInsertReplaySequence = inputBuffer.lastInsertCommands;
479
- var previous = inputBuffer.previous;
480
- if (previous) // If there is a previous action
481
- inputBuffer.exec(editor, previous.action, previous.param);
610
+ "0": new Motion(function(ed) {
611
+ return {row: ed.selection.lead.row, column: 0};
612
+ }),
613
+ "G": {
614
+ nav: function(editor, range, count, param) {
615
+ if (!count && count !== 0) { // Stupid JS
616
+ count = editor.session.getLength();
617
+ }
618
+ editor.gotoLine(count);
619
+ },
620
+ sel: function(editor, range, count, param) {
621
+ if (!count && count !== 0) { // Stupid JS
622
+ count = editor.session.getLength();
623
+ }
624
+ editor.selection.selectTo(count, 0);
482
625
  }
483
626
  },
484
- "ctrl-x": {
485
- fn: function(editor, range, count, param) {
486
- editor.modifyNumber(-(count || 1));
627
+ "g": {
628
+ param: true,
629
+ nav: function(editor, range, count, param) {
630
+ switch(param) {
631
+ case "m":
632
+ console.log("Middle line");
633
+ break;
634
+ case "e":
635
+ console.log("End of prev word");
636
+ break;
637
+ case "g":
638
+ editor.gotoLine(count || 0);
639
+ case "u":
640
+ editor.gotoLine(count || 0);
641
+ case "U":
642
+ editor.gotoLine(count || 0);
643
+ }
644
+ },
645
+ sel: function(editor, range, count, param) {
646
+ switch(param) {
647
+ case "m":
648
+ console.log("Middle line");
649
+ break;
650
+ case "e":
651
+ console.log("End of prev word");
652
+ break;
653
+ case "g":
654
+ editor.selection.selectTo(count || 0, 0);
655
+ }
487
656
  }
488
657
  },
489
- "ctrl-a": {
490
- fn: function(editor, range, count, param) {
491
- editor.modifyNumber(count || 1);
492
- }
493
- }
494
- };
495
-
496
- var inputBuffer = exports.inputBuffer = {
497
- accepting: [NUMBER, OPERATOR, MOTION, ACTION],
498
- currentCmd: null,
499
- currentCount: "",
500
- status: "",
501
- operator: null,
502
- motion: null,
503
-
504
- lastInsertCommands: [],
505
-
506
- push: function(editor, ch, keyId) {
507
- var status = this.status;
508
- var isKeyHandled = true;
509
- this.idle = false;
510
- var wObj = this.waitingForParam;
511
- if (/^numpad\d+$/i.test(ch))
512
- ch = ch.substr(6);
513
-
514
- if (wObj) {
515
- this.exec(editor, wObj, ch);
516
- }
517
- else if (!(ch === "0" && !this.currentCount.length) &&
518
- (/^\d+$/.test(ch) && this.isAccepting(NUMBER))) {
519
- this.currentCount += ch;
520
- this.currentCmd = NUMBER;
521
- this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
522
- }
523
- else if (!this.operator && this.isAccepting(OPERATOR) && operators[ch]) {
524
- this.operator = {
525
- ch: ch,
526
- count: this.getCount()
527
- };
528
- this.currentCmd = OPERATOR;
529
- this.accepting = [NUMBER, MOTION, ACTION];
530
- this.exec(editor, { operator: this.operator });
531
- }
532
- else if (motions[ch] && this.isAccepting(MOTION)) {
533
- this.currentCmd = MOTION;
534
-
535
- var ctx = {
536
- operator: this.operator,
537
- motion: {
538
- ch: ch,
539
- count: this.getCount()
540
- }
541
- };
542
-
543
- if (motions[ch].param)
544
- this.waitForParam(ctx);
545
- else
546
- this.exec(editor, ctx);
547
- }
548
- else if (alias[ch] && this.isAccepting(MOTION)) {
549
- alias[ch].operator.count = this.getCount();
550
- this.exec(editor, alias[ch]);
551
- }
552
- else if (actions[ch] && this.isAccepting(ACTION)) {
553
- var actionObj = {
554
- action: {
555
- fn: actions[ch].fn,
556
- count: this.getCount()
557
- }
558
- };
658
+ "o": {
659
+ nav: function(editor, range, count, param) {
660
+ count = count || 1;
661
+ var content = "";
662
+ while (0 < count--)
663
+ content += "\n";
559
664
 
560
- if (actions[ch].param) {
561
- this.waitForParam(actionObj);
562
- }
563
- else {
564
- this.exec(editor, actionObj);
665
+ if (content.length) {
666
+ editor.navigateLineEnd();
667
+ editor.insert(content);
668
+ util.insertMode(editor);
565
669
  }
566
-
567
- if (actions[ch].acceptsMotion)
568
- this.idle = false;
569
- }
570
- else if (this.operator) {
571
- this.operator.count = this.getCount();
572
- this.exec(editor, { operator: this.operator }, ch);
573
- }
574
- else {
575
- isKeyHandled = ch.length == 1;
576
- this.reset();
577
670
  }
578
-
579
- if (this.waitingForParam || this.motion || this.operator) {
580
- this.status += ch;
581
- } else if (this.currentCount) {
582
- this.status = this.currentCount;
583
- } else if (this.status) {
584
- this.status = "";
585
- }
586
- if (this.status != status)
587
- editor._emit("changeStatus");
588
- return isKeyHandled;
589
- },
590
-
591
- waitForParam: function(cmd) {
592
- this.waitingForParam = cmd;
593
- },
594
-
595
- getCount: function() {
596
- var count = this.currentCount;
597
- this.currentCount = "";
598
- return count && parseInt(count, 10);
599
- },
600
-
601
- exec: function(editor, action, param) {
602
- var m = action.motion;
603
- var o = action.operator;
604
- var a = action.action;
605
-
606
- if (!param)
607
- param = action.param;
608
-
609
- if (o) {
610
- this.previous = {
611
- action: action,
612
- param: param
613
- };
614
- }
615
-
616
- if (o && !editor.selection.isEmpty()) {
617
- if (operators[o.ch].selFn) {
618
- operators[o.ch].selFn(editor, editor.getSelectionRange(), o.count, param);
619
- this.reset();
620
- }
621
- return;
622
- }
623
- else if (!m && !a && o && param) {
624
- operators[o.ch].fn(editor, null, o.count, param);
625
- this.reset();
626
- }
627
- else if (m) {
628
- var run = function(fn) {
629
- if (fn && typeof fn === "function") { // There should always be a motion
630
- if (m.count && !motionObj.handlesCount)
631
- repeat(fn, m.count, [editor, null, m.count, param]);
632
- else
633
- fn(editor, null, m.count, param);
634
- }
635
- };
636
-
637
- var motionObj = motions[m.ch];
638
- var selectable = motionObj.sel;
639
-
640
- if (!o) {
641
- if ((util.onVisualMode || util.onVisualLineMode) && selectable)
642
- run(motionObj.sel);
643
- else
644
- run(motionObj.nav);
645
- }
646
- else if (selectable) {
647
- repeat(function() {
648
- run(motionObj.sel);
649
- operators[o.ch].fn(editor, editor.getSelectionRange(), o.count, param);
650
- }, o.count || 1);
651
- }
652
- this.reset();
653
- }
654
- else if (a) {
655
- a.fn(editor, editor.getSelectionRange(), a.count, param);
656
- this.reset();
657
- }
658
- handleCursorMove(editor);
659
- },
660
-
661
- isAccepting: function(type) {
662
- return this.accepting.indexOf(type) !== -1;
663
- },
664
-
665
- reset: function() {
666
- this.operator = null;
667
- this.motion = null;
668
- this.currentCount = "";
669
- this.status = "";
670
- this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
671
- this.idle = true;
672
- this.waitingForParam = null;
673
- }
674
- };
675
-
676
- function setPreviousCommand(fn) {
677
- inputBuffer.previous = { action: { action: { fn: fn } } };
678
- }
679
-
680
- exports.coreCommands = {
681
- start: {
682
- exec: function start(editor) {
683
- util.insertMode(editor);
684
- setPreviousCommand(start);
685
- }
686
- },
687
- startBeginning: {
688
- exec: function startBeginning(editor) {
689
- editor.navigateLineStart();
690
- util.insertMode(editor);
691
- setPreviousCommand(startBeginning);
692
- }
693
- },
694
- stop: {
695
- exec: function stop(editor) {
696
- inputBuffer.reset();
697
- util.onVisualMode = false;
698
- util.onVisualLineMode = false;
699
- inputBuffer.lastInsertCommands = util.normalMode(editor);
700
- }
701
- },
702
- append: {
703
- exec: function append(editor) {
704
- var pos = editor.getCursorPosition();
705
- var lineLen = editor.session.getLine(pos.row).length;
706
- if (lineLen)
707
- editor.navigateRight();
708
- util.insertMode(editor);
709
- setPreviousCommand(append);
710
- }
711
- },
712
- appendEnd: {
713
- exec: function appendEnd(editor) {
714
- editor.navigateLineEnd();
715
- util.insertMode(editor);
716
- setPreviousCommand(appendEnd);
717
- }
718
- }
719
- };
720
-
721
- var handleCursorMove = exports.onCursorMove = function(editor, e) {
722
- if (util.currentMode === 'insert' || handleCursorMove.running)
723
- return;
724
- else if(!editor.selection.isEmpty()) {
725
- handleCursorMove.running = true;
726
- if (util.onVisualLineMode) {
727
- var originRow = editor.selection.visualLineStart;
728
- var cursorRow = editor.getCursorPosition().row;
729
- if(originRow <= cursorRow) {
730
- var endLine = editor.session.getLine(cursorRow);
731
- editor.selection.clearSelection();
732
- editor.selection.moveCursorTo(originRow, 0);
733
- editor.selection.selectTo(cursorRow, endLine.length);
734
- } else {
735
- var endLine = editor.session.getLine(originRow);
736
- editor.selection.clearSelection();
737
- editor.selection.moveCursorTo(originRow, endLine.length);
738
- editor.selection.selectTo(cursorRow, 0);
739
- }
740
- }
741
- handleCursorMove.running = false;
742
- return;
743
- }
744
- else {
745
- if (e && (util.onVisualLineMode || util.onVisualMode)) {
746
- editor.selection.clearSelection();
747
- util.normalMode(editor);
748
- }
749
-
750
- handleCursorMove.running = true;
751
- var pos = editor.getCursorPosition();
752
- var lineLen = editor.session.getLine(pos.row).length;
753
-
754
- if (lineLen && pos.column === lineLen)
755
- editor.navigateLeft();
756
- handleCursorMove.running = false;
757
- }
758
- };
759
- });
760
- define('ace/keyboard/vim/maps/util', ['require', 'exports', 'module' , 'ace/keyboard/vim/registers', 'ace/lib/dom'], function(require, exports, module) {
761
- var registers = require("../registers");
762
-
763
- var dom = require("../../../lib/dom");
764
- dom.importCssString('.insert-mode .ace_cursor{\
765
- border-left: 2px solid #333333;\
766
- }\
767
- .ace_dark.insert-mode .ace_cursor{\
768
- border-left: 2px solid #eeeeee;\
769
- }\
770
- .normal-mode .ace_cursor{\
771
- border: 0!important;\
772
- background-color: red;\
773
- opacity: 0.5;\
774
- }', 'vimMode');
775
-
776
- module.exports = {
777
- onVisualMode: false,
778
- onVisualLineMode: false,
779
- currentMode: 'normal',
780
- noMode: function(editor) {
781
- editor.unsetStyle('insert-mode');
782
- editor.unsetStyle('normal-mode');
783
- if (editor.commands.recording)
784
- editor.commands.toggleRecording(editor);
785
- editor.setOverwrite(false);
786
- },
787
- insertMode: function(editor) {
788
- this.currentMode = 'insert';
789
- editor.setStyle('insert-mode');
790
- editor.unsetStyle('normal-mode');
791
-
792
- editor.setOverwrite(false);
793
- editor.keyBinding.$data.buffer = "";
794
- editor.keyBinding.$data.state = "insertMode";
795
- this.onVisualMode = false;
796
- this.onVisualLineMode = false;
797
- if(this.onInsertReplaySequence) {
798
- editor.commands.macro = this.onInsertReplaySequence;
799
- editor.commands.replay(editor);
800
- this.onInsertReplaySequence = null;
801
- this.normalMode(editor);
802
- } else {
803
- editor._emit("changeStatus");
804
- if(!editor.commands.recording)
805
- editor.commands.toggleRecording(editor);
806
- }
807
- },
808
- normalMode: function(editor) {
809
- this.currentMode = 'normal';
810
-
811
- editor.unsetStyle('insert-mode');
812
- editor.setStyle('normal-mode');
813
- editor.clearSelection();
814
-
815
- var pos;
816
- if (!editor.getOverwrite()) {
817
- pos = editor.getCursorPosition();
818
- if (pos.column > 0)
819
- editor.navigateLeft();
820
- }
821
-
822
- editor.setOverwrite(true);
823
- editor.keyBinding.$data.buffer = "";
824
- editor.keyBinding.$data.state = "start";
825
- this.onVisualMode = false;
826
- this.onVisualLineMode = false;
827
- editor._emit("changeStatus");
828
- if (editor.commands.recording) {
829
- editor.commands.toggleRecording(editor);
830
- return editor.commands.macro;
831
- }
832
- else {
833
- return [];
834
- }
835
- },
836
- visualMode: function(editor, lineMode) {
837
- if (
838
- (this.onVisualLineMode && lineMode)
839
- || (this.onVisualMode && !lineMode)
840
- ) {
841
- this.normalMode(editor);
842
- return;
843
- }
844
-
845
- editor.setStyle('insert-mode');
846
- editor.unsetStyle('normal-mode');
847
-
848
- editor._emit("changeStatus");
849
- if (lineMode) {
850
- this.onVisualLineMode = true;
851
- } else {
852
- this.onVisualMode = true;
853
- this.onVisualLineMode = false;
854
- }
855
- },
856
- getRightNthChar: function(editor, cursor, ch, n) {
857
- var line = editor.getSession().getLine(cursor.row);
858
- var matches = line.substr(cursor.column + 1).split(ch);
859
-
860
- return n < matches.length ? matches.slice(0, n).join(ch).length : null;
861
- },
862
- getLeftNthChar: function(editor, cursor, ch, n) {
863
- var line = editor.getSession().getLine(cursor.row);
864
- var matches = line.substr(0, cursor.column).split(ch);
865
-
866
- return n < matches.length ? matches.slice(-1 * n).join(ch).length : null;
867
671
  },
868
- toRealChar: function(ch) {
869
- if (ch.length === 1)
870
- return ch;
871
-
872
- if (/^shift-./.test(ch))
873
- return ch[ch.length - 1].toUpperCase();
874
- else
875
- return "";
876
- },
877
- copyLine: function(editor) {
878
- var pos = editor.getCursorPosition();
879
- editor.selection.clearSelection();
880
- editor.moveCursorTo(pos.row, pos.column);
881
- editor.selection.selectLine();
882
- registers._default.isLine = true;
883
- registers._default.text = editor.getCopyText().replace(/\n$/, "");
884
- editor.selection.clearSelection();
885
- editor.moveCursorTo(pos.row, pos.column);
886
- }
887
- };
888
- });
889
-
890
- define('ace/keyboard/vim/registers', ['require', 'exports', 'module' ], function(require, exports, module) {
891
-
892
- "never use strict";
893
-
894
- module.exports = {
895
- _default: {
896
- text: "",
897
- isLine: false
898
- }
899
- };
900
-
901
- });
902
-
903
-
904
- define('ace/keyboard/vim/maps/motions', ['require', 'exports', 'module' , 'ace/keyboard/vim/maps/util', 'ace/search', 'ace/range'], function(require, exports, module) {
905
-
906
-
907
- var util = require("./util");
908
-
909
- var keepScrollPosition = function(editor, fn) {
910
- var scrollTopRow = editor.renderer.getScrollTopRow();
911
- var initialRow = editor.getCursorPosition().row;
912
- var diff = initialRow - scrollTopRow;
913
- fn && fn.call(editor);
914
- editor.renderer.scrollToRow(editor.getCursorPosition().row - diff);
915
- };
916
-
917
- function Motion(m) {
918
- if (typeof m == "function") {
919
- var getPos = m;
920
- m = this;
921
- } else {
922
- var getPos = m.getPos;
923
- }
924
- m.nav = function(editor, range, count, param) {
925
- var a = getPos(editor, range, count, param, false);
926
- if (!a)
927
- return;
928
- editor.clearSelection();
929
- editor.moveCursorTo(a.row, a.column);
930
- };
931
- m.sel = function(editor, range, count, param) {
932
- var a = getPos(editor, range, count, param, true);
933
- if (!a)
934
- return;
935
- editor.selection.selectTo(a.row, a.column);
936
- };
937
- return m;
938
- }
939
-
940
- var nonWordRe = /[\s.\/\\()\"'-:,.;<>~!@#$%^&*|+=\[\]{}`~?]/;
941
- var wordSeparatorRe = /[.\/\\()\"'-:,.;<>~!@#$%^&*|+=\[\]{}`~?]/;
942
- var whiteRe = /\s/;
943
- var StringStream = function(editor, cursor) {
944
- var sel = editor.selection;
945
- this.range = sel.getRange();
946
- cursor = cursor || sel.selectionLead;
947
- this.row = cursor.row;
948
- this.col = cursor.column;
949
- var line = editor.session.getLine(this.row);
950
- var maxRow = editor.session.getLength();
951
- this.ch = line[this.col] || '\n';
952
- this.skippedLines = 0;
953
-
954
- this.next = function() {
955
- this.ch = line[++this.col] || this.handleNewLine(1);
956
- return this.ch;
957
- };
958
- this.prev = function() {
959
- this.ch = line[--this.col] || this.handleNewLine(-1);
960
- return this.ch;
961
- };
962
- this.peek = function(dir) {
963
- var ch = line[this.col + dir];
964
- if (ch)
965
- return ch;
966
- if (dir == -1)
967
- return '\n';
968
- if (this.col == line.length - 1)
969
- return '\n';
970
- return editor.session.getLine(this.row + 1)[0] || '\n';
971
- };
972
-
973
- this.handleNewLine = function(dir) {
974
- if (dir == 1){
975
- if (this.col == line.length)
976
- return '\n';
977
- if (this.row == maxRow - 1)
978
- return '';
979
- this.col = 0;
980
- this.row ++;
981
- line = editor.session.getLine(this.row);
982
- this.skippedLines++;
983
- return line[0] || '\n';
984
- }
985
- if (dir == -1) {
986
- if (this.row === 0)
987
- return '';
988
- this.row --;
989
- line = editor.session.getLine(this.row);
990
- this.col = line.length;
991
- this.skippedLines--;
992
- return '\n';
993
- }
994
- };
995
- this.debug = function() {
996
- console.log(line.substring(0, this.col)+'|'+this.ch+'\''+this.col+'\''+line.substr(this.col+1));
997
- };
998
- };
999
-
1000
- var Search = require("../../../search").Search;
1001
- var search = new Search();
1002
-
1003
- function find(editor, needle, dir) {
1004
- search.$options.needle = needle;
1005
- search.$options.backwards = dir == -1;
1006
- return search.find(editor.session);
1007
- }
1008
-
1009
- var Range = require("../../../range").Range;
1010
-
1011
- var LAST_SEARCH_MOTION = {};
1012
-
1013
- module.exports = {
1014
- "w": new Motion(function(editor) {
1015
- var str = new StringStream(editor);
672
+ "O": {
673
+ nav: function(editor, range, count, param) {
674
+ var row = editor.getCursorPosition().row;
675
+ count = count || 1;
676
+ var content = "";
677
+ while (0 < count--)
678
+ content += "\n";
1016
679
 
1017
- if (str.ch && wordSeparatorRe.test(str.ch)) {
1018
- while (str.ch && wordSeparatorRe.test(str.ch))
1019
- str.next();
1020
- } else {
1021
- while (str.ch && !nonWordRe.test(str.ch))
1022
- str.next();
680
+ if (content.length) {
681
+ if(row > 0) {
682
+ editor.navigateUp();
683
+ editor.navigateLineEnd();
684
+ editor.insert(content);
685
+ } else {
686
+ editor.session.insert({row: 0, column: 0}, content);
687
+ editor.navigateUp();
688
+ }
689
+ util.insertMode(editor);
690
+ }
1023
691
  }
1024
- while (str.ch && whiteRe.test(str.ch) && str.skippedLines < 2)
1025
- str.next();
692
+ },
693
+ "%": new Motion(function(editor){
694
+ var brRe = /[\[\]{}()]/g;
695
+ var cursor = editor.getCursorPosition();
696
+ var ch = editor.session.getLine(cursor.row)[cursor.column];
697
+ if (!brRe.test(ch)) {
698
+ var range = find(editor, brRe);
699
+ if (!range)
700
+ return;
701
+ cursor = range.start;
702
+ }
703
+ var match = editor.session.findMatchingBracket({
704
+ row: cursor.row,
705
+ column: cursor.column + 1
706
+ });
1026
707
 
1027
- str.skippedLines == 2 && str.prev();
1028
- return {column: str.col, row: str.row};
708
+ return match;
1029
709
  }),
1030
- "W": new Motion(function(editor) {
1031
- var str = new StringStream(editor);
1032
- while(str.ch && !(whiteRe.test(str.ch) && !whiteRe.test(str.peek(1))) && str.skippedLines < 2)
1033
- str.next();
1034
- if (str.skippedLines == 2)
1035
- str.prev();
1036
- else
1037
- str.next();
1038
-
1039
- return {column: str.col, row: str.row};
710
+ "{": new Motion(function(ed) {
711
+ var session = ed.session;
712
+ var row = session.selection.lead.row;
713
+ while(row > 0 && !/\S/.test(session.getLine(row)))
714
+ row--;
715
+ while(/\S/.test(session.getLine(row)))
716
+ row--;
717
+ return {column: 0, row: row};
1040
718
  }),
1041
- "b": new Motion(function(editor) {
1042
- var str = new StringStream(editor);
1043
-
1044
- str.prev();
1045
- while (str.ch && whiteRe.test(str.ch) && str.skippedLines > -2)
1046
- str.prev();
1047
-
1048
- if (str.ch && wordSeparatorRe.test(str.ch)) {
1049
- while (str.ch && wordSeparatorRe.test(str.ch))
1050
- str.prev();
1051
- } else {
1052
- while (str.ch && !nonWordRe.test(str.ch))
1053
- str.prev();
719
+ "}": new Motion(function(ed) {
720
+ var session = ed.session;
721
+ var l = session.getLength();
722
+ var row = session.selection.lead.row;
723
+ while(row < l && !/\S/.test(session.getLine(row)))
724
+ row++;
725
+ while(/\S/.test(session.getLine(row)))
726
+ row++;
727
+ return {column: 0, row: row};
728
+ }),
729
+ "ctrl-d": {
730
+ nav: function(editor, range, count, param) {
731
+ editor.selection.clearSelection();
732
+ keepScrollPosition(editor, editor.gotoPageDown);
733
+ },
734
+ sel: function(editor, range, count, param) {
735
+ keepScrollPosition(editor, editor.selectPageDown);
736
+ }
737
+ },
738
+ "ctrl-u": {
739
+ nav: function(editor, range, count, param) {
740
+ editor.selection.clearSelection();
741
+ keepScrollPosition(editor, editor.gotoPageUp);
742
+ },
743
+ sel: function(editor, range, count, param) {
744
+ keepScrollPosition(editor, editor.selectPageUp);
745
+ }
746
+ },
747
+ "`": new Motion({
748
+ param: true,
749
+ handlesCount: true,
750
+ getPos: function(editor, range, count, param, isSel) {
751
+ var s = editor.session;
752
+ var marker = s.vimMarkers && s.vimMarkers[param];
753
+ if (marker) {
754
+ return marker.getPosition();
755
+ }
1054
756
  }
1055
- str.ch && str.next();
1056
- return {column: str.col, row: str.row};
1057
757
  }),
1058
- "B": new Motion(function(editor) {
1059
- var str = new StringStream(editor);
1060
- str.prev();
1061
- while(str.ch && !(!whiteRe.test(str.ch) && whiteRe.test(str.peek(-1))) && str.skippedLines > -2)
1062
- str.prev();
758
+ "'": new Motion({
759
+ param: true,
760
+ handlesCount: true,
761
+ getPos: function(editor, range, count, param, isSel) {
762
+ var s = editor.session;
763
+ var marker = s.vimMarkers && s.vimMarkers[param];
764
+ if (marker) {
765
+ var pos = marker.getPosition();
766
+ var line = editor.session.getLine(pos.row);
767
+ pos.column = line.search(/\S/);
768
+ if (pos.column == -1)
769
+ pos.column = line.length;
770
+ return pos;
771
+ }
772
+ },
773
+ isLine: true
774
+ })
775
+ };
1063
776
 
1064
- if (str.skippedLines == -2)
1065
- str.next();
777
+ module.exports.backspace = module.exports.left = module.exports.h;
778
+ module.exports.space = module.exports['return'] = module.exports.right = module.exports.l;
779
+ module.exports.up = module.exports.k;
780
+ module.exports.down = module.exports.j;
781
+ module.exports.pagedown = module.exports["ctrl-d"];
782
+ module.exports.pageup = module.exports["ctrl-u"];
783
+ module.exports.home = module.exports["0"];
784
+ module.exports.end = module.exports["$"];
1066
785
 
1067
- return {column: str.col, row: str.row};
1068
- }),
1069
- "e": new Motion(function(editor) {
1070
- var str = new StringStream(editor);
786
+ });
1071
787
 
1072
- str.next();
1073
- while (str.ch && whiteRe.test(str.ch))
1074
- str.next();
788
+ define("ace/keyboard/vim/maps/operators",["require","exports","module","ace/keyboard/vim/maps/util","ace/keyboard/vim/registers","ace/range"], function(require, exports, module) {
1075
789
 
1076
- if (str.ch && wordSeparatorRe.test(str.ch)) {
1077
- while (str.ch && wordSeparatorRe.test(str.ch))
1078
- str.next();
1079
- } else {
1080
- while (str.ch && !nonWordRe.test(str.ch))
1081
- str.next();
1082
- }
1083
- str.ch && str.prev();
1084
- return {column: str.col, row: str.row};
1085
- }),
1086
- "E": new Motion(function(editor) {
1087
- var str = new StringStream(editor);
1088
- str.next();
1089
- while(str.ch && !(!whiteRe.test(str.ch) && whiteRe.test(str.peek(1))))
1090
- str.next();
790
+ "use strict";
1091
791
 
1092
- return {column: str.col, row: str.row};
1093
- }),
792
+ var util = require("./util");
793
+ var registers = require("../registers");
794
+ var Range = require("../../../range").Range;
1094
795
 
1095
- "l": {
1096
- nav: function(editor) {
1097
- var pos = editor.getCursorPosition();
1098
- var col = pos.column;
1099
- var lineLen = editor.session.getLine(pos.row).length;
1100
- if (lineLen && col !== lineLen)
1101
- editor.navigateRight();
796
+ module.exports = {
797
+ "d": {
798
+ selFn: function(editor, range, count, param) {
799
+ registers._default.text = editor.getCopyText();
800
+ registers._default.isLine = util.onVisualLineMode;
801
+ if(util.onVisualLineMode)
802
+ editor.removeLines();
803
+ else
804
+ editor.session.remove(range);
805
+ util.normalMode(editor);
1102
806
  },
1103
- sel: function(editor) {
1104
- var pos = editor.getCursorPosition();
1105
- var col = pos.column;
1106
- var lineLen = editor.session.getLine(pos.row).length;
1107
- if (lineLen && col !== lineLen) //In selection mode you can select the newline
1108
- editor.selection.selectRight();
807
+ fn: function(editor, range, count, param) {
808
+ count = count || 1;
809
+ switch (param) {
810
+ case "d":
811
+ registers._default.text = "";
812
+ registers._default.isLine = true;
813
+ for (var i = 0; i < count; i++) {
814
+ editor.selection.selectLine();
815
+ registers._default.text += editor.getCopyText();
816
+ var selRange = editor.getSelectionRange();
817
+ if (!selRange.isMultiLine()) {
818
+ var row = selRange.start.row - 1;
819
+ var col = editor.session.getLine(row).length
820
+ selRange.setStart(row, col);
821
+ editor.session.remove(selRange);
822
+ editor.selection.clearSelection();
823
+ break;
824
+ }
825
+ editor.session.remove(selRange);
826
+ editor.selection.clearSelection();
827
+ }
828
+ registers._default.text = registers._default.text.replace(/\n$/, "");
829
+ break;
830
+ default:
831
+ if (range) {
832
+ editor.selection.setSelectionRange(range);
833
+ registers._default.text = editor.getCopyText();
834
+ registers._default.isLine = false;
835
+ editor.session.remove(range);
836
+ editor.selection.clearSelection();
837
+ }
838
+ }
839
+ }
840
+ },
841
+ "c": {
842
+ selFn: function(editor, range, count, param) {
843
+ editor.session.remove(range);
844
+ util.insertMode(editor);
845
+ },
846
+ fn: function(editor, range, count, param) {
847
+ count = count || 1;
848
+ switch (param) {
849
+ case "c":
850
+ editor.$blockScrolling++;
851
+ editor.selection.$moveSelection(function() {
852
+ editor.selection.moveCursorBy(count - 1, 0);
853
+ });
854
+ var rows = editor.$getSelectedRows();
855
+ range = new Range(rows.first, 0, rows.last, Infinity);
856
+ editor.session.remove(range);
857
+ editor.$blockScrolling--;
858
+ util.insertMode(editor);
859
+ break;
860
+ default:
861
+ if (range) {
862
+ editor.session.remove(range);
863
+ util.insertMode(editor);
864
+ }
865
+ }
866
+ }
867
+ },
868
+ "y": {
869
+ selFn: function(editor, range, count, param) {
870
+ registers._default.text = editor.getCopyText();
871
+ registers._default.isLine = util.onVisualLineMode;
872
+ editor.selection.clearSelection();
873
+ util.normalMode(editor);
874
+ },
875
+ fn: function(editor, range, count, param) {
876
+ count = count || 1;
877
+ if (param && param.isLine)
878
+ param = "y";
879
+ switch (param) {
880
+ case "y":
881
+ var pos = editor.getCursorPosition();
882
+ editor.selection.selectLine();
883
+ for (var i = 0; i < count - 1; i++) {
884
+ editor.selection.moveCursorDown();
885
+ }
886
+ registers._default.text = editor.getCopyText().replace(/\n$/, "");
887
+ editor.selection.clearSelection();
888
+ registers._default.isLine = true;
889
+ editor.moveCursorToPosition(pos);
890
+ break;
891
+ default:
892
+ if (range) {
893
+ var pos = editor.getCursorPosition();
894
+ editor.selection.setSelectionRange(range);
895
+ registers._default.text = editor.getCopyText();
896
+ registers._default.isLine = false;
897
+ editor.selection.clearSelection();
898
+ editor.moveCursorTo(pos.row, pos.column);
899
+ }
900
+ }
1109
901
  }
1110
902
  },
1111
- "h": {
1112
- nav: function(editor) {
1113
- var pos = editor.getCursorPosition();
1114
- if (pos.column > 0)
1115
- editor.navigateLeft();
903
+ ">": {
904
+ selFn: function(editor, range, count, param) {
905
+ count = count || 1;
906
+ for (var i = 0; i < count; i++) {
907
+ editor.indent();
908
+ }
909
+ util.normalMode(editor);
1116
910
  },
1117
- sel: function(editor) {
1118
- var pos = editor.getCursorPosition();
1119
- if (pos.column > 0)
1120
- editor.selection.selectLeft();
911
+ fn: function(editor, range, count, param) {
912
+ count = parseInt(count || 1, 10);
913
+ switch (param) {
914
+ case ">":
915
+ var pos = editor.getCursorPosition();
916
+ editor.selection.selectLine();
917
+ for (var i = 0; i < count - 1; i++) {
918
+ editor.selection.moveCursorDown();
919
+ }
920
+ editor.indent();
921
+ editor.selection.clearSelection();
922
+ editor.moveCursorToPosition(pos);
923
+ editor.navigateLineEnd();
924
+ editor.navigateLineStart();
925
+ break;
926
+ }
1121
927
  }
1122
928
  },
1123
- "H": {
1124
- nav: function(editor) {
1125
- var row = editor.renderer.getScrollTopRow();
1126
- editor.moveCursorTo(row);
929
+ "<": {
930
+ selFn: function(editor, range, count, param) {
931
+ count = count || 1;
932
+ for (var i = 0; i < count; i++) {
933
+ editor.blockOutdent();
934
+ }
935
+ util.normalMode(editor);
1127
936
  },
1128
- sel: function(editor) {
1129
- var row = editor.renderer.getScrollTopRow();
1130
- editor.selection.selectTo(row);
937
+ fn: function(editor, range, count, param) {
938
+ count = count || 1;
939
+ switch (param) {
940
+ case "<":
941
+ var pos = editor.getCursorPosition();
942
+ editor.selection.selectLine();
943
+ for (var i = 0; i < count - 1; i++) {
944
+ editor.selection.moveCursorDown();
945
+ }
946
+ editor.blockOutdent();
947
+ editor.selection.clearSelection();
948
+ editor.moveCursorToPosition(pos);
949
+ editor.navigateLineEnd();
950
+ editor.navigateLineStart();
951
+ break;
952
+ }
953
+ }
954
+ }
955
+ };
956
+ });
957
+
958
+ "use strict"
959
+
960
+ define("ace/keyboard/vim/maps/aliases",["require","exports","module"], function(require, exports, module) {
961
+ module.exports = {
962
+ "x": {
963
+ operator: {
964
+ ch: "d",
965
+ count: 1
966
+ },
967
+ motion: {
968
+ ch: "l",
969
+ count: 1
1131
970
  }
1132
971
  },
1133
- "M": {
1134
- nav: function(editor) {
1135
- var topRow = editor.renderer.getScrollTopRow();
1136
- var bottomRow = editor.renderer.getScrollBottomRow();
1137
- var row = topRow + ((bottomRow - topRow) / 2);
1138
- editor.moveCursorTo(row);
972
+ "X": {
973
+ operator: {
974
+ ch: "d",
975
+ count: 1
1139
976
  },
1140
- sel: function(editor) {
1141
- var topRow = editor.renderer.getScrollTopRow();
1142
- var bottomRow = editor.renderer.getScrollBottomRow();
1143
- var row = topRow + ((bottomRow - topRow) / 2);
1144
- editor.selection.selectTo(row);
977
+ motion: {
978
+ ch: "h",
979
+ count: 1
1145
980
  }
1146
981
  },
1147
- "L": {
1148
- nav: function(editor) {
1149
- var row = editor.renderer.getScrollBottomRow();
1150
- editor.moveCursorTo(row);
982
+ "D": {
983
+ operator: {
984
+ ch: "d",
985
+ count: 1
1151
986
  },
1152
- sel: function(editor) {
1153
- var row = editor.renderer.getScrollBottomRow();
1154
- editor.selection.selectTo(row);
987
+ motion: {
988
+ ch: "$",
989
+ count: 1
1155
990
  }
1156
991
  },
1157
- "k": {
1158
- nav: function(editor) {
1159
- editor.navigateUp();
992
+ "C": {
993
+ operator: {
994
+ ch: "c",
995
+ count: 1
1160
996
  },
1161
- sel: function(editor) {
1162
- editor.selection.selectUp();
997
+ motion: {
998
+ ch: "$",
999
+ count: 1
1163
1000
  }
1164
1001
  },
1165
- "j": {
1166
- nav: function(editor) {
1167
- editor.navigateDown();
1002
+ "s": {
1003
+ operator: {
1004
+ ch: "c",
1005
+ count: 1
1168
1006
  },
1169
- sel: function(editor) {
1170
- editor.selection.selectDown();
1007
+ motion: {
1008
+ ch: "l",
1009
+ count: 1
1171
1010
  }
1172
1011
  },
1012
+ "S": {
1013
+ operator: {
1014
+ ch: "c",
1015
+ count: 1
1016
+ },
1017
+ param: "c"
1018
+ }
1019
+ };
1020
+ });
1173
1021
 
1174
- "i": {
1022
+ define("ace/keyboard/vim/commands",["require","exports","module","ace/lib/lang","ace/keyboard/vim/maps/util","ace/keyboard/vim/maps/motions","ace/keyboard/vim/maps/operators","ace/keyboard/vim/maps/aliases","ace/keyboard/vim/registers"], function(require, exports, module) {
1023
+
1024
+ "never use strict";
1025
+
1026
+ var lang = require("../../lib/lang");
1027
+ var util = require("./maps/util");
1028
+ var motions = require("./maps/motions");
1029
+ var operators = require("./maps/operators");
1030
+ var alias = require("./maps/aliases");
1031
+ var registers = require("./registers");
1032
+
1033
+ var NUMBER = 1;
1034
+ var OPERATOR = 2;
1035
+ var MOTION = 3;
1036
+ var ACTION = 4;
1037
+ var HMARGIN = 8; // Minimum amount of line separation between margins;
1038
+
1039
+ var repeat = function repeat(fn, count, args) {
1040
+ while (0 < count--)
1041
+ fn.apply(this, args);
1042
+ };
1043
+
1044
+ var ensureScrollMargin = function(editor) {
1045
+ var renderer = editor.renderer;
1046
+ var pos = renderer.$cursorLayer.getPixelPosition();
1047
+
1048
+ var top = pos.top;
1049
+
1050
+ var margin = HMARGIN * renderer.layerConfig.lineHeight;
1051
+ if (2 * margin > renderer.$size.scrollerHeight)
1052
+ margin = renderer.$size.scrollerHeight / 2;
1053
+
1054
+ if (renderer.scrollTop > top - margin) {
1055
+ renderer.session.setScrollTop(top - margin);
1056
+ }
1057
+
1058
+ if (renderer.scrollTop + renderer.$size.scrollerHeight < top + margin + renderer.lineHeight) {
1059
+ renderer.session.setScrollTop(top + margin + renderer.lineHeight - renderer.$size.scrollerHeight);
1060
+ }
1061
+ };
1062
+
1063
+ var actions = exports.actions = {
1064
+ "z": {
1175
1065
  param: true,
1176
- sel: function(editor, range, count, param) {
1066
+ fn: function(editor, range, count, param) {
1177
1067
  switch (param) {
1178
- case "w":
1179
- editor.selection.selectWord();
1180
- break;
1181
- case "W":
1182
- editor.selection.selectAWord();
1068
+ case "z":
1069
+ editor.renderer.alignCursor(null, 0.5);
1183
1070
  break;
1184
- case "(":
1185
- case "{":
1186
- case "[":
1187
- var cursor = editor.getCursorPosition();
1188
- var end = editor.session.$findClosingBracket(param, cursor, /paren/);
1189
- if (!end)
1190
- return;
1191
- var start = editor.session.$findOpeningBracket(editor.session.$brackets[param], cursor, /paren/);
1192
- if (!start)
1193
- return;
1194
- start.column ++;
1195
- editor.selection.setSelectionRange(Range.fromPoints(start, end));
1071
+ case "t":
1072
+ editor.renderer.alignCursor(null, 0);
1196
1073
  break;
1197
- case "'":
1198
- case '"':
1199
- case "/":
1200
- var end = find(editor, param, 1);
1201
- if (!end)
1202
- return;
1203
- var start = find(editor, param, -1);
1204
- if (!start)
1205
- return;
1206
- editor.selection.setSelectionRange(Range.fromPoints(start.end, end.start));
1074
+ case "b":
1075
+ editor.renderer.alignCursor(null, 1);
1207
1076
  break;
1208
- }
1209
- }
1210
- },
1211
- "a": {
1212
- param: true,
1213
- sel: function(editor, range, count, param) {
1214
- switch (param) {
1215
- case "w":
1216
- editor.selection.selectAWord();
1077
+ case "c":
1078
+ editor.session.onFoldWidgetClick(range.start.row, {domEvent:{target :{}}});
1217
1079
  break;
1218
- case "W":
1219
- editor.selection.selectAWord();
1080
+ case "o":
1081
+ editor.session.onFoldWidgetClick(range.start.row, {domEvent:{target :{}}});
1220
1082
  break;
1221
- case "(":
1222
- case "{":
1223
- case "[":
1224
- var cursor = editor.getCursorPosition();
1225
- var end = editor.session.$findClosingBracket(param, cursor, /paren/);
1226
- if (!end)
1227
- return;
1228
- var start = editor.session.$findOpeningBracket(editor.session.$brackets[param], cursor, /paren/);
1229
- if (!start)
1230
- return;
1231
- end.column ++;
1232
- editor.selection.setSelectionRange(Range.fromPoints(start, end));
1083
+ case "C":
1084
+ editor.session.foldAll();
1233
1085
  break;
1234
- case "'":
1235
- case "\"":
1236
- case "/":
1237
- var end = find(editor, param, 1);
1238
- if (!end)
1239
- return;
1240
- var start = find(editor, param, -1);
1241
- if (!start)
1242
- return;
1243
- end.column ++;
1244
- editor.selection.setSelectionRange(Range.fromPoints(start.start, end.end));
1086
+ case "O":
1087
+ editor.session.unfold();
1245
1088
  break;
1246
1089
  }
1247
1090
  }
1248
1091
  },
1249
-
1250
- "f": new Motion({
1092
+ "r": {
1251
1093
  param: true,
1252
- handlesCount: true,
1253
- getPos: function(editor, range, count, param, isSel, isRepeat) {
1254
- if (!isRepeat)
1255
- LAST_SEARCH_MOTION = {ch: "f", param: param};
1256
- var cursor = editor.getCursorPosition();
1257
- var column = util.getRightNthChar(editor, cursor, param, count || 1);
1258
-
1259
- if (typeof column === "number") {
1260
- cursor.column += column + (isSel ? 2 : 1);
1261
- return cursor;
1094
+ fn: function(editor, range, count, param) {
1095
+ if (param && param.length) {
1096
+ if (param.length > 1)
1097
+ param = param == "return" ? "\n" : param == "tab" ? "\t" : param;
1098
+ repeat(function() { editor.insert(param); }, count || 1);
1099
+ editor.navigateLeft();
1262
1100
  }
1263
1101
  }
1264
- }),
1265
- "F": new Motion({
1266
- param: true,
1267
- handlesCount: true,
1268
- getPos: function(editor, range, count, param, isSel, isRepeat) {
1269
- if (!isRepeat)
1270
- LAST_SEARCH_MOTION = {ch: "F", param: param};
1271
- var cursor = editor.getCursorPosition();
1272
- var column = util.getLeftNthChar(editor, cursor, param, count || 1);
1273
-
1274
- if (typeof column === "number") {
1275
- cursor.column -= column + 1;
1276
- return cursor;
1277
- }
1102
+ },
1103
+ "R": {
1104
+ fn: function(editor, range, count, param) {
1105
+ util.insertMode(editor);
1106
+ editor.setOverwrite(true);
1278
1107
  }
1279
- }),
1280
- "t": new Motion({
1281
- param: true,
1282
- handlesCount: true,
1283
- getPos: function(editor, range, count, param, isSel, isRepeat) {
1284
- if (!isRepeat)
1285
- LAST_SEARCH_MOTION = {ch: "t", param: param};
1286
- var cursor = editor.getCursorPosition();
1287
- var column = util.getRightNthChar(editor, cursor, param, count || 1);
1288
-
1289
- if (isRepeat && column == 0 && !(count > 1))
1290
- var column = util.getRightNthChar(editor, cursor, param, 2);
1291
-
1292
- if (typeof column === "number") {
1293
- cursor.column += column + (isSel ? 1 : 0);
1294
- return cursor;
1295
- }
1108
+ },
1109
+ "~": {
1110
+ fn: function(editor, range, count) {
1111
+ repeat(function() {
1112
+ var range = editor.selection.getRange();
1113
+ if (range.isEmpty())
1114
+ range.end.column++;
1115
+ var text = editor.session.getTextRange(range);
1116
+ var toggled = text.toUpperCase();
1117
+ if (toggled != text)
1118
+ editor.session.replace(range, toggled);
1119
+ else if (text.toLowerCase() != text)
1120
+ editor.session.replace(range, text.toLowerCase())
1121
+ else
1122
+ editor.navigateRight();
1123
+ }, count || 1);
1296
1124
  }
1297
- }),
1298
- "T": new Motion({
1125
+ },
1126
+ "*": {
1127
+ fn: function(editor, range, count, param) {
1128
+ editor.selection.selectWord();
1129
+ editor.findNext();
1130
+ ensureScrollMargin(editor);
1131
+ var r = editor.selection.getRange();
1132
+ editor.selection.setSelectionRange(r, true);
1133
+ }
1134
+ },
1135
+ "#": {
1136
+ fn: function(editor, range, count, param) {
1137
+ editor.selection.selectWord();
1138
+ editor.findPrevious();
1139
+ ensureScrollMargin(editor);
1140
+ var r = editor.selection.getRange();
1141
+ editor.selection.setSelectionRange(r, true);
1142
+ }
1143
+ },
1144
+ "m": {
1299
1145
  param: true,
1300
- handlesCount: true,
1301
- getPos: function(editor, range, count, param, isSel, isRepeat) {
1302
- if (!isRepeat)
1303
- LAST_SEARCH_MOTION = {ch: "T", param: param};
1304
- var cursor = editor.getCursorPosition();
1305
- var column = util.getLeftNthChar(editor, cursor, param, count || 1);
1306
-
1307
- if (isRepeat && column == 0 && !(count > 1))
1308
- var column = util.getLeftNthChar(editor, cursor, param, 2);
1309
-
1310
- if (typeof column === "number") {
1311
- cursor.column -= column;
1312
- return cursor;
1146
+ fn: function(editor, range, count, param) {
1147
+ var s = editor.session;
1148
+ var markers = s.vimMarkers || (s.vimMarkers = {});
1149
+ var c = editor.getCursorPosition();
1150
+ if (!markers[param]) {
1151
+ markers[param] = editor.session.doc.createAnchor(c);
1313
1152
  }
1153
+ markers[param].setPosition(c.row, c.column, true);
1314
1154
  }
1315
- }),
1316
- ";": new Motion({
1317
- handlesCount: true,
1318
- getPos: function(editor, range, count, param, isSel) {
1319
- var ch = LAST_SEARCH_MOTION.ch;
1320
- if (!ch)
1321
- return;
1322
- return module.exports[ch].getPos(
1323
- editor, range, count, LAST_SEARCH_MOTION.param, isSel, true
1324
- );
1325
- }
1326
- }),
1327
- ",": new Motion({
1328
- handlesCount: true,
1329
- getPos: function(editor, range, count, param, isSel) {
1330
- var ch = LAST_SEARCH_MOTION.ch;
1331
- if (!ch)
1332
- return;
1333
- var up = ch.toUpperCase();
1334
- ch = ch === up ? ch.toLowerCase() : up;
1335
-
1336
- return module.exports[ch].getPos(
1337
- editor, range, count, LAST_SEARCH_MOTION.param, isSel, true
1338
- );
1155
+ },
1156
+ "n": {
1157
+ fn: function(editor, range, count, param) {
1158
+ var options = editor.getLastSearchOptions();
1159
+ options.backwards = false;
1160
+ options.start = null;
1161
+
1162
+ editor.selection.moveCursorRight();
1163
+ editor.selection.clearSelection();
1164
+ editor.findNext(options);
1165
+
1166
+ ensureScrollMargin(editor);
1167
+ var r = editor.selection.getRange();
1168
+ r.end.row = r.start.row;
1169
+ r.end.column = r.start.column;
1170
+ editor.selection.setSelectionRange(r, true);
1339
1171
  }
1340
- }),
1172
+ },
1173
+ "N": {
1174
+ fn: function(editor, range, count, param) {
1175
+ var options = editor.getLastSearchOptions();
1176
+ options.backwards = true;
1177
+ options.start = null;
1341
1178
 
1342
- "^": {
1343
- nav: function(editor) {
1344
- editor.navigateLineStart();
1345
- },
1346
- sel: function(editor) {
1347
- editor.selection.selectLineStart();
1179
+ editor.findPrevious(options);
1180
+ ensureScrollMargin(editor);
1181
+ var r = editor.selection.getRange();
1182
+ r.end.row = r.start.row;
1183
+ r.end.column = r.start.column;
1184
+ editor.selection.setSelectionRange(r, true);
1348
1185
  }
1349
1186
  },
1350
- "$": {
1351
- nav: function(editor) {
1352
- editor.navigateLineEnd();
1187
+ "v": {
1188
+ fn: function(editor, range, count, param) {
1189
+ editor.selection.selectRight();
1190
+ util.visualMode(editor, false);
1353
1191
  },
1354
- sel: function(editor) {
1355
- editor.selection.selectLineEnd();
1356
- }
1192
+ acceptsMotion: true
1357
1193
  },
1358
- "0": new Motion(function(ed) {
1359
- return {row: ed.selection.lead.row, column: 0};
1360
- }),
1361
- "G": {
1362
- nav: function(editor, range, count, param) {
1363
- if (!count && count !== 0) { // Stupid JS
1364
- count = editor.session.getLength();
1365
- }
1366
- editor.gotoLine(count);
1194
+ "V": {
1195
+ fn: function(editor, range, count, param) {
1196
+ var row = editor.getCursorPosition().row;
1197
+ editor.selection.moveTo(row, 0);
1198
+ editor.selection.selectLineEnd();
1199
+ editor.selection.visualLineStart = row;
1200
+
1201
+ util.visualMode(editor, true);
1367
1202
  },
1368
- sel: function(editor, range, count, param) {
1369
- if (!count && count !== 0) { // Stupid JS
1370
- count = editor.session.getLength();
1371
- }
1372
- editor.selection.selectTo(count, 0);
1203
+ acceptsMotion: true
1204
+ },
1205
+ "Y": {
1206
+ fn: function(editor, range, count, param) {
1207
+ util.copyLine(editor);
1373
1208
  }
1374
1209
  },
1375
- "g": {
1376
- param: true,
1377
- nav: function(editor, range, count, param) {
1378
- switch(param) {
1379
- case "m":
1380
- console.log("Middle line");
1381
- break;
1382
- case "e":
1383
- console.log("End of prev word");
1384
- break;
1385
- case "g":
1386
- editor.gotoLine(count || 0);
1387
- case "u":
1388
- editor.gotoLine(count || 0);
1389
- case "U":
1390
- editor.gotoLine(count || 0);
1210
+ "p": {
1211
+ fn: function(editor, range, count, param) {
1212
+ var defaultReg = registers._default;
1213
+
1214
+ editor.setOverwrite(false);
1215
+ if (defaultReg.isLine) {
1216
+ var pos = editor.getCursorPosition();
1217
+ pos.column = editor.session.getLine(pos.row).length;
1218
+ var text = lang.stringRepeat("\n" + defaultReg.text, count || 1);
1219
+ editor.session.insert(pos, text);
1220
+ editor.moveCursorTo(pos.row + 1, 0);
1391
1221
  }
1392
- },
1393
- sel: function(editor, range, count, param) {
1394
- switch(param) {
1395
- case "m":
1396
- console.log("Middle line");
1397
- break;
1398
- case "e":
1399
- console.log("End of prev word");
1400
- break;
1401
- case "g":
1402
- editor.selection.selectTo(count || 0, 0);
1222
+ else {
1223
+ editor.navigateRight();
1224
+ editor.insert(lang.stringRepeat(defaultReg.text, count || 1));
1225
+ editor.navigateLeft();
1403
1226
  }
1227
+ editor.setOverwrite(true);
1228
+ editor.selection.clearSelection();
1404
1229
  }
1405
1230
  },
1406
- "o": {
1407
- nav: function(editor, range, count, param) {
1408
- count = count || 1;
1409
- var content = "";
1410
- while (0 < count--)
1411
- content += "\n";
1231
+ "P": {
1232
+ fn: function(editor, range, count, param) {
1233
+ var defaultReg = registers._default;
1234
+ editor.setOverwrite(false);
1412
1235
 
1413
- if (content.length) {
1414
- editor.navigateLineEnd()
1415
- editor.insert(content);
1416
- util.insertMode(editor);
1236
+ if (defaultReg.isLine) {
1237
+ var pos = editor.getCursorPosition();
1238
+ pos.column = 0;
1239
+ var text = lang.stringRepeat(defaultReg.text + "\n", count || 1);
1240
+ editor.session.insert(pos, text);
1241
+ editor.moveCursorToPosition(pos);
1242
+ }
1243
+ else {
1244
+ editor.insert(lang.stringRepeat(defaultReg.text, count || 1));
1417
1245
  }
1246
+ editor.setOverwrite(true);
1247
+ editor.selection.clearSelection();
1418
1248
  }
1419
1249
  },
1420
- "O": {
1421
- nav: function(editor, range, count, param) {
1422
- var row = editor.getCursorPosition().row;
1423
- count = count || 1;
1424
- var content = "";
1425
- while (0 < count--)
1426
- content += "\n";
1250
+ "J": {
1251
+ fn: function(editor, range, count, param) {
1252
+ var session = editor.session;
1253
+ range = editor.getSelectionRange();
1254
+ var pos = {row: range.start.row, column: range.start.column};
1255
+ count = count || range.end.row - range.start.row;
1256
+ var maxRow = Math.min(pos.row + (count || 1), session.getLength() - 1);
1427
1257
 
1428
- if (content.length) {
1429
- if(row > 0) {
1430
- editor.navigateUp();
1431
- editor.navigateLineEnd()
1432
- editor.insert(content);
1433
- } else {
1434
- editor.session.insert({row: 0, column: 0}, content);
1435
- editor.navigateUp();
1436
- }
1437
- util.insertMode(editor);
1258
+ range.start.column = session.getLine(pos.row).length;
1259
+ range.end.column = session.getLine(maxRow).length;
1260
+ range.end.row = maxRow;
1261
+
1262
+ var text = "";
1263
+ for (var i = pos.row; i < maxRow; i++) {
1264
+ var nextLine = session.getLine(i + 1);
1265
+ text += " " + /^\s*(.*)$/.exec(nextLine)[1] || "";
1438
1266
  }
1267
+
1268
+ session.replace(range, text);
1269
+ editor.moveCursorTo(pos.row, pos.column);
1439
1270
  }
1440
1271
  },
1441
- "%": new Motion(function(editor){
1442
- var brRe = /[\[\]{}()]/g;
1443
- var cursor = editor.getCursorPosition();
1444
- var ch = editor.session.getLine(cursor.row)[cursor.column];
1445
- if (!brRe.test(ch)) {
1446
- var range = find(editor, brRe);
1447
- if (!range)
1448
- return;
1449
- cursor = range.start;
1450
- }
1451
- var match = editor.session.findMatchingBracket({
1452
- row: cursor.row,
1453
- column: cursor.column + 1
1454
- });
1455
-
1456
- return match;
1457
- }),
1458
- "{": new Motion(function(ed) {
1459
- var session = ed.session;
1460
- var row = session.selection.lead.row;
1461
- while(row > 0 && !/\S/.test(session.getLine(row)))
1462
- row--;
1463
- while(/\S/.test(session.getLine(row)))
1464
- row--;
1465
- return {column: 0, row: row};
1466
- }),
1467
- "}": new Motion(function(ed) {
1468
- var session = ed.session;
1469
- var l = session.getLength();
1470
- var row = session.selection.lead.row;
1471
- while(row < l && !/\S/.test(session.getLine(row)))
1472
- row++;
1473
- while(/\S/.test(session.getLine(row)))
1474
- row++;
1475
- return {column: 0, row: row};
1476
- }),
1477
- "ctrl-d": {
1478
- nav: function(editor, range, count, param) {
1272
+ "u": {
1273
+ fn: function(editor, range, count, param) {
1274
+ count = parseInt(count || 1, 10);
1275
+ for (var i = 0; i < count; i++) {
1276
+ editor.undo();
1277
+ }
1479
1278
  editor.selection.clearSelection();
1480
- keepScrollPosition(editor, editor.gotoPageDown);
1481
- },
1482
- sel: function(editor, range, count, param) {
1483
- keepScrollPosition(editor, editor.selectPageDown);
1484
1279
  }
1485
1280
  },
1486
- "ctrl-u": {
1487
- nav: function(editor, range, count, param) {
1281
+ "ctrl-r": {
1282
+ fn: function(editor, range, count, param) {
1283
+ count = parseInt(count || 1, 10);
1284
+ for (var i = 0; i < count; i++) {
1285
+ editor.redo();
1286
+ }
1488
1287
  editor.selection.clearSelection();
1489
- keepScrollPosition(editor, editor.gotoPageUp);
1490
- },
1491
- sel: function(editor, range, count, param) {
1492
- keepScrollPosition(editor, editor.selectPageUp);
1493
1288
  }
1494
1289
  },
1495
- "`": new Motion({
1496
- param: true,
1497
- handlesCount: true,
1498
- getPos: function(editor, range, count, param, isSel) {
1499
- var s = editor.session;
1500
- var marker = s.vimMarkers && s.vimMarkers[param];
1501
- if (marker) {
1502
- return marker.getPosition();
1503
- }
1290
+ ":": {
1291
+ fn: function(editor, range, count, param) {
1292
+ var val = ":";
1293
+ if (count > 1)
1294
+ val = ".,.+" + count + val;
1295
+ if (editor.showCommandLine)
1296
+ editor.showCommandLine(val);
1504
1297
  }
1505
- }),
1506
- "'": new Motion({
1507
- param: true,
1508
- handlesCount: true,
1509
- getPos: function(editor, range, count, param, isSel) {
1510
- var s = editor.session;
1511
- var marker = s.vimMarkers && s.vimMarkers[param];
1512
- if (marker) {
1513
- var pos = marker.getPosition();
1514
- var line = editor.session.getLine(pos.row);
1515
- pos.column = line.search(/\S/);
1516
- if (pos.column == -1)
1517
- pos.column = line.length;
1518
- return pos;
1298
+ },
1299
+ "/": {
1300
+ fn: function(editor, range, count, param) {
1301
+ if (editor.showCommandLine)
1302
+ editor.showCommandLine("/");
1303
+ }
1304
+ },
1305
+ "?": {
1306
+ fn: function(editor, range, count, param) {
1307
+ if (editor.showCommandLine)
1308
+ editor.showCommandLine("?");
1309
+ }
1310
+ },
1311
+ ".": {
1312
+ fn: function(editor, range, count, param) {
1313
+ util.onInsertReplaySequence = inputBuffer.lastInsertCommands;
1314
+ var previous = inputBuffer.previous;
1315
+ if (previous) // If there is a previous action
1316
+ inputBuffer.exec(editor, previous.action, previous.param);
1317
+ }
1318
+ },
1319
+ "ctrl-x": {
1320
+ fn: function(editor, range, count, param) {
1321
+ editor.modifyNumber(-(count || 1));
1322
+ }
1323
+ },
1324
+ "ctrl-a": {
1325
+ fn: function(editor, range, count, param) {
1326
+ editor.modifyNumber(count || 1);
1327
+ }
1328
+ }
1329
+ };
1330
+
1331
+ var inputBuffer = exports.inputBuffer = {
1332
+ accepting: [NUMBER, OPERATOR, MOTION, ACTION],
1333
+ currentCmd: null,
1334
+ currentCount: "",
1335
+ pendingCount: "",
1336
+ status: "",
1337
+ operator: null,
1338
+ motion: null,
1339
+
1340
+ lastInsertCommands: [],
1341
+
1342
+ push: function(editor, ch, keyId) {
1343
+ var status = this.status;
1344
+ var isKeyHandled = true;
1345
+ this.idle = false;
1346
+ var wObj = this.waitingForParam;
1347
+ if (/^numpad\d+$/i.test(ch))
1348
+ ch = ch.substr(6);
1349
+
1350
+ if (wObj) {
1351
+ this.exec(editor, wObj, ch);
1352
+ }
1353
+ else if (!(ch === "0" && !this.currentCount.length) &&
1354
+ (/^\d+$/.test(ch) && this.isAccepting(NUMBER))) {
1355
+ this.currentCount += ch;
1356
+ this.currentCmd = NUMBER;
1357
+ this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
1358
+ }
1359
+ else if (!this.operator && this.isAccepting(OPERATOR) && operators[ch]) {
1360
+ this.operator = {
1361
+ ch: ch,
1362
+ count: this.getCount()
1363
+ };
1364
+ this.currentCmd = OPERATOR;
1365
+ this.accepting = [NUMBER, MOTION, ACTION];
1366
+ this.exec(editor, { operator: this.operator });
1367
+ }
1368
+ else if (motions[ch] && this.isAccepting(MOTION)) {
1369
+ this.currentCmd = MOTION;
1370
+
1371
+ var ctx = {
1372
+ operator: this.operator,
1373
+ motion: {
1374
+ ch: ch,
1375
+ count: this.getCount()
1376
+ }
1377
+ };
1378
+
1379
+ if (motions[ch].param)
1380
+ this.waitForParam(ctx);
1381
+ else
1382
+ this.exec(editor, ctx);
1383
+ }
1384
+ else if (alias[ch] && this.isAccepting(MOTION)) {
1385
+ alias[ch].operator.count = this.getCount();
1386
+ this.exec(editor, alias[ch]);
1387
+ }
1388
+ else if (actions[ch] && this.isAccepting(ACTION)) {
1389
+ var actionObj = {
1390
+ action: {
1391
+ fn: actions[ch].fn,
1392
+ count: this.getCount()
1393
+ }
1394
+ };
1395
+
1396
+ if (actions[ch].param) {
1397
+ this.waitForParam(actionObj);
1398
+ }
1399
+ else {
1400
+ this.exec(editor, actionObj);
1519
1401
  }
1402
+
1403
+ if (actions[ch].acceptsMotion)
1404
+ this.idle = false;
1520
1405
  }
1521
- })
1522
- };
1406
+ else if (this.operator) {
1407
+ this.operator.count = this.getCount();
1408
+ this.exec(editor, { operator: this.operator }, ch);
1409
+ }
1410
+ else {
1411
+ isKeyHandled = ch.length == 1;
1412
+ this.reset();
1413
+ }
1414
+
1415
+ if (this.waitingForParam || this.motion || this.operator) {
1416
+ this.status += ch;
1417
+ } else if (this.currentCount) {
1418
+ this.status = this.currentCount;
1419
+ } else if (this.status) {
1420
+ this.status = "";
1421
+ }
1422
+ if (this.status != status)
1423
+ editor._emit("changeStatus");
1424
+ return isKeyHandled;
1425
+ },
1523
1426
 
1524
- module.exports.backspace = module.exports.left = module.exports.h;
1525
- module.exports.space = module.exports['return'] = module.exports.right = module.exports.l;
1526
- module.exports.up = module.exports.k;
1527
- module.exports.down = module.exports.j;
1528
- module.exports.pagedown = module.exports["ctrl-d"];
1529
- module.exports.pageup = module.exports["ctrl-u"];
1427
+ waitForParam: function(cmd) {
1428
+ this.waitingForParam = cmd;
1429
+ },
1530
1430
 
1531
- });
1532
-
1533
- define('ace/keyboard/vim/maps/operators', ['require', 'exports', 'module' , 'ace/keyboard/vim/maps/util', 'ace/keyboard/vim/registers'], function(require, exports, module) {
1431
+ getCount: function() {
1432
+ var count = this.currentCount || this.pendingCount;
1433
+ this.currentCount = "";
1434
+ this.pendingCount = count;
1435
+ return count && parseInt(count, 10);
1436
+ },
1534
1437
 
1438
+ exec: function(editor, action, param) {
1439
+ var m = action.motion;
1440
+ var o = action.operator;
1441
+ var a = action.action;
1535
1442
 
1443
+ if (!param)
1444
+ param = action.param;
1536
1445
 
1537
- var util = require("./util");
1538
- var registers = require("../registers");
1446
+ if (o) {
1447
+ this.previous = {
1448
+ action: action,
1449
+ param: param
1450
+ };
1451
+ }
1539
1452
 
1540
- module.exports = {
1541
- "d": {
1542
- selFn: function(editor, range, count, param) {
1543
- registers._default.text = editor.getCopyText();
1544
- registers._default.isLine = util.onVisualLineMode;
1545
- if(util.onVisualLineMode)
1546
- editor.removeLines();
1547
- else
1548
- editor.session.remove(range);
1549
- util.normalMode(editor);
1550
- },
1551
- fn: function(editor, range, count, param) {
1552
- count = count || 1;
1553
- switch (param) {
1554
- case "d":
1555
- registers._default.text = "";
1556
- registers._default.isLine = true;
1557
- for (var i = 0; i < count; i++) {
1558
- editor.selection.selectLine();
1559
- registers._default.text += editor.getCopyText();
1560
- var selRange = editor.getSelectionRange();
1561
- if (!selRange.isMultiLine()) {
1562
- var row = selRange.start.row - 1;
1563
- var col = editor.session.getLine(row).length
1564
- selRange.setStart(row, col);
1565
- editor.session.remove(selRange);
1566
- editor.selection.clearSelection();
1567
- break;
1568
- }
1569
- editor.session.remove(selRange);
1570
- editor.selection.clearSelection();
1571
- }
1572
- registers._default.text = registers._default.text.replace(/\n$/, "");
1573
- break;
1574
- default:
1575
- if (range) {
1576
- editor.selection.setSelectionRange(range);
1577
- registers._default.text = editor.getCopyText();
1578
- registers._default.isLine = false;
1579
- editor.session.remove(range);
1580
- editor.selection.clearSelection();
1581
- }
1453
+ if (o && !editor.selection.isEmpty()) {
1454
+ if (operators[o.ch].selFn) {
1455
+ operators[o.ch].selFn(editor, editor.getSelectionRange(), o.count, param);
1456
+ this.reset();
1582
1457
  }
1458
+ return;
1583
1459
  }
1584
- },
1585
- "c": {
1586
- selFn: function(editor, range, count, param) {
1587
- editor.session.remove(range);
1588
- util.insertMode(editor);
1589
- },
1590
- fn: function(editor, range, count, param) {
1591
- count = count || 1;
1592
- switch (param) {
1593
- case "c":
1594
- for (var i = 0; i < count; i++) {
1595
- editor.removeLines();
1596
- util.insertMode(editor);
1597
- }
1460
+ else if (!m && !a && o && param) {
1461
+ operators[o.ch].fn(editor, null, o.count, param);
1462
+ this.reset();
1463
+ }
1464
+ else if (m) {
1465
+ var run = function(fn) {
1466
+ if (fn && typeof fn === "function") { // There should always be a motion
1467
+ if (m.count && !motionObj.handlesCount)
1468
+ repeat(fn, m.count, [editor, null, m.count, param]);
1469
+ else
1470
+ fn(editor, null, m.count, param);
1471
+ }
1472
+ };
1598
1473
 
1599
- break;
1600
- default:
1601
- if (range) {
1602
- editor.session.remove(range);
1603
- util.insertMode(editor);
1604
- }
1474
+ var motionObj = motions[m.ch];
1475
+ var selectable = motionObj.sel;
1476
+
1477
+ if (!o) {
1478
+ if ((util.onVisualMode || util.onVisualLineMode) && selectable)
1479
+ run(motionObj.sel);
1480
+ else
1481
+ run(motionObj.nav);
1605
1482
  }
1483
+ else if (selectable) {
1484
+ repeat(function() {
1485
+ run(motionObj.sel);
1486
+ operators[o.ch].fn(editor, editor.getSelectionRange(),
1487
+ o.count, motionObj.param ? motionObj : param);
1488
+ }, o.count || 1);
1489
+ }
1490
+ this.reset();
1491
+ }
1492
+ else if (a) {
1493
+ a.fn(editor, editor.getSelectionRange(), a.count, param);
1494
+ this.reset();
1606
1495
  }
1496
+ handleCursorMove(editor);
1607
1497
  },
1608
- "y": {
1609
- selFn: function(editor, range, count, param) {
1610
- registers._default.text = editor.getCopyText();
1611
- registers._default.isLine = util.onVisualLineMode;
1612
- editor.selection.clearSelection();
1613
- util.normalMode(editor);
1614
- },
1615
- fn: function(editor, range, count, param) {
1616
- count = count || 1;
1617
- switch (param) {
1618
- case "y":
1619
- var pos = editor.getCursorPosition();
1620
- editor.selection.selectLine();
1621
- for (var i = 0; i < count - 1; i++) {
1622
- editor.selection.moveCursorDown();
1623
- }
1624
- registers._default.text = editor.getCopyText().replace(/\n$/, "");
1625
- editor.selection.clearSelection();
1626
- registers._default.isLine = true;
1627
- editor.moveCursorToPosition(pos);
1628
- break;
1629
- default:
1630
- if (range) {
1631
- var pos = editor.getCursorPosition();
1632
- editor.selection.setSelectionRange(range);
1633
- registers._default.text = editor.getCopyText();
1634
- registers._default.isLine = false;
1635
- editor.selection.clearSelection();
1636
- editor.moveCursorTo(pos.row, pos.column);
1637
- }
1638
- }
1498
+
1499
+ isAccepting: function(type) {
1500
+ return this.accepting.indexOf(type) !== -1;
1501
+ },
1502
+
1503
+ reset: function() {
1504
+ this.operator = null;
1505
+ this.motion = null;
1506
+ this.currentCount = "";
1507
+ this.pendingCount = "";
1508
+ this.status = "";
1509
+ this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
1510
+ this.idle = true;
1511
+ this.waitingForParam = null;
1512
+ }
1513
+ };
1514
+
1515
+ function setPreviousCommand(fn) {
1516
+ inputBuffer.previous = { action: { action: { fn: fn } } };
1517
+ }
1518
+
1519
+ exports.coreCommands = {
1520
+ start: {
1521
+ exec: function start(editor) {
1522
+ util.insertMode(editor);
1523
+ setPreviousCommand(start);
1639
1524
  }
1640
1525
  },
1641
- ">": {
1642
- selFn: function(editor, range, count, param) {
1643
- count = count || 1;
1644
- for (var i = 0; i < count; i++) {
1645
- editor.indent();
1646
- }
1647
- util.normalMode(editor);
1648
- },
1649
- fn: function(editor, range, count, param) {
1650
- count = parseInt(count || 1, 10);
1651
- switch (param) {
1652
- case ">":
1653
- var pos = editor.getCursorPosition();
1654
- editor.selection.selectLine();
1655
- for (var i = 0; i < count - 1; i++) {
1656
- editor.selection.moveCursorDown();
1657
- }
1658
- editor.indent();
1659
- editor.selection.clearSelection();
1660
- editor.moveCursorToPosition(pos);
1661
- editor.navigateLineEnd();
1662
- editor.navigateLineStart();
1663
- break;
1664
- }
1526
+ startBeginning: {
1527
+ exec: function startBeginning(editor) {
1528
+ editor.navigateLineStart();
1529
+ util.insertMode(editor);
1530
+ setPreviousCommand(startBeginning);
1531
+ }
1532
+ },
1533
+ stop: {
1534
+ exec: function stop(editor) {
1535
+ inputBuffer.reset();
1536
+ util.onVisualMode = false;
1537
+ util.onVisualLineMode = false;
1538
+ inputBuffer.lastInsertCommands = util.normalMode(editor);
1665
1539
  }
1666
1540
  },
1667
- "<": {
1668
- selFn: function(editor, range, count, param) {
1669
- count = count || 1;
1670
- for (var i = 0; i < count; i++) {
1671
- editor.blockOutdent();
1541
+ append: {
1542
+ exec: function append(editor) {
1543
+ var pos = editor.getCursorPosition();
1544
+ var lineLen = editor.session.getLine(pos.row).length;
1545
+ if (lineLen)
1546
+ editor.navigateRight();
1547
+ util.insertMode(editor);
1548
+ setPreviousCommand(append);
1549
+ }
1550
+ },
1551
+ appendEnd: {
1552
+ exec: function appendEnd(editor) {
1553
+ editor.navigateLineEnd();
1554
+ util.insertMode(editor);
1555
+ setPreviousCommand(appendEnd);
1556
+ }
1557
+ }
1558
+ };
1559
+
1560
+ var handleCursorMove = exports.onCursorMove = function(editor, e) {
1561
+ if (util.currentMode === 'insert' || handleCursorMove.running)
1562
+ return;
1563
+ else if(!editor.selection.isEmpty()) {
1564
+ handleCursorMove.running = true;
1565
+ if (util.onVisualLineMode) {
1566
+ var originRow = editor.selection.visualLineStart;
1567
+ var cursorRow = editor.getCursorPosition().row;
1568
+ if(originRow <= cursorRow) {
1569
+ var endLine = editor.session.getLine(cursorRow);
1570
+ editor.selection.moveTo(originRow, 0);
1571
+ editor.selection.selectTo(cursorRow, endLine.length);
1572
+ } else {
1573
+ var endLine = editor.session.getLine(originRow);
1574
+ editor.selection.moveTo(originRow, endLine.length);
1575
+ editor.selection.selectTo(cursorRow, 0);
1672
1576
  }
1577
+ }
1578
+ handleCursorMove.running = false;
1579
+ return;
1580
+ }
1581
+ else {
1582
+ if (e && (util.onVisualLineMode || util.onVisualMode)) {
1583
+ editor.selection.clearSelection();
1673
1584
  util.normalMode(editor);
1674
- },
1675
- fn: function(editor, range, count, param) {
1676
- count = count || 1;
1677
- switch (param) {
1678
- case "<":
1679
- var pos = editor.getCursorPosition();
1680
- editor.selection.selectLine();
1681
- for (var i = 0; i < count - 1; i++) {
1682
- editor.selection.moveCursorDown();
1683
- }
1684
- editor.blockOutdent();
1685
- editor.selection.clearSelection();
1686
- editor.moveCursorToPosition(pos);
1687
- editor.navigateLineEnd();
1688
- editor.navigateLineStart();
1689
- break;
1690
- }
1691
1585
  }
1586
+
1587
+ handleCursorMove.running = true;
1588
+ var pos = editor.getCursorPosition();
1589
+ var lineLen = editor.session.getLine(pos.row).length;
1590
+
1591
+ if (lineLen && pos.column === lineLen)
1592
+ editor.navigateLeft();
1593
+ handleCursorMove.running = false;
1692
1594
  }
1693
1595
  };
1694
1596
  });
1695
-
1696
- "use strict"
1697
1597
 
1698
- define('ace/keyboard/vim/maps/aliases', ['require', 'exports', 'module' ], function(require, exports, module) {
1699
- module.exports = {
1700
- "x": {
1701
- operator: {
1702
- ch: "d",
1703
- count: 1
1704
- },
1705
- motion: {
1706
- ch: "l",
1707
- count: 1
1708
- }
1598
+ define("ace/keyboard/vim",["require","exports","module","ace/keyboard/vim/commands","ace/keyboard/vim/maps/util","ace/lib/useragent"], function(require, exports, module) {
1599
+ "use strict";
1600
+
1601
+ var cmds = require("./vim/commands");
1602
+ var coreCommands = cmds.coreCommands;
1603
+ var util = require("./vim/maps/util");
1604
+ var useragent = require("../lib/useragent");
1605
+
1606
+ var startCommands = {
1607
+ "i": {
1608
+ command: coreCommands.start
1709
1609
  },
1710
- "X": {
1711
- operator: {
1712
- ch: "d",
1713
- count: 1
1714
- },
1715
- motion: {
1716
- ch: "h",
1717
- count: 1
1718
- }
1610
+ "I": {
1611
+ command: coreCommands.startBeginning
1719
1612
  },
1720
- "D": {
1721
- operator: {
1722
- ch: "d",
1723
- count: 1
1724
- },
1725
- motion: {
1726
- ch: "$",
1727
- count: 1
1613
+ "a": {
1614
+ command: coreCommands.append
1615
+ },
1616
+ "A": {
1617
+ command: coreCommands.appendEnd
1618
+ },
1619
+ "ctrl-f": {
1620
+ command: "gotopagedown"
1621
+ },
1622
+ "ctrl-b": {
1623
+ command: "gotopageup"
1624
+ }
1625
+ };
1626
+
1627
+ exports.handler = {
1628
+ $id: "ace/keyboard/vim",
1629
+ handleMacRepeat: function(data, hashId, key) {
1630
+ if (hashId == -1) {
1631
+ data.inputChar = key;
1632
+ data.lastEvent = "input";
1633
+ } else if (data.inputChar && data.$lastHash == hashId && data.$lastKey == key) {
1634
+ if (data.lastEvent == "input") {
1635
+ data.lastEvent = "input1";
1636
+ } else if (data.lastEvent == "input1") {
1637
+ return true;
1638
+ }
1639
+ } else {
1640
+ data.$lastHash = hashId;
1641
+ data.$lastKey = key;
1642
+ data.lastEvent = "keypress";
1728
1643
  }
1729
1644
  },
1730
- "C": {
1731
- operator: {
1732
- ch: "c",
1733
- count: 1
1734
- },
1735
- motion: {
1736
- ch: "$",
1737
- count: 1
1645
+ updateMacCompositionHandlers: function(editor, enable) {
1646
+ var onCompositionUpdateOverride = function(text) {
1647
+ if (util.currentMode !== "insert") {
1648
+ var el = this.textInput.getElement();
1649
+ el.blur();
1650
+ el.focus();
1651
+ el.value = text;
1652
+ } else {
1653
+ this.onCompositionUpdateOrig(text);
1654
+ }
1655
+ };
1656
+ var onCompositionStartOverride = function(text) {
1657
+ if (util.currentMode === "insert") {
1658
+ this.onCompositionStartOrig(text);
1659
+ }
1660
+ };
1661
+ if (enable) {
1662
+ if (!editor.onCompositionUpdateOrig) {
1663
+ editor.onCompositionUpdateOrig = editor.onCompositionUpdate;
1664
+ editor.onCompositionUpdate = onCompositionUpdateOverride;
1665
+ editor.onCompositionStartOrig = editor.onCompositionStart;
1666
+ editor.onCompositionStart = onCompositionStartOverride;
1667
+ }
1668
+ } else {
1669
+ if (editor.onCompositionUpdateOrig) {
1670
+ editor.onCompositionUpdate = editor.onCompositionUpdateOrig;
1671
+ editor.onCompositionUpdateOrig = null;
1672
+ editor.onCompositionStart = editor.onCompositionStartOrig;
1673
+ editor.onCompositionStartOrig = null;
1674
+ }
1738
1675
  }
1739
1676
  },
1740
- "s": {
1741
- operator: {
1742
- ch: "c",
1743
- count: 1
1744
- },
1745
- motion: {
1746
- ch: "l",
1747
- count: 1
1677
+
1678
+ handleKeyboard: function(data, hashId, key, keyCode, e) {
1679
+ if (hashId !== 0 && (!key || keyCode == -1))
1680
+ return null;
1681
+
1682
+ var editor = data.editor;
1683
+ var vimState = data.vimState || "start";
1684
+
1685
+ if (hashId == 1)
1686
+ key = "ctrl-" + key;
1687
+ if (key == "ctrl-c") {
1688
+ if (!useragent.isMac && editor.getCopyText()) {
1689
+ editor.once("copy", function() {
1690
+ if (vimState == "start")
1691
+ coreCommands.stop.exec(editor);
1692
+ else
1693
+ editor.selection.clearSelection();
1694
+ });
1695
+ return {command: "null", passEvent: true};
1696
+ }
1697
+ return {command: coreCommands.stop};
1698
+ } else if ((key == "esc" && hashId === 0) || key == "ctrl-[") {
1699
+ return {command: coreCommands.stop};
1700
+ } else if (vimState == "start") {
1701
+ if (useragent.isMac && this.handleMacRepeat(data, hashId, key)) {
1702
+ hashId = -1;
1703
+ key = data.inputChar;
1704
+ }
1705
+
1706
+ if (hashId == -1 || hashId == 1 || hashId === 0 && key.length > 1) {
1707
+ if (cmds.inputBuffer.idle && startCommands[key])
1708
+ return startCommands[key];
1709
+ var isHandled = cmds.inputBuffer.push(editor, key);
1710
+ if (!isHandled && hashId !== -1)
1711
+ return;
1712
+ return {command: "null", passEvent: !isHandled};
1713
+ } else if (key == "esc" && hashId === 0) {
1714
+ return {command: coreCommands.stop};
1715
+ }
1716
+ else if (hashId === 0 || hashId == 4) {
1717
+ return {command: "null", passEvent: true};
1718
+ }
1719
+ } else {
1720
+ if (key == "ctrl-w") {
1721
+ return {command: "removewordleft"};
1722
+ }
1748
1723
  }
1749
1724
  },
1750
- "S": {
1751
- operator: {
1752
- ch: "c",
1753
- count: 1
1754
- },
1755
- param: "c"
1725
+
1726
+ attach: function(editor) {
1727
+ editor.on("click", exports.onCursorMove);
1728
+ if (util.currentMode !== "insert")
1729
+ cmds.coreCommands.stop.exec(editor);
1730
+ editor.$vimModeHandler = this;
1731
+
1732
+ this.updateMacCompositionHandlers(editor, true);
1733
+ },
1734
+
1735
+ detach: function(editor) {
1736
+ editor.removeListener("click", exports.onCursorMove);
1737
+ util.noMode(editor);
1738
+ util.currentMode = "normal";
1739
+ this.updateMacCompositionHandlers(editor, false);
1740
+ },
1741
+
1742
+ actions: cmds.actions,
1743
+ getStatusText: function() {
1744
+ if (util.currentMode == "insert")
1745
+ return "INSERT";
1746
+ if (util.onVisualMode)
1747
+ return (util.onVisualLineMode ? "VISUAL LINE " : "VISUAL ") + cmds.inputBuffer.status;
1748
+ return cmds.inputBuffer.status;
1756
1749
  }
1757
1750
  };
1758
- });
1759
1751
 
1752
+
1753
+ exports.onCursorMove = function(e) {
1754
+ cmds.onCursorMove(e.editor, e);
1755
+ exports.onCursorMove.scheduled = false;
1756
+ };
1757
+
1758
+ });