locomotivecms 4.1.1 → 4.2.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (301) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +4 -3
  4. data/Rakefile +4 -0
  5. data/app/api/locomotive/api.rb +1 -1
  6. data/app/assets/config/locomotive_manifest.js +2 -0
  7. data/app/assets/javascripts/locomotive.js +2 -2
  8. data/app/assets/stylesheets/locomotive/account.scss +0 -1
  9. data/app/assets/stylesheets/locomotive/application.scss +0 -1
  10. data/app/assets/stylesheets/locomotive/live_editing_error.scss +0 -1
  11. data/app/assets/stylesheets/locomotive/live_editing_iframe.scss +0 -1
  12. data/app/controllers/locomotive/base_controller.rb +1 -1
  13. data/app/controllers/locomotive/concerns/authorization_controller.rb +1 -1
  14. data/app/controllers/locomotive/concerns/redirect_to_main_host_controller.rb +1 -1
  15. data/app/controllers/locomotive/concerns/site_dispatcher_controller.rb +1 -1
  16. data/app/controllers/locomotive/errors_controller.rb +1 -1
  17. data/app/controllers/locomotive/my_account_controller.rb +1 -1
  18. data/app/controllers/locomotive/passwords_controller.rb +3 -1
  19. data/app/controllers/locomotive/registrations_controller.rb +3 -1
  20. data/app/controllers/locomotive/sessions_controller.rb +3 -1
  21. data/app/controllers/locomotive/sites_controller.rb +1 -1
  22. data/app/helpers/locomotive/base_helper.rb +2 -2
  23. data/app/helpers/locomotive/custom_fields_helper.rb +2 -2
  24. data/app/helpers/locomotive/shared/activities_helper.rb +1 -1
  25. data/app/inputs/locomotive/api_key_input.rb +1 -1
  26. data/app/mailers/locomotive/notifications.rb +1 -1
  27. data/app/models/locomotive/account.rb +1 -1
  28. data/app/models/locomotive/concerns/account/api_key.rb +1 -1
  29. data/app/models/locomotive/concerns/content_entry/csv.rb +1 -1
  30. data/app/models/locomotive/concerns/content_entry/slug.rb +5 -5
  31. data/app/models/locomotive/concerns/content_type/entry_template.rb +3 -3
  32. data/app/models/locomotive/concerns/page/templatized.rb +1 -1
  33. data/app/models/locomotive/concerns/shared/json_attribute.rb +21 -2
  34. data/app/models/locomotive/concerns/site/routes.rb +1 -1
  35. data/app/models/locomotive/content_entry.rb +2 -2
  36. data/app/models/locomotive/page.rb +3 -3
  37. data/app/models/locomotive/section.rb +1 -1
  38. data/app/models/locomotive/snippet.rb +1 -1
  39. data/app/models/locomotive/translation.rb +1 -1
  40. data/app/services/locomotive/content_entry_import_service.rb +1 -1
  41. data/app/services/locomotive/content_entry_service.rb +2 -2
  42. data/app/services/locomotive/content_type_service.rb +13 -3
  43. data/app/services/locomotive/custom_field_service.rb +2 -2
  44. data/app/services/locomotive/editor_service.rb +1 -1
  45. data/app/uploaders/locomotive/base_uploader.rb +0 -10
  46. data/app/views/locomotive/dashboard/_activity.html.slim +1 -1
  47. data/app/views/locomotive/page_content/_edit.json.jbuilder +50 -0
  48. data/app/views/locomotive/page_content/edit.html.erb +1 -1
  49. data/app/views/locomotive/page_content/edit.json.jbuilder +52 -50
  50. data/config/initializers/devise.rb +5 -2
  51. data/lib/generators/locomotive/install/templates/locomotive.rb +0 -5
  52. data/lib/locomotive/action_controller/responder.rb +1 -1
  53. data/lib/locomotive/configuration.rb +2 -2
  54. data/lib/locomotive/dependencies.rb +0 -2
  55. data/lib/locomotive/engine.rb +14 -2
  56. data/lib/locomotive/mongoid/patches.rb +25 -65
  57. data/lib/locomotive/steam/services/api_entry_submission_service.rb +1 -0
  58. data/lib/locomotive/version.rb +1 -1
  59. data/vendor/assets/javascripts/locomotive/codemirror/addons/comment/comment.js +203 -0
  60. data/vendor/assets/javascripts/locomotive/codemirror/addons/comment/continuecomment.js +85 -0
  61. data/vendor/assets/javascripts/locomotive/codemirror/addons/dialog/dialog.js +157 -0
  62. data/vendor/assets/javascripts/locomotive/codemirror/addons/display/autorefresh.js +47 -0
  63. data/vendor/assets/javascripts/locomotive/codemirror/addons/display/fullscreen.js +41 -0
  64. data/vendor/assets/javascripts/locomotive/codemirror/addons/display/panel.js +112 -0
  65. data/vendor/assets/javascripts/locomotive/codemirror/addons/display/placeholder.js +62 -0
  66. data/vendor/assets/javascripts/locomotive/codemirror/addons/display/rulers.js +51 -0
  67. data/vendor/assets/javascripts/locomotive/codemirror/addons/edit/closebrackets.js +195 -0
  68. data/vendor/assets/javascripts/locomotive/codemirror/addons/edit/closetag.js +169 -0
  69. data/vendor/assets/javascripts/locomotive/codemirror/addons/edit/continuelist.js +51 -0
  70. data/vendor/assets/javascripts/locomotive/codemirror/addons/edit/matchbrackets.js +120 -0
  71. data/vendor/assets/javascripts/locomotive/codemirror/addons/edit/matchtags.js +66 -0
  72. data/vendor/assets/javascripts/locomotive/codemirror/addons/edit/trailingspace.js +27 -0
  73. data/vendor/assets/javascripts/locomotive/codemirror/addons/fold/brace-fold.js +105 -0
  74. data/vendor/assets/javascripts/locomotive/codemirror/addons/fold/comment-fold.js +59 -0
  75. data/vendor/assets/javascripts/locomotive/codemirror/addons/fold/foldcode.js +150 -0
  76. data/vendor/assets/javascripts/locomotive/codemirror/addons/fold/foldgutter.js +146 -0
  77. data/vendor/assets/javascripts/locomotive/codemirror/addons/fold/indent-fold.js +44 -0
  78. data/vendor/assets/javascripts/locomotive/codemirror/addons/fold/markdown-fold.js +49 -0
  79. data/vendor/assets/javascripts/locomotive/codemirror/addons/fold/xml-fold.js +182 -0
  80. data/vendor/assets/javascripts/locomotive/codemirror/addons/hint/anyword-hint.js +41 -0
  81. data/vendor/assets/javascripts/locomotive/codemirror/addons/hint/css-hint.js +60 -0
  82. data/vendor/assets/javascripts/locomotive/codemirror/addons/hint/html-hint.js +348 -0
  83. data/vendor/assets/javascripts/locomotive/codemirror/addons/hint/javascript-hint.js +146 -0
  84. data/vendor/assets/javascripts/locomotive/codemirror/addons/hint/show-hint.js +437 -0
  85. data/vendor/assets/javascripts/locomotive/codemirror/addons/hint/sql-hint.js +271 -0
  86. data/vendor/assets/javascripts/locomotive/codemirror/addons/hint/xml-hint.js +110 -0
  87. data/vendor/assets/javascripts/locomotive/codemirror/addons/lint/coffeescript-lint.js +41 -0
  88. data/vendor/assets/javascripts/locomotive/codemirror/addons/lint/css-lint.js +35 -0
  89. data/vendor/assets/javascripts/locomotive/codemirror/addons/lint/html-lint.js +46 -0
  90. data/vendor/assets/javascripts/locomotive/codemirror/addons/lint/javascript-lint.js +136 -0
  91. data/vendor/assets/javascripts/locomotive/codemirror/addons/lint/json-lint.js +31 -0
  92. data/vendor/assets/javascripts/locomotive/codemirror/addons/lint/lint.js +239 -0
  93. data/vendor/assets/javascripts/locomotive/codemirror/addons/lint/yaml-lint.js +28 -0
  94. data/vendor/assets/javascripts/locomotive/codemirror/addons/merge/merge.js +773 -0
  95. data/vendor/assets/javascripts/locomotive/codemirror/addons/mode/loadmode.js +64 -0
  96. data/vendor/assets/javascripts/locomotive/codemirror/addons/mode/multiplex.js +123 -0
  97. data/vendor/assets/javascripts/locomotive/codemirror/addons/mode/overlay.js +85 -0
  98. data/vendor/assets/javascripts/locomotive/codemirror/addons/mode/simple.js +213 -0
  99. data/vendor/assets/javascripts/locomotive/codemirror/addons/runmode/colorize.js +40 -0
  100. data/vendor/assets/javascripts/locomotive/codemirror/addons/runmode/runmode-standalone.js +157 -0
  101. data/vendor/assets/javascripts/locomotive/codemirror/addons/runmode/runmode.js +72 -0
  102. data/vendor/assets/javascripts/locomotive/codemirror/addons/runmode/runmode.node.js +179 -0
  103. data/vendor/assets/javascripts/locomotive/codemirror/addons/scroll/annotatescrollbar.js +118 -0
  104. data/vendor/assets/javascripts/locomotive/codemirror/addons/scroll/scrollpastend.js +48 -0
  105. data/vendor/assets/javascripts/locomotive/codemirror/addons/scroll/simplescrollbars.js +152 -0
  106. data/vendor/assets/javascripts/locomotive/codemirror/addons/search/jump-to-line.js +49 -0
  107. data/vendor/assets/javascripts/locomotive/codemirror/addons/search/match-highlighter.js +146 -0
  108. data/vendor/assets/javascripts/locomotive/codemirror/addons/search/matchesonscrollbar.js +97 -0
  109. data/vendor/assets/javascripts/locomotive/codemirror/addons/search/search.js +249 -0
  110. data/vendor/assets/javascripts/locomotive/codemirror/addons/search/searchcursor.js +189 -0
  111. data/vendor/assets/javascripts/locomotive/codemirror/addons/selection/active-line.js +74 -0
  112. data/vendor/assets/javascripts/locomotive/codemirror/addons/selection/mark-selection.js +118 -0
  113. data/vendor/assets/javascripts/locomotive/codemirror/addons/selection/selection-pointer.js +98 -0
  114. data/vendor/assets/javascripts/locomotive/codemirror/addons/tern/tern.js +701 -0
  115. data/vendor/assets/javascripts/locomotive/codemirror/addons/tern/worker.js +44 -0
  116. data/vendor/assets/javascripts/locomotive/codemirror/addons/wrap/hardwrap.js +144 -0
  117. data/vendor/assets/javascripts/locomotive/codemirror/keymaps/emacs.js +412 -0
  118. data/vendor/assets/javascripts/locomotive/codemirror/keymaps/sublime.js +580 -0
  119. data/vendor/assets/javascripts/locomotive/codemirror/keymaps/vim.js +5065 -0
  120. data/vendor/assets/javascripts/locomotive/codemirror/modes/apl.js +174 -0
  121. data/vendor/assets/javascripts/locomotive/codemirror/modes/asciiarmor.js +73 -0
  122. data/vendor/assets/javascripts/locomotive/codemirror/modes/asn.1.js +204 -0
  123. data/vendor/assets/javascripts/locomotive/codemirror/modes/asterisk.js +196 -0
  124. data/vendor/assets/javascripts/locomotive/codemirror/modes/brainfuck.js +85 -0
  125. data/vendor/assets/javascripts/locomotive/codemirror/modes/clike.js +786 -0
  126. data/vendor/assets/javascripts/locomotive/codemirror/modes/clojure.js +306 -0
  127. data/vendor/assets/javascripts/locomotive/codemirror/modes/cmake.js +97 -0
  128. data/vendor/assets/javascripts/locomotive/codemirror/modes/cobol.js +255 -0
  129. data/vendor/assets/javascripts/locomotive/codemirror/modes/coffeescript.js +355 -0
  130. data/vendor/assets/javascripts/locomotive/codemirror/modes/commonlisp.js +123 -0
  131. data/vendor/assets/javascripts/locomotive/codemirror/modes/crystal.js +391 -0
  132. data/vendor/assets/javascripts/locomotive/codemirror/modes/css.js +825 -0
  133. data/vendor/assets/javascripts/locomotive/codemirror/modes/cypher.js +146 -0
  134. data/vendor/assets/javascripts/locomotive/codemirror/modes/d.js +218 -0
  135. data/vendor/assets/javascripts/locomotive/codemirror/modes/dart.js +157 -0
  136. data/vendor/assets/javascripts/locomotive/codemirror/modes/diff.js +47 -0
  137. data/vendor/assets/javascripts/locomotive/codemirror/modes/django.js +356 -0
  138. data/vendor/assets/javascripts/locomotive/codemirror/modes/dockerfile.js +79 -0
  139. data/vendor/assets/javascripts/locomotive/codemirror/modes/dtd.js +142 -0
  140. data/vendor/assets/javascripts/locomotive/codemirror/modes/dylan.js +344 -0
  141. data/vendor/assets/javascripts/locomotive/codemirror/modes/ebnf.js +195 -0
  142. data/vendor/assets/javascripts/locomotive/codemirror/modes/ecl.js +206 -0
  143. data/vendor/assets/javascripts/locomotive/codemirror/modes/eiffel.js +160 -0
  144. data/vendor/assets/javascripts/locomotive/codemirror/modes/elm.js +205 -0
  145. data/vendor/assets/javascripts/locomotive/codemirror/modes/erlang.js +618 -0
  146. data/vendor/assets/javascripts/locomotive/codemirror/modes/factor.js +83 -0
  147. data/vendor/assets/javascripts/locomotive/codemirror/modes/fcl.js +173 -0
  148. data/vendor/assets/javascripts/locomotive/codemirror/modes/forth.js +180 -0
  149. data/vendor/assets/javascripts/locomotive/codemirror/modes/fortran.js +188 -0
  150. data/vendor/assets/javascripts/locomotive/codemirror/modes/gas.js +345 -0
  151. data/vendor/assets/javascripts/locomotive/codemirror/modes/gfm.js +130 -0
  152. data/vendor/assets/javascripts/locomotive/codemirror/modes/gherkin.js +178 -0
  153. data/vendor/assets/javascripts/locomotive/codemirror/modes/go.js +185 -0
  154. data/vendor/assets/javascripts/locomotive/codemirror/modes/groovy.js +230 -0
  155. data/vendor/assets/javascripts/locomotive/codemirror/modes/haml.js +161 -0
  156. data/vendor/assets/javascripts/locomotive/codemirror/modes/handlebars.js +62 -0
  157. data/vendor/assets/javascripts/locomotive/codemirror/modes/haskell-literate.js +43 -0
  158. data/vendor/assets/javascripts/locomotive/codemirror/modes/haskell.js +267 -0
  159. data/vendor/assets/javascripts/locomotive/codemirror/modes/haxe.js +515 -0
  160. data/vendor/assets/javascripts/locomotive/codemirror/modes/htmlembedded.js +28 -0
  161. data/vendor/assets/javascripts/locomotive/codemirror/modes/htmlmixed.js +152 -0
  162. data/vendor/assets/javascripts/locomotive/codemirror/modes/http.js +113 -0
  163. data/vendor/assets/javascripts/locomotive/codemirror/modes/idl.js +290 -0
  164. data/vendor/assets/javascripts/locomotive/codemirror/modes/jade.js +590 -0
  165. data/vendor/assets/javascripts/locomotive/codemirror/modes/javascript.js +748 -0
  166. data/vendor/assets/javascripts/locomotive/codemirror/modes/jinja2.js +142 -0
  167. data/vendor/assets/javascripts/locomotive/codemirror/modes/jsx.js +147 -0
  168. data/vendor/assets/javascripts/locomotive/codemirror/modes/julia.js +392 -0
  169. data/vendor/assets/javascripts/locomotive/codemirror/modes/livescript.js +280 -0
  170. data/vendor/assets/javascripts/locomotive/codemirror/modes/lua.js +159 -0
  171. data/vendor/assets/javascripts/locomotive/codemirror/modes/markdown.js +797 -0
  172. data/vendor/assets/javascripts/locomotive/codemirror/modes/mathematica.js +176 -0
  173. data/vendor/assets/javascripts/locomotive/codemirror/modes/mbox.js +129 -0
  174. data/vendor/assets/javascripts/locomotive/codemirror/modes/mirc.js +193 -0
  175. data/vendor/assets/javascripts/locomotive/codemirror/modes/mllike.js +205 -0
  176. data/vendor/assets/javascripts/locomotive/codemirror/modes/modelica.js +245 -0
  177. data/vendor/assets/javascripts/locomotive/codemirror/modes/mscgen.js +169 -0
  178. data/vendor/assets/javascripts/locomotive/codemirror/modes/mumps.js +148 -0
  179. data/vendor/assets/javascripts/locomotive/codemirror/modes/nginx.js +178 -0
  180. data/vendor/assets/javascripts/locomotive/codemirror/modes/nsis.js +95 -0
  181. data/vendor/assets/javascripts/locomotive/codemirror/modes/ntriples.js +186 -0
  182. data/vendor/assets/javascripts/locomotive/codemirror/modes/octave.js +135 -0
  183. data/vendor/assets/javascripts/locomotive/codemirror/modes/oz.js +252 -0
  184. data/vendor/assets/javascripts/locomotive/codemirror/modes/pascal.js +109 -0
  185. data/vendor/assets/javascripts/locomotive/codemirror/modes/pegjs.js +114 -0
  186. data/vendor/assets/javascripts/locomotive/codemirror/modes/perl.js +837 -0
  187. data/vendor/assets/javascripts/locomotive/codemirror/modes/php.js +234 -0
  188. data/vendor/assets/javascripts/locomotive/codemirror/modes/pig.js +178 -0
  189. data/vendor/assets/javascripts/locomotive/codemirror/modes/powershell.js +396 -0
  190. data/vendor/assets/javascripts/locomotive/codemirror/modes/properties.js +78 -0
  191. data/vendor/assets/javascripts/locomotive/codemirror/modes/protobuf.js +68 -0
  192. data/vendor/assets/javascripts/locomotive/codemirror/modes/puppet.js +220 -0
  193. data/vendor/assets/javascripts/locomotive/codemirror/modes/python.js +340 -0
  194. data/vendor/assets/javascripts/locomotive/codemirror/modes/q.js +139 -0
  195. data/vendor/assets/javascripts/locomotive/codemirror/modes/r.js +164 -0
  196. data/vendor/assets/javascripts/locomotive/codemirror/modes/rpm.js +109 -0
  197. data/vendor/assets/javascripts/locomotive/codemirror/modes/rst.js +557 -0
  198. data/vendor/assets/javascripts/locomotive/codemirror/modes/ruby.js +285 -0
  199. data/vendor/assets/javascripts/locomotive/codemirror/modes/rust.js +71 -0
  200. data/vendor/assets/javascripts/locomotive/codemirror/modes/sas.js +315 -0
  201. data/vendor/assets/javascripts/locomotive/codemirror/modes/sass.js +414 -0
  202. data/vendor/assets/javascripts/locomotive/codemirror/modes/scheme.js +249 -0
  203. data/vendor/assets/javascripts/locomotive/codemirror/modes/shell.js +139 -0
  204. data/vendor/assets/javascripts/locomotive/codemirror/modes/sieve.js +193 -0
  205. data/vendor/assets/javascripts/locomotive/codemirror/modes/slim.js +575 -0
  206. data/vendor/assets/javascripts/locomotive/codemirror/modes/smalltalk.js +168 -0
  207. data/vendor/assets/javascripts/locomotive/codemirror/modes/smarty.js +225 -0
  208. data/vendor/assets/javascripts/locomotive/codemirror/modes/solr.js +104 -0
  209. data/vendor/assets/javascripts/locomotive/codemirror/modes/soy.js +199 -0
  210. data/vendor/assets/javascripts/locomotive/codemirror/modes/sparql.js +180 -0
  211. data/vendor/assets/javascripts/locomotive/codemirror/modes/spreadsheet.js +112 -0
  212. data/vendor/assets/javascripts/locomotive/codemirror/modes/sql.js +413 -0
  213. data/vendor/assets/javascripts/locomotive/codemirror/modes/stex.js +251 -0
  214. data/vendor/assets/javascripts/locomotive/codemirror/modes/stylus.js +769 -0
  215. data/vendor/assets/javascripts/locomotive/codemirror/modes/swift.js +202 -0
  216. data/vendor/assets/javascripts/locomotive/codemirror/modes/tcl.js +139 -0
  217. data/vendor/assets/javascripts/locomotive/codemirror/modes/textile.js +469 -0
  218. data/vendor/assets/javascripts/locomotive/codemirror/modes/tiddlywiki.js +308 -0
  219. data/vendor/assets/javascripts/locomotive/codemirror/modes/tiki.js +312 -0
  220. data/vendor/assets/javascripts/locomotive/codemirror/modes/toml.js +88 -0
  221. data/vendor/assets/javascripts/locomotive/codemirror/modes/tornado.js +68 -0
  222. data/vendor/assets/javascripts/locomotive/codemirror/modes/troff.js +84 -0
  223. data/vendor/assets/javascripts/locomotive/codemirror/modes/ttcn-cfg.js +214 -0
  224. data/vendor/assets/javascripts/locomotive/codemirror/modes/ttcn.js +283 -0
  225. data/vendor/assets/javascripts/locomotive/codemirror/modes/turtle.js +162 -0
  226. data/vendor/assets/javascripts/locomotive/codemirror/modes/twig.js +141 -0
  227. data/vendor/assets/javascripts/locomotive/codemirror/modes/vb.js +276 -0
  228. data/vendor/assets/javascripts/locomotive/codemirror/modes/vbscript.js +350 -0
  229. data/vendor/assets/javascripts/locomotive/codemirror/modes/velocity.js +201 -0
  230. data/vendor/assets/javascripts/locomotive/codemirror/modes/verilog.js +537 -0
  231. data/vendor/assets/javascripts/locomotive/codemirror/modes/vhdl.js +189 -0
  232. data/vendor/assets/javascripts/locomotive/codemirror/modes/vue.js +69 -0
  233. data/vendor/assets/javascripts/locomotive/codemirror/modes/webidl.js +195 -0
  234. data/vendor/assets/javascripts/locomotive/codemirror/modes/xml.js +394 -0
  235. data/vendor/assets/javascripts/locomotive/codemirror/modes/xquery.js +437 -0
  236. data/vendor/assets/javascripts/locomotive/codemirror/modes/yacas.js +204 -0
  237. data/vendor/assets/javascripts/locomotive/codemirror/modes/yaml-frontmatter.js +68 -0
  238. data/vendor/assets/javascripts/locomotive/codemirror/modes/yaml.js +117 -0
  239. data/vendor/assets/javascripts/locomotive/codemirror/modes/z80.js +116 -0
  240. data/vendor/assets/javascripts/locomotive/codemirror.js +8922 -0
  241. data/vendor/assets/javascripts/locomotive/select2.js +436 -175
  242. data/vendor/assets/javascripts/locomotive/wysihtml5x-toolbar.js +1346 -564
  243. data/vendor/assets/stylesheets/locomotive/codemirror/addons/dialog/dialog.css +32 -0
  244. data/vendor/assets/stylesheets/locomotive/codemirror/addons/display/fullscreen.css +6 -0
  245. data/vendor/assets/stylesheets/locomotive/codemirror/addons/fold/foldgutter.css +20 -0
  246. data/vendor/assets/stylesheets/locomotive/codemirror/addons/hint/show-hint.css +37 -0
  247. data/vendor/assets/stylesheets/locomotive/codemirror/addons/lint/lint.css +73 -0
  248. data/vendor/assets/stylesheets/locomotive/codemirror/addons/merge/merge.css +113 -0
  249. data/vendor/assets/stylesheets/locomotive/codemirror/addons/scroll/simplescrollbars.css +66 -0
  250. data/vendor/assets/stylesheets/locomotive/codemirror/addons/search/matchesonscrollbar.css +8 -0
  251. data/vendor/assets/stylesheets/locomotive/codemirror/addons/tern/tern.css +87 -0
  252. data/vendor/assets/stylesheets/locomotive/codemirror/modes/tiddlywiki.css +14 -0
  253. data/vendor/assets/stylesheets/locomotive/codemirror/modes/tiki.css +26 -0
  254. data/vendor/assets/stylesheets/locomotive/codemirror/themes/3024-day.css +41 -0
  255. data/vendor/assets/stylesheets/locomotive/codemirror/themes/3024-night.css +39 -0
  256. data/vendor/assets/stylesheets/locomotive/codemirror/themes/abcdef.css +32 -0
  257. data/vendor/assets/stylesheets/locomotive/codemirror/themes/ambiance-mobile.css +5 -0
  258. data/vendor/assets/stylesheets/locomotive/codemirror/themes/ambiance.css +74 -0
  259. data/vendor/assets/stylesheets/locomotive/codemirror/themes/base16-dark.css +38 -0
  260. data/vendor/assets/stylesheets/locomotive/codemirror/themes/base16-light.css +38 -0
  261. data/vendor/assets/stylesheets/locomotive/codemirror/themes/bespin.css +34 -0
  262. data/vendor/assets/stylesheets/locomotive/codemirror/themes/blackboard.css +32 -0
  263. data/vendor/assets/stylesheets/locomotive/codemirror/themes/cobalt.css +25 -0
  264. data/vendor/assets/stylesheets/locomotive/codemirror/themes/colorforth.css +33 -0
  265. data/vendor/assets/stylesheets/locomotive/codemirror/themes/dracula.css +41 -0
  266. data/vendor/assets/stylesheets/locomotive/codemirror/themes/eclipse.css +23 -0
  267. data/vendor/assets/stylesheets/locomotive/codemirror/themes/elegant.css +13 -0
  268. data/vendor/assets/stylesheets/locomotive/codemirror/themes/erlang-dark.css +34 -0
  269. data/vendor/assets/stylesheets/locomotive/codemirror/themes/hopscotch.css +34 -0
  270. data/vendor/assets/stylesheets/locomotive/codemirror/themes/icecoder.css +43 -0
  271. data/vendor/assets/stylesheets/locomotive/codemirror/themes/isotope.css +34 -0
  272. data/vendor/assets/stylesheets/locomotive/codemirror/themes/lesser-dark.css +47 -0
  273. data/vendor/assets/stylesheets/locomotive/codemirror/themes/liquibyte.css +95 -0
  274. data/vendor/assets/stylesheets/locomotive/codemirror/themes/material.css +53 -0
  275. data/vendor/assets/stylesheets/locomotive/codemirror/themes/mbo.css +37 -0
  276. data/vendor/assets/stylesheets/locomotive/codemirror/themes/mdn-like.css +46 -0
  277. data/vendor/assets/stylesheets/locomotive/codemirror/themes/midnight.css +45 -0
  278. data/vendor/assets/stylesheets/locomotive/codemirror/themes/monokai.css +36 -0
  279. data/vendor/assets/stylesheets/locomotive/codemirror/themes/neat.css +12 -0
  280. data/vendor/assets/stylesheets/locomotive/codemirror/themes/neo.css +43 -0
  281. data/vendor/assets/stylesheets/locomotive/codemirror/themes/night.css +27 -0
  282. data/vendor/assets/stylesheets/locomotive/codemirror/themes/paraiso-dark.css +38 -0
  283. data/vendor/assets/stylesheets/locomotive/codemirror/themes/paraiso-light.css +38 -0
  284. data/vendor/assets/stylesheets/locomotive/codemirror/themes/pastel-on-dark.css +53 -0
  285. data/vendor/assets/stylesheets/locomotive/codemirror/themes/railscasts.css +34 -0
  286. data/vendor/assets/stylesheets/locomotive/codemirror/themes/rubyblue.css +25 -0
  287. data/vendor/assets/stylesheets/locomotive/codemirror/themes/seti.css +44 -0
  288. data/vendor/assets/stylesheets/locomotive/codemirror/themes/solarized.css +169 -0
  289. data/vendor/assets/stylesheets/locomotive/codemirror/themes/the-matrix.css +30 -0
  290. data/vendor/assets/stylesheets/locomotive/codemirror/themes/tomorrow-night-bright.css +35 -0
  291. data/vendor/assets/stylesheets/locomotive/codemirror/themes/tomorrow-night-eighties.css +38 -0
  292. data/vendor/assets/stylesheets/locomotive/codemirror/themes/ttcn.css +64 -0
  293. data/vendor/assets/stylesheets/locomotive/codemirror/themes/twilight.css +32 -0
  294. data/vendor/assets/stylesheets/locomotive/codemirror/themes/vibrant-ink.css +34 -0
  295. data/vendor/assets/stylesheets/locomotive/codemirror/themes/xq-dark.css +53 -0
  296. data/vendor/assets/stylesheets/locomotive/codemirror/themes/xq-light.css +43 -0
  297. data/vendor/assets/stylesheets/locomotive/codemirror/themes/yeti.css +44 -0
  298. data/vendor/assets/stylesheets/locomotive/codemirror/themes/zenburn.css +37 -0
  299. data/vendor/assets/stylesheets/locomotive/codemirror.css +347 -0
  300. data/vendor/assets/stylesheets/locomotive/select2.css +3 -6
  301. metadata +349 -128
@@ -0,0 +1,580 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ // A rough approximation of Sublime Text's keybindings
5
+ // Depends on addon/search/searchcursor.js and optionally addon/dialog/dialogs.js
6
+
7
+ (function(mod) {
8
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
9
+ mod(require("../lib/codemirror"), require("../addon/search/searchcursor"), require("../addon/edit/matchbrackets"));
10
+ else if (typeof define == "function" && define.amd) // AMD
11
+ define(["../lib/codemirror", "../addon/search/searchcursor", "../addon/edit/matchbrackets"], mod);
12
+ else // Plain browser env
13
+ mod(CodeMirror);
14
+ })(function(CodeMirror) {
15
+ "use strict";
16
+
17
+ var map = CodeMirror.keyMap.sublime = {fallthrough: "default"};
18
+ var cmds = CodeMirror.commands;
19
+ var Pos = CodeMirror.Pos;
20
+ var mac = CodeMirror.keyMap["default"] == CodeMirror.keyMap.macDefault;
21
+ var ctrl = mac ? "Cmd-" : "Ctrl-";
22
+
23
+ // This is not exactly Sublime's algorithm. I couldn't make heads or tails of that.
24
+ function findPosSubword(doc, start, dir) {
25
+ if (dir < 0 && start.ch == 0) return doc.clipPos(Pos(start.line - 1));
26
+ var line = doc.getLine(start.line);
27
+ if (dir > 0 && start.ch >= line.length) return doc.clipPos(Pos(start.line + 1, 0));
28
+ var state = "start", type;
29
+ for (var pos = start.ch, e = dir < 0 ? 0 : line.length, i = 0; pos != e; pos += dir, i++) {
30
+ var next = line.charAt(dir < 0 ? pos - 1 : pos);
31
+ var cat = next != "_" && CodeMirror.isWordChar(next) ? "w" : "o";
32
+ if (cat == "w" && next.toUpperCase() == next) cat = "W";
33
+ if (state == "start") {
34
+ if (cat != "o") { state = "in"; type = cat; }
35
+ } else if (state == "in") {
36
+ if (type != cat) {
37
+ if (type == "w" && cat == "W" && dir < 0) pos--;
38
+ if (type == "W" && cat == "w" && dir > 0) { type = "w"; continue; }
39
+ break;
40
+ }
41
+ }
42
+ }
43
+ return Pos(start.line, pos);
44
+ }
45
+
46
+ function moveSubword(cm, dir) {
47
+ cm.extendSelectionsBy(function(range) {
48
+ if (cm.display.shift || cm.doc.extend || range.empty())
49
+ return findPosSubword(cm.doc, range.head, dir);
50
+ else
51
+ return dir < 0 ? range.from() : range.to();
52
+ });
53
+ }
54
+
55
+ cmds[map["Alt-Left"] = "goSubwordLeft"] = function(cm) { moveSubword(cm, -1); };
56
+ cmds[map["Alt-Right"] = "goSubwordRight"] = function(cm) { moveSubword(cm, 1); };
57
+
58
+ if (mac) map["Cmd-Left"] = "goLineStartSmart";
59
+
60
+ var scrollLineCombo = mac ? "Ctrl-Alt-" : "Ctrl-";
61
+
62
+ cmds[map[scrollLineCombo + "Up"] = "scrollLineUp"] = function(cm) {
63
+ var info = cm.getScrollInfo();
64
+ if (!cm.somethingSelected()) {
65
+ var visibleBottomLine = cm.lineAtHeight(info.top + info.clientHeight, "local");
66
+ if (cm.getCursor().line >= visibleBottomLine)
67
+ cm.execCommand("goLineUp");
68
+ }
69
+ cm.scrollTo(null, info.top - cm.defaultTextHeight());
70
+ };
71
+ cmds[map[scrollLineCombo + "Down"] = "scrollLineDown"] = function(cm) {
72
+ var info = cm.getScrollInfo();
73
+ if (!cm.somethingSelected()) {
74
+ var visibleTopLine = cm.lineAtHeight(info.top, "local")+1;
75
+ if (cm.getCursor().line <= visibleTopLine)
76
+ cm.execCommand("goLineDown");
77
+ }
78
+ cm.scrollTo(null, info.top + cm.defaultTextHeight());
79
+ };
80
+
81
+ cmds[map["Shift-" + ctrl + "L"] = "splitSelectionByLine"] = function(cm) {
82
+ var ranges = cm.listSelections(), lineRanges = [];
83
+ for (var i = 0; i < ranges.length; i++) {
84
+ var from = ranges[i].from(), to = ranges[i].to();
85
+ for (var line = from.line; line <= to.line; ++line)
86
+ if (!(to.line > from.line && line == to.line && to.ch == 0))
87
+ lineRanges.push({anchor: line == from.line ? from : Pos(line, 0),
88
+ head: line == to.line ? to : Pos(line)});
89
+ }
90
+ cm.setSelections(lineRanges, 0);
91
+ };
92
+
93
+ map["Shift-Tab"] = "indentLess";
94
+
95
+ cmds[map["Esc"] = "singleSelectionTop"] = function(cm) {
96
+ var range = cm.listSelections()[0];
97
+ cm.setSelection(range.anchor, range.head, {scroll: false});
98
+ };
99
+
100
+ cmds[map[ctrl + "L"] = "selectLine"] = function(cm) {
101
+ var ranges = cm.listSelections(), extended = [];
102
+ for (var i = 0; i < ranges.length; i++) {
103
+ var range = ranges[i];
104
+ extended.push({anchor: Pos(range.from().line, 0),
105
+ head: Pos(range.to().line + 1, 0)});
106
+ }
107
+ cm.setSelections(extended);
108
+ };
109
+
110
+ map["Shift-Ctrl-K"] = "deleteLine";
111
+
112
+ function insertLine(cm, above) {
113
+ if (cm.isReadOnly()) return CodeMirror.Pass
114
+ cm.operation(function() {
115
+ var len = cm.listSelections().length, newSelection = [], last = -1;
116
+ for (var i = 0; i < len; i++) {
117
+ var head = cm.listSelections()[i].head;
118
+ if (head.line <= last) continue;
119
+ var at = Pos(head.line + (above ? 0 : 1), 0);
120
+ cm.replaceRange("\n", at, null, "+insertLine");
121
+ cm.indentLine(at.line, null, true);
122
+ newSelection.push({head: at, anchor: at});
123
+ last = head.line + 1;
124
+ }
125
+ cm.setSelections(newSelection);
126
+ });
127
+ cm.execCommand("indentAuto");
128
+ }
129
+
130
+ cmds[map[ctrl + "Enter"] = "insertLineAfter"] = function(cm) { return insertLine(cm, false); };
131
+
132
+ cmds[map["Shift-" + ctrl + "Enter"] = "insertLineBefore"] = function(cm) { return insertLine(cm, true); };
133
+
134
+ function wordAt(cm, pos) {
135
+ var start = pos.ch, end = start, line = cm.getLine(pos.line);
136
+ while (start && CodeMirror.isWordChar(line.charAt(start - 1))) --start;
137
+ while (end < line.length && CodeMirror.isWordChar(line.charAt(end))) ++end;
138
+ return {from: Pos(pos.line, start), to: Pos(pos.line, end), word: line.slice(start, end)};
139
+ }
140
+
141
+ cmds[map[ctrl + "D"] = "selectNextOccurrence"] = function(cm) {
142
+ var from = cm.getCursor("from"), to = cm.getCursor("to");
143
+ var fullWord = cm.state.sublimeFindFullWord == cm.doc.sel;
144
+ if (CodeMirror.cmpPos(from, to) == 0) {
145
+ var word = wordAt(cm, from);
146
+ if (!word.word) return;
147
+ cm.setSelection(word.from, word.to);
148
+ fullWord = true;
149
+ } else {
150
+ var text = cm.getRange(from, to);
151
+ var query = fullWord ? new RegExp("\\b" + text + "\\b") : text;
152
+ var cur = cm.getSearchCursor(query, to);
153
+ if (cur.findNext()) {
154
+ cm.addSelection(cur.from(), cur.to());
155
+ } else {
156
+ cur = cm.getSearchCursor(query, Pos(cm.firstLine(), 0));
157
+ if (cur.findNext())
158
+ cm.addSelection(cur.from(), cur.to());
159
+ }
160
+ }
161
+ if (fullWord)
162
+ cm.state.sublimeFindFullWord = cm.doc.sel;
163
+ };
164
+
165
+ var mirror = "(){}[]";
166
+ function selectBetweenBrackets(cm) {
167
+ var pos = cm.getCursor(), opening = cm.scanForBracket(pos, -1);
168
+ if (!opening) return;
169
+ for (;;) {
170
+ var closing = cm.scanForBracket(pos, 1);
171
+ if (!closing) return;
172
+ if (closing.ch == mirror.charAt(mirror.indexOf(opening.ch) + 1)) {
173
+ cm.setSelection(Pos(opening.pos.line, opening.pos.ch + 1), closing.pos, false);
174
+ return true;
175
+ }
176
+ pos = Pos(closing.pos.line, closing.pos.ch + 1);
177
+ }
178
+ }
179
+
180
+ cmds[map["Shift-" + ctrl + "Space"] = "selectScope"] = function(cm) {
181
+ selectBetweenBrackets(cm) || cm.execCommand("selectAll");
182
+ };
183
+ cmds[map["Shift-" + ctrl + "M"] = "selectBetweenBrackets"] = function(cm) {
184
+ if (!selectBetweenBrackets(cm)) return CodeMirror.Pass;
185
+ };
186
+
187
+ cmds[map[ctrl + "M"] = "goToBracket"] = function(cm) {
188
+ cm.extendSelectionsBy(function(range) {
189
+ var next = cm.scanForBracket(range.head, 1);
190
+ if (next && CodeMirror.cmpPos(next.pos, range.head) != 0) return next.pos;
191
+ var prev = cm.scanForBracket(range.head, -1);
192
+ return prev && Pos(prev.pos.line, prev.pos.ch + 1) || range.head;
193
+ });
194
+ };
195
+
196
+ var swapLineCombo = mac ? "Cmd-Ctrl-" : "Shift-Ctrl-";
197
+
198
+ cmds[map[swapLineCombo + "Up"] = "swapLineUp"] = function(cm) {
199
+ if (cm.isReadOnly()) return CodeMirror.Pass
200
+ var ranges = cm.listSelections(), linesToMove = [], at = cm.firstLine() - 1, newSels = [];
201
+ for (var i = 0; i < ranges.length; i++) {
202
+ var range = ranges[i], from = range.from().line - 1, to = range.to().line;
203
+ newSels.push({anchor: Pos(range.anchor.line - 1, range.anchor.ch),
204
+ head: Pos(range.head.line - 1, range.head.ch)});
205
+ if (range.to().ch == 0 && !range.empty()) --to;
206
+ if (from > at) linesToMove.push(from, to);
207
+ else if (linesToMove.length) linesToMove[linesToMove.length - 1] = to;
208
+ at = to;
209
+ }
210
+ cm.operation(function() {
211
+ for (var i = 0; i < linesToMove.length; i += 2) {
212
+ var from = linesToMove[i], to = linesToMove[i + 1];
213
+ var line = cm.getLine(from);
214
+ cm.replaceRange("", Pos(from, 0), Pos(from + 1, 0), "+swapLine");
215
+ if (to > cm.lastLine())
216
+ cm.replaceRange("\n" + line, Pos(cm.lastLine()), null, "+swapLine");
217
+ else
218
+ cm.replaceRange(line + "\n", Pos(to, 0), null, "+swapLine");
219
+ }
220
+ cm.setSelections(newSels);
221
+ cm.scrollIntoView();
222
+ });
223
+ };
224
+
225
+ cmds[map[swapLineCombo + "Down"] = "swapLineDown"] = function(cm) {
226
+ if (cm.isReadOnly()) return CodeMirror.Pass
227
+ var ranges = cm.listSelections(), linesToMove = [], at = cm.lastLine() + 1;
228
+ for (var i = ranges.length - 1; i >= 0; i--) {
229
+ var range = ranges[i], from = range.to().line + 1, to = range.from().line;
230
+ if (range.to().ch == 0 && !range.empty()) from--;
231
+ if (from < at) linesToMove.push(from, to);
232
+ else if (linesToMove.length) linesToMove[linesToMove.length - 1] = to;
233
+ at = to;
234
+ }
235
+ cm.operation(function() {
236
+ for (var i = linesToMove.length - 2; i >= 0; i -= 2) {
237
+ var from = linesToMove[i], to = linesToMove[i + 1];
238
+ var line = cm.getLine(from);
239
+ if (from == cm.lastLine())
240
+ cm.replaceRange("", Pos(from - 1), Pos(from), "+swapLine");
241
+ else
242
+ cm.replaceRange("", Pos(from, 0), Pos(from + 1, 0), "+swapLine");
243
+ cm.replaceRange(line + "\n", Pos(to, 0), null, "+swapLine");
244
+ }
245
+ cm.scrollIntoView();
246
+ });
247
+ };
248
+
249
+ cmds[map[ctrl + "/"] = "toggleCommentIndented"] = function(cm) {
250
+ cm.toggleComment({ indent: true });
251
+ }
252
+
253
+ cmds[map[ctrl + "J"] = "joinLines"] = function(cm) {
254
+ var ranges = cm.listSelections(), joined = [];
255
+ for (var i = 0; i < ranges.length; i++) {
256
+ var range = ranges[i], from = range.from();
257
+ var start = from.line, end = range.to().line;
258
+ while (i < ranges.length - 1 && ranges[i + 1].from().line == end)
259
+ end = ranges[++i].to().line;
260
+ joined.push({start: start, end: end, anchor: !range.empty() && from});
261
+ }
262
+ cm.operation(function() {
263
+ var offset = 0, ranges = [];
264
+ for (var i = 0; i < joined.length; i++) {
265
+ var obj = joined[i];
266
+ var anchor = obj.anchor && Pos(obj.anchor.line - offset, obj.anchor.ch), head;
267
+ for (var line = obj.start; line <= obj.end; line++) {
268
+ var actual = line - offset;
269
+ if (line == obj.end) head = Pos(actual, cm.getLine(actual).length + 1);
270
+ if (actual < cm.lastLine()) {
271
+ cm.replaceRange(" ", Pos(actual), Pos(actual + 1, /^\s*/.exec(cm.getLine(actual + 1))[0].length));
272
+ ++offset;
273
+ }
274
+ }
275
+ ranges.push({anchor: anchor || head, head: head});
276
+ }
277
+ cm.setSelections(ranges, 0);
278
+ });
279
+ };
280
+
281
+ cmds[map["Shift-" + ctrl + "D"] = "duplicateLine"] = function(cm) {
282
+ cm.operation(function() {
283
+ var rangeCount = cm.listSelections().length;
284
+ for (var i = 0; i < rangeCount; i++) {
285
+ var range = cm.listSelections()[i];
286
+ if (range.empty())
287
+ cm.replaceRange(cm.getLine(range.head.line) + "\n", Pos(range.head.line, 0));
288
+ else
289
+ cm.replaceRange(cm.getRange(range.from(), range.to()), range.from());
290
+ }
291
+ cm.scrollIntoView();
292
+ });
293
+ };
294
+
295
+ map[ctrl + "T"] = "transposeChars";
296
+
297
+ function sortLines(cm, caseSensitive) {
298
+ if (cm.isReadOnly()) return CodeMirror.Pass
299
+ var ranges = cm.listSelections(), toSort = [], selected;
300
+ for (var i = 0; i < ranges.length; i++) {
301
+ var range = ranges[i];
302
+ if (range.empty()) continue;
303
+ var from = range.from().line, to = range.to().line;
304
+ while (i < ranges.length - 1 && ranges[i + 1].from().line == to)
305
+ to = range[++i].to().line;
306
+ toSort.push(from, to);
307
+ }
308
+ if (toSort.length) selected = true;
309
+ else toSort.push(cm.firstLine(), cm.lastLine());
310
+
311
+ cm.operation(function() {
312
+ var ranges = [];
313
+ for (var i = 0; i < toSort.length; i += 2) {
314
+ var from = toSort[i], to = toSort[i + 1];
315
+ var start = Pos(from, 0), end = Pos(to);
316
+ var lines = cm.getRange(start, end, false);
317
+ if (caseSensitive)
318
+ lines.sort();
319
+ else
320
+ lines.sort(function(a, b) {
321
+ var au = a.toUpperCase(), bu = b.toUpperCase();
322
+ if (au != bu) { a = au; b = bu; }
323
+ return a < b ? -1 : a == b ? 0 : 1;
324
+ });
325
+ cm.replaceRange(lines, start, end);
326
+ if (selected) ranges.push({anchor: start, head: end});
327
+ }
328
+ if (selected) cm.setSelections(ranges, 0);
329
+ });
330
+ }
331
+
332
+ cmds[map["F9"] = "sortLines"] = function(cm) { sortLines(cm, true); };
333
+ cmds[map[ctrl + "F9"] = "sortLinesInsensitive"] = function(cm) { sortLines(cm, false); };
334
+
335
+ cmds[map["F2"] = "nextBookmark"] = function(cm) {
336
+ var marks = cm.state.sublimeBookmarks;
337
+ if (marks) while (marks.length) {
338
+ var current = marks.shift();
339
+ var found = current.find();
340
+ if (found) {
341
+ marks.push(current);
342
+ return cm.setSelection(found.from, found.to);
343
+ }
344
+ }
345
+ };
346
+
347
+ cmds[map["Shift-F2"] = "prevBookmark"] = function(cm) {
348
+ var marks = cm.state.sublimeBookmarks;
349
+ if (marks) while (marks.length) {
350
+ marks.unshift(marks.pop());
351
+ var found = marks[marks.length - 1].find();
352
+ if (!found)
353
+ marks.pop();
354
+ else
355
+ return cm.setSelection(found.from, found.to);
356
+ }
357
+ };
358
+
359
+ cmds[map[ctrl + "F2"] = "toggleBookmark"] = function(cm) {
360
+ var ranges = cm.listSelections();
361
+ var marks = cm.state.sublimeBookmarks || (cm.state.sublimeBookmarks = []);
362
+ for (var i = 0; i < ranges.length; i++) {
363
+ var from = ranges[i].from(), to = ranges[i].to();
364
+ var found = cm.findMarks(from, to);
365
+ for (var j = 0; j < found.length; j++) {
366
+ if (found[j].sublimeBookmark) {
367
+ found[j].clear();
368
+ for (var k = 0; k < marks.length; k++)
369
+ if (marks[k] == found[j])
370
+ marks.splice(k--, 1);
371
+ break;
372
+ }
373
+ }
374
+ if (j == found.length)
375
+ marks.push(cm.markText(from, to, {sublimeBookmark: true, clearWhenEmpty: false}));
376
+ }
377
+ };
378
+
379
+ cmds[map["Shift-" + ctrl + "F2"] = "clearBookmarks"] = function(cm) {
380
+ var marks = cm.state.sublimeBookmarks;
381
+ if (marks) for (var i = 0; i < marks.length; i++) marks[i].clear();
382
+ marks.length = 0;
383
+ };
384
+
385
+ cmds[map["Alt-F2"] = "selectBookmarks"] = function(cm) {
386
+ var marks = cm.state.sublimeBookmarks, ranges = [];
387
+ if (marks) for (var i = 0; i < marks.length; i++) {
388
+ var found = marks[i].find();
389
+ if (!found)
390
+ marks.splice(i--, 0);
391
+ else
392
+ ranges.push({anchor: found.from, head: found.to});
393
+ }
394
+ if (ranges.length)
395
+ cm.setSelections(ranges, 0);
396
+ };
397
+
398
+ map["Alt-Q"] = "wrapLines";
399
+
400
+ var cK = ctrl + "K ";
401
+
402
+ function modifyWordOrSelection(cm, mod) {
403
+ cm.operation(function() {
404
+ var ranges = cm.listSelections(), indices = [], replacements = [];
405
+ for (var i = 0; i < ranges.length; i++) {
406
+ var range = ranges[i];
407
+ if (range.empty()) { indices.push(i); replacements.push(""); }
408
+ else replacements.push(mod(cm.getRange(range.from(), range.to())));
409
+ }
410
+ cm.replaceSelections(replacements, "around", "case");
411
+ for (var i = indices.length - 1, at; i >= 0; i--) {
412
+ var range = ranges[indices[i]];
413
+ if (at && CodeMirror.cmpPos(range.head, at) > 0) continue;
414
+ var word = wordAt(cm, range.head);
415
+ at = word.from;
416
+ cm.replaceRange(mod(word.word), word.from, word.to);
417
+ }
418
+ });
419
+ }
420
+
421
+ map[cK + ctrl + "Backspace"] = "delLineLeft";
422
+
423
+ cmds[map["Backspace"] = "smartBackspace"] = function(cm) {
424
+ if (cm.somethingSelected()) return CodeMirror.Pass;
425
+
426
+ cm.operation(function() {
427
+ var cursors = cm.listSelections();
428
+ var indentUnit = cm.getOption("indentUnit");
429
+
430
+ for (var i = cursors.length - 1; i >= 0; i--) {
431
+ var cursor = cursors[i].head;
432
+ var toStartOfLine = cm.getRange({line: cursor.line, ch: 0}, cursor);
433
+ var column = CodeMirror.countColumn(toStartOfLine, null, cm.getOption("tabSize"));
434
+
435
+ // Delete by one character by default
436
+ var deletePos = cm.findPosH(cursor, -1, "char", false);
437
+
438
+ if (toStartOfLine && !/\S/.test(toStartOfLine) && column % indentUnit == 0) {
439
+ var prevIndent = new Pos(cursor.line,
440
+ CodeMirror.findColumn(toStartOfLine, column - indentUnit, indentUnit));
441
+
442
+ // Smart delete only if we found a valid prevIndent location
443
+ if (prevIndent.ch != cursor.ch) deletePos = prevIndent;
444
+ }
445
+
446
+ cm.replaceRange("", deletePos, cursor, "+delete");
447
+ }
448
+ });
449
+ };
450
+
451
+ cmds[map[cK + ctrl + "K"] = "delLineRight"] = function(cm) {
452
+ cm.operation(function() {
453
+ var ranges = cm.listSelections();
454
+ for (var i = ranges.length - 1; i >= 0; i--)
455
+ cm.replaceRange("", ranges[i].anchor, Pos(ranges[i].to().line), "+delete");
456
+ cm.scrollIntoView();
457
+ });
458
+ };
459
+
460
+ cmds[map[cK + ctrl + "U"] = "upcaseAtCursor"] = function(cm) {
461
+ modifyWordOrSelection(cm, function(str) { return str.toUpperCase(); });
462
+ };
463
+ cmds[map[cK + ctrl + "L"] = "downcaseAtCursor"] = function(cm) {
464
+ modifyWordOrSelection(cm, function(str) { return str.toLowerCase(); });
465
+ };
466
+
467
+ cmds[map[cK + ctrl + "Space"] = "setSublimeMark"] = function(cm) {
468
+ if (cm.state.sublimeMark) cm.state.sublimeMark.clear();
469
+ cm.state.sublimeMark = cm.setBookmark(cm.getCursor());
470
+ };
471
+ cmds[map[cK + ctrl + "A"] = "selectToSublimeMark"] = function(cm) {
472
+ var found = cm.state.sublimeMark && cm.state.sublimeMark.find();
473
+ if (found) cm.setSelection(cm.getCursor(), found);
474
+ };
475
+ cmds[map[cK + ctrl + "W"] = "deleteToSublimeMark"] = function(cm) {
476
+ var found = cm.state.sublimeMark && cm.state.sublimeMark.find();
477
+ if (found) {
478
+ var from = cm.getCursor(), to = found;
479
+ if (CodeMirror.cmpPos(from, to) > 0) { var tmp = to; to = from; from = tmp; }
480
+ cm.state.sublimeKilled = cm.getRange(from, to);
481
+ cm.replaceRange("", from, to);
482
+ }
483
+ };
484
+ cmds[map[cK + ctrl + "X"] = "swapWithSublimeMark"] = function(cm) {
485
+ var found = cm.state.sublimeMark && cm.state.sublimeMark.find();
486
+ if (found) {
487
+ cm.state.sublimeMark.clear();
488
+ cm.state.sublimeMark = cm.setBookmark(cm.getCursor());
489
+ cm.setCursor(found);
490
+ }
491
+ };
492
+ cmds[map[cK + ctrl + "Y"] = "sublimeYank"] = function(cm) {
493
+ if (cm.state.sublimeKilled != null)
494
+ cm.replaceSelection(cm.state.sublimeKilled, null, "paste");
495
+ };
496
+
497
+ map[cK + ctrl + "G"] = "clearBookmarks";
498
+ cmds[map[cK + ctrl + "C"] = "showInCenter"] = function(cm) {
499
+ var pos = cm.cursorCoords(null, "local");
500
+ cm.scrollTo(null, (pos.top + pos.bottom) / 2 - cm.getScrollInfo().clientHeight / 2);
501
+ };
502
+
503
+ var selectLinesCombo = mac ? "Ctrl-Shift-" : "Ctrl-Alt-";
504
+ cmds[map[selectLinesCombo + "Up"] = "selectLinesUpward"] = function(cm) {
505
+ cm.operation(function() {
506
+ var ranges = cm.listSelections();
507
+ for (var i = 0; i < ranges.length; i++) {
508
+ var range = ranges[i];
509
+ if (range.head.line > cm.firstLine())
510
+ cm.addSelection(Pos(range.head.line - 1, range.head.ch));
511
+ }
512
+ });
513
+ };
514
+ cmds[map[selectLinesCombo + "Down"] = "selectLinesDownward"] = function(cm) {
515
+ cm.operation(function() {
516
+ var ranges = cm.listSelections();
517
+ for (var i = 0; i < ranges.length; i++) {
518
+ var range = ranges[i];
519
+ if (range.head.line < cm.lastLine())
520
+ cm.addSelection(Pos(range.head.line + 1, range.head.ch));
521
+ }
522
+ });
523
+ };
524
+
525
+ function getTarget(cm) {
526
+ var from = cm.getCursor("from"), to = cm.getCursor("to");
527
+ if (CodeMirror.cmpPos(from, to) == 0) {
528
+ var word = wordAt(cm, from);
529
+ if (!word.word) return;
530
+ from = word.from;
531
+ to = word.to;
532
+ }
533
+ return {from: from, to: to, query: cm.getRange(from, to), word: word};
534
+ }
535
+
536
+ function findAndGoTo(cm, forward) {
537
+ var target = getTarget(cm);
538
+ if (!target) return;
539
+ var query = target.query;
540
+ var cur = cm.getSearchCursor(query, forward ? target.to : target.from);
541
+
542
+ if (forward ? cur.findNext() : cur.findPrevious()) {
543
+ cm.setSelection(cur.from(), cur.to());
544
+ } else {
545
+ cur = cm.getSearchCursor(query, forward ? Pos(cm.firstLine(), 0)
546
+ : cm.clipPos(Pos(cm.lastLine())));
547
+ if (forward ? cur.findNext() : cur.findPrevious())
548
+ cm.setSelection(cur.from(), cur.to());
549
+ else if (target.word)
550
+ cm.setSelection(target.from, target.to);
551
+ }
552
+ };
553
+ cmds[map[ctrl + "F3"] = "findUnder"] = function(cm) { findAndGoTo(cm, true); };
554
+ cmds[map["Shift-" + ctrl + "F3"] = "findUnderPrevious"] = function(cm) { findAndGoTo(cm,false); };
555
+ cmds[map["Alt-F3"] = "findAllUnder"] = function(cm) {
556
+ var target = getTarget(cm);
557
+ if (!target) return;
558
+ var cur = cm.getSearchCursor(target.query);
559
+ var matches = [];
560
+ var primaryIndex = -1;
561
+ while (cur.findNext()) {
562
+ matches.push({anchor: cur.from(), head: cur.to()});
563
+ if (cur.from().line <= target.from.line && cur.from().ch <= target.from.ch)
564
+ primaryIndex++;
565
+ }
566
+ cm.setSelections(matches, primaryIndex);
567
+ };
568
+
569
+ map["Shift-" + ctrl + "["] = "fold";
570
+ map["Shift-" + ctrl + "]"] = "unfold";
571
+ map[cK + ctrl + "0"] = map[cK + ctrl + "j"] = "unfoldAll";
572
+
573
+ map[ctrl + "I"] = "findIncremental";
574
+ map["Shift-" + ctrl + "I"] = "findIncrementalReverse";
575
+ map[ctrl + "H"] = "replace";
576
+ map["F3"] = "findNext";
577
+ map["Shift-F3"] = "findPrev";
578
+
579
+ CodeMirror.normalizeKeyMap(map);
580
+ });