Esites_Editor - Version 0.6.0

Version Notes

As of this version the standalone editor is disabled by default for the front-end and can be enabled via the configuration panel.

Further more we enhanced the standalone editor by landing the support for inserting widgets and images. Also, there are new themes available due to upgrading to the latest CodeMirror version.

The GitHub repo can be found at: https://github.com/e-sites/magento-advanced-code-editor

Download this release

Release Info

Developer Boye Oomens
Extension Esites_Editor
Version 0.6.0
Comparing to
See all releases


Code changes from version 0.5.1 to 0.6.0

Files changed (52) hide show
  1. app/code/community/Esites/Editor/Block/Adminhtml/Version.php +26 -0
  2. app/code/community/Esites/Editor/Block/Standalone.php +0 -11
  3. app/code/community/Esites/Editor/Helper/Data.php +9 -0
  4. app/code/community/Esites/Editor/Model/System/Config/Source/Theme/Values.php +12 -2
  5. app/code/community/Esites/Editor/etc/config.xml +2 -1
  6. app/code/community/Esites/Editor/etc/system.xml +31 -3
  7. app/design/adminhtml/default/default/layout/esites_editor.xml +3 -2
  8. app/design/adminhtml/default/default/template/esites_editor/standalone.phtml +1 -2
  9. app/design/frontend/base/default/layout/esites_editor.xml +7 -5
  10. app/design/frontend/base/default/template/esites_editor/standalone.phtml +2 -2
  11. js/esites_editor/dist/js/app/module/editor.js +1 -1
  12. js/esites_editor/dist/js/app/module/standalone.js +1 -1
  13. js/esites_editor/dist/js/vendor/codemirror/addon/comment/comment.js +9 -2
  14. js/esites_editor/dist/js/vendor/codemirror/addon/dialog/dialog.js +2 -2
  15. js/esites_editor/dist/js/vendor/codemirror/addon/display/placeholder.js +2 -0
  16. js/esites_editor/dist/js/vendor/codemirror/addon/edit/closebrackets.js +1 -1
  17. js/esites_editor/dist/js/vendor/codemirror/addon/fold/comment-fold.js +3 -1
  18. js/esites_editor/dist/js/vendor/codemirror/addon/fold/foldgutter.js +2 -2
  19. js/esites_editor/dist/js/vendor/codemirror/addon/hint/show-hint.js +35 -41
  20. js/esites_editor/dist/js/vendor/codemirror/addon/hint/sql-hint.js +43 -16
  21. js/esites_editor/dist/js/vendor/codemirror/addon/lint/lint.js +11 -3
  22. js/esites_editor/dist/js/vendor/codemirror/addon/merge/merge.css +1 -0
  23. js/esites_editor/dist/js/vendor/codemirror/addon/merge/merge.js +3 -2
  24. js/esites_editor/dist/js/vendor/codemirror/addon/mode/simple.js +1 -1
  25. js/esites_editor/dist/js/vendor/codemirror/addon/runmode/runmode.js +1 -1
  26. js/esites_editor/dist/js/vendor/codemirror/addon/runmode/runmode.node.js +1 -0
  27. js/esites_editor/dist/js/vendor/codemirror/addon/scroll/annotatescrollbar.js +4 -1
  28. js/esites_editor/dist/js/vendor/codemirror/addon/scroll/simplescrollbars.js +10 -8
  29. js/esites_editor/dist/js/vendor/codemirror/addon/search/jump-to-line.js +49 -0
  30. js/esites_editor/dist/js/vendor/codemirror/addon/search/match-highlighter.js +50 -32
  31. js/esites_editor/dist/js/vendor/codemirror/addon/search/search.js +6 -3
  32. js/esites_editor/dist/js/vendor/codemirror/addon/selection/active-line.js +3 -0
  33. js/esites_editor/dist/js/vendor/codemirror/addon/tern/tern.js +3 -2
  34. js/esites_editor/dist/js/vendor/codemirror/keymap/sublime.js +1 -1
  35. js/esites_editor/dist/js/vendor/codemirror/keymap/vim.js +4 -4
  36. js/esites_editor/dist/js/vendor/codemirror/lib/codemirror.css +1 -1
  37. js/esites_editor/dist/js/vendor/codemirror/lib/codemirror.js +7 -7
  38. js/esites_editor/dist/js/vendor/codemirror/mode/css/css.js +1 -1
  39. js/esites_editor/dist/js/vendor/codemirror/mode/handlebars/handlebars.js +1 -1
  40. js/esites_editor/dist/js/vendor/codemirror/mode/htmlmixed/htmlmixed.js +1 -1
  41. js/esites_editor/dist/js/vendor/codemirror/mode/javascript/javascript.js +1 -1
  42. js/esites_editor/dist/js/vendor/codemirror/mode/xml/xml.js +1 -1
  43. js/esites_editor/dist/js/vendor/codemirror/theme/icecoder.css +1 -1
  44. js/esites_editor/dist/js/vendor/codemirror/theme/material.css +1 -1
  45. js/esites_editor/dist/js/vendor/codemirror/theme/mbo.css +1 -1
  46. js/esites_editor/dist/js/vendor/codemirror/theme/monokai.css +1 -1
  47. js/esites_editor/dist/js/vendor/codemirror/theme/night.css +1 -1
  48. js/tiny_mce/plugins/esites_editor/css/styles.min-0d97256b.css +1 -0
  49. js/tiny_mce/plugins/esites_editor/css/styles.min-47f779f9.css +0 -1
  50. js/tiny_mce/plugins/esites_editor/esites_editor.html +1 -1
  51. js/tiny_mce/plugins/esites_editor/esites_editor_plugin_src.js +1 -1
  52. package.xml +7 -5
app/code/community/Esites/Editor/Block/Adminhtml/Version.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Esites
16
+ * @package Esites_Editor
17
+ * @copyright Copyright (c) 2015 E-sites (http://www.e-sites.nl)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Esites_Editor_Block_Adminhtml_Version extends Mage_Adminhtml_Block_System_Config_Form_Field
21
+ {
22
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
23
+ {
24
+ return (string) Mage::helper('editor')->getExtensionVersion();
25
+ }
26
+ }
app/code/community/Esites/Editor/Block/Standalone.php CHANGED
@@ -35,7 +35,6 @@ class Esites_Editor_Block_Standalone extends Mage_Core_Block_Template
35
  */
36
  public function getEditorConfig()
37
  {
38
-
39
  if (Mage::getStoreConfig('editor/general/enabled', Mage::app()->getStore())) {
40
  $this->_config = Mage::getModel('editor/config')->getPluginSettings();
41
  $this->_config = $this->_config['plugins'][0]['config'];
@@ -43,14 +42,4 @@ class Esites_Editor_Block_Standalone extends Mage_Core_Block_Template
43
 
44
  return $this->_config;
45
  }
46
-
47
- /**
48
- * Returns the current extension version
49
- *
50
- * @return string
51
- */
52
- public function getExtensionVersion()
53
- {
54
- return (string) Mage::getConfig()->getNode()->modules->Esites_Editor->version;
55
- }
56
  }
35
  */
36
  public function getEditorConfig()
37
  {
 
38
  if (Mage::getStoreConfig('editor/general/enabled', Mage::app()->getStore())) {
39
  $this->_config = Mage::getModel('editor/config')->getPluginSettings();
40
  $this->_config = $this->_config['plugins'][0]['config'];
42
 
43
  return $this->_config;
44
  }
 
 
 
 
 
 
 
 
 
 
45
  }
app/code/community/Esites/Editor/Helper/Data.php CHANGED
@@ -19,4 +19,13 @@
19
  */
20
  class Esites_Editor_Helper_Data extends Mage_Core_Helper_Abstract
21
  {
 
 
 
 
 
 
 
 
 
22
  }
19
  */
20
  class Esites_Editor_Helper_Data extends Mage_Core_Helper_Abstract
21
  {
22
+ /**
23
+ * Returns the current extension version
24
+ *
25
+ * @return string
26
+ */
27
+ public function getExtensionVersion()
28
+ {
29
+ return (string) Mage::getConfig()->getNode()->modules->Esites_Editor->version;
30
+ }
31
  }
app/code/community/Esites/Editor/Model/System/Config/Source/Theme/Values.php CHANGED
@@ -24,17 +24,25 @@ class Esites_Editor_Model_System_Config_Source_Theme_Values extends Varien_Objec
24
  'default',
25
  '3024-day',
26
  '3024-night',
 
27
  'ambiance',
 
28
  'base16-dark',
29
  'base16-light',
 
30
  'blackboard',
31
  'cobalt',
32
  'colorforth',
 
33
  'eclipse',
34
  'elegant',
35
  'erlang-dark',
 
 
 
36
  'lesser-dark',
37
  'liquibyte',
 
38
  'mbo',
39
  'mdn-like',
40
  'midnight',
@@ -45,9 +53,10 @@ class Esites_Editor_Model_System_Config_Source_Theme_Values extends Varien_Objec
45
  'paraiso-dark',
46
  'paraiso-light',
47
  'pastel-on-dark',
 
48
  'rubyblue',
49
- 'solarized dark',
50
- 'solarized light',
51
  'the-matrix',
52
  'tomorrow-night-bright',
53
  'tomorrow-night-eighties',
@@ -56,6 +65,7 @@ class Esites_Editor_Model_System_Config_Source_Theme_Values extends Varien_Objec
56
  'vibrant-ink',
57
  'xq-dark',
58
  'xq-light',
 
59
  'zenburn'
60
  );
61
 
24
  'default',
25
  '3024-day',
26
  '3024-night',
27
+ 'abcdef',
28
  'ambiance',
29
+ 'ambiance-mobile',
30
  'base16-dark',
31
  'base16-light',
32
+ 'bespin',
33
  'blackboard',
34
  'cobalt',
35
  'colorforth',
36
+ 'dracula',
37
  'eclipse',
38
  'elegant',
39
  'erlang-dark',
40
+ 'hopscotch',
41
+ 'icecoder',
42
+ 'isotope',
43
  'lesser-dark',
44
  'liquibyte',
45
+ 'material',
46
  'mbo',
47
  'mdn-like',
48
  'midnight',
53
  'paraiso-dark',
54
  'paraiso-light',
55
  'pastel-on-dark',
56
+ 'railscasts',
57
  'rubyblue',
58
+ 'seti',
59
+ 'solarized',
60
  'the-matrix',
61
  'tomorrow-night-bright',
62
  'tomorrow-night-eighties',
65
  'vibrant-ink',
66
  'xq-dark',
67
  'xq-light',
68
+ 'yeti',
69
  'zenburn'
70
  );
71
 
app/code/community/Esites/Editor/etc/config.xml CHANGED
@@ -22,7 +22,7 @@
22
  <config>
23
  <modules>
24
  <Esites_Editor>
25
- <version>0.5.1</version>
26
  </Esites_Editor>
27
  </modules>
28
 
@@ -48,6 +48,7 @@
48
  <editor>
49
  <general>
50
  <enabled>0</enabled>
 
51
  <sections>wysiwygpage_content</sections>
52
  <selectors></selectors>
53
  </general>
22
  <config>
23
  <modules>
24
  <Esites_Editor>
25
+ <version>0.6.0</version>
26
  </Esites_Editor>
27
  </modules>
28
 
48
  <editor>
49
  <general>
50
  <enabled>0</enabled>
51
+ <enableFrontend>0</enableFrontend>
52
  <sections>wysiwygpage_content</sections>
53
  <selectors></selectors>
54
  </general>
app/code/community/Esites/Editor/etc/system.xml CHANGED
@@ -26,6 +26,15 @@
26
  <sort_order>1000</sort_order>
27
  </esites>
28
  </tabs>
 
 
 
 
 
 
 
 
 
29
  <sections>
30
  <editor translate="label" module="editor">
31
  <label>Advanced Code Editor</label>
@@ -43,20 +52,39 @@
43
  <show_in_website>1</show_in_website>
44
  <show_in_store>1</show_in_store>
45
  <fields>
 
 
 
 
 
 
 
 
 
46
  <enabled translate="label">
47
  <label>Enable</label>
48
  <frontend_type>select</frontend_type>
49
  <source_model>adminhtml/system_config_source_yesno</source_model>
50
- <sort_order>0</sort_order>
51
  <show_in_default>1</show_in_default>
52
  <show_in_website>1</show_in_website>
53
  <show_in_store>0</show_in_store>
54
  </enabled>
 
 
 
 
 
 
 
 
 
 
55
  <sections translate="label">
56
  <label>Sections</label>
57
  <frontend_type>multiselect</frontend_type>
58
  <source_model>editor/system_config_source_sections_values</source_model>
59
- <sort_order>1</sort_order>
60
  <show_in_default>1</show_in_default>
61
  <show_in_website>1</show_in_website>
62
  <show_in_store>0</show_in_store>
@@ -67,7 +95,7 @@
67
  <selectors translate="label">
68
  <label>Stand-alone selectors</label>
69
  <frontend_type>textarea</frontend_type>
70
- <sort_order>3</sort_order>
71
  <show_in_default>1</show_in_default>
72
  <show_in_website>1</show_in_website>
73
  <show_in_store>0</show_in_store>
26
  <sort_order>1000</sort_order>
27
  </esites>
28
  </tabs>
29
+ <version translate="label">
30
+ <label>MyModule extension version</label>
31
+ <frontend_type>text</frontend_type>
32
+ <frontend_model>Esites_Editor_Block_Adminhtml_Version</frontend_model>
33
+ <sort_order>0</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ </version>
38
  <sections>
39
  <editor translate="label" module="editor">
40
  <label>Advanced Code Editor</label>
52
  <show_in_website>1</show_in_website>
53
  <show_in_store>1</show_in_store>
54
  <fields>
55
+ <version translate="label">
56
+ <label>Version</label>
57
+ <frontend_type>select</frontend_type>
58
+ <frontend_model>Esites_Editor_Block_Adminhtml_Version</frontend_model>
59
+ <sort_order>0</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>1</show_in_store>
63
+ </version>
64
  <enabled translate="label">
65
  <label>Enable</label>
66
  <frontend_type>select</frontend_type>
67
  <source_model>adminhtml/system_config_source_yesno</source_model>
68
+ <sort_order>1</sort_order>
69
  <show_in_default>1</show_in_default>
70
  <show_in_website>1</show_in_website>
71
  <show_in_store>0</show_in_store>
72
  </enabled>
73
+ <enableFrontend translate="label">
74
+ <label>Enable in front-end</label>
75
+ <frontend_type>select</frontend_type>
76
+ <source_model>adminhtml/system_config_source_yesno</source_model>
77
+ <sort_order>2</sort_order>
78
+ <show_in_default>1</show_in_default>
79
+ <show_in_website>1</show_in_website>
80
+ <show_in_store>0</show_in_store>
81
+ <comment><![CDATA[Enables the stand-alone editor in the front-end]]></comment>
82
+ </enableFrontend>
83
  <sections translate="label">
84
  <label>Sections</label>
85
  <frontend_type>multiselect</frontend_type>
86
  <source_model>editor/system_config_source_sections_values</source_model>
87
+ <sort_order>3</sort_order>
88
  <show_in_default>1</show_in_default>
89
  <show_in_website>1</show_in_website>
90
  <show_in_store>0</show_in_store>
95
  <selectors translate="label">
96
  <label>Stand-alone selectors</label>
97
  <frontend_type>textarea</frontend_type>
98
+ <sort_order>4</sort_order>
99
  <show_in_default>1</show_in_default>
100
  <show_in_website>1</show_in_website>
101
  <show_in_store>0</show_in_store>
app/design/adminhtml/default/default/layout/esites_editor.xml CHANGED
@@ -21,7 +21,9 @@
21
  -->
22
  <layout>
23
  <default>
24
- <block type="editor/standalone" name="standalone" template="esites_editor/standalone.phtml"></block>
 
 
25
  <reference name="head">
26
  <action method="addItem" ifconfig="editor/general/enabled">
27
  <type>js_css</type>
@@ -31,7 +33,6 @@
31
  <type>js_css</type>
32
  <name>esites_editor/dist/css/styles.css</name>
33
  </action>
34
- <block type="editor/standalone" name="standalone" template="esites_editor/standalone.phtml"></block>
35
  </reference>
36
  <reference name="notifications">
37
  <action method="append" ifconfig="editor/general/enabled">
21
  -->
22
  <layout>
23
  <default>
24
+ <reference name="root">
25
+ <block type="editor/standalone" name="standalone" template="esites_editor/standalone.phtml"></block>
26
+ </reference>
27
  <reference name="head">
28
  <action method="addItem" ifconfig="editor/general/enabled">
29
  <type>js_css</type>
33
  <type>js_css</type>
34
  <name>esites_editor/dist/css/styles.css</name>
35
  </action>
 
36
  </reference>
37
  <reference name="notifications">
38
  <action method="append" ifconfig="editor/general/enabled">
app/design/adminhtml/default/default/template/esites_editor/standalone.phtml CHANGED
@@ -23,10 +23,9 @@
23
  <script>
24
  (function (window) {
25
  var doc = window.document,
26
- timer = 0,
27
  esites_editor = {
28
  instances: [],
29
- version: '<?php echo $this->getExtensionVersion(); ?>',
30
  settings: <?php echo json_encode($this->getEditorConfig()); ?>,
31
  init: function () {
32
  requirejs(['/js/esites_editor/dist/js/app.js']);
23
  <script>
24
  (function (window) {
25
  var doc = window.document,
 
26
  esites_editor = {
27
  instances: [],
28
+ version: '<?php echo Mage::helper('editor')->getExtensionVersion(); ?>',
29
  settings: <?php echo json_encode($this->getEditorConfig()); ?>,
30
  init: function () {
31
  requirejs(['/js/esites_editor/dist/js/app.js']);
app/design/frontend/base/default/layout/esites_editor.xml CHANGED
@@ -21,19 +21,21 @@
21
  -->
22
  <layout version="0.1.0">
23
  <default>
 
 
 
24
  <reference name="head">
25
- <action method="addItem" ifconfig="editor/general/enabled">
26
  <type>js_css</type>
27
  <name>esites_editor/dist/js/vendor/codemirror/lib/codemirror.css</name>
28
  </action>
29
- <action method="addItem" ifconfig="editor/general/enabled">
30
  <type>js_css</type>
31
  <name>esites_editor/dist/css/styles.css</name>
32
  </action>
33
- <block type="editor/standalone" name="standalone" template="esites_editor/standalone.phtml"></block>
34
  </reference>
35
- <reference name="root">
36
- <action method="append" ifconfig="editor/general/enabled">
37
  <block>standalone</block>
38
  </action>
39
  </reference>
21
  -->
22
  <layout version="0.1.0">
23
  <default>
24
+ <reference name="root">
25
+ <block type="editor/standalone" name="standalone" template="esites_editor/standalone.phtml"></block>
26
+ </reference>
27
  <reference name="head">
28
+ <action method="addItem" ifconfig="editor/general/enableFrontend">
29
  <type>js_css</type>
30
  <name>esites_editor/dist/js/vendor/codemirror/lib/codemirror.css</name>
31
  </action>
32
+ <action method="addItem" ifconfig="editor/general/enableFrontend">
33
  <type>js_css</type>
34
  <name>esites_editor/dist/css/styles.css</name>
35
  </action>
 
36
  </reference>
37
+ <reference name="footer">
38
+ <action method="append" ifconfig="editor/general/enableFrontend">
39
  <block>standalone</block>
40
  </action>
41
  </reference>
app/design/frontend/base/default/template/esites_editor/standalone.phtml CHANGED
@@ -25,7 +25,7 @@
25
  var doc = window.document,
26
  esites_editor = {
27
  instances: [],
28
- version: '<?php echo $this->getExtensionVersion(); ?>',
29
  settings: <?php echo json_encode($this->getEditorConfig()); ?>,
30
  init: function () {
31
  requirejs(['/js/esites_editor/dist/js/app.js']);
@@ -39,5 +39,5 @@
39
  }
40
 
41
  window.esites_editor = esites_editor;
42
- }(this));
43
  </script>
25
  var doc = window.document,
26
  esites_editor = {
27
  instances: [],
28
+ version: '<?php echo Mage::helper('editor')->getExtensionVersion(); ?>',
29
  settings: <?php echo json_encode($this->getEditorConfig()); ?>,
30
  init: function () {
31
  requirejs(['/js/esites_editor/dist/js/app.js']);
39
  }
40
 
41
  window.esites_editor = esites_editor;
42
+ }(window));
43
  </script>
js/esites_editor/dist/js/app/module/editor.js CHANGED
@@ -1 +1 @@
1
- define(["codemirror/lib/codemirror","../var/plugin","../var/targets","../var/deps","./dialog","./util","./standalone"],function(CodeMirror,plugin,targets,deps,dialog,util,standalone){"use strict";var editor={};editor.instances=[];editor.options=null;editor.init=function(){util.forEach(targets,editor.createInstance);editor.instances.length&&editor.instances[0].focus()};editor.createInstance=function(textarea){var cm=CodeMirror.fromTextArea(textarea,editor.options);dialog&&dialog.prepare(cm);plugin.settings.emmet&&editor.initEmmet();editor.isStandAlone()&&standalone.init(cm,editor);plugin.instances.push(cm);editor.instances.push(cm)};editor.syncValue=function(cm){cm.getTextArea().value=cm.getValue()};editor.initEmmet=function(cm){requirejs(["emmet"],function(emmetCodeMirror){cm?emmetCodeMirror(cm):util.forEach(editor.instances,function(c){emmetCodeMirror(c)})})};editor.isStandAlone=function(){return-1!==util.inArray("wysiwygtemplate_text",plugin.settings.sections)};editor.insertVariable=function(obj,cm){var attr=obj.getAttribute("onclick"),val=attr.match(/{{(.*?)[\|\|.*?]?}}/)[0],doc=cm.getDoc(),cursor=doc.getCursor();doc.replaceRange(val,cursor)};return editor});
1
+ define(["codemirror/lib/codemirror","../var/plugin","../var/targets","../var/deps","./dialog","./util","./code","./standalone"],function(CodeMirror,plugin,targets,deps,dialog,util,code,standalone){"use strict";var editor={};editor.instances=[];editor.options=null;editor.init=function(){util.forEach(targets,editor.createInstance);"undefined"!=typeof varienGlobalEvents&&varienGlobalEvents.attachEventHandler("showTab",function(){util.forEach(editor.instances,function(cm){cm.refresh()})});editor.instances.length&&editor.instances[0].focus()};editor.createInstance=function(textarea){var cm=CodeMirror.fromTextArea(textarea,editor.options);dialog&&dialog.prepare(cm);plugin.settings.emmet&&editor.initEmmet();editor.isStandAlone()&&"undefined"==typeof tinyMCE&&standalone.init(cm,editor);plugin.instances.push(cm);editor.instances.push(cm)};editor.syncValue=function(cm){cm.getTextArea().value=cm.getValue()};editor.initEmmet=function(cm){requirejs(["emmet"],function(emmetCodeMirror){cm?emmetCodeMirror(cm):util.forEach(editor.instances,function(c){emmetCodeMirror(c)})})};editor.isStandAlone=function(){return-1!==util.inArray("wysiwygtemplate_text",plugin.settings.sections)};editor.insertVariable=function(obj,cm){var attr=obj.getAttribute("onclick"),val=attr.match(/{{(.*?)[\|\|.*?]?}}/)[0],doc=cm.getDoc(),cursor=doc.getCursor();doc.replaceRange(val,cursor)};editor.insertSnippet=function(snippet,cm,cursor){var doc=cm.getDoc();doc.replaceRange(snippet,cursor)};return editor});
js/esites_editor/dist/js/app/module/standalone.js CHANGED
@@ -1 +1 @@
1
- define(["codemirror/lib/codemirror","gator","./code","./util","../var/plugin"],function(CodeMirror,Gator,code,util,plugin){"use strict";function _monitorChanges(){var textarea=this.getTextArea();if(""!==textarea.value){this.setValue(code.format("html",textarea.value));if(stylesEditor){cssCode=stylesEditor.value;plugin.settings.autoFormat&&(cssCode=code.format("css",stylesEditor.value));cmStyles.setValue(cssCode)}clearInterval(timer)}}function _createCssEditor(editor){if(stylesEditor){cmStyles=CodeMirror.fromTextArea(stylesEditor,util.extend(editor.options,{mode:"css"}));cmStyles.on("blur",editor.syncValue);plugin.settings.emmet&&editor.initEmmet(cmStyles)}}function _init(cm,editor){var cm=cm;cm.on("blur",editor.syncValue);_createCssEditor(editor);Gator(document).on("click","#variables-chooser_content a",function(){editor.insertVariable(this,cm)}).on("click","#email_template_load_form button",function(){stylesEditor&&(stylesEditor.value="");util.forEach(editor.instances,function(el){el.getTextArea().value=""});timer=setInterval(util.proxy(_monitorChanges,cm),250)})}var cmStyles,cssCode,timer=null,stylesEditor=util.getElem("template_styles");return{init:_init}});
1
+ define(["codemirror/lib/codemirror","gator","./code","./util","../var/plugin"],function(CodeMirror,Gator,code,util,plugin){"use strict";function _monitorChanges(){var textarea=this.getTextArea();if(""!==textarea.value){this.setValue(code.format("html",textarea.value));if(stylesEditor){cssCode=stylesEditor.value;plugin.settings.autoFormat&&(cssCode=code.format("css",stylesEditor.value));cmStyles.setValue(cssCode)}clearInterval(timer)}}function _createCssEditor(editor){if(stylesEditor){cmStyles=CodeMirror.fromTextArea(stylesEditor,util.extend(editor.options,{mode:"css"}));cmStyles.on("blur",editor.syncValue);plugin.settings.emmet&&editor.initEmmet(cmStyles)}}function _emptyTextAreas(editor){stylesEditor&&(stylesEditor.value="");util.forEach(editor.instances,function(el){el.getTextArea().value=""})}function _init(cm,editor){var cursor,cm=cm;cm.on("blur",editor.syncValue);_createCssEditor(editor);"undefined"!=typeof Ajax&&Ajax.Responders.register({onComplete:function(){var url,args=arguments;if(args.length>1){url=args[1].request.url;(url.indexOf("onInsert")>-1||url.indexOf("buildWidget")>-1)&&editor.insertSnippet(args[1].responseText,cm,cursor)}}});Gator(document).on("click","#variables-chooser_content a",function(){editor.insertVariable(this,cm)}).on("mousedown",".magento_close",function(){clearInterval(timer)}).on("click","#email_template_load_form button",function(){_emptyTextAreas(editor);timer=setInterval(util.proxy(_monitorChanges,cm),250)}).on("click",".add-image, .add-widget",function(){cursor=cm.getCursor()})}var cmStyles,cssCode,timer=null,stylesEditor=util.getElem("template_styles");return{init:_init}});
js/esites_editor/dist/js/vendor/codemirror/addon/comment/comment.js CHANGED
@@ -44,9 +44,17 @@
44
  }
45
  });
46
 
 
 
 
 
 
47
  CodeMirror.defineExtension("lineComment", function(from, to, options) {
48
  if (!options) options = noOptions;
49
  var self = this, mode = self.getModeAt(from);
 
 
 
50
  var commentString = options.lineComment || mode.lineComment;
51
  if (!commentString) {
52
  if (options.blockCommentStart || mode.blockCommentStart) {
@@ -55,8 +63,7 @@
55
  }
56
  return;
57
  }
58
- var firstLine = self.getLine(from.line);
59
- if (firstLine == null) return;
60
  var end = Math.min(to.ch != 0 || to.line == from.line ? to.line + 1 : to.line, self.lastLine() + 1);
61
  var pad = options.padding == null ? " " : options.padding;
62
  var blankLines = options.commentBlankLines || from.line == to.line;
44
  }
45
  });
46
 
47
+ // Rough heuristic to try and detect lines that are part of multi-line string
48
+ function probablyInsideString(cm, pos, line) {
49
+ return /\bstring\b/.test(cm.getTokenTypeAt(Pos(pos.line, 0))) && !/^[\'\"`]/.test(line)
50
+ }
51
+
52
  CodeMirror.defineExtension("lineComment", function(from, to, options) {
53
  if (!options) options = noOptions;
54
  var self = this, mode = self.getModeAt(from);
55
+ var firstLine = self.getLine(from.line);
56
+ if (firstLine == null || probablyInsideString(self, from, firstLine)) return;
57
+
58
  var commentString = options.lineComment || mode.lineComment;
59
  if (!commentString) {
60
  if (options.blockCommentStart || mode.blockCommentStart) {
63
  }
64
  return;
65
  }
66
+
 
67
  var end = Math.min(to.ch != 0 || to.line == from.line ? to.line + 1 : to.line, self.lastLine() + 1);
68
  var pad = options.padding == null ? " " : options.padding;
69
  var blankLines = options.commentBlankLines || from.line == to.line;
js/esites_editor/dist/js/vendor/codemirror/addon/dialog/dialog.js CHANGED
@@ -56,6 +56,8 @@
56
 
57
  var inp = dialog.getElementsByTagName("input")[0], button;
58
  if (inp) {
 
 
59
  if (options.value) {
60
  inp.value = options.value;
61
  if (options.selectValueOnOpen !== false) {
@@ -79,8 +81,6 @@
79
  });
80
 
81
  if (options.closeOnBlur !== false) CodeMirror.on(inp, "blur", close);
82
-
83
- inp.focus();
84
  } else if (button = dialog.getElementsByTagName("button")[0]) {
85
  CodeMirror.on(button, "click", function() {
86
  close();
56
 
57
  var inp = dialog.getElementsByTagName("input")[0], button;
58
  if (inp) {
59
+ inp.focus();
60
+
61
  if (options.value) {
62
  inp.value = options.value;
63
  if (options.selectValueOnOpen !== false) {
81
  });
82
 
83
  if (options.closeOnBlur !== false) CodeMirror.on(inp, "blur", close);
 
 
84
  } else if (button = dialog.getElementsByTagName("button")[0]) {
85
  CodeMirror.on(button, "click", function() {
86
  close();
js/esites_editor/dist/js/vendor/codemirror/addon/display/placeholder.js CHANGED
@@ -14,10 +14,12 @@
14
  if (val && !prev) {
15
  cm.on("blur", onBlur);
16
  cm.on("change", onChange);
 
17
  onChange(cm);
18
  } else if (!val && prev) {
19
  cm.off("blur", onBlur);
20
  cm.off("change", onChange);
 
21
  clearPlaceholder(cm);
22
  var wrapper = cm.getWrapperElement();
23
  wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
14
  if (val && !prev) {
15
  cm.on("blur", onBlur);
16
  cm.on("change", onChange);
17
+ cm.on("swapDoc", onChange);
18
  onChange(cm);
19
  } else if (!val && prev) {
20
  cm.off("blur", onBlur);
21
  cm.off("change", onChange);
22
+ cm.off("swapDoc", onChange);
23
  clearPlaceholder(cm);
24
  var wrapper = cm.getWrapperElement();
25
  wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
js/esites_editor/dist/js/vendor/codemirror/addon/edit/closebrackets.js CHANGED
@@ -63,7 +63,7 @@
63
  }
64
  for (var i = ranges.length - 1; i >= 0; i--) {
65
  var cur = ranges[i].head;
66
- cm.replaceRange("", Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1));
67
  }
68
  }
69
 
63
  }
64
  for (var i = ranges.length - 1; i >= 0; i--) {
65
  var cur = ranges[i].head;
66
+ cm.replaceRange("", Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1), "+delete");
67
  }
68
  }
69
 
js/esites_editor/dist/js/vendor/codemirror/addon/fold/comment-fold.js CHANGED
@@ -28,7 +28,9 @@ CodeMirror.registerGlobalHelper("fold", "comment", function(mode) {
28
  continue;
29
  }
30
  if (pass == 1 && found < start.ch) return;
31
- if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1)))) {
 
 
32
  startCh = found + startToken.length;
33
  break;
34
  }
28
  continue;
29
  }
30
  if (pass == 1 && found < start.ch) return;
31
+ if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1))) &&
32
+ (lineText.slice(found - endToken.length, found) == endToken ||
33
+ !/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found))))) {
34
  startCh = found + startToken.length;
35
  break;
36
  }
js/esites_editor/dist/js/vendor/codemirror/addon/fold/foldgutter.js CHANGED
@@ -20,7 +20,7 @@
20
  cm.off("viewportChange", onViewportChange);
21
  cm.off("fold", onFold);
22
  cm.off("unfold", onFold);
23
- cm.off("swapDoc", updateInViewport);
24
  }
25
  if (val) {
26
  cm.state.foldGutter = new State(parseOptions(val));
@@ -30,7 +30,7 @@
30
  cm.on("viewportChange", onViewportChange);
31
  cm.on("fold", onFold);
32
  cm.on("unfold", onFold);
33
- cm.on("swapDoc", updateInViewport);
34
  }
35
  });
36
 
20
  cm.off("viewportChange", onViewportChange);
21
  cm.off("fold", onFold);
22
  cm.off("unfold", onFold);
23
+ cm.off("swapDoc", onChange);
24
  }
25
  if (val) {
26
  cm.state.foldGutter = new State(parseOptions(val));
30
  cm.on("viewportChange", onViewportChange);
31
  cm.on("fold", onFold);
32
  cm.on("unfold", onFold);
33
+ cm.on("swapDoc", onChange);
34
  }
35
  });
36
 
js/esites_editor/dist/js/vendor/codemirror/addon/hint/show-hint.js CHANGED
@@ -108,24 +108,22 @@
108
  },
109
 
110
  update: function(first) {
111
- if (this.tick == null) return;
112
- if (!this.options.hint.async) {
113
- this.finishUpdate(this.options.hint(this.cm, this.options), first);
114
- } else {
115
- var myTick = ++this.tick, self = this;
116
- this.options.hint(this.cm, function(data) {
117
- if (self.tick == myTick) self.finishUpdate(data, first);
118
- }, this.options);
119
- }
120
  },
121
 
122
  finishUpdate: function(data, first) {
123
  if (this.data) CodeMirror.signal(this.data, "update");
124
- if (data && this.data && CodeMirror.cmpPos(data.from, this.data.from)) data = null;
125
- this.data = data;
126
 
127
  var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle);
128
  if (this.widget) this.widget.close();
 
 
 
 
129
  if (data && data.list.length) {
130
  if (picked && data.list.length == 1) {
131
  this.pick(data, 0);
@@ -137,6 +135,11 @@
137
  }
138
  };
139
 
 
 
 
 
 
140
  function parseOptions(cm, pos, options) {
141
  var editor = cm.options.hintOptions;
142
  var out = {};
@@ -355,40 +358,31 @@
355
  return result
356
  }
357
 
 
 
 
 
 
 
 
 
 
 
358
  function resolveAutoHints(cm, pos) {
359
  var helpers = cm.getHelpers(pos, "hint"), words
360
  if (helpers.length) {
361
- var async = false, resolved
362
- for (var i = 0; i < helpers.length; i++) if (helpers[i].async) async = true
363
- if (async) {
364
- resolved = function(cm, callback, options) {
365
- var app = applicableHelpers(cm, helpers)
366
- function run(i, result) {
367
- if (i == app.length) return callback(null)
368
- var helper = app[i]
369
- if (helper.async) {
370
- helper(cm, function(result) {
371
- if (result) callback(result)
372
- else run(i + 1)
373
- }, options)
374
- } else {
375
- var result = helper(cm, options)
376
- if (result) callback(result)
377
- else run(i + 1)
378
- }
379
- }
380
- run(0)
381
- }
382
- resolved.async = true
383
- } else {
384
- resolved = function(cm, options) {
385
- var app = applicableHelpers(cm, helpers)
386
- for (var i = 0; i < app.length; i++) {
387
- var cur = app[i](cm, options)
388
- if (cur && cur.list.length) return cur
389
- }
390
  }
 
391
  }
 
392
  resolved.supportsSelection = true
393
  return resolved
394
  } else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
@@ -430,7 +424,7 @@
430
  alignWithWord: true,
431
  closeCharacters: /[\s()\[\]{};:>,]/,
432
  closeOnUnfocus: true,
433
- completeOnSingleClick: false,
434
  container: null,
435
  customKeys: null,
436
  extraKeys: null
108
  },
109
 
110
  update: function(first) {
111
+ if (this.tick == null) return
112
+ var self = this, myTick = ++this.tick
113
+ fetchHints(this.options.hint, this.cm, this.options, function(data) {
114
+ if (self.tick == myTick) self.finishUpdate(data, first)
115
+ })
 
 
 
 
116
  },
117
 
118
  finishUpdate: function(data, first) {
119
  if (this.data) CodeMirror.signal(this.data, "update");
 
 
120
 
121
  var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle);
122
  if (this.widget) this.widget.close();
123
+
124
+ if (data && this.data && isNewCompletion(this.data, data)) return;
125
+ this.data = data;
126
+
127
  if (data && data.list.length) {
128
  if (picked && data.list.length == 1) {
129
  this.pick(data, 0);
135
  }
136
  };
137
 
138
+ function isNewCompletion(old, nw) {
139
+ var moved = CodeMirror.cmpPos(nw.from, old.from)
140
+ return moved > 0 && old.to.ch - old.from.ch != nw.to.ch - nw.from.ch
141
+ }
142
+
143
  function parseOptions(cm, pos, options) {
144
  var editor = cm.options.hintOptions;
145
  var out = {};
358
  return result
359
  }
360
 
361
+ function fetchHints(hint, cm, options, callback) {
362
+ if (hint.async) {
363
+ hint(cm, callback, options)
364
+ } else {
365
+ var result = hint(cm, options)
366
+ if (result && result.then) result.then(callback)
367
+ else callback(result)
368
+ }
369
+ }
370
+
371
  function resolveAutoHints(cm, pos) {
372
  var helpers = cm.getHelpers(pos, "hint"), words
373
  if (helpers.length) {
374
+ var resolved = function(cm, callback, options) {
375
+ var app = applicableHelpers(cm, helpers);
376
+ function run(i) {
377
+ if (i == app.length) return callback(null)
378
+ fetchHints(app[i], cm, options, function(result) {
379
+ if (result && result.list.length > 0) callback(result)
380
+ else run(i + 1)
381
+ })
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
382
  }
383
+ run(0)
384
  }
385
+ resolved.async = true
386
  resolved.supportsSelection = true
387
  return resolved
388
  } else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
424
  alignWithWord: true,
425
  closeCharacters: /[\s()\[\]{};:>,]/,
426
  closeOnUnfocus: true,
427
+ completeOnSingleClick: true,
428
  container: null,
429
  customKeys: null,
430
  extraKeys: null
js/esites_editor/dist/js/vendor/codemirror/addon/hint/sql-hint.js CHANGED
@@ -20,6 +20,8 @@
20
  };
21
  var Pos = CodeMirror.Pos;
22
 
 
 
23
  function getKeywords(editor) {
24
  var mode = editor.doc.modeOption;
25
  if (mode === "sql") mode = "text/x-sql";
@@ -30,10 +32,28 @@
30
  return typeof item == "string" ? item : item.text;
31
  }
32
 
33
- function getItem(list, item) {
34
- if (!list.slice) return list[item];
35
- for (var i = list.length - 1; i >= 0; i--) if (getText(list[i]) == item)
36
- return list[i];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  }
38
 
39
  function shallowClone(object) {
@@ -50,11 +70,18 @@
50
  }
51
 
52
  function addMatches(result, search, wordlist, formatter) {
53
- for (var word in wordlist) {
54
- if (!wordlist.hasOwnProperty(word)) continue;
55
- if (wordlist.slice) word = wordlist[word];
56
-
57
- if (match(search, word)) result.push(formatter(word));
 
 
 
 
 
 
 
58
  }
59
  }
60
 
@@ -78,7 +105,7 @@
78
  }
79
 
80
  function nameCompletion(cur, token, result, editor) {
81
- // Try to complete table, colunm names and return start position of completion
82
  var useBacktick = false;
83
  var nameParts = [];
84
  var start = token.start;
@@ -115,13 +142,13 @@
115
  var alias = false;
116
  var aliasTable = table;
117
  // Check if table is available. If not, find table by Alias
118
- if (!getItem(tables, table)) {
119
  var oldTable = table;
120
  table = findTableByAlias(table, editor);
121
  if (table !== oldTable) alias = true;
122
  }
123
 
124
- var columns = getItem(tables, table);
125
  if (columns && columns.columns)
126
  columns = columns.columns;
127
 
@@ -184,7 +211,7 @@
184
  //find valid range
185
  var prevItem = 0;
186
  var current = convertCurToNumber(editor.getCursor());
187
- for (var i=0; i< separator.length; i++) {
188
  var _v = convertCurToNumber(separator[i]);
189
  if (current > prevItem && current <= _v) {
190
  validRange = { start: convertNumberToCur(prevItem), end: convertNumberToCur(_v) };
@@ -199,7 +226,7 @@
199
  var lineText = query[i];
200
  eachWord(lineText, function(word) {
201
  var wordUpperCase = word.toUpperCase();
202
- if (wordUpperCase === aliasUpperCase && getItem(tables, previousWord))
203
  table = previousWord;
204
  if (wordUpperCase !== CONS.ALIAS_KEYWORD)
205
  previousWord = word;
@@ -210,10 +237,10 @@
210
  }
211
 
212
  CodeMirror.registerHelper("hint", "sql", function(editor, options) {
213
- tables = (options && options.tables) || {};
214
  var defaultTableName = options && options.defaultTable;
215
  var disableKeywords = options && options.disableKeywords;
216
- defaultTable = defaultTableName && getItem(tables, defaultTableName);
217
  keywords = keywords || getKeywords(editor);
218
 
219
  if (defaultTableName && !defaultTable)
20
  };
21
  var Pos = CodeMirror.Pos;
22
 
23
+ function isArray(val) { return Object.prototype.toString.call(val) == "[object Array]" }
24
+
25
  function getKeywords(editor) {
26
  var mode = editor.doc.modeOption;
27
  if (mode === "sql") mode = "text/x-sql";
32
  return typeof item == "string" ? item : item.text;
33
  }
34
 
35
+ function wrapTable(name, value) {
36
+ if (isArray(value)) value = {columns: value}
37
+ if (!value.text) value.text = name
38
+ return value
39
+ }
40
+
41
+ function parseTables(input) {
42
+ var result = {}
43
+ if (isArray(input)) {
44
+ for (var i = input.length - 1; i >= 0; i--) {
45
+ var item = input[i]
46
+ result[getText(item).toUpperCase()] = wrapTable(getText(item), item)
47
+ }
48
+ } else if (input) {
49
+ for (var name in input)
50
+ result[name.toUpperCase()] = wrapTable(name, input[name])
51
+ }
52
+ return result
53
+ }
54
+
55
+ function getTable(name) {
56
+ return tables[name.toUpperCase()]
57
  }
58
 
59
  function shallowClone(object) {
70
  }
71
 
72
  function addMatches(result, search, wordlist, formatter) {
73
+ if (isArray(wordlist)) {
74
+ for (var i = 0; i < wordlist.length; i++)
75
+ if (match(search, wordlist[i])) result.push(formatter(wordlist[i]))
76
+ } else {
77
+ for (var word in wordlist) if (wordlist.hasOwnProperty(word)) {
78
+ var val = wordlist[word]
79
+ if (!val || val === true)
80
+ val = word
81
+ else
82
+ val = val.displayText ? {text: val.text, displayText: val.displayText} : val.text
83
+ if (match(search, val)) result.push(formatter(val))
84
+ }
85
  }
86
  }
87
 
105
  }
106
 
107
  function nameCompletion(cur, token, result, editor) {
108
+ // Try to complete table, column names and return start position of completion
109
  var useBacktick = false;
110
  var nameParts = [];
111
  var start = token.start;
142
  var alias = false;
143
  var aliasTable = table;
144
  // Check if table is available. If not, find table by Alias
145
+ if (!getTable(table)) {
146
  var oldTable = table;
147
  table = findTableByAlias(table, editor);
148
  if (table !== oldTable) alias = true;
149
  }
150
 
151
+ var columns = getTable(table);
152
  if (columns && columns.columns)
153
  columns = columns.columns;
154
 
211
  //find valid range
212
  var prevItem = 0;
213
  var current = convertCurToNumber(editor.getCursor());
214
+ for (var i = 0; i < separator.length; i++) {
215
  var _v = convertCurToNumber(separator[i]);
216
  if (current > prevItem && current <= _v) {
217
  validRange = { start: convertNumberToCur(prevItem), end: convertNumberToCur(_v) };
226
  var lineText = query[i];
227
  eachWord(lineText, function(word) {
228
  var wordUpperCase = word.toUpperCase();
229
+ if (wordUpperCase === aliasUpperCase && getTable(previousWord))
230
  table = previousWord;
231
  if (wordUpperCase !== CONS.ALIAS_KEYWORD)
232
  previousWord = word;
237
  }
238
 
239
  CodeMirror.registerHelper("hint", "sql", function(editor, options) {
240
+ tables = parseTables(options && options.tables)
241
  var defaultTableName = options && options.defaultTable;
242
  var disableKeywords = options && options.disableKeywords;
243
+ defaultTable = defaultTableName && getTable(defaultTableName);
244
  keywords = keywords || getKeywords(editor);
245
 
246
  if (defaultTableName && !defaultTable)
js/esites_editor/dist/js/vendor/codemirror/addon/lint/lint.js CHANGED
@@ -186,9 +186,14 @@
186
  state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500);
187
  }
188
 
189
- function popupSpanTooltip(ann, e) {
190
  var target = e.target || e.srcElement;
191
- showTooltipFor(e, annotationTooltip(ann), target);
 
 
 
 
 
192
  }
193
 
194
  function onMouseOver(cm, e) {
@@ -196,10 +201,13 @@
196
  if (!/\bCodeMirror-lint-mark-/.test(target.className)) return;
197
  var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2;
198
  var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client"));
 
 
199
  for (var i = 0; i < spans.length; ++i) {
200
  var ann = spans[i].__annotation;
201
- if (ann) return popupSpanTooltip(ann, e);
202
  }
 
203
  }
204
 
205
  CodeMirror.defineOption("lint", false, function(cm, val, old) {
186
  state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500);
187
  }
188
 
189
+ function popupTooltips(annotations, e) {
190
  var target = e.target || e.srcElement;
191
+ var tooltip = document.createDocumentFragment();
192
+ for (var i = 0; i < annotations.length; i++) {
193
+ var ann = annotations[i];
194
+ tooltip.appendChild(annotationTooltip(ann));
195
+ }
196
+ showTooltipFor(e, tooltip, target);
197
  }
198
 
199
  function onMouseOver(cm, e) {
201
  if (!/\bCodeMirror-lint-mark-/.test(target.className)) return;
202
  var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2;
203
  var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client"));
204
+
205
+ var annotations = [];
206
  for (var i = 0; i < spans.length; ++i) {
207
  var ann = spans[i].__annotation;
208
+ if (ann) annotations.push(ann);
209
  }
210
+ if (annotations.length) popupTooltips(annotations, e);
211
  }
212
 
213
  CodeMirror.defineOption("lint", false, function(cm, val, old) {
js/esites_editor/dist/js/vendor/codemirror/addon/merge/merge.css CHANGED
@@ -60,6 +60,7 @@
60
  position: absolute;
61
  cursor: pointer;
62
  color: #44c;
 
63
  }
64
 
65
  .CodeMirror-merge-copy-reverse {
60
  position: absolute;
61
  cursor: pointer;
62
  color: #44c;
63
+ z-index: 3;
64
  }
65
 
66
  .CodeMirror-merge-copy-reverse {
js/esites_editor/dist/js/vendor/codemirror/addon/merge/merge.js CHANGED
@@ -427,8 +427,9 @@
427
 
428
  function copyChunk(dv, to, from, chunk) {
429
  if (dv.diffOutOfDate) return;
430
- to.replaceRange(from.getRange(Pos(chunk.origFrom, 0), Pos(chunk.origTo, 0)),
431
- Pos(chunk.editFrom, 0), Pos(chunk.editTo, 0));
 
432
  }
433
 
434
  // Merge view, containing 0, 1, or 2 diff views.
427
 
428
  function copyChunk(dv, to, from, chunk) {
429
  if (dv.diffOutOfDate) return;
430
+ var editStart = chunk.editTo > to.lastLine() ? Pos(chunk.editFrom - 1) : Pos(chunk.editFrom, 0)
431
+ var origStart = chunk.origTo > from.lastLine() ? Pos(chunk.origFrom - 1) : Pos(chunk.origFrom, 0)
432
+ to.replaceRange(from.getRange(origStart, Pos(chunk.origTo, 0)), editStart, Pos(chunk.editTo, 0))
433
  }
434
 
435
  // Merge view, containing 0, 1, or 2 diff views.
js/esites_editor/dist/js/vendor/codemirror/addon/mode/simple.js CHANGED
@@ -60,7 +60,7 @@
60
 
61
  function ensureState(states, name) {
62
  if (!states.hasOwnProperty(name))
63
- throw new Error("Undefined state " + name + "in simple mode");
64
  }
65
 
66
  function toRegex(val, caret) {
60
 
61
  function ensureState(states, name) {
62
  if (!states.hasOwnProperty(name))
63
+ throw new Error("Undefined state " + name + " in simple mode");
64
  }
65
 
66
  function toRegex(val, caret) {
js/esites_editor/dist/js/vendor/codemirror/addon/runmode/runmode.js CHANGED
@@ -16,7 +16,7 @@ CodeMirror.runMode = function(string, modespec, callback, options) {
16
  var ie = /MSIE \d/.test(navigator.userAgent);
17
  var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9);
18
 
19
- if (callback.nodeType == 1) {
20
  var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize;
21
  var node = callback, col = 0;
22
  node.innerHTML = "";
16
  var ie = /MSIE \d/.test(navigator.userAgent);
17
  var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9);
18
 
19
+ if (callback.appendChild) {
20
  var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize;
21
  var node = callback, col = 0;
22
  node.innerHTML = "";
js/esites_editor/dist/js/vendor/codemirror/addon/runmode/runmode.node.js CHANGED
@@ -176,3 +176,4 @@ exports.runMode = function(string, modespec, callback, options) {
176
  };
177
 
178
  require.cache[require.resolve("../../lib/codemirror")] = require.cache[require.resolve("./runmode.node")];
 
176
  };
177
 
178
  require.cache[require.resolve("../../lib/codemirror")] = require.cache[require.resolve("./runmode.node")];
179
+ require.cache[require.resolve("../../addon/runmode/runmode")] = require.cache[require.resolve("./runmode.node")];
js/esites_editor/dist/js/vendor/codemirror/addon/scroll/annotatescrollbar.js CHANGED
@@ -51,7 +51,7 @@
51
  Annotation.prototype.computeScale = function() {
52
  var cm = this.cm;
53
  var hScale = (cm.getWrapperElement().clientHeight - cm.display.barHeight - this.buttonHeight * 2) /
54
- cm.heightAtLine(cm.lastLine() + 1, "local");
55
  if (hScale != this.hScale) {
56
  this.hScale = hScale;
57
  return true;
@@ -100,6 +100,9 @@
100
  elt.style.cssText = "position: absolute; right: 0px; width: " + Math.max(cm.display.barWidth - 1, 2) + "px; top: "
101
  + (top + this.buttonHeight) + "px; height: " + height + "px";
102
  elt.className = this.options.className;
 
 
 
103
  }
104
  this.div.textContent = "";
105
  this.div.appendChild(frag);
51
  Annotation.prototype.computeScale = function() {
52
  var cm = this.cm;
53
  var hScale = (cm.getWrapperElement().clientHeight - cm.display.barHeight - this.buttonHeight * 2) /
54
+ cm.getScrollerElement().scrollHeight
55
  if (hScale != this.hScale) {
56
  this.hScale = hScale;
57
  return true;
100
  elt.style.cssText = "position: absolute; right: 0px; width: " + Math.max(cm.display.barWidth - 1, 2) + "px; top: "
101
  + (top + this.buttonHeight) + "px; height: " + height + "px";
102
  elt.className = this.options.className;
103
+ if (ann.id) {
104
+ elt.setAttribute("annotation-id", ann.id);
105
+ }
106
  }
107
  this.div.textContent = "";
108
  this.div.appendChild(frag);
js/esites_editor/dist/js/vendor/codemirror/addon/scroll/simplescrollbars.js CHANGED
@@ -59,16 +59,20 @@
59
  CodeMirror.on(this.node, "DOMMouseScroll", onWheel);
60
  }
61
 
62
- Bar.prototype.moveTo = function(pos, update) {
63
  if (pos < 0) pos = 0;
64
  if (pos > this.total - this.screen) pos = this.total - this.screen;
65
- if (pos == this.pos) return;
66
  this.pos = pos;
67
  this.inner.style[this.orientation == "horizontal" ? "left" : "top"] =
68
  (pos * (this.size / this.total)) + "px";
69
- if (update !== false) this.scroll(pos, this.orientation);
70
  };
71
 
 
 
 
 
72
  var minButtonSize = 10;
73
 
74
  Bar.prototype.update = function(scrollSize, clientSize, barSize) {
@@ -83,8 +87,7 @@
83
  }
84
  this.inner.style[this.orientation == "horizontal" ? "width" : "height"] =
85
  buttonSize + "px";
86
- this.inner.style[this.orientation == "horizontal" ? "left" : "top"] =
87
- this.pos * (this.size / this.total) + "px";
88
  };
89
 
90
  function SimpleScrollbars(cls, place, scroll) {
@@ -111,7 +114,6 @@
111
  if (needsV) {
112
  this.vert.update(measure.scrollHeight, measure.clientHeight,
113
  measure.viewHeight - (needsH ? width : 0));
114
- this.vert.node.style.display = "block";
115
  this.vert.node.style.bottom = needsH ? width + "px" : "0";
116
  }
117
  if (needsH) {
@@ -125,11 +127,11 @@
125
  };
126
 
127
  SimpleScrollbars.prototype.setScrollTop = function(pos) {
128
- this.vert.moveTo(pos, false);
129
  };
130
 
131
  SimpleScrollbars.prototype.setScrollLeft = function(pos) {
132
- this.horiz.moveTo(pos, false);
133
  };
134
 
135
  SimpleScrollbars.prototype.clear = function() {
59
  CodeMirror.on(this.node, "DOMMouseScroll", onWheel);
60
  }
61
 
62
+ Bar.prototype.setPos = function(pos) {
63
  if (pos < 0) pos = 0;
64
  if (pos > this.total - this.screen) pos = this.total - this.screen;
65
+ if (pos == this.pos) return false;
66
  this.pos = pos;
67
  this.inner.style[this.orientation == "horizontal" ? "left" : "top"] =
68
  (pos * (this.size / this.total)) + "px";
69
+ return true
70
  };
71
 
72
+ Bar.prototype.moveTo = function(pos) {
73
+ if (this.setPos(pos)) this.scroll(pos, this.orientation);
74
+ }
75
+
76
  var minButtonSize = 10;
77
 
78
  Bar.prototype.update = function(scrollSize, clientSize, barSize) {
87
  }
88
  this.inner.style[this.orientation == "horizontal" ? "width" : "height"] =
89
  buttonSize + "px";
90
+ this.setPos(this.pos);
 
91
  };
92
 
93
  function SimpleScrollbars(cls, place, scroll) {
114
  if (needsV) {
115
  this.vert.update(measure.scrollHeight, measure.clientHeight,
116
  measure.viewHeight - (needsH ? width : 0));
 
117
  this.vert.node.style.bottom = needsH ? width + "px" : "0";
118
  }
119
  if (needsH) {
127
  };
128
 
129
  SimpleScrollbars.prototype.setScrollTop = function(pos) {
130
+ this.vert.setPos(pos);
131
  };
132
 
133
  SimpleScrollbars.prototype.setScrollLeft = function(pos) {
134
+ this.horiz.setPos(pos);
135
  };
136
 
137
  SimpleScrollbars.prototype.clear = function() {
js/esites_editor/dist/js/vendor/codemirror/addon/search/jump-to-line.js ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ // Defines jumpToLine command. Uses dialog.js if present.
5
+
6
+ (function(mod) {
7
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
8
+ mod(require("../../lib/codemirror"), require("../dialog/dialog"));
9
+ else if (typeof define == "function" && define.amd) // AMD
10
+ define(["../../lib/codemirror", "../dialog/dialog"], mod);
11
+ else // Plain browser env
12
+ mod(CodeMirror);
13
+ })(function(CodeMirror) {
14
+ "use strict";
15
+
16
+ function dialog(cm, text, shortText, deflt, f) {
17
+ if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true});
18
+ else f(prompt(shortText, deflt));
19
+ }
20
+
21
+ var jumpDialog =
22
+ 'Jump to line: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use line:column or scroll% syntax)</span>';
23
+
24
+ function interpretLine(cm, string) {
25
+ var num = Number(string)
26
+ if (/^[-+]/.test(string)) return cm.getCursor().line + num
27
+ else return num - 1
28
+ }
29
+
30
+ CodeMirror.commands.jumpToLine = function(cm) {
31
+ var cur = cm.getCursor();
32
+ dialog(cm, jumpDialog, "Jump to line:", (cur.line + 1) + ":" + cur.ch, function(posStr) {
33
+ if (!posStr) return;
34
+
35
+ var match;
36
+ if (match = /^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(posStr)) {
37
+ cm.setCursor(interpretLine(cm, match[1]), Number(match[2]))
38
+ } else if (match = /^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(posStr)) {
39
+ var line = Math.round(cm.lineCount() * Number(match[1]) / 100);
40
+ if (/^[-+]/.test(match[1])) line = cur.line + line + 1;
41
+ cm.setCursor(line - 1, cur.ch);
42
+ } else if (match = /^\s*\:?\s*([\+\-]?\d+)\s*/.exec(posStr)) {
43
+ cm.setCursor(interpretLine(cm, match[1]), cur.ch);
44
+ }
45
+ });
46
+ };
47
+
48
+ CodeMirror.keyMap["default"]["Alt-G"] = "jumpToLine";
49
+ });
js/esites_editor/dist/js/vendor/codemirror/addon/search/match-highlighter.js CHANGED
@@ -16,42 +16,40 @@
16
  // highlighted only if the selected text is a word. showToken, when enabled,
17
  // will cause the current token to be highlighted when nothing is selected.
18
  // delay is used to specify how much time to wait, in milliseconds, before
19
- // highlighting the matches.
 
20
 
21
  (function(mod) {
22
  if (typeof exports == "object" && typeof module == "object") // CommonJS
23
- mod(require("../../lib/codemirror"));
24
  else if (typeof define == "function" && define.amd) // AMD
25
- define(["../../lib/codemirror"], mod);
26
  else // Plain browser env
27
  mod(CodeMirror);
28
  })(function(CodeMirror) {
29
  "use strict";
30
 
31
- var DEFAULT_MIN_CHARS = 2;
32
- var DEFAULT_TOKEN_STYLE = "matchhighlight";
33
- var DEFAULT_DELAY = 100;
34
- var DEFAULT_WORDS_ONLY = false;
 
 
 
 
 
35
 
36
  function State(options) {
37
- if (typeof options == "object") {
38
- this.minChars = options.minChars;
39
- this.style = options.style;
40
- this.showToken = options.showToken;
41
- this.delay = options.delay;
42
- this.wordsOnly = options.wordsOnly;
43
- }
44
- if (this.style == null) this.style = DEFAULT_TOKEN_STYLE;
45
- if (this.minChars == null) this.minChars = DEFAULT_MIN_CHARS;
46
- if (this.delay == null) this.delay = DEFAULT_DELAY;
47
- if (this.wordsOnly == null) this.wordsOnly = DEFAULT_WORDS_ONLY;
48
  this.overlay = this.timeout = null;
 
49
  }
50
 
51
  CodeMirror.defineOption("highlightSelectionMatches", false, function(cm, val, old) {
52
  if (old && old != CodeMirror.Init) {
53
- var over = cm.state.matchHighlighter.overlay;
54
- if (over) cm.removeOverlay(over);
55
  clearTimeout(cm.state.matchHighlighter.timeout);
56
  cm.state.matchHighlighter = null;
57
  cm.off("cursorActivity", cursorActivity);
@@ -66,31 +64,51 @@
66
  function cursorActivity(cm) {
67
  var state = cm.state.matchHighlighter;
68
  clearTimeout(state.timeout);
69
- state.timeout = setTimeout(function() {highlightMatches(cm);}, state.delay);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  }
71
 
72
  function highlightMatches(cm) {
73
  cm.operation(function() {
74
  var state = cm.state.matchHighlighter;
75
- if (state.overlay) {
76
- cm.removeOverlay(state.overlay);
77
- state.overlay = null;
78
- }
79
- if (!cm.somethingSelected() && state.showToken) {
80
- var re = state.showToken === true ? /[\w$]/ : state.showToken;
81
  var cur = cm.getCursor(), line = cm.getLine(cur.line), start = cur.ch, end = start;
82
  while (start && re.test(line.charAt(start - 1))) --start;
83
  while (end < line.length && re.test(line.charAt(end))) ++end;
84
  if (start < end)
85
- cm.addOverlay(state.overlay = makeOverlay(line.slice(start, end), re, state.style));
86
  return;
87
  }
88
  var from = cm.getCursor("from"), to = cm.getCursor("to");
89
  if (from.line != to.line) return;
90
- if (state.wordsOnly && !isWord(cm, from, to)) return;
91
- var selection = cm.getRange(from, to).replace(/^\s+|\s+$/g, "");
92
- if (selection.length >= state.minChars)
93
- cm.addOverlay(state.overlay = makeOverlay(selection, false, state.style));
 
94
  });
95
  }
96
 
16
  // highlighted only if the selected text is a word. showToken, when enabled,
17
  // will cause the current token to be highlighted when nothing is selected.
18
  // delay is used to specify how much time to wait, in milliseconds, before
19
+ // highlighting the matches. If annotateScrollbar is enabled, the occurences
20
+ // will be highlighted on the scrollbar via the matchesonscrollbar addon.
21
 
22
  (function(mod) {
23
  if (typeof exports == "object" && typeof module == "object") // CommonJS
24
+ mod(require("../../lib/codemirror"), require("./matchesonscrollbar"));
25
  else if (typeof define == "function" && define.amd) // AMD
26
+ define(["../../lib/codemirror", "./matchesonscrollbar"], mod);
27
  else // Plain browser env
28
  mod(CodeMirror);
29
  })(function(CodeMirror) {
30
  "use strict";
31
 
32
+ var defaults = {
33
+ style: "matchhighlight",
34
+ minChars: 2,
35
+ delay: 100,
36
+ wordsOnly: false,
37
+ annotateScrollbar: false,
38
+ showToken: false,
39
+ trim: true
40
+ }
41
 
42
  function State(options) {
43
+ this.options = {}
44
+ for (var name in defaults)
45
+ this.options[name] = (options && options.hasOwnProperty(name) ? options : defaults)[name]
 
 
 
 
 
 
 
 
46
  this.overlay = this.timeout = null;
47
+ this.matchesonscroll = null;
48
  }
49
 
50
  CodeMirror.defineOption("highlightSelectionMatches", false, function(cm, val, old) {
51
  if (old && old != CodeMirror.Init) {
52
+ removeOverlay(cm);
 
53
  clearTimeout(cm.state.matchHighlighter.timeout);
54
  cm.state.matchHighlighter = null;
55
  cm.off("cursorActivity", cursorActivity);
64
  function cursorActivity(cm) {
65
  var state = cm.state.matchHighlighter;
66
  clearTimeout(state.timeout);
67
+ state.timeout = setTimeout(function() {highlightMatches(cm);}, state.options.delay);
68
+ }
69
+
70
+ function addOverlay(cm, query, hasBoundary, style) {
71
+ var state = cm.state.matchHighlighter;
72
+ cm.addOverlay(state.overlay = makeOverlay(query, hasBoundary, style));
73
+ if (state.options.annotateScrollbar && cm.showMatchesOnScrollbar) {
74
+ var searchFor = hasBoundary ? new RegExp("\\b" + query + "\\b") : query;
75
+ state.matchesonscroll = cm.showMatchesOnScrollbar(searchFor, true,
76
+ {className: "CodeMirror-selection-highlight-scrollbar"});
77
+ }
78
+ }
79
+
80
+ function removeOverlay(cm) {
81
+ var state = cm.state.matchHighlighter;
82
+ if (state.overlay) {
83
+ cm.removeOverlay(state.overlay);
84
+ state.overlay = null;
85
+ if (state.matchesonscroll) {
86
+ state.matchesonscroll.clear();
87
+ state.matchesonscroll = null;
88
+ }
89
+ }
90
  }
91
 
92
  function highlightMatches(cm) {
93
  cm.operation(function() {
94
  var state = cm.state.matchHighlighter;
95
+ removeOverlay(cm);
96
+ if (!cm.somethingSelected() && state.options.showToken) {
97
+ var re = state.options.showToken === true ? /[\w$]/ : state.options.showToken;
 
 
 
98
  var cur = cm.getCursor(), line = cm.getLine(cur.line), start = cur.ch, end = start;
99
  while (start && re.test(line.charAt(start - 1))) --start;
100
  while (end < line.length && re.test(line.charAt(end))) ++end;
101
  if (start < end)
102
+ addOverlay(cm, line.slice(start, end), re, state.options.style);
103
  return;
104
  }
105
  var from = cm.getCursor("from"), to = cm.getCursor("to");
106
  if (from.line != to.line) return;
107
+ if (state.options.wordsOnly && !isWord(cm, from, to)) return;
108
+ var selection = cm.getRange(from, to)
109
+ if (state.options.trim) selection = selection.replace(/^\s+|\s+$/g, "")
110
+ if (selection.length >= state.options.minChars)
111
+ addOverlay(cm, selection, false, state.options.style);
112
  });
113
  }
114
 
js/esites_editor/dist/js/vendor/codemirror/addon/search/search.js CHANGED
@@ -29,7 +29,7 @@
29
  query.lastIndex = stream.pos;
30
  var match = query.exec(stream.string);
31
  if (match && match.index == stream.pos) {
32
- stream.pos += match[0].length;
33
  return "searching";
34
  } else if (match) {
35
  stream.pos = match.index;
@@ -121,7 +121,10 @@
121
  persistentDialog(cm, queryDialog, q, function(query, event) {
122
  CodeMirror.e_stop(event);
123
  if (!query) return;
124
- if (query != state.queryText) startSearch(cm, state, query);
 
 
 
125
  if (hiding) hiding.style.opacity = 1
126
  findNext(cm, event.shiftKey, function(_, to) {
127
  var dialog
@@ -193,7 +196,7 @@
193
  replaceAll(cm, query, text)
194
  } else {
195
  clearSearch(cm);
196
- var cursor = getSearchCursor(cm, query, cm.getCursor());
197
  var advance = function() {
198
  var start = cursor.from(), match;
199
  if (!(match = cursor.findNext())) {
29
  query.lastIndex = stream.pos;
30
  var match = query.exec(stream.string);
31
  if (match && match.index == stream.pos) {
32
+ stream.pos += match[0].length || 1;
33
  return "searching";
34
  } else if (match) {
35
  stream.pos = match.index;
121
  persistentDialog(cm, queryDialog, q, function(query, event) {
122
  CodeMirror.e_stop(event);
123
  if (!query) return;
124
+ if (query != state.queryText) {
125
+ startSearch(cm, state, query);
126
+ state.posFrom = state.posTo = cm.getCursor();
127
+ }
128
  if (hiding) hiding.style.opacity = 1
129
  findNext(cm, event.shiftKey, function(_, to) {
130
  var dialog
196
  replaceAll(cm, query, text)
197
  } else {
198
  clearSearch(cm);
199
+ var cursor = getSearchCursor(cm, query, cm.getCursor("from"));
200
  var advance = function() {
201
  var start = cursor.from(), match;
202
  if (!(match = cursor.findNext())) {
js/esites_editor/dist/js/vendor/codemirror/addon/selection/active-line.js CHANGED
@@ -18,6 +18,7 @@
18
  "use strict";
19
  var WRAP_CLASS = "CodeMirror-activeline";
20
  var BACK_CLASS = "CodeMirror-activeline-background";
 
21
 
22
  CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) {
23
  var prev = old && old != CodeMirror.Init;
@@ -36,6 +37,7 @@
36
  for (var i = 0; i < cm.state.activeLines.length; i++) {
37
  cm.removeLineClass(cm.state.activeLines[i], "wrap", WRAP_CLASS);
38
  cm.removeLineClass(cm.state.activeLines[i], "background", BACK_CLASS);
 
39
  }
40
  }
41
 
@@ -60,6 +62,7 @@
60
  for (var i = 0; i < active.length; i++) {
61
  cm.addLineClass(active[i], "wrap", WRAP_CLASS);
62
  cm.addLineClass(active[i], "background", BACK_CLASS);
 
63
  }
64
  cm.state.activeLines = active;
65
  });
18
  "use strict";
19
  var WRAP_CLASS = "CodeMirror-activeline";
20
  var BACK_CLASS = "CodeMirror-activeline-background";
21
+ var GUTT_CLASS = "CodeMirror-activeline-gutter";
22
 
23
  CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) {
24
  var prev = old && old != CodeMirror.Init;
37
  for (var i = 0; i < cm.state.activeLines.length; i++) {
38
  cm.removeLineClass(cm.state.activeLines[i], "wrap", WRAP_CLASS);
39
  cm.removeLineClass(cm.state.activeLines[i], "background", BACK_CLASS);
40
+ cm.removeLineClass(cm.state.activeLines[i], "gutter", GUTT_CLASS);
41
  }
42
  }
43
 
62
  for (var i = 0; i < active.length; i++) {
63
  cm.addLineClass(active[i], "wrap", WRAP_CLASS);
64
  cm.addLineClass(active[i], "background", BACK_CLASS);
65
+ cm.addLineClass(active[i], "gutter", GUTT_CLASS);
66
  }
67
  cm.state.activeLines = active;
68
  });
js/esites_editor/dist/js/vendor/codemirror/addon/tern/tern.js CHANGED
@@ -135,6 +135,7 @@
135
  },
136
 
137
  destroy: function () {
 
138
  if (this.worker) {
139
  this.worker.terminate();
140
  this.worker = null;
@@ -178,7 +179,7 @@
178
  var data = findDoc(ts, doc);
179
 
180
  var argHints = ts.cachedArgHints;
181
- if (argHints && argHints.doc == doc && cmpPos(argHints.start, change.to) <= 0)
182
  ts.cachedArgHints = null;
183
 
184
  var changed = data.changed;
@@ -305,7 +306,7 @@
305
  ts.request(cm, {type: "type", preferFunction: true, end: start}, function(error, data) {
306
  if (error || !data.type || !(/^fn\(/).test(data.type)) return;
307
  ts.cachedArgHints = {
308
- start: pos,
309
  type: parseFnType(data.type),
310
  name: data.exprName || data.name || "fn",
311
  guess: data.guess,
135
  },
136
 
137
  destroy: function () {
138
+ closeArgHints(this)
139
  if (this.worker) {
140
  this.worker.terminate();
141
  this.worker = null;
179
  var data = findDoc(ts, doc);
180
 
181
  var argHints = ts.cachedArgHints;
182
+ if (argHints && argHints.doc == doc && cmpPos(argHints.start, change.to) >= 0)
183
  ts.cachedArgHints = null;
184
 
185
  var changed = data.changed;
306
  ts.request(cm, {type: "type", preferFunction: true, end: start}, function(error, data) {
307
  if (error || !data.type || !(/^fn\(/).test(data.type)) return;
308
  ts.cachedArgHints = {
309
+ start: start,
310
  type: parseFnType(data.type),
311
  name: data.exprName || data.name || "fn",
312
  guess: data.guess,
js/esites_editor/dist/js/vendor/codemirror/keymap/sublime.js CHANGED
@@ -1 +1 @@
1
- !function(mod){"object"==typeof exports&&"object"==typeof module?mod(require("../lib/codemirror"),require("../addon/search/searchcursor"),require("../addon/edit/matchbrackets")):"function"==typeof define&&define.amd?define(["../lib/codemirror","../addon/search/searchcursor","../addon/edit/matchbrackets"],mod):mod(CodeMirror)}(function(CodeMirror){"use strict";function findPosSubword(doc,start,dir){if(0>dir&&0==start.ch)return doc.clipPos(Pos(start.line-1));var line=doc.getLine(start.line);if(dir>0&&start.ch>=line.length)return doc.clipPos(Pos(start.line+1,0));for(var type,state="start",pos=start.ch,e=0>dir?0:line.length,i=0;pos!=e;pos+=dir,i++){var next=line.charAt(0>dir?pos-1:pos),cat="_"!=next&&CodeMirror.isWordChar(next)?"w":"o";"w"==cat&&next.toUpperCase()==next&&(cat="W");if("start"==state){if("o"!=cat){state="in";type=cat}}else if("in"==state&&type!=cat){"w"==type&&"W"==cat&&0>dir&&pos--;if("W"==type&&"w"==cat&&dir>0){type="w";continue}break}}return Pos(start.line,pos)}function moveSubword(cm,dir){cm.extendSelectionsBy(function(range){return cm.display.shift||cm.doc.extend||range.empty()?findPosSubword(cm.doc,range.head,dir):0>dir?range.from():range.to()})}function insertLine(cm,above){cm.operation(function(){for(var len=cm.listSelections().length,newSelection=[],last=-1,i=0;len>i;i++){var head=cm.listSelections()[i].head;if(!(head.line<=last)){var at=Pos(head.line+(above?0:1),0);cm.replaceRange("\n",at,null,"+insertLine");cm.indentLine(at.line,null,!0);newSelection.push({head:at,anchor:at});last=head.line+1}}cm.setSelections(newSelection)})}function wordAt(cm,pos){for(var start=pos.ch,end=start,line=cm.getLine(pos.line);start&&CodeMirror.isWordChar(line.charAt(start-1));)--start;for(;end<line.length&&CodeMirror.isWordChar(line.charAt(end));)++end;return{from:Pos(pos.line,start),to:Pos(pos.line,end),word:line.slice(start,end)}}function selectBetweenBrackets(cm){var pos=cm.getCursor(),opening=cm.scanForBracket(pos,-1);if(opening)for(;;){var closing=cm.scanForBracket(pos,1);if(!closing)return;if(closing.ch==mirror.charAt(mirror.indexOf(opening.ch)+1)){cm.setSelection(Pos(opening.pos.line,opening.pos.ch+1),closing.pos,!1);return!0}pos=Pos(closing.pos.line,closing.pos.ch+1)}}function sortLines(cm,caseSensitive){for(var selected,ranges=cm.listSelections(),toSort=[],i=0;i<ranges.length;i++){var range=ranges[i];if(!range.empty()){for(var from=range.from().line,to=range.to().line;i<ranges.length-1&&ranges[i+1].from().line==to;)to=range[++i].to().line;toSort.push(from,to)}}toSort.length?selected=!0:toSort.push(cm.firstLine(),cm.lastLine());cm.operation(function(){for(var ranges=[],i=0;i<toSort.length;i+=2){var from=toSort[i],to=toSort[i+1],start=Pos(from,0),end=Pos(to),lines=cm.getRange(start,end,!1);caseSensitive?lines.sort():lines.sort(function(a,b){var au=a.toUpperCase(),bu=b.toUpperCase();if(au!=bu){a=au;b=bu}return b>a?-1:a==b?0:1});cm.replaceRange(lines,start,end);selected&&ranges.push({anchor:start,head:end})}selected&&cm.setSelections(ranges,0)})}function modifyWordOrSelection(cm,mod){cm.operation(function(){for(var ranges=cm.listSelections(),indices=[],replacements=[],i=0;i<ranges.length;i++){var range=ranges[i];if(range.empty()){indices.push(i);replacements.push("")}else replacements.push(mod(cm.getRange(range.from(),range.to())))}cm.replaceSelections(replacements,"around","case");for(var at,i=indices.length-1;i>=0;i--){var range=ranges[indices[i]];if(!(at&&CodeMirror.cmpPos(range.head,at)>0)){var word=wordAt(cm,range.head);at=word.from;cm.replaceRange(mod(word.word),word.from,word.to)}}})}function getTarget(cm){var from=cm.getCursor("from"),to=cm.getCursor("to");if(0==CodeMirror.cmpPos(from,to)){var word=wordAt(cm,from);if(!word.word)return;from=word.from;to=word.to}return{from:from,to:to,query:cm.getRange(from,to),word:word}}function findAndGoTo(cm,forward){var target=getTarget(cm);if(target){var query=target.query,cur=cm.getSearchCursor(query,forward?target.to:target.from);if(forward?cur.findNext():cur.findPrevious())cm.setSelection(cur.from(),cur.to());else{cur=cm.getSearchCursor(query,forward?Pos(cm.firstLine(),0):cm.clipPos(Pos(cm.lastLine())));(forward?cur.findNext():cur.findPrevious())?cm.setSelection(cur.from(),cur.to()):target.word&&cm.setSelection(target.from,target.to)}}}var map=CodeMirror.keyMap.sublime={fallthrough:"default"},cmds=CodeMirror.commands,Pos=CodeMirror.Pos,mac=CodeMirror.keyMap["default"]==CodeMirror.keyMap.macDefault,ctrl=mac?"Cmd-":"Ctrl-";cmds[map["Alt-Left"]="goSubwordLeft"]=function(cm){moveSubword(cm,-1)};cmds[map["Alt-Right"]="goSubwordRight"]=function(cm){moveSubword(cm,1)};var scrollLineCombo=mac?"Ctrl-Alt-":"Ctrl-";cmds[map[scrollLineCombo+"Up"]="scrollLineUp"]=function(cm){var info=cm.getScrollInfo();if(!cm.somethingSelected()){var visibleBottomLine=cm.lineAtHeight(info.top+info.clientHeight,"local");cm.getCursor().line>=visibleBottomLine&&cm.execCommand("goLineUp")}cm.scrollTo(null,info.top-cm.defaultTextHeight())};cmds[map[scrollLineCombo+"Down"]="scrollLineDown"]=function(cm){var info=cm.getScrollInfo();if(!cm.somethingSelected()){var visibleTopLine=cm.lineAtHeight(info.top,"local")+1;cm.getCursor().line<=visibleTopLine&&cm.execCommand("goLineDown")}cm.scrollTo(null,info.top+cm.defaultTextHeight())};cmds[map["Shift-"+ctrl+"L"]="splitSelectionByLine"]=function(cm){for(var ranges=cm.listSelections(),lineRanges=[],i=0;i<ranges.length;i++)for(var from=ranges[i].from(),to=ranges[i].to(),line=from.line;line<=to.line;++line)to.line>from.line&&line==to.line&&0==to.ch||lineRanges.push({anchor:line==from.line?from:Pos(line,0),head:line==to.line?to:Pos(line)});cm.setSelections(lineRanges,0)};map["Shift-Tab"]="indentLess";cmds[map.Esc="singleSelectionTop"]=function(cm){var range=cm.listSelections()[0];cm.setSelection(range.anchor,range.head,{scroll:!1})};cmds[map[ctrl+"L"]="selectLine"]=function(cm){for(var ranges=cm.listSelections(),extended=[],i=0;i<ranges.length;i++){var range=ranges[i];extended.push({anchor:Pos(range.from().line,0),head:Pos(range.to().line+1,0)})}cm.setSelections(extended)};map["Shift-"+ctrl+"K"]="deleteLine";cmds[map[ctrl+"Enter"]="insertLineAfter"]=function(cm){insertLine(cm,!1)};cmds[map["Shift-"+ctrl+"Enter"]="insertLineBefore"]=function(cm){insertLine(cm,!0)};cmds[map[ctrl+"D"]="selectNextOccurrence"]=function(cm){var from=cm.getCursor("from"),to=cm.getCursor("to"),fullWord=cm.state.sublimeFindFullWord==cm.doc.sel;if(0==CodeMirror.cmpPos(from,to)){var word=wordAt(cm,from);if(!word.word)return;cm.setSelection(word.from,word.to);fullWord=!0}else{var text=cm.getRange(from,to),query=fullWord?new RegExp("\\b"+text+"\\b"):text,cur=cm.getSearchCursor(query,to);if(cur.findNext())cm.addSelection(cur.from(),cur.to());else{cur=cm.getSearchCursor(query,Pos(cm.firstLine(),0));cur.findNext()&&cm.addSelection(cur.from(),cur.to())}}fullWord&&(cm.state.sublimeFindFullWord=cm.doc.sel)};var mirror="(){}[]";cmds[map["Shift-"+ctrl+"Space"]="selectScope"]=function(cm){selectBetweenBrackets(cm)||cm.execCommand("selectAll")};cmds[map["Shift-"+ctrl+"M"]="selectBetweenBrackets"]=function(cm){return selectBetweenBrackets(cm)?void 0:CodeMirror.Pass};cmds[map[ctrl+"M"]="goToBracket"]=function(cm){cm.extendSelectionsBy(function(range){var next=cm.scanForBracket(range.head,1);if(next&&0!=CodeMirror.cmpPos(next.pos,range.head))return next.pos;var prev=cm.scanForBracket(range.head,-1);return prev&&Pos(prev.pos.line,prev.pos.ch+1)||range.head})};var swapLineCombo=mac?"Cmd-Ctrl-":"Shift-Ctrl-";cmds[map[swapLineCombo+"Up"]="swapLineUp"]=function(cm){for(var ranges=cm.listSelections(),linesToMove=[],at=cm.firstLine()-1,newSels=[],i=0;i<ranges.length;i++){var range=ranges[i],from=range.from().line-1,to=range.to().line;newSels.push({anchor:Pos(range.anchor.line-1,range.anchor.ch),head:Pos(range.head.line-1,range.head.ch)});0!=range.to().ch||range.empty()||--to;from>at?linesToMove.push(from,to):linesToMove.length&&(linesToMove[linesToMove.length-1]=to);at=to}cm.operation(function(){for(var i=0;i<linesToMove.length;i+=2){var from=linesToMove[i],to=linesToMove[i+1],line=cm.getLine(from);cm.replaceRange("",Pos(from,0),Pos(from+1,0),"+swapLine");to>cm.lastLine()?cm.replaceRange("\n"+line,Pos(cm.lastLine()),null,"+swapLine"):cm.replaceRange(line+"\n",Pos(to,0),null,"+swapLine")}cm.setSelections(newSels);cm.scrollIntoView()})};cmds[map[swapLineCombo+"Down"]="swapLineDown"]=function(cm){for(var ranges=cm.listSelections(),linesToMove=[],at=cm.lastLine()+1,i=ranges.length-1;i>=0;i--){var range=ranges[i],from=range.to().line+1,to=range.from().line;0!=range.to().ch||range.empty()||from--;at>from?linesToMove.push(from,to):linesToMove.length&&(linesToMove[linesToMove.length-1]=to);at=to}cm.operation(function(){for(var i=linesToMove.length-2;i>=0;i-=2){var from=linesToMove[i],to=linesToMove[i+1],line=cm.getLine(from);from==cm.lastLine()?cm.replaceRange("",Pos(from-1),Pos(from),"+swapLine"):cm.replaceRange("",Pos(from,0),Pos(from+1,0),"+swapLine");cm.replaceRange(line+"\n",Pos(to,0),null,"+swapLine")}cm.scrollIntoView()})};map[ctrl+"/"]=function(cm){cm.toggleComment({indent:!0})};cmds[map[ctrl+"J"]="joinLines"]=function(cm){for(var ranges=cm.listSelections(),joined=[],i=0;i<ranges.length;i++){for(var range=ranges[i],from=range.from(),start=from.line,end=range.to().line;i<ranges.length-1&&ranges[i+1].from().line==end;)end=ranges[++i].to().line;joined.push({start:start,end:end,anchor:!range.empty()&&from})}cm.operation(function(){for(var offset=0,ranges=[],i=0;i<joined.length;i++){for(var head,obj=joined[i],anchor=obj.anchor&&Pos(obj.anchor.line-offset,obj.anchor.ch),line=obj.start;line<=obj.end;line++){var actual=line-offset;line==obj.end&&(head=Pos(actual,cm.getLine(actual).length+1));if(actual<cm.lastLine()){cm.replaceRange(" ",Pos(actual),Pos(actual+1,/^\s*/.exec(cm.getLine(actual+1))[0].length));++offset}}ranges.push({anchor:anchor||head,head:head})}cm.setSelections(ranges,0)})};cmds[map["Shift-"+ctrl+"D"]="duplicateLine"]=function(cm){cm.operation(function(){for(var rangeCount=cm.listSelections().length,i=0;rangeCount>i;i++){var range=cm.listSelections()[i];range.empty()?cm.replaceRange(cm.getLine(range.head.line)+"\n",Pos(range.head.line,0)):cm.replaceRange(cm.getRange(range.from(),range.to()),range.from())}cm.scrollIntoView()})};map[ctrl+"T"]="transposeChars";cmds[map.F9="sortLines"]=function(cm){sortLines(cm,!0)};cmds[map[ctrl+"F9"]="sortLinesInsensitive"]=function(cm){sortLines(cm,!1)};cmds[map.F2="nextBookmark"]=function(cm){var marks=cm.state.sublimeBookmarks;if(marks)for(;marks.length;){var current=marks.shift(),found=current.find();if(found){marks.push(current);return cm.setSelection(found.from,found.to)}}};cmds[map["Shift-F2"]="prevBookmark"]=function(cm){var marks=cm.state.sublimeBookmarks;if(marks)for(;marks.length;){marks.unshift(marks.pop());var found=marks[marks.length-1].find();if(found)return cm.setSelection(found.from,found.to);marks.pop()}};cmds[map[ctrl+"F2"]="toggleBookmark"]=function(cm){for(var ranges=cm.listSelections(),marks=cm.state.sublimeBookmarks||(cm.state.sublimeBookmarks=[]),i=0;i<ranges.length;i++){for(var from=ranges[i].from(),to=ranges[i].to(),found=cm.findMarks(from,to),j=0;j<found.length;j++)if(found[j].sublimeBookmark){found[j].clear();for(var k=0;k<marks.length;k++)marks[k]==found[j]&&marks.splice(k--,1);break}j==found.length&&marks.push(cm.markText(from,to,{sublimeBookmark:!0,clearWhenEmpty:!1}))}};cmds[map["Shift-"+ctrl+"F2"]="clearBookmarks"]=function(cm){var marks=cm.state.sublimeBookmarks;if(marks)for(var i=0;i<marks.length;i++)marks[i].clear();marks.length=0};cmds[map["Alt-F2"]="selectBookmarks"]=function(cm){var marks=cm.state.sublimeBookmarks,ranges=[];if(marks)for(var i=0;i<marks.length;i++){var found=marks[i].find();found?ranges.push({anchor:found.from,head:found.to}):marks.splice(i--,0)}ranges.length&&cm.setSelections(ranges,0)};map["Alt-Q"]="wrapLines";var cK=ctrl+"K ";map[cK+ctrl+"Backspace"]="delLineLeft";cmds[map.Backspace="smartBackspace"]=function(cm){if(cm.somethingSelected())return CodeMirror.Pass;var cursor=cm.getCursor(),toStartOfLine=cm.getRange({line:cursor.line,ch:0},cursor),column=CodeMirror.countColumn(toStartOfLine,null,cm.getOption("tabSize")),indentUnit=cm.getOption("indentUnit");if(toStartOfLine&&!/\S/.test(toStartOfLine)&&column%indentUnit==0){var prevIndent=new Pos(cursor.line,CodeMirror.findColumn(toStartOfLine,column-indentUnit,indentUnit));return prevIndent.ch==cursor.ch?CodeMirror.Pass:cm.replaceRange("",prevIndent,cursor,"+delete")}return CodeMirror.Pass};cmds[map[cK+ctrl+"K"]="delLineRight"]=function(cm){cm.operation(function(){for(var ranges=cm.listSelections(),i=ranges.length-1;i>=0;i--)cm.replaceRange("",ranges[i].anchor,Pos(ranges[i].to().line),"+delete");cm.scrollIntoView()})};cmds[map[cK+ctrl+"U"]="upcaseAtCursor"]=function(cm){modifyWordOrSelection(cm,function(str){return str.toUpperCase()})};cmds[map[cK+ctrl+"L"]="downcaseAtCursor"]=function(cm){modifyWordOrSelection(cm,function(str){return str.toLowerCase()})};cmds[map[cK+ctrl+"Space"]="setSublimeMark"]=function(cm){cm.state.sublimeMark&&cm.state.sublimeMark.clear();cm.state.sublimeMark=cm.setBookmark(cm.getCursor())};cmds[map[cK+ctrl+"A"]="selectToSublimeMark"]=function(cm){var found=cm.state.sublimeMark&&cm.state.sublimeMark.find();found&&cm.setSelection(cm.getCursor(),found)};cmds[map[cK+ctrl+"W"]="deleteToSublimeMark"]=function(cm){var found=cm.state.sublimeMark&&cm.state.sublimeMark.find();if(found){var from=cm.getCursor(),to=found;if(CodeMirror.cmpPos(from,to)>0){var tmp=to;to=from;from=tmp}cm.state.sublimeKilled=cm.getRange(from,to);cm.replaceRange("",from,to)}};cmds[map[cK+ctrl+"X"]="swapWithSublimeMark"]=function(cm){var found=cm.state.sublimeMark&&cm.state.sublimeMark.find();if(found){cm.state.sublimeMark.clear();cm.state.sublimeMark=cm.setBookmark(cm.getCursor());cm.setCursor(found)}};cmds[map[cK+ctrl+"Y"]="sublimeYank"]=function(cm){null!=cm.state.sublimeKilled&&cm.replaceSelection(cm.state.sublimeKilled,null,"paste")};map[cK+ctrl+"G"]="clearBookmarks";cmds[map[cK+ctrl+"C"]="showInCenter"]=function(cm){var pos=cm.cursorCoords(null,"local");cm.scrollTo(null,(pos.top+pos.bottom)/2-cm.getScrollInfo().clientHeight/2)};cmds[map["Shift-Alt-Up"]="selectLinesUpward"]=function(cm){cm.operation(function(){for(var ranges=cm.listSelections(),i=0;i<ranges.length;i++){var range=ranges[i];range.head.line>cm.firstLine()&&cm.addSelection(Pos(range.head.line-1,range.head.ch))}})};cmds[map["Shift-Alt-Down"]="selectLinesDownward"]=function(cm){cm.operation(function(){for(var ranges=cm.listSelections(),i=0;i<ranges.length;i++){var range=ranges[i];range.head.line<cm.lastLine()&&cm.addSelection(Pos(range.head.line+1,range.head.ch))}})};cmds[map[ctrl+"F3"]="findUnder"]=function(cm){findAndGoTo(cm,!0)};cmds[map["Shift-"+ctrl+"F3"]="findUnderPrevious"]=function(cm){findAndGoTo(cm,!1)};cmds[map["Alt-F3"]="findAllUnder"]=function(cm){var target=getTarget(cm);if(target){for(var cur=cm.getSearchCursor(target.query),matches=[],primaryIndex=-1;cur.findNext();){matches.push({anchor:cur.from(),head:cur.to()});cur.from().line<=target.from.line&&cur.from().ch<=target.from.ch&&primaryIndex++}cm.setSelections(matches,primaryIndex)}};map["Shift-"+ctrl+"["]="fold";map["Shift-"+ctrl+"]"]="unfold";map[cK+ctrl+"0"]=map[cK+ctrl+"j"]="unfoldAll";map[ctrl+"I"]="findIncremental";map["Shift-"+ctrl+"I"]="findIncrementalReverse";map[ctrl+"H"]="replace";map.F3="findNext";map["Shift-F3"]="findPrev";CodeMirror.normalizeKeyMap(map)});
1
+ !function(mod){"object"==typeof exports&&"object"==typeof module?mod(require("../lib/codemirror"),require("../addon/search/searchcursor"),require("../addon/edit/matchbrackets")):"function"==typeof define&&define.amd?define(["../lib/codemirror","../addon/search/searchcursor","../addon/edit/matchbrackets"],mod):mod(CodeMirror)}(function(CodeMirror){"use strict";function findPosSubword(doc,start,dir){if(0>dir&&0==start.ch)return doc.clipPos(Pos(start.line-1));var line=doc.getLine(start.line);if(dir>0&&start.ch>=line.length)return doc.clipPos(Pos(start.line+1,0));for(var type,state="start",pos=start.ch,e=0>dir?0:line.length,i=0;pos!=e;pos+=dir,i++){var next=line.charAt(0>dir?pos-1:pos),cat="_"!=next&&CodeMirror.isWordChar(next)?"w":"o";"w"==cat&&next.toUpperCase()==next&&(cat="W");if("start"==state){if("o"!=cat){state="in";type=cat}}else if("in"==state&&type!=cat){"w"==type&&"W"==cat&&0>dir&&pos--;if("W"==type&&"w"==cat&&dir>0){type="w";continue}break}}return Pos(start.line,pos)}function moveSubword(cm,dir){cm.extendSelectionsBy(function(range){return cm.display.shift||cm.doc.extend||range.empty()?findPosSubword(cm.doc,range.head,dir):0>dir?range.from():range.to()})}function insertLine(cm,above){if(cm.isReadOnly())return CodeMirror.Pass;cm.operation(function(){for(var len=cm.listSelections().length,newSelection=[],last=-1,i=0;len>i;i++){var head=cm.listSelections()[i].head;if(!(head.line<=last)){var at=Pos(head.line+(above?0:1),0);cm.replaceRange("\n",at,null,"+insertLine");cm.indentLine(at.line,null,!0);newSelection.push({head:at,anchor:at});last=head.line+1}}cm.setSelections(newSelection)});return void 0}function wordAt(cm,pos){for(var start=pos.ch,end=start,line=cm.getLine(pos.line);start&&CodeMirror.isWordChar(line.charAt(start-1));)--start;for(;end<line.length&&CodeMirror.isWordChar(line.charAt(end));)++end;return{from:Pos(pos.line,start),to:Pos(pos.line,end),word:line.slice(start,end)}}function selectBetweenBrackets(cm){var pos=cm.getCursor(),opening=cm.scanForBracket(pos,-1);if(opening)for(;;){var closing=cm.scanForBracket(pos,1);if(!closing)return;if(closing.ch==mirror.charAt(mirror.indexOf(opening.ch)+1)){cm.setSelection(Pos(opening.pos.line,opening.pos.ch+1),closing.pos,!1);return!0}pos=Pos(closing.pos.line,closing.pos.ch+1)}}function sortLines(cm,caseSensitive){if(cm.isReadOnly())return CodeMirror.Pass;for(var selected,ranges=cm.listSelections(),toSort=[],i=0;i<ranges.length;i++){var range=ranges[i];if(!range.empty()){for(var from=range.from().line,to=range.to().line;i<ranges.length-1&&ranges[i+1].from().line==to;)to=range[++i].to().line;toSort.push(from,to)}}toSort.length?selected=!0:toSort.push(cm.firstLine(),cm.lastLine());cm.operation(function(){for(var ranges=[],i=0;i<toSort.length;i+=2){var from=toSort[i],to=toSort[i+1],start=Pos(from,0),end=Pos(to),lines=cm.getRange(start,end,!1);caseSensitive?lines.sort():lines.sort(function(a,b){var au=a.toUpperCase(),bu=b.toUpperCase();if(au!=bu){a=au;b=bu}return b>a?-1:a==b?0:1});cm.replaceRange(lines,start,end);selected&&ranges.push({anchor:start,head:end})}selected&&cm.setSelections(ranges,0)})}function modifyWordOrSelection(cm,mod){cm.operation(function(){for(var ranges=cm.listSelections(),indices=[],replacements=[],i=0;i<ranges.length;i++){var range=ranges[i];if(range.empty()){indices.push(i);replacements.push("")}else replacements.push(mod(cm.getRange(range.from(),range.to())))}cm.replaceSelections(replacements,"around","case");for(var at,i=indices.length-1;i>=0;i--){var range=ranges[indices[i]];if(!(at&&CodeMirror.cmpPos(range.head,at)>0)){var word=wordAt(cm,range.head);at=word.from;cm.replaceRange(mod(word.word),word.from,word.to)}}})}function getTarget(cm){var from=cm.getCursor("from"),to=cm.getCursor("to");if(0==CodeMirror.cmpPos(from,to)){var word=wordAt(cm,from);if(!word.word)return;from=word.from;to=word.to}return{from:from,to:to,query:cm.getRange(from,to),word:word}}function findAndGoTo(cm,forward){var target=getTarget(cm);if(target){var query=target.query,cur=cm.getSearchCursor(query,forward?target.to:target.from);if(forward?cur.findNext():cur.findPrevious())cm.setSelection(cur.from(),cur.to());else{cur=cm.getSearchCursor(query,forward?Pos(cm.firstLine(),0):cm.clipPos(Pos(cm.lastLine())));(forward?cur.findNext():cur.findPrevious())?cm.setSelection(cur.from(),cur.to()):target.word&&cm.setSelection(target.from,target.to)}}}var map=CodeMirror.keyMap.sublime={fallthrough:"default"},cmds=CodeMirror.commands,Pos=CodeMirror.Pos,mac=CodeMirror.keyMap["default"]==CodeMirror.keyMap.macDefault,ctrl=mac?"Cmd-":"Ctrl-";cmds[map["Alt-Left"]="goSubwordLeft"]=function(cm){moveSubword(cm,-1)};cmds[map["Alt-Right"]="goSubwordRight"]=function(cm){moveSubword(cm,1)};mac&&(map["Cmd-Left"]="goLineStartSmart");var scrollLineCombo=mac?"Ctrl-Alt-":"Ctrl-";cmds[map[scrollLineCombo+"Up"]="scrollLineUp"]=function(cm){var info=cm.getScrollInfo();if(!cm.somethingSelected()){var visibleBottomLine=cm.lineAtHeight(info.top+info.clientHeight,"local");cm.getCursor().line>=visibleBottomLine&&cm.execCommand("goLineUp")}cm.scrollTo(null,info.top-cm.defaultTextHeight())};cmds[map[scrollLineCombo+"Down"]="scrollLineDown"]=function(cm){var info=cm.getScrollInfo();if(!cm.somethingSelected()){var visibleTopLine=cm.lineAtHeight(info.top,"local")+1;cm.getCursor().line<=visibleTopLine&&cm.execCommand("goLineDown")}cm.scrollTo(null,info.top+cm.defaultTextHeight())};cmds[map["Shift-"+ctrl+"L"]="splitSelectionByLine"]=function(cm){for(var ranges=cm.listSelections(),lineRanges=[],i=0;i<ranges.length;i++)for(var from=ranges[i].from(),to=ranges[i].to(),line=from.line;line<=to.line;++line)to.line>from.line&&line==to.line&&0==to.ch||lineRanges.push({anchor:line==from.line?from:Pos(line,0),head:line==to.line?to:Pos(line)});cm.setSelections(lineRanges,0)};map["Shift-Tab"]="indentLess";cmds[map.Esc="singleSelectionTop"]=function(cm){var range=cm.listSelections()[0];cm.setSelection(range.anchor,range.head,{scroll:!1})};cmds[map[ctrl+"L"]="selectLine"]=function(cm){for(var ranges=cm.listSelections(),extended=[],i=0;i<ranges.length;i++){var range=ranges[i];extended.push({anchor:Pos(range.from().line,0),head:Pos(range.to().line+1,0)})}cm.setSelections(extended)};map["Shift-Ctrl-K"]="deleteLine";cmds[map[ctrl+"Enter"]="insertLineAfter"]=function(cm){return insertLine(cm,!1)};cmds[map["Shift-"+ctrl+"Enter"]="insertLineBefore"]=function(cm){return insertLine(cm,!0)};cmds[map[ctrl+"D"]="selectNextOccurrence"]=function(cm){var from=cm.getCursor("from"),to=cm.getCursor("to"),fullWord=cm.state.sublimeFindFullWord==cm.doc.sel;if(0==CodeMirror.cmpPos(from,to)){var word=wordAt(cm,from);if(!word.word)return;cm.setSelection(word.from,word.to);fullWord=!0}else{var text=cm.getRange(from,to),query=fullWord?new RegExp("\\b"+text+"\\b"):text,cur=cm.getSearchCursor(query,to);if(cur.findNext())cm.addSelection(cur.from(),cur.to());else{cur=cm.getSearchCursor(query,Pos(cm.firstLine(),0));cur.findNext()&&cm.addSelection(cur.from(),cur.to())}}fullWord&&(cm.state.sublimeFindFullWord=cm.doc.sel)};var mirror="(){}[]";cmds[map["Shift-"+ctrl+"Space"]="selectScope"]=function(cm){selectBetweenBrackets(cm)||cm.execCommand("selectAll")};cmds[map["Shift-"+ctrl+"M"]="selectBetweenBrackets"]=function(cm){return selectBetweenBrackets(cm)?void 0:CodeMirror.Pass};cmds[map[ctrl+"M"]="goToBracket"]=function(cm){cm.extendSelectionsBy(function(range){var next=cm.scanForBracket(range.head,1);if(next&&0!=CodeMirror.cmpPos(next.pos,range.head))return next.pos;var prev=cm.scanForBracket(range.head,-1);return prev&&Pos(prev.pos.line,prev.pos.ch+1)||range.head})};var swapLineCombo=mac?"Cmd-Ctrl-":"Shift-Ctrl-";cmds[map[swapLineCombo+"Up"]="swapLineUp"]=function(cm){if(cm.isReadOnly())return CodeMirror.Pass;for(var ranges=cm.listSelections(),linesToMove=[],at=cm.firstLine()-1,newSels=[],i=0;i<ranges.length;i++){var range=ranges[i],from=range.from().line-1,to=range.to().line;newSels.push({anchor:Pos(range.anchor.line-1,range.anchor.ch),head:Pos(range.head.line-1,range.head.ch)});0!=range.to().ch||range.empty()||--to;from>at?linesToMove.push(from,to):linesToMove.length&&(linesToMove[linesToMove.length-1]=to);at=to}cm.operation(function(){for(var i=0;i<linesToMove.length;i+=2){var from=linesToMove[i],to=linesToMove[i+1],line=cm.getLine(from);cm.replaceRange("",Pos(from,0),Pos(from+1,0),"+swapLine");to>cm.lastLine()?cm.replaceRange("\n"+line,Pos(cm.lastLine()),null,"+swapLine"):cm.replaceRange(line+"\n",Pos(to,0),null,"+swapLine")}cm.setSelections(newSels);cm.scrollIntoView()})};cmds[map[swapLineCombo+"Down"]="swapLineDown"]=function(cm){if(cm.isReadOnly())return CodeMirror.Pass;for(var ranges=cm.listSelections(),linesToMove=[],at=cm.lastLine()+1,i=ranges.length-1;i>=0;i--){var range=ranges[i],from=range.to().line+1,to=range.from().line;0!=range.to().ch||range.empty()||from--;at>from?linesToMove.push(from,to):linesToMove.length&&(linesToMove[linesToMove.length-1]=to);at=to}cm.operation(function(){for(var i=linesToMove.length-2;i>=0;i-=2){var from=linesToMove[i],to=linesToMove[i+1],line=cm.getLine(from);from==cm.lastLine()?cm.replaceRange("",Pos(from-1),Pos(from),"+swapLine"):cm.replaceRange("",Pos(from,0),Pos(from+1,0),"+swapLine");cm.replaceRange(line+"\n",Pos(to,0),null,"+swapLine")}cm.scrollIntoView()})};cmds[map[ctrl+"/"]="toggleCommentIndented"]=function(cm){cm.toggleComment({indent:!0})};cmds[map[ctrl+"J"]="joinLines"]=function(cm){for(var ranges=cm.listSelections(),joined=[],i=0;i<ranges.length;i++){for(var range=ranges[i],from=range.from(),start=from.line,end=range.to().line;i<ranges.length-1&&ranges[i+1].from().line==end;)end=ranges[++i].to().line;joined.push({start:start,end:end,anchor:!range.empty()&&from})}cm.operation(function(){for(var offset=0,ranges=[],i=0;i<joined.length;i++){for(var head,obj=joined[i],anchor=obj.anchor&&Pos(obj.anchor.line-offset,obj.anchor.ch),line=obj.start;line<=obj.end;line++){var actual=line-offset;line==obj.end&&(head=Pos(actual,cm.getLine(actual).length+1));if(actual<cm.lastLine()){cm.replaceRange(" ",Pos(actual),Pos(actual+1,/^\s*/.exec(cm.getLine(actual+1))[0].length));++offset}}ranges.push({anchor:anchor||head,head:head})}cm.setSelections(ranges,0)})};cmds[map["Shift-"+ctrl+"D"]="duplicateLine"]=function(cm){cm.operation(function(){for(var rangeCount=cm.listSelections().length,i=0;rangeCount>i;i++){var range=cm.listSelections()[i];range.empty()?cm.replaceRange(cm.getLine(range.head.line)+"\n",Pos(range.head.line,0)):cm.replaceRange(cm.getRange(range.from(),range.to()),range.from())}cm.scrollIntoView()})};map[ctrl+"T"]="transposeChars";cmds[map.F9="sortLines"]=function(cm){sortLines(cm,!0)};cmds[map[ctrl+"F9"]="sortLinesInsensitive"]=function(cm){sortLines(cm,!1)};cmds[map.F2="nextBookmark"]=function(cm){var marks=cm.state.sublimeBookmarks;if(marks)for(;marks.length;){var current=marks.shift(),found=current.find();if(found){marks.push(current);return cm.setSelection(found.from,found.to)}}};cmds[map["Shift-F2"]="prevBookmark"]=function(cm){var marks=cm.state.sublimeBookmarks;if(marks)for(;marks.length;){marks.unshift(marks.pop());var found=marks[marks.length-1].find();if(found)return cm.setSelection(found.from,found.to);marks.pop()}};cmds[map[ctrl+"F2"]="toggleBookmark"]=function(cm){for(var ranges=cm.listSelections(),marks=cm.state.sublimeBookmarks||(cm.state.sublimeBookmarks=[]),i=0;i<ranges.length;i++){for(var from=ranges[i].from(),to=ranges[i].to(),found=cm.findMarks(from,to),j=0;j<found.length;j++)if(found[j].sublimeBookmark){found[j].clear();for(var k=0;k<marks.length;k++)marks[k]==found[j]&&marks.splice(k--,1);break}j==found.length&&marks.push(cm.markText(from,to,{sublimeBookmark:!0,clearWhenEmpty:!1}))}};cmds[map["Shift-"+ctrl+"F2"]="clearBookmarks"]=function(cm){var marks=cm.state.sublimeBookmarks;if(marks)for(var i=0;i<marks.length;i++)marks[i].clear();marks.length=0};cmds[map["Alt-F2"]="selectBookmarks"]=function(cm){var marks=cm.state.sublimeBookmarks,ranges=[];if(marks)for(var i=0;i<marks.length;i++){var found=marks[i].find();found?ranges.push({anchor:found.from,head:found.to}):marks.splice(i--,0)}ranges.length&&cm.setSelections(ranges,0)};map["Alt-Q"]="wrapLines";var cK=ctrl+"K ";map[cK+ctrl+"Backspace"]="delLineLeft";cmds[map.Backspace="smartBackspace"]=function(cm){if(cm.somethingSelected())return CodeMirror.Pass;var cursor=cm.getCursor(),toStartOfLine=cm.getRange({line:cursor.line,ch:0},cursor),column=CodeMirror.countColumn(toStartOfLine,null,cm.getOption("tabSize")),indentUnit=cm.getOption("indentUnit");if(toStartOfLine&&!/\S/.test(toStartOfLine)&&column%indentUnit==0){var prevIndent=new Pos(cursor.line,CodeMirror.findColumn(toStartOfLine,column-indentUnit,indentUnit));return prevIndent.ch==cursor.ch?CodeMirror.Pass:cm.replaceRange("",prevIndent,cursor,"+delete")}return CodeMirror.Pass};cmds[map[cK+ctrl+"K"]="delLineRight"]=function(cm){cm.operation(function(){for(var ranges=cm.listSelections(),i=ranges.length-1;i>=0;i--)cm.replaceRange("",ranges[i].anchor,Pos(ranges[i].to().line),"+delete");cm.scrollIntoView()})};cmds[map[cK+ctrl+"U"]="upcaseAtCursor"]=function(cm){modifyWordOrSelection(cm,function(str){return str.toUpperCase()})};cmds[map[cK+ctrl+"L"]="downcaseAtCursor"]=function(cm){modifyWordOrSelection(cm,function(str){return str.toLowerCase()})};cmds[map[cK+ctrl+"Space"]="setSublimeMark"]=function(cm){cm.state.sublimeMark&&cm.state.sublimeMark.clear();cm.state.sublimeMark=cm.setBookmark(cm.getCursor())};cmds[map[cK+ctrl+"A"]="selectToSublimeMark"]=function(cm){var found=cm.state.sublimeMark&&cm.state.sublimeMark.find();found&&cm.setSelection(cm.getCursor(),found)};cmds[map[cK+ctrl+"W"]="deleteToSublimeMark"]=function(cm){var found=cm.state.sublimeMark&&cm.state.sublimeMark.find();if(found){var from=cm.getCursor(),to=found;if(CodeMirror.cmpPos(from,to)>0){var tmp=to;to=from;from=tmp}cm.state.sublimeKilled=cm.getRange(from,to);cm.replaceRange("",from,to)}};cmds[map[cK+ctrl+"X"]="swapWithSublimeMark"]=function(cm){var found=cm.state.sublimeMark&&cm.state.sublimeMark.find();if(found){cm.state.sublimeMark.clear();cm.state.sublimeMark=cm.setBookmark(cm.getCursor());cm.setCursor(found)}};cmds[map[cK+ctrl+"Y"]="sublimeYank"]=function(cm){null!=cm.state.sublimeKilled&&cm.replaceSelection(cm.state.sublimeKilled,null,"paste")};map[cK+ctrl+"G"]="clearBookmarks";cmds[map[cK+ctrl+"C"]="showInCenter"]=function(cm){var pos=cm.cursorCoords(null,"local");cm.scrollTo(null,(pos.top+pos.bottom)/2-cm.getScrollInfo().clientHeight/2)};cmds[map["Shift-Alt-Up"]="selectLinesUpward"]=function(cm){cm.operation(function(){for(var ranges=cm.listSelections(),i=0;i<ranges.length;i++){var range=ranges[i];range.head.line>cm.firstLine()&&cm.addSelection(Pos(range.head.line-1,range.head.ch))}})};cmds[map["Shift-Alt-Down"]="selectLinesDownward"]=function(cm){cm.operation(function(){for(var ranges=cm.listSelections(),i=0;i<ranges.length;i++){var range=ranges[i];range.head.line<cm.lastLine()&&cm.addSelection(Pos(range.head.line+1,range.head.ch))}})};cmds[map[ctrl+"F3"]="findUnder"]=function(cm){findAndGoTo(cm,!0)};cmds[map["Shift-"+ctrl+"F3"]="findUnderPrevious"]=function(cm){findAndGoTo(cm,!1)};cmds[map["Alt-F3"]="findAllUnder"]=function(cm){var target=getTarget(cm);if(target){for(var cur=cm.getSearchCursor(target.query),matches=[],primaryIndex=-1;cur.findNext();){matches.push({anchor:cur.from(),head:cur.to()});cur.from().line<=target.from.line&&cur.from().ch<=target.from.ch&&primaryIndex++}cm.setSelections(matches,primaryIndex)}};map["Shift-"+ctrl+"["]="fold";map["Shift-"+ctrl+"]"]="unfold";map[cK+ctrl+"0"]=map[cK+ctrl+"j"]="unfoldAll";map[ctrl+"I"]="findIncremental";map["Shift-"+ctrl+"I"]="findIncrementalReverse";map[ctrl+"H"]="replace";map.F3="findNext";map["Shift-F3"]="findPrev";CodeMirror.normalizeKeyMap(map)});
js/esites_editor/dist/js/vendor/codemirror/keymap/vim.js CHANGED
@@ -1,4 +1,4 @@
1
- !function(mod){"object"==typeof exports&&"object"==typeof module?mod(require("../lib/codemirror"),require("../addon/search/searchcursor"),require("../addon/dialog/dialog"),require("../addon/edit/matchbrackets.js")):"function"==typeof define&&define.amd?define(["../lib/codemirror","../addon/search/searchcursor","../addon/dialog/dialog","../addon/edit/matchbrackets"],mod):mod(CodeMirror)}(function(CodeMirror){"use strict";var defaultKeymap=[{keys:"<Left>",type:"keyToKey",toKeys:"h"},{keys:"<Right>",type:"keyToKey",toKeys:"l"},{keys:"<Up>",type:"keyToKey",toKeys:"k"},{keys:"<Down>",type:"keyToKey",toKeys:"j"},{keys:"<Space>",type:"keyToKey",toKeys:"l"},{keys:"<BS>",type:"keyToKey",toKeys:"h",context:"normal"},{keys:"<C-Space>",type:"keyToKey",toKeys:"W"},{keys:"<C-BS>",type:"keyToKey",toKeys:"B",context:"normal"},{keys:"<S-Space>",type:"keyToKey",toKeys:"w"},{keys:"<S-BS>",type:"keyToKey",toKeys:"b",context:"normal"},{keys:"<C-n>",type:"keyToKey",toKeys:"j"},{keys:"<C-p>",type:"keyToKey",toKeys:"k"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"xi",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"dcc",context:"visual"},{keys:"<Home>",type:"keyToKey",toKeys:"0"},{keys:"<End>",type:"keyToKey",toKeys:"$"},{keys:"<PageUp>",type:"keyToKey",toKeys:"<C-b>"},{keys:"<PageDown>",type:"keyToKey",toKeys:"<C-f>"},{keys:"<CR>",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"h",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!1}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!0}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!1}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:"ge",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!1,toJumplist:!0}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!0,toJumplist:!0}},{keys:"<C-f>",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"<C-b>",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"<C-d>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"<C-u>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!1,explicitRepeat:!0}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,toFirstChar:!0}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0,toJumplist:!0}},{keys:"f<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'<character>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`<character>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0,linewise:!0}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1,linewise:!0}},{keys:"]p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0,matchIndent:!0}},{keys:"[p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:"]<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!1,toJumplist:!0}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:!0},context:"visual"},{keys:"d",type:"operator",operator:"delete"},{keys:"y",type:"operator",operator:"yank"},{keys:"c",type:"operator",operator:"change"},{keys:">",type:"operator",operator:"indent",operatorArgs:{indentRight:!0}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:"g~",type:"operator",operator:"changeCase"},{keys:"gu",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},isEdit:!0},{keys:"gU",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},isEdit:!0},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:!0}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:!1,toJumplist:!0}},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"D",type:"operator",operator:"delete",operatorArgs:{linewise:!0},context:"visual"},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"Y",type:"operator",operator:"yank",operatorArgs:{linewise:!0},context:"visual"},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"C",type:"operator",operator:"change",operatorArgs:{linewise:!0},context:"visual"},{keys:"~",type:"operatorMotion",operator:"changeCase",motion:"moveByCharacters",motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:"normal"},{keys:"~",type:"operator",operator:"changeCase",context:"visual"},{keys:"<C-w>",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"<C-i>",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"<C-o>",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"<C-e>",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"<C-y>",type:"action",action:"scroll",actionArgs:{forward:!1,linewise:!0}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"endOfSelectedArea"},context:"visual"},{keys:"i",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"firstNonBlank"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"startOfSelectedArea"},context:"visual"},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:"<C-v>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:!0},{keys:"p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:"P",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:"r<character>",type:"action",action:"replace",isEdit:!0},{keys:"@<character>",type:"action",action:"replayMacro"},{keys:"q<character>",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{replace:!0}},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},context:"visual",isEdit:!0},{keys:"U",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},context:"visual",isEdit:!0},{keys:"<C-r>",type:"action",action:"redo"},{keys:"m<character>",type:"action",action:"setMark"},{keys:'"<character>',type:"action",action:"setRegister"},{keys:"zz",type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:"z.",type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zt",type:"action",action:"scrollToCursor",actionArgs:{position:"top"}},{keys:"z<CR>",type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"z-",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:"zb",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:".",type:"action",action:"repeatLastEdit"},{keys:"<C-a>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"<C-x>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"a<character>",type:"motion",motion:"textObjectManipulation"},{keys:"i<character>",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:"/",type:"search",searchArgs:{forward:!0,querySrc:"prompt",toJumplist:!0}},{keys:"?",type:"search",searchArgs:{forward:!1,querySrc:"prompt",toJumplist:!0}},{keys:"*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"g*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:"g#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:":",type:"ex"}],defaultExCommandMap=[{name:"colorscheme",shortName:"colo"},{name:"map"},{name:"imap",shortName:"im"},{name:"nmap",shortName:"nm"},{name:"vmap",shortName:"vm"},{name:"unmap"},{name:"write",shortName:"w"},{name:"undo",shortName:"u"},{name:"redo",shortName:"red"},{name:"set",shortName:"se"},{name:"set",shortName:"se"},{name:"setlocal",shortName:"setl"},{name:"setglobal",shortName:"setg"},{name:"sort",shortName:"sor"},{name:"substitute",shortName:"s",possiblyAsync:!0},{name:"nohlsearch",shortName:"noh"},{name:"delmarks",shortName:"delm"},{name:"registers",shortName:"reg",excludeFromCommandHistory:!0},{name:"global",shortName:"g"}],Pos=CodeMirror.Pos,Vim=function(){function enterVimMode(cm){cm.setOption("disableInput",!0);cm.setOption("showCursorWhenSelecting",!1);CodeMirror.signal(cm,"vim-mode-change",{mode:"normal"});cm.on("cursorActivity",onCursorActivity);maybeInitVimState(cm);CodeMirror.on(cm.getInputField(),"paste",getOnPasteFn(cm))}function leaveVimMode(cm){cm.setOption("disableInput",!1);cm.off("cursorActivity",onCursorActivity);CodeMirror.off(cm.getInputField(),"paste",getOnPasteFn(cm));cm.state.vim=null}function detachVimMap(cm,next){this==CodeMirror.keyMap.vim&&CodeMirror.rmClass(cm.getWrapperElement(),"cm-fat-cursor");next&&next.attach==attachVimMap||leaveVimMode(cm,!1)}function attachVimMap(cm,prev){this==CodeMirror.keyMap.vim&&CodeMirror.addClass(cm.getWrapperElement(),"cm-fat-cursor");prev&&prev.attach==attachVimMap||enterVimMode(cm)}function cmKey(key,cm){if(!cm)return void 0;var vimKey=cmKeyToVimKey(key);if(!vimKey)return!1;var cmd=CodeMirror.Vim.findKey(cm,vimKey);"function"==typeof cmd&&CodeMirror.signal(cm,"vim-keypress",vimKey);return cmd}function cmKeyToVimKey(key){if("'"==key.charAt(0))return key.charAt(1);var pieces=key.split("-");/-$/.test(key)&&pieces.splice(-2,2,"-");var lastPiece=pieces[pieces.length-1];if(1==pieces.length&&1==pieces[0].length)return!1;if(2==pieces.length&&"Shift"==pieces[0]&&1==lastPiece.length)return!1;for(var hasCharacter=!1,i=0;i<pieces.length;i++){var piece=pieces[i];piece in modifiers?pieces[i]=modifiers[piece]:hasCharacter=!0;piece in specialKeys&&(pieces[i]=specialKeys[piece])}if(!hasCharacter)return!1;isUpperCase(lastPiece)&&(pieces[pieces.length-1]=lastPiece.toLowerCase());return"<"+pieces.join("-")+">"}function getOnPasteFn(cm){var vim=cm.state.vim;vim.onPasteFn||(vim.onPasteFn=function(){if(!vim.insertMode){cm.setCursor(offsetCursor(cm.getCursor(),0,1));actions.enterInsertMode(cm,{},vim)}});return vim.onPasteFn}function makeKeyRange(start,size){for(var keys=[],i=start;start+size>i;i++)keys.push(String.fromCharCode(i));return keys}function isLine(cm,line){return line>=cm.firstLine()&&line<=cm.lastLine()}function isLowerCase(k){return/^[a-z]$/.test(k)}function isMatchableSymbol(k){return-1!="()[]{}".indexOf(k)}function isNumber(k){return numberRegex.test(k)}function isUpperCase(k){return/^[A-Z]$/.test(k)}function isWhiteSpaceString(k){return/^\s*$/.test(k)}function inArray(val,arr){for(var i=0;i<arr.length;i++)if(arr[i]==val)return!0;return!1}function defineOption(name,defaultValue,type,aliases,callback){if(void 0===defaultValue&&!callback)throw Error("defaultValue is required unless callback is provided");type||(type="string");options[name]={type:type,defaultValue:defaultValue,callback:callback};if(aliases)for(var i=0;i<aliases.length;i++)options[aliases[i]]=options[name];defaultValue&&setOption(name,defaultValue)}function setOption(name,value,cm,cfg){var option=options[name];cfg=cfg||{};var scope=cfg.scope;if(!option)throw Error("Unknown option: "+name);if("boolean"==option.type){if(value&&value!==!0)throw Error("Invalid argument: "+name+"="+value);value!==!1&&(value=!0)}if(option.callback){"local"!==scope&&option.callback(value,void 0);"global"!==scope&&cm&&option.callback(value,cm)}else{"local"!==scope&&(option.value="boolean"==option.type?!!value:value);"global"!==scope&&cm&&(cm.state.vim.options[name]={value:value})}}function getOption(name,cm,cfg){var option=options[name];cfg=cfg||{};var scope=cfg.scope;if(!option)throw Error("Unknown option: "+name);if(!option.callback){var local="global"!==scope&&cm&&cm.state.vim.options[name];return(local||"local"!==scope&&option||{}).value}var local=cm&&option.callback(void 0,cm);return"global"!==scope&&void 0!==local?local:"local"!==scope?option.callback():void 0}function MacroModeState(){this.latestRegister=void 0;this.isPlaying=!1;this.isRecording=!1;this.replaySearchQueries=[];this.onRecordingDone=void 0;this.lastInsertModeChanges=createInsertModeChanges()}function maybeInitVimState(cm){cm.state.vim||(cm.state.vim={inputState:new InputState,lastEditInputState:void 0,lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},fakeCursor:null,insertMode:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:null,sel:{},options:{}});return cm.state.vim}function resetVimGlobalState(){vimGlobalState={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:createCircularJumpList(),macroModeState:new MacroModeState,lastChararacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new RegisterController({}),searchHistoryController:new HistoryController({}),exCommandHistoryController:new HistoryController({})};for(var optionName in options){var option=options[optionName];option.value=option.defaultValue}}function InputState(){this.prefixRepeat=[];this.motionRepeat=[];this.operator=null;this.operatorArgs=null;this.motion=null;this.motionArgs=null;this.keyBuffer=[];this.registerName=null}function clearInputState(cm,reason){cm.state.vim.inputState=new InputState;CodeMirror.signal(cm,"vim-command-done",reason)}function Register(text,linewise,blockwise){this.clear();this.keyBuffer=[text||""];this.insertModeChanges=[];this.searchQueries=[];this.linewise=!!linewise;this.blockwise=!!blockwise}function defineRegister(name,register){var registers=vimGlobalState.registerController.registers[name];if(!name||1!=name.length)throw Error("Register name must be 1 character");if(registers[name])throw Error("Register already defined "+name);registers[name]=register;validRegisters.push(name)}function RegisterController(registers){this.registers=registers;this.unnamedRegister=registers['"']=new Register;registers["."]=new Register;registers[":"]=new Register;registers["/"]=new Register}function HistoryController(){this.historyBuffer=[];this.iterator;this.initialPrefix=null}function defineMotion(name,fn){motions[name]=fn}function fillArray(val,times){for(var arr=[],i=0;times>i;i++)arr.push(val);return arr}function defineOperator(name,fn){operators[name]=fn}function defineAction(name,fn){actions[name]=fn}function clipCursorToContent(cm,cur,includeLineBreak){var line=Math.min(Math.max(cm.firstLine(),cur.line),cm.lastLine()),maxCh=lineLength(cm,line)-1;maxCh=includeLineBreak?maxCh+1:maxCh;var ch=Math.min(Math.max(0,cur.ch),maxCh);return Pos(line,ch)}function copyArgs(args){var ret={};for(var prop in args)args.hasOwnProperty(prop)&&(ret[prop]=args[prop]);return ret}function offsetCursor(cur,offsetLine,offsetCh){if("object"==typeof offsetLine){offsetCh=offsetLine.ch;offsetLine=offsetLine.line}return Pos(cur.line+offsetLine,cur.ch+offsetCh)}function getOffset(anchor,head){return{line:head.line-anchor.line,ch:head.line-anchor.line}}function commandMatches(keys,keyMap,context,inputState){for(var match,partial=[],full=[],i=0;i<keyMap.length;i++){var command=keyMap[i];if(!("insert"==context&&"insert"!=command.context||command.context&&command.context!=context||inputState.operator&&"action"==command.type)&&(match=commandMatch(keys,command.keys))){"partial"==match&&partial.push(command);"full"==match&&full.push(command)}}return{partial:partial.length&&partial,full:full.length&&full}}function commandMatch(pressed,mapped){if("<character>"==mapped.slice(-11)){var prefixLen=mapped.length-11,pressedPrefix=pressed.slice(0,prefixLen),mappedPrefix=mapped.slice(0,prefixLen);return pressedPrefix==mappedPrefix&&pressed.length>prefixLen?"full":0==mappedPrefix.indexOf(pressedPrefix)?"partial":!1}return pressed==mapped?"full":0==mapped.indexOf(pressed)?"partial":!1}function lastChar(keys){var match=/^.*(<[\w\-]+>)$/.exec(keys),selectedCharacter=match?match[1]:keys.slice(-1);if(selectedCharacter.length>1)switch(selectedCharacter){case"<CR>":selectedCharacter="\n";break;case"<Space>":selectedCharacter=" "}return selectedCharacter}function repeatFn(cm,fn,repeat){return function(){for(var i=0;repeat>i;i++)fn(cm)}}function copyCursor(cur){return Pos(cur.line,cur.ch)}function cursorEqual(cur1,cur2){return cur1.ch==cur2.ch&&cur1.line==cur2.line}function cursorIsBefore(cur1,cur2){return cur1.line<cur2.line?!0:cur1.line==cur2.line&&cur1.ch<cur2.ch?!0:!1}function cursorMin(cur1,cur2){arguments.length>2&&(cur2=cursorMin.apply(void 0,Array.prototype.slice.call(arguments,1)));return cursorIsBefore(cur1,cur2)?cur1:cur2}function cursorMax(cur1,cur2){arguments.length>2&&(cur2=cursorMax.apply(void 0,Array.prototype.slice.call(arguments,1)));return cursorIsBefore(cur1,cur2)?cur2:cur1}function cursorIsBetween(cur1,cur2,cur3){var cur1before2=cursorIsBefore(cur1,cur2),cur2before3=cursorIsBefore(cur2,cur3);return cur1before2&&cur2before3}function lineLength(cm,lineNum){return cm.getLine(lineNum).length}function trim(s){return s.trim?s.trim():s.replace(/^\s+|\s+$/g,"")}function escapeRegex(s){return s.replace(/([.?*+$\[\]\/\\(){}|\-])/g,"\\$1")}function extendLineToColumn(cm,lineNum,column){var endCh=lineLength(cm,lineNum),spaces=new Array(column-endCh+1).join(" ");cm.setCursor(Pos(lineNum,endCh));cm.replaceRange(spaces,cm.getCursor())}function selectBlock(cm,selectionEnd){var selections=[],ranges=cm.listSelections(),head=copyCursor(cm.clipPos(selectionEnd)),isClipped=!cursorEqual(selectionEnd,head),curHead=cm.getCursor("head"),primIndex=getIndex(ranges,curHead),wasClipped=cursorEqual(ranges[primIndex].head,ranges[primIndex].anchor),max=ranges.length-1,index=max-primIndex>primIndex?max:0,base=ranges[index].anchor,firstLine=Math.min(base.line,head.line),lastLine=Math.max(base.line,head.line),baseCh=base.ch,headCh=head.ch,dir=ranges[index].head.ch-baseCh,newDir=headCh-baseCh;if(dir>0&&0>=newDir){baseCh++;isClipped||headCh--}else if(0>dir&&newDir>=0){baseCh--;wasClipped||headCh++}else if(0>dir&&-1==newDir){baseCh--;headCh++}for(var line=firstLine;lastLine>=line;line++){var range={anchor:new Pos(line,baseCh),head:new Pos(line,headCh)};selections.push(range)}primIndex=head.line==lastLine?selections.length-1:0;cm.setSelections(selections);selectionEnd.ch=headCh;base.ch=baseCh;return base}function selectForInsert(cm,head,height){for(var sel=[],i=0;height>i;i++){var lineHead=offsetCursor(head,i,0);sel.push({anchor:lineHead,head:lineHead})}cm.setSelections(sel,0)}function getIndex(ranges,cursor,end){for(var i=0;i<ranges.length;i++){var atAnchor="head"!=end&&cursorEqual(ranges[i].anchor,cursor),atHead="anchor"!=end&&cursorEqual(ranges[i].head,cursor);if(atAnchor||atHead)return i}return-1}function getSelectedAreaRange(cm,vim){var lastSelection=vim.lastSelection,getCurrentSelectedAreaRange=function(){var selections=cm.listSelections(),start=selections[0],end=selections[selections.length-1],selectionStart=cursorIsBefore(start.anchor,start.head)?start.anchor:start.head,selectionEnd=cursorIsBefore(end.anchor,end.head)?end.head:end.anchor;return[selectionStart,selectionEnd]},getLastSelectedAreaRange=function(){var selectionStart=cm.getCursor(),selectionEnd=cm.getCursor(),block=lastSelection.visualBlock;if(block){var width=block.width,height=block.height;selectionEnd=Pos(selectionStart.line+height,selectionStart.ch+width);for(var selections=[],i=selectionStart.line;i<selectionEnd.line;i++){var anchor=Pos(i,selectionStart.ch),head=Pos(i,selectionEnd.ch),range={anchor:anchor,head:head};selections.push(range)}cm.setSelections(selections)}else{var start=lastSelection.anchorMark.find(),end=lastSelection.headMark.find(),line=end.line-start.line,ch=end.ch-start.ch;selectionEnd={line:selectionEnd.line+line,ch:line?selectionEnd.ch:ch+selectionEnd.ch};if(lastSelection.visualLine){selectionStart=Pos(selectionStart.line,0);selectionEnd=Pos(selectionEnd.line,lineLength(cm,selectionEnd.line))}cm.setSelection(selectionStart,selectionEnd)}return[selectionStart,selectionEnd]};return vim.visualMode?getCurrentSelectedAreaRange():getLastSelectedAreaRange()}function updateLastSelection(cm,vim){var anchor=vim.sel.anchor,head=vim.sel.head;if(vim.lastPastedText){head=cm.posFromIndex(cm.indexFromPos(anchor)+vim.lastPastedText.length);vim.lastPastedText=null}vim.lastSelection={anchorMark:cm.setBookmark(anchor),headMark:cm.setBookmark(head),anchor:copyCursor(anchor),head:copyCursor(head),visualMode:vim.visualMode,visualLine:vim.visualLine,visualBlock:vim.visualBlock}}function expandSelection(cm,start,end){var tmp,sel=cm.state.vim.sel,head=sel.head,anchor=sel.anchor;if(cursorIsBefore(end,start)){tmp=end;end=start;start=tmp}if(cursorIsBefore(head,anchor)){head=cursorMin(start,head);anchor=cursorMax(anchor,end)}else{anchor=cursorMin(start,anchor);head=cursorMax(head,end);head=offsetCursor(head,0,-1);-1==head.ch&&head.line!=cm.firstLine()&&(head=Pos(head.line-1,lineLength(cm,head.line-1)))}return[anchor,head]}function updateCmSelection(cm,sel,mode){var vim=cm.state.vim;sel=sel||vim.sel;var mode=mode||vim.visualLine?"line":vim.visualBlock?"block":"char",cmSel=makeCmSelection(cm,sel,mode);cm.setSelections(cmSel.ranges,cmSel.primary);updateFakeCursor(cm)}function makeCmSelection(cm,sel,mode,exclusive){var head=copyCursor(sel.head),anchor=copyCursor(sel.anchor);if("char"==mode){var headOffset=exclusive||cursorIsBefore(sel.head,sel.anchor)?0:1,anchorOffset=cursorIsBefore(sel.head,sel.anchor)?1:0;head=offsetCursor(sel.head,0,headOffset);anchor=offsetCursor(sel.anchor,0,anchorOffset);return{ranges:[{anchor:anchor,head:head}],primary:0}}if("line"==mode){if(cursorIsBefore(sel.head,sel.anchor)){head.ch=0;anchor.ch=lineLength(cm,anchor.line)}else{anchor.ch=0;var lastLine=cm.lastLine();head.line>lastLine&&(head.line=lastLine);head.ch=lineLength(cm,head.line)}return{ranges:[{anchor:anchor,head:head}],primary:0}}if("block"==mode){for(var top=Math.min(anchor.line,head.line),left=Math.min(anchor.ch,head.ch),bottom=Math.max(anchor.line,head.line),right=Math.max(anchor.ch,head.ch)+1,height=bottom-top+1,primary=head.line==top?0:height-1,ranges=[],i=0;height>i;i++)ranges.push({anchor:Pos(top+i,left),head:Pos(top+i,right)});return{ranges:ranges,primary:primary}}}function getHead(cm){var cur=cm.getCursor("head");1==cm.getSelection().length&&(cur=cursorMin(cur,cm.getCursor("anchor")));return cur}function exitVisualMode(cm,moveHead){var vim=cm.state.vim;moveHead!==!1&&cm.setCursor(clipCursorToContent(cm,vim.sel.head));updateLastSelection(cm,vim);vim.visualMode=!1;vim.visualLine=!1;vim.visualBlock=!1;CodeMirror.signal(cm,"vim-mode-change",{mode:"normal"});vim.fakeCursor&&vim.fakeCursor.clear()}function clipToLine(cm,curStart,curEnd){var selection=cm.getRange(curStart,curEnd);if(/\n\s*$/.test(selection)){var lines=selection.split("\n");lines.pop();for(var line,line=lines.pop();lines.length>0&&line&&isWhiteSpaceString(line);line=lines.pop()){curEnd.line--;curEnd.ch=0}if(line){curEnd.line--;curEnd.ch=lineLength(cm,curEnd.line)}else curEnd.ch=0}}function expandSelectionToLine(_cm,curStart,curEnd){curStart.ch=0;curEnd.ch=0;curEnd.line++}function findFirstNonWhiteSpaceCharacter(text){if(!text)return 0;var firstNonWS=text.search(/\S/);return-1==firstNonWS?text.length:firstNonWS}function expandWordUnderCursor(cm,inclusive,_forward,bigWord,noSymbol){for(var cur=getHead(cm),line=cm.getLine(cur.line),idx=cur.ch,test=noSymbol?wordCharTest[0]:bigWordCharTest[0];!test(line.charAt(idx));){idx++;if(idx>=line.length)return null}if(bigWord)test=bigWordCharTest[0];else{test=wordCharTest[0];test(line.charAt(idx))||(test=wordCharTest[1])}for(var end=idx,start=idx;test(line.charAt(end))&&end<line.length;)end++;for(;test(line.charAt(start))&&start>=0;)start--;start++;if(inclusive){for(var wordEnd=end;/\s/.test(line.charAt(end))&&end<line.length;)end++;if(wordEnd==end){for(var wordStart=start;/\s/.test(line.charAt(start-1))&&start>0;)start--;start||(start=wordStart)}}return{start:Pos(cur.line,start),end:Pos(cur.line,end)}}function recordJumpPosition(cm,oldCur,newCur){cursorEqual(oldCur,newCur)||vimGlobalState.jumpList.add(cm,oldCur,newCur)}function recordLastCharacterSearch(increment,args){vimGlobalState.lastChararacterSearch.increment=increment;vimGlobalState.lastChararacterSearch.forward=args.forward;vimGlobalState.lastChararacterSearch.selectedCharacter=args.selectedCharacter}function findSymbol(cm,repeat,forward,symb){var cur=copyCursor(cm.getCursor()),increment=forward?1:-1,endLine=forward?cm.lineCount():-1,curCh=cur.ch,line=cur.line,lineText=cm.getLine(line),state={lineText:lineText,nextCh:lineText.charAt(curCh),lastCh:null,index:curCh,symb:symb,reverseSymb:(forward?{")":"(","}":"{"}:{"(":")","{":"}"})[symb],forward:forward,depth:0,curMoveThrough:!1},mode=symbolToMode[symb];if(!mode)return cur;var init=findSymbolModes[mode].init,isComplete=findSymbolModes[mode].isComplete;init&&init(state);for(;line!==endLine&&repeat;){state.index+=increment;state.nextCh=state.lineText.charAt(state.index);if(!state.nextCh){line+=increment;state.lineText=cm.getLine(line)||"";if(increment>0)state.index=0;else{var lineLen=state.lineText.length;state.index=lineLen>0?lineLen-1:0}state.nextCh=state.lineText.charAt(state.index)}if(isComplete(state)){cur.line=line;cur.ch=state.index;repeat--}}return state.nextCh||state.curMoveThrough?Pos(line,state.index):cur}function findWord(cm,cur,forward,bigWord,emptyLineIsWord){var lineNum=cur.line,pos=cur.ch,line=cm.getLine(lineNum),dir=forward?1:-1,charTests=bigWord?bigWordCharTest:wordCharTest;if(emptyLineIsWord&&""==line){lineNum+=dir;line=cm.getLine(lineNum);if(!isLine(cm,lineNum))return null;pos=forward?0:line.length}for(;;){if(emptyLineIsWord&&""==line)return{from:0,to:0,line:lineNum};for(var stop=dir>0?line.length:-1,wordStart=stop,wordEnd=stop;pos!=stop;){for(var foundWord=!1,i=0;i<charTests.length&&!foundWord;++i)if(charTests[i](line.charAt(pos))){wordStart=pos;for(;pos!=stop&&charTests[i](line.charAt(pos));)pos+=dir;wordEnd=pos;foundWord=wordStart!=wordEnd;if(wordStart==cur.ch&&lineNum==cur.line&&wordEnd==wordStart+dir)continue;return{from:Math.min(wordStart,wordEnd+1),to:Math.max(wordStart,wordEnd),line:lineNum}}foundWord||(pos+=dir)}lineNum+=dir;if(!isLine(cm,lineNum))return null;line=cm.getLine(lineNum);pos=dir>0?0:line.length}throw new Error("The impossible happened.")}function moveToWord(cm,cur,repeat,forward,wordEnd,bigWord){var curStart=copyCursor(cur),words=[];(forward&&!wordEnd||!forward&&wordEnd)&&repeat++;for(var emptyLineIsWord=!(forward&&wordEnd),i=0;repeat>i;i++){var word=findWord(cm,cur,forward,bigWord,emptyLineIsWord);if(!word){var eodCh=lineLength(cm,cm.lastLine());words.push(forward?{line:cm.lastLine(),from:eodCh,to:eodCh}:{line:0,from:0,to:0});break}words.push(word);cur=Pos(word.line,forward?word.to-1:word.from)}var shortCircuit=words.length!=repeat,firstWord=words[0],lastWord=words.pop();if(forward&&!wordEnd){shortCircuit||firstWord.from==curStart.ch&&firstWord.line==curStart.line||(lastWord=words.pop());return Pos(lastWord.line,lastWord.from)}if(forward&&wordEnd)return Pos(lastWord.line,lastWord.to-1);if(!forward&&wordEnd){shortCircuit||firstWord.to==curStart.ch&&firstWord.line==curStart.line||(lastWord=words.pop());return Pos(lastWord.line,lastWord.to)}return Pos(lastWord.line,lastWord.from)}function moveToCharacter(cm,repeat,forward,character){for(var idx,cur=cm.getCursor(),start=cur.ch,i=0;repeat>i;i++){var line=cm.getLine(cur.line);idx=charIdxInLine(start,line,character,forward,!0);if(-1==idx)return null;start=idx}return Pos(cm.getCursor().line,idx)}function moveToColumn(cm,repeat){var line=cm.getCursor().line;return clipCursorToContent(cm,Pos(line,repeat-1));
2
- }function updateMark(cm,vim,markName,pos){if(inArray(markName,validMarks)){vim.marks[markName]&&vim.marks[markName].clear();vim.marks[markName]=cm.setBookmark(pos)}}function charIdxInLine(start,line,character,forward,includeChar){var idx;if(forward){idx=line.indexOf(character,start+1);-1==idx||includeChar||(idx-=1)}else{idx=line.lastIndexOf(character,start-1);-1==idx||includeChar||(idx+=1)}return idx}function findParagraph(cm,head,repeat,dir,inclusive){function isEmpty(i){return!cm.getLine(i)}function isBoundary(i,dir,any){return any?isEmpty(i)!=isEmpty(i+dir):!isEmpty(i)&&isEmpty(i+dir)}var start,end,line=head.line,min=cm.firstLine(),max=cm.lastLine(),i=line;if(dir){for(;i>=min&&max>=i&&repeat>0;){isBoundary(i,dir)&&repeat--;i+=dir}return new Pos(i,0)}var vim=cm.state.vim;if(vim.visualLine&&isBoundary(line,1,!0)){var anchor=vim.sel.anchor;isBoundary(anchor.line,-1,!0)&&(inclusive&&anchor.line==line||(line+=1))}var startState=isEmpty(line);for(i=line;max>=i&&repeat;i++)isBoundary(i,1,!0)&&(inclusive&&isEmpty(i)==startState||repeat--);end=new Pos(i,0);i>max&&!startState?startState=!0:inclusive=!1;for(i=line;i>min&&(inclusive&&isEmpty(i)!=startState&&i!=line||!isBoundary(i,-1,!0));i--);start=new Pos(i,0);return{start:start,end:end}}function selectCompanionObject(cm,head,symb,inclusive){var start,end,cur=head,bracketRegexp={"(":/[()]/,")":/[()]/,"[":/[[\]]/,"]":/[[\]]/,"{":/[{}]/,"}":/[{}]/}[symb],openSym={"(":"(",")":"(","[":"[","]":"[","{":"{","}":"{"}[symb],curChar=cm.getLine(cur.line).charAt(cur.ch),offset=curChar===openSym?1:0;start=cm.scanForBracket(Pos(cur.line,cur.ch+offset),-1,null,{bracketRegex:bracketRegexp});end=cm.scanForBracket(Pos(cur.line,cur.ch+offset),1,null,{bracketRegex:bracketRegexp});if(!start||!end)return{start:cur,end:cur};start=start.pos;end=end.pos;if(start.line==end.line&&start.ch>end.ch||start.line>end.line){var tmp=start;start=end;end=tmp}inclusive?end.ch+=1:start.ch+=1;return{start:start,end:end}}function findBeginningAndEnd(cm,head,symb,inclusive){var start,end,i,len,cur=copyCursor(head),line=cm.getLine(cur.line),chars=line.split(""),firstIndex=chars.indexOf(symb);if(cur.ch<firstIndex)cur.ch=firstIndex;else if(firstIndex<cur.ch&&chars[cur.ch]==symb){end=cur.ch;--cur.ch}if(chars[cur.ch]!=symb||end)for(i=cur.ch;i>-1&&!start;i--)chars[i]==symb&&(start=i+1);else start=cur.ch+1;if(start&&!end)for(i=start,len=chars.length;len>i&&!end;i++)chars[i]==symb&&(end=i);if(!start||!end)return{start:cur,end:cur};if(inclusive){--start;++end}return{start:Pos(cur.line,start),end:Pos(cur.line,end)}}function SearchState(){}function getSearchState(cm){var vim=cm.state.vim;return vim.searchState_||(vim.searchState_=new SearchState)}function dialog(cm,template,shortText,onClose,options){cm.openDialog?cm.openDialog(template,onClose,{bottom:!0,value:options.value,onKeyDown:options.onKeyDown,onKeyUp:options.onKeyUp,selectValueOnOpen:!1}):onClose(prompt(shortText,""))}function splitBySlash(argString){var slashes=findUnescapedSlashes(argString)||[];if(!slashes.length)return[];var tokens=[];if(0===slashes[0]){for(var i=0;i<slashes.length;i++)"number"==typeof slashes[i]&&tokens.push(argString.substring(slashes[i]+1,slashes[i+1]));return tokens}}function findUnescapedSlashes(str){for(var escapeNextChar=!1,slashes=[],i=0;i<str.length;i++){var c=str.charAt(i);escapeNextChar||"/"!=c||slashes.push(i);escapeNextChar=!escapeNextChar&&"\\"==c}return slashes}function translateRegex(str){for(var specials="|(){",unescape="}",escapeNextChar=!1,out=[],i=-1;i<str.length;i++){var c=str.charAt(i)||"",n=str.charAt(i+1)||"",specialComesNext=n&&-1!=specials.indexOf(n);if(escapeNextChar){"\\"===c&&specialComesNext||out.push(c);escapeNextChar=!1}else if("\\"===c){escapeNextChar=!0;n&&-1!=unescape.indexOf(n)&&(specialComesNext=!0);specialComesNext&&"\\"!==n||out.push(c)}else{out.push(c);specialComesNext&&"\\"!==n&&out.push("\\")}}return out.join("")}function translateRegexReplace(str){for(var escapeNextChar=!1,out=[],i=-1;i<str.length;i++){var c=str.charAt(i)||"",n=str.charAt(i+1)||"";if(charUnescapes[c+n]){out.push(charUnescapes[c+n]);i++}else if(escapeNextChar){out.push(c);escapeNextChar=!1}else if("\\"===c){escapeNextChar=!0;isNumber(n)||"$"===n?out.push("$"):"/"!==n&&"\\"!==n&&out.push("\\")}else{"$"===c&&out.push("$");out.push(c);"/"===n&&out.push("\\")}}return out.join("")}function unescapeRegexReplace(str){for(var stream=new CodeMirror.StringStream(str),output=[];!stream.eol();){for(;stream.peek()&&"\\"!=stream.peek();)output.push(stream.next());var matched=!1;for(var matcher in unescapes)if(stream.match(matcher,!0)){matched=!0;output.push(unescapes[matcher]);break}matched||output.push(stream.next())}return output.join("")}function parseQuery(query,ignoreCase,smartCase){var lastSearchRegister=vimGlobalState.registerController.getRegister("/");lastSearchRegister.setText(query);if(query instanceof RegExp)return query;var regexPart,forceIgnoreCase,slashes=findUnescapedSlashes(query);if(slashes.length){regexPart=query.substring(0,slashes[0]);var flagsPart=query.substring(slashes[0]);forceIgnoreCase=-1!=flagsPart.indexOf("i")}else regexPart=query;if(!regexPart)return null;getOption("pcre")||(regexPart=translateRegex(regexPart));smartCase&&(ignoreCase=/^[^A-Z]*$/.test(regexPart));var regexp=new RegExp(regexPart,ignoreCase||forceIgnoreCase?"i":void 0);return regexp}function showConfirm(cm,text){cm.openNotification?cm.openNotification('<span style="color: red">'+text+"</span>",{bottom:!0,duration:5e3}):alert(text)}function makePrompt(prefix,desc){var raw="";prefix&&(raw+='<span style="font-family: monospace">'+prefix+"</span>");raw+='<input type="text"/> <span style="color: #888">';if(desc){raw+='<span style="color: #888">';raw+=desc;raw+="</span>"}return raw}function showPrompt(cm,options){var shortText=(options.prefix||"")+" "+(options.desc||""),prompt=makePrompt(options.prefix,options.desc);dialog(cm,prompt,shortText,options.onClose,options)}function regexEqual(r1,r2){if(r1 instanceof RegExp&&r2 instanceof RegExp){for(var props=["global","multiline","ignoreCase","source"],i=0;i<props.length;i++){var prop=props[i];if(r1[prop]!==r2[prop])return!1}return!0}return!1}function updateSearchQuery(cm,rawQuery,ignoreCase,smartCase){if(rawQuery){var state=getSearchState(cm),query=parseQuery(rawQuery,!!ignoreCase,!!smartCase);if(query){highlightSearchMatches(cm,query);if(regexEqual(query,state.getQuery()))return query;state.setQuery(query);return query}}}function searchOverlay(query){if("^"==query.source.charAt(0))var matchSol=!0;return{token:function(stream){if(!matchSol||stream.sol()){var match=stream.match(query,!1);if(match){if(0==match[0].length){stream.next();return"searching"}if(!stream.sol()){stream.backUp(1);if(!query.exec(stream.next()+match[0])){stream.next();return null}}stream.match(query);return"searching"}for(;!stream.eol();){stream.next();if(stream.match(query,!1))break}}else stream.skipToEnd()},query:query}}function highlightSearchMatches(cm,query){var searchState=getSearchState(cm),overlay=searchState.getOverlay();if(!overlay||query!=overlay.query){overlay&&cm.removeOverlay(overlay);overlay=searchOverlay(query);cm.addOverlay(overlay);if(cm.showMatchesOnScrollbar){searchState.getScrollbarAnnotate()&&searchState.getScrollbarAnnotate().clear();searchState.setScrollbarAnnotate(cm.showMatchesOnScrollbar(query))}searchState.setOverlay(overlay)}}function findNext(cm,prev,query,repeat){void 0===repeat&&(repeat=1);return cm.operation(function(){for(var pos=cm.getCursor(),cursor=cm.getSearchCursor(query,pos),i=0;repeat>i;i++){var found=cursor.find(prev);0==i&&found&&cursorEqual(cursor.from(),pos)&&(found=cursor.find(prev));if(!found){cursor=cm.getSearchCursor(query,prev?Pos(cm.lastLine()):Pos(cm.firstLine(),0));if(!cursor.find(prev))return}}return cursor.from()})}function clearSearchHighlight(cm){var state=getSearchState(cm);cm.removeOverlay(getSearchState(cm).getOverlay());state.setOverlay(null);if(state.getScrollbarAnnotate()){state.getScrollbarAnnotate().clear();state.setScrollbarAnnotate(null)}}function isInRange(pos,start,end){"number"!=typeof pos&&(pos=pos.line);return start instanceof Array?inArray(pos,start):end?pos>=start&&end>=pos:pos==start}function getUserVisibleLines(cm){var scrollInfo=cm.getScrollInfo(),occludeToleranceTop=6,occludeToleranceBottom=10,from=cm.coordsChar({left:0,top:occludeToleranceTop+scrollInfo.top},"local"),bottomY=scrollInfo.clientHeight-occludeToleranceBottom+scrollInfo.top,to=cm.coordsChar({left:0,top:bottomY},"local");return{top:from.line,bottom:to.line}}function doReplace(cm,confirm,global,lineStart,lineEnd,searchCursor,query,replaceWith,callback){function replaceAll(){cm.operation(function(){for(;!done;){replace();next()}stop()})}function replace(){var text=cm.getRange(searchCursor.from(),searchCursor.to()),newText=text.replace(query,replaceWith);searchCursor.replace(newText)}function next(){for(;searchCursor.findNext()&&isInRange(searchCursor.from(),lineStart,lineEnd);)if(global||!lastPos||searchCursor.from().line!=lastPos.line){cm.scrollIntoView(searchCursor.from(),30);cm.setSelection(searchCursor.from(),searchCursor.to());lastPos=searchCursor.from();done=!1;return}done=!0}function stop(close){close&&close();cm.focus();if(lastPos){cm.setCursor(lastPos);var vim=cm.state.vim;vim.exMode=!1;vim.lastHPos=vim.lastHSPos=lastPos.ch}callback&&callback()}function onPromptKeyDown(e,_value,close){CodeMirror.e_stop(e);var keyName=CodeMirror.keyName(e);switch(keyName){case"Y":replace();next();break;case"N":next();break;case"A":var savedCallback=callback;callback=void 0;cm.operation(replaceAll);callback=savedCallback;break;case"L":replace();case"Q":case"Esc":case"Ctrl-C":case"Ctrl-[":stop(close)}done&&stop(close);return!0}cm.state.vim.exMode=!0;var done=!1,lastPos=searchCursor.from();next();if(done)showConfirm(cm,"No matches for "+query.source);else if(confirm)showPrompt(cm,{prefix:"replace with <strong>"+replaceWith+"</strong> (y/n/a/q/l)",onKeyDown:onPromptKeyDown});else{replaceAll();callback&&callback()}}function exitInsertMode(cm){var vim=cm.state.vim,macroModeState=vimGlobalState.macroModeState,insertModeChangeRegister=vimGlobalState.registerController.getRegister("."),isPlaying=macroModeState.isPlaying,lastChange=macroModeState.lastInsertModeChanges,text=[];if(!isPlaying){for(var selLength=lastChange.inVisualBlock?vim.lastSelection.visualBlock.height:1,changes=lastChange.changes,text=[],i=0;i<changes.length;){text.push(changes[i]);changes[i]instanceof InsertModeKey?i++:i+=selLength}lastChange.changes=text;cm.off("change",onChange);CodeMirror.off(cm.getInputField(),"keydown",onKeyEventTargetKeyDown)}if(!isPlaying&&vim.insertModeRepeat>1){repeatLastEdit(cm,vim,vim.insertModeRepeat-1,!0);vim.lastEditInputState.repeatOverride=vim.insertModeRepeat}delete vim.insertModeRepeat;vim.insertMode=!1;cm.setCursor(cm.getCursor().line,cm.getCursor().ch-1);cm.setOption("keyMap","vim");cm.setOption("disableInput",!0);cm.toggleOverwrite(!1);insertModeChangeRegister.setText(lastChange.changes.join(""));CodeMirror.signal(cm,"vim-mode-change",{mode:"normal"});macroModeState.isRecording&&logInsertModeChange(macroModeState)}function _mapCommand(command){defaultKeymap.unshift(command)}function mapCommand(keys,type,name,args,extra){var command={keys:keys,type:type};command[type]=name;command[type+"Args"]=args;for(var key in extra)command[key]=extra[key];_mapCommand(command)}function executeMacroRegister(cm,vim,macroModeState,registerName){var register=vimGlobalState.registerController.getRegister(registerName);if(":"!=registerName){var keyBuffer=register.keyBuffer,imc=0;macroModeState.isPlaying=!0;macroModeState.replaySearchQueries=register.searchQueries.slice(0);for(var i=0;i<keyBuffer.length;i++)for(var match,key,text=keyBuffer[i];text;){match=/<\w+-.+?>|<\w+>|./.exec(text);key=match[0];text=text.substring(match.index+key.length);CodeMirror.Vim.handleKey(cm,key,"macro");if(vim.insertMode){var changes=register.insertModeChanges[imc++].changes;vimGlobalState.macroModeState.lastInsertModeChanges.changes=changes;repeatInsertModeChanges(cm,changes,1);exitInsertMode(cm)}}macroModeState.isPlaying=!1}else{register.keyBuffer[0]&&exCommandDispatcher.processCommand(cm,register.keyBuffer[0]);macroModeState.isPlaying=!1}}function logKey(macroModeState,key){if(!macroModeState.isPlaying){var registerName=macroModeState.latestRegister,register=vimGlobalState.registerController.getRegister(registerName);register&&register.pushText(key)}}function logInsertModeChange(macroModeState){if(!macroModeState.isPlaying){var registerName=macroModeState.latestRegister,register=vimGlobalState.registerController.getRegister(registerName);register&&register.pushInsertModeChanges&&register.pushInsertModeChanges(macroModeState.lastInsertModeChanges)}}function logSearchQuery(macroModeState,query){if(!macroModeState.isPlaying){var registerName=macroModeState.latestRegister,register=vimGlobalState.registerController.getRegister(registerName);register&&register.pushSearchQuery&&register.pushSearchQuery(query)}}function onChange(_cm,changeObj){var macroModeState=vimGlobalState.macroModeState,lastChange=macroModeState.lastInsertModeChanges;if(!macroModeState.isPlaying)for(;changeObj;){lastChange.expectCursorActivityForChange=!0;if("+input"==changeObj.origin||"paste"==changeObj.origin||void 0===changeObj.origin){var text=changeObj.text.join("\n");lastChange.changes.push(text)}changeObj=changeObj.next}}function onCursorActivity(cm){var vim=cm.state.vim;if(vim.insertMode){var macroModeState=vimGlobalState.macroModeState;if(macroModeState.isPlaying)return;var lastChange=macroModeState.lastInsertModeChanges;lastChange.expectCursorActivityForChange?lastChange.expectCursorActivityForChange=!1:lastChange.changes=[]}else cm.curOp.isVimOp||handleExternalSelection(cm,vim);vim.visualMode&&updateFakeCursor(cm)}function updateFakeCursor(cm){var vim=cm.state.vim,from=clipCursorToContent(cm,copyCursor(vim.sel.head)),to=offsetCursor(from,0,1);vim.fakeCursor&&vim.fakeCursor.clear();vim.fakeCursor=cm.markText(from,to,{className:"cm-animate-fat-cursor"})}function handleExternalSelection(cm,vim){var anchor=cm.getCursor("anchor"),head=cm.getCursor("head");if(vim.visualMode&&!cm.somethingSelected())exitVisualMode(cm,!1);else if(!vim.visualMode&&!vim.insertMode&&cm.somethingSelected()){vim.visualMode=!0;vim.visualLine=!1;CodeMirror.signal(cm,"vim-mode-change",{mode:"visual"})}if(vim.visualMode){var headOffset=cursorIsBefore(head,anchor)?0:-1,anchorOffset=cursorIsBefore(head,anchor)?-1:0;head=offsetCursor(head,0,headOffset);anchor=offsetCursor(anchor,0,anchorOffset);vim.sel={anchor:anchor,head:head};updateMark(cm,vim,"<",cursorMin(head,anchor));updateMark(cm,vim,">",cursorMax(head,anchor))}else vim.insertMode||(vim.lastHPos=cm.getCursor().ch)}function InsertModeKey(keyName){this.keyName=keyName}function onKeyEventTargetKeyDown(e){function onKeyFound(){lastChange.changes.push(new InsertModeKey(keyName));return!0}var macroModeState=vimGlobalState.macroModeState,lastChange=macroModeState.lastInsertModeChanges,keyName=CodeMirror.keyName(e);keyName&&(-1!=keyName.indexOf("Delete")||-1!=keyName.indexOf("Backspace"))&&CodeMirror.lookupKey(keyName,"vim-insert",onKeyFound)}function repeatLastEdit(cm,vim,repeat,repeatForInsert){function repeatCommand(){isAction?commandDispatcher.processAction(cm,vim,vim.lastEditActionCommand):commandDispatcher.evalInput(cm,vim)}function repeatInsert(repeat){if(macroModeState.lastInsertModeChanges.changes.length>0){repeat=vim.lastEditActionCommand?repeat:1;var changeObject=macroModeState.lastInsertModeChanges;repeatInsertModeChanges(cm,changeObject.changes,repeat)}}var macroModeState=vimGlobalState.macroModeState;macroModeState.isPlaying=!0;var isAction=!!vim.lastEditActionCommand,cachedInputState=vim.inputState;vim.inputState=vim.lastEditInputState;if(isAction&&vim.lastEditActionCommand.interlaceInsertRepeat)for(var i=0;repeat>i;i++){repeatCommand();repeatInsert(1)}else{repeatForInsert||repeatCommand();repeatInsert(repeat)}vim.inputState=cachedInputState;vim.insertMode&&!repeatForInsert&&exitInsertMode(cm);macroModeState.isPlaying=!1}function repeatInsertModeChanges(cm,changes,repeat){function keyHandler(binding){"string"==typeof binding?CodeMirror.commands[binding](cm):binding(cm);return!0}var head=cm.getCursor("head"),inVisualBlock=vimGlobalState.macroModeState.lastInsertModeChanges.inVisualBlock;if(inVisualBlock){var vim=cm.state.vim,lastSel=vim.lastSelection,offset=getOffset(lastSel.anchor,lastSel.head);selectForInsert(cm,head,offset.line+1);repeat=cm.listSelections().length;cm.setCursor(head)}for(var i=0;repeat>i;i++){inVisualBlock&&cm.setCursor(offsetCursor(head,i,0));for(var j=0;j<changes.length;j++){var change=changes[j];if(change instanceof InsertModeKey)CodeMirror.lookupKey(change.keyName,"vim-insert",keyHandler);else{var cur=cm.getCursor();cm.replaceRange(change,cur,cur)}}}inVisualBlock&&cm.setCursor(offsetCursor(head,0,1))}CodeMirror.defineOption("vimMode",!1,function(cm,val,prev){val&&"vim"!=cm.getOption("keyMap")?cm.setOption("keyMap","vim"):!val&&prev!=CodeMirror.Init&&/^vim/.test(cm.getOption("keyMap"))&&cm.setOption("keyMap","default")});var modifiers={Shift:"S",Ctrl:"C",Alt:"A",Cmd:"D",Mod:"A"},specialKeys={Enter:"CR",Backspace:"BS",Delete:"Del"},numberRegex=/[\d]/,wordCharTest=[CodeMirror.isWordChar,function(ch){return ch&&!CodeMirror.isWordChar(ch)&&!/\s/.test(ch)}],bigWordCharTest=[function(ch){return/\S/.test(ch)}],upperCaseAlphabet=makeKeyRange(65,26),lowerCaseAlphabet=makeKeyRange(97,26),numbers=makeKeyRange(48,10),validMarks=[].concat(upperCaseAlphabet,lowerCaseAlphabet,numbers,["<",">"]),validRegisters=[].concat(upperCaseAlphabet,lowerCaseAlphabet,numbers,["-",'"',".",":","/"]),options={};defineOption("filetype",void 0,"string",["ft"],function(name,cm){if(void 0!==cm){if(void 0===name){var mode=cm.getOption("mode");return"null"==mode?"":mode}var mode=""==name?"null":name;cm.setOption("mode",mode)}});var createCircularJumpList=function(){function add(cm,oldCur,newCur){function useNextSlot(cursor){var next=++pointer%size,trashMark=buffer[next];trashMark&&trashMark.clear();buffer[next]=cm.setBookmark(cursor)}var current=pointer%size,curMark=buffer[current];if(curMark){var markPos=curMark.find();markPos&&!cursorEqual(markPos,oldCur)&&useNextSlot(oldCur)}else useNextSlot(oldCur);useNextSlot(newCur);head=pointer;tail=pointer-size+1;0>tail&&(tail=0)}function move(cm,offset){pointer+=offset;pointer>head?pointer=head:tail>pointer&&(pointer=tail);var mark=buffer[(size+pointer)%size];if(mark&&!mark.find()){var newCur,inc=offset>0?1:-1,oldCur=cm.getCursor();do{pointer+=inc;mark=buffer[(size+pointer)%size];if(mark&&(newCur=mark.find())&&!cursorEqual(oldCur,newCur))break}while(head>pointer&&pointer>tail)}return mark}var size=100,pointer=-1,head=0,tail=0,buffer=new Array(size);return{cachedCursor:void 0,add:add,move:move}},createInsertModeChanges=function(c){return c?{changes:c.changes,expectCursorActivityForChange:c.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};MacroModeState.prototype={exitMacroRecordMode:function(){var macroModeState=vimGlobalState.macroModeState;macroModeState.onRecordingDone&&macroModeState.onRecordingDone();macroModeState.onRecordingDone=void 0;macroModeState.isRecording=!1},enterMacroRecordMode:function(cm,registerName){var register=vimGlobalState.registerController.getRegister(registerName);if(register){register.clear();this.latestRegister=registerName;cm.openDialog&&(this.onRecordingDone=cm.openDialog("(recording)["+registerName+"]",null,{bottom:!0}));this.isRecording=!0}}};var vimGlobalState,lastInsertModeKeyTimer,vimApi={buildKeyMap:function(){},getRegisterController:function(){return vimGlobalState.registerController},resetVimGlobalState_:resetVimGlobalState,getVimGlobalState_:function(){return vimGlobalState},maybeInitVimState_:maybeInitVimState,suppressErrorLogging:!1,InsertModeKey:InsertModeKey,map:function(lhs,rhs,ctx){exCommandDispatcher.map(lhs,rhs,ctx)},setOption:setOption,getOption:getOption,defineOption:defineOption,defineEx:function(name,prefix,func){if(prefix){if(0!==name.indexOf(prefix))throw new Error('(Vim.defineEx) "'+prefix+'" is not a prefix of "'+name+'", command not registered')}else prefix=name;exCommands[name]=func;exCommandDispatcher.commandMap_[prefix]={name:name,shortName:prefix,type:"api"}},handleKey:function(cm,key,origin){var command=this.findKey(cm,key,origin);return"function"==typeof command?command():void 0},findKey:function(cm,key,origin){function handleMacroRecording(){var macroModeState=vimGlobalState.macroModeState;if(macroModeState.isRecording){if("q"==key){macroModeState.exitMacroRecordMode();clearInputState(cm);return!0}"mapping"!=origin&&logKey(macroModeState,key)}}function handleEsc(){if("<Esc>"==key){clearInputState(cm);vim.visualMode?exitVisualMode(cm):vim.insertMode&&exitInsertMode(cm);return!0}}function doKeyToKey(keys){for(var match;keys;){match=/<\w+-.+?>|<\w+>|./.exec(keys);key=match[0];keys=keys.substring(match.index+key.length);CodeMirror.Vim.handleKey(cm,key,"mapping")}}function handleKeyInsertMode(){if(handleEsc())return!0;for(var keys=vim.inputState.keyBuffer=vim.inputState.keyBuffer+key,keysAreChars=1==key.length,match=commandDispatcher.matchCommand(keys,defaultKeymap,vim.inputState,"insert");keys.length>1&&"full"!=match.type;){var keys=vim.inputState.keyBuffer=keys.slice(1),thisMatch=commandDispatcher.matchCommand(keys,defaultKeymap,vim.inputState,"insert");"none"!=thisMatch.type&&(match=thisMatch)}if("none"==match.type){clearInputState(cm);return!1}if("partial"==match.type){lastInsertModeKeyTimer&&window.clearTimeout(lastInsertModeKeyTimer);lastInsertModeKeyTimer=window.setTimeout(function(){vim.insertMode&&vim.inputState.keyBuffer&&clearInputState(cm)},getOption("insertModeEscKeysTimeout"));return!keysAreChars}lastInsertModeKeyTimer&&window.clearTimeout(lastInsertModeKeyTimer);if(keysAreChars){var here=cm.getCursor();cm.replaceRange("",offsetCursor(here,0,-(keys.length-1)),here,"+input")}clearInputState(cm);return match.command}function handleKeyNonInsertMode(){if(handleMacroRecording()||handleEsc())return!0;var keys=vim.inputState.keyBuffer=vim.inputState.keyBuffer+key;if(/^[1-9]\d*$/.test(keys))return!0;var keysMatcher=/^(\d*)(.*)$/.exec(keys);if(!keysMatcher){clearInputState(cm);return!1}var context=vim.visualMode?"visual":"normal",match=commandDispatcher.matchCommand(keysMatcher[2]||keysMatcher[1],defaultKeymap,vim.inputState,context);if("none"==match.type){clearInputState(cm);return!1}if("partial"==match.type)return!0;vim.inputState.keyBuffer="";var keysMatcher=/^(\d*)(.*)$/.exec(keys);keysMatcher[1]&&"0"!=keysMatcher[1]&&vim.inputState.pushRepeatDigit(keysMatcher[1]);return match.command}var command,vim=maybeInitVimState(cm);command=vim.insertMode?handleKeyInsertMode():handleKeyNonInsertMode();return command===!1?void 0:command===!0?function(){}:function(){return cm.operation(function(){cm.curOp.isVimOp=!0;try{"keyToKey"==command.type?doKeyToKey(command.toKeys):commandDispatcher.processCommand(cm,vim,command)}catch(e){cm.state.vim=void 0;maybeInitVimState(cm);CodeMirror.Vim.suppressErrorLogging||console.log(e);throw e}return!0})}},handleEx:function(cm,input){exCommandDispatcher.processCommand(cm,input)},defineMotion:defineMotion,defineAction:defineAction,defineOperator:defineOperator,mapCommand:mapCommand,_mapCommand:_mapCommand,defineRegister:defineRegister,exitVisualMode:exitVisualMode,exitInsertMode:exitInsertMode};InputState.prototype.pushRepeatDigit=function(n){this.operator?this.motionRepeat=this.motionRepeat.concat(n):this.prefixRepeat=this.prefixRepeat.concat(n)};InputState.prototype.getRepeat=function(){var repeat=0;if(this.prefixRepeat.length>0||this.motionRepeat.length>0){repeat=1;this.prefixRepeat.length>0&&(repeat*=parseInt(this.prefixRepeat.join(""),10));this.motionRepeat.length>0&&(repeat*=parseInt(this.motionRepeat.join(""),10))}return repeat};Register.prototype={setText:function(text,linewise,blockwise){this.keyBuffer=[text||""];this.linewise=!!linewise;this.blockwise=!!blockwise},pushText:function(text,linewise){if(linewise){this.linewise||this.keyBuffer.push("\n");this.linewise=!0}this.keyBuffer.push(text)},pushInsertModeChanges:function(changes){this.insertModeChanges.push(createInsertModeChanges(changes))},pushSearchQuery:function(query){this.searchQueries.push(query)},clear:function(){this.keyBuffer=[];this.insertModeChanges=[];this.searchQueries=[];this.linewise=!1},toString:function(){return this.keyBuffer.join("")}};RegisterController.prototype={pushText:function(registerName,operator,text,linewise,blockwise){linewise&&"\n"==text.charAt(0)&&(text=text.slice(1)+"\n");linewise&&"\n"!==text.charAt(text.length-1)&&(text+="\n");var register=this.isValidRegister(registerName)?this.getRegister(registerName):null;if(register){var append=isUpperCase(registerName);append?register.pushText(text,linewise):register.setText(text,linewise,blockwise);this.unnamedRegister.setText(register.toString(),linewise)}else{switch(operator){case"yank":this.registers[0]=new Register(text,linewise,blockwise);break;case"delete":case"change":if(-1==text.indexOf("\n"))this.registers["-"]=new Register(text,linewise);else{this.shiftNumericRegisters_();this.registers[1]=new Register(text,linewise)}}this.unnamedRegister.setText(text,linewise,blockwise)}},getRegister:function(name){if(!this.isValidRegister(name))return this.unnamedRegister;name=name.toLowerCase();this.registers[name]||(this.registers[name]=new Register);return this.registers[name]},isValidRegister:function(name){return name&&inArray(name,validRegisters)},shiftNumericRegisters_:function(){for(var i=9;i>=2;i--)this.registers[i]=this.getRegister(""+(i-1))}};HistoryController.prototype={nextMatch:function(input,up){var historyBuffer=this.historyBuffer,dir=up?-1:1;null===this.initialPrefix&&(this.initialPrefix=input);for(var i=this.iterator+dir;up?i>=0:i<historyBuffer.length;i+=dir)for(var element=historyBuffer[i],j=0;j<=element.length;j++)if(this.initialPrefix==element.substring(0,j)){this.iterator=i;return element}if(i>=historyBuffer.length){this.iterator=historyBuffer.length;return this.initialPrefix}return 0>i?input:void 0},pushInput:function(input){var index=this.historyBuffer.indexOf(input);index>-1&&this.historyBuffer.splice(index,1);input.length&&this.historyBuffer.push(input)},reset:function(){this.initialPrefix=null;this.iterator=this.historyBuffer.length}};var commandDispatcher={matchCommand:function(keys,keyMap,inputState,context){var matches=commandMatches(keys,keyMap,context,inputState);if(!matches.full&&!matches.partial)return{type:"none"};if(!matches.full&&matches.partial)return{type:"partial"};for(var bestMatch,i=0;i<matches.full.length;i++){var match=matches.full[i];bestMatch||(bestMatch=match)}"<character>"==bestMatch.keys.slice(-11)&&(inputState.selectedCharacter=lastChar(keys));return{type:"full",command:bestMatch}},processCommand:function(cm,vim,command){vim.inputState.repeatOverride=command.repeatOverride;switch(command.type){case"motion":this.processMotion(cm,vim,command);break;case"operator":this.processOperator(cm,vim,command);break;case"operatorMotion":this.processOperatorMotion(cm,vim,command);break;case"action":this.processAction(cm,vim,command);break;case"search":this.processSearch(cm,vim,command);break;case"ex":case"keyToEx":this.processEx(cm,vim,command)}},processMotion:function(cm,vim,command){vim.inputState.motion=command.motion;vim.inputState.motionArgs=copyArgs(command.motionArgs);this.evalInput(cm,vim)},processOperator:function(cm,vim,command){var inputState=vim.inputState;if(inputState.operator){if(inputState.operator==command.operator){inputState.motion="expandToLine";inputState.motionArgs={linewise:!0};this.evalInput(cm,vim);return}clearInputState(cm)}inputState.operator=command.operator;inputState.operatorArgs=copyArgs(command.operatorArgs);vim.visualMode&&this.evalInput(cm,vim)},processOperatorMotion:function(cm,vim,command){var visualMode=vim.visualMode,operatorMotionArgs=copyArgs(command.operatorMotionArgs);operatorMotionArgs&&visualMode&&operatorMotionArgs.visualLine&&(vim.visualLine=!0);this.processOperator(cm,vim,command);visualMode||this.processMotion(cm,vim,command)},processAction:function(cm,vim,command){var inputState=vim.inputState,repeat=inputState.getRepeat(),repeatIsExplicit=!!repeat,actionArgs=copyArgs(command.actionArgs)||{};inputState.selectedCharacter&&(actionArgs.selectedCharacter=inputState.selectedCharacter);command.operator&&this.processOperator(cm,vim,command);command.motion&&this.processMotion(cm,vim,command);(command.motion||command.operator)&&this.evalInput(cm,vim);actionArgs.repeat=repeat||1;actionArgs.repeatIsExplicit=repeatIsExplicit;actionArgs.registerName=inputState.registerName;clearInputState(cm);vim.lastMotion=null;command.isEdit&&this.recordLastEdit(vim,inputState,command);actions[command.action](cm,actionArgs,vim)},processSearch:function(cm,vim,command){function handleQuery(query,ignoreCase,smartCase){vimGlobalState.searchHistoryController.pushInput(query);vimGlobalState.searchHistoryController.reset();try{updateSearchQuery(cm,query,ignoreCase,smartCase)}catch(e){showConfirm(cm,"Invalid regex: "+query);clearInputState(cm);return}commandDispatcher.processMotion(cm,vim,{type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:command.searchArgs.toJumplist}})}function onPromptClose(query){cm.scrollTo(originalScrollPos.left,originalScrollPos.top);handleQuery(query,!0,!0);var macroModeState=vimGlobalState.macroModeState;macroModeState.isRecording&&logSearchQuery(macroModeState,query)}function onPromptKeyUp(e,query,close){var up,keyName=CodeMirror.keyName(e);if("Up"==keyName||"Down"==keyName){up="Up"==keyName?!0:!1;query=vimGlobalState.searchHistoryController.nextMatch(query,up)||"";close(query)}else"Left"!=keyName&&"Right"!=keyName&&"Ctrl"!=keyName&&"Alt"!=keyName&&"Shift"!=keyName&&vimGlobalState.searchHistoryController.reset();var parsedQuery;try{parsedQuery=updateSearchQuery(cm,query,!0,!0)}catch(e){}if(parsedQuery)cm.scrollIntoView(findNext(cm,!forward,parsedQuery),30);else{clearSearchHighlight(cm);cm.scrollTo(originalScrollPos.left,originalScrollPos.top)}}function onPromptKeyDown(e,query,close){var keyName=CodeMirror.keyName(e);if("Esc"==keyName||"Ctrl-C"==keyName||"Ctrl-["==keyName||"Backspace"==keyName&&""==query){vimGlobalState.searchHistoryController.pushInput(query);vimGlobalState.searchHistoryController.reset();updateSearchQuery(cm,originalQuery);clearSearchHighlight(cm);cm.scrollTo(originalScrollPos.left,originalScrollPos.top);CodeMirror.e_stop(e);clearInputState(cm);close();cm.focus()}else if("Ctrl-U"==keyName){CodeMirror.e_stop(e);close("")}}if(cm.getSearchCursor){var forward=command.searchArgs.forward,wholeWordOnly=command.searchArgs.wholeWordOnly;getSearchState(cm).setReversed(!forward);var promptPrefix=forward?"/":"?",originalQuery=getSearchState(cm).getQuery(),originalScrollPos=cm.getScrollInfo();switch(command.searchArgs.querySrc){case"prompt":var macroModeState=vimGlobalState.macroModeState;if(macroModeState.isPlaying){var query=macroModeState.replaySearchQueries.shift();handleQuery(query,!0,!1)}else showPrompt(cm,{onClose:onPromptClose,prefix:promptPrefix,desc:searchPromptDesc,onKeyUp:onPromptKeyUp,onKeyDown:onPromptKeyDown});break;case"wordUnderCursor":var word=expandWordUnderCursor(cm,!1,!0,!1,!0),isKeyword=!0;if(!word){word=expandWordUnderCursor(cm,!1,!0,!1,!1);isKeyword=!1}if(!word)return;var query=cm.getLine(word.start.line).substring(word.start.ch,word.end.ch);query=isKeyword&&wholeWordOnly?"\\b"+query+"\\b":escapeRegex(query);vimGlobalState.jumpList.cachedCursor=cm.getCursor();cm.setCursor(word.start);handleQuery(query,!0,!1)}}},processEx:function(cm,vim,command){function onPromptClose(input){vimGlobalState.exCommandHistoryController.pushInput(input);vimGlobalState.exCommandHistoryController.reset();exCommandDispatcher.processCommand(cm,input)}function onPromptKeyDown(e,input,close){var up,keyName=CodeMirror.keyName(e);if("Esc"==keyName||"Ctrl-C"==keyName||"Ctrl-["==keyName||"Backspace"==keyName&&""==input){
3
- vimGlobalState.exCommandHistoryController.pushInput(input);vimGlobalState.exCommandHistoryController.reset();CodeMirror.e_stop(e);clearInputState(cm);close();cm.focus()}if("Up"==keyName||"Down"==keyName){up="Up"==keyName?!0:!1;input=vimGlobalState.exCommandHistoryController.nextMatch(input,up)||"";close(input)}else if("Ctrl-U"==keyName){CodeMirror.e_stop(e);close("")}else"Left"!=keyName&&"Right"!=keyName&&"Ctrl"!=keyName&&"Alt"!=keyName&&"Shift"!=keyName&&vimGlobalState.exCommandHistoryController.reset()}"keyToEx"==command.type?exCommandDispatcher.processCommand(cm,command.exArgs.input):vim.visualMode?showPrompt(cm,{onClose:onPromptClose,prefix:":",value:"'<,'>",onKeyDown:onPromptKeyDown}):showPrompt(cm,{onClose:onPromptClose,prefix:":",onKeyDown:onPromptKeyDown})},evalInput:function(cm,vim){var newHead,newAnchor,repeat,inputState=vim.inputState,motion=inputState.motion,motionArgs=inputState.motionArgs||{},operator=inputState.operator,operatorArgs=inputState.operatorArgs||{},registerName=inputState.registerName,sel=vim.sel,origHead=copyCursor(vim.visualMode?clipCursorToContent(cm,sel.head):cm.getCursor("head")),origAnchor=copyCursor(vim.visualMode?clipCursorToContent(cm,sel.anchor):cm.getCursor("anchor")),oldHead=copyCursor(origHead),oldAnchor=copyCursor(origAnchor);operator&&this.recordLastEdit(vim,inputState);repeat=void 0!==inputState.repeatOverride?inputState.repeatOverride:inputState.getRepeat();if(repeat>0&&motionArgs.explicitRepeat)motionArgs.repeatIsExplicit=!0;else if(motionArgs.noRepeat||!motionArgs.explicitRepeat&&0===repeat){repeat=1;motionArgs.repeatIsExplicit=!1}inputState.selectedCharacter&&(motionArgs.selectedCharacter=operatorArgs.selectedCharacter=inputState.selectedCharacter);motionArgs.repeat=repeat;clearInputState(cm);if(motion){var motionResult=motions[motion](cm,origHead,motionArgs,vim);vim.lastMotion=motions[motion];if(!motionResult)return;if(motionArgs.toJumplist){var jumpList=vimGlobalState.jumpList,cachedCursor=jumpList.cachedCursor;if(cachedCursor){recordJumpPosition(cm,cachedCursor,motionResult);delete jumpList.cachedCursor}else recordJumpPosition(cm,origHead,motionResult)}if(motionResult instanceof Array){newAnchor=motionResult[0];newHead=motionResult[1]}else newHead=motionResult;newHead||(newHead=copyCursor(origHead));if(vim.visualMode){vim.visualBlock&&newHead.ch===1/0||(newHead=clipCursorToContent(cm,newHead,vim.visualBlock));newAnchor&&(newAnchor=clipCursorToContent(cm,newAnchor,!0));newAnchor=newAnchor||oldAnchor;sel.anchor=newAnchor;sel.head=newHead;updateCmSelection(cm);updateMark(cm,vim,"<",cursorIsBefore(newAnchor,newHead)?newAnchor:newHead);updateMark(cm,vim,">",cursorIsBefore(newAnchor,newHead)?newHead:newAnchor)}else if(!operator){newHead=clipCursorToContent(cm,newHead);cm.setCursor(newHead.line,newHead.ch)}}if(operator){if(operatorArgs.lastSel){newAnchor=oldAnchor;var lastSel=operatorArgs.lastSel,lineOffset=Math.abs(lastSel.head.line-lastSel.anchor.line),chOffset=Math.abs(lastSel.head.ch-lastSel.anchor.ch);newHead=lastSel.visualLine?Pos(oldAnchor.line+lineOffset,oldAnchor.ch):lastSel.visualBlock?Pos(oldAnchor.line+lineOffset,oldAnchor.ch+chOffset):lastSel.head.line==lastSel.anchor.line?Pos(oldAnchor.line,oldAnchor.ch+chOffset):Pos(oldAnchor.line+lineOffset,oldAnchor.ch);vim.visualMode=!0;vim.visualLine=lastSel.visualLine;vim.visualBlock=lastSel.visualBlock;sel=vim.sel={anchor:newAnchor,head:newHead};updateCmSelection(cm)}else vim.visualMode&&(operatorArgs.lastSel={anchor:copyCursor(sel.anchor),head:copyCursor(sel.head),visualBlock:vim.visualBlock,visualLine:vim.visualLine});var curStart,curEnd,linewise,mode,cmSel;if(vim.visualMode){curStart=cursorMin(sel.head,sel.anchor);curEnd=cursorMax(sel.head,sel.anchor);linewise=vim.visualLine||operatorArgs.linewise;mode=vim.visualBlock?"block":linewise?"line":"char";cmSel=makeCmSelection(cm,{anchor:curStart,head:curEnd},mode);if(linewise){var ranges=cmSel.ranges;if("block"==mode)for(var i=0;i<ranges.length;i++)ranges[i].head.ch=lineLength(cm,ranges[i].head.line);else"line"==mode&&(ranges[0].head=Pos(ranges[0].head.line+1,0))}}else{curStart=copyCursor(newAnchor||oldAnchor);curEnd=copyCursor(newHead||oldHead);if(cursorIsBefore(curEnd,curStart)){var tmp=curStart;curStart=curEnd;curEnd=tmp}linewise=motionArgs.linewise||operatorArgs.linewise;linewise?expandSelectionToLine(cm,curStart,curEnd):motionArgs.forward&&clipToLine(cm,curStart,curEnd);mode="char";var exclusive=!motionArgs.inclusive||linewise;cmSel=makeCmSelection(cm,{anchor:curStart,head:curEnd},mode,exclusive)}cm.setSelections(cmSel.ranges,cmSel.primary);vim.lastMotion=null;operatorArgs.repeat=repeat;operatorArgs.registerName=registerName;operatorArgs.linewise=linewise;var operatorMoveTo=operators[operator](cm,operatorArgs,cmSel.ranges,oldAnchor,newHead);vim.visualMode&&exitVisualMode(cm,null!=operatorMoveTo);operatorMoveTo&&cm.setCursor(operatorMoveTo)}},recordLastEdit:function(vim,inputState,actionCommand){var macroModeState=vimGlobalState.macroModeState;if(!macroModeState.isPlaying){vim.lastEditInputState=inputState;vim.lastEditActionCommand=actionCommand;macroModeState.lastInsertModeChanges.changes=[];macroModeState.lastInsertModeChanges.expectCursorActivityForChange=!1}}},motions={moveToTopLine:function(cm,_head,motionArgs){var line=getUserVisibleLines(cm).top+motionArgs.repeat-1;return Pos(line,findFirstNonWhiteSpaceCharacter(cm.getLine(line)))},moveToMiddleLine:function(cm){var range=getUserVisibleLines(cm),line=Math.floor(.5*(range.top+range.bottom));return Pos(line,findFirstNonWhiteSpaceCharacter(cm.getLine(line)))},moveToBottomLine:function(cm,_head,motionArgs){var line=getUserVisibleLines(cm).bottom-motionArgs.repeat+1;return Pos(line,findFirstNonWhiteSpaceCharacter(cm.getLine(line)))},expandToLine:function(_cm,head,motionArgs){var cur=head;return Pos(cur.line+motionArgs.repeat-1,1/0)},findNext:function(cm,_head,motionArgs){var state=getSearchState(cm),query=state.getQuery();if(query){var prev=!motionArgs.forward;prev=state.isReversed()?!prev:prev;highlightSearchMatches(cm,query);return findNext(cm,prev,query,motionArgs.repeat)}},goToMark:function(cm,_head,motionArgs,vim){var mark=vim.marks[motionArgs.selectedCharacter];if(mark){var pos=mark.find();return motionArgs.linewise?{line:pos.line,ch:findFirstNonWhiteSpaceCharacter(cm.getLine(pos.line))}:pos}return null},moveToOtherHighlightedEnd:function(cm,_head,motionArgs,vim){if(vim.visualBlock&&motionArgs.sameLine){var sel=vim.sel;return[clipCursorToContent(cm,Pos(sel.anchor.line,sel.head.ch)),clipCursorToContent(cm,Pos(sel.head.line,sel.anchor.ch))]}return[vim.sel.head,vim.sel.anchor]},jumpToMark:function(cm,head,motionArgs,vim){for(var best=head,i=0;i<motionArgs.repeat;i++){var cursor=best;for(var key in vim.marks)if(isLowerCase(key)){var mark=vim.marks[key].find(),isWrongDirection=motionArgs.forward?cursorIsBefore(mark,cursor):cursorIsBefore(cursor,mark);if(!(isWrongDirection||motionArgs.linewise&&mark.line==cursor.line)){var equal=cursorEqual(cursor,best),between=motionArgs.forward?cursorIsBetween(cursor,mark,best):cursorIsBetween(best,mark,cursor);(equal||between)&&(best=mark)}}}motionArgs.linewise&&(best=Pos(best.line,findFirstNonWhiteSpaceCharacter(cm.getLine(best.line))));return best},moveByCharacters:function(_cm,head,motionArgs){var cur=head,repeat=motionArgs.repeat,ch=motionArgs.forward?cur.ch+repeat:cur.ch-repeat;return Pos(cur.line,ch)},moveByLines:function(cm,head,motionArgs,vim){var cur=head,endCh=cur.ch;switch(vim.lastMotion){case this.moveByLines:case this.moveByDisplayLines:case this.moveByScroll:case this.moveToColumn:case this.moveToEol:endCh=vim.lastHPos;break;default:vim.lastHPos=endCh}var repeat=motionArgs.repeat+(motionArgs.repeatOffset||0),line=motionArgs.forward?cur.line+repeat:cur.line-repeat,first=cm.firstLine(),last=cm.lastLine();if(!(first>line&&cur.line==first||line>last&&cur.line==last)){if(motionArgs.toFirstChar){endCh=findFirstNonWhiteSpaceCharacter(cm.getLine(line));vim.lastHPos=endCh}vim.lastHSPos=cm.charCoords(Pos(line,endCh),"div").left;return Pos(line,endCh)}},moveByDisplayLines:function(cm,head,motionArgs,vim){var cur=head;switch(vim.lastMotion){case this.moveByDisplayLines:case this.moveByScroll:case this.moveByLines:case this.moveToColumn:case this.moveToEol:break;default:vim.lastHSPos=cm.charCoords(cur,"div").left}var repeat=motionArgs.repeat,res=cm.findPosV(cur,motionArgs.forward?repeat:-repeat,"line",vim.lastHSPos);if(res.hitSide)if(motionArgs.forward)var lastCharCoords=cm.charCoords(res,"div"),goalCoords={top:lastCharCoords.top+8,left:vim.lastHSPos},res=cm.coordsChar(goalCoords,"div");else{var resCoords=cm.charCoords(Pos(cm.firstLine(),0),"div");resCoords.left=vim.lastHSPos;res=cm.coordsChar(resCoords,"div")}vim.lastHPos=res.ch;return res},moveByPage:function(cm,head,motionArgs){var curStart=head,repeat=motionArgs.repeat;return cm.findPosV(curStart,motionArgs.forward?repeat:-repeat,"page")},moveByParagraph:function(cm,head,motionArgs){var dir=motionArgs.forward?1:-1;return findParagraph(cm,head,motionArgs.repeat,dir)},moveByScroll:function(cm,head,motionArgs,vim){var scrollbox=cm.getScrollInfo(),curEnd=null,repeat=motionArgs.repeat;repeat||(repeat=scrollbox.clientHeight/(2*cm.defaultTextHeight()));var orig=cm.charCoords(head,"local");motionArgs.repeat=repeat;var curEnd=motions.moveByDisplayLines(cm,head,motionArgs,vim);if(!curEnd)return null;var dest=cm.charCoords(curEnd,"local");cm.scrollTo(null,scrollbox.top+dest.top-orig.top);return curEnd},moveByWords:function(cm,head,motionArgs){return moveToWord(cm,head,motionArgs.repeat,!!motionArgs.forward,!!motionArgs.wordEnd,!!motionArgs.bigWord)},moveTillCharacter:function(cm,_head,motionArgs){var repeat=motionArgs.repeat,curEnd=moveToCharacter(cm,repeat,motionArgs.forward,motionArgs.selectedCharacter),increment=motionArgs.forward?-1:1;recordLastCharacterSearch(increment,motionArgs);if(!curEnd)return null;curEnd.ch+=increment;return curEnd},moveToCharacter:function(cm,head,motionArgs){var repeat=motionArgs.repeat;recordLastCharacterSearch(0,motionArgs);return moveToCharacter(cm,repeat,motionArgs.forward,motionArgs.selectedCharacter)||head},moveToSymbol:function(cm,head,motionArgs){var repeat=motionArgs.repeat;return findSymbol(cm,repeat,motionArgs.forward,motionArgs.selectedCharacter)||head},moveToColumn:function(cm,head,motionArgs,vim){var repeat=motionArgs.repeat;vim.lastHPos=repeat-1;vim.lastHSPos=cm.charCoords(head,"div").left;return moveToColumn(cm,repeat)},moveToEol:function(cm,head,motionArgs,vim){var cur=head;vim.lastHPos=1/0;var retval=Pos(cur.line+motionArgs.repeat-1,1/0),end=cm.clipPos(retval);end.ch--;vim.lastHSPos=cm.charCoords(end,"div").left;return retval},moveToFirstNonWhiteSpaceCharacter:function(cm,head){var cursor=head;return Pos(cursor.line,findFirstNonWhiteSpaceCharacter(cm.getLine(cursor.line)))},moveToMatchedSymbol:function(cm,head){var symbol,cursor=head,line=cursor.line,ch=cursor.ch,lineText=cm.getLine(line);do{symbol=lineText.charAt(ch++);if(symbol&&isMatchableSymbol(symbol)){var style=cm.getTokenTypeAt(Pos(line,ch));if("string"!==style&&"comment"!==style)break}}while(symbol);if(symbol){var matched=cm.findMatchingBracket(Pos(line,ch));return matched.to}return cursor},moveToStartOfLine:function(_cm,head){return Pos(head.line,0)},moveToLineOrEdgeOfDocument:function(cm,_head,motionArgs){var lineNum=motionArgs.forward?cm.lastLine():cm.firstLine();motionArgs.repeatIsExplicit&&(lineNum=motionArgs.repeat-cm.getOption("firstLineNumber"));return Pos(lineNum,findFirstNonWhiteSpaceCharacter(cm.getLine(lineNum)))},textObjectManipulation:function(cm,head,motionArgs,vim){var mirroredPairs={"(":")",")":"(","{":"}","}":"{","[":"]","]":"["},selfPaired={"'":!0,'"':!0},character=motionArgs.selectedCharacter;"b"==character?character="(":"B"==character&&(character="{");var tmp,inclusive=!motionArgs.textObjectInner;if(mirroredPairs[character])tmp=selectCompanionObject(cm,head,character,inclusive);else if(selfPaired[character])tmp=findBeginningAndEnd(cm,head,character,inclusive);else if("W"===character)tmp=expandWordUnderCursor(cm,inclusive,!0,!0);else if("w"===character)tmp=expandWordUnderCursor(cm,inclusive,!0,!1);else{if("p"!==character)return null;tmp=findParagraph(cm,head,motionArgs.repeat,0,inclusive);motionArgs.linewise=!0;if(vim.visualMode)vim.visualLine||(vim.visualLine=!0);else{var operatorArgs=vim.inputState.operatorArgs;operatorArgs&&(operatorArgs.linewise=!0);tmp.end.line--}}return cm.state.vim.visualMode?expandSelection(cm,tmp.start,tmp.end):[tmp.start,tmp.end]},repeatLastCharacterSearch:function(cm,head,motionArgs){var lastSearch=vimGlobalState.lastChararacterSearch,repeat=motionArgs.repeat,forward=motionArgs.forward===lastSearch.forward,increment=(lastSearch.increment?1:0)*(forward?-1:1);cm.moveH(-increment,"char");motionArgs.inclusive=forward?!0:!1;var curEnd=moveToCharacter(cm,repeat,forward,lastSearch.selectedCharacter);if(!curEnd){cm.moveH(increment,"char");return head}curEnd.ch+=increment;return curEnd}},operators={change:function(cm,args,ranges){var finalHead,text,vim=cm.state.vim;vimGlobalState.macroModeState.lastInsertModeChanges.inVisualBlock=vim.visualBlock;if(vim.visualMode){text=cm.getSelection();var replacement=fillArray("",ranges.length);cm.replaceSelections(replacement);finalHead=cursorMin(ranges[0].head,ranges[0].anchor)}else{var anchor=ranges[0].anchor,head=ranges[0].head;text=cm.getRange(anchor,head);var lastState=vim.lastEditInputState||{};if("moveByWords"==lastState.motion&&!isWhiteSpaceString(text)){var match=/\s+$/.exec(text);if(match&&lastState.motionArgs&&lastState.motionArgs.forward){head=offsetCursor(head,0,-match[0].length);text=text.slice(0,-match[0].length)}}var wasLastLine=head.line-1==cm.lastLine();cm.replaceRange("",anchor,head);if(args.linewise&&!wasLastLine){CodeMirror.commands.newlineAndIndent(cm);anchor.ch=null}finalHead=anchor}vimGlobalState.registerController.pushText(args.registerName,"change",text,args.linewise,ranges.length>1);actions.enterInsertMode(cm,{head:finalHead},cm.state.vim)},"delete":function(cm,args,ranges){var finalHead,text,vim=cm.state.vim;if(vim.visualBlock){text=cm.getSelection();var replacement=fillArray("",ranges.length);cm.replaceSelections(replacement);finalHead=ranges[0].anchor}else{var anchor=ranges[0].anchor,head=ranges[0].head;args.linewise&&head.line!=cm.firstLine()&&anchor.line==cm.lastLine()&&anchor.line==head.line-1&&(anchor.line==cm.firstLine()?anchor.ch=0:anchor=Pos(anchor.line-1,lineLength(cm,anchor.line-1)));text=cm.getRange(anchor,head);cm.replaceRange("",anchor,head);finalHead=anchor;args.linewise&&(finalHead=motions.moveToFirstNonWhiteSpaceCharacter(cm,anchor))}vimGlobalState.registerController.pushText(args.registerName,"delete",text,args.linewise,vim.visualBlock);return clipCursorToContent(cm,finalHead)},indent:function(cm,args,ranges){var vim=cm.state.vim,startLine=ranges[0].anchor.line,endLine=vim.visualBlock?ranges[ranges.length-1].anchor.line:ranges[0].head.line,repeat=vim.visualMode?args.repeat:1;args.linewise&&endLine--;for(var i=startLine;endLine>=i;i++)for(var j=0;repeat>j;j++)cm.indentLine(i,args.indentRight);return motions.moveToFirstNonWhiteSpaceCharacter(cm,ranges[0].anchor)},changeCase:function(cm,args,ranges,oldAnchor,newHead){for(var selections=cm.getSelections(),swapped=[],toLower=args.toLower,j=0;j<selections.length;j++){var toSwap=selections[j],text="";if(toLower===!0)text=toSwap.toLowerCase();else if(toLower===!1)text=toSwap.toUpperCase();else for(var i=0;i<toSwap.length;i++){var character=toSwap.charAt(i);text+=isUpperCase(character)?character.toLowerCase():character.toUpperCase()}swapped.push(text)}cm.replaceSelections(swapped);return args.shouldMoveCursor?newHead:!cm.state.vim.visualMode&&args.linewise&&ranges[0].anchor.line+1==ranges[0].head.line?motions.moveToFirstNonWhiteSpaceCharacter(cm,oldAnchor):args.linewise?oldAnchor:cursorMin(ranges[0].anchor,ranges[0].head)},yank:function(cm,args,ranges,oldAnchor){var vim=cm.state.vim,text=cm.getSelection(),endPos=vim.visualMode?cursorMin(vim.sel.anchor,vim.sel.head,ranges[0].head,ranges[0].anchor):oldAnchor;vimGlobalState.registerController.pushText(args.registerName,"yank",text,args.linewise,vim.visualBlock);return endPos}},actions={jumpListWalk:function(cm,actionArgs,vim){if(!vim.visualMode){var repeat=actionArgs.repeat,forward=actionArgs.forward,jumpList=vimGlobalState.jumpList,mark=jumpList.move(cm,forward?repeat:-repeat),markPos=mark?mark.find():void 0;markPos=markPos?markPos:cm.getCursor();cm.setCursor(markPos)}},scroll:function(cm,actionArgs,vim){if(!vim.visualMode){var repeat=actionArgs.repeat||1,lineHeight=cm.defaultTextHeight(),top=cm.getScrollInfo().top,delta=lineHeight*repeat,newPos=actionArgs.forward?top+delta:top-delta,cursor=copyCursor(cm.getCursor()),cursorCoords=cm.charCoords(cursor,"local");if(actionArgs.forward)if(newPos>cursorCoords.top){cursor.line+=(newPos-cursorCoords.top)/lineHeight;cursor.line=Math.ceil(cursor.line);cm.setCursor(cursor);cursorCoords=cm.charCoords(cursor,"local");cm.scrollTo(null,cursorCoords.top)}else cm.scrollTo(null,newPos);else{var newBottom=newPos+cm.getScrollInfo().clientHeight;if(newBottom<cursorCoords.bottom){cursor.line-=(cursorCoords.bottom-newBottom)/lineHeight;cursor.line=Math.floor(cursor.line);cm.setCursor(cursor);cursorCoords=cm.charCoords(cursor,"local");cm.scrollTo(null,cursorCoords.bottom-cm.getScrollInfo().clientHeight)}else cm.scrollTo(null,newPos)}}},scrollToCursor:function(cm,actionArgs){var lineNum=cm.getCursor().line,charCoords=cm.charCoords(Pos(lineNum,0),"local"),height=cm.getScrollInfo().clientHeight,y=charCoords.top,lineHeight=charCoords.bottom-y;switch(actionArgs.position){case"center":y=y-height/2+lineHeight;break;case"bottom":y=y-height+1.4*lineHeight;break;case"top":y+=.4*lineHeight}cm.scrollTo(null,y)},replayMacro:function(cm,actionArgs,vim){var registerName=actionArgs.selectedCharacter,repeat=actionArgs.repeat,macroModeState=vimGlobalState.macroModeState;"@"==registerName&&(registerName=macroModeState.latestRegister);for(;repeat--;)executeMacroRegister(cm,vim,macroModeState,registerName)},enterMacroRecordMode:function(cm,actionArgs){var macroModeState=vimGlobalState.macroModeState,registerName=actionArgs.selectedCharacter;macroModeState.enterMacroRecordMode(cm,registerName)},enterInsertMode:function(cm,actionArgs,vim){if(!cm.getOption("readOnly")){vim.insertMode=!0;vim.insertModeRepeat=actionArgs&&actionArgs.repeat||1;var insertAt=actionArgs?actionArgs.insertAt:null,sel=vim.sel,head=actionArgs.head||cm.getCursor("head"),height=cm.listSelections().length;if("eol"==insertAt)head=Pos(head.line,lineLength(cm,head.line));else if("charAfter"==insertAt)head=offsetCursor(head,0,1);else if("firstNonBlank"==insertAt)head=motions.moveToFirstNonWhiteSpaceCharacter(cm,head);else if("startOfSelectedArea"==insertAt)if(vim.visualBlock){head=Pos(Math.min(sel.head.line,sel.anchor.line),Math.min(sel.head.ch,sel.anchor.ch));height=Math.abs(sel.head.line-sel.anchor.line)+1}else head=sel.head.line<sel.anchor.line?sel.head:Pos(sel.anchor.line,0);else if("endOfSelectedArea"==insertAt)if(vim.visualBlock){head=Pos(Math.min(sel.head.line,sel.anchor.line),Math.max(sel.head.ch+1,sel.anchor.ch));height=Math.abs(sel.head.line-sel.anchor.line)+1}else head=sel.head.line>=sel.anchor.line?offsetCursor(sel.head,0,1):Pos(sel.anchor.line,0);else if("inplace"==insertAt&&vim.visualMode)return;cm.setOption("keyMap","vim-insert");cm.setOption("disableInput",!1);if(actionArgs&&actionArgs.replace){cm.toggleOverwrite(!0);cm.setOption("keyMap","vim-replace");CodeMirror.signal(cm,"vim-mode-change",{mode:"replace"})}else{cm.setOption("keyMap","vim-insert");CodeMirror.signal(cm,"vim-mode-change",{mode:"insert"})}if(!vimGlobalState.macroModeState.isPlaying){cm.on("change",onChange);CodeMirror.on(cm.getInputField(),"keydown",onKeyEventTargetKeyDown)}vim.visualMode&&exitVisualMode(cm);selectForInsert(cm,head,height)}},toggleVisualMode:function(cm,actionArgs,vim){var head,repeat=actionArgs.repeat,anchor=cm.getCursor();if(vim.visualMode)if(vim.visualLine^actionArgs.linewise||vim.visualBlock^actionArgs.blockwise){vim.visualLine=!!actionArgs.linewise;vim.visualBlock=!!actionArgs.blockwise;CodeMirror.signal(cm,"vim-mode-change",{mode:"visual",subMode:vim.visualLine?"linewise":vim.visualBlock?"blockwise":""});updateCmSelection(cm)}else exitVisualMode(cm);else{vim.visualMode=!0;vim.visualLine=!!actionArgs.linewise;vim.visualBlock=!!actionArgs.blockwise;head=clipCursorToContent(cm,Pos(anchor.line,anchor.ch+repeat-1),!0);vim.sel={anchor:anchor,head:head};CodeMirror.signal(cm,"vim-mode-change",{mode:"visual",subMode:vim.visualLine?"linewise":vim.visualBlock?"blockwise":""});updateCmSelection(cm);updateMark(cm,vim,"<",cursorMin(anchor,head));updateMark(cm,vim,">",cursorMax(anchor,head))}},reselectLastSelection:function(cm,_actionArgs,vim){var lastSelection=vim.lastSelection;vim.visualMode&&updateLastSelection(cm,vim);if(lastSelection){var anchor=lastSelection.anchorMark.find(),head=lastSelection.headMark.find();if(!anchor||!head)return;vim.sel={anchor:anchor,head:head};vim.visualMode=!0;vim.visualLine=lastSelection.visualLine;vim.visualBlock=lastSelection.visualBlock;updateCmSelection(cm);updateMark(cm,vim,"<",cursorMin(anchor,head));updateMark(cm,vim,">",cursorMax(anchor,head));CodeMirror.signal(cm,"vim-mode-change",{mode:"visual",subMode:vim.visualLine?"linewise":vim.visualBlock?"blockwise":""})}},joinLines:function(cm,actionArgs,vim){var curStart,curEnd;if(vim.visualMode){curStart=cm.getCursor("anchor");curEnd=cm.getCursor("head");if(cursorIsBefore(curEnd,curStart)){var tmp=curEnd;curEnd=curStart;curStart=tmp}curEnd.ch=lineLength(cm,curEnd.line)-1}else{var repeat=Math.max(actionArgs.repeat,2);curStart=cm.getCursor();curEnd=clipCursorToContent(cm,Pos(curStart.line+repeat-1,1/0))}for(var finalCh=0,i=curStart.line;i<curEnd.line;i++){finalCh=lineLength(cm,curStart.line);var tmp=Pos(curStart.line+1,lineLength(cm,curStart.line+1)),text=cm.getRange(curStart,tmp);text=text.replace(/\n\s*/g," ");cm.replaceRange(text,curStart,tmp)}var curFinalPos=Pos(curStart.line,finalCh);vim.visualMode&&exitVisualMode(cm,!1);cm.setCursor(curFinalPos)},newLineAndEnterInsertMode:function(cm,actionArgs,vim){vim.insertMode=!0;var insertAt=copyCursor(cm.getCursor());if(insertAt.line!==cm.firstLine()||actionArgs.after){insertAt.line=actionArgs.after?insertAt.line:insertAt.line-1;insertAt.ch=lineLength(cm,insertAt.line);cm.setCursor(insertAt);var newlineFn=CodeMirror.commands.newlineAndIndentContinueComment||CodeMirror.commands.newlineAndIndent;newlineFn(cm)}else{cm.replaceRange("\n",Pos(cm.firstLine(),0));cm.setCursor(cm.firstLine(),0)}this.enterInsertMode(cm,{repeat:actionArgs.repeat},vim)},paste:function(cm,actionArgs,vim){var cur=copyCursor(cm.getCursor()),register=vimGlobalState.registerController.getRegister(actionArgs.registerName),text=register.toString();if(text){if(actionArgs.matchIndent){var tabSize=cm.getOption("tabSize"),whitespaceLength=function(str){var tabs=str.split(" ").length-1,spaces=str.split(" ").length-1;return tabs*tabSize+1*spaces},currentLine=cm.getLine(cm.getCursor().line),indent=whitespaceLength(currentLine.match(/^\s*/)[0]),chompedText=text.replace(/\n$/,""),wasChomped=text!==chompedText,firstIndent=whitespaceLength(text.match(/^\s*/)[0]),text=chompedText.replace(/^\s*/gm,function(wspace){var newIndent=indent+(whitespaceLength(wspace)-firstIndent);if(0>newIndent)return"";if(cm.getOption("indentWithTabs")){var quotient=Math.floor(newIndent/tabSize);return Array(quotient+1).join(" ")}return Array(newIndent+1).join(" ")});text+=wasChomped?"\n":""}if(actionArgs.repeat>1)var text=Array(actionArgs.repeat+1).join(text);var linewise=register.linewise,blockwise=register.blockwise;if(linewise)if(vim.visualMode)text=vim.visualLine?text.slice(0,-1):"\n"+text.slice(0,text.length-1)+"\n";else if(actionArgs.after){text="\n"+text.slice(0,text.length-1);cur.ch=lineLength(cm,cur.line)}else cur.ch=0;else{if(blockwise){text=text.split("\n");for(var i=0;i<text.length;i++)text[i]=""==text[i]?" ":text[i]}cur.ch+=actionArgs.after?1:0}var curPosFinal,idx;if(vim.visualMode){vim.lastPastedText=text;var lastSelectionCurEnd,selectedArea=getSelectedAreaRange(cm,vim),selectionStart=selectedArea[0],selectionEnd=selectedArea[1],selectedText=cm.getSelection(),selections=cm.listSelections(),emptyStrings=new Array(selections.length).join("1").split("1");vim.lastSelection&&(lastSelectionCurEnd=vim.lastSelection.headMark.find());vimGlobalState.registerController.unnamedRegister.setText(selectedText);if(blockwise){cm.replaceSelections(emptyStrings);selectionEnd=Pos(selectionStart.line+text.length-1,selectionStart.ch);cm.setCursor(selectionStart);selectBlock(cm,selectionEnd);cm.replaceSelections(text);curPosFinal=selectionStart}else if(vim.visualBlock){cm.replaceSelections(emptyStrings);cm.setCursor(selectionStart);cm.replaceRange(text,selectionStart,selectionStart);curPosFinal=selectionStart}else{cm.replaceRange(text,selectionStart,selectionEnd);curPosFinal=cm.posFromIndex(cm.indexFromPos(selectionStart)+text.length-1)}lastSelectionCurEnd&&(vim.lastSelection.headMark=cm.setBookmark(lastSelectionCurEnd));linewise&&(curPosFinal.ch=0)}else if(blockwise){cm.setCursor(cur);for(var i=0;i<text.length;i++){var line=cur.line+i;line>cm.lastLine()&&cm.replaceRange("\n",Pos(line,0));var lastCh=lineLength(cm,line);lastCh<cur.ch&&extendLineToColumn(cm,line,cur.ch)}cm.setCursor(cur);selectBlock(cm,Pos(cur.line+text.length-1,cur.ch));cm.replaceSelections(text);curPosFinal=cur}else{cm.replaceRange(text,cur);if(linewise&&actionArgs.after)curPosFinal=Pos(cur.line+1,findFirstNonWhiteSpaceCharacter(cm.getLine(cur.line+1)));else if(linewise&&!actionArgs.after)curPosFinal=Pos(cur.line,findFirstNonWhiteSpaceCharacter(cm.getLine(cur.line)));else if(!linewise&&actionArgs.after){idx=cm.indexFromPos(cur);curPosFinal=cm.posFromIndex(idx+text.length-1)}else{idx=cm.indexFromPos(cur);curPosFinal=cm.posFromIndex(idx+text.length)}}vim.visualMode&&exitVisualMode(cm,!1);cm.setCursor(curPosFinal)}},undo:function(cm,actionArgs){cm.operation(function(){repeatFn(cm,CodeMirror.commands.undo,actionArgs.repeat)();cm.setCursor(cm.getCursor("anchor"))})},redo:function(cm,actionArgs){repeatFn(cm,CodeMirror.commands.redo,actionArgs.repeat)()},setRegister:function(_cm,actionArgs,vim){vim.inputState.registerName=actionArgs.selectedCharacter},setMark:function(cm,actionArgs,vim){var markName=actionArgs.selectedCharacter;updateMark(cm,vim,markName,cm.getCursor())},replace:function(cm,actionArgs,vim){var replaceTo,curEnd,replaceWith=actionArgs.selectedCharacter,curStart=cm.getCursor(),selections=cm.listSelections();if(vim.visualMode){curStart=cm.getCursor("start");curEnd=cm.getCursor("end")}else{var line=cm.getLine(curStart.line);replaceTo=curStart.ch+actionArgs.repeat;replaceTo>line.length&&(replaceTo=line.length);curEnd=Pos(curStart.line,replaceTo)}if("\n"==replaceWith){vim.visualMode||cm.replaceRange("",curStart,curEnd);(CodeMirror.commands.newlineAndIndentContinueComment||CodeMirror.commands.newlineAndIndent)(cm)}else{var replaceWithStr=cm.getRange(curStart,curEnd);replaceWithStr=replaceWithStr.replace(/[^\n]/g,replaceWith);if(vim.visualBlock){var spaces=new Array(cm.getOption("tabSize")+1).join(" ");replaceWithStr=cm.getSelection();replaceWithStr=replaceWithStr.replace(/\t/g,spaces).replace(/[^\n]/g,replaceWith).split("\n");cm.replaceSelections(replaceWithStr)}else cm.replaceRange(replaceWithStr,curStart,curEnd);if(vim.visualMode){curStart=cursorIsBefore(selections[0].anchor,selections[0].head)?selections[0].anchor:selections[0].head;cm.setCursor(curStart);exitVisualMode(cm,!1)}else cm.setCursor(offsetCursor(curEnd,0,-1))}},incrementNumberToken:function(cm,actionArgs){for(var match,start,end,numberStr,token,cur=cm.getCursor(),lineStr=cm.getLine(cur.line),re=/-?\d+/g;null!==(match=re.exec(lineStr));){token=match[0];start=match.index;end=start+token.length;if(cur.ch<end)break}if((actionArgs.backtrack||!(end<=cur.ch))&&token){var increment=actionArgs.increase?1:-1,number=parseInt(token)+increment*actionArgs.repeat,from=Pos(cur.line,start),to=Pos(cur.line,end);numberStr=number.toString();cm.replaceRange(numberStr,from,to);cm.setCursor(Pos(cur.line,start+numberStr.length-1))}},repeatLastEdit:function(cm,actionArgs,vim){var lastEditInputState=vim.lastEditInputState;if(lastEditInputState){var repeat=actionArgs.repeat;repeat&&actionArgs.repeatIsExplicit?vim.lastEditInputState.repeatOverride=repeat:repeat=vim.lastEditInputState.repeatOverride||repeat;repeatLastEdit(cm,vim,repeat,!1)}},exitInsertMode:exitInsertMode},symbolToMode={"(":"bracket",")":"bracket","{":"bracket","}":"bracket","[":"section","]":"section","*":"comment","/":"comment",m:"method",M:"method","#":"preprocess"},findSymbolModes={bracket:{isComplete:function(state){if(state.nextCh===state.symb){state.depth++;if(state.depth>=1)return!0}else state.nextCh===state.reverseSymb&&state.depth--;return!1}},section:{init:function(state){state.curMoveThrough=!0;state.symb=(state.forward?"]":"[")===state.symb?"{":"}"},isComplete:function(state){return 0===state.index&&state.nextCh===state.symb}},comment:{isComplete:function(state){var found="*"===state.lastCh&&"/"===state.nextCh;state.lastCh=state.nextCh;return found}},method:{init:function(state){state.symb="m"===state.symb?"{":"}";state.reverseSymb="{"===state.symb?"}":"{"},isComplete:function(state){return state.nextCh===state.symb?!0:!1}},preprocess:{init:function(state){state.index=0},isComplete:function(state){if("#"===state.nextCh){var token=state.lineText.match(/#(\w+)/)[1];if("endif"===token){if(state.forward&&0===state.depth)return!0;state.depth++}else if("if"===token){if(!state.forward&&0===state.depth)return!0;state.depth--}if("else"===token&&0===state.depth)return!0}return!1}}};defineOption("pcre",!0,"boolean");SearchState.prototype={getQuery:function(){return vimGlobalState.query},setQuery:function(query){vimGlobalState.query=query},getOverlay:function(){return this.searchOverlay},setOverlay:function(overlay){this.searchOverlay=overlay},isReversed:function(){return vimGlobalState.isReversed},setReversed:function(reversed){vimGlobalState.isReversed=reversed},getScrollbarAnnotate:function(){return this.annotate},setScrollbarAnnotate:function(annotate){this.annotate=annotate}};var charUnescapes={"\\n":"\n","\\r":"\r","\\t":" "},unescapes={"\\/":"/","\\\\":"\\","\\n":"\n","\\r":"\r","\\t":" "},searchPromptDesc="(Javascript regexp)",ExCommandDispatcher=function(){this.buildCommandMap_()};ExCommandDispatcher.prototype={processCommand:function(cm,input,opt_params){var that=this;cm.operation(function(){cm.curOp.isVimOp=!0;that._processCommand(cm,input,opt_params)})},_processCommand:function(cm,input,opt_params){var vim=cm.state.vim,commandHistoryRegister=vimGlobalState.registerController.getRegister(":"),previousCommand=commandHistoryRegister.toString();vim.visualMode&&exitVisualMode(cm);var inputStream=new CodeMirror.StringStream(input);commandHistoryRegister.setText(input);var params=opt_params||{};params.input=input;try{this.parseInput_(cm,inputStream,params)}catch(e){showConfirm(cm,e);throw e}var command,commandName;if(params.commandName){command=this.matchCommand_(params.commandName);if(command){commandName=command.name;command.excludeFromCommandHistory&&commandHistoryRegister.setText(previousCommand);this.parseCommandArgs_(inputStream,params,command);if("exToKey"==command.type){for(var i=0;i<command.toKeys.length;i++)CodeMirror.Vim.handleKey(cm,command.toKeys[i],"mapping");return}if("exToEx"==command.type){this.processCommand(cm,command.toInput);return}}}else void 0!==params.line&&(commandName="move");if(commandName)try{exCommands[commandName](cm,params);command&&command.possiblyAsync||!params.callback||params.callback()}catch(e){showConfirm(cm,e);throw e}else showConfirm(cm,'Not an editor command ":'+input+'"')},parseInput_:function(cm,inputStream,result){inputStream.eatWhile(":");if(inputStream.eat("%")){result.line=cm.firstLine();result.lineEnd=cm.lastLine()}else{result.line=this.parseLineSpec_(cm,inputStream);
4
- void 0!==result.line&&inputStream.eat(",")&&(result.lineEnd=this.parseLineSpec_(cm,inputStream))}var commandMatch=inputStream.match(/^(\w+)/);commandMatch?result.commandName=commandMatch[1]:result.commandName=inputStream.match(/.*/)[0];return result},parseLineSpec_:function(cm,inputStream){var numberMatch=inputStream.match(/^(\d+)/);if(numberMatch)return parseInt(numberMatch[1],10)-1;switch(inputStream.next()){case".":return cm.getCursor().line;case"$":return cm.lastLine();case"'":var mark=cm.state.vim.marks[inputStream.next()];if(mark&&mark.find())return mark.find().line;throw new Error("Mark not set");default:inputStream.backUp(1);return void 0}},parseCommandArgs_:function(inputStream,params,command){if(!inputStream.eol()){params.argString=inputStream.match(/.*/)[0];var delim=command.argDelimiter||/\s+/,args=trim(params.argString).split(delim);args.length&&args[0]&&(params.args=args)}},matchCommand_:function(commandName){for(var i=commandName.length;i>0;i--){var prefix=commandName.substring(0,i);if(this.commandMap_[prefix]){var command=this.commandMap_[prefix];if(0===command.name.indexOf(commandName))return command}}return null},buildCommandMap_:function(){this.commandMap_={};for(var i=0;i<defaultExCommandMap.length;i++){var command=defaultExCommandMap[i],key=command.shortName||command.name;this.commandMap_[key]=command}},map:function(lhs,rhs,ctx){if(":"!=lhs&&":"==lhs.charAt(0)){if(ctx)throw Error("Mode not supported for ex mappings");var commandName=lhs.substring(1);":"!=rhs&&":"==rhs.charAt(0)?this.commandMap_[commandName]={name:commandName,type:"exToEx",toInput:rhs.substring(1),user:!0}:this.commandMap_[commandName]={name:commandName,type:"exToKey",toKeys:rhs,user:!0}}else if(":"!=rhs&&":"==rhs.charAt(0)){var mapping={keys:lhs,type:"keyToEx",exArgs:{input:rhs.substring(1)},user:!0};ctx&&(mapping.context=ctx);defaultKeymap.unshift(mapping)}else{var mapping={keys:lhs,type:"keyToKey",toKeys:rhs,user:!0};ctx&&(mapping.context=ctx);defaultKeymap.unshift(mapping)}},unmap:function(lhs,ctx){if(":"!=lhs&&":"==lhs.charAt(0)){if(ctx)throw Error("Mode not supported for ex mappings");var commandName=lhs.substring(1);if(this.commandMap_[commandName]&&this.commandMap_[commandName].user){delete this.commandMap_[commandName];return}}else for(var keys=lhs,i=0;i<defaultKeymap.length;i++)if(keys==defaultKeymap[i].keys&&defaultKeymap[i].context===ctx&&defaultKeymap[i].user){defaultKeymap.splice(i,1);return}throw Error("No such mapping.")}};var exCommands={colorscheme:function(cm,params){!params.args||params.args.length<1?showConfirm(cm,cm.getOption("theme")):cm.setOption("theme",params.args[0])},map:function(cm,params,ctx){var mapArgs=params.args;!mapArgs||mapArgs.length<2?cm&&showConfirm(cm,"Invalid mapping: "+params.input):exCommandDispatcher.map(mapArgs[0],mapArgs[1],ctx)},imap:function(cm,params){this.map(cm,params,"insert")},nmap:function(cm,params){this.map(cm,params,"normal")},vmap:function(cm,params){this.map(cm,params,"visual")},unmap:function(cm,params,ctx){var mapArgs=params.args;!mapArgs||mapArgs.length<1?cm&&showConfirm(cm,"No such mapping: "+params.input):exCommandDispatcher.unmap(mapArgs[0],ctx)},move:function(cm,params){commandDispatcher.processCommand(cm,cm.state.vim,{type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0},repeatOverride:params.line+1})},set:function(cm,params){var setArgs=params.args,setCfg=params.setCfg||{};if(!setArgs||setArgs.length<1)cm&&showConfirm(cm,"Invalid mapping: "+params.input);else{var expr=setArgs[0].split("="),optionName=expr[0],value=expr[1],forceGet=!1;if("?"==optionName.charAt(optionName.length-1)){if(value)throw Error("Trailing characters: "+params.argString);optionName=optionName.substring(0,optionName.length-1);forceGet=!0}if(void 0===value&&"no"==optionName.substring(0,2)){optionName=optionName.substring(2);value=!1}var optionIsBoolean=options[optionName]&&"boolean"==options[optionName].type;optionIsBoolean&&void 0==value&&(value=!0);if(!optionIsBoolean&&void 0===value||forceGet){var oldValue=getOption(optionName,cm,setCfg);oldValue===!0||oldValue===!1?showConfirm(cm," "+(oldValue?"":"no")+optionName):showConfirm(cm," "+optionName+"="+oldValue)}else setOption(optionName,value,cm,setCfg)}},setlocal:function(cm,params){params.setCfg={scope:"local"};this.set(cm,params)},setglobal:function(cm,params){params.setCfg={scope:"global"};this.set(cm,params)},registers:function(cm,params){var regArgs=params.args,registers=vimGlobalState.registerController.registers,regInfo="----------Registers----------<br><br>";if(regArgs){var registerName;regArgs=regArgs.join("");for(var i=0;i<regArgs.length;i++){registerName=regArgs.charAt(i);if(vimGlobalState.registerController.isValidRegister(registerName)){var register=registers[registerName]||new Register;regInfo+='"'+registerName+" "+register.toString()+"<br>"}}}else for(var registerName in registers){var text=registers[registerName].toString();text.length&&(regInfo+='"'+registerName+" "+text+"<br>")}showConfirm(cm,regInfo)},sort:function(cm,params){function parseArgs(){if(params.argString){var args=new CodeMirror.StringStream(params.argString);args.eat("!")&&(reverse=!0);if(args.eol())return;if(!args.eatSpace())return"Invalid arguments";var opts=args.match(/[a-z]+/);if(opts){opts=opts[0];ignoreCase=-1!=opts.indexOf("i");unique=-1!=opts.indexOf("u");var decimal=-1!=opts.indexOf("d")&&1,hex=-1!=opts.indexOf("x")&&1,octal=-1!=opts.indexOf("o")&&1;if(decimal+hex+octal>1)return"Invalid arguments";number=decimal&&"decimal"||hex&&"hex"||octal&&"octal"}if(args.match(/\/.*\//))return"patterns not supported"}}function compareFn(a,b){if(reverse){var tmp;tmp=a;a=b;b=tmp}if(ignoreCase){a=a.toLowerCase();b=b.toLowerCase()}var anum=number&&numberRegex.exec(a),bnum=number&&numberRegex.exec(b);if(!anum)return b>a?-1:1;anum=parseInt((anum[1]+anum[2]).toLowerCase(),radix);bnum=parseInt((bnum[1]+bnum[2]).toLowerCase(),radix);return anum-bnum}var reverse,ignoreCase,unique,number,err=parseArgs();if(err)showConfirm(cm,err+": "+params.argString);else{var lineStart=params.line||cm.firstLine(),lineEnd=params.lineEnd||params.line||cm.lastLine();if(lineStart!=lineEnd){var curStart=Pos(lineStart,0),curEnd=Pos(lineEnd,lineLength(cm,lineEnd)),text=cm.getRange(curStart,curEnd).split("\n"),numberRegex="decimal"==number?/(-?)([\d]+)/:"hex"==number?/(-?)(?:0x)?([0-9a-f]+)/i:"octal"==number?/([0-7]+)/:null,radix="decimal"==number?10:"hex"==number?16:"octal"==number?8:null,numPart=[],textPart=[];if(number)for(var i=0;i<text.length;i++)numberRegex.exec(text[i])?numPart.push(text[i]):textPart.push(text[i]);else textPart=text;numPart.sort(compareFn);textPart.sort(compareFn);text=reverse?numPart.concat(textPart):textPart.concat(numPart);if(unique){var lastLine,textOld=text;text=[];for(var i=0;i<textOld.length;i++){textOld[i]!=lastLine&&text.push(textOld[i]);lastLine=textOld[i]}}cm.replaceRange(text.join("\n"),curStart,curEnd)}}},global:function(cm,params){var argString=params.argString;if(argString){var cmd,lineStart=void 0!==params.line?params.line:cm.firstLine(),lineEnd=params.lineEnd||params.line||cm.lastLine(),tokens=splitBySlash(argString),regexPart=argString;if(tokens.length){regexPart=tokens[0];cmd=tokens.slice(1,tokens.length).join("/")}if(regexPart)try{updateSearchQuery(cm,regexPart,!0,!0)}catch(e){showConfirm(cm,"Invalid regex: "+regexPart);return}for(var query=getSearchState(cm).getQuery(),matchedLines=[],content="",i=lineStart;lineEnd>=i;i++){var matched=query.test(cm.getLine(i));if(matched){matchedLines.push(i+1);content+=cm.getLine(i)+"<br>"}}if(cmd){var index=0,nextCommand=function(){if(index<matchedLines.length){var command=matchedLines[index]+cmd;exCommandDispatcher.processCommand(cm,command,{callback:nextCommand})}index++};nextCommand()}else showConfirm(cm,content)}else showConfirm(cm,"Regular Expression missing from global")},substitute:function(cm,params){if(!cm.getSearchCursor)throw new Error("Search feature not available. Requires searchcursor.js or any other getSearchCursor implementation.");var regexPart,trailing,flagsPart,count,argString=params.argString,tokens=argString?splitBySlash(argString):[],replacePart="",confirm=!1,global=!1;if(tokens.length){regexPart=tokens[0];replacePart=tokens[1];if(void 0!==replacePart){replacePart=getOption("pcre")?unescapeRegexReplace(replacePart):translateRegexReplace(replacePart);vimGlobalState.lastSubstituteReplacePart=replacePart}trailing=tokens[2]?tokens[2].split(" "):[]}else if(argString&&argString.length){showConfirm(cm,"Substitutions should be of the form :s/pattern/replace/");return}if(trailing){flagsPart=trailing[0];count=parseInt(trailing[1]);if(flagsPart){if(-1!=flagsPart.indexOf("c")){confirm=!0;flagsPart.replace("c","")}if(-1!=flagsPart.indexOf("g")){global=!0;flagsPart.replace("g","")}regexPart=regexPart+"/"+flagsPart}}if(regexPart)try{updateSearchQuery(cm,regexPart,!0,!0)}catch(e){showConfirm(cm,"Invalid regex: "+regexPart);return}replacePart=replacePart||vimGlobalState.lastSubstituteReplacePart;if(void 0!==replacePart){var state=getSearchState(cm),query=state.getQuery(),lineStart=void 0!==params.line?params.line:cm.getCursor().line,lineEnd=params.lineEnd||lineStart;lineStart==cm.firstLine()&&lineEnd==cm.lastLine()&&(lineEnd=1/0);if(count){lineStart=lineEnd;lineEnd=lineStart+count-1}var startPos=clipCursorToContent(cm,Pos(lineStart,0)),cursor=cm.getSearchCursor(query,startPos);doReplace(cm,confirm,global,lineStart,lineEnd,cursor,query,replacePart,params.callback)}else showConfirm(cm,"No previous substitute regular expression")},redo:CodeMirror.commands.redo,undo:CodeMirror.commands.undo,write:function(cm){CodeMirror.commands.save?CodeMirror.commands.save(cm):cm.save()},nohlsearch:function(cm){clearSearchHighlight(cm)},delmarks:function(cm,params){if(params.argString&&trim(params.argString))for(var state=cm.state.vim,stream=new CodeMirror.StringStream(trim(params.argString));!stream.eol();){stream.eatSpace();var count=stream.pos;if(!stream.match(/[a-zA-Z]/,!1)){showConfirm(cm,"Invalid argument: "+params.argString.substring(count));return}var sym=stream.next();if(stream.match("-",!0)){if(!stream.match(/[a-zA-Z]/,!1)){showConfirm(cm,"Invalid argument: "+params.argString.substring(count));return}var startMark=sym,finishMark=stream.next();if(!(isLowerCase(startMark)&&isLowerCase(finishMark)||isUpperCase(startMark)&&isUpperCase(finishMark))){showConfirm(cm,"Invalid argument: "+startMark+"-");return}var start=startMark.charCodeAt(0),finish=finishMark.charCodeAt(0);if(start>=finish){showConfirm(cm,"Invalid argument: "+params.argString.substring(count));return}for(var j=0;finish-start>=j;j++){var mark=String.fromCharCode(start+j);delete state.marks[mark]}}else delete state.marks[sym]}else showConfirm(cm,"Argument required")}},exCommandDispatcher=new ExCommandDispatcher;CodeMirror.keyMap.vim={attach:attachVimMap,detach:detachVimMap,call:cmKey};defineOption("insertModeEscKeysTimeout",200,"number");CodeMirror.keyMap["vim-insert"]={"Ctrl-N":"autocomplete","Ctrl-P":"autocomplete",Enter:function(cm){var fn=CodeMirror.commands.newlineAndIndentContinueComment||CodeMirror.commands.newlineAndIndent;fn(cm)},fallthrough:["default"],attach:attachVimMap,detach:detachVimMap,call:cmKey};CodeMirror.keyMap["vim-replace"]={Backspace:"goCharLeft",fallthrough:["vim-insert"],attach:attachVimMap,detach:detachVimMap,call:cmKey};resetVimGlobalState();return vimApi};CodeMirror.Vim=Vim()});
1
+ !function(mod){"object"==typeof exports&&"object"==typeof module?mod(require("../lib/codemirror"),require("../addon/search/searchcursor"),require("../addon/dialog/dialog"),require("../addon/edit/matchbrackets.js")):"function"==typeof define&&define.amd?define(["../lib/codemirror","../addon/search/searchcursor","../addon/dialog/dialog","../addon/edit/matchbrackets"],mod):mod(CodeMirror)}(function(CodeMirror){"use strict";var defaultKeymap=[{keys:"<Left>",type:"keyToKey",toKeys:"h"},{keys:"<Right>",type:"keyToKey",toKeys:"l"},{keys:"<Up>",type:"keyToKey",toKeys:"k"},{keys:"<Down>",type:"keyToKey",toKeys:"j"},{keys:"<Space>",type:"keyToKey",toKeys:"l"},{keys:"<BS>",type:"keyToKey",toKeys:"h",context:"normal"},{keys:"<C-Space>",type:"keyToKey",toKeys:"W"},{keys:"<C-BS>",type:"keyToKey",toKeys:"B",context:"normal"},{keys:"<S-Space>",type:"keyToKey",toKeys:"w"},{keys:"<S-BS>",type:"keyToKey",toKeys:"b",context:"normal"},{keys:"<C-n>",type:"keyToKey",toKeys:"j"},{keys:"<C-p>",type:"keyToKey",toKeys:"k"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"c",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"VdO",context:"visual"},{keys:"<Home>",type:"keyToKey",toKeys:"0"},{keys:"<End>",type:"keyToKey",toKeys:"$"},{keys:"<PageUp>",type:"keyToKey",toKeys:"<C-b>"},{keys:"<PageDown>",type:"keyToKey",toKeys:"<C-f>"},{keys:"<CR>",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"h",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!1}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!0}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!1}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:"ge",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!1,toJumplist:!0}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!0,toJumplist:!0}},{keys:"<C-f>",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"<C-b>",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"<C-d>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"<C-u>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!1,explicitRepeat:!0}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,toFirstChar:!0}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0,toJumplist:!0}},{keys:"f<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'<character>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`<character>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0,linewise:!0}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1,linewise:!0}},{keys:"]p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0,matchIndent:!0}},{keys:"[p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:"]<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!1,toJumplist:!0}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:!0},context:"visual"},{keys:"d",type:"operator",operator:"delete"},{keys:"y",type:"operator",operator:"yank"},{keys:"c",type:"operator",operator:"change"},{keys:">",type:"operator",operator:"indent",operatorArgs:{indentRight:!0}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:"g~",type:"operator",operator:"changeCase"},{keys:"gu",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},isEdit:!0},{keys:"gU",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},isEdit:!0},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:!0}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:!1,toJumplist:!0}},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"D",type:"operator",operator:"delete",operatorArgs:{linewise:!0},context:"visual"},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"Y",type:"operator",operator:"yank",operatorArgs:{linewise:!0},context:"visual"},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"C",type:"operator",operator:"change",operatorArgs:{linewise:!0},context:"visual"},{keys:"~",type:"operatorMotion",operator:"changeCase",motion:"moveByCharacters",motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:"normal"},{keys:"~",type:"operator",operator:"changeCase",context:"visual"},{keys:"<C-w>",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"<C-i>",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"<C-o>",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"<C-e>",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"<C-y>",type:"action",action:"scroll",actionArgs:{forward:!1,linewise:!0}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"endOfSelectedArea"},context:"visual"},{keys:"i",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"firstNonBlank"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"startOfSelectedArea"},context:"visual"},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:"<C-v>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"<C-q>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:!0},{keys:"p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:"P",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:"r<character>",type:"action",action:"replace",isEdit:!0},{keys:"@<character>",type:"action",action:"replayMacro"},{keys:"q<character>",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{replace:!0}},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},context:"visual",isEdit:!0},{keys:"U",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},context:"visual",isEdit:!0},{keys:"<C-r>",type:"action",action:"redo"},{keys:"m<character>",type:"action",action:"setMark"},{keys:'"<character>',type:"action",action:"setRegister"},{keys:"zz",type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:"z.",type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zt",type:"action",action:"scrollToCursor",actionArgs:{position:"top"}},{keys:"z<CR>",type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"z-",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:"zb",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:".",type:"action",action:"repeatLastEdit"},{keys:"<C-a>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"<C-x>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"a<character>",type:"motion",motion:"textObjectManipulation"},{keys:"i<character>",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:"/",type:"search",searchArgs:{forward:!0,querySrc:"prompt",toJumplist:!0}},{keys:"?",type:"search",searchArgs:{forward:!1,querySrc:"prompt",toJumplist:!0}},{keys:"*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"g*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:"g#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:":",type:"ex"}],defaultExCommandMap=[{name:"colorscheme",shortName:"colo"},{name:"map"},{name:"imap",shortName:"im"},{name:"nmap",shortName:"nm"},{name:"vmap",shortName:"vm"},{name:"unmap"},{name:"write",shortName:"w"},{name:"undo",shortName:"u"},{name:"redo",shortName:"red"},{name:"set",shortName:"se"},{name:"set",shortName:"se"},{name:"setlocal",shortName:"setl"},{name:"setglobal",shortName:"setg"},{name:"sort",shortName:"sor"},{name:"substitute",shortName:"s",possiblyAsync:!0},{name:"nohlsearch",shortName:"noh"},{name:"yank",shortName:"y"},{name:"delmarks",shortName:"delm"},{name:"registers",shortName:"reg",excludeFromCommandHistory:!0},{name:"global",shortName:"g"}],Pos=CodeMirror.Pos,Vim=function(){function enterVimMode(cm){cm.setOption("disableInput",!0);cm.setOption("showCursorWhenSelecting",!1);CodeMirror.signal(cm,"vim-mode-change",{mode:"normal"});cm.on("cursorActivity",onCursorActivity);maybeInitVimState(cm);CodeMirror.on(cm.getInputField(),"paste",getOnPasteFn(cm))}function leaveVimMode(cm){cm.setOption("disableInput",!1);cm.off("cursorActivity",onCursorActivity);CodeMirror.off(cm.getInputField(),"paste",getOnPasteFn(cm));cm.state.vim=null}function detachVimMap(cm,next){this==CodeMirror.keyMap.vim&&CodeMirror.rmClass(cm.getWrapperElement(),"cm-fat-cursor");next&&next.attach==attachVimMap||leaveVimMode(cm,!1)}function attachVimMap(cm,prev){this==CodeMirror.keyMap.vim&&CodeMirror.addClass(cm.getWrapperElement(),"cm-fat-cursor");prev&&prev.attach==attachVimMap||enterVimMode(cm)}function cmKey(key,cm){if(!cm)return void 0;var vimKey=cmKeyToVimKey(key);if(!vimKey)return!1;var cmd=CodeMirror.Vim.findKey(cm,vimKey);"function"==typeof cmd&&CodeMirror.signal(cm,"vim-keypress",vimKey);return cmd}function cmKeyToVimKey(key){if("'"==key.charAt(0))return key.charAt(1);var pieces=key.split(/-(?!$)/),lastPiece=pieces[pieces.length-1];if(1==pieces.length&&1==pieces[0].length)return!1;if(2==pieces.length&&"Shift"==pieces[0]&&1==lastPiece.length)return!1;for(var hasCharacter=!1,i=0;i<pieces.length;i++){var piece=pieces[i];piece in modifiers?pieces[i]=modifiers[piece]:hasCharacter=!0;piece in specialKeys&&(pieces[i]=specialKeys[piece])}if(!hasCharacter)return!1;isUpperCase(lastPiece)&&(pieces[pieces.length-1]=lastPiece.toLowerCase());return"<"+pieces.join("-")+">"}function getOnPasteFn(cm){var vim=cm.state.vim;vim.onPasteFn||(vim.onPasteFn=function(){if(!vim.insertMode){cm.setCursor(offsetCursor(cm.getCursor(),0,1));actions.enterInsertMode(cm,{},vim)}});return vim.onPasteFn}function makeKeyRange(start,size){for(var keys=[],i=start;start+size>i;i++)keys.push(String.fromCharCode(i));return keys}function isLine(cm,line){return line>=cm.firstLine()&&line<=cm.lastLine()}function isLowerCase(k){return/^[a-z]$/.test(k)}function isMatchableSymbol(k){return-1!="()[]{}".indexOf(k)}function isNumber(k){return numberRegex.test(k)}function isUpperCase(k){return/^[A-Z]$/.test(k)}function isWhiteSpaceString(k){return/^\s*$/.test(k)}function inArray(val,arr){for(var i=0;i<arr.length;i++)if(arr[i]==val)return!0;return!1}function defineOption(name,defaultValue,type,aliases,callback){if(void 0===defaultValue&&!callback)throw Error("defaultValue is required unless callback is provided");type||(type="string");options[name]={type:type,defaultValue:defaultValue,callback:callback};if(aliases)for(var i=0;i<aliases.length;i++)options[aliases[i]]=options[name];defaultValue&&setOption(name,defaultValue)}function setOption(name,value,cm,cfg){var option=options[name];cfg=cfg||{};var scope=cfg.scope;if(!option)throw Error("Unknown option: "+name);if("boolean"==option.type){if(value&&value!==!0)throw Error("Invalid argument: "+name+"="+value);value!==!1&&(value=!0)}if(option.callback){"local"!==scope&&option.callback(value,void 0);"global"!==scope&&cm&&option.callback(value,cm)}else{"local"!==scope&&(option.value="boolean"==option.type?!!value:value);"global"!==scope&&cm&&(cm.state.vim.options[name]={value:value})}}function getOption(name,cm,cfg){var option=options[name];cfg=cfg||{};var scope=cfg.scope;if(!option)throw Error("Unknown option: "+name);if(!option.callback){var local="global"!==scope&&cm&&cm.state.vim.options[name];return(local||"local"!==scope&&option||{}).value}var local=cm&&option.callback(void 0,cm);return"global"!==scope&&void 0!==local?local:"local"!==scope?option.callback():void 0}function MacroModeState(){this.latestRegister=void 0;this.isPlaying=!1;this.isRecording=!1;this.replaySearchQueries=[];this.onRecordingDone=void 0;this.lastInsertModeChanges=createInsertModeChanges()}function maybeInitVimState(cm){cm.state.vim||(cm.state.vim={inputState:new InputState,lastEditInputState:void 0,lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},fakeCursor:null,insertMode:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:null,sel:{},options:{}});return cm.state.vim}function resetVimGlobalState(){vimGlobalState={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:createCircularJumpList(),macroModeState:new MacroModeState,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new RegisterController({}),searchHistoryController:new HistoryController({}),exCommandHistoryController:new HistoryController({})};for(var optionName in options){var option=options[optionName];option.value=option.defaultValue}}function InputState(){this.prefixRepeat=[];this.motionRepeat=[];this.operator=null;this.operatorArgs=null;this.motion=null;this.motionArgs=null;this.keyBuffer=[];this.registerName=null}function clearInputState(cm,reason){cm.state.vim.inputState=new InputState;CodeMirror.signal(cm,"vim-command-done",reason)}function Register(text,linewise,blockwise){this.clear();this.keyBuffer=[text||""];this.insertModeChanges=[];this.searchQueries=[];this.linewise=!!linewise;this.blockwise=!!blockwise}function defineRegister(name,register){var registers=vimGlobalState.registerController.registers[name];if(!name||1!=name.length)throw Error("Register name must be 1 character");if(registers[name])throw Error("Register already defined "+name);registers[name]=register;validRegisters.push(name)}function RegisterController(registers){this.registers=registers;this.unnamedRegister=registers['"']=new Register;registers["."]=new Register;registers[":"]=new Register;registers["/"]=new Register}function HistoryController(){this.historyBuffer=[];this.iterator=0;this.initialPrefix=null}function defineMotion(name,fn){motions[name]=fn}function fillArray(val,times){for(var arr=[],i=0;times>i;i++)arr.push(val);return arr}function defineOperator(name,fn){operators[name]=fn}function defineAction(name,fn){actions[name]=fn}function clipCursorToContent(cm,cur,includeLineBreak){var line=Math.min(Math.max(cm.firstLine(),cur.line),cm.lastLine()),maxCh=lineLength(cm,line)-1;maxCh=includeLineBreak?maxCh+1:maxCh;var ch=Math.min(Math.max(0,cur.ch),maxCh);return Pos(line,ch)}function copyArgs(args){var ret={};for(var prop in args)args.hasOwnProperty(prop)&&(ret[prop]=args[prop]);return ret}function offsetCursor(cur,offsetLine,offsetCh){if("object"==typeof offsetLine){offsetCh=offsetLine.ch;offsetLine=offsetLine.line}return Pos(cur.line+offsetLine,cur.ch+offsetCh)}function getOffset(anchor,head){return{line:head.line-anchor.line,ch:head.line-anchor.line}}function commandMatches(keys,keyMap,context,inputState){for(var match,partial=[],full=[],i=0;i<keyMap.length;i++){var command=keyMap[i];if(!("insert"==context&&"insert"!=command.context||command.context&&command.context!=context||inputState.operator&&"action"==command.type)&&(match=commandMatch(keys,command.keys))){"partial"==match&&partial.push(command);"full"==match&&full.push(command)}}return{partial:partial.length&&partial,full:full.length&&full}}function commandMatch(pressed,mapped){if("<character>"==mapped.slice(-11)){var prefixLen=mapped.length-11,pressedPrefix=pressed.slice(0,prefixLen),mappedPrefix=mapped.slice(0,prefixLen);return pressedPrefix==mappedPrefix&&pressed.length>prefixLen?"full":0==mappedPrefix.indexOf(pressedPrefix)?"partial":!1}return pressed==mapped?"full":0==mapped.indexOf(pressed)?"partial":!1}function lastChar(keys){var match=/^.*(<[\w\-]+>)$/.exec(keys),selectedCharacter=match?match[1]:keys.slice(-1);if(selectedCharacter.length>1)switch(selectedCharacter){case"<CR>":selectedCharacter="\n";break;case"<Space>":selectedCharacter=" "}return selectedCharacter}function repeatFn(cm,fn,repeat){return function(){for(var i=0;repeat>i;i++)fn(cm)}}function copyCursor(cur){return Pos(cur.line,cur.ch)}function cursorEqual(cur1,cur2){return cur1.ch==cur2.ch&&cur1.line==cur2.line}function cursorIsBefore(cur1,cur2){return cur1.line<cur2.line?!0:cur1.line==cur2.line&&cur1.ch<cur2.ch?!0:!1}function cursorMin(cur1,cur2){arguments.length>2&&(cur2=cursorMin.apply(void 0,Array.prototype.slice.call(arguments,1)));return cursorIsBefore(cur1,cur2)?cur1:cur2}function cursorMax(cur1,cur2){arguments.length>2&&(cur2=cursorMax.apply(void 0,Array.prototype.slice.call(arguments,1)));return cursorIsBefore(cur1,cur2)?cur2:cur1}function cursorIsBetween(cur1,cur2,cur3){var cur1before2=cursorIsBefore(cur1,cur2),cur2before3=cursorIsBefore(cur2,cur3);return cur1before2&&cur2before3}function lineLength(cm,lineNum){return cm.getLine(lineNum).length}function trim(s){return s.trim?s.trim():s.replace(/^\s+|\s+$/g,"")}function escapeRegex(s){return s.replace(/([.?*+$\[\]\/\\(){}|\-])/g,"\\$1")}function extendLineToColumn(cm,lineNum,column){var endCh=lineLength(cm,lineNum),spaces=new Array(column-endCh+1).join(" ");cm.setCursor(Pos(lineNum,endCh));cm.replaceRange(spaces,cm.getCursor())}function selectBlock(cm,selectionEnd){var selections=[],ranges=cm.listSelections(),head=copyCursor(cm.clipPos(selectionEnd)),isClipped=!cursorEqual(selectionEnd,head),curHead=cm.getCursor("head"),primIndex=getIndex(ranges,curHead),wasClipped=cursorEqual(ranges[primIndex].head,ranges[primIndex].anchor),max=ranges.length-1,index=max-primIndex>primIndex?max:0,base=ranges[index].anchor,firstLine=Math.min(base.line,head.line),lastLine=Math.max(base.line,head.line),baseCh=base.ch,headCh=head.ch,dir=ranges[index].head.ch-baseCh,newDir=headCh-baseCh;if(dir>0&&0>=newDir){baseCh++;isClipped||headCh--}else if(0>dir&&newDir>=0){baseCh--;wasClipped||headCh++}else if(0>dir&&-1==newDir){baseCh--;headCh++}for(var line=firstLine;lastLine>=line;line++){var range={anchor:new Pos(line,baseCh),head:new Pos(line,headCh)};selections.push(range)}primIndex=head.line==lastLine?selections.length-1:0;cm.setSelections(selections);selectionEnd.ch=headCh;base.ch=baseCh;return base}function selectForInsert(cm,head,height){for(var sel=[],i=0;height>i;i++){var lineHead=offsetCursor(head,i,0);sel.push({anchor:lineHead,head:lineHead})}cm.setSelections(sel,0)}function getIndex(ranges,cursor,end){for(var i=0;i<ranges.length;i++){var atAnchor="head"!=end&&cursorEqual(ranges[i].anchor,cursor),atHead="anchor"!=end&&cursorEqual(ranges[i].head,cursor);if(atAnchor||atHead)return i}return-1}function getSelectedAreaRange(cm,vim){var lastSelection=vim.lastSelection,getCurrentSelectedAreaRange=function(){var selections=cm.listSelections(),start=selections[0],end=selections[selections.length-1],selectionStart=cursorIsBefore(start.anchor,start.head)?start.anchor:start.head,selectionEnd=cursorIsBefore(end.anchor,end.head)?end.head:end.anchor;return[selectionStart,selectionEnd]},getLastSelectedAreaRange=function(){var selectionStart=cm.getCursor(),selectionEnd=cm.getCursor(),block=lastSelection.visualBlock;if(block){var width=block.width,height=block.height;selectionEnd=Pos(selectionStart.line+height,selectionStart.ch+width);for(var selections=[],i=selectionStart.line;i<selectionEnd.line;i++){var anchor=Pos(i,selectionStart.ch),head=Pos(i,selectionEnd.ch),range={anchor:anchor,head:head};selections.push(range)}cm.setSelections(selections)}else{var start=lastSelection.anchorMark.find(),end=lastSelection.headMark.find(),line=end.line-start.line,ch=end.ch-start.ch;selectionEnd={line:selectionEnd.line+line,ch:line?selectionEnd.ch:ch+selectionEnd.ch};if(lastSelection.visualLine){selectionStart=Pos(selectionStart.line,0);selectionEnd=Pos(selectionEnd.line,lineLength(cm,selectionEnd.line))}cm.setSelection(selectionStart,selectionEnd)}return[selectionStart,selectionEnd]};return vim.visualMode?getCurrentSelectedAreaRange():getLastSelectedAreaRange()}function updateLastSelection(cm,vim){var anchor=vim.sel.anchor,head=vim.sel.head;if(vim.lastPastedText){head=cm.posFromIndex(cm.indexFromPos(anchor)+vim.lastPastedText.length);vim.lastPastedText=null}vim.lastSelection={anchorMark:cm.setBookmark(anchor),headMark:cm.setBookmark(head),anchor:copyCursor(anchor),head:copyCursor(head),visualMode:vim.visualMode,visualLine:vim.visualLine,visualBlock:vim.visualBlock}}function expandSelection(cm,start,end){var tmp,sel=cm.state.vim.sel,head=sel.head,anchor=sel.anchor;if(cursorIsBefore(end,start)){tmp=end;end=start;start=tmp}if(cursorIsBefore(head,anchor)){head=cursorMin(start,head);anchor=cursorMax(anchor,end)}else{anchor=cursorMin(start,anchor);head=cursorMax(head,end);head=offsetCursor(head,0,-1);-1==head.ch&&head.line!=cm.firstLine()&&(head=Pos(head.line-1,lineLength(cm,head.line-1)))}return[anchor,head]}function updateCmSelection(cm,sel,mode){var vim=cm.state.vim;sel=sel||vim.sel;var mode=mode||vim.visualLine?"line":vim.visualBlock?"block":"char",cmSel=makeCmSelection(cm,sel,mode);cm.setSelections(cmSel.ranges,cmSel.primary);updateFakeCursor(cm)}function makeCmSelection(cm,sel,mode,exclusive){var head=copyCursor(sel.head),anchor=copyCursor(sel.anchor);if("char"==mode){var headOffset=exclusive||cursorIsBefore(sel.head,sel.anchor)?0:1,anchorOffset=cursorIsBefore(sel.head,sel.anchor)?1:0;head=offsetCursor(sel.head,0,headOffset);anchor=offsetCursor(sel.anchor,0,anchorOffset);return{ranges:[{anchor:anchor,head:head}],primary:0}}if("line"==mode){if(cursorIsBefore(sel.head,sel.anchor)){head.ch=0;anchor.ch=lineLength(cm,anchor.line)}else{anchor.ch=0;var lastLine=cm.lastLine();head.line>lastLine&&(head.line=lastLine);head.ch=lineLength(cm,head.line)}return{ranges:[{anchor:anchor,head:head}],primary:0}}if("block"==mode){for(var top=Math.min(anchor.line,head.line),left=Math.min(anchor.ch,head.ch),bottom=Math.max(anchor.line,head.line),right=Math.max(anchor.ch,head.ch)+1,height=bottom-top+1,primary=head.line==top?0:height-1,ranges=[],i=0;height>i;i++)ranges.push({anchor:Pos(top+i,left),head:Pos(top+i,right)});return{ranges:ranges,primary:primary}}}function getHead(cm){var cur=cm.getCursor("head");1==cm.getSelection().length&&(cur=cursorMin(cur,cm.getCursor("anchor")));return cur}function exitVisualMode(cm,moveHead){var vim=cm.state.vim;moveHead!==!1&&cm.setCursor(clipCursorToContent(cm,vim.sel.head));updateLastSelection(cm,vim);vim.visualMode=!1;vim.visualLine=!1;vim.visualBlock=!1;CodeMirror.signal(cm,"vim-mode-change",{mode:"normal"});vim.fakeCursor&&vim.fakeCursor.clear()}function clipToLine(cm,curStart,curEnd){var selection=cm.getRange(curStart,curEnd);if(/\n\s*$/.test(selection)){var lines=selection.split("\n");lines.pop();for(var line,line=lines.pop();lines.length>0&&line&&isWhiteSpaceString(line);line=lines.pop()){curEnd.line--;curEnd.ch=0}if(line){curEnd.line--;curEnd.ch=lineLength(cm,curEnd.line)}else curEnd.ch=0}}function expandSelectionToLine(_cm,curStart,curEnd){curStart.ch=0;curEnd.ch=0;curEnd.line++}function findFirstNonWhiteSpaceCharacter(text){if(!text)return 0;var firstNonWS=text.search(/\S/);return-1==firstNonWS?text.length:firstNonWS}function expandWordUnderCursor(cm,inclusive,_forward,bigWord,noSymbol){for(var cur=getHead(cm),line=cm.getLine(cur.line),idx=cur.ch,test=noSymbol?wordCharTest[0]:bigWordCharTest[0];!test(line.charAt(idx));){idx++;if(idx>=line.length)return null}if(bigWord)test=bigWordCharTest[0];else{test=wordCharTest[0];test(line.charAt(idx))||(test=wordCharTest[1])}for(var end=idx,start=idx;test(line.charAt(end))&&end<line.length;)end++;for(;test(line.charAt(start))&&start>=0;)start--;start++;if(inclusive){for(var wordEnd=end;/\s/.test(line.charAt(end))&&end<line.length;)end++;if(wordEnd==end){for(var wordStart=start;/\s/.test(line.charAt(start-1))&&start>0;)start--;start||(start=wordStart)}}return{start:Pos(cur.line,start),end:Pos(cur.line,end)}}function recordJumpPosition(cm,oldCur,newCur){cursorEqual(oldCur,newCur)||vimGlobalState.jumpList.add(cm,oldCur,newCur)}function recordLastCharacterSearch(increment,args){vimGlobalState.lastCharacterSearch.increment=increment;vimGlobalState.lastCharacterSearch.forward=args.forward;vimGlobalState.lastCharacterSearch.selectedCharacter=args.selectedCharacter}function findSymbol(cm,repeat,forward,symb){var cur=copyCursor(cm.getCursor()),increment=forward?1:-1,endLine=forward?cm.lineCount():-1,curCh=cur.ch,line=cur.line,lineText=cm.getLine(line),state={lineText:lineText,nextCh:lineText.charAt(curCh),lastCh:null,index:curCh,symb:symb,reverseSymb:(forward?{")":"(","}":"{"}:{"(":")","{":"}"})[symb],forward:forward,depth:0,curMoveThrough:!1},mode=symbolToMode[symb];if(!mode)return cur;var init=findSymbolModes[mode].init,isComplete=findSymbolModes[mode].isComplete;init&&init(state);for(;line!==endLine&&repeat;){state.index+=increment;state.nextCh=state.lineText.charAt(state.index);if(!state.nextCh){line+=increment;state.lineText=cm.getLine(line)||"";if(increment>0)state.index=0;else{var lineLen=state.lineText.length;state.index=lineLen>0?lineLen-1:0}state.nextCh=state.lineText.charAt(state.index)}if(isComplete(state)){cur.line=line;cur.ch=state.index;repeat--}}return state.nextCh||state.curMoveThrough?Pos(line,state.index):cur}function findWord(cm,cur,forward,bigWord,emptyLineIsWord){var lineNum=cur.line,pos=cur.ch,line=cm.getLine(lineNum),dir=forward?1:-1,charTests=bigWord?bigWordCharTest:wordCharTest;if(emptyLineIsWord&&""==line){lineNum+=dir;line=cm.getLine(lineNum);if(!isLine(cm,lineNum))return null;pos=forward?0:line.length}for(;;){if(emptyLineIsWord&&""==line)return{from:0,to:0,line:lineNum};for(var stop=dir>0?line.length:-1,wordStart=stop,wordEnd=stop;pos!=stop;){for(var foundWord=!1,i=0;i<charTests.length&&!foundWord;++i)if(charTests[i](line.charAt(pos))){wordStart=pos;for(;pos!=stop&&charTests[i](line.charAt(pos));)pos+=dir;wordEnd=pos;foundWord=wordStart!=wordEnd;if(wordStart==cur.ch&&lineNum==cur.line&&wordEnd==wordStart+dir)continue;return{from:Math.min(wordStart,wordEnd+1),to:Math.max(wordStart,wordEnd),line:lineNum}}foundWord||(pos+=dir)}lineNum+=dir;if(!isLine(cm,lineNum))return null;line=cm.getLine(lineNum);pos=dir>0?0:line.length}}function moveToWord(cm,cur,repeat,forward,wordEnd,bigWord){var curStart=copyCursor(cur),words=[];(forward&&!wordEnd||!forward&&wordEnd)&&repeat++;for(var emptyLineIsWord=!(forward&&wordEnd),i=0;repeat>i;i++){var word=findWord(cm,cur,forward,bigWord,emptyLineIsWord);if(!word){var eodCh=lineLength(cm,cm.lastLine());words.push(forward?{line:cm.lastLine(),from:eodCh,to:eodCh}:{line:0,from:0,to:0});break}words.push(word);cur=Pos(word.line,forward?word.to-1:word.from)}var shortCircuit=words.length!=repeat,firstWord=words[0],lastWord=words.pop();if(forward&&!wordEnd){shortCircuit||firstWord.from==curStart.ch&&firstWord.line==curStart.line||(lastWord=words.pop());return Pos(lastWord.line,lastWord.from)}if(forward&&wordEnd)return Pos(lastWord.line,lastWord.to-1);if(!forward&&wordEnd){shortCircuit||firstWord.to==curStart.ch&&firstWord.line==curStart.line||(lastWord=words.pop());return Pos(lastWord.line,lastWord.to)}return Pos(lastWord.line,lastWord.from)}function moveToCharacter(cm,repeat,forward,character){for(var idx,cur=cm.getCursor(),start=cur.ch,i=0;repeat>i;i++){var line=cm.getLine(cur.line);idx=charIdxInLine(start,line,character,forward,!0);if(-1==idx)return null;start=idx}return Pos(cm.getCursor().line,idx)}function moveToColumn(cm,repeat){var line=cm.getCursor().line;return clipCursorToContent(cm,Pos(line,repeat-1));
2
+ }function updateMark(cm,vim,markName,pos){if(inArray(markName,validMarks)){vim.marks[markName]&&vim.marks[markName].clear();vim.marks[markName]=cm.setBookmark(pos)}}function charIdxInLine(start,line,character,forward,includeChar){var idx;if(forward){idx=line.indexOf(character,start+1);-1==idx||includeChar||(idx-=1)}else{idx=line.lastIndexOf(character,start-1);-1==idx||includeChar||(idx+=1)}return idx}function findParagraph(cm,head,repeat,dir,inclusive){function isEmpty(i){return!cm.getLine(i)}function isBoundary(i,dir,any){return any?isEmpty(i)!=isEmpty(i+dir):!isEmpty(i)&&isEmpty(i+dir)}var start,end,line=head.line,min=cm.firstLine(),max=cm.lastLine(),i=line;if(dir){for(;i>=min&&max>=i&&repeat>0;){isBoundary(i,dir)&&repeat--;i+=dir}return new Pos(i,0)}var vim=cm.state.vim;if(vim.visualLine&&isBoundary(line,1,!0)){var anchor=vim.sel.anchor;isBoundary(anchor.line,-1,!0)&&(inclusive&&anchor.line==line||(line+=1))}var startState=isEmpty(line);for(i=line;max>=i&&repeat;i++)isBoundary(i,1,!0)&&(inclusive&&isEmpty(i)==startState||repeat--);end=new Pos(i,0);i>max&&!startState?startState=!0:inclusive=!1;for(i=line;i>min&&(inclusive&&isEmpty(i)!=startState&&i!=line||!isBoundary(i,-1,!0));i--);start=new Pos(i,0);return{start:start,end:end}}function selectCompanionObject(cm,head,symb,inclusive){var start,end,cur=head,bracketRegexp={"(":/[()]/,")":/[()]/,"[":/[[\]]/,"]":/[[\]]/,"{":/[{}]/,"}":/[{}]/}[symb],openSym={"(":"(",")":"(","[":"[","]":"[","{":"{","}":"{"}[symb],curChar=cm.getLine(cur.line).charAt(cur.ch),offset=curChar===openSym?1:0;start=cm.scanForBracket(Pos(cur.line,cur.ch+offset),-1,null,{bracketRegex:bracketRegexp});end=cm.scanForBracket(Pos(cur.line,cur.ch+offset),1,null,{bracketRegex:bracketRegexp});if(!start||!end)return{start:cur,end:cur};start=start.pos;end=end.pos;if(start.line==end.line&&start.ch>end.ch||start.line>end.line){var tmp=start;start=end;end=tmp}inclusive?end.ch+=1:start.ch+=1;return{start:start,end:end}}function findBeginningAndEnd(cm,head,symb,inclusive){var start,end,i,len,cur=copyCursor(head),line=cm.getLine(cur.line),chars=line.split(""),firstIndex=chars.indexOf(symb);if(cur.ch<firstIndex)cur.ch=firstIndex;else if(firstIndex<cur.ch&&chars[cur.ch]==symb){end=cur.ch;--cur.ch}if(chars[cur.ch]!=symb||end)for(i=cur.ch;i>-1&&!start;i--)chars[i]==symb&&(start=i+1);else start=cur.ch+1;if(start&&!end)for(i=start,len=chars.length;len>i&&!end;i++)chars[i]==symb&&(end=i);if(!start||!end)return{start:cur,end:cur};if(inclusive){--start;++end}return{start:Pos(cur.line,start),end:Pos(cur.line,end)}}function SearchState(){}function getSearchState(cm){var vim=cm.state.vim;return vim.searchState_||(vim.searchState_=new SearchState)}function dialog(cm,template,shortText,onClose,options){cm.openDialog?cm.openDialog(template,onClose,{bottom:!0,value:options.value,onKeyDown:options.onKeyDown,onKeyUp:options.onKeyUp,selectValueOnOpen:!1}):onClose(prompt(shortText,""))}function splitBySlash(argString){var slashes=findUnescapedSlashes(argString)||[];if(!slashes.length)return[];var tokens=[];if(0===slashes[0]){for(var i=0;i<slashes.length;i++)"number"==typeof slashes[i]&&tokens.push(argString.substring(slashes[i]+1,slashes[i+1]));return tokens}}function findUnescapedSlashes(str){for(var escapeNextChar=!1,slashes=[],i=0;i<str.length;i++){var c=str.charAt(i);escapeNextChar||"/"!=c||slashes.push(i);escapeNextChar=!escapeNextChar&&"\\"==c}return slashes}function translateRegex(str){for(var specials="|(){",unescape="}",escapeNextChar=!1,out=[],i=-1;i<str.length;i++){var c=str.charAt(i)||"",n=str.charAt(i+1)||"",specialComesNext=n&&-1!=specials.indexOf(n);if(escapeNextChar){"\\"===c&&specialComesNext||out.push(c);escapeNextChar=!1}else if("\\"===c){escapeNextChar=!0;n&&-1!=unescape.indexOf(n)&&(specialComesNext=!0);specialComesNext&&"\\"!==n||out.push(c)}else{out.push(c);specialComesNext&&"\\"!==n&&out.push("\\")}}return out.join("")}function translateRegexReplace(str){for(var escapeNextChar=!1,out=[],i=-1;i<str.length;i++){var c=str.charAt(i)||"",n=str.charAt(i+1)||"";if(charUnescapes[c+n]){out.push(charUnescapes[c+n]);i++}else if(escapeNextChar){out.push(c);escapeNextChar=!1}else if("\\"===c){escapeNextChar=!0;isNumber(n)||"$"===n?out.push("$"):"/"!==n&&"\\"!==n&&out.push("\\")}else{"$"===c&&out.push("$");out.push(c);"/"===n&&out.push("\\")}}return out.join("")}function unescapeRegexReplace(str){for(var stream=new CodeMirror.StringStream(str),output=[];!stream.eol();){for(;stream.peek()&&"\\"!=stream.peek();)output.push(stream.next());var matched=!1;for(var matcher in unescapes)if(stream.match(matcher,!0)){matched=!0;output.push(unescapes[matcher]);break}matched||output.push(stream.next())}return output.join("")}function parseQuery(query,ignoreCase,smartCase){var lastSearchRegister=vimGlobalState.registerController.getRegister("/");lastSearchRegister.setText(query);if(query instanceof RegExp)return query;var regexPart,forceIgnoreCase,slashes=findUnescapedSlashes(query);if(slashes.length){regexPart=query.substring(0,slashes[0]);var flagsPart=query.substring(slashes[0]);forceIgnoreCase=-1!=flagsPart.indexOf("i")}else regexPart=query;if(!regexPart)return null;getOption("pcre")||(regexPart=translateRegex(regexPart));smartCase&&(ignoreCase=/^[^A-Z]*$/.test(regexPart));var regexp=new RegExp(regexPart,ignoreCase||forceIgnoreCase?"i":void 0);return regexp}function showConfirm(cm,text){cm.openNotification?cm.openNotification('<span style="color: red">'+text+"</span>",{bottom:!0,duration:5e3}):alert(text)}function makePrompt(prefix,desc){var raw="";prefix&&(raw+='<span style="font-family: monospace">'+prefix+"</span>");raw+='<input type="text"/> <span style="color: #888">';if(desc){raw+='<span style="color: #888">';raw+=desc;raw+="</span>"}return raw}function showPrompt(cm,options){var shortText=(options.prefix||"")+" "+(options.desc||""),prompt=makePrompt(options.prefix,options.desc);dialog(cm,prompt,shortText,options.onClose,options)}function regexEqual(r1,r2){if(r1 instanceof RegExp&&r2 instanceof RegExp){for(var props=["global","multiline","ignoreCase","source"],i=0;i<props.length;i++){var prop=props[i];if(r1[prop]!==r2[prop])return!1}return!0}return!1}function updateSearchQuery(cm,rawQuery,ignoreCase,smartCase){if(rawQuery){var state=getSearchState(cm),query=parseQuery(rawQuery,!!ignoreCase,!!smartCase);if(query){highlightSearchMatches(cm,query);if(regexEqual(query,state.getQuery()))return query;state.setQuery(query);return query}}}function searchOverlay(query){if("^"==query.source.charAt(0))var matchSol=!0;return{token:function(stream){if(!matchSol||stream.sol()){var match=stream.match(query,!1);if(match){if(0==match[0].length){stream.next();return"searching"}if(!stream.sol()){stream.backUp(1);if(!query.exec(stream.next()+match[0])){stream.next();return null}}stream.match(query);return"searching"}for(;!stream.eol();){stream.next();if(stream.match(query,!1))break}}else stream.skipToEnd()},query:query}}function highlightSearchMatches(cm,query){var searchState=getSearchState(cm),overlay=searchState.getOverlay();if(!overlay||query!=overlay.query){overlay&&cm.removeOverlay(overlay);overlay=searchOverlay(query);cm.addOverlay(overlay);if(cm.showMatchesOnScrollbar){searchState.getScrollbarAnnotate()&&searchState.getScrollbarAnnotate().clear();searchState.setScrollbarAnnotate(cm.showMatchesOnScrollbar(query))}searchState.setOverlay(overlay)}}function findNext(cm,prev,query,repeat){void 0===repeat&&(repeat=1);return cm.operation(function(){for(var pos=cm.getCursor(),cursor=cm.getSearchCursor(query,pos),i=0;repeat>i;i++){var found=cursor.find(prev);0==i&&found&&cursorEqual(cursor.from(),pos)&&(found=cursor.find(prev));if(!found){cursor=cm.getSearchCursor(query,prev?Pos(cm.lastLine()):Pos(cm.firstLine(),0));if(!cursor.find(prev))return}}return cursor.from()})}function clearSearchHighlight(cm){var state=getSearchState(cm);cm.removeOverlay(getSearchState(cm).getOverlay());state.setOverlay(null);if(state.getScrollbarAnnotate()){state.getScrollbarAnnotate().clear();state.setScrollbarAnnotate(null)}}function isInRange(pos,start,end){"number"!=typeof pos&&(pos=pos.line);return start instanceof Array?inArray(pos,start):end?pos>=start&&end>=pos:pos==start}function getUserVisibleLines(cm){var scrollInfo=cm.getScrollInfo(),occludeToleranceTop=6,occludeToleranceBottom=10,from=cm.coordsChar({left:0,top:occludeToleranceTop+scrollInfo.top},"local"),bottomY=scrollInfo.clientHeight-occludeToleranceBottom+scrollInfo.top,to=cm.coordsChar({left:0,top:bottomY},"local");return{top:from.line,bottom:to.line}}function doReplace(cm,confirm,global,lineStart,lineEnd,searchCursor,query,replaceWith,callback){function replaceAll(){cm.operation(function(){for(;!done;){replace();next()}stop()})}function replace(){var text=cm.getRange(searchCursor.from(),searchCursor.to()),newText=text.replace(query,replaceWith);searchCursor.replace(newText)}function next(){for(;searchCursor.findNext()&&isInRange(searchCursor.from(),lineStart,lineEnd);)if(global||!lastPos||searchCursor.from().line!=lastPos.line){cm.scrollIntoView(searchCursor.from(),30);cm.setSelection(searchCursor.from(),searchCursor.to());lastPos=searchCursor.from();done=!1;return}done=!0}function stop(close){close&&close();cm.focus();if(lastPos){cm.setCursor(lastPos);var vim=cm.state.vim;vim.exMode=!1;vim.lastHPos=vim.lastHSPos=lastPos.ch}callback&&callback()}function onPromptKeyDown(e,_value,close){CodeMirror.e_stop(e);var keyName=CodeMirror.keyName(e);switch(keyName){case"Y":replace();next();break;case"N":next();break;case"A":var savedCallback=callback;callback=void 0;cm.operation(replaceAll);callback=savedCallback;break;case"L":replace();case"Q":case"Esc":case"Ctrl-C":case"Ctrl-[":stop(close)}done&&stop(close);return!0}cm.state.vim.exMode=!0;var done=!1,lastPos=searchCursor.from();next();if(done)showConfirm(cm,"No matches for "+query.source);else if(confirm)showPrompt(cm,{prefix:"replace with <strong>"+replaceWith+"</strong> (y/n/a/q/l)",onKeyDown:onPromptKeyDown});else{replaceAll();callback&&callback()}}function exitInsertMode(cm){var vim=cm.state.vim,macroModeState=vimGlobalState.macroModeState,insertModeChangeRegister=vimGlobalState.registerController.getRegister("."),isPlaying=macroModeState.isPlaying,lastChange=macroModeState.lastInsertModeChanges,text=[];if(!isPlaying){for(var selLength=lastChange.inVisualBlock?vim.lastSelection.visualBlock.height:1,changes=lastChange.changes,text=[],i=0;i<changes.length;){text.push(changes[i]);changes[i]instanceof InsertModeKey?i++:i+=selLength}lastChange.changes=text;cm.off("change",onChange);CodeMirror.off(cm.getInputField(),"keydown",onKeyEventTargetKeyDown)}if(!isPlaying&&vim.insertModeRepeat>1){repeatLastEdit(cm,vim,vim.insertModeRepeat-1,!0);vim.lastEditInputState.repeatOverride=vim.insertModeRepeat}delete vim.insertModeRepeat;vim.insertMode=!1;cm.setCursor(cm.getCursor().line,cm.getCursor().ch-1);cm.setOption("keyMap","vim");cm.setOption("disableInput",!0);cm.toggleOverwrite(!1);insertModeChangeRegister.setText(lastChange.changes.join(""));CodeMirror.signal(cm,"vim-mode-change",{mode:"normal"});macroModeState.isRecording&&logInsertModeChange(macroModeState)}function _mapCommand(command){defaultKeymap.unshift(command)}function mapCommand(keys,type,name,args,extra){var command={keys:keys,type:type};command[type]=name;command[type+"Args"]=args;for(var key in extra)command[key]=extra[key];_mapCommand(command)}function executeMacroRegister(cm,vim,macroModeState,registerName){var register=vimGlobalState.registerController.getRegister(registerName);if(":"!=registerName){var keyBuffer=register.keyBuffer,imc=0;macroModeState.isPlaying=!0;macroModeState.replaySearchQueries=register.searchQueries.slice(0);for(var i=0;i<keyBuffer.length;i++)for(var match,key,text=keyBuffer[i];text;){match=/<\w+-.+?>|<\w+>|./.exec(text);key=match[0];text=text.substring(match.index+key.length);CodeMirror.Vim.handleKey(cm,key,"macro");if(vim.insertMode){var changes=register.insertModeChanges[imc++].changes;vimGlobalState.macroModeState.lastInsertModeChanges.changes=changes;repeatInsertModeChanges(cm,changes,1);exitInsertMode(cm)}}macroModeState.isPlaying=!1}else{register.keyBuffer[0]&&exCommandDispatcher.processCommand(cm,register.keyBuffer[0]);macroModeState.isPlaying=!1}}function logKey(macroModeState,key){if(!macroModeState.isPlaying){var registerName=macroModeState.latestRegister,register=vimGlobalState.registerController.getRegister(registerName);register&&register.pushText(key)}}function logInsertModeChange(macroModeState){if(!macroModeState.isPlaying){var registerName=macroModeState.latestRegister,register=vimGlobalState.registerController.getRegister(registerName);register&&register.pushInsertModeChanges&&register.pushInsertModeChanges(macroModeState.lastInsertModeChanges)}}function logSearchQuery(macroModeState,query){if(!macroModeState.isPlaying){var registerName=macroModeState.latestRegister,register=vimGlobalState.registerController.getRegister(registerName);register&&register.pushSearchQuery&&register.pushSearchQuery(query)}}function onChange(_cm,changeObj){var macroModeState=vimGlobalState.macroModeState,lastChange=macroModeState.lastInsertModeChanges;if(!macroModeState.isPlaying)for(;changeObj;){lastChange.expectCursorActivityForChange=!0;if("+input"==changeObj.origin||"paste"==changeObj.origin||void 0===changeObj.origin){var text=changeObj.text.join("\n");lastChange.changes.push(text)}changeObj=changeObj.next}}function onCursorActivity(cm){var vim=cm.state.vim;if(vim.insertMode){var macroModeState=vimGlobalState.macroModeState;if(macroModeState.isPlaying)return;var lastChange=macroModeState.lastInsertModeChanges;lastChange.expectCursorActivityForChange?lastChange.expectCursorActivityForChange=!1:lastChange.changes=[]}else cm.curOp.isVimOp||handleExternalSelection(cm,vim);vim.visualMode&&updateFakeCursor(cm)}function updateFakeCursor(cm){var vim=cm.state.vim,from=clipCursorToContent(cm,copyCursor(vim.sel.head)),to=offsetCursor(from,0,1);vim.fakeCursor&&vim.fakeCursor.clear();vim.fakeCursor=cm.markText(from,to,{className:"cm-animate-fat-cursor"})}function handleExternalSelection(cm,vim){var anchor=cm.getCursor("anchor"),head=cm.getCursor("head");if(vim.visualMode&&!cm.somethingSelected())exitVisualMode(cm,!1);else if(!vim.visualMode&&!vim.insertMode&&cm.somethingSelected()){vim.visualMode=!0;vim.visualLine=!1;CodeMirror.signal(cm,"vim-mode-change",{mode:"visual"})}if(vim.visualMode){var headOffset=cursorIsBefore(head,anchor)?0:-1,anchorOffset=cursorIsBefore(head,anchor)?-1:0;head=offsetCursor(head,0,headOffset);anchor=offsetCursor(anchor,0,anchorOffset);vim.sel={anchor:anchor,head:head};updateMark(cm,vim,"<",cursorMin(head,anchor));updateMark(cm,vim,">",cursorMax(head,anchor))}else vim.insertMode||(vim.lastHPos=cm.getCursor().ch)}function InsertModeKey(keyName){this.keyName=keyName}function onKeyEventTargetKeyDown(e){function onKeyFound(){lastChange.changes.push(new InsertModeKey(keyName));return!0}var macroModeState=vimGlobalState.macroModeState,lastChange=macroModeState.lastInsertModeChanges,keyName=CodeMirror.keyName(e);keyName&&(-1!=keyName.indexOf("Delete")||-1!=keyName.indexOf("Backspace"))&&CodeMirror.lookupKey(keyName,"vim-insert",onKeyFound)}function repeatLastEdit(cm,vim,repeat,repeatForInsert){function repeatCommand(){isAction?commandDispatcher.processAction(cm,vim,vim.lastEditActionCommand):commandDispatcher.evalInput(cm,vim)}function repeatInsert(repeat){if(macroModeState.lastInsertModeChanges.changes.length>0){repeat=vim.lastEditActionCommand?repeat:1;var changeObject=macroModeState.lastInsertModeChanges;repeatInsertModeChanges(cm,changeObject.changes,repeat)}}var macroModeState=vimGlobalState.macroModeState;macroModeState.isPlaying=!0;var isAction=!!vim.lastEditActionCommand,cachedInputState=vim.inputState;vim.inputState=vim.lastEditInputState;if(isAction&&vim.lastEditActionCommand.interlaceInsertRepeat)for(var i=0;repeat>i;i++){repeatCommand();repeatInsert(1)}else{repeatForInsert||repeatCommand();repeatInsert(repeat)}vim.inputState=cachedInputState;vim.insertMode&&!repeatForInsert&&exitInsertMode(cm);macroModeState.isPlaying=!1}function repeatInsertModeChanges(cm,changes,repeat){function keyHandler(binding){"string"==typeof binding?CodeMirror.commands[binding](cm):binding(cm);return!0}var head=cm.getCursor("head"),inVisualBlock=vimGlobalState.macroModeState.lastInsertModeChanges.inVisualBlock;if(inVisualBlock){var vim=cm.state.vim,lastSel=vim.lastSelection,offset=getOffset(lastSel.anchor,lastSel.head);selectForInsert(cm,head,offset.line+1);repeat=cm.listSelections().length;cm.setCursor(head)}for(var i=0;repeat>i;i++){inVisualBlock&&cm.setCursor(offsetCursor(head,i,0));for(var j=0;j<changes.length;j++){var change=changes[j];if(change instanceof InsertModeKey)CodeMirror.lookupKey(change.keyName,"vim-insert",keyHandler);else{var cur=cm.getCursor();cm.replaceRange(change,cur,cur)}}}inVisualBlock&&cm.setCursor(offsetCursor(head,0,1))}CodeMirror.defineOption("vimMode",!1,function(cm,val,prev){val&&"vim"!=cm.getOption("keyMap")?cm.setOption("keyMap","vim"):!val&&prev!=CodeMirror.Init&&/^vim/.test(cm.getOption("keyMap"))&&cm.setOption("keyMap","default")});var modifiers={Shift:"S",Ctrl:"C",Alt:"A",Cmd:"D",Mod:"A"},specialKeys={Enter:"CR",Backspace:"BS",Delete:"Del"},numberRegex=/[\d]/,wordCharTest=[CodeMirror.isWordChar,function(ch){return ch&&!CodeMirror.isWordChar(ch)&&!/\s/.test(ch)}],bigWordCharTest=[function(ch){return/\S/.test(ch)}],upperCaseAlphabet=makeKeyRange(65,26),lowerCaseAlphabet=makeKeyRange(97,26),numbers=makeKeyRange(48,10),validMarks=[].concat(upperCaseAlphabet,lowerCaseAlphabet,numbers,["<",">"]),validRegisters=[].concat(upperCaseAlphabet,lowerCaseAlphabet,numbers,["-",'"',".",":","/"]),options={};defineOption("filetype",void 0,"string",["ft"],function(name,cm){if(void 0!==cm){if(void 0===name){var mode=cm.getOption("mode");return"null"==mode?"":mode}var mode=""==name?"null":name;cm.setOption("mode",mode)}});var createCircularJumpList=function(){function add(cm,oldCur,newCur){function useNextSlot(cursor){var next=++pointer%size,trashMark=buffer[next];trashMark&&trashMark.clear();buffer[next]=cm.setBookmark(cursor)}var current=pointer%size,curMark=buffer[current];if(curMark){var markPos=curMark.find();markPos&&!cursorEqual(markPos,oldCur)&&useNextSlot(oldCur)}else useNextSlot(oldCur);useNextSlot(newCur);head=pointer;tail=pointer-size+1;0>tail&&(tail=0)}function move(cm,offset){pointer+=offset;pointer>head?pointer=head:tail>pointer&&(pointer=tail);var mark=buffer[(size+pointer)%size];if(mark&&!mark.find()){var newCur,inc=offset>0?1:-1,oldCur=cm.getCursor();do{pointer+=inc;mark=buffer[(size+pointer)%size];if(mark&&(newCur=mark.find())&&!cursorEqual(oldCur,newCur))break}while(head>pointer&&pointer>tail)}return mark}var size=100,pointer=-1,head=0,tail=0,buffer=new Array(size);return{cachedCursor:void 0,add:add,move:move}},createInsertModeChanges=function(c){return c?{changes:c.changes,expectCursorActivityForChange:c.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};MacroModeState.prototype={exitMacroRecordMode:function(){var macroModeState=vimGlobalState.macroModeState;macroModeState.onRecordingDone&&macroModeState.onRecordingDone();macroModeState.onRecordingDone=void 0;macroModeState.isRecording=!1},enterMacroRecordMode:function(cm,registerName){var register=vimGlobalState.registerController.getRegister(registerName);if(register){register.clear();this.latestRegister=registerName;cm.openDialog&&(this.onRecordingDone=cm.openDialog("(recording)["+registerName+"]",null,{bottom:!0}));this.isRecording=!0}}};var vimGlobalState,lastInsertModeKeyTimer,vimApi={buildKeyMap:function(){},getRegisterController:function(){return vimGlobalState.registerController},resetVimGlobalState_:resetVimGlobalState,getVimGlobalState_:function(){return vimGlobalState},maybeInitVimState_:maybeInitVimState,suppressErrorLogging:!1,InsertModeKey:InsertModeKey,map:function(lhs,rhs,ctx){exCommandDispatcher.map(lhs,rhs,ctx)},unmap:function(lhs,ctx){exCommandDispatcher.unmap(lhs,ctx)},setOption:setOption,getOption:getOption,defineOption:defineOption,defineEx:function(name,prefix,func){if(prefix){if(0!==name.indexOf(prefix))throw new Error('(Vim.defineEx) "'+prefix+'" is not a prefix of "'+name+'", command not registered')}else prefix=name;exCommands[name]=func;exCommandDispatcher.commandMap_[prefix]={name:name,shortName:prefix,type:"api"}},handleKey:function(cm,key,origin){var command=this.findKey(cm,key,origin);return"function"==typeof command?command():void 0},findKey:function(cm,key,origin){function handleMacroRecording(){var macroModeState=vimGlobalState.macroModeState;if(macroModeState.isRecording){if("q"==key){macroModeState.exitMacroRecordMode();clearInputState(cm);return!0}"mapping"!=origin&&logKey(macroModeState,key)}}function handleEsc(){if("<Esc>"==key){clearInputState(cm);vim.visualMode?exitVisualMode(cm):vim.insertMode&&exitInsertMode(cm);return!0}}function doKeyToKey(keys){for(var match;keys;){match=/<\w+-.+?>|<\w+>|./.exec(keys);key=match[0];keys=keys.substring(match.index+key.length);CodeMirror.Vim.handleKey(cm,key,"mapping")}}function handleKeyInsertMode(){if(handleEsc())return!0;for(var keys=vim.inputState.keyBuffer=vim.inputState.keyBuffer+key,keysAreChars=1==key.length,match=commandDispatcher.matchCommand(keys,defaultKeymap,vim.inputState,"insert");keys.length>1&&"full"!=match.type;){var keys=vim.inputState.keyBuffer=keys.slice(1),thisMatch=commandDispatcher.matchCommand(keys,defaultKeymap,vim.inputState,"insert");"none"!=thisMatch.type&&(match=thisMatch)}if("none"==match.type){clearInputState(cm);return!1}if("partial"==match.type){lastInsertModeKeyTimer&&window.clearTimeout(lastInsertModeKeyTimer);lastInsertModeKeyTimer=window.setTimeout(function(){vim.insertMode&&vim.inputState.keyBuffer&&clearInputState(cm)},getOption("insertModeEscKeysTimeout"));return!keysAreChars}lastInsertModeKeyTimer&&window.clearTimeout(lastInsertModeKeyTimer);if(keysAreChars){var here=cm.getCursor();cm.replaceRange("",offsetCursor(here,0,-(keys.length-1)),here,"+input")}clearInputState(cm);return match.command}function handleKeyNonInsertMode(){if(handleMacroRecording()||handleEsc())return!0;var keys=vim.inputState.keyBuffer=vim.inputState.keyBuffer+key;if(/^[1-9]\d*$/.test(keys))return!0;var keysMatcher=/^(\d*)(.*)$/.exec(keys);if(!keysMatcher){clearInputState(cm);return!1}var context=vim.visualMode?"visual":"normal",match=commandDispatcher.matchCommand(keysMatcher[2]||keysMatcher[1],defaultKeymap,vim.inputState,context);if("none"==match.type){clearInputState(cm);return!1}if("partial"==match.type)return!0;vim.inputState.keyBuffer="";var keysMatcher=/^(\d*)(.*)$/.exec(keys);keysMatcher[1]&&"0"!=keysMatcher[1]&&vim.inputState.pushRepeatDigit(keysMatcher[1]);return match.command}var command,vim=maybeInitVimState(cm);command=vim.insertMode?handleKeyInsertMode():handleKeyNonInsertMode();return command===!1?void 0:command===!0?function(){}:function(){return cm.operation(function(){cm.curOp.isVimOp=!0;try{"keyToKey"==command.type?doKeyToKey(command.toKeys):commandDispatcher.processCommand(cm,vim,command)}catch(e){cm.state.vim=void 0;maybeInitVimState(cm);CodeMirror.Vim.suppressErrorLogging||console.log(e);throw e}return!0})}},handleEx:function(cm,input){exCommandDispatcher.processCommand(cm,input)},defineMotion:defineMotion,defineAction:defineAction,defineOperator:defineOperator,mapCommand:mapCommand,_mapCommand:_mapCommand,defineRegister:defineRegister,exitVisualMode:exitVisualMode,exitInsertMode:exitInsertMode};InputState.prototype.pushRepeatDigit=function(n){this.operator?this.motionRepeat=this.motionRepeat.concat(n):this.prefixRepeat=this.prefixRepeat.concat(n)};InputState.prototype.getRepeat=function(){var repeat=0;if(this.prefixRepeat.length>0||this.motionRepeat.length>0){repeat=1;this.prefixRepeat.length>0&&(repeat*=parseInt(this.prefixRepeat.join(""),10));this.motionRepeat.length>0&&(repeat*=parseInt(this.motionRepeat.join(""),10))}return repeat};Register.prototype={setText:function(text,linewise,blockwise){this.keyBuffer=[text||""];this.linewise=!!linewise;this.blockwise=!!blockwise},pushText:function(text,linewise){if(linewise){this.linewise||this.keyBuffer.push("\n");this.linewise=!0}this.keyBuffer.push(text)},pushInsertModeChanges:function(changes){this.insertModeChanges.push(createInsertModeChanges(changes))},pushSearchQuery:function(query){this.searchQueries.push(query)},clear:function(){this.keyBuffer=[];this.insertModeChanges=[];this.searchQueries=[];this.linewise=!1},toString:function(){return this.keyBuffer.join("")}};RegisterController.prototype={pushText:function(registerName,operator,text,linewise,blockwise){linewise&&"\n"==text.charAt(0)&&(text=text.slice(1)+"\n");linewise&&"\n"!==text.charAt(text.length-1)&&(text+="\n");var register=this.isValidRegister(registerName)?this.getRegister(registerName):null;if(register){var append=isUpperCase(registerName);append?register.pushText(text,linewise):register.setText(text,linewise,blockwise);this.unnamedRegister.setText(register.toString(),linewise)}else{switch(operator){case"yank":this.registers[0]=new Register(text,linewise,blockwise);break;case"delete":case"change":if(-1==text.indexOf("\n"))this.registers["-"]=new Register(text,linewise);else{this.shiftNumericRegisters_();this.registers[1]=new Register(text,linewise)}}this.unnamedRegister.setText(text,linewise,blockwise)}},getRegister:function(name){if(!this.isValidRegister(name))return this.unnamedRegister;name=name.toLowerCase();this.registers[name]||(this.registers[name]=new Register);return this.registers[name]},isValidRegister:function(name){return name&&inArray(name,validRegisters)},shiftNumericRegisters_:function(){for(var i=9;i>=2;i--)this.registers[i]=this.getRegister(""+(i-1))}};HistoryController.prototype={nextMatch:function(input,up){var historyBuffer=this.historyBuffer,dir=up?-1:1;null===this.initialPrefix&&(this.initialPrefix=input);for(var i=this.iterator+dir;up?i>=0:i<historyBuffer.length;i+=dir)for(var element=historyBuffer[i],j=0;j<=element.length;j++)if(this.initialPrefix==element.substring(0,j)){this.iterator=i;return element}if(i>=historyBuffer.length){this.iterator=historyBuffer.length;return this.initialPrefix}return 0>i?input:void 0},pushInput:function(input){var index=this.historyBuffer.indexOf(input);index>-1&&this.historyBuffer.splice(index,1);input.length&&this.historyBuffer.push(input)},reset:function(){this.initialPrefix=null;this.iterator=this.historyBuffer.length}};var commandDispatcher={matchCommand:function(keys,keyMap,inputState,context){var matches=commandMatches(keys,keyMap,context,inputState);if(!matches.full&&!matches.partial)return{type:"none"};if(!matches.full&&matches.partial)return{type:"partial"};for(var bestMatch,i=0;i<matches.full.length;i++){var match=matches.full[i];bestMatch||(bestMatch=match)}"<character>"==bestMatch.keys.slice(-11)&&(inputState.selectedCharacter=lastChar(keys));return{type:"full",command:bestMatch}},processCommand:function(cm,vim,command){vim.inputState.repeatOverride=command.repeatOverride;switch(command.type){case"motion":this.processMotion(cm,vim,command);break;case"operator":this.processOperator(cm,vim,command);break;case"operatorMotion":this.processOperatorMotion(cm,vim,command);break;case"action":this.processAction(cm,vim,command);break;case"search":this.processSearch(cm,vim,command);break;case"ex":case"keyToEx":this.processEx(cm,vim,command)}},processMotion:function(cm,vim,command){vim.inputState.motion=command.motion;vim.inputState.motionArgs=copyArgs(command.motionArgs);this.evalInput(cm,vim)},processOperator:function(cm,vim,command){var inputState=vim.inputState;if(inputState.operator){if(inputState.operator==command.operator){inputState.motion="expandToLine";inputState.motionArgs={linewise:!0};this.evalInput(cm,vim);return}clearInputState(cm)}inputState.operator=command.operator;inputState.operatorArgs=copyArgs(command.operatorArgs);vim.visualMode&&this.evalInput(cm,vim)},processOperatorMotion:function(cm,vim,command){var visualMode=vim.visualMode,operatorMotionArgs=copyArgs(command.operatorMotionArgs);operatorMotionArgs&&visualMode&&operatorMotionArgs.visualLine&&(vim.visualLine=!0);this.processOperator(cm,vim,command);visualMode||this.processMotion(cm,vim,command)},processAction:function(cm,vim,command){var inputState=vim.inputState,repeat=inputState.getRepeat(),repeatIsExplicit=!!repeat,actionArgs=copyArgs(command.actionArgs)||{};inputState.selectedCharacter&&(actionArgs.selectedCharacter=inputState.selectedCharacter);command.operator&&this.processOperator(cm,vim,command);command.motion&&this.processMotion(cm,vim,command);(command.motion||command.operator)&&this.evalInput(cm,vim);actionArgs.repeat=repeat||1;actionArgs.repeatIsExplicit=repeatIsExplicit;actionArgs.registerName=inputState.registerName;clearInputState(cm);vim.lastMotion=null;command.isEdit&&this.recordLastEdit(vim,inputState,command);actions[command.action](cm,actionArgs,vim)},processSearch:function(cm,vim,command){function handleQuery(query,ignoreCase,smartCase){vimGlobalState.searchHistoryController.pushInput(query);vimGlobalState.searchHistoryController.reset();try{updateSearchQuery(cm,query,ignoreCase,smartCase)}catch(e){showConfirm(cm,"Invalid regex: "+query);clearInputState(cm);return}commandDispatcher.processMotion(cm,vim,{type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:command.searchArgs.toJumplist}})}function onPromptClose(query){cm.scrollTo(originalScrollPos.left,originalScrollPos.top);handleQuery(query,!0,!0);var macroModeState=vimGlobalState.macroModeState;macroModeState.isRecording&&logSearchQuery(macroModeState,query)}function onPromptKeyUp(e,query,close){var up,keyName=CodeMirror.keyName(e);if("Up"==keyName||"Down"==keyName){up="Up"==keyName?!0:!1;query=vimGlobalState.searchHistoryController.nextMatch(query,up)||"";close(query)}else"Left"!=keyName&&"Right"!=keyName&&"Ctrl"!=keyName&&"Alt"!=keyName&&"Shift"!=keyName&&vimGlobalState.searchHistoryController.reset();var parsedQuery;try{parsedQuery=updateSearchQuery(cm,query,!0,!0)}catch(e){}if(parsedQuery)cm.scrollIntoView(findNext(cm,!forward,parsedQuery),30);else{clearSearchHighlight(cm);cm.scrollTo(originalScrollPos.left,originalScrollPos.top)}}function onPromptKeyDown(e,query,close){var keyName=CodeMirror.keyName(e);if("Esc"==keyName||"Ctrl-C"==keyName||"Ctrl-["==keyName||"Backspace"==keyName&&""==query){vimGlobalState.searchHistoryController.pushInput(query);vimGlobalState.searchHistoryController.reset();updateSearchQuery(cm,originalQuery);clearSearchHighlight(cm);cm.scrollTo(originalScrollPos.left,originalScrollPos.top);CodeMirror.e_stop(e);clearInputState(cm);close();cm.focus()}else if("Ctrl-U"==keyName){CodeMirror.e_stop(e);close("")}}if(cm.getSearchCursor){var forward=command.searchArgs.forward,wholeWordOnly=command.searchArgs.wholeWordOnly;getSearchState(cm).setReversed(!forward);var promptPrefix=forward?"/":"?",originalQuery=getSearchState(cm).getQuery(),originalScrollPos=cm.getScrollInfo();switch(command.searchArgs.querySrc){case"prompt":var macroModeState=vimGlobalState.macroModeState;if(macroModeState.isPlaying){var query=macroModeState.replaySearchQueries.shift();handleQuery(query,!0,!1)}else showPrompt(cm,{onClose:onPromptClose,prefix:promptPrefix,desc:searchPromptDesc,onKeyUp:onPromptKeyUp,onKeyDown:onPromptKeyDown});break;case"wordUnderCursor":var word=expandWordUnderCursor(cm,!1,!0,!1,!0),isKeyword=!0;if(!word){word=expandWordUnderCursor(cm,!1,!0,!1,!1);isKeyword=!1}if(!word)return;var query=cm.getLine(word.start.line).substring(word.start.ch,word.end.ch);query=isKeyword&&wholeWordOnly?"\\b"+query+"\\b":escapeRegex(query);vimGlobalState.jumpList.cachedCursor=cm.getCursor();cm.setCursor(word.start);handleQuery(query,!0,!1)}}},processEx:function(cm,vim,command){function onPromptClose(input){vimGlobalState.exCommandHistoryController.pushInput(input);vimGlobalState.exCommandHistoryController.reset();exCommandDispatcher.processCommand(cm,input)}function onPromptKeyDown(e,input,close){var up,keyName=CodeMirror.keyName(e);
3
+ if("Esc"==keyName||"Ctrl-C"==keyName||"Ctrl-["==keyName||"Backspace"==keyName&&""==input){vimGlobalState.exCommandHistoryController.pushInput(input);vimGlobalState.exCommandHistoryController.reset();CodeMirror.e_stop(e);clearInputState(cm);close();cm.focus()}if("Up"==keyName||"Down"==keyName){up="Up"==keyName?!0:!1;input=vimGlobalState.exCommandHistoryController.nextMatch(input,up)||"";close(input)}else if("Ctrl-U"==keyName){CodeMirror.e_stop(e);close("")}else"Left"!=keyName&&"Right"!=keyName&&"Ctrl"!=keyName&&"Alt"!=keyName&&"Shift"!=keyName&&vimGlobalState.exCommandHistoryController.reset()}"keyToEx"==command.type?exCommandDispatcher.processCommand(cm,command.exArgs.input):vim.visualMode?showPrompt(cm,{onClose:onPromptClose,prefix:":",value:"'<,'>",onKeyDown:onPromptKeyDown}):showPrompt(cm,{onClose:onPromptClose,prefix:":",onKeyDown:onPromptKeyDown})},evalInput:function(cm,vim){var newHead,newAnchor,repeat,inputState=vim.inputState,motion=inputState.motion,motionArgs=inputState.motionArgs||{},operator=inputState.operator,operatorArgs=inputState.operatorArgs||{},registerName=inputState.registerName,sel=vim.sel,origHead=copyCursor(vim.visualMode?clipCursorToContent(cm,sel.head):cm.getCursor("head")),origAnchor=copyCursor(vim.visualMode?clipCursorToContent(cm,sel.anchor):cm.getCursor("anchor")),oldHead=copyCursor(origHead),oldAnchor=copyCursor(origAnchor);operator&&this.recordLastEdit(vim,inputState);repeat=void 0!==inputState.repeatOverride?inputState.repeatOverride:inputState.getRepeat();if(repeat>0&&motionArgs.explicitRepeat)motionArgs.repeatIsExplicit=!0;else if(motionArgs.noRepeat||!motionArgs.explicitRepeat&&0===repeat){repeat=1;motionArgs.repeatIsExplicit=!1}inputState.selectedCharacter&&(motionArgs.selectedCharacter=operatorArgs.selectedCharacter=inputState.selectedCharacter);motionArgs.repeat=repeat;clearInputState(cm);if(motion){var motionResult=motions[motion](cm,origHead,motionArgs,vim);vim.lastMotion=motions[motion];if(!motionResult)return;if(motionArgs.toJumplist){var jumpList=vimGlobalState.jumpList,cachedCursor=jumpList.cachedCursor;if(cachedCursor){recordJumpPosition(cm,cachedCursor,motionResult);delete jumpList.cachedCursor}else recordJumpPosition(cm,origHead,motionResult)}if(motionResult instanceof Array){newAnchor=motionResult[0];newHead=motionResult[1]}else newHead=motionResult;newHead||(newHead=copyCursor(origHead));if(vim.visualMode){vim.visualBlock&&newHead.ch===1/0||(newHead=clipCursorToContent(cm,newHead,vim.visualBlock));newAnchor&&(newAnchor=clipCursorToContent(cm,newAnchor,!0));newAnchor=newAnchor||oldAnchor;sel.anchor=newAnchor;sel.head=newHead;updateCmSelection(cm);updateMark(cm,vim,"<",cursorIsBefore(newAnchor,newHead)?newAnchor:newHead);updateMark(cm,vim,">",cursorIsBefore(newAnchor,newHead)?newHead:newAnchor)}else if(!operator){newHead=clipCursorToContent(cm,newHead);cm.setCursor(newHead.line,newHead.ch)}}if(operator){if(operatorArgs.lastSel){newAnchor=oldAnchor;var lastSel=operatorArgs.lastSel,lineOffset=Math.abs(lastSel.head.line-lastSel.anchor.line),chOffset=Math.abs(lastSel.head.ch-lastSel.anchor.ch);newHead=lastSel.visualLine?Pos(oldAnchor.line+lineOffset,oldAnchor.ch):lastSel.visualBlock?Pos(oldAnchor.line+lineOffset,oldAnchor.ch+chOffset):lastSel.head.line==lastSel.anchor.line?Pos(oldAnchor.line,oldAnchor.ch+chOffset):Pos(oldAnchor.line+lineOffset,oldAnchor.ch);vim.visualMode=!0;vim.visualLine=lastSel.visualLine;vim.visualBlock=lastSel.visualBlock;sel=vim.sel={anchor:newAnchor,head:newHead};updateCmSelection(cm)}else vim.visualMode&&(operatorArgs.lastSel={anchor:copyCursor(sel.anchor),head:copyCursor(sel.head),visualBlock:vim.visualBlock,visualLine:vim.visualLine});var curStart,curEnd,linewise,mode,cmSel;if(vim.visualMode){curStart=cursorMin(sel.head,sel.anchor);curEnd=cursorMax(sel.head,sel.anchor);linewise=vim.visualLine||operatorArgs.linewise;mode=vim.visualBlock?"block":linewise?"line":"char";cmSel=makeCmSelection(cm,{anchor:curStart,head:curEnd},mode);if(linewise){var ranges=cmSel.ranges;if("block"==mode)for(var i=0;i<ranges.length;i++)ranges[i].head.ch=lineLength(cm,ranges[i].head.line);else"line"==mode&&(ranges[0].head=Pos(ranges[0].head.line+1,0))}}else{curStart=copyCursor(newAnchor||oldAnchor);curEnd=copyCursor(newHead||oldHead);if(cursorIsBefore(curEnd,curStart)){var tmp=curStart;curStart=curEnd;curEnd=tmp}linewise=motionArgs.linewise||operatorArgs.linewise;linewise?expandSelectionToLine(cm,curStart,curEnd):motionArgs.forward&&clipToLine(cm,curStart,curEnd);mode="char";var exclusive=!motionArgs.inclusive||linewise;cmSel=makeCmSelection(cm,{anchor:curStart,head:curEnd},mode,exclusive)}cm.setSelections(cmSel.ranges,cmSel.primary);vim.lastMotion=null;operatorArgs.repeat=repeat;operatorArgs.registerName=registerName;operatorArgs.linewise=linewise;var operatorMoveTo=operators[operator](cm,operatorArgs,cmSel.ranges,oldAnchor,newHead);vim.visualMode&&exitVisualMode(cm,null!=operatorMoveTo);operatorMoveTo&&cm.setCursor(operatorMoveTo)}},recordLastEdit:function(vim,inputState,actionCommand){var macroModeState=vimGlobalState.macroModeState;if(!macroModeState.isPlaying){vim.lastEditInputState=inputState;vim.lastEditActionCommand=actionCommand;macroModeState.lastInsertModeChanges.changes=[];macroModeState.lastInsertModeChanges.expectCursorActivityForChange=!1}}},motions={moveToTopLine:function(cm,_head,motionArgs){var line=getUserVisibleLines(cm).top+motionArgs.repeat-1;return Pos(line,findFirstNonWhiteSpaceCharacter(cm.getLine(line)))},moveToMiddleLine:function(cm){var range=getUserVisibleLines(cm),line=Math.floor(.5*(range.top+range.bottom));return Pos(line,findFirstNonWhiteSpaceCharacter(cm.getLine(line)))},moveToBottomLine:function(cm,_head,motionArgs){var line=getUserVisibleLines(cm).bottom-motionArgs.repeat+1;return Pos(line,findFirstNonWhiteSpaceCharacter(cm.getLine(line)))},expandToLine:function(_cm,head,motionArgs){var cur=head;return Pos(cur.line+motionArgs.repeat-1,1/0)},findNext:function(cm,_head,motionArgs){var state=getSearchState(cm),query=state.getQuery();if(query){var prev=!motionArgs.forward;prev=state.isReversed()?!prev:prev;highlightSearchMatches(cm,query);return findNext(cm,prev,query,motionArgs.repeat)}},goToMark:function(cm,_head,motionArgs,vim){var mark=vim.marks[motionArgs.selectedCharacter];if(mark){var pos=mark.find();return motionArgs.linewise?{line:pos.line,ch:findFirstNonWhiteSpaceCharacter(cm.getLine(pos.line))}:pos}return null},moveToOtherHighlightedEnd:function(cm,_head,motionArgs,vim){if(vim.visualBlock&&motionArgs.sameLine){var sel=vim.sel;return[clipCursorToContent(cm,Pos(sel.anchor.line,sel.head.ch)),clipCursorToContent(cm,Pos(sel.head.line,sel.anchor.ch))]}return[vim.sel.head,vim.sel.anchor]},jumpToMark:function(cm,head,motionArgs,vim){for(var best=head,i=0;i<motionArgs.repeat;i++){var cursor=best;for(var key in vim.marks)if(isLowerCase(key)){var mark=vim.marks[key].find(),isWrongDirection=motionArgs.forward?cursorIsBefore(mark,cursor):cursorIsBefore(cursor,mark);if(!(isWrongDirection||motionArgs.linewise&&mark.line==cursor.line)){var equal=cursorEqual(cursor,best),between=motionArgs.forward?cursorIsBetween(cursor,mark,best):cursorIsBetween(best,mark,cursor);(equal||between)&&(best=mark)}}}motionArgs.linewise&&(best=Pos(best.line,findFirstNonWhiteSpaceCharacter(cm.getLine(best.line))));return best},moveByCharacters:function(_cm,head,motionArgs){var cur=head,repeat=motionArgs.repeat,ch=motionArgs.forward?cur.ch+repeat:cur.ch-repeat;return Pos(cur.line,ch)},moveByLines:function(cm,head,motionArgs,vim){var cur=head,endCh=cur.ch;switch(vim.lastMotion){case this.moveByLines:case this.moveByDisplayLines:case this.moveByScroll:case this.moveToColumn:case this.moveToEol:endCh=vim.lastHPos;break;default:vim.lastHPos=endCh}var repeat=motionArgs.repeat+(motionArgs.repeatOffset||0),line=motionArgs.forward?cur.line+repeat:cur.line-repeat,first=cm.firstLine(),last=cm.lastLine();if(first>line&&cur.line==first)return this.moveToStartOfLine(cm,head,motionArgs,vim);if(line>last&&cur.line==last)return this.moveToEol(cm,head,motionArgs,vim);if(motionArgs.toFirstChar){endCh=findFirstNonWhiteSpaceCharacter(cm.getLine(line));vim.lastHPos=endCh}vim.lastHSPos=cm.charCoords(Pos(line,endCh),"div").left;return Pos(line,endCh)},moveByDisplayLines:function(cm,head,motionArgs,vim){var cur=head;switch(vim.lastMotion){case this.moveByDisplayLines:case this.moveByScroll:case this.moveByLines:case this.moveToColumn:case this.moveToEol:break;default:vim.lastHSPos=cm.charCoords(cur,"div").left}var repeat=motionArgs.repeat,res=cm.findPosV(cur,motionArgs.forward?repeat:-repeat,"line",vim.lastHSPos);if(res.hitSide)if(motionArgs.forward)var lastCharCoords=cm.charCoords(res,"div"),goalCoords={top:lastCharCoords.top+8,left:vim.lastHSPos},res=cm.coordsChar(goalCoords,"div");else{var resCoords=cm.charCoords(Pos(cm.firstLine(),0),"div");resCoords.left=vim.lastHSPos;res=cm.coordsChar(resCoords,"div")}vim.lastHPos=res.ch;return res},moveByPage:function(cm,head,motionArgs){var curStart=head,repeat=motionArgs.repeat;return cm.findPosV(curStart,motionArgs.forward?repeat:-repeat,"page")},moveByParagraph:function(cm,head,motionArgs){var dir=motionArgs.forward?1:-1;return findParagraph(cm,head,motionArgs.repeat,dir)},moveByScroll:function(cm,head,motionArgs,vim){var scrollbox=cm.getScrollInfo(),curEnd=null,repeat=motionArgs.repeat;repeat||(repeat=scrollbox.clientHeight/(2*cm.defaultTextHeight()));var orig=cm.charCoords(head,"local");motionArgs.repeat=repeat;var curEnd=motions.moveByDisplayLines(cm,head,motionArgs,vim);if(!curEnd)return null;var dest=cm.charCoords(curEnd,"local");cm.scrollTo(null,scrollbox.top+dest.top-orig.top);return curEnd},moveByWords:function(cm,head,motionArgs){return moveToWord(cm,head,motionArgs.repeat,!!motionArgs.forward,!!motionArgs.wordEnd,!!motionArgs.bigWord)},moveTillCharacter:function(cm,_head,motionArgs){var repeat=motionArgs.repeat,curEnd=moveToCharacter(cm,repeat,motionArgs.forward,motionArgs.selectedCharacter),increment=motionArgs.forward?-1:1;recordLastCharacterSearch(increment,motionArgs);if(!curEnd)return null;curEnd.ch+=increment;return curEnd},moveToCharacter:function(cm,head,motionArgs){var repeat=motionArgs.repeat;recordLastCharacterSearch(0,motionArgs);return moveToCharacter(cm,repeat,motionArgs.forward,motionArgs.selectedCharacter)||head},moveToSymbol:function(cm,head,motionArgs){var repeat=motionArgs.repeat;return findSymbol(cm,repeat,motionArgs.forward,motionArgs.selectedCharacter)||head},moveToColumn:function(cm,head,motionArgs,vim){var repeat=motionArgs.repeat;vim.lastHPos=repeat-1;vim.lastHSPos=cm.charCoords(head,"div").left;return moveToColumn(cm,repeat)},moveToEol:function(cm,head,motionArgs,vim){var cur=head;vim.lastHPos=1/0;var retval=Pos(cur.line+motionArgs.repeat-1,1/0),end=cm.clipPos(retval);end.ch--;vim.lastHSPos=cm.charCoords(end,"div").left;return retval},moveToFirstNonWhiteSpaceCharacter:function(cm,head){var cursor=head;return Pos(cursor.line,findFirstNonWhiteSpaceCharacter(cm.getLine(cursor.line)))},moveToMatchedSymbol:function(cm,head){var symbol,cursor=head,line=cursor.line,ch=cursor.ch,lineText=cm.getLine(line);do{symbol=lineText.charAt(ch++);if(symbol&&isMatchableSymbol(symbol)){var style=cm.getTokenTypeAt(Pos(line,ch));if("string"!==style&&"comment"!==style)break}}while(symbol);if(symbol){var matched=cm.findMatchingBracket(Pos(line,ch));return matched.to}return cursor},moveToStartOfLine:function(_cm,head){return Pos(head.line,0)},moveToLineOrEdgeOfDocument:function(cm,_head,motionArgs){var lineNum=motionArgs.forward?cm.lastLine():cm.firstLine();motionArgs.repeatIsExplicit&&(lineNum=motionArgs.repeat-cm.getOption("firstLineNumber"));return Pos(lineNum,findFirstNonWhiteSpaceCharacter(cm.getLine(lineNum)))},textObjectManipulation:function(cm,head,motionArgs,vim){var mirroredPairs={"(":")",")":"(","{":"}","}":"{","[":"]","]":"["},selfPaired={"'":!0,'"':!0},character=motionArgs.selectedCharacter;"b"==character?character="(":"B"==character&&(character="{");var tmp,inclusive=!motionArgs.textObjectInner;if(mirroredPairs[character])tmp=selectCompanionObject(cm,head,character,inclusive);else if(selfPaired[character])tmp=findBeginningAndEnd(cm,head,character,inclusive);else if("W"===character)tmp=expandWordUnderCursor(cm,inclusive,!0,!0);else if("w"===character)tmp=expandWordUnderCursor(cm,inclusive,!0,!1);else{if("p"!==character)return null;tmp=findParagraph(cm,head,motionArgs.repeat,0,inclusive);motionArgs.linewise=!0;if(vim.visualMode)vim.visualLine||(vim.visualLine=!0);else{var operatorArgs=vim.inputState.operatorArgs;operatorArgs&&(operatorArgs.linewise=!0);tmp.end.line--}}return cm.state.vim.visualMode?expandSelection(cm,tmp.start,tmp.end):[tmp.start,tmp.end]},repeatLastCharacterSearch:function(cm,head,motionArgs){var lastSearch=vimGlobalState.lastCharacterSearch,repeat=motionArgs.repeat,forward=motionArgs.forward===lastSearch.forward,increment=(lastSearch.increment?1:0)*(forward?-1:1);cm.moveH(-increment,"char");motionArgs.inclusive=forward?!0:!1;var curEnd=moveToCharacter(cm,repeat,forward,lastSearch.selectedCharacter);if(!curEnd){cm.moveH(increment,"char");return head}curEnd.ch+=increment;return curEnd}},operators={change:function(cm,args,ranges){var finalHead,text,vim=cm.state.vim;vimGlobalState.macroModeState.lastInsertModeChanges.inVisualBlock=vim.visualBlock;if(vim.visualMode){text=cm.getSelection();var replacement=fillArray("",ranges.length);cm.replaceSelections(replacement);finalHead=cursorMin(ranges[0].head,ranges[0].anchor)}else{var anchor=ranges[0].anchor,head=ranges[0].head;text=cm.getRange(anchor,head);var lastState=vim.lastEditInputState||{};if("moveByWords"==lastState.motion&&!isWhiteSpaceString(text)){var match=/\s+$/.exec(text);if(match&&lastState.motionArgs&&lastState.motionArgs.forward){head=offsetCursor(head,0,-match[0].length);text=text.slice(0,-match[0].length)}}var prevLineEnd=new Pos(anchor.line-1,Number.MAX_VALUE),wasLastLine=cm.firstLine()==cm.lastLine();head.line>cm.lastLine()&&args.linewise&&!wasLastLine?cm.replaceRange("",prevLineEnd,head):cm.replaceRange("",anchor,head);if(args.linewise){if(!wasLastLine){cm.setCursor(prevLineEnd);CodeMirror.commands.newlineAndIndent(cm)}anchor.ch=Number.MAX_VALUE}finalHead=anchor}vimGlobalState.registerController.pushText(args.registerName,"change",text,args.linewise,ranges.length>1);actions.enterInsertMode(cm,{head:finalHead},cm.state.vim)},"delete":function(cm,args,ranges){var finalHead,text,vim=cm.state.vim;if(vim.visualBlock){text=cm.getSelection();var replacement=fillArray("",ranges.length);cm.replaceSelections(replacement);finalHead=ranges[0].anchor}else{var anchor=ranges[0].anchor,head=ranges[0].head;args.linewise&&head.line!=cm.firstLine()&&anchor.line==cm.lastLine()&&anchor.line==head.line-1&&(anchor.line==cm.firstLine()?anchor.ch=0:anchor=Pos(anchor.line-1,lineLength(cm,anchor.line-1)));text=cm.getRange(anchor,head);cm.replaceRange("",anchor,head);finalHead=anchor;args.linewise&&(finalHead=motions.moveToFirstNonWhiteSpaceCharacter(cm,anchor))}vimGlobalState.registerController.pushText(args.registerName,"delete",text,args.linewise,vim.visualBlock);return clipCursorToContent(cm,finalHead)},indent:function(cm,args,ranges){var vim=cm.state.vim,startLine=ranges[0].anchor.line,endLine=vim.visualBlock?ranges[ranges.length-1].anchor.line:ranges[0].head.line,repeat=vim.visualMode?args.repeat:1;args.linewise&&endLine--;for(var i=startLine;endLine>=i;i++)for(var j=0;repeat>j;j++)cm.indentLine(i,args.indentRight);return motions.moveToFirstNonWhiteSpaceCharacter(cm,ranges[0].anchor)},changeCase:function(cm,args,ranges,oldAnchor,newHead){for(var selections=cm.getSelections(),swapped=[],toLower=args.toLower,j=0;j<selections.length;j++){var toSwap=selections[j],text="";if(toLower===!0)text=toSwap.toLowerCase();else if(toLower===!1)text=toSwap.toUpperCase();else for(var i=0;i<toSwap.length;i++){var character=toSwap.charAt(i);text+=isUpperCase(character)?character.toLowerCase():character.toUpperCase()}swapped.push(text)}cm.replaceSelections(swapped);return args.shouldMoveCursor?newHead:!cm.state.vim.visualMode&&args.linewise&&ranges[0].anchor.line+1==ranges[0].head.line?motions.moveToFirstNonWhiteSpaceCharacter(cm,oldAnchor):args.linewise?oldAnchor:cursorMin(ranges[0].anchor,ranges[0].head)},yank:function(cm,args,ranges,oldAnchor){var vim=cm.state.vim,text=cm.getSelection(),endPos=vim.visualMode?cursorMin(vim.sel.anchor,vim.sel.head,ranges[0].head,ranges[0].anchor):oldAnchor;vimGlobalState.registerController.pushText(args.registerName,"yank",text,args.linewise,vim.visualBlock);return endPos}},actions={jumpListWalk:function(cm,actionArgs,vim){if(!vim.visualMode){var repeat=actionArgs.repeat,forward=actionArgs.forward,jumpList=vimGlobalState.jumpList,mark=jumpList.move(cm,forward?repeat:-repeat),markPos=mark?mark.find():void 0;markPos=markPos?markPos:cm.getCursor();cm.setCursor(markPos)}},scroll:function(cm,actionArgs,vim){if(!vim.visualMode){var repeat=actionArgs.repeat||1,lineHeight=cm.defaultTextHeight(),top=cm.getScrollInfo().top,delta=lineHeight*repeat,newPos=actionArgs.forward?top+delta:top-delta,cursor=copyCursor(cm.getCursor()),cursorCoords=cm.charCoords(cursor,"local");if(actionArgs.forward)if(newPos>cursorCoords.top){cursor.line+=(newPos-cursorCoords.top)/lineHeight;cursor.line=Math.ceil(cursor.line);cm.setCursor(cursor);cursorCoords=cm.charCoords(cursor,"local");cm.scrollTo(null,cursorCoords.top)}else cm.scrollTo(null,newPos);else{var newBottom=newPos+cm.getScrollInfo().clientHeight;if(newBottom<cursorCoords.bottom){cursor.line-=(cursorCoords.bottom-newBottom)/lineHeight;cursor.line=Math.floor(cursor.line);cm.setCursor(cursor);cursorCoords=cm.charCoords(cursor,"local");cm.scrollTo(null,cursorCoords.bottom-cm.getScrollInfo().clientHeight)}else cm.scrollTo(null,newPos)}}},scrollToCursor:function(cm,actionArgs){var lineNum=cm.getCursor().line,charCoords=cm.charCoords(Pos(lineNum,0),"local"),height=cm.getScrollInfo().clientHeight,y=charCoords.top,lineHeight=charCoords.bottom-y;switch(actionArgs.position){case"center":y=y-height/2+lineHeight;break;case"bottom":y=y-height+lineHeight}cm.scrollTo(null,y)},replayMacro:function(cm,actionArgs,vim){var registerName=actionArgs.selectedCharacter,repeat=actionArgs.repeat,macroModeState=vimGlobalState.macroModeState;"@"==registerName&&(registerName=macroModeState.latestRegister);for(;repeat--;)executeMacroRegister(cm,vim,macroModeState,registerName)},enterMacroRecordMode:function(cm,actionArgs){var macroModeState=vimGlobalState.macroModeState,registerName=actionArgs.selectedCharacter;macroModeState.enterMacroRecordMode(cm,registerName)},enterInsertMode:function(cm,actionArgs,vim){if(!cm.getOption("readOnly")){vim.insertMode=!0;vim.insertModeRepeat=actionArgs&&actionArgs.repeat||1;var insertAt=actionArgs?actionArgs.insertAt:null,sel=vim.sel,head=actionArgs.head||cm.getCursor("head"),height=cm.listSelections().length;if("eol"==insertAt)head=Pos(head.line,lineLength(cm,head.line));else if("charAfter"==insertAt)head=offsetCursor(head,0,1);else if("firstNonBlank"==insertAt)head=motions.moveToFirstNonWhiteSpaceCharacter(cm,head);else if("startOfSelectedArea"==insertAt)if(vim.visualBlock){head=Pos(Math.min(sel.head.line,sel.anchor.line),Math.min(sel.head.ch,sel.anchor.ch));height=Math.abs(sel.head.line-sel.anchor.line)+1}else head=sel.head.line<sel.anchor.line?sel.head:Pos(sel.anchor.line,0);else if("endOfSelectedArea"==insertAt)if(vim.visualBlock){head=Pos(Math.min(sel.head.line,sel.anchor.line),Math.max(sel.head.ch+1,sel.anchor.ch));height=Math.abs(sel.head.line-sel.anchor.line)+1}else head=sel.head.line>=sel.anchor.line?offsetCursor(sel.head,0,1):Pos(sel.anchor.line,0);else if("inplace"==insertAt&&vim.visualMode)return;cm.setOption("keyMap","vim-insert");cm.setOption("disableInput",!1);if(actionArgs&&actionArgs.replace){cm.toggleOverwrite(!0);cm.setOption("keyMap","vim-replace");CodeMirror.signal(cm,"vim-mode-change",{mode:"replace"})}else{cm.setOption("keyMap","vim-insert");CodeMirror.signal(cm,"vim-mode-change",{mode:"insert"})}if(!vimGlobalState.macroModeState.isPlaying){cm.on("change",onChange);CodeMirror.on(cm.getInputField(),"keydown",onKeyEventTargetKeyDown)}vim.visualMode&&exitVisualMode(cm);selectForInsert(cm,head,height)}},toggleVisualMode:function(cm,actionArgs,vim){var head,repeat=actionArgs.repeat,anchor=cm.getCursor();if(vim.visualMode)if(vim.visualLine^actionArgs.linewise||vim.visualBlock^actionArgs.blockwise){vim.visualLine=!!actionArgs.linewise;vim.visualBlock=!!actionArgs.blockwise;CodeMirror.signal(cm,"vim-mode-change",{mode:"visual",subMode:vim.visualLine?"linewise":vim.visualBlock?"blockwise":""});updateCmSelection(cm)}else exitVisualMode(cm);else{vim.visualMode=!0;vim.visualLine=!!actionArgs.linewise;vim.visualBlock=!!actionArgs.blockwise;head=clipCursorToContent(cm,Pos(anchor.line,anchor.ch+repeat-1),!0);vim.sel={anchor:anchor,head:head};CodeMirror.signal(cm,"vim-mode-change",{mode:"visual",subMode:vim.visualLine?"linewise":vim.visualBlock?"blockwise":""});updateCmSelection(cm);updateMark(cm,vim,"<",cursorMin(anchor,head));updateMark(cm,vim,">",cursorMax(anchor,head))}},reselectLastSelection:function(cm,_actionArgs,vim){var lastSelection=vim.lastSelection;vim.visualMode&&updateLastSelection(cm,vim);if(lastSelection){var anchor=lastSelection.anchorMark.find(),head=lastSelection.headMark.find();if(!anchor||!head)return;vim.sel={anchor:anchor,head:head};vim.visualMode=!0;vim.visualLine=lastSelection.visualLine;vim.visualBlock=lastSelection.visualBlock;updateCmSelection(cm);updateMark(cm,vim,"<",cursorMin(anchor,head));updateMark(cm,vim,">",cursorMax(anchor,head));CodeMirror.signal(cm,"vim-mode-change",{mode:"visual",subMode:vim.visualLine?"linewise":vim.visualBlock?"blockwise":""})}},joinLines:function(cm,actionArgs,vim){var curStart,curEnd;if(vim.visualMode){curStart=cm.getCursor("anchor");curEnd=cm.getCursor("head");if(cursorIsBefore(curEnd,curStart)){var tmp=curEnd;curEnd=curStart;curStart=tmp}curEnd.ch=lineLength(cm,curEnd.line)-1}else{var repeat=Math.max(actionArgs.repeat,2);curStart=cm.getCursor();curEnd=clipCursorToContent(cm,Pos(curStart.line+repeat-1,1/0))}for(var finalCh=0,i=curStart.line;i<curEnd.line;i++){finalCh=lineLength(cm,curStart.line);var tmp=Pos(curStart.line+1,lineLength(cm,curStart.line+1)),text=cm.getRange(curStart,tmp);text=text.replace(/\n\s*/g," ");cm.replaceRange(text,curStart,tmp)}var curFinalPos=Pos(curStart.line,finalCh);vim.visualMode&&exitVisualMode(cm,!1);cm.setCursor(curFinalPos)},newLineAndEnterInsertMode:function(cm,actionArgs,vim){vim.insertMode=!0;var insertAt=copyCursor(cm.getCursor());if(insertAt.line!==cm.firstLine()||actionArgs.after){insertAt.line=actionArgs.after?insertAt.line:insertAt.line-1;insertAt.ch=lineLength(cm,insertAt.line);cm.setCursor(insertAt);var newlineFn=CodeMirror.commands.newlineAndIndentContinueComment||CodeMirror.commands.newlineAndIndent;newlineFn(cm)}else{cm.replaceRange("\n",Pos(cm.firstLine(),0));cm.setCursor(cm.firstLine(),0)}this.enterInsertMode(cm,{repeat:actionArgs.repeat},vim)},paste:function(cm,actionArgs,vim){var cur=copyCursor(cm.getCursor()),register=vimGlobalState.registerController.getRegister(actionArgs.registerName),text=register.toString();if(text){if(actionArgs.matchIndent){var tabSize=cm.getOption("tabSize"),whitespaceLength=function(str){var tabs=str.split(" ").length-1,spaces=str.split(" ").length-1;return tabs*tabSize+1*spaces},currentLine=cm.getLine(cm.getCursor().line),indent=whitespaceLength(currentLine.match(/^\s*/)[0]),chompedText=text.replace(/\n$/,""),wasChomped=text!==chompedText,firstIndent=whitespaceLength(text.match(/^\s*/)[0]),text=chompedText.replace(/^\s*/gm,function(wspace){var newIndent=indent+(whitespaceLength(wspace)-firstIndent);if(0>newIndent)return"";if(cm.getOption("indentWithTabs")){var quotient=Math.floor(newIndent/tabSize);return Array(quotient+1).join(" ")}return Array(newIndent+1).join(" ")});text+=wasChomped?"\n":""}if(actionArgs.repeat>1)var text=Array(actionArgs.repeat+1).join(text);var linewise=register.linewise,blockwise=register.blockwise;if(linewise)if(vim.visualMode)text=vim.visualLine?text.slice(0,-1):"\n"+text.slice(0,text.length-1)+"\n";else if(actionArgs.after){text="\n"+text.slice(0,text.length-1);cur.ch=lineLength(cm,cur.line)}else cur.ch=0;else{if(blockwise){text=text.split("\n");for(var i=0;i<text.length;i++)text[i]=""==text[i]?" ":text[i]}cur.ch+=actionArgs.after?1:0}var curPosFinal,idx;if(vim.visualMode){vim.lastPastedText=text;var lastSelectionCurEnd,selectedArea=getSelectedAreaRange(cm,vim),selectionStart=selectedArea[0],selectionEnd=selectedArea[1],selectedText=cm.getSelection(),selections=cm.listSelections(),emptyStrings=new Array(selections.length).join("1").split("1");vim.lastSelection&&(lastSelectionCurEnd=vim.lastSelection.headMark.find());vimGlobalState.registerController.unnamedRegister.setText(selectedText);if(blockwise){cm.replaceSelections(emptyStrings);selectionEnd=Pos(selectionStart.line+text.length-1,selectionStart.ch);cm.setCursor(selectionStart);selectBlock(cm,selectionEnd);cm.replaceSelections(text);curPosFinal=selectionStart}else if(vim.visualBlock){cm.replaceSelections(emptyStrings);cm.setCursor(selectionStart);cm.replaceRange(text,selectionStart,selectionStart);curPosFinal=selectionStart}else{cm.replaceRange(text,selectionStart,selectionEnd);curPosFinal=cm.posFromIndex(cm.indexFromPos(selectionStart)+text.length-1)}lastSelectionCurEnd&&(vim.lastSelection.headMark=cm.setBookmark(lastSelectionCurEnd));linewise&&(curPosFinal.ch=0)}else if(blockwise){cm.setCursor(cur);for(var i=0;i<text.length;i++){var line=cur.line+i;line>cm.lastLine()&&cm.replaceRange("\n",Pos(line,0));var lastCh=lineLength(cm,line);lastCh<cur.ch&&extendLineToColumn(cm,line,cur.ch)}cm.setCursor(cur);selectBlock(cm,Pos(cur.line+text.length-1,cur.ch));cm.replaceSelections(text);curPosFinal=cur}else{cm.replaceRange(text,cur);if(linewise&&actionArgs.after)curPosFinal=Pos(cur.line+1,findFirstNonWhiteSpaceCharacter(cm.getLine(cur.line+1)));else if(linewise&&!actionArgs.after)curPosFinal=Pos(cur.line,findFirstNonWhiteSpaceCharacter(cm.getLine(cur.line)));else if(!linewise&&actionArgs.after){idx=cm.indexFromPos(cur);curPosFinal=cm.posFromIndex(idx+text.length-1)}else{idx=cm.indexFromPos(cur);curPosFinal=cm.posFromIndex(idx+text.length)}}vim.visualMode&&exitVisualMode(cm,!1);cm.setCursor(curPosFinal)}},undo:function(cm,actionArgs){cm.operation(function(){repeatFn(cm,CodeMirror.commands.undo,actionArgs.repeat)();cm.setCursor(cm.getCursor("anchor"))})},redo:function(cm,actionArgs){repeatFn(cm,CodeMirror.commands.redo,actionArgs.repeat)()},setRegister:function(_cm,actionArgs,vim){vim.inputState.registerName=actionArgs.selectedCharacter},setMark:function(cm,actionArgs,vim){var markName=actionArgs.selectedCharacter;updateMark(cm,vim,markName,cm.getCursor())},replace:function(cm,actionArgs,vim){var replaceTo,curEnd,replaceWith=actionArgs.selectedCharacter,curStart=cm.getCursor(),selections=cm.listSelections();if(vim.visualMode){curStart=cm.getCursor("start");curEnd=cm.getCursor("end")}else{var line=cm.getLine(curStart.line);replaceTo=curStart.ch+actionArgs.repeat;replaceTo>line.length&&(replaceTo=line.length);curEnd=Pos(curStart.line,replaceTo)}if("\n"==replaceWith){vim.visualMode||cm.replaceRange("",curStart,curEnd);(CodeMirror.commands.newlineAndIndentContinueComment||CodeMirror.commands.newlineAndIndent)(cm)}else{var replaceWithStr=cm.getRange(curStart,curEnd);replaceWithStr=replaceWithStr.replace(/[^\n]/g,replaceWith);if(vim.visualBlock){var spaces=new Array(cm.getOption("tabSize")+1).join(" ");replaceWithStr=cm.getSelection();replaceWithStr=replaceWithStr.replace(/\t/g,spaces).replace(/[^\n]/g,replaceWith).split("\n");cm.replaceSelections(replaceWithStr)}else cm.replaceRange(replaceWithStr,curStart,curEnd);if(vim.visualMode){curStart=cursorIsBefore(selections[0].anchor,selections[0].head)?selections[0].anchor:selections[0].head;cm.setCursor(curStart);exitVisualMode(cm,!1)}else cm.setCursor(offsetCursor(curEnd,0,-1))}},incrementNumberToken:function(cm,actionArgs){for(var match,start,end,numberStr,token,cur=cm.getCursor(),lineStr=cm.getLine(cur.line),re=/-?\d+/g;null!==(match=re.exec(lineStr));){token=match[0];start=match.index;end=start+token.length;if(cur.ch<end)break}if((actionArgs.backtrack||!(end<=cur.ch))&&token){var increment=actionArgs.increase?1:-1,number=parseInt(token)+increment*actionArgs.repeat,from=Pos(cur.line,start),to=Pos(cur.line,end);numberStr=number.toString();cm.replaceRange(numberStr,from,to);cm.setCursor(Pos(cur.line,start+numberStr.length-1))}},repeatLastEdit:function(cm,actionArgs,vim){var lastEditInputState=vim.lastEditInputState;if(lastEditInputState){var repeat=actionArgs.repeat;repeat&&actionArgs.repeatIsExplicit?vim.lastEditInputState.repeatOverride=repeat:repeat=vim.lastEditInputState.repeatOverride||repeat;repeatLastEdit(cm,vim,repeat,!1)}},exitInsertMode:exitInsertMode},symbolToMode={"(":"bracket",")":"bracket","{":"bracket","}":"bracket","[":"section","]":"section","*":"comment","/":"comment",m:"method",M:"method","#":"preprocess"},findSymbolModes={bracket:{isComplete:function(state){if(state.nextCh===state.symb){state.depth++;if(state.depth>=1)return!0}else state.nextCh===state.reverseSymb&&state.depth--;return!1}},section:{init:function(state){state.curMoveThrough=!0;state.symb=(state.forward?"]":"[")===state.symb?"{":"}"},isComplete:function(state){return 0===state.index&&state.nextCh===state.symb}},comment:{isComplete:function(state){var found="*"===state.lastCh&&"/"===state.nextCh;state.lastCh=state.nextCh;return found}},method:{init:function(state){state.symb="m"===state.symb?"{":"}";state.reverseSymb="{"===state.symb?"}":"{"},isComplete:function(state){return state.nextCh===state.symb?!0:!1}},preprocess:{init:function(state){state.index=0},isComplete:function(state){if("#"===state.nextCh){var token=state.lineText.match(/#(\w+)/)[1];if("endif"===token){if(state.forward&&0===state.depth)return!0;state.depth++}else if("if"===token){if(!state.forward&&0===state.depth)return!0;state.depth--}if("else"===token&&0===state.depth)return!0}return!1}}};defineOption("pcre",!0,"boolean");SearchState.prototype={getQuery:function(){return vimGlobalState.query},setQuery:function(query){vimGlobalState.query=query},getOverlay:function(){return this.searchOverlay},setOverlay:function(overlay){this.searchOverlay=overlay},isReversed:function(){return vimGlobalState.isReversed},setReversed:function(reversed){vimGlobalState.isReversed=reversed},getScrollbarAnnotate:function(){return this.annotate},setScrollbarAnnotate:function(annotate){this.annotate=annotate}};var charUnescapes={"\\n":"\n","\\r":"\r","\\t":" "},unescapes={"\\/":"/","\\\\":"\\","\\n":"\n","\\r":"\r","\\t":" "},searchPromptDesc="(Javascript regexp)",ExCommandDispatcher=function(){this.buildCommandMap_()};ExCommandDispatcher.prototype={processCommand:function(cm,input,opt_params){var that=this;cm.operation(function(){cm.curOp.isVimOp=!0;that._processCommand(cm,input,opt_params)})},_processCommand:function(cm,input,opt_params){var vim=cm.state.vim,commandHistoryRegister=vimGlobalState.registerController.getRegister(":"),previousCommand=commandHistoryRegister.toString();vim.visualMode&&exitVisualMode(cm);var inputStream=new CodeMirror.StringStream(input);commandHistoryRegister.setText(input);var params=opt_params||{};params.input=input;try{this.parseInput_(cm,inputStream,params)}catch(e){showConfirm(cm,e);throw e}var command,commandName;if(params.commandName){command=this.matchCommand_(params.commandName);if(command){commandName=command.name;command.excludeFromCommandHistory&&commandHistoryRegister.setText(previousCommand);this.parseCommandArgs_(inputStream,params,command);if("exToKey"==command.type){for(var i=0;i<command.toKeys.length;i++)CodeMirror.Vim.handleKey(cm,command.toKeys[i],"mapping");return}if("exToEx"==command.type){this.processCommand(cm,command.toInput);return}}}else void 0!==params.line&&(commandName="move");if(commandName)try{exCommands[commandName](cm,params);command&&command.possiblyAsync||!params.callback||params.callback();
4
+ }catch(e){showConfirm(cm,e);throw e}else showConfirm(cm,'Not an editor command ":'+input+'"')},parseInput_:function(cm,inputStream,result){inputStream.eatWhile(":");if(inputStream.eat("%")){result.line=cm.firstLine();result.lineEnd=cm.lastLine()}else{result.line=this.parseLineSpec_(cm,inputStream);void 0!==result.line&&inputStream.eat(",")&&(result.lineEnd=this.parseLineSpec_(cm,inputStream))}var commandMatch=inputStream.match(/^(\w+)/);commandMatch?result.commandName=commandMatch[1]:result.commandName=inputStream.match(/.*/)[0];return result},parseLineSpec_:function(cm,inputStream){var numberMatch=inputStream.match(/^(\d+)/);if(numberMatch)return parseInt(numberMatch[1],10)-1;switch(inputStream.next()){case".":return cm.getCursor().line;case"$":return cm.lastLine();case"'":var mark=cm.state.vim.marks[inputStream.next()];if(mark&&mark.find())return mark.find().line;throw new Error("Mark not set");default:inputStream.backUp(1);return void 0}},parseCommandArgs_:function(inputStream,params,command){if(!inputStream.eol()){params.argString=inputStream.match(/.*/)[0];var delim=command.argDelimiter||/\s+/,args=trim(params.argString).split(delim);args.length&&args[0]&&(params.args=args)}},matchCommand_:function(commandName){for(var i=commandName.length;i>0;i--){var prefix=commandName.substring(0,i);if(this.commandMap_[prefix]){var command=this.commandMap_[prefix];if(0===command.name.indexOf(commandName))return command}}return null},buildCommandMap_:function(){this.commandMap_={};for(var i=0;i<defaultExCommandMap.length;i++){var command=defaultExCommandMap[i],key=command.shortName||command.name;this.commandMap_[key]=command}},map:function(lhs,rhs,ctx){if(":"!=lhs&&":"==lhs.charAt(0)){if(ctx)throw Error("Mode not supported for ex mappings");var commandName=lhs.substring(1);":"!=rhs&&":"==rhs.charAt(0)?this.commandMap_[commandName]={name:commandName,type:"exToEx",toInput:rhs.substring(1),user:!0}:this.commandMap_[commandName]={name:commandName,type:"exToKey",toKeys:rhs,user:!0}}else if(":"!=rhs&&":"==rhs.charAt(0)){var mapping={keys:lhs,type:"keyToEx",exArgs:{input:rhs.substring(1)},user:!0};ctx&&(mapping.context=ctx);defaultKeymap.unshift(mapping)}else{var mapping={keys:lhs,type:"keyToKey",toKeys:rhs,user:!0};ctx&&(mapping.context=ctx);defaultKeymap.unshift(mapping)}},unmap:function(lhs,ctx){if(":"!=lhs&&":"==lhs.charAt(0)){if(ctx)throw Error("Mode not supported for ex mappings");var commandName=lhs.substring(1);if(this.commandMap_[commandName]&&this.commandMap_[commandName].user){delete this.commandMap_[commandName];return}}else for(var keys=lhs,i=0;i<defaultKeymap.length;i++)if(keys==defaultKeymap[i].keys&&defaultKeymap[i].context===ctx&&defaultKeymap[i].user){defaultKeymap.splice(i,1);return}throw Error("No such mapping.")}};var exCommands={colorscheme:function(cm,params){!params.args||params.args.length<1?showConfirm(cm,cm.getOption("theme")):cm.setOption("theme",params.args[0])},map:function(cm,params,ctx){var mapArgs=params.args;!mapArgs||mapArgs.length<2?cm&&showConfirm(cm,"Invalid mapping: "+params.input):exCommandDispatcher.map(mapArgs[0],mapArgs[1],ctx)},imap:function(cm,params){this.map(cm,params,"insert")},nmap:function(cm,params){this.map(cm,params,"normal")},vmap:function(cm,params){this.map(cm,params,"visual")},unmap:function(cm,params,ctx){var mapArgs=params.args;!mapArgs||mapArgs.length<1?cm&&showConfirm(cm,"No such mapping: "+params.input):exCommandDispatcher.unmap(mapArgs[0],ctx)},move:function(cm,params){commandDispatcher.processCommand(cm,cm.state.vim,{type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0},repeatOverride:params.line+1})},set:function(cm,params){var setArgs=params.args,setCfg=params.setCfg||{};if(!setArgs||setArgs.length<1)cm&&showConfirm(cm,"Invalid mapping: "+params.input);else{var expr=setArgs[0].split("="),optionName=expr[0],value=expr[1],forceGet=!1;if("?"==optionName.charAt(optionName.length-1)){if(value)throw Error("Trailing characters: "+params.argString);optionName=optionName.substring(0,optionName.length-1);forceGet=!0}if(void 0===value&&"no"==optionName.substring(0,2)){optionName=optionName.substring(2);value=!1}var optionIsBoolean=options[optionName]&&"boolean"==options[optionName].type;optionIsBoolean&&void 0==value&&(value=!0);if(!optionIsBoolean&&void 0===value||forceGet){var oldValue=getOption(optionName,cm,setCfg);oldValue===!0||oldValue===!1?showConfirm(cm," "+(oldValue?"":"no")+optionName):showConfirm(cm," "+optionName+"="+oldValue)}else setOption(optionName,value,cm,setCfg)}},setlocal:function(cm,params){params.setCfg={scope:"local"};this.set(cm,params)},setglobal:function(cm,params){params.setCfg={scope:"global"};this.set(cm,params)},registers:function(cm,params){var regArgs=params.args,registers=vimGlobalState.registerController.registers,regInfo="----------Registers----------<br><br>";if(regArgs){var registerName;regArgs=regArgs.join("");for(var i=0;i<regArgs.length;i++){registerName=regArgs.charAt(i);if(vimGlobalState.registerController.isValidRegister(registerName)){var register=registers[registerName]||new Register;regInfo+='"'+registerName+" "+register.toString()+"<br>"}}}else for(var registerName in registers){var text=registers[registerName].toString();text.length&&(regInfo+='"'+registerName+" "+text+"<br>")}showConfirm(cm,regInfo)},sort:function(cm,params){function parseArgs(){if(params.argString){var args=new CodeMirror.StringStream(params.argString);args.eat("!")&&(reverse=!0);if(args.eol())return;if(!args.eatSpace())return"Invalid arguments";var opts=args.match(/[a-z]+/);if(opts){opts=opts[0];ignoreCase=-1!=opts.indexOf("i");unique=-1!=opts.indexOf("u");var decimal=-1!=opts.indexOf("d")&&1,hex=-1!=opts.indexOf("x")&&1,octal=-1!=opts.indexOf("o")&&1;if(decimal+hex+octal>1)return"Invalid arguments";number=decimal&&"decimal"||hex&&"hex"||octal&&"octal"}if(args.match(/\/.*\//))return"patterns not supported"}}function compareFn(a,b){if(reverse){var tmp;tmp=a;a=b;b=tmp}if(ignoreCase){a=a.toLowerCase();b=b.toLowerCase()}var anum=number&&numberRegex.exec(a),bnum=number&&numberRegex.exec(b);if(!anum)return b>a?-1:1;anum=parseInt((anum[1]+anum[2]).toLowerCase(),radix);bnum=parseInt((bnum[1]+bnum[2]).toLowerCase(),radix);return anum-bnum}var reverse,ignoreCase,unique,number,err=parseArgs();if(err)showConfirm(cm,err+": "+params.argString);else{var lineStart=params.line||cm.firstLine(),lineEnd=params.lineEnd||params.line||cm.lastLine();if(lineStart!=lineEnd){var curStart=Pos(lineStart,0),curEnd=Pos(lineEnd,lineLength(cm,lineEnd)),text=cm.getRange(curStart,curEnd).split("\n"),numberRegex="decimal"==number?/(-?)([\d]+)/:"hex"==number?/(-?)(?:0x)?([0-9a-f]+)/i:"octal"==number?/([0-7]+)/:null,radix="decimal"==number?10:"hex"==number?16:"octal"==number?8:null,numPart=[],textPart=[];if(number)for(var i=0;i<text.length;i++)numberRegex.exec(text[i])?numPart.push(text[i]):textPart.push(text[i]);else textPart=text;numPart.sort(compareFn);textPart.sort(compareFn);text=reverse?numPart.concat(textPart):textPart.concat(numPart);if(unique){var lastLine,textOld=text;text=[];for(var i=0;i<textOld.length;i++){textOld[i]!=lastLine&&text.push(textOld[i]);lastLine=textOld[i]}}cm.replaceRange(text.join("\n"),curStart,curEnd)}}},global:function(cm,params){var argString=params.argString;if(argString){var cmd,lineStart=void 0!==params.line?params.line:cm.firstLine(),lineEnd=params.lineEnd||params.line||cm.lastLine(),tokens=splitBySlash(argString),regexPart=argString;if(tokens.length){regexPart=tokens[0];cmd=tokens.slice(1,tokens.length).join("/")}if(regexPart)try{updateSearchQuery(cm,regexPart,!0,!0)}catch(e){showConfirm(cm,"Invalid regex: "+regexPart);return}for(var query=getSearchState(cm).getQuery(),matchedLines=[],content="",i=lineStart;lineEnd>=i;i++){var matched=query.test(cm.getLine(i));if(matched){matchedLines.push(i+1);content+=cm.getLine(i)+"<br>"}}if(cmd){var index=0,nextCommand=function(){if(index<matchedLines.length){var command=matchedLines[index]+cmd;exCommandDispatcher.processCommand(cm,command,{callback:nextCommand})}index++};nextCommand()}else showConfirm(cm,content)}else showConfirm(cm,"Regular Expression missing from global")},substitute:function(cm,params){if(!cm.getSearchCursor)throw new Error("Search feature not available. Requires searchcursor.js or any other getSearchCursor implementation.");var regexPart,trailing,flagsPart,count,argString=params.argString,tokens=argString?splitBySlash(argString):[],replacePart="",confirm=!1,global=!1;if(tokens.length){regexPart=tokens[0];replacePart=tokens[1];if(void 0!==replacePart){replacePart=getOption("pcre")?unescapeRegexReplace(replacePart):translateRegexReplace(replacePart);vimGlobalState.lastSubstituteReplacePart=replacePart}trailing=tokens[2]?tokens[2].split(" "):[]}else if(argString&&argString.length){showConfirm(cm,"Substitutions should be of the form :s/pattern/replace/");return}if(trailing){flagsPart=trailing[0];count=parseInt(trailing[1]);if(flagsPart){if(-1!=flagsPart.indexOf("c")){confirm=!0;flagsPart.replace("c","")}if(-1!=flagsPart.indexOf("g")){global=!0;flagsPart.replace("g","")}regexPart=regexPart+"/"+flagsPart}}if(regexPart)try{updateSearchQuery(cm,regexPart,!0,!0)}catch(e){showConfirm(cm,"Invalid regex: "+regexPart);return}replacePart=replacePart||vimGlobalState.lastSubstituteReplacePart;if(void 0!==replacePart){var state=getSearchState(cm),query=state.getQuery(),lineStart=void 0!==params.line?params.line:cm.getCursor().line,lineEnd=params.lineEnd||lineStart;lineStart==cm.firstLine()&&lineEnd==cm.lastLine()&&(lineEnd=1/0);if(count){lineStart=lineEnd;lineEnd=lineStart+count-1}var startPos=clipCursorToContent(cm,Pos(lineStart,0)),cursor=cm.getSearchCursor(query,startPos);doReplace(cm,confirm,global,lineStart,lineEnd,cursor,query,replacePart,params.callback)}else showConfirm(cm,"No previous substitute regular expression")},redo:CodeMirror.commands.redo,undo:CodeMirror.commands.undo,write:function(cm){CodeMirror.commands.save?CodeMirror.commands.save(cm):cm.save&&cm.save()},nohlsearch:function(cm){clearSearchHighlight(cm)},yank:function(cm){var cur=copyCursor(cm.getCursor()),line=cur.line,lineText=cm.getLine(line);vimGlobalState.registerController.pushText("0","yank",lineText,!0,!0)},delmarks:function(cm,params){if(params.argString&&trim(params.argString))for(var state=cm.state.vim,stream=new CodeMirror.StringStream(trim(params.argString));!stream.eol();){stream.eatSpace();var count=stream.pos;if(!stream.match(/[a-zA-Z]/,!1)){showConfirm(cm,"Invalid argument: "+params.argString.substring(count));return}var sym=stream.next();if(stream.match("-",!0)){if(!stream.match(/[a-zA-Z]/,!1)){showConfirm(cm,"Invalid argument: "+params.argString.substring(count));return}var startMark=sym,finishMark=stream.next();if(!(isLowerCase(startMark)&&isLowerCase(finishMark)||isUpperCase(startMark)&&isUpperCase(finishMark))){showConfirm(cm,"Invalid argument: "+startMark+"-");return}var start=startMark.charCodeAt(0),finish=finishMark.charCodeAt(0);if(start>=finish){showConfirm(cm,"Invalid argument: "+params.argString.substring(count));return}for(var j=0;finish-start>=j;j++){var mark=String.fromCharCode(start+j);delete state.marks[mark]}}else delete state.marks[sym]}else showConfirm(cm,"Argument required")}},exCommandDispatcher=new ExCommandDispatcher;CodeMirror.keyMap.vim={attach:attachVimMap,detach:detachVimMap,call:cmKey};defineOption("insertModeEscKeysTimeout",200,"number");CodeMirror.keyMap["vim-insert"]={"Ctrl-N":"autocomplete","Ctrl-P":"autocomplete",Enter:function(cm){var fn=CodeMirror.commands.newlineAndIndentContinueComment||CodeMirror.commands.newlineAndIndent;fn(cm)},fallthrough:["default"],attach:attachVimMap,detach:detachVimMap,call:cmKey};CodeMirror.keyMap["vim-replace"]={Backspace:"goCharLeft",fallthrough:["vim-insert"],attach:attachVimMap,detach:detachVimMap,call:cmKey};resetVimGlobalState();return vimApi};CodeMirror.Vim=Vim()});
js/esites_editor/dist/js/vendor/codemirror/lib/codemirror.css CHANGED
@@ -1 +1 @@
1
- .CodeMirror{font-family:monospace;height:300px;color:#000}.CodeMirror-lines{padding:4px 0}.CodeMirror pre{padding:0 4px}.CodeMirror-gutter-filler,.CodeMirror-scrollbar-filler{background-color:#fff}.CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;white-space:nowrap}.CodeMirror-guttermarker{color:#000}.CodeMirror-guttermarker-subtle{color:#999}.CodeMirror-cursor{border-left:1px solid #000;border-right:none;width:0}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.cm-fat-cursor .CodeMirror-cursor{width:auto;border:0;background:#7e7}.cm-fat-cursor div.CodeMirror-cursors{z-index:1}.cm-animate-fat-cursor{width:auto;border:0;-webkit-animation:blink 1.06s steps(1) infinite;-moz-animation:blink 1.06s steps(1) infinite;animation:blink 1.06s steps(1) infinite;background-color:#7e7}@-moz-keyframes blink{50%{background-color:transparent}}@-webkit-keyframes blink{50%{background-color:transparent}}@keyframes blink{50%{background-color:transparent}}.cm-tab{display:inline-block;text-decoration:inherit}.CodeMirror-ruler{border-left:1px solid #ccc;position:absolute}.cm-s-default .cm-header{color:#00f}.cm-s-default .cm-quote{color:#090}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:700}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-strikethrough{text-decoration:line-through}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta,.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-invalidchar,.cm-s-default .cm-error{color:red}.CodeMirror-composing{border-bottom:2px solid}div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}.CodeMirror-matchingtag{background:rgba(255,150,0,.3)}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{position:relative;overflow:hidden;background:#fff}.CodeMirror-scroll{overflow:scroll!important;margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;height:100%;outline:0;position:relative}.CodeMirror-sizer{position:relative;border-right:30px solid transparent}.CodeMirror-gutter-filler,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-vscrollbar{position:absolute;z-index:6;display:none}.CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom:0}.CodeMirror-gutters{position:absolute;left:0;top:0;z-index:3}.CodeMirror-gutter{white-space:normal;height:100%;display:inline-block;margin-bottom:-30px}.CodeMirror-gutter-wrapper{position:absolute;z-index:4;background:0 0!important;border:none!important}.CodeMirror-gutter-background{position:absolute;top:0;bottom:0;z-index:4}.CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.CodeMirror-gutter-wrapper{-webkit-user-select:none;-moz-user-select:none;user-select:none}.CodeMirror-lines{cursor:text;min-height:1px}.CodeMirror pre{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:0 0;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible;-webkit-tap-highlight-color:transparent}.CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.CodeMirror-linewidget{position:relative;z-index:2;overflow:auto}.CodeMirror-code{outline:0}.CodeMirror-gutter,.CodeMirror-gutters,.CodeMirror-linenumber,.CodeMirror-scroll,.CodeMirror-sizer{-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.CodeMirror-cursor{position:absolute}.CodeMirror-measure pre{position:static}div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:3}.CodeMirror-focused div.CodeMirror-cursors,div.CodeMirror-dragcursors{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.CodeMirror-crosshair{cursor:crosshair}.CodeMirror-line::selection,.CodeMirror-line>span::selection,.CodeMirror-line>span>span::selection{background:#d7d4f0}.CodeMirror-line::-moz-selection,.CodeMirror-line>span::-moz-selection,.CodeMirror-line>span>span::-moz-selection{background:#d7d4f0}.cm-searching{background:#ffa;background:rgba(255,255,0,.4)}.cm-force-border{padding-right:.1px}@media print{.CodeMirror div.CodeMirror-cursors{visibility:hidden}}.cm-tab-wrap-hack:after{content:''}span.CodeMirror-selectedtext{background:0 0}
1
+ .CodeMirror{font-family:monospace;height:300px;color:#000}.CodeMirror-lines{padding:4px 0}.CodeMirror pre{padding:0 4px}.CodeMirror-gutter-filler,.CodeMirror-scrollbar-filler{background-color:#fff}.CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;white-space:nowrap}.CodeMirror-guttermarker{color:#000}.CodeMirror-guttermarker-subtle{color:#999}.CodeMirror-cursor{border-left:1px solid #000;border-right:none;width:0}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.cm-fat-cursor .CodeMirror-cursor{width:auto;border:0;background:#7e7}.cm-fat-cursor div.CodeMirror-cursors{z-index:1}.cm-animate-fat-cursor{width:auto;border:0;-webkit-animation:blink 1.06s steps(1) infinite;-moz-animation:blink 1.06s steps(1) infinite;animation:blink 1.06s steps(1) infinite;background-color:#7e7}@-moz-keyframes blink{50%{background-color:transparent}}@-webkit-keyframes blink{50%{background-color:transparent}}@keyframes blink{50%{background-color:transparent}}.cm-tab{display:inline-block;text-decoration:inherit}.CodeMirror-ruler{border-left:1px solid #ccc;position:absolute}.cm-s-default .cm-header{color:#00f}.cm-s-default .cm-quote{color:#090}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:700}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-strikethrough{text-decoration:line-through}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta,.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-invalidchar,.cm-s-default .cm-error{color:red}.CodeMirror-composing{border-bottom:2px solid}div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}.CodeMirror-matchingtag{background:rgba(255,150,0,.3)}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{position:relative;overflow:hidden;background:#fff}.CodeMirror-scroll{overflow:scroll!important;margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;height:100%;outline:0;position:relative}.CodeMirror-sizer{position:relative;border-right:30px solid transparent}.CodeMirror-gutter-filler,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-vscrollbar{position:absolute;z-index:6;display:none}.CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom:0}.CodeMirror-gutters{position:absolute;left:0;top:0;min-height:100%;z-index:3}.CodeMirror-gutter{white-space:normal;height:100%;display:inline-block;vertical-align:top;margin-bottom:-30px}.CodeMirror-gutter-wrapper{position:absolute;z-index:4;background:0 0!important;border:none!important}.CodeMirror-gutter-background{position:absolute;top:0;bottom:0;z-index:4}.CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.CodeMirror-gutter-wrapper{-webkit-user-select:none;-moz-user-select:none;user-select:none}.CodeMirror-lines{cursor:text;min-height:1px}.CodeMirror pre{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:0 0;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible;-webkit-tap-highlight-color:transparent;-webkit-font-variant-ligatures:none;font-variant-ligatures:none}.CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.CodeMirror-linewidget{position:relative;z-index:2;overflow:auto}.CodeMirror-code{outline:0}.CodeMirror-gutter,.CodeMirror-gutters,.CodeMirror-linenumber,.CodeMirror-scroll,.CodeMirror-sizer{-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.CodeMirror-cursor{position:absolute}.CodeMirror-measure pre{position:static}div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:3}.CodeMirror-focused div.CodeMirror-cursors,div.CodeMirror-dragcursors{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.CodeMirror-crosshair{cursor:crosshair}.CodeMirror-line::selection,.CodeMirror-line>span::selection,.CodeMirror-line>span>span::selection{background:#d7d4f0}.CodeMirror-line::-moz-selection,.CodeMirror-line>span::-moz-selection,.CodeMirror-line>span>span::-moz-selection{background:#d7d4f0}.cm-searching{background:#ffa;background:rgba(255,255,0,.4)}.cm-force-border{padding-right:.1px}@media print{.CodeMirror div.CodeMirror-cursors{visibility:hidden}}.cm-tab-wrap-hack:after{content:''}span.CodeMirror-selectedtext{background:0 0}
js/esites_editor/dist/js/vendor/codemirror/lib/codemirror.js CHANGED
@@ -1,7 +1,7 @@
1
- !function(mod){if("object"==typeof exports&&"object"==typeof module)module.exports=mod();else{if("function"==typeof define&&define.amd)return define([],mod);this.CodeMirror=mod()}}(function(){"use strict";function CodeMirror(place,options){if(!(this instanceof CodeMirror))return new CodeMirror(place,options);this.options=options=options?copyObj(options):{};copyObj(defaults,options,!1);setGuttersForLineNumbers(options);var doc=options.value;"string"==typeof doc&&(doc=new Doc(doc,options.mode,null,options.lineSeparator));this.doc=doc;var input=new CodeMirror.inputStyles[options.inputStyle](this),display=this.display=new Display(place,doc,input);display.wrapper.CodeMirror=this;updateGutters(this);themeChanged(this);options.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap");options.autofocus&&!mobile&&display.input.focus();initScrollbars(this);this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,selectingText:!1,draggingText:!1,highlight:new Delayed,keySeq:null,specialChars:null};var cm=this;ie&&11>ie_version&&setTimeout(function(){cm.display.input.reset(!0)},20);registerEventHandlers(this);ensureGlobalHandlers();startOperation(this);this.curOp.forceUpdate=!0;attachDoc(this,doc);options.autofocus&&!mobile||cm.hasFocus()?setTimeout(bind(onFocus,this),20):onBlur(this);for(var opt in optionHandlers)optionHandlers.hasOwnProperty(opt)&&optionHandlers[opt](this,options[opt],Init);maybeUpdateLineNumberWidth(this);options.finishInit&&options.finishInit(this);for(var i=0;i<initHooks.length;++i)initHooks[i](this);endOperation(this);webkit&&options.lineWrapping&&"optimizelegibility"==getComputedStyle(display.lineDiv).textRendering&&(display.lineDiv.style.textRendering="auto")}function Display(place,doc,input){var d=this;this.input=input;d.scrollbarFiller=elt("div",null,"CodeMirror-scrollbar-filler");d.scrollbarFiller.setAttribute("cm-not-content","true");d.gutterFiller=elt("div",null,"CodeMirror-gutter-filler");d.gutterFiller.setAttribute("cm-not-content","true");d.lineDiv=elt("div",null,"CodeMirror-code");d.selectionDiv=elt("div",null,null,"position: relative; z-index: 1");d.cursorDiv=elt("div",null,"CodeMirror-cursors");d.measure=elt("div",null,"CodeMirror-measure");d.lineMeasure=elt("div",null,"CodeMirror-measure");d.lineSpace=elt("div",[d.measure,d.lineMeasure,d.selectionDiv,d.cursorDiv,d.lineDiv],null,"position: relative; outline: none");d.mover=elt("div",[elt("div",[d.lineSpace],"CodeMirror-lines")],null,"position: relative");d.sizer=elt("div",[d.mover],"CodeMirror-sizer");d.sizerWidth=null;d.heightForcer=elt("div",null,null,"position: absolute; height: "+scrollerGap+"px; width: 1px;");d.gutters=elt("div",null,"CodeMirror-gutters");d.lineGutter=null;d.scroller=elt("div",[d.sizer,d.heightForcer,d.gutters],"CodeMirror-scroll");d.scroller.setAttribute("tabIndex","-1");d.wrapper=elt("div",[d.scrollbarFiller,d.gutterFiller,d.scroller],"CodeMirror");if(ie&&8>ie_version){d.gutters.style.zIndex=-1;d.scroller.style.paddingRight=0}webkit||gecko&&mobile||(d.scroller.draggable=!0);place&&(place.appendChild?place.appendChild(d.wrapper):place(d.wrapper));d.viewFrom=d.viewTo=doc.first;d.reportedViewFrom=d.reportedViewTo=doc.first;d.view=[];d.renderedView=null;d.externalMeasured=null;d.viewOffset=0;d.lastWrapHeight=d.lastWrapWidth=0;d.updateLineNumbers=null;d.nativeBarWidth=d.barHeight=d.barWidth=0;d.scrollbarsClipped=!1;d.lineNumWidth=d.lineNumInnerWidth=d.lineNumChars=null;d.alignWidgets=!1;d.cachedCharWidth=d.cachedTextHeight=d.cachedPaddingH=null;d.maxLine=null;d.maxLineLength=0;d.maxLineChanged=!1;d.wheelDX=d.wheelDY=d.wheelStartX=d.wheelStartY=null;d.shift=!1;d.selForContextMenu=null;d.activeTouch=null;input.init(d)}function loadMode(cm){cm.doc.mode=CodeMirror.getMode(cm.options,cm.doc.modeOption);resetModeState(cm)}function resetModeState(cm){cm.doc.iter(function(line){line.stateAfter&&(line.stateAfter=null);line.styles&&(line.styles=null)});cm.doc.frontier=cm.doc.first;startWorker(cm,100);cm.state.modeGen++;cm.curOp&&regChange(cm)}function wrappingChanged(cm){if(cm.options.lineWrapping){addClass(cm.display.wrapper,"CodeMirror-wrap");cm.display.sizer.style.minWidth="";cm.display.sizerWidth=null}else{rmClass(cm.display.wrapper,"CodeMirror-wrap");findMaxLine(cm)}estimateLineHeights(cm);regChange(cm);clearCaches(cm);setTimeout(function(){updateScrollbars(cm)},100)}function estimateHeight(cm){var th=textHeight(cm.display),wrapping=cm.options.lineWrapping,perLine=wrapping&&Math.max(5,cm.display.scroller.clientWidth/charWidth(cm.display)-3);return function(line){if(lineIsHidden(cm.doc,line))return 0;var widgetsHeight=0;if(line.widgets)for(var i=0;i<line.widgets.length;i++)line.widgets[i].height&&(widgetsHeight+=line.widgets[i].height);return wrapping?widgetsHeight+(Math.ceil(line.text.length/perLine)||1)*th:widgetsHeight+th}}function estimateLineHeights(cm){var doc=cm.doc,est=estimateHeight(cm);doc.iter(function(line){var estHeight=est(line);estHeight!=line.height&&updateLineHeight(line,estHeight)})}function themeChanged(cm){cm.display.wrapper.className=cm.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+cm.options.theme.replace(/(^|\s)\s*/g," cm-s-");clearCaches(cm)}function guttersChanged(cm){updateGutters(cm);regChange(cm);setTimeout(function(){alignHorizontally(cm)},20)}function updateGutters(cm){var gutters=cm.display.gutters,specs=cm.options.gutters;removeChildren(gutters);for(var i=0;i<specs.length;++i){var gutterClass=specs[i],gElt=gutters.appendChild(elt("div",null,"CodeMirror-gutter "+gutterClass));if("CodeMirror-linenumbers"==gutterClass){cm.display.lineGutter=gElt;gElt.style.width=(cm.display.lineNumWidth||1)+"px"}}gutters.style.display=i?"":"none";updateGutterSpace(cm)}function updateGutterSpace(cm){var width=cm.display.gutters.offsetWidth;cm.display.sizer.style.marginLeft=width+"px"}function lineLength(line){if(0==line.height)return 0;for(var merged,len=line.text.length,cur=line;merged=collapsedSpanAtStart(cur);){var found=merged.find(0,!0);cur=found.from.line;len+=found.from.ch-found.to.ch}cur=line;for(;merged=collapsedSpanAtEnd(cur);){var found=merged.find(0,!0);len-=cur.text.length-found.from.ch;cur=found.to.line;len+=cur.text.length-found.to.ch}return len}function findMaxLine(cm){var d=cm.display,doc=cm.doc;d.maxLine=getLine(doc,doc.first);d.maxLineLength=lineLength(d.maxLine);d.maxLineChanged=!0;doc.iter(function(line){var len=lineLength(line);if(len>d.maxLineLength){d.maxLineLength=len;d.maxLine=line}})}function setGuttersForLineNumbers(options){var found=indexOf(options.gutters,"CodeMirror-linenumbers");if(-1==found&&options.lineNumbers)options.gutters=options.gutters.concat(["CodeMirror-linenumbers"]);else if(found>-1&&!options.lineNumbers){options.gutters=options.gutters.slice(0);options.gutters.splice(found,1)}}function measureForScrollbars(cm){var d=cm.display,gutterW=d.gutters.offsetWidth,docH=Math.round(cm.doc.height+paddingVert(cm.display));return{clientHeight:d.scroller.clientHeight,viewHeight:d.wrapper.clientHeight,scrollWidth:d.scroller.scrollWidth,clientWidth:d.scroller.clientWidth,viewWidth:d.wrapper.clientWidth,barLeft:cm.options.fixedGutter?gutterW:0,docHeight:docH,scrollHeight:docH+scrollGap(cm)+d.barHeight,nativeBarWidth:d.nativeBarWidth,gutterWidth:gutterW}}function NativeScrollbars(place,scroll,cm){this.cm=cm;var vert=this.vert=elt("div",[elt("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),horiz=this.horiz=elt("div",[elt("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");place(vert);place(horiz);on(vert,"scroll",function(){vert.clientHeight&&scroll(vert.scrollTop,"vertical")});on(horiz,"scroll",function(){horiz.clientWidth&&scroll(horiz.scrollLeft,"horizontal")});this.checkedOverlay=!1;ie&&8>ie_version&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function NullScrollbars(){}function initScrollbars(cm){if(cm.display.scrollbars){cm.display.scrollbars.clear();cm.display.scrollbars.addClass&&rmClass(cm.display.wrapper,cm.display.scrollbars.addClass)}cm.display.scrollbars=new CodeMirror.scrollbarModel[cm.options.scrollbarStyle](function(node){cm.display.wrapper.insertBefore(node,cm.display.scrollbarFiller);on(node,"mousedown",function(){cm.state.focused&&setTimeout(function(){cm.display.input.focus()},0)});node.setAttribute("cm-not-content","true")},function(pos,axis){"horizontal"==axis?setScrollLeft(cm,pos):setScrollTop(cm,pos)},cm);cm.display.scrollbars.addClass&&addClass(cm.display.wrapper,cm.display.scrollbars.addClass)}function updateScrollbars(cm,measure){measure||(measure=measureForScrollbars(cm));var startWidth=cm.display.barWidth,startHeight=cm.display.barHeight;updateScrollbarsInner(cm,measure);for(var i=0;4>i&&startWidth!=cm.display.barWidth||startHeight!=cm.display.barHeight;i++){startWidth!=cm.display.barWidth&&cm.options.lineWrapping&&updateHeightsInViewport(cm);updateScrollbarsInner(cm,measureForScrollbars(cm));startWidth=cm.display.barWidth;startHeight=cm.display.barHeight}}function updateScrollbarsInner(cm,measure){var d=cm.display,sizes=d.scrollbars.update(measure);d.sizer.style.paddingRight=(d.barWidth=sizes.right)+"px";d.sizer.style.paddingBottom=(d.barHeight=sizes.bottom)+"px";if(sizes.right&&sizes.bottom){d.scrollbarFiller.style.display="block";d.scrollbarFiller.style.height=sizes.bottom+"px";d.scrollbarFiller.style.width=sizes.right+"px"}else d.scrollbarFiller.style.display="";if(sizes.bottom&&cm.options.coverGutterNextToScrollbar&&cm.options.fixedGutter){d.gutterFiller.style.display="block";d.gutterFiller.style.height=sizes.bottom+"px";d.gutterFiller.style.width=measure.gutterWidth+"px"}else d.gutterFiller.style.display=""}function visibleLines(display,doc,viewport){var top=viewport&&null!=viewport.top?Math.max(0,viewport.top):display.scroller.scrollTop;top=Math.floor(top-paddingTop(display));var bottom=viewport&&null!=viewport.bottom?viewport.bottom:top+display.wrapper.clientHeight,from=lineAtHeight(doc,top),to=lineAtHeight(doc,bottom);if(viewport&&viewport.ensure){var ensureFrom=viewport.ensure.from.line,ensureTo=viewport.ensure.to.line;if(from>ensureFrom){from=ensureFrom;to=lineAtHeight(doc,heightAtLine(getLine(doc,ensureFrom))+display.wrapper.clientHeight)}else if(Math.min(ensureTo,doc.lastLine())>=to){from=lineAtHeight(doc,heightAtLine(getLine(doc,ensureTo))-display.wrapper.clientHeight);to=ensureTo}}return{from:from,to:Math.max(to,from+1)}}function alignHorizontally(cm){var display=cm.display,view=display.view;if(display.alignWidgets||display.gutters.firstChild&&cm.options.fixedGutter){for(var comp=compensateForHScroll(display)-display.scroller.scrollLeft+cm.doc.scrollLeft,gutterW=display.gutters.offsetWidth,left=comp+"px",i=0;i<view.length;i++)if(!view[i].hidden){cm.options.fixedGutter&&view[i].gutter&&(view[i].gutter.style.left=left);var align=view[i].alignable;if(align)for(var j=0;j<align.length;j++)align[j].style.left=left}cm.options.fixedGutter&&(display.gutters.style.left=comp+gutterW+"px")}}function maybeUpdateLineNumberWidth(cm){if(!cm.options.lineNumbers)return!1;var doc=cm.doc,last=lineNumberFor(cm.options,doc.first+doc.size-1),display=cm.display;if(last.length!=display.lineNumChars){var test=display.measure.appendChild(elt("div",[elt("div",last)],"CodeMirror-linenumber CodeMirror-gutter-elt")),innerW=test.firstChild.offsetWidth,padding=test.offsetWidth-innerW;display.lineGutter.style.width="";display.lineNumInnerWidth=Math.max(innerW,display.lineGutter.offsetWidth-padding)+1;display.lineNumWidth=display.lineNumInnerWidth+padding;display.lineNumChars=display.lineNumInnerWidth?last.length:-1;display.lineGutter.style.width=display.lineNumWidth+"px";updateGutterSpace(cm);return!0}return!1}function lineNumberFor(options,i){return String(options.lineNumberFormatter(i+options.firstLineNumber))}function compensateForHScroll(display){return display.scroller.getBoundingClientRect().left-display.sizer.getBoundingClientRect().left}function DisplayUpdate(cm,viewport,force){var display=cm.display;this.viewport=viewport;this.visible=visibleLines(display,cm.doc,viewport);this.editorIsHidden=!display.wrapper.offsetWidth;this.wrapperHeight=display.wrapper.clientHeight;this.wrapperWidth=display.wrapper.clientWidth;this.oldDisplayWidth=displayWidth(cm);this.force=force;this.dims=getDimensions(cm);this.events=[]}function maybeClipScrollbars(cm){var display=cm.display;if(!display.scrollbarsClipped&&display.scroller.offsetWidth){display.nativeBarWidth=display.scroller.offsetWidth-display.scroller.clientWidth;display.heightForcer.style.height=scrollGap(cm)+"px";display.sizer.style.marginBottom=-display.nativeBarWidth+"px";display.sizer.style.borderRightWidth=scrollGap(cm)+"px";display.scrollbarsClipped=!0}}function updateDisplayIfNeeded(cm,update){var display=cm.display,doc=cm.doc;if(update.editorIsHidden){resetView(cm);return!1}if(!update.force&&update.visible.from>=display.viewFrom&&update.visible.to<=display.viewTo&&(null==display.updateLineNumbers||display.updateLineNumbers>=display.viewTo)&&display.renderedView==display.view&&0==countDirtyView(cm))return!1;if(maybeUpdateLineNumberWidth(cm)){resetView(cm);update.dims=getDimensions(cm)}var end=doc.first+doc.size,from=Math.max(update.visible.from-cm.options.viewportMargin,doc.first),to=Math.min(end,update.visible.to+cm.options.viewportMargin);display.viewFrom<from&&from-display.viewFrom<20&&(from=Math.max(doc.first,display.viewFrom));display.viewTo>to&&display.viewTo-to<20&&(to=Math.min(end,display.viewTo));if(sawCollapsedSpans){from=visualLineNo(cm.doc,from);to=visualLineEndNo(cm.doc,to)}var different=from!=display.viewFrom||to!=display.viewTo||display.lastWrapHeight!=update.wrapperHeight||display.lastWrapWidth!=update.wrapperWidth;adjustView(cm,from,to);display.viewOffset=heightAtLine(getLine(cm.doc,display.viewFrom));cm.display.mover.style.top=display.viewOffset+"px";var toUpdate=countDirtyView(cm);if(!different&&0==toUpdate&&!update.force&&display.renderedView==display.view&&(null==display.updateLineNumbers||display.updateLineNumbers>=display.viewTo))return!1;var focused=activeElt();toUpdate>4&&(display.lineDiv.style.display="none");patchDisplay(cm,display.updateLineNumbers,update.dims);toUpdate>4&&(display.lineDiv.style.display="");display.renderedView=display.view;focused&&activeElt()!=focused&&focused.offsetHeight&&focused.focus();removeChildren(display.cursorDiv);removeChildren(display.selectionDiv);display.gutters.style.height=display.sizer.style.minHeight=0;if(different){display.lastWrapHeight=update.wrapperHeight;display.lastWrapWidth=update.wrapperWidth;startWorker(cm,400)}display.updateLineNumbers=null;return!0}function postUpdateDisplay(cm,update){for(var viewport=update.viewport,first=!0;;first=!1){if(!first||!cm.options.lineWrapping||update.oldDisplayWidth==displayWidth(cm)){viewport&&null!=viewport.top&&(viewport={top:Math.min(cm.doc.height+paddingVert(cm.display)-displayHeight(cm),viewport.top)});update.visible=visibleLines(cm.display,cm.doc,viewport);if(update.visible.from>=cm.display.viewFrom&&update.visible.to<=cm.display.viewTo)break}if(!updateDisplayIfNeeded(cm,update))break;updateHeightsInViewport(cm);var barMeasure=measureForScrollbars(cm);updateSelection(cm);setDocumentHeight(cm,barMeasure);updateScrollbars(cm,barMeasure)}update.signal(cm,"update",cm);if(cm.display.viewFrom!=cm.display.reportedViewFrom||cm.display.viewTo!=cm.display.reportedViewTo){update.signal(cm,"viewportChange",cm,cm.display.viewFrom,cm.display.viewTo);cm.display.reportedViewFrom=cm.display.viewFrom;cm.display.reportedViewTo=cm.display.viewTo}}function updateDisplaySimple(cm,viewport){var update=new DisplayUpdate(cm,viewport);if(updateDisplayIfNeeded(cm,update)){updateHeightsInViewport(cm);postUpdateDisplay(cm,update);var barMeasure=measureForScrollbars(cm);updateSelection(cm);setDocumentHeight(cm,barMeasure);updateScrollbars(cm,barMeasure);update.finish()}}function setDocumentHeight(cm,measure){cm.display.sizer.style.minHeight=measure.docHeight+"px";var total=measure.docHeight+cm.display.barHeight;cm.display.heightForcer.style.top=total+"px";cm.display.gutters.style.height=Math.max(total+scrollGap(cm),measure.clientHeight)+"px"}function updateHeightsInViewport(cm){for(var display=cm.display,prevBottom=display.lineDiv.offsetTop,i=0;i<display.view.length;i++){var height,cur=display.view[i];if(!cur.hidden){if(ie&&8>ie_version){var bot=cur.node.offsetTop+cur.node.offsetHeight;height=bot-prevBottom;prevBottom=bot}else{var box=cur.node.getBoundingClientRect();height=box.bottom-box.top}var diff=cur.line.height-height;2>height&&(height=textHeight(display));if(diff>.001||-.001>diff){updateLineHeight(cur.line,height);updateWidgetHeight(cur.line);if(cur.rest)for(var j=0;j<cur.rest.length;j++)updateWidgetHeight(cur.rest[j])}}}}function updateWidgetHeight(line){if(line.widgets)for(var i=0;i<line.widgets.length;++i)line.widgets[i].height=line.widgets[i].node.offsetHeight}function getDimensions(cm){for(var d=cm.display,left={},width={},gutterLeft=d.gutters.clientLeft,n=d.gutters.firstChild,i=0;n;n=n.nextSibling,++i){left[cm.options.gutters[i]]=n.offsetLeft+n.clientLeft+gutterLeft;width[cm.options.gutters[i]]=n.clientWidth}return{fixedPos:compensateForHScroll(d),gutterTotalWidth:d.gutters.offsetWidth,gutterLeft:left,gutterWidth:width,wrapperWidth:d.wrapper.clientWidth}}function patchDisplay(cm,updateNumbersFrom,dims){function rm(node){var next=node.nextSibling;webkit&&mac&&cm.display.currentWheelTarget==node?node.style.display="none":node.parentNode.removeChild(node);return next}for(var display=cm.display,lineNumbers=cm.options.lineNumbers,container=display.lineDiv,cur=container.firstChild,view=display.view,lineN=display.viewFrom,i=0;i<view.length;i++){var lineView=view[i];if(lineView.hidden);else if(lineView.node&&lineView.node.parentNode==container){for(;cur!=lineView.node;)cur=rm(cur);var updateNumber=lineNumbers&&null!=updateNumbersFrom&&lineN>=updateNumbersFrom&&lineView.lineNumber;if(lineView.changes){indexOf(lineView.changes,"gutter")>-1&&(updateNumber=!1);updateLineForChanges(cm,lineView,lineN,dims)}if(updateNumber){removeChildren(lineView.lineNumber);lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options,lineN)))}cur=lineView.node.nextSibling}else{var node=buildLineElement(cm,lineView,lineN,dims);container.insertBefore(node,cur)}lineN+=lineView.size}for(;cur;)cur=rm(cur)}function updateLineForChanges(cm,lineView,lineN,dims){for(var j=0;j<lineView.changes.length;j++){var type=lineView.changes[j];"text"==type?updateLineText(cm,lineView):"gutter"==type?updateLineGutter(cm,lineView,lineN,dims):"class"==type?updateLineClasses(lineView):"widget"==type&&updateLineWidgets(cm,lineView,dims)}lineView.changes=null}function ensureLineWrapped(lineView){if(lineView.node==lineView.text){lineView.node=elt("div",null,null,"position: relative");lineView.text.parentNode&&lineView.text.parentNode.replaceChild(lineView.node,lineView.text);lineView.node.appendChild(lineView.text);ie&&8>ie_version&&(lineView.node.style.zIndex=2)}return lineView.node}function updateLineBackground(lineView){var cls=lineView.bgClass?lineView.bgClass+" "+(lineView.line.bgClass||""):lineView.line.bgClass;cls&&(cls+=" CodeMirror-linebackground");if(lineView.background)if(cls)lineView.background.className=cls;else{lineView.background.parentNode.removeChild(lineView.background);lineView.background=null}else if(cls){var wrap=ensureLineWrapped(lineView);lineView.background=wrap.insertBefore(elt("div",null,cls),wrap.firstChild)}}function getLineContent(cm,lineView){var ext=cm.display.externalMeasured;if(ext&&ext.line==lineView.line){cm.display.externalMeasured=null;lineView.measure=ext.measure;return ext.built}return buildLineContent(cm,lineView)}function updateLineText(cm,lineView){var cls=lineView.text.className,built=getLineContent(cm,lineView);lineView.text==lineView.node&&(lineView.node=built.pre);lineView.text.parentNode.replaceChild(built.pre,lineView.text);lineView.text=built.pre;if(built.bgClass!=lineView.bgClass||built.textClass!=lineView.textClass){lineView.bgClass=built.bgClass;lineView.textClass=built.textClass;updateLineClasses(lineView)}else cls&&(lineView.text.className=cls)}function updateLineClasses(lineView){updateLineBackground(lineView);lineView.line.wrapClass?ensureLineWrapped(lineView).className=lineView.line.wrapClass:lineView.node!=lineView.text&&(lineView.node.className="");var textClass=lineView.textClass?lineView.textClass+" "+(lineView.line.textClass||""):lineView.line.textClass;lineView.text.className=textClass||""}function updateLineGutter(cm,lineView,lineN,dims){if(lineView.gutter){lineView.node.removeChild(lineView.gutter);lineView.gutter=null}if(lineView.gutterBackground){lineView.node.removeChild(lineView.gutterBackground);lineView.gutterBackground=null}if(lineView.line.gutterClass){var wrap=ensureLineWrapped(lineView);lineView.gutterBackground=elt("div",null,"CodeMirror-gutter-background "+lineView.line.gutterClass,"left: "+(cm.options.fixedGutter?dims.fixedPos:-dims.gutterTotalWidth)+"px; width: "+dims.gutterTotalWidth+"px");wrap.insertBefore(lineView.gutterBackground,lineView.text)}var markers=lineView.line.gutterMarkers;if(cm.options.lineNumbers||markers){var wrap=ensureLineWrapped(lineView),gutterWrap=lineView.gutter=elt("div",null,"CodeMirror-gutter-wrapper","left: "+(cm.options.fixedGutter?dims.fixedPos:-dims.gutterTotalWidth)+"px");cm.display.input.setUneditable(gutterWrap);wrap.insertBefore(gutterWrap,lineView.text);lineView.line.gutterClass&&(gutterWrap.className+=" "+lineView.line.gutterClass);!cm.options.lineNumbers||markers&&markers["CodeMirror-linenumbers"]||(lineView.lineNumber=gutterWrap.appendChild(elt("div",lineNumberFor(cm.options,lineN),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+dims.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+cm.display.lineNumInnerWidth+"px")));if(markers)for(var k=0;k<cm.options.gutters.length;++k){var id=cm.options.gutters[k],found=markers.hasOwnProperty(id)&&markers[id];found&&gutterWrap.appendChild(elt("div",[found],"CodeMirror-gutter-elt","left: "+dims.gutterLeft[id]+"px; width: "+dims.gutterWidth[id]+"px"))}}}function updateLineWidgets(cm,lineView,dims){lineView.alignable&&(lineView.alignable=null);for(var next,node=lineView.node.firstChild;node;node=next){var next=node.nextSibling;"CodeMirror-linewidget"==node.className&&lineView.node.removeChild(node)}insertLineWidgets(cm,lineView,dims)}function buildLineElement(cm,lineView,lineN,dims){var built=getLineContent(cm,lineView);lineView.text=lineView.node=built.pre;built.bgClass&&(lineView.bgClass=built.bgClass);built.textClass&&(lineView.textClass=built.textClass);updateLineClasses(lineView);updateLineGutter(cm,lineView,lineN,dims);insertLineWidgets(cm,lineView,dims);return lineView.node}function insertLineWidgets(cm,lineView,dims){insertLineWidgetsFor(cm,lineView.line,lineView,dims,!0);if(lineView.rest)for(var i=0;i<lineView.rest.length;i++)insertLineWidgetsFor(cm,lineView.rest[i],lineView,dims,!1)}function insertLineWidgetsFor(cm,line,lineView,dims,allowAbove){if(line.widgets)for(var wrap=ensureLineWrapped(lineView),i=0,ws=line.widgets;i<ws.length;++i){var widget=ws[i],node=elt("div",[widget.node],"CodeMirror-linewidget");widget.handleMouseEvents||node.setAttribute("cm-ignore-events","true");positionLineWidget(widget,node,lineView,dims);cm.display.input.setUneditable(node);allowAbove&&widget.above?wrap.insertBefore(node,lineView.gutter||lineView.text):wrap.appendChild(node);signalLater(widget,"redraw")}}function positionLineWidget(widget,node,lineView,dims){if(widget.noHScroll){(lineView.alignable||(lineView.alignable=[])).push(node);var width=dims.wrapperWidth;node.style.left=dims.fixedPos+"px";if(!widget.coverGutter){width-=dims.gutterTotalWidth;node.style.paddingLeft=dims.gutterTotalWidth+"px"}node.style.width=width+"px"}if(widget.coverGutter){node.style.zIndex=5;node.style.position="relative";widget.noHScroll||(node.style.marginLeft=-dims.gutterTotalWidth+"px")}}function copyPos(x){return Pos(x.line,x.ch)}function maxPos(a,b){return cmp(a,b)<0?b:a}function minPos(a,b){return cmp(a,b)<0?a:b}function ensureFocus(cm){if(!cm.state.focused){cm.display.input.focus();onFocus(cm)}}function isReadOnly(cm){return cm.options.readOnly||cm.doc.cantEdit}function applyTextInput(cm,inserted,deleted,sel,origin){var doc=cm.doc;cm.display.shift=!1;sel||(sel=doc.sel);var paste=cm.state.pasteIncoming||"paste"==origin,textLines=doc.splitLines(inserted),multiPaste=null;if(paste&&sel.ranges.length>1)if(lastCopied&&lastCopied.join("\n")==inserted){if(sel.ranges.length%lastCopied.length==0){multiPaste=[];for(var i=0;i<lastCopied.length;i++)multiPaste.push(doc.splitLines(lastCopied[i]))}}else textLines.length==sel.ranges.length&&(multiPaste=map(textLines,function(l){return[l]}));for(var i=sel.ranges.length-1;i>=0;i--){var range=sel.ranges[i],from=range.from(),to=range.to();range.empty()&&(deleted&&deleted>0?from=Pos(from.line,from.ch-deleted):cm.state.overwrite&&!paste&&(to=Pos(to.line,Math.min(getLine(doc,to.line).text.length,to.ch+lst(textLines).length))));var updateInput=cm.curOp.updateInput,changeEvent={from:from,to:to,text:multiPaste?multiPaste[i%multiPaste.length]:textLines,origin:origin||(paste?"paste":cm.state.cutIncoming?"cut":"+input")};makeChange(cm.doc,changeEvent);signalLater(cm,"inputRead",cm,changeEvent)}inserted&&!paste&&triggerElectric(cm,inserted);ensureCursorVisible(cm);cm.curOp.updateInput=updateInput;cm.curOp.typing=!0;cm.state.pasteIncoming=cm.state.cutIncoming=!1}function handlePaste(e,cm){var pasted=e.clipboardData&&e.clipboardData.getData("text/plain");if(pasted){e.preventDefault();isReadOnly(cm)||cm.options.disableInput||runInOp(cm,function(){applyTextInput(cm,pasted,0,null,"paste")});return!0}}function triggerElectric(cm,inserted){if(cm.options.electricChars&&cm.options.smartIndent)for(var sel=cm.doc.sel,i=sel.ranges.length-1;i>=0;i--){var range=sel.ranges[i];if(!(range.head.ch>100||i&&sel.ranges[i-1].head.line==range.head.line)){var mode=cm.getModeAt(range.head),indented=!1;if(mode.electricChars){for(var j=0;j<mode.electricChars.length;j++)if(inserted.indexOf(mode.electricChars.charAt(j))>-1){indented=indentLine(cm,range.head.line,"smart");break}}else mode.electricInput&&mode.electricInput.test(getLine(cm.doc,range.head.line).text.slice(0,range.head.ch))&&(indented=indentLine(cm,range.head.line,"smart"));indented&&signalLater(cm,"electricInput",cm,range.head.line)}}}function copyableRanges(cm){for(var text=[],ranges=[],i=0;i<cm.doc.sel.ranges.length;i++){var line=cm.doc.sel.ranges[i].head.line,lineRange={anchor:Pos(line,0),head:Pos(line+1,0)};ranges.push(lineRange);text.push(cm.getRange(lineRange.anchor,lineRange.head))}return{text:text,ranges:ranges}}function disableBrowserMagic(field){field.setAttribute("autocorrect","off");field.setAttribute("autocapitalize","off");field.setAttribute("spellcheck","false")}function TextareaInput(cm){this.cm=cm;this.prevInput="";this.pollingFast=!1;this.polling=new Delayed;this.inaccurateSelection=!1;this.hasSelection=!1;this.composing=null}function hiddenTextarea(){var te=elt("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none"),div=elt("div",[te],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");webkit?te.style.width="1000px":te.setAttribute("wrap","off");ios&&(te.style.border="1px solid black");disableBrowserMagic(te);return div}function ContentEditableInput(cm){this.cm=cm;this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null;this.polling=new Delayed;this.gracePeriod=!1}function posToDOM(cm,pos){var view=findViewForLine(cm,pos.line);if(!view||view.hidden)return null;var line=getLine(cm.doc,pos.line),info=mapFromLineView(view,line,pos.line),order=getOrder(line),side="left";if(order){var partPos=getBidiPartAt(order,pos.ch);side=partPos%2?"right":"left"}var result=nodeAndOffsetInLineMap(info.map,pos.ch,side);result.offset="right"==result.collapse?result.end:result.start;return result}function badPos(pos,bad){bad&&(pos.bad=!0);return pos}function domToPos(cm,node,offset){var lineNode;if(node==cm.display.lineDiv){lineNode=cm.display.lineDiv.childNodes[offset];if(!lineNode)return badPos(cm.clipPos(Pos(cm.display.viewTo-1)),!0);node=null;offset=0}else for(lineNode=node;;lineNode=lineNode.parentNode){if(!lineNode||lineNode==cm.display.lineDiv)return null;if(lineNode.parentNode&&lineNode.parentNode==cm.display.lineDiv)break}for(var i=0;i<cm.display.view.length;i++){var lineView=cm.display.view[i];if(lineView.node==lineNode)return locateNodeInLineView(lineView,node,offset)}}function locateNodeInLineView(lineView,node,offset){function find(textNode,topNode,offset){for(var i=-1;i<(maps?maps.length:0);i++)for(var map=0>i?measure.map:maps[i],j=0;j<map.length;j+=3){var curNode=map[j+2];if(curNode==textNode||curNode==topNode){var line=lineNo(0>i?lineView.line:lineView.rest[i]),ch=map[j]+offset;(0>offset||curNode!=textNode)&&(ch=map[j+(offset?1:0)]);return Pos(line,ch)}}}var wrapper=lineView.text.firstChild,bad=!1;if(!node||!contains(wrapper,node))return badPos(Pos(lineNo(lineView.line),0),!0);if(node==wrapper){bad=!0;node=wrapper.childNodes[offset];offset=0;if(!node){var line=lineView.rest?lst(lineView.rest):lineView.line;return badPos(Pos(lineNo(line),line.text.length),bad)}}var textNode=3==node.nodeType?node:null,topNode=node;if(!textNode&&1==node.childNodes.length&&3==node.firstChild.nodeType){textNode=node.firstChild;offset&&(offset=textNode.nodeValue.length)}for(;topNode.parentNode!=wrapper;)topNode=topNode.parentNode;var measure=lineView.measure,maps=measure.maps,found=find(textNode,topNode,offset);if(found)return badPos(found,bad);for(var after=topNode.nextSibling,dist=textNode?textNode.nodeValue.length-offset:0;after;after=after.nextSibling){found=find(after,after.firstChild,0);if(found)return badPos(Pos(found.line,found.ch-dist),bad);dist+=after.textContent.length}for(var before=topNode.previousSibling,dist=offset;before;before=before.previousSibling){found=find(before,before.firstChild,-1);if(found)return badPos(Pos(found.line,found.ch+dist),bad);dist+=after.textContent.length}}function domTextBetween(cm,from,to,fromLine,toLine){function recognizeMarker(id){return function(marker){return marker.id==id}}function walk(node){if(1==node.nodeType){var cmText=node.getAttribute("cm-text");if(null!=cmText){""==cmText&&(cmText=node.textContent.replace(/\u200b/g,""));text+=cmText;return}var range,markerID=node.getAttribute("cm-marker");if(markerID){var found=cm.findMarks(Pos(fromLine,0),Pos(toLine+1,0),recognizeMarker(+markerID));found.length&&(range=found[0].find())&&(text+=getBetween(cm.doc,range.from,range.to).join(lineSep));return}if("false"==node.getAttribute("contenteditable"))return;for(var i=0;i<node.childNodes.length;i++)walk(node.childNodes[i]);/^(pre|div|p)$/i.test(node.nodeName)&&(closing=!0)}else if(3==node.nodeType){var val=node.nodeValue;if(!val)return;if(closing){text+=lineSep;closing=!1}text+=val}}for(var text="",closing=!1,lineSep=cm.doc.lineSeparator();;){walk(from);if(from==to)break;from=from.nextSibling}return text}function Selection(ranges,primIndex){this.ranges=ranges;this.primIndex=primIndex}function Range(anchor,head){this.anchor=anchor;this.head=head}function normalizeSelection(ranges,primIndex){var prim=ranges[primIndex];ranges.sort(function(a,b){return cmp(a.from(),b.from())});primIndex=indexOf(ranges,prim);for(var i=1;i<ranges.length;i++){var cur=ranges[i],prev=ranges[i-1];if(cmp(prev.to(),cur.from())>=0){var from=minPos(prev.from(),cur.from()),to=maxPos(prev.to(),cur.to()),inv=prev.empty()?cur.from()==cur.head:prev.from()==prev.head;primIndex>=i&&--primIndex;ranges.splice(--i,2,new Range(inv?to:from,inv?from:to))}}return new Selection(ranges,primIndex)}function simpleSelection(anchor,head){return new Selection([new Range(anchor,head||anchor)],0)}function clipLine(doc,n){return Math.max(doc.first,Math.min(n,doc.first+doc.size-1))}function clipPos(doc,pos){if(pos.line<doc.first)return Pos(doc.first,0);
2
- var last=doc.first+doc.size-1;return pos.line>last?Pos(last,getLine(doc,last).text.length):clipToLen(pos,getLine(doc,pos.line).text.length)}function clipToLen(pos,linelen){var ch=pos.ch;return null==ch||ch>linelen?Pos(pos.line,linelen):0>ch?Pos(pos.line,0):pos}function isLine(doc,l){return l>=doc.first&&l<doc.first+doc.size}function clipPosArray(doc,array){for(var out=[],i=0;i<array.length;i++)out[i]=clipPos(doc,array[i]);return out}function extendRange(doc,range,head,other){if(doc.cm&&doc.cm.display.shift||doc.extend){var anchor=range.anchor;if(other){var posBefore=cmp(head,anchor)<0;if(posBefore!=cmp(other,anchor)<0){anchor=head;head=other}else posBefore!=cmp(head,other)<0&&(head=other)}return new Range(anchor,head)}return new Range(other||head,head)}function extendSelection(doc,head,other,options){setSelection(doc,new Selection([extendRange(doc,doc.sel.primary(),head,other)],0),options)}function extendSelections(doc,heads,options){for(var out=[],i=0;i<doc.sel.ranges.length;i++)out[i]=extendRange(doc,doc.sel.ranges[i],heads[i],null);var newSel=normalizeSelection(out,doc.sel.primIndex);setSelection(doc,newSel,options)}function replaceOneSelection(doc,i,range,options){var ranges=doc.sel.ranges.slice(0);ranges[i]=range;setSelection(doc,normalizeSelection(ranges,doc.sel.primIndex),options)}function setSimpleSelection(doc,anchor,head,options){setSelection(doc,simpleSelection(anchor,head),options)}function filterSelectionChange(doc,sel){var obj={ranges:sel.ranges,update:function(ranges){this.ranges=[];for(var i=0;i<ranges.length;i++)this.ranges[i]=new Range(clipPos(doc,ranges[i].anchor),clipPos(doc,ranges[i].head))}};signal(doc,"beforeSelectionChange",doc,obj);doc.cm&&signal(doc.cm,"beforeSelectionChange",doc.cm,obj);return obj.ranges!=sel.ranges?normalizeSelection(obj.ranges,obj.ranges.length-1):sel}function setSelectionReplaceHistory(doc,sel,options){var done=doc.history.done,last=lst(done);if(last&&last.ranges){done[done.length-1]=sel;setSelectionNoUndo(doc,sel,options)}else setSelection(doc,sel,options)}function setSelection(doc,sel,options){setSelectionNoUndo(doc,sel,options);addSelectionToHistory(doc,doc.sel,doc.cm?doc.cm.curOp.id:NaN,options)}function setSelectionNoUndo(doc,sel,options){(hasHandler(doc,"beforeSelectionChange")||doc.cm&&hasHandler(doc.cm,"beforeSelectionChange"))&&(sel=filterSelectionChange(doc,sel));var bias=options&&options.bias||(cmp(sel.primary().head,doc.sel.primary().head)<0?-1:1);setSelectionInner(doc,skipAtomicInSelection(doc,sel,bias,!0));options&&options.scroll===!1||!doc.cm||ensureCursorVisible(doc.cm)}function setSelectionInner(doc,sel){if(!sel.equals(doc.sel)){doc.sel=sel;if(doc.cm){doc.cm.curOp.updateInput=doc.cm.curOp.selectionChanged=!0;signalCursorActivity(doc.cm)}signalLater(doc,"cursorActivity",doc)}}function reCheckSelection(doc){setSelectionInner(doc,skipAtomicInSelection(doc,doc.sel,null,!1),sel_dontScroll)}function skipAtomicInSelection(doc,sel,bias,mayClear){for(var out,i=0;i<sel.ranges.length;i++){var range=sel.ranges[i],newAnchor=skipAtomic(doc,range.anchor,bias,mayClear),newHead=skipAtomic(doc,range.head,bias,mayClear);if(out||newAnchor!=range.anchor||newHead!=range.head){out||(out=sel.ranges.slice(0,i));out[i]=new Range(newAnchor,newHead)}}return out?normalizeSelection(out,sel.primIndex):sel}function skipAtomic(doc,pos,bias,mayClear){var flipped=!1,curPos=pos,dir=bias||1;doc.cantEdit=!1;search:for(;;){var line=getLine(doc,curPos.line);if(line.markedSpans)for(var i=0;i<line.markedSpans.length;++i){var sp=line.markedSpans[i],m=sp.marker;if((null==sp.from||(m.inclusiveLeft?sp.from<=curPos.ch:sp.from<curPos.ch))&&(null==sp.to||(m.inclusiveRight?sp.to>=curPos.ch:sp.to>curPos.ch))){if(mayClear){signal(m,"beforeCursorEnter");if(m.explicitlyCleared){if(line.markedSpans){--i;continue}break}}if(!m.atomic)continue;var newPos=m.find(0>dir?-1:1);if(0==cmp(newPos,curPos)){newPos.ch+=dir;newPos.ch<0?newPos=newPos.line>doc.first?clipPos(doc,Pos(newPos.line-1)):null:newPos.ch>line.text.length&&(newPos=newPos.line<doc.first+doc.size-1?Pos(newPos.line+1,0):null);if(!newPos){if(flipped){if(!mayClear)return skipAtomic(doc,pos,bias,!0);doc.cantEdit=!0;return Pos(doc.first,0)}flipped=!0;newPos=pos;dir=-dir}}curPos=newPos;continue search}}return curPos}}function updateSelection(cm){cm.display.input.showSelection(cm.display.input.prepareSelection())}function prepareSelection(cm,primary){for(var doc=cm.doc,result={},curFragment=result.cursors=document.createDocumentFragment(),selFragment=result.selection=document.createDocumentFragment(),i=0;i<doc.sel.ranges.length;i++)if(primary!==!1||i!=doc.sel.primIndex){var range=doc.sel.ranges[i],collapsed=range.empty();(collapsed||cm.options.showCursorWhenSelecting)&&drawSelectionCursor(cm,range.head,curFragment);collapsed||drawSelectionRange(cm,range,selFragment)}return result}function drawSelectionCursor(cm,head,output){var pos=cursorCoords(cm,head,"div",null,null,!cm.options.singleCursorHeightPerLine),cursor=output.appendChild(elt("div"," ","CodeMirror-cursor"));cursor.style.left=pos.left+"px";cursor.style.top=pos.top+"px";cursor.style.height=Math.max(0,pos.bottom-pos.top)*cm.options.cursorHeight+"px";if(pos.other){var otherCursor=output.appendChild(elt("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));otherCursor.style.display="";otherCursor.style.left=pos.other.left+"px";otherCursor.style.top=pos.other.top+"px";otherCursor.style.height=.85*(pos.other.bottom-pos.other.top)+"px"}}function drawSelectionRange(cm,range,output){function add(left,top,width,bottom){0>top&&(top=0);top=Math.round(top);bottom=Math.round(bottom);fragment.appendChild(elt("div",null,"CodeMirror-selected","position: absolute; left: "+left+"px; top: "+top+"px; width: "+(null==width?rightSide-left:width)+"px; height: "+(bottom-top)+"px"))}function drawForLine(line,fromArg,toArg){function coords(ch,bias){return charCoords(cm,Pos(line,ch),"div",lineObj,bias)}var start,end,lineObj=getLine(doc,line),lineLen=lineObj.text.length;iterateBidiSections(getOrder(lineObj),fromArg||0,null==toArg?lineLen:toArg,function(from,to,dir){var rightPos,left,right,leftPos=coords(from,"left");if(from==to){rightPos=leftPos;left=right=leftPos.left}else{rightPos=coords(to-1,"right");if("rtl"==dir){var tmp=leftPos;leftPos=rightPos;rightPos=tmp}left=leftPos.left;right=rightPos.right}null==fromArg&&0==from&&(left=leftSide);if(rightPos.top-leftPos.top>3){add(left,leftPos.top,null,leftPos.bottom);left=leftSide;leftPos.bottom<rightPos.top&&add(left,leftPos.bottom,null,rightPos.top)}null==toArg&&to==lineLen&&(right=rightSide);(!start||leftPos.top<start.top||leftPos.top==start.top&&leftPos.left<start.left)&&(start=leftPos);(!end||rightPos.bottom>end.bottom||rightPos.bottom==end.bottom&&rightPos.right>end.right)&&(end=rightPos);leftSide+1>left&&(left=leftSide);add(left,rightPos.top,right-left,rightPos.bottom)});return{start:start,end:end}}var display=cm.display,doc=cm.doc,fragment=document.createDocumentFragment(),padding=paddingH(cm.display),leftSide=padding.left,rightSide=Math.max(display.sizerWidth,displayWidth(cm)-display.sizer.offsetLeft)-padding.right,sFrom=range.from(),sTo=range.to();if(sFrom.line==sTo.line)drawForLine(sFrom.line,sFrom.ch,sTo.ch);else{var fromLine=getLine(doc,sFrom.line),toLine=getLine(doc,sTo.line),singleVLine=visualLine(fromLine)==visualLine(toLine),leftEnd=drawForLine(sFrom.line,sFrom.ch,singleVLine?fromLine.text.length+1:null).end,rightStart=drawForLine(sTo.line,singleVLine?0:null,sTo.ch).start;if(singleVLine)if(leftEnd.top<rightStart.top-2){add(leftEnd.right,leftEnd.top,null,leftEnd.bottom);add(leftSide,rightStart.top,rightStart.left,rightStart.bottom)}else add(leftEnd.right,leftEnd.top,rightStart.left-leftEnd.right,leftEnd.bottom);leftEnd.bottom<rightStart.top&&add(leftSide,leftEnd.bottom,null,rightStart.top)}output.appendChild(fragment)}function restartBlink(cm){if(cm.state.focused){var display=cm.display;clearInterval(display.blinker);var on=!0;display.cursorDiv.style.visibility="";cm.options.cursorBlinkRate>0?display.blinker=setInterval(function(){display.cursorDiv.style.visibility=(on=!on)?"":"hidden"},cm.options.cursorBlinkRate):cm.options.cursorBlinkRate<0&&(display.cursorDiv.style.visibility="hidden")}}function startWorker(cm,time){cm.doc.mode.startState&&cm.doc.frontier<cm.display.viewTo&&cm.state.highlight.set(time,bind(highlightWorker,cm))}function highlightWorker(cm){var doc=cm.doc;doc.frontier<doc.first&&(doc.frontier=doc.first);if(!(doc.frontier>=cm.display.viewTo)){var end=+new Date+cm.options.workTime,state=copyState(doc.mode,getStateBefore(cm,doc.frontier)),changedLines=[];doc.iter(doc.frontier,Math.min(doc.first+doc.size,cm.display.viewTo+500),function(line){if(doc.frontier>=cm.display.viewFrom){var oldStyles=line.styles,tooLong=line.text.length>cm.options.maxHighlightLength,highlighted=highlightLine(cm,line,tooLong?copyState(doc.mode,state):state,!0);line.styles=highlighted.styles;var oldCls=line.styleClasses,newCls=highlighted.classes;newCls?line.styleClasses=newCls:oldCls&&(line.styleClasses=null);for(var ischange=!oldStyles||oldStyles.length!=line.styles.length||oldCls!=newCls&&(!oldCls||!newCls||oldCls.bgClass!=newCls.bgClass||oldCls.textClass!=newCls.textClass),i=0;!ischange&&i<oldStyles.length;++i)ischange=oldStyles[i]!=line.styles[i];ischange&&changedLines.push(doc.frontier);line.stateAfter=tooLong?state:copyState(doc.mode,state)}else{line.text.length<=cm.options.maxHighlightLength&&processLine(cm,line.text,state);line.stateAfter=doc.frontier%5==0?copyState(doc.mode,state):null}++doc.frontier;if(+new Date>end){startWorker(cm,cm.options.workDelay);return!0}});changedLines.length&&runInOp(cm,function(){for(var i=0;i<changedLines.length;i++)regLineChange(cm,changedLines[i],"text")})}}function findStartLine(cm,n,precise){for(var minindent,minline,doc=cm.doc,lim=precise?-1:n-(cm.doc.mode.innerMode?1e3:100),search=n;search>lim;--search){if(search<=doc.first)return doc.first;var line=getLine(doc,search-1);if(line.stateAfter&&(!precise||search<=doc.frontier))return search;var indented=countColumn(line.text,null,cm.options.tabSize);if(null==minline||minindent>indented){minline=search-1;minindent=indented}}return minline}function getStateBefore(cm,n,precise){var doc=cm.doc,display=cm.display;if(!doc.mode.startState)return!0;var pos=findStartLine(cm,n,precise),state=pos>doc.first&&getLine(doc,pos-1).stateAfter;state=state?copyState(doc.mode,state):startState(doc.mode);doc.iter(pos,n,function(line){processLine(cm,line.text,state);var save=pos==n-1||pos%5==0||pos>=display.viewFrom&&pos<display.viewTo;line.stateAfter=save?copyState(doc.mode,state):null;++pos});precise&&(doc.frontier=pos);return state}function paddingTop(display){return display.lineSpace.offsetTop}function paddingVert(display){return display.mover.offsetHeight-display.lineSpace.offsetHeight}function paddingH(display){if(display.cachedPaddingH)return display.cachedPaddingH;var e=removeChildrenAndAdd(display.measure,elt("pre","x")),style=window.getComputedStyle?window.getComputedStyle(e):e.currentStyle,data={left:parseInt(style.paddingLeft),right:parseInt(style.paddingRight)};isNaN(data.left)||isNaN(data.right)||(display.cachedPaddingH=data);return data}function scrollGap(cm){return scrollerGap-cm.display.nativeBarWidth}function displayWidth(cm){return cm.display.scroller.clientWidth-scrollGap(cm)-cm.display.barWidth}function displayHeight(cm){return cm.display.scroller.clientHeight-scrollGap(cm)-cm.display.barHeight}function ensureLineHeights(cm,lineView,rect){var wrapping=cm.options.lineWrapping,curWidth=wrapping&&displayWidth(cm);if(!lineView.measure.heights||wrapping&&lineView.measure.width!=curWidth){var heights=lineView.measure.heights=[];if(wrapping){lineView.measure.width=curWidth;for(var rects=lineView.text.firstChild.getClientRects(),i=0;i<rects.length-1;i++){var cur=rects[i],next=rects[i+1];Math.abs(cur.bottom-next.bottom)>2&&heights.push((cur.bottom+next.top)/2-rect.top)}}heights.push(rect.bottom-rect.top)}}function mapFromLineView(lineView,line,lineN){if(lineView.line==line)return{map:lineView.measure.map,cache:lineView.measure.cache};for(var i=0;i<lineView.rest.length;i++)if(lineView.rest[i]==line)return{map:lineView.measure.maps[i],cache:lineView.measure.caches[i]};for(var i=0;i<lineView.rest.length;i++)if(lineNo(lineView.rest[i])>lineN)return{map:lineView.measure.maps[i],cache:lineView.measure.caches[i],before:!0}}function updateExternalMeasurement(cm,line){line=visualLine(line);var lineN=lineNo(line),view=cm.display.externalMeasured=new LineView(cm.doc,line,lineN);view.lineN=lineN;var built=view.built=buildLineContent(cm,view);view.text=built.pre;removeChildrenAndAdd(cm.display.lineMeasure,built.pre);return view}function measureChar(cm,line,ch,bias){return measureCharPrepared(cm,prepareMeasureForLine(cm,line),ch,bias)}function findViewForLine(cm,lineN){if(lineN>=cm.display.viewFrom&&lineN<cm.display.viewTo)return cm.display.view[findViewIndex(cm,lineN)];var ext=cm.display.externalMeasured;return ext&&lineN>=ext.lineN&&lineN<ext.lineN+ext.size?ext:void 0}function prepareMeasureForLine(cm,line){var lineN=lineNo(line),view=findViewForLine(cm,lineN);if(view&&!view.text)view=null;else if(view&&view.changes){updateLineForChanges(cm,view,lineN,getDimensions(cm));cm.curOp.forceUpdate=!0}view||(view=updateExternalMeasurement(cm,line));var info=mapFromLineView(view,line,lineN);return{line:line,view:view,rect:null,map:info.map,cache:info.cache,before:info.before,hasHeights:!1}}function measureCharPrepared(cm,prepared,ch,bias,varHeight){prepared.before&&(ch=-1);var found,key=ch+(bias||"");if(prepared.cache.hasOwnProperty(key))found=prepared.cache[key];else{prepared.rect||(prepared.rect=prepared.view.text.getBoundingClientRect());if(!prepared.hasHeights){ensureLineHeights(cm,prepared.view,prepared.rect);prepared.hasHeights=!0}found=measureCharInner(cm,prepared,ch,bias);found.bogus||(prepared.cache[key]=found)}return{left:found.left,right:found.right,top:varHeight?found.rtop:found.top,bottom:varHeight?found.rbottom:found.bottom}}function nodeAndOffsetInLineMap(map,ch,bias){for(var node,start,end,collapse,i=0;i<map.length;i+=3){var mStart=map[i],mEnd=map[i+1];if(mStart>ch){start=0;end=1;collapse="left"}else if(mEnd>ch){start=ch-mStart;end=start+1}else if(i==map.length-3||ch==mEnd&&map[i+3]>ch){end=mEnd-mStart;start=end-1;ch>=mEnd&&(collapse="right")}if(null!=start){node=map[i+2];mStart==mEnd&&bias==(node.insertLeft?"left":"right")&&(collapse=bias);if("left"==bias&&0==start)for(;i&&map[i-2]==map[i-3]&&map[i-1].insertLeft;){node=map[(i-=3)+2];collapse="left"}if("right"==bias&&start==mEnd-mStart)for(;i<map.length-3&&map[i+3]==map[i+4]&&!map[i+5].insertLeft;){node=map[(i+=3)+2];collapse="right"}break}}return{node:node,start:start,end:end,collapse:collapse,coverStart:mStart,coverEnd:mEnd}}function measureCharInner(cm,prepared,ch,bias){var rect,place=nodeAndOffsetInLineMap(prepared.map,ch,bias),node=place.node,start=place.start,end=place.end,collapse=place.collapse;if(3==node.nodeType){for(var i=0;4>i;i++){for(;start&&isExtendingChar(prepared.line.text.charAt(place.coverStart+start));)--start;for(;place.coverStart+end<place.coverEnd&&isExtendingChar(prepared.line.text.charAt(place.coverStart+end));)++end;if(ie&&9>ie_version&&0==start&&end==place.coverEnd-place.coverStart)rect=node.parentNode.getBoundingClientRect();else if(ie&&cm.options.lineWrapping){var rects=range(node,start,end).getClientRects();rect=rects.length?rects["right"==bias?rects.length-1:0]:nullRect}else rect=range(node,start,end).getBoundingClientRect()||nullRect;if(rect.left||rect.right||0==start)break;end=start;start-=1;collapse="right"}ie&&11>ie_version&&(rect=maybeUpdateRectForZooming(cm.display.measure,rect))}else{start>0&&(collapse=bias="right");var rects;rect=cm.options.lineWrapping&&(rects=node.getClientRects()).length>1?rects["right"==bias?rects.length-1:0]:node.getBoundingClientRect()}if(ie&&9>ie_version&&!start&&(!rect||!rect.left&&!rect.right)){var rSpan=node.parentNode.getClientRects()[0];rect=rSpan?{left:rSpan.left,right:rSpan.left+charWidth(cm.display),top:rSpan.top,bottom:rSpan.bottom}:nullRect}for(var rtop=rect.top-prepared.rect.top,rbot=rect.bottom-prepared.rect.top,mid=(rtop+rbot)/2,heights=prepared.view.measure.heights,i=0;i<heights.length-1&&!(mid<heights[i]);i++);var top=i?heights[i-1]:0,bot=heights[i],result={left:("right"==collapse?rect.right:rect.left)-prepared.rect.left,right:("left"==collapse?rect.left:rect.right)-prepared.rect.left,top:top,bottom:bot};rect.left||rect.right||(result.bogus=!0);if(!cm.options.singleCursorHeightPerLine){result.rtop=rtop;result.rbottom=rbot}return result}function maybeUpdateRectForZooming(measure,rect){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!hasBadZoomedRects(measure))return rect;var scaleX=screen.logicalXDPI/screen.deviceXDPI,scaleY=screen.logicalYDPI/screen.deviceYDPI;return{left:rect.left*scaleX,right:rect.right*scaleX,top:rect.top*scaleY,bottom:rect.bottom*scaleY}}function clearLineMeasurementCacheFor(lineView){if(lineView.measure){lineView.measure.cache={};lineView.measure.heights=null;if(lineView.rest)for(var i=0;i<lineView.rest.length;i++)lineView.measure.caches[i]={}}}function clearLineMeasurementCache(cm){cm.display.externalMeasure=null;removeChildren(cm.display.lineMeasure);for(var i=0;i<cm.display.view.length;i++)clearLineMeasurementCacheFor(cm.display.view[i])}function clearCaches(cm){clearLineMeasurementCache(cm);cm.display.cachedCharWidth=cm.display.cachedTextHeight=cm.display.cachedPaddingH=null;cm.options.lineWrapping||(cm.display.maxLineChanged=!0);cm.display.lineNumChars=null}function pageScrollX(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function pageScrollY(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function intoCoordSystem(cm,lineObj,rect,context){if(lineObj.widgets)for(var i=0;i<lineObj.widgets.length;++i)if(lineObj.widgets[i].above){var size=widgetHeight(lineObj.widgets[i]);rect.top+=size;rect.bottom+=size}if("line"==context)return rect;context||(context="local");var yOff=heightAtLine(lineObj);"local"==context?yOff+=paddingTop(cm.display):yOff-=cm.display.viewOffset;if("page"==context||"window"==context){var lOff=cm.display.lineSpace.getBoundingClientRect();yOff+=lOff.top+("window"==context?0:pageScrollY());var xOff=lOff.left+("window"==context?0:pageScrollX());rect.left+=xOff;rect.right+=xOff}rect.top+=yOff;rect.bottom+=yOff;return rect}function fromCoordSystem(cm,coords,context){if("div"==context)return coords;var left=coords.left,top=coords.top;if("page"==context){left-=pageScrollX();top-=pageScrollY()}else if("local"==context||!context){var localBox=cm.display.sizer.getBoundingClientRect();left+=localBox.left;top+=localBox.top}var lineSpaceBox=cm.display.lineSpace.getBoundingClientRect();return{left:left-lineSpaceBox.left,top:top-lineSpaceBox.top}}function charCoords(cm,pos,context,lineObj,bias){lineObj||(lineObj=getLine(cm.doc,pos.line));return intoCoordSystem(cm,lineObj,measureChar(cm,lineObj,pos.ch,bias),context)}function cursorCoords(cm,pos,context,lineObj,preparedMeasure,varHeight){function get(ch,right){var m=measureCharPrepared(cm,preparedMeasure,ch,right?"right":"left",varHeight);right?m.left=m.right:m.right=m.left;return intoCoordSystem(cm,lineObj,m,context)}function getBidi(ch,partPos){var part=order[partPos],right=part.level%2;if(ch==bidiLeft(part)&&partPos&&part.level<order[partPos-1].level){part=order[--partPos];ch=bidiRight(part)-(part.level%2?0:1);right=!0}else if(ch==bidiRight(part)&&partPos<order.length-1&&part.level<order[partPos+1].level){part=order[++partPos];ch=bidiLeft(part)-part.level%2;right=!1}return right&&ch==part.to&&ch>part.from?get(ch-1):get(ch,right)}lineObj=lineObj||getLine(cm.doc,pos.line);preparedMeasure||(preparedMeasure=prepareMeasureForLine(cm,lineObj));var order=getOrder(lineObj),ch=pos.ch;if(!order)return get(ch);var partPos=getBidiPartAt(order,ch),val=getBidi(ch,partPos);null!=bidiOther&&(val.other=getBidi(ch,bidiOther));return val}function estimateCoords(cm,pos){var left=0,pos=clipPos(cm.doc,pos);cm.options.lineWrapping||(left=charWidth(cm.display)*pos.ch);var lineObj=getLine(cm.doc,pos.line),top=heightAtLine(lineObj)+paddingTop(cm.display);return{left:left,right:left,top:top,bottom:top+lineObj.height}}function PosWithInfo(line,ch,outside,xRel){var pos=Pos(line,ch);pos.xRel=xRel;outside&&(pos.outside=!0);return pos}function coordsChar(cm,x,y){var doc=cm.doc;y+=cm.display.viewOffset;if(0>y)return PosWithInfo(doc.first,0,!0,-1);var lineN=lineAtHeight(doc,y),last=doc.first+doc.size-1;if(lineN>last)return PosWithInfo(doc.first+doc.size-1,getLine(doc,last).text.length,!0,1);0>x&&(x=0);for(var lineObj=getLine(doc,lineN);;){var found=coordsCharInner(cm,lineObj,lineN,x,y),merged=collapsedSpanAtEnd(lineObj),mergedPos=merged&&merged.find(0,!0);if(!merged||!(found.ch>mergedPos.from.ch||found.ch==mergedPos.from.ch&&found.xRel>0))return found;lineN=lineNo(lineObj=mergedPos.to.line)}}function coordsCharInner(cm,lineObj,lineNo,x,y){function getX(ch){var sp=cursorCoords(cm,Pos(lineNo,ch),"line",lineObj,preparedMeasure);wrongLine=!0;if(innerOff>sp.bottom)return sp.left-adjust;if(innerOff<sp.top)return sp.left+adjust;wrongLine=!1;return sp.left}var innerOff=y-heightAtLine(lineObj),wrongLine=!1,adjust=2*cm.display.wrapper.clientWidth,preparedMeasure=prepareMeasureForLine(cm,lineObj),bidi=getOrder(lineObj),dist=lineObj.text.length,from=lineLeft(lineObj),to=lineRight(lineObj),fromX=getX(from),fromOutside=wrongLine,toX=getX(to),toOutside=wrongLine;if(x>toX)return PosWithInfo(lineNo,to,toOutside,1);for(;;){if(bidi?to==from||to==moveVisually(lineObj,from,1):1>=to-from){for(var ch=fromX>x||toX-x>=x-fromX?from:to,xDiff=x-(ch==from?fromX:toX);isExtendingChar(lineObj.text.charAt(ch));)++ch;var pos=PosWithInfo(lineNo,ch,ch==from?fromOutside:toOutside,-1>xDiff?-1:xDiff>1?1:0);return pos}var step=Math.ceil(dist/2),middle=from+step;if(bidi){middle=from;for(var i=0;step>i;++i)middle=moveVisually(lineObj,middle,1)}var middleX=getX(middle);if(middleX>x){to=middle;toX=middleX;(toOutside=wrongLine)&&(toX+=1e3);dist=step}else{from=middle;fromX=middleX;fromOutside=wrongLine;dist-=step}}}function textHeight(display){if(null!=display.cachedTextHeight)return display.cachedTextHeight;if(null==measureText){measureText=elt("pre");for(var i=0;49>i;++i){measureText.appendChild(document.createTextNode("x"));measureText.appendChild(elt("br"))}measureText.appendChild(document.createTextNode("x"))}removeChildrenAndAdd(display.measure,measureText);var height=measureText.offsetHeight/50;height>3&&(display.cachedTextHeight=height);removeChildren(display.measure);return height||1}function charWidth(display){if(null!=display.cachedCharWidth)return display.cachedCharWidth;var anchor=elt("span","xxxxxxxxxx"),pre=elt("pre",[anchor]);removeChildrenAndAdd(display.measure,pre);var rect=anchor.getBoundingClientRect(),width=(rect.right-rect.left)/10;width>2&&(display.cachedCharWidth=width);return width||10}function startOperation(cm){cm.curOp={cm:cm,viewChanged:!1,startHeight:cm.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++nextOpId};operationGroup?operationGroup.ops.push(cm.curOp):cm.curOp.ownsGroup=operationGroup={ops:[cm.curOp],delayedCallbacks:[]}}function fireCallbacksForOps(group){var callbacks=group.delayedCallbacks,i=0;do{for(;i<callbacks.length;i++)callbacks[i].call(null);for(var j=0;j<group.ops.length;j++){var op=group.ops[j];if(op.cursorActivityHandlers)for(;op.cursorActivityCalled<op.cursorActivityHandlers.length;)op.cursorActivityHandlers[op.cursorActivityCalled++].call(null,op.cm)}}while(i<callbacks.length)}function endOperation(cm){var op=cm.curOp,group=op.ownsGroup;if(group)try{fireCallbacksForOps(group)}finally{operationGroup=null;for(var i=0;i<group.ops.length;i++)group.ops[i].cm.curOp=null;endOperations(group)}}function endOperations(group){for(var ops=group.ops,i=0;i<ops.length;i++)endOperation_R1(ops[i]);for(var i=0;i<ops.length;i++)endOperation_W1(ops[i]);for(var i=0;i<ops.length;i++)endOperation_R2(ops[i]);for(var i=0;i<ops.length;i++)endOperation_W2(ops[i]);for(var i=0;i<ops.length;i++)endOperation_finish(ops[i])}function endOperation_R1(op){var cm=op.cm,display=cm.display;maybeClipScrollbars(cm);op.updateMaxLine&&findMaxLine(cm);op.mustUpdate=op.viewChanged||op.forceUpdate||null!=op.scrollTop||op.scrollToPos&&(op.scrollToPos.from.line<display.viewFrom||op.scrollToPos.to.line>=display.viewTo)||display.maxLineChanged&&cm.options.lineWrapping;op.update=op.mustUpdate&&new DisplayUpdate(cm,op.mustUpdate&&{top:op.scrollTop,ensure:op.scrollToPos},op.forceUpdate)}function endOperation_W1(op){op.updatedDisplay=op.mustUpdate&&updateDisplayIfNeeded(op.cm,op.update)}function endOperation_R2(op){var cm=op.cm,display=cm.display;op.updatedDisplay&&updateHeightsInViewport(cm);op.barMeasure=measureForScrollbars(cm);if(display.maxLineChanged&&!cm.options.lineWrapping){op.adjustWidthTo=measureChar(cm,display.maxLine,display.maxLine.text.length).left+3;cm.display.sizerWidth=op.adjustWidthTo;op.barMeasure.scrollWidth=Math.max(display.scroller.clientWidth,display.sizer.offsetLeft+op.adjustWidthTo+scrollGap(cm)+cm.display.barWidth);op.maxScrollLeft=Math.max(0,display.sizer.offsetLeft+op.adjustWidthTo-displayWidth(cm))}(op.updatedDisplay||op.selectionChanged)&&(op.preparedSelection=display.input.prepareSelection())}function endOperation_W2(op){var cm=op.cm;if(null!=op.adjustWidthTo){cm.display.sizer.style.minWidth=op.adjustWidthTo+"px";op.maxScrollLeft<cm.doc.scrollLeft&&setScrollLeft(cm,Math.min(cm.display.scroller.scrollLeft,op.maxScrollLeft),!0);cm.display.maxLineChanged=!1}op.preparedSelection&&cm.display.input.showSelection(op.preparedSelection);op.updatedDisplay&&setDocumentHeight(cm,op.barMeasure);(op.updatedDisplay||op.startHeight!=cm.doc.height)&&updateScrollbars(cm,op.barMeasure);op.selectionChanged&&restartBlink(cm);cm.state.focused&&op.updateInput&&cm.display.input.reset(op.typing);op.focus&&op.focus==activeElt()&&ensureFocus(op.cm)}function endOperation_finish(op){var cm=op.cm,display=cm.display,doc=cm.doc;op.updatedDisplay&&postUpdateDisplay(cm,op.update);null==display.wheelStartX||null==op.scrollTop&&null==op.scrollLeft&&!op.scrollToPos||(display.wheelStartX=display.wheelStartY=null);if(null!=op.scrollTop&&(display.scroller.scrollTop!=op.scrollTop||op.forceScroll)){doc.scrollTop=Math.max(0,Math.min(display.scroller.scrollHeight-display.scroller.clientHeight,op.scrollTop));display.scrollbars.setScrollTop(doc.scrollTop);display.scroller.scrollTop=doc.scrollTop}if(null!=op.scrollLeft&&(display.scroller.scrollLeft!=op.scrollLeft||op.forceScroll)){doc.scrollLeft=Math.max(0,Math.min(display.scroller.scrollWidth-displayWidth(cm),op.scrollLeft));display.scrollbars.setScrollLeft(doc.scrollLeft);display.scroller.scrollLeft=doc.scrollLeft;alignHorizontally(cm)}if(op.scrollToPos){var coords=scrollPosIntoView(cm,clipPos(doc,op.scrollToPos.from),clipPos(doc,op.scrollToPos.to),op.scrollToPos.margin);op.scrollToPos.isCursor&&cm.state.focused&&maybeScrollWindow(cm,coords)}var hidden=op.maybeHiddenMarkers,unhidden=op.maybeUnhiddenMarkers;if(hidden)for(var i=0;i<hidden.length;++i)hidden[i].lines.length||signal(hidden[i],"hide");if(unhidden)for(var i=0;i<unhidden.length;++i)unhidden[i].lines.length&&signal(unhidden[i],"unhide");display.wrapper.offsetHeight&&(doc.scrollTop=cm.display.scroller.scrollTop);op.changeObjs&&signal(cm,"changes",cm,op.changeObjs);op.update&&op.update.finish()}function runInOp(cm,f){if(cm.curOp)return f();startOperation(cm);try{return f()}finally{endOperation(cm)}}function operation(cm,f){return function(){if(cm.curOp)return f.apply(cm,arguments);startOperation(cm);try{return f.apply(cm,arguments)}finally{endOperation(cm)}}}function methodOp(f){return function(){if(this.curOp)return f.apply(this,arguments);startOperation(this);try{return f.apply(this,arguments)}finally{endOperation(this)}}}function docMethodOp(f){return function(){var cm=this.cm;if(!cm||cm.curOp)return f.apply(this,arguments);startOperation(cm);try{return f.apply(this,arguments)}finally{endOperation(cm)}}}function LineView(doc,line,lineN){this.line=line;this.rest=visualLineContinued(line);this.size=this.rest?lineNo(lst(this.rest))-lineN+1:1;this.node=this.text=null;this.hidden=lineIsHidden(doc,line)}function buildViewArray(cm,from,to){for(var nextPos,array=[],pos=from;to>pos;pos=nextPos){var view=new LineView(cm.doc,getLine(cm.doc,pos),pos);nextPos=pos+view.size;array.push(view)}return array}function regChange(cm,from,to,lendiff){null==from&&(from=cm.doc.first);null==to&&(to=cm.doc.first+cm.doc.size);lendiff||(lendiff=0);var display=cm.display;lendiff&&to<display.viewTo&&(null==display.updateLineNumbers||display.updateLineNumbers>from)&&(display.updateLineNumbers=from);cm.curOp.viewChanged=!0;if(from>=display.viewTo)sawCollapsedSpans&&visualLineNo(cm.doc,from)<display.viewTo&&resetView(cm);else if(to<=display.viewFrom)if(sawCollapsedSpans&&visualLineEndNo(cm.doc,to+lendiff)>display.viewFrom)resetView(cm);else{display.viewFrom+=lendiff;display.viewTo+=lendiff}else if(from<=display.viewFrom&&to>=display.viewTo)resetView(cm);else if(from<=display.viewFrom){var cut=viewCuttingPoint(cm,to,to+lendiff,1);if(cut){display.view=display.view.slice(cut.index);display.viewFrom=cut.lineN;display.viewTo+=lendiff}else resetView(cm)}else if(to>=display.viewTo){var cut=viewCuttingPoint(cm,from,from,-1);if(cut){display.view=display.view.slice(0,cut.index);display.viewTo=cut.lineN}else resetView(cm)}else{var cutTop=viewCuttingPoint(cm,from,from,-1),cutBot=viewCuttingPoint(cm,to,to+lendiff,1);if(cutTop&&cutBot){display.view=display.view.slice(0,cutTop.index).concat(buildViewArray(cm,cutTop.lineN,cutBot.lineN)).concat(display.view.slice(cutBot.index));display.viewTo+=lendiff}else resetView(cm)}var ext=display.externalMeasured;ext&&(to<ext.lineN?ext.lineN+=lendiff:from<ext.lineN+ext.size&&(display.externalMeasured=null))}function regLineChange(cm,line,type){cm.curOp.viewChanged=!0;var display=cm.display,ext=cm.display.externalMeasured;ext&&line>=ext.lineN&&line<ext.lineN+ext.size&&(display.externalMeasured=null);if(!(line<display.viewFrom||line>=display.viewTo)){var lineView=display.view[findViewIndex(cm,line)];if(null!=lineView.node){var arr=lineView.changes||(lineView.changes=[]);-1==indexOf(arr,type)&&arr.push(type)}}}function resetView(cm){cm.display.viewFrom=cm.display.viewTo=cm.doc.first;cm.display.view=[];cm.display.viewOffset=0}function findViewIndex(cm,n){if(n>=cm.display.viewTo)return null;n-=cm.display.viewFrom;if(0>n)return null;for(var view=cm.display.view,i=0;i<view.length;i++){n-=view[i].size;if(0>n)return i}}function viewCuttingPoint(cm,oldN,newN,dir){var diff,index=findViewIndex(cm,oldN),view=cm.display.view;if(!sawCollapsedSpans||newN==cm.doc.first+cm.doc.size)return{index:index,lineN:newN};for(var i=0,n=cm.display.viewFrom;index>i;i++)n+=view[i].size;if(n!=oldN){if(dir>0){if(index==view.length-1)return null;diff=n+view[index].size-oldN;index++}else diff=n-oldN;oldN+=diff;newN+=diff}for(;visualLineNo(cm.doc,newN)!=newN;){if(index==(0>dir?0:view.length-1))return null;newN+=dir*view[index-(0>dir?1:0)].size;index+=dir}return{index:index,lineN:newN}}function adjustView(cm,from,to){var display=cm.display,view=display.view;if(0==view.length||from>=display.viewTo||to<=display.viewFrom){display.view=buildViewArray(cm,from,to);display.viewFrom=from}else{display.viewFrom>from?display.view=buildViewArray(cm,from,display.viewFrom).concat(display.view):display.viewFrom<from&&(display.view=display.view.slice(findViewIndex(cm,from)));display.viewFrom=from;display.viewTo<to?display.view=display.view.concat(buildViewArray(cm,display.viewTo,to)):display.viewTo>to&&(display.view=display.view.slice(0,findViewIndex(cm,to)))}display.viewTo=to}function countDirtyView(cm){for(var view=cm.display.view,dirty=0,i=0;i<view.length;i++){
3
- var lineView=view[i];lineView.hidden||lineView.node&&!lineView.changes||++dirty}return dirty}function registerEventHandlers(cm){function finishTouch(){if(d.activeTouch){touchFinished=setTimeout(function(){d.activeTouch=null},1e3);prevTouch=d.activeTouch;prevTouch.end=+new Date}}function isMouseLikeTouchEvent(e){if(1!=e.touches.length)return!1;var touch=e.touches[0];return touch.radiusX<=1&&touch.radiusY<=1}function farAway(touch,other){if(null==other.left)return!0;var dx=other.left-touch.left,dy=other.top-touch.top;return dx*dx+dy*dy>400}var d=cm.display;on(d.scroller,"mousedown",operation(cm,onMouseDown));ie&&11>ie_version?on(d.scroller,"dblclick",operation(cm,function(e){if(!signalDOMEvent(cm,e)){var pos=posFromMouse(cm,e);if(pos&&!clickInGutter(cm,e)&&!eventInWidget(cm.display,e)){e_preventDefault(e);var word=cm.findWordAt(pos);extendSelection(cm.doc,word.anchor,word.head)}}})):on(d.scroller,"dblclick",function(e){signalDOMEvent(cm,e)||e_preventDefault(e)});captureRightClick||on(d.scroller,"contextmenu",function(e){onContextMenu(cm,e)});var touchFinished,prevTouch={end:0};on(d.scroller,"touchstart",function(e){if(!isMouseLikeTouchEvent(e)){clearTimeout(touchFinished);var now=+new Date;d.activeTouch={start:now,moved:!1,prev:now-prevTouch.end<=300?prevTouch:null};if(1==e.touches.length){d.activeTouch.left=e.touches[0].pageX;d.activeTouch.top=e.touches[0].pageY}}});on(d.scroller,"touchmove",function(){d.activeTouch&&(d.activeTouch.moved=!0)});on(d.scroller,"touchend",function(e){var touch=d.activeTouch;if(touch&&!eventInWidget(d,e)&&null!=touch.left&&!touch.moved&&new Date-touch.start<300){var range,pos=cm.coordsChar(d.activeTouch,"page");range=!touch.prev||farAway(touch,touch.prev)?new Range(pos,pos):!touch.prev.prev||farAway(touch,touch.prev.prev)?cm.findWordAt(pos):new Range(Pos(pos.line,0),clipPos(cm.doc,Pos(pos.line+1,0)));cm.setSelection(range.anchor,range.head);cm.focus();e_preventDefault(e)}finishTouch()});on(d.scroller,"touchcancel",finishTouch);on(d.scroller,"scroll",function(){if(d.scroller.clientHeight){setScrollTop(cm,d.scroller.scrollTop);setScrollLeft(cm,d.scroller.scrollLeft,!0);signal(cm,"scroll",cm)}});on(d.scroller,"mousewheel",function(e){onScrollWheel(cm,e)});on(d.scroller,"DOMMouseScroll",function(e){onScrollWheel(cm,e)});on(d.wrapper,"scroll",function(){d.wrapper.scrollTop=d.wrapper.scrollLeft=0});d.dragFunctions={enter:function(e){signalDOMEvent(cm,e)||e_stop(e)},over:function(e){if(!signalDOMEvent(cm,e)){onDragOver(cm,e);e_stop(e)}},start:function(e){onDragStart(cm,e)},drop:operation(cm,onDrop),leave:function(){clearDragCursor(cm)}};var inp=d.input.getField();on(inp,"keyup",function(e){onKeyUp.call(cm,e)});on(inp,"keydown",operation(cm,onKeyDown));on(inp,"keypress",operation(cm,onKeyPress));on(inp,"focus",bind(onFocus,cm));on(inp,"blur",bind(onBlur,cm))}function dragDropChanged(cm,value,old){var wasOn=old&&old!=CodeMirror.Init;if(!value!=!wasOn){var funcs=cm.display.dragFunctions,toggle=value?on:off;toggle(cm.display.scroller,"dragstart",funcs.start);toggle(cm.display.scroller,"dragenter",funcs.enter);toggle(cm.display.scroller,"dragover",funcs.over);toggle(cm.display.scroller,"dragleave",funcs.leave);toggle(cm.display.scroller,"drop",funcs.drop)}}function onResize(cm){var d=cm.display;if(d.lastWrapHeight!=d.wrapper.clientHeight||d.lastWrapWidth!=d.wrapper.clientWidth){d.cachedCharWidth=d.cachedTextHeight=d.cachedPaddingH=null;d.scrollbarsClipped=!1;cm.setSize()}}function eventInWidget(display,e){for(var n=e_target(e);n!=display.wrapper;n=n.parentNode)if(!n||1==n.nodeType&&"true"==n.getAttribute("cm-ignore-events")||n.parentNode==display.sizer&&n!=display.mover)return!0}function posFromMouse(cm,e,liberal,forRect){var display=cm.display;if(!liberal&&"true"==e_target(e).getAttribute("cm-not-content"))return null;var x,y,space=display.lineSpace.getBoundingClientRect();try{x=e.clientX-space.left;y=e.clientY-space.top}catch(e){return null}var line,coords=coordsChar(cm,x,y);if(forRect&&1==coords.xRel&&(line=getLine(cm.doc,coords.line).text).length==coords.ch){var colDiff=countColumn(line,line.length,cm.options.tabSize)-line.length;coords=Pos(coords.line,Math.max(0,Math.round((x-paddingH(cm.display).left)/charWidth(cm.display))-colDiff))}return coords}function onMouseDown(e){var cm=this,display=cm.display;if(!(display.activeTouch&&display.input.supportsTouch()||signalDOMEvent(cm,e))){display.shift=e.shiftKey;if(eventInWidget(display,e)){if(!webkit){display.scroller.draggable=!1;setTimeout(function(){display.scroller.draggable=!0},100)}}else if(!clickInGutter(cm,e)){var start=posFromMouse(cm,e);window.focus();switch(e_button(e)){case 1:cm.state.selectingText?cm.state.selectingText(e):start?leftButtonDown(cm,e,start):e_target(e)==display.scroller&&e_preventDefault(e);break;case 2:webkit&&(cm.state.lastMiddleDown=+new Date);start&&extendSelection(cm.doc,start);setTimeout(function(){display.input.focus()},20);e_preventDefault(e);break;case 3:captureRightClick?onContextMenu(cm,e):delayBlurEvent(cm)}}}}function leftButtonDown(cm,e,start){ie?setTimeout(bind(ensureFocus,cm),0):cm.curOp.focus=activeElt();var type,now=+new Date;if(lastDoubleClick&&lastDoubleClick.time>now-400&&0==cmp(lastDoubleClick.pos,start))type="triple";else if(lastClick&&lastClick.time>now-400&&0==cmp(lastClick.pos,start)){type="double";lastDoubleClick={time:now,pos:start}}else{type="single";lastClick={time:now,pos:start}}var contained,sel=cm.doc.sel,modifier=mac?e.metaKey:e.ctrlKey;cm.options.dragDrop&&dragAndDrop&&!isReadOnly(cm)&&"single"==type&&(contained=sel.contains(start))>-1&&(cmp((contained=sel.ranges[contained]).from(),start)<0||start.xRel>0)&&(cmp(contained.to(),start)>0||start.xRel<0)?leftButtonStartDrag(cm,e,start,modifier):leftButtonSelect(cm,e,start,type,modifier)}function leftButtonStartDrag(cm,e,start,modifier){var display=cm.display,startTime=+new Date,dragEnd=operation(cm,function(e2){webkit&&(display.scroller.draggable=!1);cm.state.draggingText=!1;off(document,"mouseup",dragEnd);off(display.scroller,"drop",dragEnd);if(Math.abs(e.clientX-e2.clientX)+Math.abs(e.clientY-e2.clientY)<10){e_preventDefault(e2);!modifier&&+new Date-200<startTime&&extendSelection(cm.doc,start);webkit||ie&&9==ie_version?setTimeout(function(){document.body.focus();display.input.focus()},20):display.input.focus()}});webkit&&(display.scroller.draggable=!0);cm.state.draggingText=dragEnd;display.scroller.dragDrop&&display.scroller.dragDrop();on(document,"mouseup",dragEnd);on(display.scroller,"drop",dragEnd)}function leftButtonSelect(cm,e,start,type,addNew){function extendTo(pos){if(0!=cmp(lastPos,pos)){lastPos=pos;if("rect"==type){for(var ranges=[],tabSize=cm.options.tabSize,startCol=countColumn(getLine(doc,start.line).text,start.ch,tabSize),posCol=countColumn(getLine(doc,pos.line).text,pos.ch,tabSize),left=Math.min(startCol,posCol),right=Math.max(startCol,posCol),line=Math.min(start.line,pos.line),end=Math.min(cm.lastLine(),Math.max(start.line,pos.line));end>=line;line++){var text=getLine(doc,line).text,leftPos=findColumn(text,left,tabSize);left==right?ranges.push(new Range(Pos(line,leftPos),Pos(line,leftPos))):text.length>leftPos&&ranges.push(new Range(Pos(line,leftPos),Pos(line,findColumn(text,right,tabSize))))}ranges.length||ranges.push(new Range(start,start));setSelection(doc,normalizeSelection(startSel.ranges.slice(0,ourIndex).concat(ranges),ourIndex),{origin:"*mouse",scroll:!1});cm.scrollIntoView(pos)}else{var oldRange=ourRange,anchor=oldRange.anchor,head=pos;if("single"!=type){if("double"==type)var range=cm.findWordAt(pos);else var range=new Range(Pos(pos.line,0),clipPos(doc,Pos(pos.line+1,0)));if(cmp(range.anchor,anchor)>0){head=range.head;anchor=minPos(oldRange.from(),range.anchor)}else{head=range.anchor;anchor=maxPos(oldRange.to(),range.head)}}var ranges=startSel.ranges.slice(0);ranges[ourIndex]=new Range(clipPos(doc,anchor),head);setSelection(doc,normalizeSelection(ranges,ourIndex),sel_mouse)}}}function extend(e){var curCount=++counter,cur=posFromMouse(cm,e,!0,"rect"==type);if(cur)if(0!=cmp(cur,lastPos)){cm.curOp.focus=activeElt();extendTo(cur);var visible=visibleLines(display,doc);(cur.line>=visible.to||cur.line<visible.from)&&setTimeout(operation(cm,function(){counter==curCount&&extend(e)}),150)}else{var outside=e.clientY<editorSize.top?-20:e.clientY>editorSize.bottom?20:0;outside&&setTimeout(operation(cm,function(){if(counter==curCount){display.scroller.scrollTop+=outside;extend(e)}}),50)}}function done(e){cm.state.selectingText=!1;counter=1/0;e_preventDefault(e);display.input.focus();off(document,"mousemove",move);off(document,"mouseup",up);doc.history.lastSelOrigin=null}var display=cm.display,doc=cm.doc;e_preventDefault(e);var ourRange,ourIndex,startSel=doc.sel,ranges=startSel.ranges;if(addNew&&!e.shiftKey){ourIndex=doc.sel.contains(start);ourRange=ourIndex>-1?ranges[ourIndex]:new Range(start,start)}else{ourRange=doc.sel.primary();ourIndex=doc.sel.primIndex}if(e.altKey){type="rect";addNew||(ourRange=new Range(start,start));start=posFromMouse(cm,e,!0,!0);ourIndex=-1}else if("double"==type){var word=cm.findWordAt(start);ourRange=cm.display.shift||doc.extend?extendRange(doc,ourRange,word.anchor,word.head):word}else if("triple"==type){var line=new Range(Pos(start.line,0),clipPos(doc,Pos(start.line+1,0)));ourRange=cm.display.shift||doc.extend?extendRange(doc,ourRange,line.anchor,line.head):line}else ourRange=extendRange(doc,ourRange,start);if(addNew)if(-1==ourIndex){ourIndex=ranges.length;setSelection(doc,normalizeSelection(ranges.concat([ourRange]),ourIndex),{scroll:!1,origin:"*mouse"})}else if(ranges.length>1&&ranges[ourIndex].empty()&&"single"==type&&!e.shiftKey){setSelection(doc,normalizeSelection(ranges.slice(0,ourIndex).concat(ranges.slice(ourIndex+1)),0),{scroll:!1,origin:"*mouse"});startSel=doc.sel}else replaceOneSelection(doc,ourIndex,ourRange,sel_mouse);else{ourIndex=0;setSelection(doc,new Selection([ourRange],0),sel_mouse);startSel=doc.sel}var lastPos=start,editorSize=display.wrapper.getBoundingClientRect(),counter=0,move=operation(cm,function(e){e_button(e)?extend(e):done(e)}),up=operation(cm,done);cm.state.selectingText=up;on(document,"mousemove",move);on(document,"mouseup",up)}function gutterEvent(cm,e,type,prevent,signalfn){try{var mX=e.clientX,mY=e.clientY}catch(e){return!1}if(mX>=Math.floor(cm.display.gutters.getBoundingClientRect().right))return!1;prevent&&e_preventDefault(e);var display=cm.display,lineBox=display.lineDiv.getBoundingClientRect();if(mY>lineBox.bottom||!hasHandler(cm,type))return e_defaultPrevented(e);mY-=lineBox.top-display.viewOffset;for(var i=0;i<cm.options.gutters.length;++i){var g=display.gutters.childNodes[i];if(g&&g.getBoundingClientRect().right>=mX){var line=lineAtHeight(cm.doc,mY),gutter=cm.options.gutters[i];signalfn(cm,type,cm,line,gutter,e);return e_defaultPrevented(e)}}}function clickInGutter(cm,e){return gutterEvent(cm,e,"gutterClick",!0,signalLater)}function onDrop(e){var cm=this;clearDragCursor(cm);if(!signalDOMEvent(cm,e)&&!eventInWidget(cm.display,e)){e_preventDefault(e);ie&&(lastDrop=+new Date);var pos=posFromMouse(cm,e,!0),files=e.dataTransfer.files;if(pos&&!isReadOnly(cm))if(files&&files.length&&window.FileReader&&window.File)for(var n=files.length,text=Array(n),read=0,loadFile=function(file,i){if(!cm.options.allowDropFileTypes||-1!=indexOf(cm.options.allowDropFileTypes,file.type)){var reader=new FileReader;reader.onload=operation(cm,function(){var content=reader.result;/[\x00-\x08\x0e-\x1f]{2}/.test(content)&&(content="");text[i]=content;if(++read==n){pos=clipPos(cm.doc,pos);var change={from:pos,to:pos,text:cm.doc.splitLines(text.join(cm.doc.lineSeparator())),origin:"paste"};makeChange(cm.doc,change);setSelectionReplaceHistory(cm.doc,simpleSelection(pos,changeEnd(change)))}});reader.readAsText(file)}},i=0;n>i;++i)loadFile(files[i],i);else{if(cm.state.draggingText&&cm.doc.sel.contains(pos)>-1){cm.state.draggingText(e);setTimeout(function(){cm.display.input.focus()},20);return}try{var text=e.dataTransfer.getData("Text");if(text){if(cm.state.draggingText&&!(mac?e.altKey:e.ctrlKey))var selected=cm.listSelections();setSelectionNoUndo(cm.doc,simpleSelection(pos,pos));if(selected)for(var i=0;i<selected.length;++i)replaceRange(cm.doc,"",selected[i].anchor,selected[i].head,"drag");cm.replaceSelection(text,"around","paste");cm.display.input.focus()}}catch(e){}}}}function onDragStart(cm,e){if(ie&&(!cm.state.draggingText||+new Date-lastDrop<100))e_stop(e);else if(!signalDOMEvent(cm,e)&&!eventInWidget(cm.display,e)){e.dataTransfer.setData("Text",cm.getSelection());if(e.dataTransfer.setDragImage&&!safari){var img=elt("img",null,null,"position: fixed; left: 0; top: 0;");img.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";if(presto){img.width=img.height=1;cm.display.wrapper.appendChild(img);img._top=img.offsetTop}e.dataTransfer.setDragImage(img,0,0);presto&&img.parentNode.removeChild(img)}}}function onDragOver(cm,e){var pos=posFromMouse(cm,e);if(pos){var frag=document.createDocumentFragment();drawSelectionCursor(cm,pos,frag);if(!cm.display.dragCursor){cm.display.dragCursor=elt("div",null,"CodeMirror-cursors CodeMirror-dragcursors");cm.display.lineSpace.insertBefore(cm.display.dragCursor,cm.display.cursorDiv)}removeChildrenAndAdd(cm.display.dragCursor,frag)}}function clearDragCursor(cm){if(cm.display.dragCursor){cm.display.lineSpace.removeChild(cm.display.dragCursor);cm.display.dragCursor=null}}function setScrollTop(cm,val){if(!(Math.abs(cm.doc.scrollTop-val)<2)){cm.doc.scrollTop=val;gecko||updateDisplaySimple(cm,{top:val});cm.display.scroller.scrollTop!=val&&(cm.display.scroller.scrollTop=val);cm.display.scrollbars.setScrollTop(val);gecko&&updateDisplaySimple(cm);startWorker(cm,100)}}function setScrollLeft(cm,val,isScroller){if(!(isScroller?val==cm.doc.scrollLeft:Math.abs(cm.doc.scrollLeft-val)<2)){val=Math.min(val,cm.display.scroller.scrollWidth-cm.display.scroller.clientWidth);cm.doc.scrollLeft=val;alignHorizontally(cm);cm.display.scroller.scrollLeft!=val&&(cm.display.scroller.scrollLeft=val);cm.display.scrollbars.setScrollLeft(val)}}function onScrollWheel(cm,e){var delta=wheelEventDelta(e),dx=delta.x,dy=delta.y,display=cm.display,scroll=display.scroller,canScrollX=scroll.scrollWidth>scroll.clientWidth,canScrollY=scroll.scrollHeight>scroll.clientHeight;if(dx&&canScrollX||dy&&canScrollY){if(dy&&mac&&webkit)outer:for(var cur=e.target,view=display.view;cur!=scroll;cur=cur.parentNode)for(var i=0;i<view.length;i++)if(view[i].node==cur){cm.display.currentWheelTarget=cur;break outer}if(!dx||gecko||presto||null==wheelPixelsPerUnit){if(dy&&null!=wheelPixelsPerUnit){var pixels=dy*wheelPixelsPerUnit,top=cm.doc.scrollTop,bot=top+display.wrapper.clientHeight;0>pixels?top=Math.max(0,top+pixels-50):bot=Math.min(cm.doc.height,bot+pixels+50);updateDisplaySimple(cm,{top:top,bottom:bot})}if(20>wheelSamples)if(null==display.wheelStartX){display.wheelStartX=scroll.scrollLeft;display.wheelStartY=scroll.scrollTop;display.wheelDX=dx;display.wheelDY=dy;setTimeout(function(){if(null!=display.wheelStartX){var movedX=scroll.scrollLeft-display.wheelStartX,movedY=scroll.scrollTop-display.wheelStartY,sample=movedY&&display.wheelDY&&movedY/display.wheelDY||movedX&&display.wheelDX&&movedX/display.wheelDX;display.wheelStartX=display.wheelStartY=null;if(sample){wheelPixelsPerUnit=(wheelPixelsPerUnit*wheelSamples+sample)/(wheelSamples+1);++wheelSamples}}},200)}else{display.wheelDX+=dx;display.wheelDY+=dy}}else{dy&&canScrollY&&setScrollTop(cm,Math.max(0,Math.min(scroll.scrollTop+dy*wheelPixelsPerUnit,scroll.scrollHeight-scroll.clientHeight)));setScrollLeft(cm,Math.max(0,Math.min(scroll.scrollLeft+dx*wheelPixelsPerUnit,scroll.scrollWidth-scroll.clientWidth)));(!dy||dy&&canScrollY)&&e_preventDefault(e);display.wheelStartX=null}}}function doHandleBinding(cm,bound,dropShift){if("string"==typeof bound){bound=commands[bound];if(!bound)return!1}cm.display.input.ensurePolled();var prevShift=cm.display.shift,done=!1;try{isReadOnly(cm)&&(cm.state.suppressEdits=!0);dropShift&&(cm.display.shift=!1);done=bound(cm)!=Pass}finally{cm.display.shift=prevShift;cm.state.suppressEdits=!1}return done}function lookupKeyForEditor(cm,name,handle){for(var i=0;i<cm.state.keyMaps.length;i++){var result=lookupKey(name,cm.state.keyMaps[i],handle,cm);if(result)return result}return cm.options.extraKeys&&lookupKey(name,cm.options.extraKeys,handle,cm)||lookupKey(name,cm.options.keyMap,handle,cm)}function dispatchKey(cm,name,e,handle){var seq=cm.state.keySeq;if(seq){if(isModifierKey(name))return"handled";stopSeq.set(50,function(){if(cm.state.keySeq==seq){cm.state.keySeq=null;cm.display.input.reset()}});name=seq+" "+name}var result=lookupKeyForEditor(cm,name,handle);"multi"==result&&(cm.state.keySeq=name);"handled"==result&&signalLater(cm,"keyHandled",cm,name,e);if("handled"==result||"multi"==result){e_preventDefault(e);restartBlink(cm)}if(seq&&!result&&/\'$/.test(name)){e_preventDefault(e);return!0}return!!result}function handleKeyBinding(cm,e){var name=keyName(e,!0);return name?e.shiftKey&&!cm.state.keySeq?dispatchKey(cm,"Shift-"+name,e,function(b){return doHandleBinding(cm,b,!0)})||dispatchKey(cm,name,e,function(b){return("string"==typeof b?/^go[A-Z]/.test(b):b.motion)?doHandleBinding(cm,b):void 0}):dispatchKey(cm,name,e,function(b){return doHandleBinding(cm,b)}):!1}function handleCharBinding(cm,e,ch){return dispatchKey(cm,"'"+ch+"'",e,function(b){return doHandleBinding(cm,b,!0)})}function onKeyDown(e){var cm=this;cm.curOp.focus=activeElt();if(!signalDOMEvent(cm,e)){ie&&11>ie_version&&27==e.keyCode&&(e.returnValue=!1);var code=e.keyCode;cm.display.shift=16==code||e.shiftKey;var handled=handleKeyBinding(cm,e);if(presto){lastStoppedKey=handled?code:null;!handled&&88==code&&!hasCopyEvent&&(mac?e.metaKey:e.ctrlKey)&&cm.replaceSelection("",null,"cut")}18!=code||/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className)||showCrossHair(cm)}}function showCrossHair(cm){function up(e){if(18==e.keyCode||!e.altKey){rmClass(lineDiv,"CodeMirror-crosshair");off(document,"keyup",up);off(document,"mouseover",up)}}var lineDiv=cm.display.lineDiv;addClass(lineDiv,"CodeMirror-crosshair");on(document,"keyup",up);on(document,"mouseover",up)}function onKeyUp(e){16==e.keyCode&&(this.doc.sel.shift=!1);signalDOMEvent(this,e)}function onKeyPress(e){var cm=this;if(!(eventInWidget(cm.display,e)||signalDOMEvent(cm,e)||e.ctrlKey&&!e.altKey||mac&&e.metaKey)){var keyCode=e.keyCode,charCode=e.charCode;if(presto&&keyCode==lastStoppedKey){lastStoppedKey=null;e_preventDefault(e)}else if(!presto||e.which&&!(e.which<10)||!handleKeyBinding(cm,e)){var ch=String.fromCharCode(null==charCode?keyCode:charCode);handleCharBinding(cm,e,ch)||cm.display.input.onKeyPress(e)}}}function delayBlurEvent(cm){cm.state.delayingBlurEvent=!0;setTimeout(function(){if(cm.state.delayingBlurEvent){cm.state.delayingBlurEvent=!1;onBlur(cm)}},100)}function onFocus(cm){cm.state.delayingBlurEvent&&(cm.state.delayingBlurEvent=!1);if("nocursor"!=cm.options.readOnly){if(!cm.state.focused){signal(cm,"focus",cm);cm.state.focused=!0;addClass(cm.display.wrapper,"CodeMirror-focused");if(!cm.curOp&&cm.display.selForContextMenu!=cm.doc.sel){cm.display.input.reset();webkit&&setTimeout(function(){cm.display.input.reset(!0)},20)}cm.display.input.receivedFocus()}restartBlink(cm)}}function onBlur(cm){if(!cm.state.delayingBlurEvent){if(cm.state.focused){signal(cm,"blur",cm);cm.state.focused=!1;rmClass(cm.display.wrapper,"CodeMirror-focused")}clearInterval(cm.display.blinker);setTimeout(function(){cm.state.focused||(cm.display.shift=!1)},150)}}function onContextMenu(cm,e){eventInWidget(cm.display,e)||contextMenuInGutter(cm,e)||signalDOMEvent(cm,e,"contextmenu")||cm.display.input.onContextMenu(e)}function contextMenuInGutter(cm,e){return hasHandler(cm,"gutterContextMenu")?gutterEvent(cm,e,"gutterContextMenu",!1,signal):!1}function adjustForChange(pos,change){if(cmp(pos,change.from)<0)return pos;if(cmp(pos,change.to)<=0)return changeEnd(change);var line=pos.line+change.text.length-(change.to.line-change.from.line)-1,ch=pos.ch;pos.line==change.to.line&&(ch+=changeEnd(change).ch-change.to.ch);return Pos(line,ch)}function computeSelAfterChange(doc,change){for(var out=[],i=0;i<doc.sel.ranges.length;i++){var range=doc.sel.ranges[i];out.push(new Range(adjustForChange(range.anchor,change),adjustForChange(range.head,change)))}return normalizeSelection(out,doc.sel.primIndex)}function offsetPos(pos,old,nw){return pos.line==old.line?Pos(nw.line,pos.ch-old.ch+nw.ch):Pos(nw.line+(pos.line-old.line),pos.ch)}function computeReplacedSel(doc,changes,hint){for(var out=[],oldPrev=Pos(doc.first,0),newPrev=oldPrev,i=0;i<changes.length;i++){var change=changes[i],from=offsetPos(change.from,oldPrev,newPrev),to=offsetPos(changeEnd(change),oldPrev,newPrev);oldPrev=change.to;newPrev=to;if("around"==hint){var range=doc.sel.ranges[i],inv=cmp(range.head,range.anchor)<0;out[i]=new Range(inv?to:from,inv?from:to)}else out[i]=new Range(from,from)}return new Selection(out,doc.sel.primIndex)}function filterChange(doc,change,update){var obj={canceled:!1,from:change.from,to:change.to,text:change.text,origin:change.origin,cancel:function(){this.canceled=!0}};update&&(obj.update=function(from,to,text,origin){from&&(this.from=clipPos(doc,from));to&&(this.to=clipPos(doc,to));text&&(this.text=text);void 0!==origin&&(this.origin=origin)});signal(doc,"beforeChange",doc,obj);doc.cm&&signal(doc.cm,"beforeChange",doc.cm,obj);return obj.canceled?null:{from:obj.from,to:obj.to,text:obj.text,origin:obj.origin}}function makeChange(doc,change,ignoreReadOnly){if(doc.cm){if(!doc.cm.curOp)return operation(doc.cm,makeChange)(doc,change,ignoreReadOnly);if(doc.cm.state.suppressEdits)return}if(hasHandler(doc,"beforeChange")||doc.cm&&hasHandler(doc.cm,"beforeChange")){change=filterChange(doc,change,!0);if(!change)return}var split=sawReadOnlySpans&&!ignoreReadOnly&&removeReadOnlyRanges(doc,change.from,change.to);if(split)for(var i=split.length-1;i>=0;--i)makeChangeInner(doc,{from:split[i].from,to:split[i].to,text:i?[""]:change.text});else makeChangeInner(doc,change)}function makeChangeInner(doc,change){if(1!=change.text.length||""!=change.text[0]||0!=cmp(change.from,change.to)){var selAfter=computeSelAfterChange(doc,change);addChangeToHistory(doc,change,selAfter,doc.cm?doc.cm.curOp.id:NaN);makeChangeSingleDoc(doc,change,selAfter,stretchSpansOverChange(doc,change));var rebased=[];linkedDocs(doc,function(doc,sharedHist){if(!sharedHist&&-1==indexOf(rebased,doc.history)){rebaseHist(doc.history,change);rebased.push(doc.history)}makeChangeSingleDoc(doc,change,null,stretchSpansOverChange(doc,change))})}}function makeChangeFromHistory(doc,type,allowSelectionOnly){if(!doc.cm||!doc.cm.state.suppressEdits){for(var event,hist=doc.history,selAfter=doc.sel,source="undo"==type?hist.done:hist.undone,dest="undo"==type?hist.undone:hist.done,i=0;i<source.length;i++){event=source[i];if(allowSelectionOnly?event.ranges&&!event.equals(doc.sel):!event.ranges)break}if(i!=source.length){hist.lastOrigin=hist.lastSelOrigin=null;for(;;){event=source.pop();if(!event.ranges)break;pushSelectionToHistory(event,dest);if(allowSelectionOnly&&!event.equals(doc.sel)){setSelection(doc,event,{clearRedo:!1});return}selAfter=event}var antiChanges=[];pushSelectionToHistory(selAfter,dest);dest.push({changes:antiChanges,generation:hist.generation});hist.generation=event.generation||++hist.maxGeneration;for(var filter=hasHandler(doc,"beforeChange")||doc.cm&&hasHandler(doc.cm,"beforeChange"),i=event.changes.length-1;i>=0;--i){var change=event.changes[i];change.origin=type;if(filter&&!filterChange(doc,change,!1)){source.length=0;return}antiChanges.push(historyChangeFromChange(doc,change));var after=i?computeSelAfterChange(doc,change):lst(source);makeChangeSingleDoc(doc,change,after,mergeOldSpans(doc,change));!i&&doc.cm&&doc.cm.scrollIntoView({from:change.from,to:changeEnd(change)});var rebased=[];linkedDocs(doc,function(doc,sharedHist){if(!sharedHist&&-1==indexOf(rebased,doc.history)){rebaseHist(doc.history,change);rebased.push(doc.history)}makeChangeSingleDoc(doc,change,null,mergeOldSpans(doc,change))})}}}}function shiftDoc(doc,distance){if(0!=distance){doc.first+=distance;doc.sel=new Selection(map(doc.sel.ranges,function(range){return new Range(Pos(range.anchor.line+distance,range.anchor.ch),Pos(range.head.line+distance,range.head.ch))}),doc.sel.primIndex);if(doc.cm){regChange(doc.cm,doc.first,doc.first-distance,distance);for(var d=doc.cm.display,l=d.viewFrom;l<d.viewTo;l++)regLineChange(doc.cm,l,"gutter")}}}function makeChangeSingleDoc(doc,change,selAfter,spans){if(doc.cm&&!doc.cm.curOp)return operation(doc.cm,makeChangeSingleDoc)(doc,change,selAfter,spans);if(change.to.line<doc.first)shiftDoc(doc,change.text.length-1-(change.to.line-change.from.line));else if(!(change.from.line>doc.lastLine())){if(change.from.line<doc.first){var shift=change.text.length-1-(doc.first-change.from.line);shiftDoc(doc,shift);change={from:Pos(doc.first,0),to:Pos(change.to.line+shift,change.to.ch),text:[lst(change.text)],origin:change.origin}}var last=doc.lastLine();change.to.line>last&&(change={from:change.from,to:Pos(last,getLine(doc,last).text.length),text:[change.text[0]],origin:change.origin});change.removed=getBetween(doc,change.from,change.to);selAfter||(selAfter=computeSelAfterChange(doc,change));doc.cm?makeChangeSingleDocInEditor(doc.cm,change,spans):updateDoc(doc,change,spans);setSelectionNoUndo(doc,selAfter,sel_dontScroll)}}function makeChangeSingleDocInEditor(cm,change,spans){var doc=cm.doc,display=cm.display,from=change.from,to=change.to,recomputeMaxLength=!1,checkWidthStart=from.line;if(!cm.options.lineWrapping){checkWidthStart=lineNo(visualLine(getLine(doc,from.line)));doc.iter(checkWidthStart,to.line+1,function(line){if(line==display.maxLine){recomputeMaxLength=!0;return!0}})}doc.sel.contains(change.from,change.to)>-1&&signalCursorActivity(cm);updateDoc(doc,change,spans,estimateHeight(cm));if(!cm.options.lineWrapping){doc.iter(checkWidthStart,from.line+change.text.length,function(line){var len=lineLength(line);if(len>display.maxLineLength){display.maxLine=line;display.maxLineLength=len;display.maxLineChanged=!0;recomputeMaxLength=!1}});recomputeMaxLength&&(cm.curOp.updateMaxLine=!0)}doc.frontier=Math.min(doc.frontier,from.line);startWorker(cm,400);var lendiff=change.text.length-(to.line-from.line)-1;change.full?regChange(cm):from.line!=to.line||1!=change.text.length||isWholeLineUpdate(cm.doc,change)?regChange(cm,from.line,to.line+1,lendiff):regLineChange(cm,from.line,"text");var changesHandler=hasHandler(cm,"changes"),changeHandler=hasHandler(cm,"change");if(changeHandler||changesHandler){var obj={from:from,to:to,text:change.text,removed:change.removed,origin:change.origin};changeHandler&&signalLater(cm,"change",cm,obj);changesHandler&&(cm.curOp.changeObjs||(cm.curOp.changeObjs=[])).push(obj)}cm.display.selForContextMenu=null}function replaceRange(doc,code,from,to,origin){to||(to=from);if(cmp(to,from)<0){var tmp=to;to=from;from=tmp}"string"==typeof code&&(code=doc.splitLines(code));makeChange(doc,{from:from,to:to,text:code,origin:origin})}function maybeScrollWindow(cm,coords){if(!signalDOMEvent(cm,"scrollCursorIntoView")){var display=cm.display,box=display.sizer.getBoundingClientRect(),doScroll=null;coords.top+box.top<0?doScroll=!0:coords.bottom+box.top>(window.innerHeight||document.documentElement.clientHeight)&&(doScroll=!1);if(null!=doScroll&&!phantom){var scrollNode=elt("div","​",null,"position: absolute; top: "+(coords.top-display.viewOffset-paddingTop(cm.display))+"px; height: "+(coords.bottom-coords.top+scrollGap(cm)+display.barHeight)+"px; left: "+coords.left+"px; width: 2px;");cm.display.lineSpace.appendChild(scrollNode);scrollNode.scrollIntoView(doScroll);cm.display.lineSpace.removeChild(scrollNode)}}}function scrollPosIntoView(cm,pos,end,margin){null==margin&&(margin=0);for(var limit=0;5>limit;limit++){var changed=!1,coords=cursorCoords(cm,pos),endCoords=end&&end!=pos?cursorCoords(cm,end):coords,scrollPos=calculateScrollPos(cm,Math.min(coords.left,endCoords.left),Math.min(coords.top,endCoords.top)-margin,Math.max(coords.left,endCoords.left),Math.max(coords.bottom,endCoords.bottom)+margin),startTop=cm.doc.scrollTop,startLeft=cm.doc.scrollLeft;if(null!=scrollPos.scrollTop){setScrollTop(cm,scrollPos.scrollTop);Math.abs(cm.doc.scrollTop-startTop)>1&&(changed=!0)}if(null!=scrollPos.scrollLeft){setScrollLeft(cm,scrollPos.scrollLeft);Math.abs(cm.doc.scrollLeft-startLeft)>1&&(changed=!0)}if(!changed)break}return coords}function scrollIntoView(cm,x1,y1,x2,y2){var scrollPos=calculateScrollPos(cm,x1,y1,x2,y2);null!=scrollPos.scrollTop&&setScrollTop(cm,scrollPos.scrollTop);null!=scrollPos.scrollLeft&&setScrollLeft(cm,scrollPos.scrollLeft)}function calculateScrollPos(cm,x1,y1,x2,y2){var display=cm.display,snapMargin=textHeight(cm.display);0>y1&&(y1=0);var screentop=cm.curOp&&null!=cm.curOp.scrollTop?cm.curOp.scrollTop:display.scroller.scrollTop,screen=displayHeight(cm),result={};y2-y1>screen&&(y2=y1+screen);var docBottom=cm.doc.height+paddingVert(display),atTop=snapMargin>y1,atBottom=y2>docBottom-snapMargin;if(screentop>y1)result.scrollTop=atTop?0:y1;else if(y2>screentop+screen){var newTop=Math.min(y1,(atBottom?docBottom:y2)-screen);newTop!=screentop&&(result.scrollTop=newTop)}var screenleft=cm.curOp&&null!=cm.curOp.scrollLeft?cm.curOp.scrollLeft:display.scroller.scrollLeft,screenw=displayWidth(cm)-(cm.options.fixedGutter?display.gutters.offsetWidth:0),tooWide=x2-x1>screenw;tooWide&&(x2=x1+screenw);10>x1?result.scrollLeft=0:screenleft>x1?result.scrollLeft=Math.max(0,x1-(tooWide?0:10)):x2>screenw+screenleft-3&&(result.scrollLeft=x2+(tooWide?0:10)-screenw);return result}function addToScrollPos(cm,left,top){(null!=left||null!=top)&&resolveScrollToPos(cm);null!=left&&(cm.curOp.scrollLeft=(null==cm.curOp.scrollLeft?cm.doc.scrollLeft:cm.curOp.scrollLeft)+left);null!=top&&(cm.curOp.scrollTop=(null==cm.curOp.scrollTop?cm.doc.scrollTop:cm.curOp.scrollTop)+top)}function ensureCursorVisible(cm){resolveScrollToPos(cm);var cur=cm.getCursor(),from=cur,to=cur;if(!cm.options.lineWrapping){from=cur.ch?Pos(cur.line,cur.ch-1):cur;to=Pos(cur.line,cur.ch+1)}cm.curOp.scrollToPos={from:from,to:to,margin:cm.options.cursorScrollMargin,isCursor:!0}}function resolveScrollToPos(cm){var range=cm.curOp.scrollToPos;if(range){cm.curOp.scrollToPos=null;var from=estimateCoords(cm,range.from),to=estimateCoords(cm,range.to),sPos=calculateScrollPos(cm,Math.min(from.left,to.left),Math.min(from.top,to.top)-range.margin,Math.max(from.right,to.right),Math.max(from.bottom,to.bottom)+range.margin);cm.scrollTo(sPos.scrollLeft,sPos.scrollTop)}}function indentLine(cm,n,how,aggressive){var state,doc=cm.doc;null==how&&(how="add");"smart"==how&&(doc.mode.indent?state=getStateBefore(cm,n):how="prev");var tabSize=cm.options.tabSize,line=getLine(doc,n),curSpace=countColumn(line.text,null,tabSize);line.stateAfter&&(line.stateAfter=null);var indentation,curSpaceString=line.text.match(/^\s*/)[0];if(aggressive||/\S/.test(line.text)){if("smart"==how){indentation=doc.mode.indent(state,line.text.slice(curSpaceString.length),line.text);if(indentation==Pass||indentation>150){if(!aggressive)return;how="prev"}}}else{indentation=0;how="not"}"prev"==how?indentation=n>doc.first?countColumn(getLine(doc,n-1).text,null,tabSize):0:"add"==how?indentation=curSpace+cm.options.indentUnit:"subtract"==how?indentation=curSpace-cm.options.indentUnit:"number"==typeof how&&(indentation=curSpace+how);indentation=Math.max(0,indentation);var indentString="",pos=0;if(cm.options.indentWithTabs)for(var i=Math.floor(indentation/tabSize);i;--i){pos+=tabSize;indentString+=" "}indentation>pos&&(indentString+=spaceStr(indentation-pos));if(indentString!=curSpaceString){replaceRange(doc,indentString,Pos(n,0),Pos(n,curSpaceString.length),"+input");line.stateAfter=null;return!0}for(var i=0;i<doc.sel.ranges.length;i++){var range=doc.sel.ranges[i];if(range.head.line==n&&range.head.ch<curSpaceString.length){var pos=Pos(n,curSpaceString.length);replaceOneSelection(doc,i,new Range(pos,pos));break;
4
- }}}function changeLine(doc,handle,changeType,op){var no=handle,line=handle;"number"==typeof handle?line=getLine(doc,clipLine(doc,handle)):no=lineNo(handle);if(null==no)return null;op(line,no)&&doc.cm&&regLineChange(doc.cm,no,changeType);return line}function deleteNearSelection(cm,compute){for(var ranges=cm.doc.sel.ranges,kill=[],i=0;i<ranges.length;i++){for(var toKill=compute(ranges[i]);kill.length&&cmp(toKill.from,lst(kill).to)<=0;){var replaced=kill.pop();if(cmp(replaced.from,toKill.from)<0){toKill.from=replaced.from;break}}kill.push(toKill)}runInOp(cm,function(){for(var i=kill.length-1;i>=0;i--)replaceRange(cm.doc,"",kill[i].from,kill[i].to,"+delete");ensureCursorVisible(cm)})}function findPosH(doc,pos,dir,unit,visually){function findNextLine(){var l=line+dir;if(l<doc.first||l>=doc.first+doc.size)return possible=!1;line=l;return lineObj=getLine(doc,l)}function moveOnce(boundToLine){var next=(visually?moveVisually:moveLogically)(lineObj,ch,dir,!0);if(null==next){if(boundToLine||!findNextLine())return possible=!1;ch=visually?(0>dir?lineRight:lineLeft)(lineObj):0>dir?lineObj.text.length:0}else ch=next;return!0}var line=pos.line,ch=pos.ch,origDir=dir,lineObj=getLine(doc,line),possible=!0;if("char"==unit)moveOnce();else if("column"==unit)moveOnce(!0);else if("word"==unit||"group"==unit)for(var sawType=null,group="group"==unit,helper=doc.cm&&doc.cm.getHelper(pos,"wordChars"),first=!0;!(0>dir)||moveOnce(!first);first=!1){var cur=lineObj.text.charAt(ch)||"\n",type=isWordChar(cur,helper)?"w":group&&"\n"==cur?"n":!group||/\s/.test(cur)?null:"p";!group||first||type||(type="s");if(sawType&&sawType!=type){if(0>dir){dir=1;moveOnce()}break}type&&(sawType=type);if(dir>0&&!moveOnce(!first))break}var result=skipAtomic(doc,Pos(line,ch),origDir,!0);possible||(result.hitSide=!0);return result}function findPosV(cm,pos,dir,unit){var y,doc=cm.doc,x=pos.left;if("page"==unit){var pageSize=Math.min(cm.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);y=pos.top+dir*(pageSize-(0>dir?1.5:.5)*textHeight(cm.display))}else"line"==unit&&(y=dir>0?pos.bottom+3:pos.top-3);for(;;){var target=coordsChar(cm,x,y);if(!target.outside)break;if(0>dir?0>=y:y>=doc.height){target.hitSide=!0;break}y+=5*dir}return target}function option(name,deflt,handle,notOnInit){CodeMirror.defaults[name]=deflt;handle&&(optionHandlers[name]=notOnInit?function(cm,val,old){old!=Init&&handle(cm,val,old)}:handle)}function normalizeKeyName(name){for(var alt,ctrl,shift,cmd,parts=name.split(/-(?!$)/),name=parts[parts.length-1],i=0;i<parts.length-1;i++){var mod=parts[i];if(/^(cmd|meta|m)$/i.test(mod))cmd=!0;else if(/^a(lt)?$/i.test(mod))alt=!0;else if(/^(c|ctrl|control)$/i.test(mod))ctrl=!0;else{if(!/^s(hift)$/i.test(mod))throw new Error("Unrecognized modifier name: "+mod);shift=!0}}alt&&(name="Alt-"+name);ctrl&&(name="Ctrl-"+name);cmd&&(name="Cmd-"+name);shift&&(name="Shift-"+name);return name}function getKeyMap(val){return"string"==typeof val?keyMap[val]:val}function markText(doc,from,to,options,type){if(options&&options.shared)return markTextShared(doc,from,to,options,type);if(doc.cm&&!doc.cm.curOp)return operation(doc.cm,markText)(doc,from,to,options,type);var marker=new TextMarker(doc,type),diff=cmp(from,to);options&&copyObj(options,marker,!1);if(diff>0||0==diff&&marker.clearWhenEmpty!==!1)return marker;if(marker.replacedWith){marker.collapsed=!0;marker.widgetNode=elt("span",[marker.replacedWith],"CodeMirror-widget");options.handleMouseEvents||marker.widgetNode.setAttribute("cm-ignore-events","true");options.insertLeft&&(marker.widgetNode.insertLeft=!0)}if(marker.collapsed){if(conflictingCollapsedRange(doc,from.line,from,to,marker)||from.line!=to.line&&conflictingCollapsedRange(doc,to.line,from,to,marker))throw new Error("Inserting collapsed marker partially overlapping an existing one");sawCollapsedSpans=!0}marker.addToHistory&&addChangeToHistory(doc,{from:from,to:to,origin:"markText"},doc.sel,NaN);var updateMaxLine,curLine=from.line,cm=doc.cm;doc.iter(curLine,to.line+1,function(line){cm&&marker.collapsed&&!cm.options.lineWrapping&&visualLine(line)==cm.display.maxLine&&(updateMaxLine=!0);marker.collapsed&&curLine!=from.line&&updateLineHeight(line,0);addMarkedSpan(line,new MarkedSpan(marker,curLine==from.line?from.ch:null,curLine==to.line?to.ch:null));++curLine});marker.collapsed&&doc.iter(from.line,to.line+1,function(line){lineIsHidden(doc,line)&&updateLineHeight(line,0)});marker.clearOnEnter&&on(marker,"beforeCursorEnter",function(){marker.clear()});if(marker.readOnly){sawReadOnlySpans=!0;(doc.history.done.length||doc.history.undone.length)&&doc.clearHistory()}if(marker.collapsed){marker.id=++nextMarkerId;marker.atomic=!0}if(cm){updateMaxLine&&(cm.curOp.updateMaxLine=!0);if(marker.collapsed)regChange(cm,from.line,to.line+1);else if(marker.className||marker.title||marker.startStyle||marker.endStyle||marker.css)for(var i=from.line;i<=to.line;i++)regLineChange(cm,i,"text");marker.atomic&&reCheckSelection(cm.doc);signalLater(cm,"markerAdded",cm,marker)}return marker}function markTextShared(doc,from,to,options,type){options=copyObj(options);options.shared=!1;var markers=[markText(doc,from,to,options,type)],primary=markers[0],widget=options.widgetNode;linkedDocs(doc,function(doc){widget&&(options.widgetNode=widget.cloneNode(!0));markers.push(markText(doc,clipPos(doc,from),clipPos(doc,to),options,type));for(var i=0;i<doc.linked.length;++i)if(doc.linked[i].isParent)return;primary=lst(markers)});return new SharedTextMarker(markers,primary)}function findSharedMarkers(doc){return doc.findMarks(Pos(doc.first,0),doc.clipPos(Pos(doc.lastLine())),function(m){return m.parent})}function copySharedMarkers(doc,markers){for(var i=0;i<markers.length;i++){var marker=markers[i],pos=marker.find(),mFrom=doc.clipPos(pos.from),mTo=doc.clipPos(pos.to);if(cmp(mFrom,mTo)){var subMark=markText(doc,mFrom,mTo,marker.primary,marker.primary.type);marker.markers.push(subMark);subMark.parent=marker}}}function detachSharedMarkers(markers){for(var i=0;i<markers.length;i++){var marker=markers[i],linked=[marker.primary.doc];linkedDocs(marker.primary.doc,function(d){linked.push(d)});for(var j=0;j<marker.markers.length;j++){var subMarker=marker.markers[j];if(-1==indexOf(linked,subMarker.doc)){subMarker.parent=null;marker.markers.splice(j--,1)}}}}function MarkedSpan(marker,from,to){this.marker=marker;this.from=from;this.to=to}function getMarkedSpanFor(spans,marker){if(spans)for(var i=0;i<spans.length;++i){var span=spans[i];if(span.marker==marker)return span}}function removeMarkedSpan(spans,span){for(var r,i=0;i<spans.length;++i)spans[i]!=span&&(r||(r=[])).push(spans[i]);return r}function addMarkedSpan(line,span){line.markedSpans=line.markedSpans?line.markedSpans.concat([span]):[span];span.marker.attachLine(line)}function markedSpansBefore(old,startCh,isInsert){if(old)for(var nw,i=0;i<old.length;++i){var span=old[i],marker=span.marker,startsBefore=null==span.from||(marker.inclusiveLeft?span.from<=startCh:span.from<startCh);if(startsBefore||span.from==startCh&&"bookmark"==marker.type&&(!isInsert||!span.marker.insertLeft)){var endsAfter=null==span.to||(marker.inclusiveRight?span.to>=startCh:span.to>startCh);(nw||(nw=[])).push(new MarkedSpan(marker,span.from,endsAfter?null:span.to))}}return nw}function markedSpansAfter(old,endCh,isInsert){if(old)for(var nw,i=0;i<old.length;++i){var span=old[i],marker=span.marker,endsAfter=null==span.to||(marker.inclusiveRight?span.to>=endCh:span.to>endCh);if(endsAfter||span.from==endCh&&"bookmark"==marker.type&&(!isInsert||span.marker.insertLeft)){var startsBefore=null==span.from||(marker.inclusiveLeft?span.from<=endCh:span.from<endCh);(nw||(nw=[])).push(new MarkedSpan(marker,startsBefore?null:span.from-endCh,null==span.to?null:span.to-endCh))}}return nw}function stretchSpansOverChange(doc,change){if(change.full)return null;var oldFirst=isLine(doc,change.from.line)&&getLine(doc,change.from.line).markedSpans,oldLast=isLine(doc,change.to.line)&&getLine(doc,change.to.line).markedSpans;if(!oldFirst&&!oldLast)return null;var startCh=change.from.ch,endCh=change.to.ch,isInsert=0==cmp(change.from,change.to),first=markedSpansBefore(oldFirst,startCh,isInsert),last=markedSpansAfter(oldLast,endCh,isInsert),sameLine=1==change.text.length,offset=lst(change.text).length+(sameLine?startCh:0);if(first)for(var i=0;i<first.length;++i){var span=first[i];if(null==span.to){var found=getMarkedSpanFor(last,span.marker);found?sameLine&&(span.to=null==found.to?null:found.to+offset):span.to=startCh}}if(last)for(var i=0;i<last.length;++i){var span=last[i];null!=span.to&&(span.to+=offset);if(null==span.from){var found=getMarkedSpanFor(first,span.marker);if(!found){span.from=offset;sameLine&&(first||(first=[])).push(span)}}else{span.from+=offset;sameLine&&(first||(first=[])).push(span)}}first&&(first=clearEmptySpans(first));last&&last!=first&&(last=clearEmptySpans(last));var newMarkers=[first];if(!sameLine){var gapMarkers,gap=change.text.length-2;if(gap>0&&first)for(var i=0;i<first.length;++i)null==first[i].to&&(gapMarkers||(gapMarkers=[])).push(new MarkedSpan(first[i].marker,null,null));for(var i=0;gap>i;++i)newMarkers.push(gapMarkers);newMarkers.push(last)}return newMarkers}function clearEmptySpans(spans){for(var i=0;i<spans.length;++i){var span=spans[i];null!=span.from&&span.from==span.to&&span.marker.clearWhenEmpty!==!1&&spans.splice(i--,1)}return spans.length?spans:null}function mergeOldSpans(doc,change){var old=getOldSpans(doc,change),stretched=stretchSpansOverChange(doc,change);if(!old)return stretched;if(!stretched)return old;for(var i=0;i<old.length;++i){var oldCur=old[i],stretchCur=stretched[i];if(oldCur&&stretchCur)spans:for(var j=0;j<stretchCur.length;++j){for(var span=stretchCur[j],k=0;k<oldCur.length;++k)if(oldCur[k].marker==span.marker)continue spans;oldCur.push(span)}else stretchCur&&(old[i]=stretchCur)}return old}function removeReadOnlyRanges(doc,from,to){var markers=null;doc.iter(from.line,to.line+1,function(line){if(line.markedSpans)for(var i=0;i<line.markedSpans.length;++i){var mark=line.markedSpans[i].marker;!mark.readOnly||markers&&-1!=indexOf(markers,mark)||(markers||(markers=[])).push(mark)}});if(!markers)return null;for(var parts=[{from:from,to:to}],i=0;i<markers.length;++i)for(var mk=markers[i],m=mk.find(0),j=0;j<parts.length;++j){var p=parts[j];if(!(cmp(p.to,m.from)<0||cmp(p.from,m.to)>0)){var newParts=[j,1],dfrom=cmp(p.from,m.from),dto=cmp(p.to,m.to);(0>dfrom||!mk.inclusiveLeft&&!dfrom)&&newParts.push({from:p.from,to:m.from});(dto>0||!mk.inclusiveRight&&!dto)&&newParts.push({from:m.to,to:p.to});parts.splice.apply(parts,newParts);j+=newParts.length-1}}return parts}function detachMarkedSpans(line){var spans=line.markedSpans;if(spans){for(var i=0;i<spans.length;++i)spans[i].marker.detachLine(line);line.markedSpans=null}}function attachMarkedSpans(line,spans){if(spans){for(var i=0;i<spans.length;++i)spans[i].marker.attachLine(line);line.markedSpans=spans}}function extraLeft(marker){return marker.inclusiveLeft?-1:0}function extraRight(marker){return marker.inclusiveRight?1:0}function compareCollapsedMarkers(a,b){var lenDiff=a.lines.length-b.lines.length;if(0!=lenDiff)return lenDiff;var aPos=a.find(),bPos=b.find(),fromCmp=cmp(aPos.from,bPos.from)||extraLeft(a)-extraLeft(b);if(fromCmp)return-fromCmp;var toCmp=cmp(aPos.to,bPos.to)||extraRight(a)-extraRight(b);return toCmp?toCmp:b.id-a.id}function collapsedSpanAtSide(line,start){var found,sps=sawCollapsedSpans&&line.markedSpans;if(sps)for(var sp,i=0;i<sps.length;++i){sp=sps[i];sp.marker.collapsed&&null==(start?sp.from:sp.to)&&(!found||compareCollapsedMarkers(found,sp.marker)<0)&&(found=sp.marker)}return found}function collapsedSpanAtStart(line){return collapsedSpanAtSide(line,!0)}function collapsedSpanAtEnd(line){return collapsedSpanAtSide(line,!1)}function conflictingCollapsedRange(doc,lineNo,from,to,marker){var line=getLine(doc,lineNo),sps=sawCollapsedSpans&&line.markedSpans;if(sps)for(var i=0;i<sps.length;++i){var sp=sps[i];if(sp.marker.collapsed){var found=sp.marker.find(0),fromCmp=cmp(found.from,from)||extraLeft(sp.marker)-extraLeft(marker),toCmp=cmp(found.to,to)||extraRight(sp.marker)-extraRight(marker);if(!(fromCmp>=0&&0>=toCmp||0>=fromCmp&&toCmp>=0)&&(0>=fromCmp&&(cmp(found.to,from)>0||sp.marker.inclusiveRight&&marker.inclusiveLeft)||fromCmp>=0&&(cmp(found.from,to)<0||sp.marker.inclusiveLeft&&marker.inclusiveRight)))return!0}}}function visualLine(line){for(var merged;merged=collapsedSpanAtStart(line);)line=merged.find(-1,!0).line;return line}function visualLineContinued(line){for(var merged,lines;merged=collapsedSpanAtEnd(line);){line=merged.find(1,!0).line;(lines||(lines=[])).push(line)}return lines}function visualLineNo(doc,lineN){var line=getLine(doc,lineN),vis=visualLine(line);return line==vis?lineN:lineNo(vis)}function visualLineEndNo(doc,lineN){if(lineN>doc.lastLine())return lineN;var merged,line=getLine(doc,lineN);if(!lineIsHidden(doc,line))return lineN;for(;merged=collapsedSpanAtEnd(line);)line=merged.find(1,!0).line;return lineNo(line)+1}function lineIsHidden(doc,line){var sps=sawCollapsedSpans&&line.markedSpans;if(sps)for(var sp,i=0;i<sps.length;++i){sp=sps[i];if(sp.marker.collapsed){if(null==sp.from)return!0;if(!sp.marker.widgetNode&&0==sp.from&&sp.marker.inclusiveLeft&&lineIsHiddenInner(doc,line,sp))return!0}}}function lineIsHiddenInner(doc,line,span){if(null==span.to){var end=span.marker.find(1,!0);return lineIsHiddenInner(doc,end.line,getMarkedSpanFor(end.line.markedSpans,span.marker))}if(span.marker.inclusiveRight&&span.to==line.text.length)return!0;for(var sp,i=0;i<line.markedSpans.length;++i){sp=line.markedSpans[i];if(sp.marker.collapsed&&!sp.marker.widgetNode&&sp.from==span.to&&(null==sp.to||sp.to!=span.from)&&(sp.marker.inclusiveLeft||span.marker.inclusiveRight)&&lineIsHiddenInner(doc,line,sp))return!0}}function adjustScrollWhenAboveVisible(cm,line,diff){heightAtLine(line)<(cm.curOp&&cm.curOp.scrollTop||cm.doc.scrollTop)&&addToScrollPos(cm,null,diff)}function widgetHeight(widget){if(null!=widget.height)return widget.height;var cm=widget.doc.cm;if(!cm)return 0;if(!contains(document.body,widget.node)){var parentStyle="position: relative;";widget.coverGutter&&(parentStyle+="margin-left: -"+cm.display.gutters.offsetWidth+"px;");widget.noHScroll&&(parentStyle+="width: "+cm.display.wrapper.clientWidth+"px;");removeChildrenAndAdd(cm.display.measure,elt("div",[widget.node],null,parentStyle))}return widget.height=widget.node.offsetHeight}function addLineWidget(doc,handle,node,options){var widget=new LineWidget(doc,node,options),cm=doc.cm;cm&&widget.noHScroll&&(cm.display.alignWidgets=!0);changeLine(doc,handle,"widget",function(line){var widgets=line.widgets||(line.widgets=[]);null==widget.insertAt?widgets.push(widget):widgets.splice(Math.min(widgets.length-1,Math.max(0,widget.insertAt)),0,widget);widget.line=line;if(cm&&!lineIsHidden(doc,line)){var aboveVisible=heightAtLine(line)<doc.scrollTop;updateLineHeight(line,line.height+widgetHeight(widget));aboveVisible&&addToScrollPos(cm,null,widget.height);cm.curOp.forceUpdate=!0}return!0});return widget}function updateLine(line,text,markedSpans,estimateHeight){line.text=text;line.stateAfter&&(line.stateAfter=null);line.styles&&(line.styles=null);null!=line.order&&(line.order=null);detachMarkedSpans(line);attachMarkedSpans(line,markedSpans);var estHeight=estimateHeight?estimateHeight(line):1;estHeight!=line.height&&updateLineHeight(line,estHeight)}function cleanUpLine(line){line.parent=null;detachMarkedSpans(line)}function extractLineClasses(type,output){if(type)for(;;){var lineClass=type.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!lineClass)break;type=type.slice(0,lineClass.index)+type.slice(lineClass.index+lineClass[0].length);var prop=lineClass[1]?"bgClass":"textClass";null==output[prop]?output[prop]=lineClass[2]:new RegExp("(?:^|s)"+lineClass[2]+"(?:$|s)").test(output[prop])||(output[prop]+=" "+lineClass[2])}return type}function callBlankLine(mode,state){if(mode.blankLine)return mode.blankLine(state);if(mode.innerMode){var inner=CodeMirror.innerMode(mode,state);return inner.mode.blankLine?inner.mode.blankLine(inner.state):void 0}}function readToken(mode,stream,state,inner){for(var i=0;10>i;i++){inner&&(inner[0]=CodeMirror.innerMode(mode,state).mode);var style=mode.token(stream,state);if(stream.pos>stream.start)return style}throw new Error("Mode "+mode.name+" failed to advance stream.")}function takeToken(cm,pos,precise,asArray){function getObj(copy){return{start:stream.start,end:stream.pos,string:stream.current(),type:style||null,state:copy?copyState(doc.mode,state):state}}var style,doc=cm.doc,mode=doc.mode;pos=clipPos(doc,pos);var tokens,line=getLine(doc,pos.line),state=getStateBefore(cm,pos.line,precise),stream=new StringStream(line.text,cm.options.tabSize);asArray&&(tokens=[]);for(;(asArray||stream.pos<pos.ch)&&!stream.eol();){stream.start=stream.pos;style=readToken(mode,stream,state);asArray&&tokens.push(getObj(!0))}return asArray?tokens:getObj()}function runMode(cm,text,mode,state,f,lineClasses,forceToEnd){var flattenSpans=mode.flattenSpans;null==flattenSpans&&(flattenSpans=cm.options.flattenSpans);var style,curStart=0,curStyle=null,stream=new StringStream(text,cm.options.tabSize),inner=cm.options.addModeClass&&[null];""==text&&extractLineClasses(callBlankLine(mode,state),lineClasses);for(;!stream.eol();){if(stream.pos>cm.options.maxHighlightLength){flattenSpans=!1;forceToEnd&&processLine(cm,text,state,stream.pos);stream.pos=text.length;style=null}else style=extractLineClasses(readToken(mode,stream,state,inner),lineClasses);if(inner){var mName=inner[0].name;mName&&(style="m-"+(style?mName+" "+style:mName))}if(!flattenSpans||curStyle!=style){for(;curStart<stream.start;){curStart=Math.min(stream.start,curStart+5e4);f(curStart,curStyle)}curStyle=style}stream.start=stream.pos}for(;curStart<stream.pos;){var pos=Math.min(stream.pos,curStart+5e4);f(pos,curStyle);curStart=pos}}function highlightLine(cm,line,state,forceToEnd){var st=[cm.state.modeGen],lineClasses={};runMode(cm,line.text,cm.doc.mode,state,function(end,style){st.push(end,style)},lineClasses,forceToEnd);for(var o=0;o<cm.state.overlays.length;++o){var overlay=cm.state.overlays[o],i=1,at=0;runMode(cm,line.text,overlay.mode,!0,function(end,style){for(var start=i;end>at;){var i_end=st[i];i_end>end&&st.splice(i,1,end,st[i+1],i_end);i+=2;at=Math.min(end,i_end)}if(style)if(overlay.opaque){st.splice(start,i-start,end,"cm-overlay "+style);i=start+2}else for(;i>start;start+=2){var cur=st[start+1];st[start+1]=(cur?cur+" ":"")+"cm-overlay "+style}},lineClasses)}return{styles:st,classes:lineClasses.bgClass||lineClasses.textClass?lineClasses:null}}function getLineStyles(cm,line,updateFrontier){if(!line.styles||line.styles[0]!=cm.state.modeGen){var state=getStateBefore(cm,lineNo(line)),result=highlightLine(cm,line,line.text.length>cm.options.maxHighlightLength?copyState(cm.doc.mode,state):state);line.stateAfter=state;line.styles=result.styles;result.classes?line.styleClasses=result.classes:line.styleClasses&&(line.styleClasses=null);updateFrontier===cm.doc.frontier&&cm.doc.frontier++}return line.styles}function processLine(cm,text,state,startAt){var mode=cm.doc.mode,stream=new StringStream(text,cm.options.tabSize);stream.start=stream.pos=startAt||0;""==text&&callBlankLine(mode,state);for(;!stream.eol();){readToken(mode,stream,state);stream.start=stream.pos}}function interpretTokenStyle(style,options){if(!style||/^\s*$/.test(style))return null;var cache=options.addModeClass?styleToClassCacheWithMode:styleToClassCache;return cache[style]||(cache[style]=style.replace(/\S+/g,"cm-$&"))}function buildLineContent(cm,lineView){var content=elt("span",null,null,webkit?"padding-right: .1px":null),builder={pre:elt("pre",[content],"CodeMirror-line"),content:content,col:0,pos:0,cm:cm,splitSpaces:(ie||webkit)&&cm.getOption("lineWrapping")};lineView.measure={};for(var i=0;i<=(lineView.rest?lineView.rest.length:0);i++){var order,line=i?lineView.rest[i-1]:lineView.line;builder.pos=0;builder.addToken=buildToken;hasBadBidiRects(cm.display.measure)&&(order=getOrder(line))&&(builder.addToken=buildTokenBadBidi(builder.addToken,order));builder.map=[];var allowFrontierUpdate=lineView!=cm.display.externalMeasured&&lineNo(line);insertLineContent(line,builder,getLineStyles(cm,line,allowFrontierUpdate));if(line.styleClasses){line.styleClasses.bgClass&&(builder.bgClass=joinClasses(line.styleClasses.bgClass,builder.bgClass||""));line.styleClasses.textClass&&(builder.textClass=joinClasses(line.styleClasses.textClass,builder.textClass||""))}0==builder.map.length&&builder.map.push(0,0,builder.content.appendChild(zeroWidthElement(cm.display.measure)));if(0==i){lineView.measure.map=builder.map;lineView.measure.cache={}}else{(lineView.measure.maps||(lineView.measure.maps=[])).push(builder.map);(lineView.measure.caches||(lineView.measure.caches=[])).push({})}}webkit&&/\bcm-tab\b/.test(builder.content.lastChild.className)&&(builder.content.className="cm-tab-wrap-hack");signal(cm,"renderLine",cm,lineView.line,builder.pre);builder.pre.className&&(builder.textClass=joinClasses(builder.pre.className,builder.textClass||""));return builder}function defaultSpecialCharPlaceholder(ch){var token=elt("span","•","cm-invalidchar");token.title="\\u"+ch.charCodeAt(0).toString(16);token.setAttribute("aria-label",token.title);return token}function buildToken(builder,text,style,startStyle,endStyle,title,css){if(text){var displayText=builder.splitSpaces?text.replace(/ {3,}/g,splitSpaces):text,special=builder.cm.state.specialChars,mustWrap=!1;if(special.test(text))for(var content=document.createDocumentFragment(),pos=0;;){special.lastIndex=pos;var m=special.exec(text),skipped=m?m.index-pos:text.length-pos;if(skipped){var txt=document.createTextNode(displayText.slice(pos,pos+skipped));ie&&9>ie_version?content.appendChild(elt("span",[txt])):content.appendChild(txt);builder.map.push(builder.pos,builder.pos+skipped,txt);builder.col+=skipped;builder.pos+=skipped}if(!m)break;pos+=skipped+1;if(" "==m[0]){var tabSize=builder.cm.options.tabSize,tabWidth=tabSize-builder.col%tabSize,txt=content.appendChild(elt("span",spaceStr(tabWidth),"cm-tab"));txt.setAttribute("role","presentation");txt.setAttribute("cm-text"," ");builder.col+=tabWidth}else if("\r"==m[0]||"\n"==m[0]){var txt=content.appendChild(elt("span","\r"==m[0]?"␍":"␤","cm-invalidchar"));txt.setAttribute("cm-text",m[0]);builder.col+=1}else{var txt=builder.cm.options.specialCharPlaceholder(m[0]);txt.setAttribute("cm-text",m[0]);ie&&9>ie_version?content.appendChild(elt("span",[txt])):content.appendChild(txt);builder.col+=1}builder.map.push(builder.pos,builder.pos+1,txt);builder.pos++}else{builder.col+=text.length;var content=document.createTextNode(displayText);builder.map.push(builder.pos,builder.pos+text.length,content);ie&&9>ie_version&&(mustWrap=!0);builder.pos+=text.length}if(style||startStyle||endStyle||mustWrap||css){var fullStyle=style||"";startStyle&&(fullStyle+=startStyle);endStyle&&(fullStyle+=endStyle);var token=elt("span",[content],fullStyle,css);title&&(token.title=title);return builder.content.appendChild(token)}builder.content.appendChild(content)}}function splitSpaces(old){for(var out=" ",i=0;i<old.length-2;++i)out+=i%2?" ":" ";out+=" ";return out}function buildTokenBadBidi(inner,order){return function(builder,text,style,startStyle,endStyle,title,css){style=style?style+" cm-force-border":"cm-force-border";for(var start=builder.pos,end=start+text.length;;){for(var i=0;i<order.length;i++){var part=order[i];if(part.to>start&&part.from<=start)break}if(part.to>=end)return inner(builder,text,style,startStyle,endStyle,title,css);inner(builder,text.slice(0,part.to-start),style,startStyle,null,title,css);startStyle=null;text=text.slice(part.to-start);start=part.to}}}function buildCollapsedSpan(builder,size,marker,ignoreWidget){var widget=!ignoreWidget&&marker.widgetNode;widget&&builder.map.push(builder.pos,builder.pos+size,widget);if(!ignoreWidget&&builder.cm.display.input.needsContentAttribute){widget||(widget=builder.content.appendChild(document.createElement("span")));widget.setAttribute("cm-marker",marker.id)}if(widget){builder.cm.display.input.setUneditable(widget);builder.content.appendChild(widget)}builder.pos+=size}function insertLineContent(line,builder,styles){var spans=line.markedSpans,allText=line.text,at=0;if(spans)for(var style,css,spanStyle,spanEndStyle,spanStartStyle,title,collapsed,len=allText.length,pos=0,i=1,text="",nextChange=0;;){if(nextChange==pos){spanStyle=spanEndStyle=spanStartStyle=title=css="";collapsed=null;nextChange=1/0;for(var foundBookmarks=[],j=0;j<spans.length;++j){var sp=spans[j],m=sp.marker;if("bookmark"==m.type&&sp.from==pos&&m.widgetNode)foundBookmarks.push(m);else if(sp.from<=pos&&(null==sp.to||sp.to>pos||m.collapsed&&sp.to==pos&&sp.from==pos)){if(null!=sp.to&&sp.to!=pos&&nextChange>sp.to){nextChange=sp.to;spanEndStyle=""}m.className&&(spanStyle+=" "+m.className);m.css&&(css=m.css);m.startStyle&&sp.from==pos&&(spanStartStyle+=" "+m.startStyle);m.endStyle&&sp.to==nextChange&&(spanEndStyle+=" "+m.endStyle);m.title&&!title&&(title=m.title);m.collapsed&&(!collapsed||compareCollapsedMarkers(collapsed.marker,m)<0)&&(collapsed=sp)}else sp.from>pos&&nextChange>sp.from&&(nextChange=sp.from)}if(collapsed&&(collapsed.from||0)==pos){buildCollapsedSpan(builder,(null==collapsed.to?len+1:collapsed.to)-pos,collapsed.marker,null==collapsed.from);if(null==collapsed.to)return;collapsed.to==pos&&(collapsed=!1)}if(!collapsed&&foundBookmarks.length)for(var j=0;j<foundBookmarks.length;++j)buildCollapsedSpan(builder,0,foundBookmarks[j])}if(pos>=len)break;for(var upto=Math.min(len,nextChange);;){if(text){var end=pos+text.length;if(!collapsed){var tokenText=end>upto?text.slice(0,upto-pos):text;builder.addToken(builder,tokenText,style?style+spanStyle:spanStyle,spanStartStyle,pos+tokenText.length==nextChange?spanEndStyle:"",title,css)}if(end>=upto){text=text.slice(upto-pos);pos=upto;break}pos=end;spanStartStyle=""}text=allText.slice(at,at=styles[i++]);style=interpretTokenStyle(styles[i++],builder.cm.options)}}else for(var i=1;i<styles.length;i+=2)builder.addToken(builder,allText.slice(at,at=styles[i]),interpretTokenStyle(styles[i+1],builder.cm.options))}function isWholeLineUpdate(doc,change){return 0==change.from.ch&&0==change.to.ch&&""==lst(change.text)&&(!doc.cm||doc.cm.options.wholeLineUpdateBefore)}function updateDoc(doc,change,markedSpans,estimateHeight){function spansFor(n){return markedSpans?markedSpans[n]:null}function update(line,text,spans){updateLine(line,text,spans,estimateHeight);signalLater(line,"change",line,change)}function linesFor(start,end){for(var i=start,result=[];end>i;++i)result.push(new Line(text[i],spansFor(i),estimateHeight));return result}var from=change.from,to=change.to,text=change.text,firstLine=getLine(doc,from.line),lastLine=getLine(doc,to.line),lastText=lst(text),lastSpans=spansFor(text.length-1),nlines=to.line-from.line;if(change.full){doc.insert(0,linesFor(0,text.length));doc.remove(text.length,doc.size-text.length)}else if(isWholeLineUpdate(doc,change)){var added=linesFor(0,text.length-1);update(lastLine,lastLine.text,lastSpans);nlines&&doc.remove(from.line,nlines);added.length&&doc.insert(from.line,added)}else if(firstLine==lastLine)if(1==text.length)update(firstLine,firstLine.text.slice(0,from.ch)+lastText+firstLine.text.slice(to.ch),lastSpans);else{var added=linesFor(1,text.length-1);added.push(new Line(lastText+firstLine.text.slice(to.ch),lastSpans,estimateHeight));update(firstLine,firstLine.text.slice(0,from.ch)+text[0],spansFor(0));doc.insert(from.line+1,added)}else if(1==text.length){update(firstLine,firstLine.text.slice(0,from.ch)+text[0]+lastLine.text.slice(to.ch),spansFor(0));doc.remove(from.line+1,nlines)}else{update(firstLine,firstLine.text.slice(0,from.ch)+text[0],spansFor(0));update(lastLine,lastText+lastLine.text.slice(to.ch),lastSpans);var added=linesFor(1,text.length-1);nlines>1&&doc.remove(from.line+1,nlines-1);doc.insert(from.line+1,added)}signalLater(doc,"change",doc,change)}function LeafChunk(lines){this.lines=lines;this.parent=null;for(var i=0,height=0;i<lines.length;++i){lines[i].parent=this;height+=lines[i].height}this.height=height}function BranchChunk(children){this.children=children;for(var size=0,height=0,i=0;i<children.length;++i){var ch=children[i];size+=ch.chunkSize();height+=ch.height;ch.parent=this}this.size=size;this.height=height;this.parent=null}function linkedDocs(doc,f,sharedHistOnly){function propagate(doc,skip,sharedHist){if(doc.linked)for(var i=0;i<doc.linked.length;++i){var rel=doc.linked[i];if(rel.doc!=skip){var shared=sharedHist&&rel.sharedHist;if(!sharedHistOnly||shared){f(rel.doc,shared);propagate(rel.doc,doc,shared)}}}}propagate(doc,null,!0)}function attachDoc(cm,doc){if(doc.cm)throw new Error("This document is already in use.");cm.doc=doc;doc.cm=cm;estimateLineHeights(cm);loadMode(cm);cm.options.lineWrapping||findMaxLine(cm);cm.options.mode=doc.modeOption;regChange(cm)}function getLine(doc,n){n-=doc.first;if(0>n||n>=doc.size)throw new Error("There is no line "+(n+doc.first)+" in the document.");for(var chunk=doc;!chunk.lines;)for(var i=0;;++i){var child=chunk.children[i],sz=child.chunkSize();if(sz>n){chunk=child;break}n-=sz}return chunk.lines[n]}function getBetween(doc,start,end){var out=[],n=start.line;doc.iter(start.line,end.line+1,function(line){var text=line.text;n==end.line&&(text=text.slice(0,end.ch));n==start.line&&(text=text.slice(start.ch));out.push(text);++n});return out}function getLines(doc,from,to){var out=[];doc.iter(from,to,function(line){out.push(line.text)});return out}function updateLineHeight(line,height){var diff=height-line.height;if(diff)for(var n=line;n;n=n.parent)n.height+=diff}function lineNo(line){if(null==line.parent)return null;for(var cur=line.parent,no=indexOf(cur.lines,line),chunk=cur.parent;chunk;cur=chunk,chunk=chunk.parent)for(var i=0;chunk.children[i]!=cur;++i)no+=chunk.children[i].chunkSize();return no+cur.first}function lineAtHeight(chunk,h){var n=chunk.first;outer:do{for(var i=0;i<chunk.children.length;++i){var child=chunk.children[i],ch=child.height;if(ch>h){chunk=child;continue outer}h-=ch;n+=child.chunkSize()}return n}while(!chunk.lines);for(var i=0;i<chunk.lines.length;++i){var line=chunk.lines[i],lh=line.height;if(lh>h)break;h-=lh}return n+i}function heightAtLine(lineObj){lineObj=visualLine(lineObj);for(var h=0,chunk=lineObj.parent,i=0;i<chunk.lines.length;++i){var line=chunk.lines[i];if(line==lineObj)break;h+=line.height}for(var p=chunk.parent;p;chunk=p,p=chunk.parent)for(var i=0;i<p.children.length;++i){var cur=p.children[i];if(cur==chunk)break;h+=cur.height}return h}function getOrder(line){var order=line.order;null==order&&(order=line.order=bidiOrdering(line.text));return order}function History(startGen){this.done=[];this.undone=[];this.undoDepth=1/0;this.lastModTime=this.lastSelTime=0;this.lastOp=this.lastSelOp=null;this.lastOrigin=this.lastSelOrigin=null;this.generation=this.maxGeneration=startGen||1}function historyChangeFromChange(doc,change){var histChange={from:copyPos(change.from),to:changeEnd(change),text:getBetween(doc,change.from,change.to)};attachLocalSpans(doc,histChange,change.from.line,change.to.line+1);linkedDocs(doc,function(doc){attachLocalSpans(doc,histChange,change.from.line,change.to.line+1)},!0);return histChange}function clearSelectionEvents(array){for(;array.length;){var last=lst(array);if(!last.ranges)break;array.pop()}}function lastChangeEvent(hist,force){if(force){clearSelectionEvents(hist.done);return lst(hist.done)}if(hist.done.length&&!lst(hist.done).ranges)return lst(hist.done);if(hist.done.length>1&&!hist.done[hist.done.length-2].ranges){hist.done.pop();return lst(hist.done)}}function addChangeToHistory(doc,change,selAfter,opId){var hist=doc.history;hist.undone.length=0;var cur,time=+new Date;if((hist.lastOp==opId||hist.lastOrigin==change.origin&&change.origin&&("+"==change.origin.charAt(0)&&doc.cm&&hist.lastModTime>time-doc.cm.options.historyEventDelay||"*"==change.origin.charAt(0)))&&(cur=lastChangeEvent(hist,hist.lastOp==opId))){
5
- var last=lst(cur.changes);0==cmp(change.from,change.to)&&0==cmp(change.from,last.to)?last.to=changeEnd(change):cur.changes.push(historyChangeFromChange(doc,change))}else{var before=lst(hist.done);before&&before.ranges||pushSelectionToHistory(doc.sel,hist.done);cur={changes:[historyChangeFromChange(doc,change)],generation:hist.generation};hist.done.push(cur);for(;hist.done.length>hist.undoDepth;){hist.done.shift();hist.done[0].ranges||hist.done.shift()}}hist.done.push(selAfter);hist.generation=++hist.maxGeneration;hist.lastModTime=hist.lastSelTime=time;hist.lastOp=hist.lastSelOp=opId;hist.lastOrigin=hist.lastSelOrigin=change.origin;last||signal(doc,"historyAdded")}function selectionEventCanBeMerged(doc,origin,prev,sel){var ch=origin.charAt(0);return"*"==ch||"+"==ch&&prev.ranges.length==sel.ranges.length&&prev.somethingSelected()==sel.somethingSelected()&&new Date-doc.history.lastSelTime<=(doc.cm?doc.cm.options.historyEventDelay:500)}function addSelectionToHistory(doc,sel,opId,options){var hist=doc.history,origin=options&&options.origin;opId==hist.lastSelOp||origin&&hist.lastSelOrigin==origin&&(hist.lastModTime==hist.lastSelTime&&hist.lastOrigin==origin||selectionEventCanBeMerged(doc,origin,lst(hist.done),sel))?hist.done[hist.done.length-1]=sel:pushSelectionToHistory(sel,hist.done);hist.lastSelTime=+new Date;hist.lastSelOrigin=origin;hist.lastSelOp=opId;options&&options.clearRedo!==!1&&clearSelectionEvents(hist.undone)}function pushSelectionToHistory(sel,dest){var top=lst(dest);top&&top.ranges&&top.equals(sel)||dest.push(sel)}function attachLocalSpans(doc,change,from,to){var existing=change["spans_"+doc.id],n=0;doc.iter(Math.max(doc.first,from),Math.min(doc.first+doc.size,to),function(line){line.markedSpans&&((existing||(existing=change["spans_"+doc.id]={}))[n]=line.markedSpans);++n})}function removeClearedSpans(spans){if(!spans)return null;for(var out,i=0;i<spans.length;++i)spans[i].marker.explicitlyCleared?out||(out=spans.slice(0,i)):out&&out.push(spans[i]);return out?out.length?out:null:spans}function getOldSpans(doc,change){var found=change["spans_"+doc.id];if(!found)return null;for(var i=0,nw=[];i<change.text.length;++i)nw.push(removeClearedSpans(found[i]));return nw}function copyHistoryArray(events,newGroup,instantiateSel){for(var i=0,copy=[];i<events.length;++i){var event=events[i];if(event.ranges)copy.push(instantiateSel?Selection.prototype.deepCopy.call(event):event);else{var changes=event.changes,newChanges=[];copy.push({changes:newChanges});for(var j=0;j<changes.length;++j){var m,change=changes[j];newChanges.push({from:change.from,to:change.to,text:change.text});if(newGroup)for(var prop in change)if((m=prop.match(/^spans_(\d+)$/))&&indexOf(newGroup,Number(m[1]))>-1){lst(newChanges)[prop]=change[prop];delete change[prop]}}}}return copy}function rebaseHistSelSingle(pos,from,to,diff){if(to<pos.line)pos.line+=diff;else if(from<pos.line){pos.line=from;pos.ch=0}}function rebaseHistArray(array,from,to,diff){for(var i=0;i<array.length;++i){var sub=array[i],ok=!0;if(sub.ranges){if(!sub.copied){sub=array[i]=sub.deepCopy();sub.copied=!0}for(var j=0;j<sub.ranges.length;j++){rebaseHistSelSingle(sub.ranges[j].anchor,from,to,diff);rebaseHistSelSingle(sub.ranges[j].head,from,to,diff)}}else{for(var j=0;j<sub.changes.length;++j){var cur=sub.changes[j];if(to<cur.from.line){cur.from=Pos(cur.from.line+diff,cur.from.ch);cur.to=Pos(cur.to.line+diff,cur.to.ch)}else if(from<=cur.to.line){ok=!1;break}}if(!ok){array.splice(0,i+1);i=0}}}}function rebaseHist(hist,change){var from=change.from.line,to=change.to.line,diff=change.text.length-(to-from)-1;rebaseHistArray(hist.done,from,to,diff);rebaseHistArray(hist.undone,from,to,diff)}function e_defaultPrevented(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function e_target(e){return e.target||e.srcElement}function e_button(e){var b=e.which;null==b&&(1&e.button?b=1:2&e.button?b=3:4&e.button&&(b=2));mac&&e.ctrlKey&&1==b&&(b=3);return b}function getHandlers(emitter,type,copy){var arr=emitter._handlers&&emitter._handlers[type];return copy?arr&&arr.length>0?arr.slice():noHandlers:arr||noHandlers}function signalLater(emitter,type){function bnd(f){return function(){f.apply(null,args)}}var arr=getHandlers(emitter,type,!1);if(arr.length){var list,args=Array.prototype.slice.call(arguments,2);if(operationGroup)list=operationGroup.delayedCallbacks;else if(orphanDelayedCallbacks)list=orphanDelayedCallbacks;else{list=orphanDelayedCallbacks=[];setTimeout(fireOrphanDelayed,0)}for(var i=0;i<arr.length;++i)list.push(bnd(arr[i]))}}function fireOrphanDelayed(){var delayed=orphanDelayedCallbacks;orphanDelayedCallbacks=null;for(var i=0;i<delayed.length;++i)delayed[i]()}function signalDOMEvent(cm,e,override){"string"==typeof e&&(e={type:e,preventDefault:function(){this.defaultPrevented=!0}});signal(cm,override||e.type,cm,e);return e_defaultPrevented(e)||e.codemirrorIgnore}function signalCursorActivity(cm){var arr=cm._handlers&&cm._handlers.cursorActivity;if(arr)for(var set=cm.curOp.cursorActivityHandlers||(cm.curOp.cursorActivityHandlers=[]),i=0;i<arr.length;++i)-1==indexOf(set,arr[i])&&set.push(arr[i])}function hasHandler(emitter,type){return getHandlers(emitter,type).length>0}function eventMixin(ctor){ctor.prototype.on=function(type,f){on(this,type,f)};ctor.prototype.off=function(type,f){off(this,type,f)}}function Delayed(){this.id=null}function spaceStr(n){for(;spaceStrs.length<=n;)spaceStrs.push(lst(spaceStrs)+" ");return spaceStrs[n]}function lst(arr){return arr[arr.length-1]}function indexOf(array,elt){for(var i=0;i<array.length;++i)if(array[i]==elt)return i;return-1}function map(array,f){for(var out=[],i=0;i<array.length;i++)out[i]=f(array[i],i);return out}function nothing(){}function createObj(base,props){var inst;if(Object.create)inst=Object.create(base);else{nothing.prototype=base;inst=new nothing}props&&copyObj(props,inst);return inst}function copyObj(obj,target,overwrite){target||(target={});for(var prop in obj)!obj.hasOwnProperty(prop)||overwrite===!1&&target.hasOwnProperty(prop)||(target[prop]=obj[prop]);return target}function bind(f){var args=Array.prototype.slice.call(arguments,1);return function(){return f.apply(null,args)}}function isWordChar(ch,helper){return helper?helper.source.indexOf("\\w")>-1&&isWordCharBasic(ch)?!0:helper.test(ch):isWordCharBasic(ch)}function isEmpty(obj){for(var n in obj)if(obj.hasOwnProperty(n)&&obj[n])return!1;return!0}function isExtendingChar(ch){return ch.charCodeAt(0)>=768&&extendingChars.test(ch)}function elt(tag,content,className,style){var e=document.createElement(tag);className&&(e.className=className);style&&(e.style.cssText=style);if("string"==typeof content)e.appendChild(document.createTextNode(content));else if(content)for(var i=0;i<content.length;++i)e.appendChild(content[i]);return e}function removeChildren(e){for(var count=e.childNodes.length;count>0;--count)e.removeChild(e.firstChild);return e}function removeChildrenAndAdd(parent,e){return removeChildren(parent).appendChild(e)}function activeElt(){for(var activeElement=document.activeElement;activeElement&&activeElement.root&&activeElement.root.activeElement;)activeElement=activeElement.root.activeElement;return activeElement}function classTest(cls){return new RegExp("(^|\\s)"+cls+"(?:$|\\s)\\s*")}function joinClasses(a,b){for(var as=a.split(" "),i=0;i<as.length;i++)as[i]&&!classTest(as[i]).test(b)&&(b+=" "+as[i]);return b}function forEachCodeMirror(f){if(document.body.getElementsByClassName)for(var byClass=document.body.getElementsByClassName("CodeMirror"),i=0;i<byClass.length;i++){var cm=byClass[i].CodeMirror;cm&&f(cm)}}function ensureGlobalHandlers(){if(!globalsRegistered){registerGlobalHandlers();globalsRegistered=!0}}function registerGlobalHandlers(){var resizeTimer;on(window,"resize",function(){null==resizeTimer&&(resizeTimer=setTimeout(function(){resizeTimer=null;forEachCodeMirror(onResize)},100))});on(window,"blur",function(){forEachCodeMirror(onBlur)})}function zeroWidthElement(measure){if(null==zwspSupported){var test=elt("span","​");removeChildrenAndAdd(measure,elt("span",[test,document.createTextNode("x")]));0!=measure.firstChild.offsetHeight&&(zwspSupported=test.offsetWidth<=1&&test.offsetHeight>2&&!(ie&&8>ie_version))}var node=zwspSupported?elt("span","​"):elt("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");node.setAttribute("cm-text","");return node}function hasBadBidiRects(measure){if(null!=badBidiRects)return badBidiRects;var txt=removeChildrenAndAdd(measure,document.createTextNode("AخA")),r0=range(txt,0,1).getBoundingClientRect();if(!r0||r0.left==r0.right)return!1;var r1=range(txt,1,2).getBoundingClientRect();return badBidiRects=r1.right-r0.right<3}function hasBadZoomedRects(measure){if(null!=badZoomedRects)return badZoomedRects;var node=removeChildrenAndAdd(measure,elt("span","x")),normal=node.getBoundingClientRect(),fromRange=range(node,0,1).getBoundingClientRect();return badZoomedRects=Math.abs(normal.left-fromRange.left)>1}function iterateBidiSections(order,from,to,f){if(!order)return f(from,to,"ltr");for(var found=!1,i=0;i<order.length;++i){var part=order[i];if(part.from<to&&part.to>from||from==to&&part.to==from){f(Math.max(part.from,from),Math.min(part.to,to),1==part.level?"rtl":"ltr");found=!0}}found||f(from,to,"ltr")}function bidiLeft(part){return part.level%2?part.to:part.from}function bidiRight(part){return part.level%2?part.from:part.to}function lineLeft(line){var order=getOrder(line);return order?bidiLeft(order[0]):0}function lineRight(line){var order=getOrder(line);return order?bidiRight(lst(order)):line.text.length}function lineStart(cm,lineN){var line=getLine(cm.doc,lineN),visual=visualLine(line);visual!=line&&(lineN=lineNo(visual));var order=getOrder(visual),ch=order?order[0].level%2?lineRight(visual):lineLeft(visual):0;return Pos(lineN,ch)}function lineEnd(cm,lineN){for(var merged,line=getLine(cm.doc,lineN);merged=collapsedSpanAtEnd(line);){line=merged.find(1,!0).line;lineN=null}var order=getOrder(line),ch=order?order[0].level%2?lineLeft(line):lineRight(line):line.text.length;return Pos(null==lineN?lineNo(line):lineN,ch)}function lineStartSmart(cm,pos){var start=lineStart(cm,pos.line),line=getLine(cm.doc,start.line),order=getOrder(line);if(!order||0==order[0].level){var firstNonWS=Math.max(0,line.text.search(/\S/)),inWS=pos.line==start.line&&pos.ch<=firstNonWS&&pos.ch;return Pos(start.line,inWS?0:firstNonWS)}return start}function compareBidiLevel(order,a,b){var linedir=order[0].level;return a==linedir?!0:b==linedir?!1:b>a}function getBidiPartAt(order,pos){bidiOther=null;for(var found,i=0;i<order.length;++i){var cur=order[i];if(cur.from<pos&&cur.to>pos)return i;if(cur.from==pos||cur.to==pos){if(null!=found){if(compareBidiLevel(order,cur.level,order[found].level)){cur.from!=cur.to&&(bidiOther=found);return i}cur.from!=cur.to&&(bidiOther=i);return found}found=i}}return found}function moveInLine(line,pos,dir,byUnit){if(!byUnit)return pos+dir;do pos+=dir;while(pos>0&&isExtendingChar(line.text.charAt(pos)));return pos}function moveVisually(line,start,dir,byUnit){var bidi=getOrder(line);if(!bidi)return moveLogically(line,start,dir,byUnit);for(var pos=getBidiPartAt(bidi,start),part=bidi[pos],target=moveInLine(line,start,part.level%2?-dir:dir,byUnit);;){if(target>part.from&&target<part.to)return target;if(target==part.from||target==part.to){if(getBidiPartAt(bidi,target)==pos)return target;part=bidi[pos+=dir];return dir>0==part.level%2?part.to:part.from}part=bidi[pos+=dir];if(!part)return null;target=dir>0==part.level%2?moveInLine(line,part.to,-1,byUnit):moveInLine(line,part.from,1,byUnit)}}function moveLogically(line,start,dir,byUnit){var target=start+dir;if(byUnit)for(;target>0&&isExtendingChar(line.text.charAt(target));)target+=dir;return 0>target||target>line.text.length?null:target}var userAgent=navigator.userAgent,platform=navigator.platform,gecko=/gecko\/\d/i.test(userAgent),ie_upto10=/MSIE \d/.test(userAgent),ie_11up=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent),ie=ie_upto10||ie_11up,ie_version=ie&&(ie_upto10?document.documentMode||6:ie_11up[1]),webkit=/WebKit\//.test(userAgent),qtwebkit=webkit&&/Qt\/\d+\.\d+/.test(userAgent),chrome=/Chrome\//.test(userAgent),presto=/Opera\//.test(userAgent),safari=/Apple Computer/.test(navigator.vendor),mac_geMountainLion=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent),phantom=/PhantomJS/.test(userAgent),ios=/AppleWebKit/.test(userAgent)&&/Mobile\/\w+/.test(userAgent),mobile=ios||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent),mac=ios||/Mac/.test(platform),windows=/win/i.test(platform),presto_version=presto&&userAgent.match(/Version\/(\d*\.\d*)/);presto_version&&(presto_version=Number(presto_version[1]));if(presto_version&&presto_version>=15){presto=!1;webkit=!0}var flipCtrlCmd=mac&&(qtwebkit||presto&&(null==presto_version||12.11>presto_version)),captureRightClick=gecko||ie&&ie_version>=9,sawReadOnlySpans=!1,sawCollapsedSpans=!1;NativeScrollbars.prototype=copyObj({update:function(measure){var needsH=measure.scrollWidth>measure.clientWidth+1,needsV=measure.scrollHeight>measure.clientHeight+1,sWidth=measure.nativeBarWidth;if(needsV){this.vert.style.display="block";this.vert.style.bottom=needsH?sWidth+"px":"0";var totalHeight=measure.viewHeight-(needsH?sWidth:0);this.vert.firstChild.style.height=Math.max(0,measure.scrollHeight-measure.clientHeight+totalHeight)+"px"}else{this.vert.style.display="";this.vert.firstChild.style.height="0"}if(needsH){this.horiz.style.display="block";this.horiz.style.right=needsV?sWidth+"px":"0";this.horiz.style.left=measure.barLeft+"px";var totalWidth=measure.viewWidth-measure.barLeft-(needsV?sWidth:0);this.horiz.firstChild.style.width=measure.scrollWidth-measure.clientWidth+totalWidth+"px"}else{this.horiz.style.display="";this.horiz.firstChild.style.width="0"}if(!this.checkedOverlay&&measure.clientHeight>0){0==sWidth&&this.overlayHack();this.checkedOverlay=!0}return{right:needsV?sWidth:0,bottom:needsH?sWidth:0}},setScrollLeft:function(pos){this.horiz.scrollLeft!=pos&&(this.horiz.scrollLeft=pos)},setScrollTop:function(pos){this.vert.scrollTop!=pos&&(this.vert.scrollTop=pos)},overlayHack:function(){var w=mac&&!mac_geMountainLion?"12px":"18px";this.horiz.style.minHeight=this.vert.style.minWidth=w;var self=this,barMouseDown=function(e){e_target(e)!=self.vert&&e_target(e)!=self.horiz&&operation(self.cm,onMouseDown)(e)};on(this.vert,"mousedown",barMouseDown);on(this.horiz,"mousedown",barMouseDown)},clear:function(){var parent=this.horiz.parentNode;parent.removeChild(this.horiz);parent.removeChild(this.vert)}},NativeScrollbars.prototype);NullScrollbars.prototype=copyObj({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},NullScrollbars.prototype);CodeMirror.scrollbarModel={"native":NativeScrollbars,"null":NullScrollbars};DisplayUpdate.prototype.signal=function(emitter,type){hasHandler(emitter,type)&&this.events.push(arguments)};DisplayUpdate.prototype.finish=function(){for(var i=0;i<this.events.length;i++)signal.apply(null,this.events[i])};var Pos=CodeMirror.Pos=function(line,ch){if(!(this instanceof Pos))return new Pos(line,ch);this.line=line;this.ch=ch},cmp=CodeMirror.cmpPos=function(a,b){return a.line-b.line||a.ch-b.ch},lastCopied=null;TextareaInput.prototype=copyObj({init:function(display){function prepareCopyCut(e){if(cm.somethingSelected()){lastCopied=cm.getSelections();if(input.inaccurateSelection){input.prevInput="";input.inaccurateSelection=!1;te.value=lastCopied.join("\n");selectInput(te)}}else{if(!cm.options.lineWiseCopyCut)return;var ranges=copyableRanges(cm);lastCopied=ranges.text;if("cut"==e.type)cm.setSelections(ranges.ranges,null,sel_dontScroll);else{input.prevInput="";te.value=ranges.text.join("\n");selectInput(te)}}"cut"==e.type&&(cm.state.cutIncoming=!0)}var input=this,cm=this.cm,div=this.wrapper=hiddenTextarea(),te=this.textarea=div.firstChild;display.wrapper.insertBefore(div,display.wrapper.firstChild);ios&&(te.style.width="0px");on(te,"input",function(){ie&&ie_version>=9&&input.hasSelection&&(input.hasSelection=null);input.poll()});on(te,"paste",function(e){if(handlePaste(e,cm))return!0;cm.state.pasteIncoming=!0;input.fastPoll()});on(te,"cut",prepareCopyCut);on(te,"copy",prepareCopyCut);on(display.scroller,"paste",function(e){if(!eventInWidget(display,e)){cm.state.pasteIncoming=!0;input.focus()}});on(display.lineSpace,"selectstart",function(e){eventInWidget(display,e)||e_preventDefault(e)});on(te,"compositionstart",function(){var start=cm.getCursor("from");input.composing&&input.composing.range.clear();input.composing={start:start,range:cm.markText(start,cm.getCursor("to"),{className:"CodeMirror-composing"})}});on(te,"compositionend",function(){if(input.composing){input.poll();input.composing.range.clear();input.composing=null}})},prepareSelection:function(){var cm=this.cm,display=cm.display,doc=cm.doc,result=prepareSelection(cm);if(cm.options.moveInputWithCursor){var headPos=cursorCoords(cm,doc.sel.primary().head,"div"),wrapOff=display.wrapper.getBoundingClientRect(),lineOff=display.lineDiv.getBoundingClientRect();result.teTop=Math.max(0,Math.min(display.wrapper.clientHeight-10,headPos.top+lineOff.top-wrapOff.top));result.teLeft=Math.max(0,Math.min(display.wrapper.clientWidth-10,headPos.left+lineOff.left-wrapOff.left))}return result},showSelection:function(drawn){var cm=this.cm,display=cm.display;removeChildrenAndAdd(display.cursorDiv,drawn.cursors);removeChildrenAndAdd(display.selectionDiv,drawn.selection);if(null!=drawn.teTop){this.wrapper.style.top=drawn.teTop+"px";this.wrapper.style.left=drawn.teLeft+"px"}},reset:function(typing){if(!this.contextMenuPending){var minimal,selected,cm=this.cm,doc=cm.doc;if(cm.somethingSelected()){this.prevInput="";var range=doc.sel.primary();minimal=hasCopyEvent&&(range.to().line-range.from().line>100||(selected=cm.getSelection()).length>1e3);var content=minimal?"-":selected||cm.getSelection();this.textarea.value=content;cm.state.focused&&selectInput(this.textarea);ie&&ie_version>=9&&(this.hasSelection=content)}else if(!typing){this.prevInput=this.textarea.value="";ie&&ie_version>=9&&(this.hasSelection=null)}this.inaccurateSelection=minimal}},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if("nocursor"!=this.cm.options.readOnly&&(!mobile||activeElt()!=this.textarea))try{this.textarea.focus()}catch(e){}},blur:function(){this.textarea.blur()},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var input=this;input.pollingFast||input.polling.set(this.cm.options.pollInterval,function(){input.poll();input.cm.state.focused&&input.slowPoll()})},fastPoll:function(){function p(){var changed=input.poll();if(changed||missed){input.pollingFast=!1;input.slowPoll()}else{missed=!0;input.polling.set(60,p)}}var missed=!1,input=this;input.pollingFast=!0;input.polling.set(20,p)},poll:function(){var cm=this.cm,input=this.textarea,prevInput=this.prevInput;if(this.contextMenuPending||!cm.state.focused||hasSelection(input)&&!prevInput&&!this.composing||isReadOnly(cm)||cm.options.disableInput||cm.state.keySeq)return!1;var text=input.value;if(text==prevInput&&!cm.somethingSelected())return!1;if(ie&&ie_version>=9&&this.hasSelection===text||mac&&/[\uf700-\uf7ff]/.test(text)){cm.display.input.reset();return!1}if(cm.doc.sel==cm.display.selForContextMenu){var first=text.charCodeAt(0);8203!=first||prevInput||(prevInput="​");if(8666==first){this.reset();return this.cm.execCommand("undo")}}for(var same=0,l=Math.min(prevInput.length,text.length);l>same&&prevInput.charCodeAt(same)==text.charCodeAt(same);)++same;var self=this;runInOp(cm,function(){applyTextInput(cm,text.slice(same),prevInput.length-same,null,self.composing?"*compose":null);text.length>1e3||text.indexOf("\n")>-1?input.value=self.prevInput="":self.prevInput=text;if(self.composing){self.composing.range.clear();self.composing.range=cm.markText(self.composing.start,cm.getCursor("to"),{className:"CodeMirror-composing"})}});return!0},ensurePolled:function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},onKeyPress:function(){ie&&ie_version>=9&&(this.hasSelection=null);this.fastPoll()},onContextMenu:function(e){function prepareSelectAllHack(){if(null!=te.selectionStart){var selected=cm.somethingSelected(),extval="​"+(selected?te.value:"");te.value="⇚";te.value=extval;input.prevInput=selected?"":"​";te.selectionStart=1;te.selectionEnd=extval.length;display.selForContextMenu=cm.doc.sel}}function rehide(){input.contextMenuPending=!1;input.wrapper.style.position="relative";te.style.cssText=oldCSS;ie&&9>ie_version&&display.scrollbars.setScrollTop(display.scroller.scrollTop=scrollPos);if(null!=te.selectionStart){(!ie||ie&&9>ie_version)&&prepareSelectAllHack();var i=0,poll=function(){display.selForContextMenu==cm.doc.sel&&0==te.selectionStart&&te.selectionEnd>0&&"​"==input.prevInput?operation(cm,commands.selectAll)(cm):i++<10?display.detectingSelectAll=setTimeout(poll,500):display.input.reset()};display.detectingSelectAll=setTimeout(poll,200)}}var input=this,cm=input.cm,display=cm.display,te=input.textarea,pos=posFromMouse(cm,e),scrollPos=display.scroller.scrollTop;if(pos&&!presto){var reset=cm.options.resetSelectionOnContextMenu;reset&&-1==cm.doc.sel.contains(pos)&&operation(cm,setSelection)(cm.doc,simpleSelection(pos),sel_dontScroll);var oldCSS=te.style.cssText;input.wrapper.style.position="absolute";te.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(e.clientY-5)+"px; left: "+(e.clientX-5)+"px; z-index: 1000; background: "+(ie?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";if(webkit)var oldScrollY=window.scrollY;display.input.focus();webkit&&window.scrollTo(null,oldScrollY);display.input.reset();cm.somethingSelected()||(te.value=input.prevInput=" ");input.contextMenuPending=!0;display.selForContextMenu=cm.doc.sel;clearTimeout(display.detectingSelectAll);ie&&ie_version>=9&&prepareSelectAllHack();if(captureRightClick){e_stop(e);var mouseup=function(){off(window,"mouseup",mouseup);setTimeout(rehide,20)};on(window,"mouseup",mouseup)}else setTimeout(rehide,50)}},readOnlyChanged:function(val){val||this.reset()},setUneditable:nothing,needsContentAttribute:!1},TextareaInput.prototype);ContentEditableInput.prototype=copyObj({init:function(display){function onCopyCut(e){if(cm.somethingSelected()){lastCopied=cm.getSelections();"cut"==e.type&&cm.replaceSelection("",null,"cut")}else{if(!cm.options.lineWiseCopyCut)return;var ranges=copyableRanges(cm);lastCopied=ranges.text;"cut"==e.type&&cm.operation(function(){cm.setSelections(ranges.ranges,0,sel_dontScroll);cm.replaceSelection("",null,"cut")})}if(e.clipboardData&&!ios){e.preventDefault();e.clipboardData.clearData();e.clipboardData.setData("text/plain",lastCopied.join("\n"))}else{var kludge=hiddenTextarea(),te=kludge.firstChild;cm.display.lineSpace.insertBefore(kludge,cm.display.lineSpace.firstChild);te.value=lastCopied.join("\n");var hadFocus=document.activeElement;selectInput(te);setTimeout(function(){cm.display.lineSpace.removeChild(kludge);hadFocus.focus()},50)}}var input=this,cm=input.cm,div=input.div=display.lineDiv;disableBrowserMagic(div);on(div,"paste",function(e){handlePaste(e,cm)});on(div,"compositionstart",function(e){var data=e.data;input.composing={sel:cm.doc.sel,data:data,startData:data};if(data){var prim=cm.doc.sel.primary(),line=cm.getLine(prim.head.line),found=line.indexOf(data,Math.max(0,prim.head.ch-data.length));found>-1&&found<=prim.head.ch&&(input.composing.sel=simpleSelection(Pos(prim.head.line,found),Pos(prim.head.line,found+data.length)))}});on(div,"compositionupdate",function(e){input.composing.data=e.data});on(div,"compositionend",function(e){var ours=input.composing;if(ours){e.data==ours.startData||/\u200b/.test(e.data)||(ours.data=e.data);setTimeout(function(){ours.handled||input.applyComposition(ours);input.composing==ours&&(input.composing=null)},50)}});on(div,"touchstart",function(){input.forceCompositionEnd()});on(div,"input",function(){input.composing||(isReadOnly(cm)||!input.pollContent())&&runInOp(input.cm,function(){regChange(cm)})});on(div,"copy",onCopyCut);on(div,"cut",onCopyCut)},prepareSelection:function(){var result=prepareSelection(this.cm,!1);result.focus=this.cm.state.focused;return result},showSelection:function(info){if(info&&this.cm.display.view.length){info.focus&&this.showPrimarySelection();this.showMultipleSelections(info)}},showPrimarySelection:function(){var sel=window.getSelection(),prim=this.cm.doc.sel.primary(),curAnchor=domToPos(this.cm,sel.anchorNode,sel.anchorOffset),curFocus=domToPos(this.cm,sel.focusNode,sel.focusOffset);if(!curAnchor||curAnchor.bad||!curFocus||curFocus.bad||0!=cmp(minPos(curAnchor,curFocus),prim.from())||0!=cmp(maxPos(curAnchor,curFocus),prim.to())){var start=posToDOM(this.cm,prim.from()),end=posToDOM(this.cm,prim.to());if(start||end){var view=this.cm.display.view,old=sel.rangeCount&&sel.getRangeAt(0);if(start){if(!end){var measure=view[view.length-1].measure,map=measure.maps?measure.maps[measure.maps.length-1]:measure.map;end={node:map[map.length-1],offset:map[map.length-2]-map[map.length-3]}}}else start={node:view[0].measure.map[2],offset:0};try{var rng=range(start.node,start.offset,end.offset,end.node)}catch(e){}if(rng){sel.removeAllRanges();sel.addRange(rng);old&&null==sel.anchorNode?sel.addRange(old):gecko&&this.startGracePeriod()}this.rememberSelection()}}},startGracePeriod:function(){var input=this;clearTimeout(this.gracePeriod);this.gracePeriod=setTimeout(function(){input.gracePeriod=!1;input.selectionChanged()&&input.cm.operation(function(){input.cm.curOp.selectionChanged=!0})},20)},showMultipleSelections:function(info){removeChildrenAndAdd(this.cm.display.cursorDiv,info.cursors);removeChildrenAndAdd(this.cm.display.selectionDiv,info.selection)},rememberSelection:function(){var sel=window.getSelection();this.lastAnchorNode=sel.anchorNode;this.lastAnchorOffset=sel.anchorOffset;this.lastFocusNode=sel.focusNode;this.lastFocusOffset=sel.focusOffset},selectionInEditor:function(){var sel=window.getSelection();if(!sel.rangeCount)return!1;var node=sel.getRangeAt(0).commonAncestorContainer;return contains(this.div,node)},focus:function(){"nocursor"!=this.cm.options.readOnly&&this.div.focus()},blur:function(){this.div.blur()},getField:function(){return this.div},supportsTouch:function(){return!0},receivedFocus:function(){function poll(){if(input.cm.state.focused){input.pollSelection();input.polling.set(input.cm.options.pollInterval,poll)}}var input=this;this.selectionInEditor()?this.pollSelection():runInOp(this.cm,function(){input.cm.curOp.selectionChanged=!0});this.polling.set(this.cm.options.pollInterval,poll)},selectionChanged:function(){var sel=window.getSelection();return sel.anchorNode!=this.lastAnchorNode||sel.anchorOffset!=this.lastAnchorOffset||sel.focusNode!=this.lastFocusNode||sel.focusOffset!=this.lastFocusOffset},pollSelection:function(){if(!this.composing&&!this.gracePeriod&&this.selectionChanged()){var sel=window.getSelection(),cm=this.cm;this.rememberSelection();var anchor=domToPos(cm,sel.anchorNode,sel.anchorOffset),head=domToPos(cm,sel.focusNode,sel.focusOffset);anchor&&head&&runInOp(cm,function(){setSelection(cm.doc,simpleSelection(anchor,head),sel_dontScroll);(anchor.bad||head.bad)&&(cm.curOp.selectionChanged=!0)})}},pollContent:function(){var cm=this.cm,display=cm.display,sel=cm.doc.sel.primary(),from=sel.from(),to=sel.to();if(from.line<display.viewFrom||to.line>display.viewTo-1)return!1;var fromIndex;if(from.line==display.viewFrom||0==(fromIndex=findViewIndex(cm,from.line)))var fromLine=lineNo(display.view[0].line),fromNode=display.view[0].node;else var fromLine=lineNo(display.view[fromIndex].line),fromNode=display.view[fromIndex-1].node.nextSibling;var toIndex=findViewIndex(cm,to.line);if(toIndex==display.view.length-1)var toLine=display.viewTo-1,toNode=display.lineDiv.lastChild;else var toLine=lineNo(display.view[toIndex+1].line)-1,toNode=display.view[toIndex+1].node.previousSibling;for(var newText=cm.doc.splitLines(domTextBetween(cm,fromNode,toNode,fromLine,toLine)),oldText=getBetween(cm.doc,Pos(fromLine,0),Pos(toLine,getLine(cm.doc,toLine).text.length));newText.length>1&&oldText.length>1;)if(lst(newText)==lst(oldText)){newText.pop();oldText.pop();toLine--}else{if(newText[0]!=oldText[0])break;newText.shift();oldText.shift();fromLine++}for(var cutFront=0,cutEnd=0,newTop=newText[0],oldTop=oldText[0],maxCutFront=Math.min(newTop.length,oldTop.length);maxCutFront>cutFront&&newTop.charCodeAt(cutFront)==oldTop.charCodeAt(cutFront);)++cutFront;for(var newBot=lst(newText),oldBot=lst(oldText),maxCutEnd=Math.min(newBot.length-(1==newText.length?cutFront:0),oldBot.length-(1==oldText.length?cutFront:0));maxCutEnd>cutEnd&&newBot.charCodeAt(newBot.length-cutEnd-1)==oldBot.charCodeAt(oldBot.length-cutEnd-1);)++cutEnd;newText[newText.length-1]=newBot.slice(0,newBot.length-cutEnd);newText[0]=newText[0].slice(cutFront);var chFrom=Pos(fromLine,cutFront),chTo=Pos(toLine,oldText.length?lst(oldText).length-cutEnd:0);if(newText.length>1||newText[0]||cmp(chFrom,chTo)){replaceRange(cm.doc,newText,chFrom,chTo,"+input");return!0}},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){if(this.composing&&!this.composing.handled){this.applyComposition(this.composing);this.composing.handled=!0;this.div.blur();this.div.focus()}},applyComposition:function(composing){isReadOnly(this.cm)?operation(this.cm,regChange)(this.cm):composing.data&&composing.data!=composing.startData&&operation(this.cm,applyTextInput)(this.cm,composing.data,0,composing.sel)},setUneditable:function(node){node.contentEditable="false"},onKeyPress:function(e){e.preventDefault();isReadOnly(this.cm)||operation(this.cm,applyTextInput)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0)},readOnlyChanged:function(val){this.div.contentEditable=String("nocursor"!=val)},onContextMenu:nothing,resetPosition:nothing,needsContentAttribute:!0},ContentEditableInput.prototype);CodeMirror.inputStyles={textarea:TextareaInput,contenteditable:ContentEditableInput};Selection.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(other){if(other==this)return!0;if(other.primIndex!=this.primIndex||other.ranges.length!=this.ranges.length)return!1;for(var i=0;i<this.ranges.length;i++){var here=this.ranges[i],there=other.ranges[i];if(0!=cmp(here.anchor,there.anchor)||0!=cmp(here.head,there.head))return!1}return!0},deepCopy:function(){for(var out=[],i=0;i<this.ranges.length;i++)out[i]=new Range(copyPos(this.ranges[i].anchor),copyPos(this.ranges[i].head));return new Selection(out,this.primIndex)},somethingSelected:function(){for(var i=0;i<this.ranges.length;i++)if(!this.ranges[i].empty())return!0;return!1},contains:function(pos,end){end||(end=pos);for(var i=0;i<this.ranges.length;i++){var range=this.ranges[i];if(cmp(end,range.from())>=0&&cmp(pos,range.to())<=0)return i}return-1}};Range.prototype={from:function(){return minPos(this.anchor,this.head)},to:function(){return maxPos(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var measureText,lastClick,lastDoubleClick,nullRect={left:0,right:0,top:0,bottom:0},operationGroup=null,nextOpId=0,lastDrop=0,wheelSamples=0,wheelPixelsPerUnit=null;ie?wheelPixelsPerUnit=-.53:gecko?wheelPixelsPerUnit=15:chrome?wheelPixelsPerUnit=-.7:safari&&(wheelPixelsPerUnit=-1/3);var wheelEventDelta=function(e){var dx=e.wheelDeltaX,dy=e.wheelDeltaY;null==dx&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(dx=e.detail);null==dy&&e.detail&&e.axis==e.VERTICAL_AXIS?dy=e.detail:null==dy&&(dy=e.wheelDelta);return{x:dx,y:dy}};CodeMirror.wheelEventPixels=function(e){var delta=wheelEventDelta(e);delta.x*=wheelPixelsPerUnit;delta.y*=wheelPixelsPerUnit;return delta};var stopSeq=new Delayed,lastStoppedKey=null,changeEnd=CodeMirror.changeEnd=function(change){
6
- return change.text?Pos(change.from.line+change.text.length-1,lst(change.text).length+(1==change.text.length?change.from.ch:0)):change.to};CodeMirror.prototype={constructor:CodeMirror,focus:function(){window.focus();this.display.input.focus()},setOption:function(option,value){var options=this.options,old=options[option];if(options[option]!=value||"mode"==option){options[option]=value;optionHandlers.hasOwnProperty(option)&&operation(this,optionHandlers[option])(this,value,old)}},getOption:function(option){return this.options[option]},getDoc:function(){return this.doc},addKeyMap:function(map,bottom){this.state.keyMaps[bottom?"push":"unshift"](getKeyMap(map))},removeKeyMap:function(map){for(var maps=this.state.keyMaps,i=0;i<maps.length;++i)if(maps[i]==map||maps[i].name==map){maps.splice(i,1);return!0}},addOverlay:methodOp(function(spec,options){var mode=spec.token?spec:CodeMirror.getMode(this.options,spec);if(mode.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:mode,modeSpec:spec,opaque:options&&options.opaque});this.state.modeGen++;regChange(this)}),removeOverlay:methodOp(function(spec){for(var overlays=this.state.overlays,i=0;i<overlays.length;++i){var cur=overlays[i].modeSpec;if(cur==spec||"string"==typeof spec&&cur.name==spec){overlays.splice(i,1);this.state.modeGen++;regChange(this);return}}}),indentLine:methodOp(function(n,dir,aggressive){"string"!=typeof dir&&"number"!=typeof dir&&(dir=null==dir?this.options.smartIndent?"smart":"prev":dir?"add":"subtract");isLine(this.doc,n)&&indentLine(this,n,dir,aggressive)}),indentSelection:methodOp(function(how){for(var ranges=this.doc.sel.ranges,end=-1,i=0;i<ranges.length;i++){var range=ranges[i];if(range.empty()){if(range.head.line>end){indentLine(this,range.head.line,how,!0);end=range.head.line;i==this.doc.sel.primIndex&&ensureCursorVisible(this)}}else{var from=range.from(),to=range.to(),start=Math.max(end,from.line);end=Math.min(this.lastLine(),to.line-(to.ch?0:1))+1;for(var j=start;end>j;++j)indentLine(this,j,how);var newRanges=this.doc.sel.ranges;0==from.ch&&ranges.length==newRanges.length&&newRanges[i].from().ch>0&&replaceOneSelection(this.doc,i,new Range(from,newRanges[i].to()),sel_dontScroll)}}}),getTokenAt:function(pos,precise){return takeToken(this,pos,precise)},getLineTokens:function(line,precise){return takeToken(this,Pos(line),precise,!0)},getTokenTypeAt:function(pos){pos=clipPos(this.doc,pos);var type,styles=getLineStyles(this,getLine(this.doc,pos.line)),before=0,after=(styles.length-1)/2,ch=pos.ch;if(0==ch)type=styles[2];else for(;;){var mid=before+after>>1;if((mid?styles[2*mid-1]:0)>=ch)after=mid;else{if(!(styles[2*mid+1]<ch)){type=styles[2*mid+2];break}before=mid+1}}var cut=type?type.indexOf("cm-overlay "):-1;return 0>cut?type:0==cut?null:type.slice(0,cut-1)},getModeAt:function(pos){var mode=this.doc.mode;return mode.innerMode?CodeMirror.innerMode(mode,this.getTokenAt(pos).state).mode:mode},getHelper:function(pos,type){return this.getHelpers(pos,type)[0]},getHelpers:function(pos,type){var found=[];if(!helpers.hasOwnProperty(type))return found;var help=helpers[type],mode=this.getModeAt(pos);if("string"==typeof mode[type])help[mode[type]]&&found.push(help[mode[type]]);else if(mode[type])for(var i=0;i<mode[type].length;i++){var val=help[mode[type][i]];val&&found.push(val)}else mode.helperType&&help[mode.helperType]?found.push(help[mode.helperType]):help[mode.name]&&found.push(help[mode.name]);for(var i=0;i<help._global.length;i++){var cur=help._global[i];cur.pred(mode,this)&&-1==indexOf(found,cur.val)&&found.push(cur.val)}return found},getStateAfter:function(line,precise){var doc=this.doc;line=clipLine(doc,null==line?doc.first+doc.size-1:line);return getStateBefore(this,line+1,precise)},cursorCoords:function(start,mode){var pos,range=this.doc.sel.primary();pos=null==start?range.head:"object"==typeof start?clipPos(this.doc,start):start?range.from():range.to();return cursorCoords(this,pos,mode||"page")},charCoords:function(pos,mode){return charCoords(this,clipPos(this.doc,pos),mode||"page")},coordsChar:function(coords,mode){coords=fromCoordSystem(this,coords,mode||"page");return coordsChar(this,coords.left,coords.top)},lineAtHeight:function(height,mode){height=fromCoordSystem(this,{top:height,left:0},mode||"page").top;return lineAtHeight(this.doc,height+this.display.viewOffset)},heightAtLine:function(line,mode){var lineObj,end=!1;if("number"==typeof line){var last=this.doc.first+this.doc.size-1;if(line<this.doc.first)line=this.doc.first;else if(line>last){line=last;end=!0}lineObj=getLine(this.doc,line)}else lineObj=line;return intoCoordSystem(this,lineObj,{top:0,left:0},mode||"page").top+(end?this.doc.height-heightAtLine(lineObj):0)},defaultTextHeight:function(){return textHeight(this.display)},defaultCharWidth:function(){return charWidth(this.display)},setGutterMarker:methodOp(function(line,gutterID,value){return changeLine(this.doc,line,"gutter",function(line){var markers=line.gutterMarkers||(line.gutterMarkers={});markers[gutterID]=value;!value&&isEmpty(markers)&&(line.gutterMarkers=null);return!0})}),clearGutter:methodOp(function(gutterID){var cm=this,doc=cm.doc,i=doc.first;doc.iter(function(line){if(line.gutterMarkers&&line.gutterMarkers[gutterID]){line.gutterMarkers[gutterID]=null;regLineChange(cm,i,"gutter");isEmpty(line.gutterMarkers)&&(line.gutterMarkers=null)}++i})}),lineInfo:function(line){if("number"==typeof line){if(!isLine(this.doc,line))return null;var n=line;line=getLine(this.doc,line);if(!line)return null}else{var n=lineNo(line);if(null==n)return null}return{line:n,handle:line,text:line.text,gutterMarkers:line.gutterMarkers,textClass:line.textClass,bgClass:line.bgClass,wrapClass:line.wrapClass,widgets:line.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(pos,node,scroll,vert,horiz){var display=this.display;pos=cursorCoords(this,clipPos(this.doc,pos));var top=pos.bottom,left=pos.left;node.style.position="absolute";node.setAttribute("cm-ignore-events","true");this.display.input.setUneditable(node);display.sizer.appendChild(node);if("over"==vert)top=pos.top;else if("above"==vert||"near"==vert){var vspace=Math.max(display.wrapper.clientHeight,this.doc.height),hspace=Math.max(display.sizer.clientWidth,display.lineSpace.clientWidth);("above"==vert||pos.bottom+node.offsetHeight>vspace)&&pos.top>node.offsetHeight?top=pos.top-node.offsetHeight:pos.bottom+node.offsetHeight<=vspace&&(top=pos.bottom);left+node.offsetWidth>hspace&&(left=hspace-node.offsetWidth)}node.style.top=top+"px";node.style.left=node.style.right="";if("right"==horiz){left=display.sizer.clientWidth-node.offsetWidth;node.style.right="0px"}else{"left"==horiz?left=0:"middle"==horiz&&(left=(display.sizer.clientWidth-node.offsetWidth)/2);node.style.left=left+"px"}scroll&&scrollIntoView(this,left,top,left+node.offsetWidth,top+node.offsetHeight)},triggerOnKeyDown:methodOp(onKeyDown),triggerOnKeyPress:methodOp(onKeyPress),triggerOnKeyUp:onKeyUp,execCommand:function(cmd){return commands.hasOwnProperty(cmd)?commands[cmd].call(null,this):void 0},triggerElectric:methodOp(function(text){triggerElectric(this,text)}),findPosH:function(from,amount,unit,visually){var dir=1;if(0>amount){dir=-1;amount=-amount}for(var i=0,cur=clipPos(this.doc,from);amount>i;++i){cur=findPosH(this.doc,cur,dir,unit,visually);if(cur.hitSide)break}return cur},moveH:methodOp(function(dir,unit){var cm=this;cm.extendSelectionsBy(function(range){return cm.display.shift||cm.doc.extend||range.empty()?findPosH(cm.doc,range.head,dir,unit,cm.options.rtlMoveVisually):0>dir?range.from():range.to()},sel_move)}),deleteH:methodOp(function(dir,unit){var sel=this.doc.sel,doc=this.doc;sel.somethingSelected()?doc.replaceSelection("",null,"+delete"):deleteNearSelection(this,function(range){var other=findPosH(doc,range.head,dir,unit,!1);return 0>dir?{from:other,to:range.head}:{from:range.head,to:other}})}),findPosV:function(from,amount,unit,goalColumn){var dir=1,x=goalColumn;if(0>amount){dir=-1;amount=-amount}for(var i=0,cur=clipPos(this.doc,from);amount>i;++i){var coords=cursorCoords(this,cur,"div");null==x?x=coords.left:coords.left=x;cur=findPosV(this,coords,dir,unit);if(cur.hitSide)break}return cur},moveV:methodOp(function(dir,unit){var cm=this,doc=this.doc,goals=[],collapse=!cm.display.shift&&!doc.extend&&doc.sel.somethingSelected();doc.extendSelectionsBy(function(range){if(collapse)return 0>dir?range.from():range.to();var headPos=cursorCoords(cm,range.head,"div");null!=range.goalColumn&&(headPos.left=range.goalColumn);goals.push(headPos.left);var pos=findPosV(cm,headPos,dir,unit);"page"==unit&&range==doc.sel.primary()&&addToScrollPos(cm,null,charCoords(cm,pos,"div").top-headPos.top);return pos},sel_move);if(goals.length)for(var i=0;i<doc.sel.ranges.length;i++)doc.sel.ranges[i].goalColumn=goals[i]}),findWordAt:function(pos){var doc=this.doc,line=getLine(doc,pos.line).text,start=pos.ch,end=pos.ch;if(line){var helper=this.getHelper(pos,"wordChars");(pos.xRel<0||end==line.length)&&start?--start:++end;for(var startChar=line.charAt(start),check=isWordChar(startChar,helper)?function(ch){return isWordChar(ch,helper)}:/\s/.test(startChar)?function(ch){return/\s/.test(ch)}:function(ch){return!/\s/.test(ch)&&!isWordChar(ch)};start>0&&check(line.charAt(start-1));)--start;for(;end<line.length&&check(line.charAt(end));)++end}return new Range(Pos(pos.line,start),Pos(pos.line,end))},toggleOverwrite:function(value){if(null==value||value!=this.state.overwrite){(this.state.overwrite=!this.state.overwrite)?addClass(this.display.cursorDiv,"CodeMirror-overwrite"):rmClass(this.display.cursorDiv,"CodeMirror-overwrite");signal(this,"overwriteToggle",this,this.state.overwrite)}},hasFocus:function(){return this.display.input.getField()==activeElt()},scrollTo:methodOp(function(x,y){(null!=x||null!=y)&&resolveScrollToPos(this);null!=x&&(this.curOp.scrollLeft=x);null!=y&&(this.curOp.scrollTop=y)}),getScrollInfo:function(){var scroller=this.display.scroller;return{left:scroller.scrollLeft,top:scroller.scrollTop,height:scroller.scrollHeight-scrollGap(this)-this.display.barHeight,width:scroller.scrollWidth-scrollGap(this)-this.display.barWidth,clientHeight:displayHeight(this),clientWidth:displayWidth(this)}},scrollIntoView:methodOp(function(range,margin){if(null==range){range={from:this.doc.sel.primary().head,to:null};null==margin&&(margin=this.options.cursorScrollMargin)}else"number"==typeof range?range={from:Pos(range,0),to:null}:null==range.from&&(range={from:range,to:null});range.to||(range.to=range.from);range.margin=margin||0;if(null!=range.from.line){resolveScrollToPos(this);this.curOp.scrollToPos=range}else{var sPos=calculateScrollPos(this,Math.min(range.from.left,range.to.left),Math.min(range.from.top,range.to.top)-range.margin,Math.max(range.from.right,range.to.right),Math.max(range.from.bottom,range.to.bottom)+range.margin);this.scrollTo(sPos.scrollLeft,sPos.scrollTop)}}),setSize:methodOp(function(width,height){function interpret(val){return"number"==typeof val||/^\d+$/.test(String(val))?val+"px":val}var cm=this;null!=width&&(cm.display.wrapper.style.width=interpret(width));null!=height&&(cm.display.wrapper.style.height=interpret(height));cm.options.lineWrapping&&clearLineMeasurementCache(this);var lineNo=cm.display.viewFrom;cm.doc.iter(lineNo,cm.display.viewTo,function(line){if(line.widgets)for(var i=0;i<line.widgets.length;i++)if(line.widgets[i].noHScroll){regLineChange(cm,lineNo,"widget");break}++lineNo});cm.curOp.forceUpdate=!0;signal(cm,"refresh",this)}),operation:function(f){return runInOp(this,f)},refresh:methodOp(function(){var oldHeight=this.display.cachedTextHeight;regChange(this);this.curOp.forceUpdate=!0;clearCaches(this);this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop);updateGutterSpace(this);(null==oldHeight||Math.abs(oldHeight-textHeight(this.display))>.5)&&estimateLineHeights(this);signal(this,"refresh",this)}),swapDoc:methodOp(function(doc){var old=this.doc;old.cm=null;attachDoc(this,doc);clearCaches(this);this.display.input.reset();this.scrollTo(doc.scrollLeft,doc.scrollTop);this.curOp.forceScroll=!0;signalLater(this,"swapDoc",this,old);return old}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}};eventMixin(CodeMirror);var defaults=CodeMirror.defaults={},optionHandlers=CodeMirror.optionHandlers={},Init=CodeMirror.Init={toString:function(){return"CodeMirror.Init"}};option("value","",function(cm,val){cm.setValue(val)},!0);option("mode",null,function(cm,val){cm.doc.modeOption=val;loadMode(cm)},!0);option("indentUnit",2,loadMode,!0);option("indentWithTabs",!1);option("smartIndent",!0);option("tabSize",4,function(cm){resetModeState(cm);clearCaches(cm);regChange(cm)},!0);option("lineSeparator",null,function(cm,val){cm.doc.lineSep=val;if(val){var newBreaks=[],lineNo=cm.doc.first;cm.doc.iter(function(line){for(var pos=0;;){var found=line.text.indexOf(val,pos);if(-1==found)break;pos=found+val.length;newBreaks.push(Pos(lineNo,found))}lineNo++});for(var i=newBreaks.length-1;i>=0;i--)replaceRange(cm.doc,val,newBreaks[i],Pos(newBreaks[i].line,newBreaks[i].ch+val.length))}});option("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(cm,val,old){cm.state.specialChars=new RegExp(val.source+(val.test(" ")?"":"| "),"g");old!=CodeMirror.Init&&cm.refresh()});option("specialCharPlaceholder",defaultSpecialCharPlaceholder,function(cm){cm.refresh()},!0);option("electricChars",!0);option("inputStyle",mobile?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0);option("rtlMoveVisually",!windows);option("wholeLineUpdateBefore",!0);option("theme","default",function(cm){themeChanged(cm);guttersChanged(cm)},!0);option("keyMap","default",function(cm,val,old){var next=getKeyMap(val),prev=old!=CodeMirror.Init&&getKeyMap(old);prev&&prev.detach&&prev.detach(cm,next);next.attach&&next.attach(cm,prev||null)});option("extraKeys",null);option("lineWrapping",!1,wrappingChanged,!0);option("gutters",[],function(cm){setGuttersForLineNumbers(cm.options);guttersChanged(cm)},!0);option("fixedGutter",!0,function(cm,val){cm.display.gutters.style.left=val?compensateForHScroll(cm.display)+"px":"0";cm.refresh()},!0);option("coverGutterNextToScrollbar",!1,function(cm){updateScrollbars(cm)},!0);option("scrollbarStyle","native",function(cm){initScrollbars(cm);updateScrollbars(cm);cm.display.scrollbars.setScrollTop(cm.doc.scrollTop);cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft)},!0);option("lineNumbers",!1,function(cm){setGuttersForLineNumbers(cm.options);guttersChanged(cm)},!0);option("firstLineNumber",1,guttersChanged,!0);option("lineNumberFormatter",function(integer){return integer},guttersChanged,!0);option("showCursorWhenSelecting",!1,updateSelection,!0);option("resetSelectionOnContextMenu",!0);option("lineWiseCopyCut",!0);option("readOnly",!1,function(cm,val){if("nocursor"==val){onBlur(cm);cm.display.input.blur();cm.display.disabled=!0}else cm.display.disabled=!1;cm.display.input.readOnlyChanged(val)});option("disableInput",!1,function(cm,val){val||cm.display.input.reset()},!0);option("dragDrop",!0,dragDropChanged);option("allowDropFileTypes",null);option("cursorBlinkRate",530);option("cursorScrollMargin",0);option("cursorHeight",1,updateSelection,!0);option("singleCursorHeightPerLine",!0,updateSelection,!0);option("workTime",100);option("workDelay",100);option("flattenSpans",!0,resetModeState,!0);option("addModeClass",!1,resetModeState,!0);option("pollInterval",100);option("undoDepth",200,function(cm,val){cm.doc.history.undoDepth=val});option("historyEventDelay",1250);option("viewportMargin",10,function(cm){cm.refresh()},!0);option("maxHighlightLength",1e4,resetModeState,!0);option("moveInputWithCursor",!0,function(cm,val){val||cm.display.input.resetPosition()});option("tabindex",null,function(cm,val){cm.display.input.getField().tabIndex=val||""});option("autofocus",null);var modes=CodeMirror.modes={},mimeModes=CodeMirror.mimeModes={};CodeMirror.defineMode=function(name,mode){CodeMirror.defaults.mode||"null"==name||(CodeMirror.defaults.mode=name);arguments.length>2&&(mode.dependencies=Array.prototype.slice.call(arguments,2));modes[name]=mode};CodeMirror.defineMIME=function(mime,spec){mimeModes[mime]=spec};CodeMirror.resolveMode=function(spec){if("string"==typeof spec&&mimeModes.hasOwnProperty(spec))spec=mimeModes[spec];else if(spec&&"string"==typeof spec.name&&mimeModes.hasOwnProperty(spec.name)){var found=mimeModes[spec.name];"string"==typeof found&&(found={name:found});spec=createObj(found,spec);spec.name=found.name}else if("string"==typeof spec&&/^[\w\-]+\/[\w\-]+\+xml$/.test(spec))return CodeMirror.resolveMode("application/xml");return"string"==typeof spec?{name:spec}:spec||{name:"null"}};CodeMirror.getMode=function(options,spec){var spec=CodeMirror.resolveMode(spec),mfactory=modes[spec.name];if(!mfactory)return CodeMirror.getMode(options,"text/plain");var modeObj=mfactory(options,spec);if(modeExtensions.hasOwnProperty(spec.name)){var exts=modeExtensions[spec.name];for(var prop in exts)if(exts.hasOwnProperty(prop)){modeObj.hasOwnProperty(prop)&&(modeObj["_"+prop]=modeObj[prop]);modeObj[prop]=exts[prop]}}modeObj.name=spec.name;spec.helperType&&(modeObj.helperType=spec.helperType);if(spec.modeProps)for(var prop in spec.modeProps)modeObj[prop]=spec.modeProps[prop];return modeObj};CodeMirror.defineMode("null",function(){return{token:function(stream){stream.skipToEnd()}}});CodeMirror.defineMIME("text/plain","null");var modeExtensions=CodeMirror.modeExtensions={};CodeMirror.extendMode=function(mode,properties){var exts=modeExtensions.hasOwnProperty(mode)?modeExtensions[mode]:modeExtensions[mode]={};copyObj(properties,exts)};CodeMirror.defineExtension=function(name,func){CodeMirror.prototype[name]=func};CodeMirror.defineDocExtension=function(name,func){Doc.prototype[name]=func};CodeMirror.defineOption=option;var initHooks=[];CodeMirror.defineInitHook=function(f){initHooks.push(f)};var helpers=CodeMirror.helpers={};CodeMirror.registerHelper=function(type,name,value){helpers.hasOwnProperty(type)||(helpers[type]=CodeMirror[type]={_global:[]});helpers[type][name]=value};CodeMirror.registerGlobalHelper=function(type,name,predicate,value){CodeMirror.registerHelper(type,name,value);helpers[type]._global.push({pred:predicate,val:value})};var copyState=CodeMirror.copyState=function(mode,state){if(state===!0)return state;if(mode.copyState)return mode.copyState(state);var nstate={};for(var n in state){var val=state[n];val instanceof Array&&(val=val.concat([]));nstate[n]=val}return nstate},startState=CodeMirror.startState=function(mode,a1,a2){return mode.startState?mode.startState(a1,a2):!0};CodeMirror.innerMode=function(mode,state){for(;mode.innerMode;){var info=mode.innerMode(state);if(!info||info.mode==mode)break;state=info.state;mode=info.mode}return info||{mode:mode,state:state}};var commands=CodeMirror.commands={selectAll:function(cm){cm.setSelection(Pos(cm.firstLine(),0),Pos(cm.lastLine()),sel_dontScroll)},singleSelection:function(cm){cm.setSelection(cm.getCursor("anchor"),cm.getCursor("head"),sel_dontScroll)},killLine:function(cm){deleteNearSelection(cm,function(range){if(range.empty()){var len=getLine(cm.doc,range.head.line).text.length;return range.head.ch==len&&range.head.line<cm.lastLine()?{from:range.head,to:Pos(range.head.line+1,0)}:{from:range.head,to:Pos(range.head.line,len)}}return{from:range.from(),to:range.to()}})},deleteLine:function(cm){deleteNearSelection(cm,function(range){return{from:Pos(range.from().line,0),to:clipPos(cm.doc,Pos(range.to().line+1,0))}})},delLineLeft:function(cm){deleteNearSelection(cm,function(range){return{from:Pos(range.from().line,0),to:range.from()}})},delWrappedLineLeft:function(cm){deleteNearSelection(cm,function(range){var top=cm.charCoords(range.head,"div").top+5,leftPos=cm.coordsChar({left:0,top:top},"div");return{from:leftPos,to:range.from()}})},delWrappedLineRight:function(cm){deleteNearSelection(cm,function(range){var top=cm.charCoords(range.head,"div").top+5,rightPos=cm.coordsChar({left:cm.display.lineDiv.offsetWidth+100,top:top},"div");return{from:range.from(),to:rightPos}})},undo:function(cm){cm.undo()},redo:function(cm){cm.redo()},undoSelection:function(cm){cm.undoSelection()},redoSelection:function(cm){cm.redoSelection()},goDocStart:function(cm){cm.extendSelection(Pos(cm.firstLine(),0))},goDocEnd:function(cm){cm.extendSelection(Pos(cm.lastLine()))},goLineStart:function(cm){cm.extendSelectionsBy(function(range){return lineStart(cm,range.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(cm){cm.extendSelectionsBy(function(range){return lineStartSmart(cm,range.head)},{origin:"+move",bias:1})},goLineEnd:function(cm){cm.extendSelectionsBy(function(range){return lineEnd(cm,range.head.line)},{origin:"+move",bias:-1})},goLineRight:function(cm){cm.extendSelectionsBy(function(range){var top=cm.charCoords(range.head,"div").top+5;return cm.coordsChar({left:cm.display.lineDiv.offsetWidth+100,top:top},"div")},sel_move)},goLineLeft:function(cm){cm.extendSelectionsBy(function(range){var top=cm.charCoords(range.head,"div").top+5;return cm.coordsChar({left:0,top:top},"div")},sel_move)},goLineLeftSmart:function(cm){cm.extendSelectionsBy(function(range){var top=cm.charCoords(range.head,"div").top+5,pos=cm.coordsChar({left:0,top:top},"div");return pos.ch<cm.getLine(pos.line).search(/\S/)?lineStartSmart(cm,range.head):pos},sel_move)},goLineUp:function(cm){cm.moveV(-1,"line")},goLineDown:function(cm){cm.moveV(1,"line")},goPageUp:function(cm){cm.moveV(-1,"page")},goPageDown:function(cm){cm.moveV(1,"page")},goCharLeft:function(cm){cm.moveH(-1,"char")},goCharRight:function(cm){cm.moveH(1,"char")},goColumnLeft:function(cm){cm.moveH(-1,"column")},goColumnRight:function(cm){cm.moveH(1,"column")},goWordLeft:function(cm){cm.moveH(-1,"word")},goGroupRight:function(cm){cm.moveH(1,"group")},goGroupLeft:function(cm){cm.moveH(-1,"group")},goWordRight:function(cm){cm.moveH(1,"word")},delCharBefore:function(cm){cm.deleteH(-1,"char")},delCharAfter:function(cm){cm.deleteH(1,"char")},delWordBefore:function(cm){cm.deleteH(-1,"word")},delWordAfter:function(cm){cm.deleteH(1,"word")},delGroupBefore:function(cm){cm.deleteH(-1,"group")},delGroupAfter:function(cm){cm.deleteH(1,"group")},indentAuto:function(cm){cm.indentSelection("smart")},indentMore:function(cm){cm.indentSelection("add")},indentLess:function(cm){cm.indentSelection("subtract")},insertTab:function(cm){cm.replaceSelection(" ")},insertSoftTab:function(cm){for(var spaces=[],ranges=cm.listSelections(),tabSize=cm.options.tabSize,i=0;i<ranges.length;i++){var pos=ranges[i].from(),col=countColumn(cm.getLine(pos.line),pos.ch,tabSize);spaces.push(new Array(tabSize-col%tabSize+1).join(" "))}cm.replaceSelections(spaces)},defaultTab:function(cm){cm.somethingSelected()?cm.indentSelection("add"):cm.execCommand("insertTab")},transposeChars:function(cm){runInOp(cm,function(){for(var ranges=cm.listSelections(),newSel=[],i=0;i<ranges.length;i++){var cur=ranges[i].head,line=getLine(cm.doc,cur.line).text;if(line){cur.ch==line.length&&(cur=new Pos(cur.line,cur.ch-1));if(cur.ch>0){cur=new Pos(cur.line,cur.ch+1);cm.replaceRange(line.charAt(cur.ch-1)+line.charAt(cur.ch-2),Pos(cur.line,cur.ch-2),cur,"+transpose")}else if(cur.line>cm.doc.first){var prev=getLine(cm.doc,cur.line-1).text;prev&&cm.replaceRange(line.charAt(0)+cm.doc.lineSeparator()+prev.charAt(prev.length-1),Pos(cur.line-1,prev.length-1),Pos(cur.line,1),"+transpose")}}newSel.push(new Range(cur,cur))}cm.setSelections(newSel)})},newlineAndIndent:function(cm){runInOp(cm,function(){for(var len=cm.listSelections().length,i=0;len>i;i++){var range=cm.listSelections()[i];cm.replaceRange(cm.doc.lineSeparator(),range.anchor,range.head,"+input");cm.indentLine(range.from().line+1,null,!0)}ensureCursorVisible(cm)})},toggleOverwrite:function(cm){cm.toggleOverwrite()}},keyMap=CodeMirror.keyMap={};keyMap.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"};keyMap.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"};keyMap.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"};keyMap.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]};keyMap["default"]=mac?keyMap.macDefault:keyMap.pcDefault;CodeMirror.normalizeKeyMap=function(keymap){var copy={};for(var keyname in keymap)if(keymap.hasOwnProperty(keyname)){var value=keymap[keyname];if(/^(name|fallthrough|(de|at)tach)$/.test(keyname))continue;if("..."==value){delete keymap[keyname];continue}for(var keys=map(keyname.split(" "),normalizeKeyName),i=0;i<keys.length;i++){var val,name;if(i==keys.length-1){name=keys.join(" ");val=value}else{name=keys.slice(0,i+1).join(" ");val="..."}var prev=copy[name];if(prev){if(prev!=val)throw new Error("Inconsistent bindings for "+name)}else copy[name]=val}delete keymap[keyname]}for(var prop in copy)keymap[prop]=copy[prop];return keymap};var lookupKey=CodeMirror.lookupKey=function(key,map,handle,context){map=getKeyMap(map);var found=map.call?map.call(key,context):map[key];if(found===!1)return"nothing";if("..."===found)return"multi";if(null!=found&&handle(found))return"handled";if(map.fallthrough){if("[object Array]"!=Object.prototype.toString.call(map.fallthrough))return lookupKey(key,map.fallthrough,handle,context);for(var i=0;i<map.fallthrough.length;i++){var result=lookupKey(key,map.fallthrough[i],handle,context);if(result)return result}}},isModifierKey=CodeMirror.isModifierKey=function(value){var name="string"==typeof value?value:keyNames[value.keyCode];return"Ctrl"==name||"Alt"==name||"Shift"==name||"Mod"==name},keyName=CodeMirror.keyName=function(event,noShift){if(presto&&34==event.keyCode&&event["char"])return!1;var base=keyNames[event.keyCode],name=base;if(null==name||event.altGraphKey)return!1;event.altKey&&"Alt"!=base&&(name="Alt-"+name);(flipCtrlCmd?event.metaKey:event.ctrlKey)&&"Ctrl"!=base&&(name="Ctrl-"+name);(flipCtrlCmd?event.ctrlKey:event.metaKey)&&"Cmd"!=base&&(name="Cmd-"+name);!noShift&&event.shiftKey&&"Shift"!=base&&(name="Shift-"+name);return name};CodeMirror.fromTextArea=function(textarea,options){function save(){textarea.value=cm.getValue()}options=options?copyObj(options):{};options.value=textarea.value;!options.tabindex&&textarea.tabIndex&&(options.tabindex=textarea.tabIndex);!options.placeholder&&textarea.placeholder&&(options.placeholder=textarea.placeholder);if(null==options.autofocus){var hasFocus=activeElt();options.autofocus=hasFocus==textarea||null!=textarea.getAttribute("autofocus")&&hasFocus==document.body}if(textarea.form){on(textarea.form,"submit",save);if(!options.leaveSubmitMethodAlone){var form=textarea.form,realSubmit=form.submit;try{var wrappedSubmit=form.submit=function(){save();form.submit=realSubmit;form.submit();form.submit=wrappedSubmit}}catch(e){}}}options.finishInit=function(cm){cm.save=save;cm.getTextArea=function(){return textarea};cm.toTextArea=function(){cm.toTextArea=isNaN;save();textarea.parentNode.removeChild(cm.getWrapperElement());textarea.style.display="";if(textarea.form){off(textarea.form,"submit",save);"function"==typeof textarea.form.submit&&(textarea.form.submit=realSubmit)}}};textarea.style.display="none";var cm=CodeMirror(function(node){textarea.parentNode.insertBefore(node,textarea.nextSibling)},options);return cm};var StringStream=CodeMirror.StringStream=function(string,tabSize){this.pos=this.start=0;this.string=string;this.tabSize=tabSize||8;this.lastColumnPos=this.lastColumnValue=0;this.lineStart=0};StringStream.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.pos<this.string.length?this.string.charAt(this.pos++):void 0},eat:function(match){var ch=this.string.charAt(this.pos);if("string"==typeof match)var ok=ch==match;else var ok=ch&&(match.test?match.test(ch):match(ch));if(ok){++this.pos;return ch}},eatWhile:function(match){for(var start=this.pos;this.eat(match););return this.pos>start},eatSpace:function(){for(var start=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>start},skipToEnd:function(){this.pos=this.string.length},skipTo:function(ch){var found=this.string.indexOf(ch,this.pos);if(found>-1){this.pos=found;return!0}},backUp:function(n){this.pos-=n},column:function(){if(this.lastColumnPos<this.start){this.lastColumnValue=countColumn(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue);this.lastColumnPos=this.start}return this.lastColumnValue-(this.lineStart?countColumn(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return countColumn(this.string,null,this.tabSize)-(this.lineStart?countColumn(this.string,this.lineStart,this.tabSize):0)},match:function(pattern,consume,caseInsensitive){if("string"!=typeof pattern){var match=this.string.slice(this.pos).match(pattern);if(match&&match.index>0)return null;match&&consume!==!1&&(this.pos+=match[0].length);return match}var cased=function(str){return caseInsensitive?str.toLowerCase():str},substr=this.string.substr(this.pos,pattern.length);if(cased(substr)==cased(pattern)){consume!==!1&&(this.pos+=pattern.length);return!0}},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(n,inner){this.lineStart+=n;try{return inner()}finally{this.lineStart-=n}}};var nextMarkerId=0,TextMarker=CodeMirror.TextMarker=function(doc,type){this.lines=[];this.type=type;this.doc=doc;this.id=++nextMarkerId};eventMixin(TextMarker);TextMarker.prototype.clear=function(){if(!this.explicitlyCleared){var cm=this.doc.cm,withOp=cm&&!cm.curOp;withOp&&startOperation(cm);if(hasHandler(this,"clear")){var found=this.find();found&&signalLater(this,"clear",found.from,found.to)}for(var min=null,max=null,i=0;i<this.lines.length;++i){var line=this.lines[i],span=getMarkedSpanFor(line.markedSpans,this);if(cm&&!this.collapsed)regLineChange(cm,lineNo(line),"text");else if(cm){
7
- null!=span.to&&(max=lineNo(line));null!=span.from&&(min=lineNo(line))}line.markedSpans=removeMarkedSpan(line.markedSpans,span);null==span.from&&this.collapsed&&!lineIsHidden(this.doc,line)&&cm&&updateLineHeight(line,textHeight(cm.display))}if(cm&&this.collapsed&&!cm.options.lineWrapping)for(var i=0;i<this.lines.length;++i){var visual=visualLine(this.lines[i]),len=lineLength(visual);if(len>cm.display.maxLineLength){cm.display.maxLine=visual;cm.display.maxLineLength=len;cm.display.maxLineChanged=!0}}null!=min&&cm&&this.collapsed&&regChange(cm,min,max+1);this.lines.length=0;this.explicitlyCleared=!0;if(this.atomic&&this.doc.cantEdit){this.doc.cantEdit=!1;cm&&reCheckSelection(cm.doc)}cm&&signalLater(cm,"markerCleared",cm,this);withOp&&endOperation(cm);this.parent&&this.parent.clear()}};TextMarker.prototype.find=function(side,lineObj){null==side&&"bookmark"==this.type&&(side=1);for(var from,to,i=0;i<this.lines.length;++i){var line=this.lines[i],span=getMarkedSpanFor(line.markedSpans,this);if(null!=span.from){from=Pos(lineObj?line:lineNo(line),span.from);if(-1==side)return from}if(null!=span.to){to=Pos(lineObj?line:lineNo(line),span.to);if(1==side)return to}}return from&&{from:from,to:to}};TextMarker.prototype.changed=function(){var pos=this.find(-1,!0),widget=this,cm=this.doc.cm;pos&&cm&&runInOp(cm,function(){var line=pos.line,lineN=lineNo(pos.line),view=findViewForLine(cm,lineN);if(view){clearLineMeasurementCacheFor(view);cm.curOp.selectionChanged=cm.curOp.forceUpdate=!0}cm.curOp.updateMaxLine=!0;if(!lineIsHidden(widget.doc,line)&&null!=widget.height){var oldHeight=widget.height;widget.height=null;var dHeight=widgetHeight(widget)-oldHeight;dHeight&&updateLineHeight(line,line.height+dHeight)}})};TextMarker.prototype.attachLine=function(line){if(!this.lines.length&&this.doc.cm){var op=this.doc.cm.curOp;op.maybeHiddenMarkers&&-1!=indexOf(op.maybeHiddenMarkers,this)||(op.maybeUnhiddenMarkers||(op.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(line)};TextMarker.prototype.detachLine=function(line){this.lines.splice(indexOf(this.lines,line),1);if(!this.lines.length&&this.doc.cm){var op=this.doc.cm.curOp;(op.maybeHiddenMarkers||(op.maybeHiddenMarkers=[])).push(this)}};var nextMarkerId=0,SharedTextMarker=CodeMirror.SharedTextMarker=function(markers,primary){this.markers=markers;this.primary=primary;for(var i=0;i<markers.length;++i)markers[i].parent=this};eventMixin(SharedTextMarker);SharedTextMarker.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var i=0;i<this.markers.length;++i)this.markers[i].clear();signalLater(this,"clear")}};SharedTextMarker.prototype.find=function(side,lineObj){return this.primary.find(side,lineObj)};var LineWidget=CodeMirror.LineWidget=function(doc,node,options){if(options)for(var opt in options)options.hasOwnProperty(opt)&&(this[opt]=options[opt]);this.doc=doc;this.node=node};eventMixin(LineWidget);LineWidget.prototype.clear=function(){var cm=this.doc.cm,ws=this.line.widgets,line=this.line,no=lineNo(line);if(null!=no&&ws){for(var i=0;i<ws.length;++i)ws[i]==this&&ws.splice(i--,1);ws.length||(line.widgets=null);var height=widgetHeight(this);updateLineHeight(line,Math.max(0,line.height-height));cm&&runInOp(cm,function(){adjustScrollWhenAboveVisible(cm,line,-height);regLineChange(cm,no,"widget")})}};LineWidget.prototype.changed=function(){var oldH=this.height,cm=this.doc.cm,line=this.line;this.height=null;var diff=widgetHeight(this)-oldH;if(diff){updateLineHeight(line,line.height+diff);cm&&runInOp(cm,function(){cm.curOp.forceUpdate=!0;adjustScrollWhenAboveVisible(cm,line,diff)})}};var Line=CodeMirror.Line=function(text,markedSpans,estimateHeight){this.text=text;attachMarkedSpans(this,markedSpans);this.height=estimateHeight?estimateHeight(this):1};eventMixin(Line);Line.prototype.lineNo=function(){return lineNo(this)};var styleToClassCache={},styleToClassCacheWithMode={};LeafChunk.prototype={chunkSize:function(){return this.lines.length},removeInner:function(at,n){for(var i=at,e=at+n;e>i;++i){var line=this.lines[i];this.height-=line.height;cleanUpLine(line);signalLater(line,"delete")}this.lines.splice(at,n)},collapse:function(lines){lines.push.apply(lines,this.lines)},insertInner:function(at,lines,height){this.height+=height;this.lines=this.lines.slice(0,at).concat(lines).concat(this.lines.slice(at));for(var i=0;i<lines.length;++i)lines[i].parent=this},iterN:function(at,n,op){for(var e=at+n;e>at;++at)if(op(this.lines[at]))return!0}};BranchChunk.prototype={chunkSize:function(){return this.size},removeInner:function(at,n){this.size-=n;for(var i=0;i<this.children.length;++i){var child=this.children[i],sz=child.chunkSize();if(sz>at){var rm=Math.min(n,sz-at),oldHeight=child.height;child.removeInner(at,rm);this.height-=oldHeight-child.height;if(sz==rm){this.children.splice(i--,1);child.parent=null}if(0==(n-=rm))break;at=0}else at-=sz}if(this.size-n<25&&(this.children.length>1||!(this.children[0]instanceof LeafChunk))){var lines=[];this.collapse(lines);this.children=[new LeafChunk(lines)];this.children[0].parent=this}},collapse:function(lines){for(var i=0;i<this.children.length;++i)this.children[i].collapse(lines)},insertInner:function(at,lines,height){this.size+=lines.length;this.height+=height;for(var i=0;i<this.children.length;++i){var child=this.children[i],sz=child.chunkSize();if(sz>=at){child.insertInner(at,lines,height);if(child.lines&&child.lines.length>50){for(;child.lines.length>50;){var spilled=child.lines.splice(child.lines.length-25,25),newleaf=new LeafChunk(spilled);child.height-=newleaf.height;this.children.splice(i+1,0,newleaf);newleaf.parent=this}this.maybeSpill()}break}at-=sz}},maybeSpill:function(){if(!(this.children.length<=10)){var me=this;do{var spilled=me.children.splice(me.children.length-5,5),sibling=new BranchChunk(spilled);if(me.parent){me.size-=sibling.size;me.height-=sibling.height;var myIndex=indexOf(me.parent.children,me);me.parent.children.splice(myIndex+1,0,sibling)}else{var copy=new BranchChunk(me.children);copy.parent=me;me.children=[copy,sibling];me=copy}sibling.parent=me.parent}while(me.children.length>10);me.parent.maybeSpill()}},iterN:function(at,n,op){for(var i=0;i<this.children.length;++i){var child=this.children[i],sz=child.chunkSize();if(sz>at){var used=Math.min(n,sz-at);if(child.iterN(at,used,op))return!0;if(0==(n-=used))break;at=0}else at-=sz}}};var nextDocId=0,Doc=CodeMirror.Doc=function(text,mode,firstLine,lineSep){if(!(this instanceof Doc))return new Doc(text,mode,firstLine,lineSep);null==firstLine&&(firstLine=0);BranchChunk.call(this,[new LeafChunk([new Line("",null)])]);this.first=firstLine;this.scrollTop=this.scrollLeft=0;this.cantEdit=!1;this.cleanGeneration=1;this.frontier=firstLine;var start=Pos(firstLine,0);this.sel=simpleSelection(start);this.history=new History(null);this.id=++nextDocId;this.modeOption=mode;this.lineSep=lineSep;"string"==typeof text&&(text=this.splitLines(text));updateDoc(this,{from:start,to:start,text:text});setSelection(this,simpleSelection(start),sel_dontScroll)};Doc.prototype=createObj(BranchChunk.prototype,{constructor:Doc,iter:function(from,to,op){op?this.iterN(from-this.first,to-from,op):this.iterN(this.first,this.first+this.size,from)},insert:function(at,lines){for(var height=0,i=0;i<lines.length;++i)height+=lines[i].height;this.insertInner(at-this.first,lines,height)},remove:function(at,n){this.removeInner(at-this.first,n)},getValue:function(lineSep){var lines=getLines(this,this.first,this.first+this.size);return lineSep===!1?lines:lines.join(lineSep||this.lineSeparator())},setValue:docMethodOp(function(code){var top=Pos(this.first,0),last=this.first+this.size-1;makeChange(this,{from:top,to:Pos(last,getLine(this,last).text.length),text:this.splitLines(code),origin:"setValue",full:!0},!0);setSelection(this,simpleSelection(top))}),replaceRange:function(code,from,to,origin){from=clipPos(this,from);to=to?clipPos(this,to):from;replaceRange(this,code,from,to,origin)},getRange:function(from,to,lineSep){var lines=getBetween(this,clipPos(this,from),clipPos(this,to));return lineSep===!1?lines:lines.join(lineSep||this.lineSeparator())},getLine:function(line){var l=this.getLineHandle(line);return l&&l.text},getLineHandle:function(line){return isLine(this,line)?getLine(this,line):void 0},getLineNumber:function(line){return lineNo(line)},getLineHandleVisualStart:function(line){"number"==typeof line&&(line=getLine(this,line));return visualLine(line)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(pos){return clipPos(this,pos)},getCursor:function(start){var pos,range=this.sel.primary();pos=null==start||"head"==start?range.head:"anchor"==start?range.anchor:"end"==start||"to"==start||start===!1?range.to():range.from();return pos},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:docMethodOp(function(line,ch,options){setSimpleSelection(this,clipPos(this,"number"==typeof line?Pos(line,ch||0):line),null,options)}),setSelection:docMethodOp(function(anchor,head,options){setSimpleSelection(this,clipPos(this,anchor),clipPos(this,head||anchor),options)}),extendSelection:docMethodOp(function(head,other,options){extendSelection(this,clipPos(this,head),other&&clipPos(this,other),options)}),extendSelections:docMethodOp(function(heads,options){extendSelections(this,clipPosArray(this,heads,options))}),extendSelectionsBy:docMethodOp(function(f,options){extendSelections(this,map(this.sel.ranges,f),options)}),setSelections:docMethodOp(function(ranges,primary,options){if(ranges.length){for(var i=0,out=[];i<ranges.length;i++)out[i]=new Range(clipPos(this,ranges[i].anchor),clipPos(this,ranges[i].head));null==primary&&(primary=Math.min(ranges.length-1,this.sel.primIndex));setSelection(this,normalizeSelection(out,primary),options)}}),addSelection:docMethodOp(function(anchor,head,options){var ranges=this.sel.ranges.slice(0);ranges.push(new Range(clipPos(this,anchor),clipPos(this,head||anchor)));setSelection(this,normalizeSelection(ranges,ranges.length-1),options)}),getSelection:function(lineSep){for(var lines,ranges=this.sel.ranges,i=0;i<ranges.length;i++){var sel=getBetween(this,ranges[i].from(),ranges[i].to());lines=lines?lines.concat(sel):sel}return lineSep===!1?lines:lines.join(lineSep||this.lineSeparator())},getSelections:function(lineSep){for(var parts=[],ranges=this.sel.ranges,i=0;i<ranges.length;i++){var sel=getBetween(this,ranges[i].from(),ranges[i].to());lineSep!==!1&&(sel=sel.join(lineSep||this.lineSeparator()));parts[i]=sel}return parts},replaceSelection:function(code,collapse,origin){for(var dup=[],i=0;i<this.sel.ranges.length;i++)dup[i]=code;this.replaceSelections(dup,collapse,origin||"+input")},replaceSelections:docMethodOp(function(code,collapse,origin){for(var changes=[],sel=this.sel,i=0;i<sel.ranges.length;i++){var range=sel.ranges[i];changes[i]={from:range.from(),to:range.to(),text:this.splitLines(code[i]),origin:origin}}for(var newSel=collapse&&"end"!=collapse&&computeReplacedSel(this,changes,collapse),i=changes.length-1;i>=0;i--)makeChange(this,changes[i]);newSel?setSelectionReplaceHistory(this,newSel):this.cm&&ensureCursorVisible(this.cm)}),undo:docMethodOp(function(){makeChangeFromHistory(this,"undo")}),redo:docMethodOp(function(){makeChangeFromHistory(this,"redo")}),undoSelection:docMethodOp(function(){makeChangeFromHistory(this,"undo",!0)}),redoSelection:docMethodOp(function(){makeChangeFromHistory(this,"redo",!0)}),setExtending:function(val){this.extend=val},getExtending:function(){return this.extend},historySize:function(){for(var hist=this.history,done=0,undone=0,i=0;i<hist.done.length;i++)hist.done[i].ranges||++done;for(var i=0;i<hist.undone.length;i++)hist.undone[i].ranges||++undone;return{undo:done,redo:undone}},clearHistory:function(){this.history=new History(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(forceSplit){forceSplit&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null);return this.history.generation},isClean:function(gen){return this.history.generation==(gen||this.cleanGeneration)},getHistory:function(){return{done:copyHistoryArray(this.history.done),undone:copyHistoryArray(this.history.undone)}},setHistory:function(histData){var hist=this.history=new History(this.history.maxGeneration);hist.done=copyHistoryArray(histData.done.slice(0),null,!0);hist.undone=copyHistoryArray(histData.undone.slice(0),null,!0)},addLineClass:docMethodOp(function(handle,where,cls){return changeLine(this,handle,"gutter"==where?"gutter":"class",function(line){var prop="text"==where?"textClass":"background"==where?"bgClass":"gutter"==where?"gutterClass":"wrapClass";if(line[prop]){if(classTest(cls).test(line[prop]))return!1;line[prop]+=" "+cls}else line[prop]=cls;return!0})}),removeLineClass:docMethodOp(function(handle,where,cls){return changeLine(this,handle,"gutter"==where?"gutter":"class",function(line){var prop="text"==where?"textClass":"background"==where?"bgClass":"gutter"==where?"gutterClass":"wrapClass",cur=line[prop];if(!cur)return!1;if(null==cls)line[prop]=null;else{var found=cur.match(classTest(cls));if(!found)return!1;var end=found.index+found[0].length;line[prop]=cur.slice(0,found.index)+(found.index&&end!=cur.length?" ":"")+cur.slice(end)||null}return!0})}),addLineWidget:docMethodOp(function(handle,node,options){return addLineWidget(this,handle,node,options)}),removeLineWidget:function(widget){widget.clear()},markText:function(from,to,options){return markText(this,clipPos(this,from),clipPos(this,to),options,options&&options.type||"range")},setBookmark:function(pos,options){var realOpts={replacedWith:options&&(null==options.nodeType?options.widget:options),insertLeft:options&&options.insertLeft,clearWhenEmpty:!1,shared:options&&options.shared,handleMouseEvents:options&&options.handleMouseEvents};pos=clipPos(this,pos);return markText(this,pos,pos,realOpts,"bookmark")},findMarksAt:function(pos){pos=clipPos(this,pos);var markers=[],spans=getLine(this,pos.line).markedSpans;if(spans)for(var i=0;i<spans.length;++i){var span=spans[i];(null==span.from||span.from<=pos.ch)&&(null==span.to||span.to>=pos.ch)&&markers.push(span.marker.parent||span.marker)}return markers},findMarks:function(from,to,filter){from=clipPos(this,from);to=clipPos(this,to);var found=[],lineNo=from.line;this.iter(from.line,to.line+1,function(line){var spans=line.markedSpans;if(spans)for(var i=0;i<spans.length;i++){var span=spans[i];lineNo==from.line&&from.ch>span.to||null==span.from&&lineNo!=from.line||lineNo==to.line&&span.from>to.ch||filter&&!filter(span.marker)||found.push(span.marker.parent||span.marker)}++lineNo});return found},getAllMarks:function(){var markers=[];this.iter(function(line){var sps=line.markedSpans;if(sps)for(var i=0;i<sps.length;++i)null!=sps[i].from&&markers.push(sps[i].marker)});return markers},posFromIndex:function(off){var ch,lineNo=this.first;this.iter(function(line){var sz=line.text.length+1;if(sz>off){ch=off;return!0}off-=sz;++lineNo});return clipPos(this,Pos(lineNo,ch))},indexFromPos:function(coords){coords=clipPos(this,coords);var index=coords.ch;if(coords.line<this.first||coords.ch<0)return 0;this.iter(this.first,coords.line,function(line){index+=line.text.length+1});return index},copy:function(copyHistory){var doc=new Doc(getLines(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep);doc.scrollTop=this.scrollTop;doc.scrollLeft=this.scrollLeft;doc.sel=this.sel;doc.extend=!1;if(copyHistory){doc.history.undoDepth=this.history.undoDepth;doc.setHistory(this.getHistory())}return doc},linkedDoc:function(options){options||(options={});var from=this.first,to=this.first+this.size;null!=options.from&&options.from>from&&(from=options.from);null!=options.to&&options.to<to&&(to=options.to);var copy=new Doc(getLines(this,from,to),options.mode||this.modeOption,from,this.lineSep);options.sharedHist&&(copy.history=this.history);(this.linked||(this.linked=[])).push({doc:copy,sharedHist:options.sharedHist});copy.linked=[{doc:this,isParent:!0,sharedHist:options.sharedHist}];copySharedMarkers(copy,findSharedMarkers(this));return copy},unlinkDoc:function(other){other instanceof CodeMirror&&(other=other.doc);if(this.linked)for(var i=0;i<this.linked.length;++i){var link=this.linked[i];if(link.doc==other){this.linked.splice(i,1);other.unlinkDoc(this);detachSharedMarkers(findSharedMarkers(this));break}}if(other.history==this.history){var splitIds=[other.id];linkedDocs(other,function(doc){splitIds.push(doc.id)},!0);other.history=new History(null);other.history.done=copyHistoryArray(this.history.done,splitIds);other.history.undone=copyHistoryArray(this.history.undone,splitIds)}},iterLinkedDocs:function(f){linkedDocs(this,f)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(str){return this.lineSep?str.split(this.lineSep):splitLinesAuto(str)},lineSeparator:function(){return this.lineSep||"\n"}});Doc.prototype.eachLine=Doc.prototype.iter;var dontDelegate="iter insert remove copy getEditor constructor".split(" ");for(var prop in Doc.prototype)Doc.prototype.hasOwnProperty(prop)&&indexOf(dontDelegate,prop)<0&&(CodeMirror.prototype[prop]=function(method){return function(){return method.apply(this.doc,arguments)}}(Doc.prototype[prop]));eventMixin(Doc);var e_preventDefault=CodeMirror.e_preventDefault=function(e){e.preventDefault?e.preventDefault():e.returnValue=!1},e_stopPropagation=CodeMirror.e_stopPropagation=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},e_stop=CodeMirror.e_stop=function(e){e_preventDefault(e);e_stopPropagation(e)},on=CodeMirror.on=function(emitter,type,f){if(emitter.addEventListener)emitter.addEventListener(type,f,!1);else if(emitter.attachEvent)emitter.attachEvent("on"+type,f);else{var map=emitter._handlers||(emitter._handlers={}),arr=map[type]||(map[type]=[]);arr.push(f)}},noHandlers=[],off=CodeMirror.off=function(emitter,type,f){if(emitter.removeEventListener)emitter.removeEventListener(type,f,!1);else if(emitter.detachEvent)emitter.detachEvent("on"+type,f);else for(var handlers=getHandlers(emitter,type,!1),i=0;i<handlers.length;++i)if(handlers[i]==f){handlers.splice(i,1);break}},signal=CodeMirror.signal=function(emitter,type){var handlers=getHandlers(emitter,type,!0);if(handlers.length)for(var args=Array.prototype.slice.call(arguments,2),i=0;i<handlers.length;++i)handlers[i].apply(null,args)},orphanDelayedCallbacks=null,scrollerGap=30,Pass=CodeMirror.Pass={toString:function(){return"CodeMirror.Pass"}},sel_dontScroll={scroll:!1},sel_mouse={origin:"*mouse"},sel_move={origin:"+move"};Delayed.prototype.set=function(ms,f){clearTimeout(this.id);this.id=setTimeout(f,ms)};var countColumn=CodeMirror.countColumn=function(string,end,tabSize,startIndex,startValue){if(null==end){end=string.search(/[^\s\u00a0]/);-1==end&&(end=string.length)}for(var i=startIndex||0,n=startValue||0;;){var nextTab=string.indexOf(" ",i);if(0>nextTab||nextTab>=end)return n+(end-i);n+=nextTab-i;n+=tabSize-n%tabSize;i=nextTab+1}},findColumn=CodeMirror.findColumn=function(string,goal,tabSize){for(var pos=0,col=0;;){var nextTab=string.indexOf(" ",pos);-1==nextTab&&(nextTab=string.length);var skipped=nextTab-pos;if(nextTab==string.length||col+skipped>=goal)return pos+Math.min(skipped,goal-col);col+=nextTab-pos;col+=tabSize-col%tabSize;pos=nextTab+1;if(col>=goal)return pos}},spaceStrs=[""],selectInput=function(node){node.select()};ios?selectInput=function(node){node.selectionStart=0;node.selectionEnd=node.value.length}:ie&&(selectInput=function(node){try{node.select()}catch(_e){}});var range,nonASCIISingleCaseWordChar=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,isWordCharBasic=CodeMirror.isWordChar=function(ch){return/\w/.test(ch)||ch>"€"&&(ch.toUpperCase()!=ch.toLowerCase()||nonASCIISingleCaseWordChar.test(ch))},extendingChars=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;range=document.createRange?function(node,start,end,endNode){var r=document.createRange();r.setEnd(endNode||node,end);r.setStart(node,start);return r}:function(node,start,end){var r=document.body.createTextRange();try{r.moveToElementText(node.parentNode)}catch(e){return r}r.collapse(!0);r.moveEnd("character",end);r.moveStart("character",start);return r};var contains=CodeMirror.contains=function(parent,child){3==child.nodeType&&(child=child.parentNode);if(parent.contains)return parent.contains(child);do{11==child.nodeType&&(child=child.host);if(child==parent)return!0}while(child=child.parentNode)};ie&&11>ie_version&&(activeElt=function(){try{return document.activeElement}catch(e){return document.body}});var zwspSupported,badBidiRects,rmClass=CodeMirror.rmClass=function(node,cls){var current=node.className,match=classTest(cls).exec(current);if(match){var after=current.slice(match.index+match[0].length);node.className=current.slice(0,match.index)+(after?match[1]+after:"")}},addClass=CodeMirror.addClass=function(node,cls){var current=node.className;classTest(cls).test(current)||(node.className+=(current?" ":"")+cls)},globalsRegistered=!1,dragAndDrop=function(){if(ie&&9>ie_version)return!1;var div=elt("div");return"draggable"in div||"dragDrop"in div}(),splitLinesAuto=CodeMirror.splitLines=3!="\n\nb".split(/\n/).length?function(string){for(var pos=0,result=[],l=string.length;l>=pos;){var nl=string.indexOf("\n",pos);-1==nl&&(nl=string.length);var line=string.slice(pos,"\r"==string.charAt(nl-1)?nl-1:nl),rt=line.indexOf("\r");if(-1!=rt){result.push(line.slice(0,rt));pos+=rt+1}else{result.push(line);pos=nl+1}}return result}:function(string){return string.split(/\r\n?|\n/)},hasSelection=window.getSelection?function(te){try{return te.selectionStart!=te.selectionEnd}catch(e){return!1}}:function(te){try{var range=te.ownerDocument.selection.createRange()}catch(e){}return range&&range.parentElement()==te?0!=range.compareEndPoints("StartToEnd",range):!1},hasCopyEvent=function(){var e=elt("div");if("oncopy"in e)return!0;e.setAttribute("oncopy","return;");return"function"==typeof e.oncopy}(),badZoomedRects=null,keyNames=CodeMirror.keyNames={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};!function(){for(var i=0;10>i;i++)keyNames[i+48]=keyNames[i+96]=String(i);for(var i=65;90>=i;i++)keyNames[i]=String.fromCharCode(i);for(var i=1;12>=i;i++)keyNames[i+111]=keyNames[i+63235]="F"+i}();var bidiOther,bidiOrdering=function(){function charType(code){return 247>=code?lowTypes.charAt(code):code>=1424&&1524>=code?"R":code>=1536&&1773>=code?arabicTypes.charAt(code-1536):code>=1774&&2220>=code?"r":code>=8192&&8203>=code?"w":8204==code?"b":"L"}function BidiSpan(level,from,to){this.level=level;this.from=from;this.to=to}var lowTypes="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",arabicTypes="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",bidiRE=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,isNeutral=/[stwN]/,isStrong=/[LRr]/,countsAsLeft=/[Lb1n]/,countsAsNum=/[1n]/,outerType="L";return function(str){if(!bidiRE.test(str))return!1;for(var type,len=str.length,types=[],i=0;len>i;++i)types.push(type=charType(str.charCodeAt(i)));for(var i=0,prev=outerType;len>i;++i){var type=types[i];"m"==type?types[i]=prev:prev=type}for(var i=0,cur=outerType;len>i;++i){var type=types[i];if("1"==type&&"r"==cur)types[i]="n";else if(isStrong.test(type)){cur=type;"r"==type&&(types[i]="R")}}for(var i=1,prev=types[0];len-1>i;++i){var type=types[i];"+"==type&&"1"==prev&&"1"==types[i+1]?types[i]="1":","!=type||prev!=types[i+1]||"1"!=prev&&"n"!=prev||(types[i]=prev);prev=type}for(var i=0;len>i;++i){var type=types[i];if(","==type)types[i]="N";else if("%"==type){for(var end=i+1;len>end&&"%"==types[end];++end);for(var replace=i&&"!"==types[i-1]||len>end&&"1"==types[end]?"1":"N",j=i;end>j;++j)types[j]=replace;i=end-1}}for(var i=0,cur=outerType;len>i;++i){var type=types[i];"L"==cur&&"1"==type?types[i]="L":isStrong.test(type)&&(cur=type)}for(var i=0;len>i;++i)if(isNeutral.test(types[i])){for(var end=i+1;len>end&&isNeutral.test(types[end]);++end);for(var before="L"==(i?types[i-1]:outerType),after="L"==(len>end?types[end]:outerType),replace=before||after?"L":"R",j=i;end>j;++j)types[j]=replace;i=end-1}for(var m,order=[],i=0;len>i;)if(countsAsLeft.test(types[i])){var start=i;for(++i;len>i&&countsAsLeft.test(types[i]);++i);order.push(new BidiSpan(0,start,i))}else{var pos=i,at=order.length;for(++i;len>i&&"L"!=types[i];++i);for(var j=pos;i>j;)if(countsAsNum.test(types[j])){j>pos&&order.splice(at,0,new BidiSpan(1,pos,j));var nstart=j;for(++j;i>j&&countsAsNum.test(types[j]);++j);order.splice(at,0,new BidiSpan(2,nstart,j));pos=j}else++j;i>pos&&order.splice(at,0,new BidiSpan(1,pos,i))}if(1==order[0].level&&(m=str.match(/^\s+/))){order[0].from=m[0].length;order.unshift(new BidiSpan(0,0,m[0].length))}if(1==lst(order).level&&(m=str.match(/\s+$/))){lst(order).to-=m[0].length;order.push(new BidiSpan(0,len-m[0].length,len))}2==order[0].level&&order.unshift(new BidiSpan(1,order[0].to,order[0].to));order[0].level!=lst(order).level&&order.push(new BidiSpan(order[0].level,len,len));return order}}();CodeMirror.version="5.8.0";return CodeMirror});
1
+ !function(mod){if("object"==typeof exports&&"object"==typeof module)module.exports=mod();else{if("function"==typeof define&&define.amd)return define([],mod);(this||window).CodeMirror=mod()}}(function(){"use strict";function CodeMirror(place,options){if(!(this instanceof CodeMirror))return new CodeMirror(place,options);this.options=options=options?copyObj(options):{};copyObj(defaults,options,!1);setGuttersForLineNumbers(options);var doc=options.value;"string"==typeof doc&&(doc=new Doc(doc,options.mode,null,options.lineSeparator));this.doc=doc;var input=new CodeMirror.inputStyles[options.inputStyle](this),display=this.display=new Display(place,doc,input);display.wrapper.CodeMirror=this;updateGutters(this);themeChanged(this);options.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap");options.autofocus&&!mobile&&display.input.focus();initScrollbars(this);this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,selectingText:!1,draggingText:!1,highlight:new Delayed,keySeq:null,specialChars:null};var cm=this;ie&&11>ie_version&&setTimeout(function(){cm.display.input.reset(!0)},20);registerEventHandlers(this);ensureGlobalHandlers();startOperation(this);this.curOp.forceUpdate=!0;attachDoc(this,doc);options.autofocus&&!mobile||cm.hasFocus()?setTimeout(bind(onFocus,this),20):onBlur(this);for(var opt in optionHandlers)optionHandlers.hasOwnProperty(opt)&&optionHandlers[opt](this,options[opt],Init);maybeUpdateLineNumberWidth(this);options.finishInit&&options.finishInit(this);for(var i=0;i<initHooks.length;++i)initHooks[i](this);endOperation(this);webkit&&options.lineWrapping&&"optimizelegibility"==getComputedStyle(display.lineDiv).textRendering&&(display.lineDiv.style.textRendering="auto")}function Display(place,doc,input){var d=this;this.input=input;d.scrollbarFiller=elt("div",null,"CodeMirror-scrollbar-filler");d.scrollbarFiller.setAttribute("cm-not-content","true");d.gutterFiller=elt("div",null,"CodeMirror-gutter-filler");d.gutterFiller.setAttribute("cm-not-content","true");d.lineDiv=elt("div",null,"CodeMirror-code");d.selectionDiv=elt("div",null,null,"position: relative; z-index: 1");d.cursorDiv=elt("div",null,"CodeMirror-cursors");d.measure=elt("div",null,"CodeMirror-measure");d.lineMeasure=elt("div",null,"CodeMirror-measure");d.lineSpace=elt("div",[d.measure,d.lineMeasure,d.selectionDiv,d.cursorDiv,d.lineDiv],null,"position: relative; outline: none");d.mover=elt("div",[elt("div",[d.lineSpace],"CodeMirror-lines")],null,"position: relative");d.sizer=elt("div",[d.mover],"CodeMirror-sizer");d.sizerWidth=null;d.heightForcer=elt("div",null,null,"position: absolute; height: "+scrollerGap+"px; width: 1px;");d.gutters=elt("div",null,"CodeMirror-gutters");d.lineGutter=null;d.scroller=elt("div",[d.sizer,d.heightForcer,d.gutters],"CodeMirror-scroll");d.scroller.setAttribute("tabIndex","-1");d.wrapper=elt("div",[d.scrollbarFiller,d.gutterFiller,d.scroller],"CodeMirror");if(ie&&8>ie_version){d.gutters.style.zIndex=-1;d.scroller.style.paddingRight=0}webkit||gecko&&mobile||(d.scroller.draggable=!0);place&&(place.appendChild?place.appendChild(d.wrapper):place(d.wrapper));d.viewFrom=d.viewTo=doc.first;d.reportedViewFrom=d.reportedViewTo=doc.first;d.view=[];d.renderedView=null;d.externalMeasured=null;d.viewOffset=0;d.lastWrapHeight=d.lastWrapWidth=0;d.updateLineNumbers=null;d.nativeBarWidth=d.barHeight=d.barWidth=0;d.scrollbarsClipped=!1;d.lineNumWidth=d.lineNumInnerWidth=d.lineNumChars=null;d.alignWidgets=!1;d.cachedCharWidth=d.cachedTextHeight=d.cachedPaddingH=null;d.maxLine=null;d.maxLineLength=0;d.maxLineChanged=!1;d.wheelDX=d.wheelDY=d.wheelStartX=d.wheelStartY=null;d.shift=!1;d.selForContextMenu=null;d.activeTouch=null;input.init(d)}function loadMode(cm){cm.doc.mode=CodeMirror.getMode(cm.options,cm.doc.modeOption);resetModeState(cm)}function resetModeState(cm){cm.doc.iter(function(line){line.stateAfter&&(line.stateAfter=null);line.styles&&(line.styles=null)});cm.doc.frontier=cm.doc.first;startWorker(cm,100);cm.state.modeGen++;cm.curOp&&regChange(cm)}function wrappingChanged(cm){if(cm.options.lineWrapping){addClass(cm.display.wrapper,"CodeMirror-wrap");cm.display.sizer.style.minWidth="";cm.display.sizerWidth=null}else{rmClass(cm.display.wrapper,"CodeMirror-wrap");findMaxLine(cm)}estimateLineHeights(cm);regChange(cm);clearCaches(cm);setTimeout(function(){updateScrollbars(cm)},100)}function estimateHeight(cm){var th=textHeight(cm.display),wrapping=cm.options.lineWrapping,perLine=wrapping&&Math.max(5,cm.display.scroller.clientWidth/charWidth(cm.display)-3);return function(line){if(lineIsHidden(cm.doc,line))return 0;var widgetsHeight=0;if(line.widgets)for(var i=0;i<line.widgets.length;i++)line.widgets[i].height&&(widgetsHeight+=line.widgets[i].height);return wrapping?widgetsHeight+(Math.ceil(line.text.length/perLine)||1)*th:widgetsHeight+th}}function estimateLineHeights(cm){var doc=cm.doc,est=estimateHeight(cm);doc.iter(function(line){var estHeight=est(line);estHeight!=line.height&&updateLineHeight(line,estHeight)})}function themeChanged(cm){cm.display.wrapper.className=cm.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+cm.options.theme.replace(/(^|\s)\s*/g," cm-s-");clearCaches(cm)}function guttersChanged(cm){updateGutters(cm);regChange(cm);setTimeout(function(){alignHorizontally(cm)},20)}function updateGutters(cm){var gutters=cm.display.gutters,specs=cm.options.gutters;removeChildren(gutters);for(var i=0;i<specs.length;++i){var gutterClass=specs[i],gElt=gutters.appendChild(elt("div",null,"CodeMirror-gutter "+gutterClass));if("CodeMirror-linenumbers"==gutterClass){cm.display.lineGutter=gElt;gElt.style.width=(cm.display.lineNumWidth||1)+"px"}}gutters.style.display=i?"":"none";updateGutterSpace(cm)}function updateGutterSpace(cm){var width=cm.display.gutters.offsetWidth;cm.display.sizer.style.marginLeft=width+"px"}function lineLength(line){if(0==line.height)return 0;for(var merged,len=line.text.length,cur=line;merged=collapsedSpanAtStart(cur);){var found=merged.find(0,!0);cur=found.from.line;len+=found.from.ch-found.to.ch}cur=line;for(;merged=collapsedSpanAtEnd(cur);){var found=merged.find(0,!0);len-=cur.text.length-found.from.ch;cur=found.to.line;len+=cur.text.length-found.to.ch}return len}function findMaxLine(cm){var d=cm.display,doc=cm.doc;d.maxLine=getLine(doc,doc.first);d.maxLineLength=lineLength(d.maxLine);d.maxLineChanged=!0;doc.iter(function(line){var len=lineLength(line);if(len>d.maxLineLength){d.maxLineLength=len;d.maxLine=line}})}function setGuttersForLineNumbers(options){var found=indexOf(options.gutters,"CodeMirror-linenumbers");if(-1==found&&options.lineNumbers)options.gutters=options.gutters.concat(["CodeMirror-linenumbers"]);else if(found>-1&&!options.lineNumbers){options.gutters=options.gutters.slice(0);options.gutters.splice(found,1)}}function measureForScrollbars(cm){var d=cm.display,gutterW=d.gutters.offsetWidth,docH=Math.round(cm.doc.height+paddingVert(cm.display));return{clientHeight:d.scroller.clientHeight,viewHeight:d.wrapper.clientHeight,scrollWidth:d.scroller.scrollWidth,clientWidth:d.scroller.clientWidth,viewWidth:d.wrapper.clientWidth,barLeft:cm.options.fixedGutter?gutterW:0,docHeight:docH,scrollHeight:docH+scrollGap(cm)+d.barHeight,nativeBarWidth:d.nativeBarWidth,gutterWidth:gutterW}}function NativeScrollbars(place,scroll,cm){this.cm=cm;var vert=this.vert=elt("div",[elt("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),horiz=this.horiz=elt("div",[elt("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");place(vert);place(horiz);on(vert,"scroll",function(){vert.clientHeight&&scroll(vert.scrollTop,"vertical")});on(horiz,"scroll",function(){horiz.clientWidth&&scroll(horiz.scrollLeft,"horizontal")});this.checkedZeroWidth=!1;ie&&8>ie_version&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function NullScrollbars(){}function initScrollbars(cm){if(cm.display.scrollbars){cm.display.scrollbars.clear();cm.display.scrollbars.addClass&&rmClass(cm.display.wrapper,cm.display.scrollbars.addClass)}cm.display.scrollbars=new CodeMirror.scrollbarModel[cm.options.scrollbarStyle](function(node){cm.display.wrapper.insertBefore(node,cm.display.scrollbarFiller);on(node,"mousedown",function(){cm.state.focused&&setTimeout(function(){cm.display.input.focus()},0)});node.setAttribute("cm-not-content","true")},function(pos,axis){"horizontal"==axis?setScrollLeft(cm,pos):setScrollTop(cm,pos)},cm);cm.display.scrollbars.addClass&&addClass(cm.display.wrapper,cm.display.scrollbars.addClass)}function updateScrollbars(cm,measure){measure||(measure=measureForScrollbars(cm));var startWidth=cm.display.barWidth,startHeight=cm.display.barHeight;updateScrollbarsInner(cm,measure);for(var i=0;4>i&&startWidth!=cm.display.barWidth||startHeight!=cm.display.barHeight;i++){startWidth!=cm.display.barWidth&&cm.options.lineWrapping&&updateHeightsInViewport(cm);updateScrollbarsInner(cm,measureForScrollbars(cm));startWidth=cm.display.barWidth;startHeight=cm.display.barHeight}}function updateScrollbarsInner(cm,measure){var d=cm.display,sizes=d.scrollbars.update(measure);d.sizer.style.paddingRight=(d.barWidth=sizes.right)+"px";d.sizer.style.paddingBottom=(d.barHeight=sizes.bottom)+"px";d.heightForcer.style.borderBottom=sizes.bottom+"px solid transparent";if(sizes.right&&sizes.bottom){d.scrollbarFiller.style.display="block";d.scrollbarFiller.style.height=sizes.bottom+"px";d.scrollbarFiller.style.width=sizes.right+"px"}else d.scrollbarFiller.style.display="";if(sizes.bottom&&cm.options.coverGutterNextToScrollbar&&cm.options.fixedGutter){d.gutterFiller.style.display="block";d.gutterFiller.style.height=sizes.bottom+"px";d.gutterFiller.style.width=measure.gutterWidth+"px"}else d.gutterFiller.style.display=""}function visibleLines(display,doc,viewport){var top=viewport&&null!=viewport.top?Math.max(0,viewport.top):display.scroller.scrollTop;top=Math.floor(top-paddingTop(display));var bottom=viewport&&null!=viewport.bottom?viewport.bottom:top+display.wrapper.clientHeight,from=lineAtHeight(doc,top),to=lineAtHeight(doc,bottom);if(viewport&&viewport.ensure){var ensureFrom=viewport.ensure.from.line,ensureTo=viewport.ensure.to.line;if(from>ensureFrom){from=ensureFrom;to=lineAtHeight(doc,heightAtLine(getLine(doc,ensureFrom))+display.wrapper.clientHeight)}else if(Math.min(ensureTo,doc.lastLine())>=to){from=lineAtHeight(doc,heightAtLine(getLine(doc,ensureTo))-display.wrapper.clientHeight);to=ensureTo}}return{from:from,to:Math.max(to,from+1)}}function alignHorizontally(cm){var display=cm.display,view=display.view;if(display.alignWidgets||display.gutters.firstChild&&cm.options.fixedGutter){for(var comp=compensateForHScroll(display)-display.scroller.scrollLeft+cm.doc.scrollLeft,gutterW=display.gutters.offsetWidth,left=comp+"px",i=0;i<view.length;i++)if(!view[i].hidden){cm.options.fixedGutter&&view[i].gutter&&(view[i].gutter.style.left=left);var align=view[i].alignable;if(align)for(var j=0;j<align.length;j++)align[j].style.left=left}cm.options.fixedGutter&&(display.gutters.style.left=comp+gutterW+"px")}}function maybeUpdateLineNumberWidth(cm){if(!cm.options.lineNumbers)return!1;var doc=cm.doc,last=lineNumberFor(cm.options,doc.first+doc.size-1),display=cm.display;if(last.length!=display.lineNumChars){var test=display.measure.appendChild(elt("div",[elt("div",last)],"CodeMirror-linenumber CodeMirror-gutter-elt")),innerW=test.firstChild.offsetWidth,padding=test.offsetWidth-innerW;display.lineGutter.style.width="";display.lineNumInnerWidth=Math.max(innerW,display.lineGutter.offsetWidth-padding)+1;display.lineNumWidth=display.lineNumInnerWidth+padding;display.lineNumChars=display.lineNumInnerWidth?last.length:-1;display.lineGutter.style.width=display.lineNumWidth+"px";updateGutterSpace(cm);return!0}return!1}function lineNumberFor(options,i){return String(options.lineNumberFormatter(i+options.firstLineNumber))}function compensateForHScroll(display){return display.scroller.getBoundingClientRect().left-display.sizer.getBoundingClientRect().left}function DisplayUpdate(cm,viewport,force){var display=cm.display;this.viewport=viewport;this.visible=visibleLines(display,cm.doc,viewport);this.editorIsHidden=!display.wrapper.offsetWidth;this.wrapperHeight=display.wrapper.clientHeight;this.wrapperWidth=display.wrapper.clientWidth;this.oldDisplayWidth=displayWidth(cm);this.force=force;this.dims=getDimensions(cm);this.events=[]}function maybeClipScrollbars(cm){var display=cm.display;if(!display.scrollbarsClipped&&display.scroller.offsetWidth){display.nativeBarWidth=display.scroller.offsetWidth-display.scroller.clientWidth;display.heightForcer.style.height=scrollGap(cm)+"px";display.sizer.style.marginBottom=-display.nativeBarWidth+"px";display.sizer.style.borderRightWidth=scrollGap(cm)+"px";display.scrollbarsClipped=!0}}function updateDisplayIfNeeded(cm,update){var display=cm.display,doc=cm.doc;if(update.editorIsHidden){resetView(cm);return!1}if(!update.force&&update.visible.from>=display.viewFrom&&update.visible.to<=display.viewTo&&(null==display.updateLineNumbers||display.updateLineNumbers>=display.viewTo)&&display.renderedView==display.view&&0==countDirtyView(cm))return!1;if(maybeUpdateLineNumberWidth(cm)){resetView(cm);update.dims=getDimensions(cm)}var end=doc.first+doc.size,from=Math.max(update.visible.from-cm.options.viewportMargin,doc.first),to=Math.min(end,update.visible.to+cm.options.viewportMargin);display.viewFrom<from&&from-display.viewFrom<20&&(from=Math.max(doc.first,display.viewFrom));display.viewTo>to&&display.viewTo-to<20&&(to=Math.min(end,display.viewTo));if(sawCollapsedSpans){from=visualLineNo(cm.doc,from);to=visualLineEndNo(cm.doc,to)}var different=from!=display.viewFrom||to!=display.viewTo||display.lastWrapHeight!=update.wrapperHeight||display.lastWrapWidth!=update.wrapperWidth;adjustView(cm,from,to);display.viewOffset=heightAtLine(getLine(cm.doc,display.viewFrom));cm.display.mover.style.top=display.viewOffset+"px";var toUpdate=countDirtyView(cm);if(!different&&0==toUpdate&&!update.force&&display.renderedView==display.view&&(null==display.updateLineNumbers||display.updateLineNumbers>=display.viewTo))return!1;var focused=activeElt();toUpdate>4&&(display.lineDiv.style.display="none");patchDisplay(cm,display.updateLineNumbers,update.dims);toUpdate>4&&(display.lineDiv.style.display="");display.renderedView=display.view;focused&&activeElt()!=focused&&focused.offsetHeight&&focused.focus();removeChildren(display.cursorDiv);removeChildren(display.selectionDiv);display.gutters.style.height=display.sizer.style.minHeight=0;if(different){display.lastWrapHeight=update.wrapperHeight;display.lastWrapWidth=update.wrapperWidth;startWorker(cm,400)}display.updateLineNumbers=null;return!0}function postUpdateDisplay(cm,update){for(var viewport=update.viewport,first=!0;;first=!1){if(!first||!cm.options.lineWrapping||update.oldDisplayWidth==displayWidth(cm)){viewport&&null!=viewport.top&&(viewport={top:Math.min(cm.doc.height+paddingVert(cm.display)-displayHeight(cm),viewport.top)});update.visible=visibleLines(cm.display,cm.doc,viewport);if(update.visible.from>=cm.display.viewFrom&&update.visible.to<=cm.display.viewTo)break}if(!updateDisplayIfNeeded(cm,update))break;updateHeightsInViewport(cm);var barMeasure=measureForScrollbars(cm);updateSelection(cm);updateScrollbars(cm,barMeasure);setDocumentHeight(cm,barMeasure)}update.signal(cm,"update",cm);if(cm.display.viewFrom!=cm.display.reportedViewFrom||cm.display.viewTo!=cm.display.reportedViewTo){update.signal(cm,"viewportChange",cm,cm.display.viewFrom,cm.display.viewTo);cm.display.reportedViewFrom=cm.display.viewFrom;cm.display.reportedViewTo=cm.display.viewTo}}function updateDisplaySimple(cm,viewport){var update=new DisplayUpdate(cm,viewport);if(updateDisplayIfNeeded(cm,update)){updateHeightsInViewport(cm);postUpdateDisplay(cm,update);var barMeasure=measureForScrollbars(cm);updateSelection(cm);updateScrollbars(cm,barMeasure);setDocumentHeight(cm,barMeasure);update.finish()}}function setDocumentHeight(cm,measure){cm.display.sizer.style.minHeight=measure.docHeight+"px";cm.display.heightForcer.style.top=measure.docHeight+"px";cm.display.gutters.style.height=measure.docHeight+cm.display.barHeight+scrollGap(cm)+"px"}function updateHeightsInViewport(cm){for(var display=cm.display,prevBottom=display.lineDiv.offsetTop,i=0;i<display.view.length;i++){var height,cur=display.view[i];if(!cur.hidden){if(ie&&8>ie_version){var bot=cur.node.offsetTop+cur.node.offsetHeight;height=bot-prevBottom;prevBottom=bot}else{var box=cur.node.getBoundingClientRect();height=box.bottom-box.top}var diff=cur.line.height-height;2>height&&(height=textHeight(display));if(diff>.001||-.001>diff){updateLineHeight(cur.line,height);updateWidgetHeight(cur.line);if(cur.rest)for(var j=0;j<cur.rest.length;j++)updateWidgetHeight(cur.rest[j])}}}}function updateWidgetHeight(line){if(line.widgets)for(var i=0;i<line.widgets.length;++i)line.widgets[i].height=line.widgets[i].node.parentNode.offsetHeight}function getDimensions(cm){for(var d=cm.display,left={},width={},gutterLeft=d.gutters.clientLeft,n=d.gutters.firstChild,i=0;n;n=n.nextSibling,++i){left[cm.options.gutters[i]]=n.offsetLeft+n.clientLeft+gutterLeft;width[cm.options.gutters[i]]=n.clientWidth}return{fixedPos:compensateForHScroll(d),gutterTotalWidth:d.gutters.offsetWidth,gutterLeft:left,gutterWidth:width,wrapperWidth:d.wrapper.clientWidth}}function patchDisplay(cm,updateNumbersFrom,dims){function rm(node){var next=node.nextSibling;webkit&&mac&&cm.display.currentWheelTarget==node?node.style.display="none":node.parentNode.removeChild(node);return next}for(var display=cm.display,lineNumbers=cm.options.lineNumbers,container=display.lineDiv,cur=container.firstChild,view=display.view,lineN=display.viewFrom,i=0;i<view.length;i++){var lineView=view[i];if(lineView.hidden);else if(lineView.node&&lineView.node.parentNode==container){for(;cur!=lineView.node;)cur=rm(cur);var updateNumber=lineNumbers&&null!=updateNumbersFrom&&lineN>=updateNumbersFrom&&lineView.lineNumber;if(lineView.changes){indexOf(lineView.changes,"gutter")>-1&&(updateNumber=!1);updateLineForChanges(cm,lineView,lineN,dims)}if(updateNumber){removeChildren(lineView.lineNumber);lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options,lineN)))}cur=lineView.node.nextSibling}else{var node=buildLineElement(cm,lineView,lineN,dims);container.insertBefore(node,cur)}lineN+=lineView.size}for(;cur;)cur=rm(cur)}function updateLineForChanges(cm,lineView,lineN,dims){for(var j=0;j<lineView.changes.length;j++){var type=lineView.changes[j];"text"==type?updateLineText(cm,lineView):"gutter"==type?updateLineGutter(cm,lineView,lineN,dims):"class"==type?updateLineClasses(lineView):"widget"==type&&updateLineWidgets(cm,lineView,dims)}lineView.changes=null}function ensureLineWrapped(lineView){if(lineView.node==lineView.text){lineView.node=elt("div",null,null,"position: relative");lineView.text.parentNode&&lineView.text.parentNode.replaceChild(lineView.node,lineView.text);lineView.node.appendChild(lineView.text);ie&&8>ie_version&&(lineView.node.style.zIndex=2)}return lineView.node}function updateLineBackground(lineView){var cls=lineView.bgClass?lineView.bgClass+" "+(lineView.line.bgClass||""):lineView.line.bgClass;cls&&(cls+=" CodeMirror-linebackground");if(lineView.background)if(cls)lineView.background.className=cls;else{lineView.background.parentNode.removeChild(lineView.background);lineView.background=null}else if(cls){var wrap=ensureLineWrapped(lineView);lineView.background=wrap.insertBefore(elt("div",null,cls),wrap.firstChild)}}function getLineContent(cm,lineView){var ext=cm.display.externalMeasured;if(ext&&ext.line==lineView.line){cm.display.externalMeasured=null;lineView.measure=ext.measure;return ext.built}return buildLineContent(cm,lineView)}function updateLineText(cm,lineView){var cls=lineView.text.className,built=getLineContent(cm,lineView);lineView.text==lineView.node&&(lineView.node=built.pre);lineView.text.parentNode.replaceChild(built.pre,lineView.text);lineView.text=built.pre;if(built.bgClass!=lineView.bgClass||built.textClass!=lineView.textClass){lineView.bgClass=built.bgClass;lineView.textClass=built.textClass;updateLineClasses(lineView)}else cls&&(lineView.text.className=cls)}function updateLineClasses(lineView){updateLineBackground(lineView);lineView.line.wrapClass?ensureLineWrapped(lineView).className=lineView.line.wrapClass:lineView.node!=lineView.text&&(lineView.node.className="");var textClass=lineView.textClass?lineView.textClass+" "+(lineView.line.textClass||""):lineView.line.textClass;lineView.text.className=textClass||""}function updateLineGutter(cm,lineView,lineN,dims){if(lineView.gutter){lineView.node.removeChild(lineView.gutter);lineView.gutter=null}if(lineView.gutterBackground){lineView.node.removeChild(lineView.gutterBackground);lineView.gutterBackground=null}if(lineView.line.gutterClass){var wrap=ensureLineWrapped(lineView);lineView.gutterBackground=elt("div",null,"CodeMirror-gutter-background "+lineView.line.gutterClass,"left: "+(cm.options.fixedGutter?dims.fixedPos:-dims.gutterTotalWidth)+"px; width: "+dims.gutterTotalWidth+"px");wrap.insertBefore(lineView.gutterBackground,lineView.text)}var markers=lineView.line.gutterMarkers;if(cm.options.lineNumbers||markers){var wrap=ensureLineWrapped(lineView),gutterWrap=lineView.gutter=elt("div",null,"CodeMirror-gutter-wrapper","left: "+(cm.options.fixedGutter?dims.fixedPos:-dims.gutterTotalWidth)+"px");cm.display.input.setUneditable(gutterWrap);wrap.insertBefore(gutterWrap,lineView.text);lineView.line.gutterClass&&(gutterWrap.className+=" "+lineView.line.gutterClass);!cm.options.lineNumbers||markers&&markers["CodeMirror-linenumbers"]||(lineView.lineNumber=gutterWrap.appendChild(elt("div",lineNumberFor(cm.options,lineN),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+dims.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+cm.display.lineNumInnerWidth+"px")));if(markers)for(var k=0;k<cm.options.gutters.length;++k){var id=cm.options.gutters[k],found=markers.hasOwnProperty(id)&&markers[id];found&&gutterWrap.appendChild(elt("div",[found],"CodeMirror-gutter-elt","left: "+dims.gutterLeft[id]+"px; width: "+dims.gutterWidth[id]+"px"))}}}function updateLineWidgets(cm,lineView,dims){lineView.alignable&&(lineView.alignable=null);for(var next,node=lineView.node.firstChild;node;node=next){var next=node.nextSibling;"CodeMirror-linewidget"==node.className&&lineView.node.removeChild(node)}insertLineWidgets(cm,lineView,dims)}function buildLineElement(cm,lineView,lineN,dims){var built=getLineContent(cm,lineView);lineView.text=lineView.node=built.pre;built.bgClass&&(lineView.bgClass=built.bgClass);built.textClass&&(lineView.textClass=built.textClass);updateLineClasses(lineView);updateLineGutter(cm,lineView,lineN,dims);insertLineWidgets(cm,lineView,dims);return lineView.node}function insertLineWidgets(cm,lineView,dims){insertLineWidgetsFor(cm,lineView.line,lineView,dims,!0);if(lineView.rest)for(var i=0;i<lineView.rest.length;i++)insertLineWidgetsFor(cm,lineView.rest[i],lineView,dims,!1)}function insertLineWidgetsFor(cm,line,lineView,dims,allowAbove){if(line.widgets)for(var wrap=ensureLineWrapped(lineView),i=0,ws=line.widgets;i<ws.length;++i){var widget=ws[i],node=elt("div",[widget.node],"CodeMirror-linewidget");widget.handleMouseEvents||node.setAttribute("cm-ignore-events","true");positionLineWidget(widget,node,lineView,dims);cm.display.input.setUneditable(node);allowAbove&&widget.above?wrap.insertBefore(node,lineView.gutter||lineView.text):wrap.appendChild(node);signalLater(widget,"redraw")}}function positionLineWidget(widget,node,lineView,dims){if(widget.noHScroll){(lineView.alignable||(lineView.alignable=[])).push(node);var width=dims.wrapperWidth;node.style.left=dims.fixedPos+"px";if(!widget.coverGutter){width-=dims.gutterTotalWidth;node.style.paddingLeft=dims.gutterTotalWidth+"px"}node.style.width=width+"px"}if(widget.coverGutter){node.style.zIndex=5;node.style.position="relative";widget.noHScroll||(node.style.marginLeft=-dims.gutterTotalWidth+"px")}}function copyPos(x){return Pos(x.line,x.ch)}function maxPos(a,b){return cmp(a,b)<0?b:a}function minPos(a,b){return cmp(a,b)<0?a:b}function ensureFocus(cm){if(!cm.state.focused){cm.display.input.focus();onFocus(cm)}}function applyTextInput(cm,inserted,deleted,sel,origin){var doc=cm.doc;cm.display.shift=!1;sel||(sel=doc.sel);var paste=cm.state.pasteIncoming||"paste"==origin,textLines=doc.splitLines(inserted),multiPaste=null;if(paste&&sel.ranges.length>1)if(lastCopied&&lastCopied.join("\n")==inserted){if(sel.ranges.length%lastCopied.length==0){multiPaste=[];for(var i=0;i<lastCopied.length;i++)multiPaste.push(doc.splitLines(lastCopied[i]))}}else textLines.length==sel.ranges.length&&(multiPaste=map(textLines,function(l){return[l]}));for(var i=sel.ranges.length-1;i>=0;i--){var range=sel.ranges[i],from=range.from(),to=range.to();range.empty()&&(deleted&&deleted>0?from=Pos(from.line,from.ch-deleted):cm.state.overwrite&&!paste&&(to=Pos(to.line,Math.min(getLine(doc,to.line).text.length,to.ch+lst(textLines).length))));var updateInput=cm.curOp.updateInput,changeEvent={from:from,to:to,text:multiPaste?multiPaste[i%multiPaste.length]:textLines,origin:origin||(paste?"paste":cm.state.cutIncoming?"cut":"+input")};makeChange(cm.doc,changeEvent);signalLater(cm,"inputRead",cm,changeEvent)}inserted&&!paste&&triggerElectric(cm,inserted);ensureCursorVisible(cm);cm.curOp.updateInput=updateInput;cm.curOp.typing=!0;cm.state.pasteIncoming=cm.state.cutIncoming=!1}function handlePaste(e,cm){var pasted=e.clipboardData&&e.clipboardData.getData("text/plain");if(pasted){e.preventDefault();cm.isReadOnly()||cm.options.disableInput||runInOp(cm,function(){applyTextInput(cm,pasted,0,null,"paste")});return!0}}function triggerElectric(cm,inserted){if(cm.options.electricChars&&cm.options.smartIndent)for(var sel=cm.doc.sel,i=sel.ranges.length-1;i>=0;i--){var range=sel.ranges[i];if(!(range.head.ch>100||i&&sel.ranges[i-1].head.line==range.head.line)){var mode=cm.getModeAt(range.head),indented=!1;if(mode.electricChars){for(var j=0;j<mode.electricChars.length;j++)if(inserted.indexOf(mode.electricChars.charAt(j))>-1){indented=indentLine(cm,range.head.line,"smart");break}}else mode.electricInput&&mode.electricInput.test(getLine(cm.doc,range.head.line).text.slice(0,range.head.ch))&&(indented=indentLine(cm,range.head.line,"smart"));indented&&signalLater(cm,"electricInput",cm,range.head.line)}}}function copyableRanges(cm){for(var text=[],ranges=[],i=0;i<cm.doc.sel.ranges.length;i++){var line=cm.doc.sel.ranges[i].head.line,lineRange={anchor:Pos(line,0),head:Pos(line+1,0)};ranges.push(lineRange);text.push(cm.getRange(lineRange.anchor,lineRange.head))}return{text:text,ranges:ranges}}function disableBrowserMagic(field){field.setAttribute("autocorrect","off");field.setAttribute("autocapitalize","off");field.setAttribute("spellcheck","false")}function TextareaInput(cm){this.cm=cm;this.prevInput="";this.pollingFast=!1;this.polling=new Delayed;this.inaccurateSelection=!1;this.hasSelection=!1;this.composing=null}function hiddenTextarea(){var te=elt("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none"),div=elt("div",[te],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");webkit?te.style.width="1000px":te.setAttribute("wrap","off");ios&&(te.style.border="1px solid black");disableBrowserMagic(te);return div}function ContentEditableInput(cm){this.cm=cm;this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null;this.polling=new Delayed;this.gracePeriod=!1}function posToDOM(cm,pos){var view=findViewForLine(cm,pos.line);if(!view||view.hidden)return null;var line=getLine(cm.doc,pos.line),info=mapFromLineView(view,line,pos.line),order=getOrder(line),side="left";if(order){var partPos=getBidiPartAt(order,pos.ch);side=partPos%2?"right":"left"}var result=nodeAndOffsetInLineMap(info.map,pos.ch,side);result.offset="right"==result.collapse?result.end:result.start;return result}function badPos(pos,bad){bad&&(pos.bad=!0);return pos}function domToPos(cm,node,offset){var lineNode;if(node==cm.display.lineDiv){lineNode=cm.display.lineDiv.childNodes[offset];if(!lineNode)return badPos(cm.clipPos(Pos(cm.display.viewTo-1)),!0);node=null;offset=0}else for(lineNode=node;;lineNode=lineNode.parentNode){if(!lineNode||lineNode==cm.display.lineDiv)return null;if(lineNode.parentNode&&lineNode.parentNode==cm.display.lineDiv)break}for(var i=0;i<cm.display.view.length;i++){var lineView=cm.display.view[i];if(lineView.node==lineNode)return locateNodeInLineView(lineView,node,offset)}}function locateNodeInLineView(lineView,node,offset){function find(textNode,topNode,offset){for(var i=-1;i<(maps?maps.length:0);i++)for(var map=0>i?measure.map:maps[i],j=0;j<map.length;j+=3){var curNode=map[j+2];if(curNode==textNode||curNode==topNode){var line=lineNo(0>i?lineView.line:lineView.rest[i]),ch=map[j]+offset;(0>offset||curNode!=textNode)&&(ch=map[j+(offset?1:0)]);return Pos(line,ch)}}}var wrapper=lineView.text.firstChild,bad=!1;if(!node||!contains(wrapper,node))return badPos(Pos(lineNo(lineView.line),0),!0);if(node==wrapper){bad=!0;node=wrapper.childNodes[offset];offset=0;if(!node){var line=lineView.rest?lst(lineView.rest):lineView.line;return badPos(Pos(lineNo(line),line.text.length),bad)}}var textNode=3==node.nodeType?node:null,topNode=node;if(!textNode&&1==node.childNodes.length&&3==node.firstChild.nodeType){textNode=node.firstChild;offset&&(offset=textNode.nodeValue.length)}for(;topNode.parentNode!=wrapper;)topNode=topNode.parentNode;var measure=lineView.measure,maps=measure.maps,found=find(textNode,topNode,offset);if(found)return badPos(found,bad);for(var after=topNode.nextSibling,dist=textNode?textNode.nodeValue.length-offset:0;after;after=after.nextSibling){found=find(after,after.firstChild,0);if(found)return badPos(Pos(found.line,found.ch-dist),bad);dist+=after.textContent.length}for(var before=topNode.previousSibling,dist=offset;before;before=before.previousSibling){found=find(before,before.firstChild,-1);if(found)return badPos(Pos(found.line,found.ch+dist),bad);dist+=after.textContent.length}}function domTextBetween(cm,from,to,fromLine,toLine){function recognizeMarker(id){return function(marker){return marker.id==id}}function walk(node){if(1==node.nodeType){var cmText=node.getAttribute("cm-text");if(null!=cmText){""==cmText&&(cmText=node.textContent.replace(/\u200b/g,""));text+=cmText;return}var range,markerID=node.getAttribute("cm-marker");if(markerID){var found=cm.findMarks(Pos(fromLine,0),Pos(toLine+1,0),recognizeMarker(+markerID));found.length&&(range=found[0].find())&&(text+=getBetween(cm.doc,range.from,range.to).join(lineSep));return}if("false"==node.getAttribute("contenteditable"))return;for(var i=0;i<node.childNodes.length;i++)walk(node.childNodes[i]);/^(pre|div|p)$/i.test(node.nodeName)&&(closing=!0)}else if(3==node.nodeType){var val=node.nodeValue;if(!val)return;if(closing){text+=lineSep;closing=!1}text+=val}}for(var text="",closing=!1,lineSep=cm.doc.lineSeparator();;){walk(from);if(from==to)break;from=from.nextSibling}return text}function Selection(ranges,primIndex){this.ranges=ranges;this.primIndex=primIndex}function Range(anchor,head){this.anchor=anchor;this.head=head}function normalizeSelection(ranges,primIndex){var prim=ranges[primIndex];ranges.sort(function(a,b){return cmp(a.from(),b.from())});primIndex=indexOf(ranges,prim);for(var i=1;i<ranges.length;i++){var cur=ranges[i],prev=ranges[i-1];if(cmp(prev.to(),cur.from())>=0){var from=minPos(prev.from(),cur.from()),to=maxPos(prev.to(),cur.to()),inv=prev.empty()?cur.from()==cur.head:prev.from()==prev.head;primIndex>=i&&--primIndex;ranges.splice(--i,2,new Range(inv?to:from,inv?from:to))}}return new Selection(ranges,primIndex)}function simpleSelection(anchor,head){return new Selection([new Range(anchor,head||anchor)],0)}function clipLine(doc,n){return Math.max(doc.first,Math.min(n,doc.first+doc.size-1))}function clipPos(doc,pos){if(pos.line<doc.first)return Pos(doc.first,0);
2
+ var last=doc.first+doc.size-1;return pos.line>last?Pos(last,getLine(doc,last).text.length):clipToLen(pos,getLine(doc,pos.line).text.length)}function clipToLen(pos,linelen){var ch=pos.ch;return null==ch||ch>linelen?Pos(pos.line,linelen):0>ch?Pos(pos.line,0):pos}function isLine(doc,l){return l>=doc.first&&l<doc.first+doc.size}function clipPosArray(doc,array){for(var out=[],i=0;i<array.length;i++)out[i]=clipPos(doc,array[i]);return out}function extendRange(doc,range,head,other){if(doc.cm&&doc.cm.display.shift||doc.extend){var anchor=range.anchor;if(other){var posBefore=cmp(head,anchor)<0;if(posBefore!=cmp(other,anchor)<0){anchor=head;head=other}else posBefore!=cmp(head,other)<0&&(head=other)}return new Range(anchor,head)}return new Range(other||head,head)}function extendSelection(doc,head,other,options){setSelection(doc,new Selection([extendRange(doc,doc.sel.primary(),head,other)],0),options)}function extendSelections(doc,heads,options){for(var out=[],i=0;i<doc.sel.ranges.length;i++)out[i]=extendRange(doc,doc.sel.ranges[i],heads[i],null);var newSel=normalizeSelection(out,doc.sel.primIndex);setSelection(doc,newSel,options)}function replaceOneSelection(doc,i,range,options){var ranges=doc.sel.ranges.slice(0);ranges[i]=range;setSelection(doc,normalizeSelection(ranges,doc.sel.primIndex),options)}function setSimpleSelection(doc,anchor,head,options){setSelection(doc,simpleSelection(anchor,head),options)}function filterSelectionChange(doc,sel,options){var obj={ranges:sel.ranges,update:function(ranges){this.ranges=[];for(var i=0;i<ranges.length;i++)this.ranges[i]=new Range(clipPos(doc,ranges[i].anchor),clipPos(doc,ranges[i].head))},origin:options&&options.origin};signal(doc,"beforeSelectionChange",doc,obj);doc.cm&&signal(doc.cm,"beforeSelectionChange",doc.cm,obj);return obj.ranges!=sel.ranges?normalizeSelection(obj.ranges,obj.ranges.length-1):sel}function setSelectionReplaceHistory(doc,sel,options){var done=doc.history.done,last=lst(done);if(last&&last.ranges){done[done.length-1]=sel;setSelectionNoUndo(doc,sel,options)}else setSelection(doc,sel,options)}function setSelection(doc,sel,options){setSelectionNoUndo(doc,sel,options);addSelectionToHistory(doc,doc.sel,doc.cm?doc.cm.curOp.id:NaN,options)}function setSelectionNoUndo(doc,sel,options){(hasHandler(doc,"beforeSelectionChange")||doc.cm&&hasHandler(doc.cm,"beforeSelectionChange"))&&(sel=filterSelectionChange(doc,sel,options));var bias=options&&options.bias||(cmp(sel.primary().head,doc.sel.primary().head)<0?-1:1);setSelectionInner(doc,skipAtomicInSelection(doc,sel,bias,!0));options&&options.scroll===!1||!doc.cm||ensureCursorVisible(doc.cm)}function setSelectionInner(doc,sel){if(!sel.equals(doc.sel)){doc.sel=sel;if(doc.cm){doc.cm.curOp.updateInput=doc.cm.curOp.selectionChanged=!0;signalCursorActivity(doc.cm)}signalLater(doc,"cursorActivity",doc)}}function reCheckSelection(doc){setSelectionInner(doc,skipAtomicInSelection(doc,doc.sel,null,!1),sel_dontScroll)}function skipAtomicInSelection(doc,sel,bias,mayClear){for(var out,i=0;i<sel.ranges.length;i++){var range=sel.ranges[i],old=sel.ranges.length==doc.sel.ranges.length&&doc.sel.ranges[i],newAnchor=skipAtomic(doc,range.anchor,old&&old.anchor,bias,mayClear),newHead=skipAtomic(doc,range.head,old&&old.head,bias,mayClear);if(out||newAnchor!=range.anchor||newHead!=range.head){out||(out=sel.ranges.slice(0,i));out[i]=new Range(newAnchor,newHead)}}return out?normalizeSelection(out,sel.primIndex):sel}function skipAtomicInner(doc,pos,oldPos,dir,mayClear){var line=getLine(doc,pos.line);if(line.markedSpans)for(var i=0;i<line.markedSpans.length;++i){var sp=line.markedSpans[i],m=sp.marker;if((null==sp.from||(m.inclusiveLeft?sp.from<=pos.ch:sp.from<pos.ch))&&(null==sp.to||(m.inclusiveRight?sp.to>=pos.ch:sp.to>pos.ch))){if(mayClear){signal(m,"beforeCursorEnter");if(m.explicitlyCleared){if(line.markedSpans){--i;continue}break}}if(!m.atomic)continue;if(oldPos){var diff,near=m.find(0>dir?1:-1);(0>dir?m.inclusiveRight:m.inclusiveLeft)&&(near=movePos(doc,near,-dir,near&&near.line==pos.line?line:null));if(near&&near.line==pos.line&&(diff=cmp(near,oldPos))&&(0>dir?0>diff:diff>0))return skipAtomicInner(doc,near,pos,dir,mayClear)}var far=m.find(0>dir?-1:1);(0>dir?m.inclusiveLeft:m.inclusiveRight)&&(far=movePos(doc,far,dir,far.line==pos.line?line:null));return far?skipAtomicInner(doc,far,pos,dir,mayClear):null}}return pos}function skipAtomic(doc,pos,oldPos,bias,mayClear){var dir=bias||1,found=skipAtomicInner(doc,pos,oldPos,dir,mayClear)||!mayClear&&skipAtomicInner(doc,pos,oldPos,dir,!0)||skipAtomicInner(doc,pos,oldPos,-dir,mayClear)||!mayClear&&skipAtomicInner(doc,pos,oldPos,-dir,!0);if(!found){doc.cantEdit=!0;return Pos(doc.first,0)}return found}function movePos(doc,pos,dir,line){return 0>dir&&0==pos.ch?pos.line>doc.first?clipPos(doc,Pos(pos.line-1)):null:dir>0&&pos.ch==(line||getLine(doc,pos.line)).text.length?pos.line<doc.first+doc.size-1?Pos(pos.line+1,0):null:new Pos(pos.line,pos.ch+dir)}function updateSelection(cm){cm.display.input.showSelection(cm.display.input.prepareSelection())}function prepareSelection(cm,primary){for(var doc=cm.doc,result={},curFragment=result.cursors=document.createDocumentFragment(),selFragment=result.selection=document.createDocumentFragment(),i=0;i<doc.sel.ranges.length;i++)if(primary!==!1||i!=doc.sel.primIndex){var range=doc.sel.ranges[i];if(!(range.from().line>=cm.display.viewTo||range.to().line<cm.display.viewFrom)){var collapsed=range.empty();(collapsed||cm.options.showCursorWhenSelecting)&&drawSelectionCursor(cm,range.head,curFragment);collapsed||drawSelectionRange(cm,range,selFragment)}}return result}function drawSelectionCursor(cm,head,output){var pos=cursorCoords(cm,head,"div",null,null,!cm.options.singleCursorHeightPerLine),cursor=output.appendChild(elt("div"," ","CodeMirror-cursor"));cursor.style.left=pos.left+"px";cursor.style.top=pos.top+"px";cursor.style.height=Math.max(0,pos.bottom-pos.top)*cm.options.cursorHeight+"px";if(pos.other){var otherCursor=output.appendChild(elt("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));otherCursor.style.display="";otherCursor.style.left=pos.other.left+"px";otherCursor.style.top=pos.other.top+"px";otherCursor.style.height=.85*(pos.other.bottom-pos.other.top)+"px"}}function drawSelectionRange(cm,range,output){function add(left,top,width,bottom){0>top&&(top=0);top=Math.round(top);bottom=Math.round(bottom);fragment.appendChild(elt("div",null,"CodeMirror-selected","position: absolute; left: "+left+"px; top: "+top+"px; width: "+(null==width?rightSide-left:width)+"px; height: "+(bottom-top)+"px"))}function drawForLine(line,fromArg,toArg){function coords(ch,bias){return charCoords(cm,Pos(line,ch),"div",lineObj,bias)}var start,end,lineObj=getLine(doc,line),lineLen=lineObj.text.length;iterateBidiSections(getOrder(lineObj),fromArg||0,null==toArg?lineLen:toArg,function(from,to,dir){var rightPos,left,right,leftPos=coords(from,"left");if(from==to){rightPos=leftPos;left=right=leftPos.left}else{rightPos=coords(to-1,"right");if("rtl"==dir){var tmp=leftPos;leftPos=rightPos;rightPos=tmp}left=leftPos.left;right=rightPos.right}null==fromArg&&0==from&&(left=leftSide);if(rightPos.top-leftPos.top>3){add(left,leftPos.top,null,leftPos.bottom);left=leftSide;leftPos.bottom<rightPos.top&&add(left,leftPos.bottom,null,rightPos.top)}null==toArg&&to==lineLen&&(right=rightSide);(!start||leftPos.top<start.top||leftPos.top==start.top&&leftPos.left<start.left)&&(start=leftPos);(!end||rightPos.bottom>end.bottom||rightPos.bottom==end.bottom&&rightPos.right>end.right)&&(end=rightPos);leftSide+1>left&&(left=leftSide);add(left,rightPos.top,right-left,rightPos.bottom)});return{start:start,end:end}}var display=cm.display,doc=cm.doc,fragment=document.createDocumentFragment(),padding=paddingH(cm.display),leftSide=padding.left,rightSide=Math.max(display.sizerWidth,displayWidth(cm)-display.sizer.offsetLeft)-padding.right,sFrom=range.from(),sTo=range.to();if(sFrom.line==sTo.line)drawForLine(sFrom.line,sFrom.ch,sTo.ch);else{var fromLine=getLine(doc,sFrom.line),toLine=getLine(doc,sTo.line),singleVLine=visualLine(fromLine)==visualLine(toLine),leftEnd=drawForLine(sFrom.line,sFrom.ch,singleVLine?fromLine.text.length+1:null).end,rightStart=drawForLine(sTo.line,singleVLine?0:null,sTo.ch).start;if(singleVLine)if(leftEnd.top<rightStart.top-2){add(leftEnd.right,leftEnd.top,null,leftEnd.bottom);add(leftSide,rightStart.top,rightStart.left,rightStart.bottom)}else add(leftEnd.right,leftEnd.top,rightStart.left-leftEnd.right,leftEnd.bottom);leftEnd.bottom<rightStart.top&&add(leftSide,leftEnd.bottom,null,rightStart.top)}output.appendChild(fragment)}function restartBlink(cm){if(cm.state.focused){var display=cm.display;clearInterval(display.blinker);var on=!0;display.cursorDiv.style.visibility="";cm.options.cursorBlinkRate>0?display.blinker=setInterval(function(){display.cursorDiv.style.visibility=(on=!on)?"":"hidden"},cm.options.cursorBlinkRate):cm.options.cursorBlinkRate<0&&(display.cursorDiv.style.visibility="hidden")}}function startWorker(cm,time){cm.doc.mode.startState&&cm.doc.frontier<cm.display.viewTo&&cm.state.highlight.set(time,bind(highlightWorker,cm))}function highlightWorker(cm){var doc=cm.doc;doc.frontier<doc.first&&(doc.frontier=doc.first);if(!(doc.frontier>=cm.display.viewTo)){var end=+new Date+cm.options.workTime,state=copyState(doc.mode,getStateBefore(cm,doc.frontier)),changedLines=[];doc.iter(doc.frontier,Math.min(doc.first+doc.size,cm.display.viewTo+500),function(line){if(doc.frontier>=cm.display.viewFrom){var oldStyles=line.styles,tooLong=line.text.length>cm.options.maxHighlightLength,highlighted=highlightLine(cm,line,tooLong?copyState(doc.mode,state):state,!0);line.styles=highlighted.styles;var oldCls=line.styleClasses,newCls=highlighted.classes;newCls?line.styleClasses=newCls:oldCls&&(line.styleClasses=null);for(var ischange=!oldStyles||oldStyles.length!=line.styles.length||oldCls!=newCls&&(!oldCls||!newCls||oldCls.bgClass!=newCls.bgClass||oldCls.textClass!=newCls.textClass),i=0;!ischange&&i<oldStyles.length;++i)ischange=oldStyles[i]!=line.styles[i];ischange&&changedLines.push(doc.frontier);line.stateAfter=tooLong?state:copyState(doc.mode,state)}else{line.text.length<=cm.options.maxHighlightLength&&processLine(cm,line.text,state);line.stateAfter=doc.frontier%5==0?copyState(doc.mode,state):null}++doc.frontier;if(+new Date>end){startWorker(cm,cm.options.workDelay);return!0}});changedLines.length&&runInOp(cm,function(){for(var i=0;i<changedLines.length;i++)regLineChange(cm,changedLines[i],"text")})}}function findStartLine(cm,n,precise){for(var minindent,minline,doc=cm.doc,lim=precise?-1:n-(cm.doc.mode.innerMode?1e3:100),search=n;search>lim;--search){if(search<=doc.first)return doc.first;var line=getLine(doc,search-1);if(line.stateAfter&&(!precise||search<=doc.frontier))return search;var indented=countColumn(line.text,null,cm.options.tabSize);if(null==minline||minindent>indented){minline=search-1;minindent=indented}}return minline}function getStateBefore(cm,n,precise){var doc=cm.doc,display=cm.display;if(!doc.mode.startState)return!0;var pos=findStartLine(cm,n,precise),state=pos>doc.first&&getLine(doc,pos-1).stateAfter;state=state?copyState(doc.mode,state):startState(doc.mode);doc.iter(pos,n,function(line){processLine(cm,line.text,state);var save=pos==n-1||pos%5==0||pos>=display.viewFrom&&pos<display.viewTo;line.stateAfter=save?copyState(doc.mode,state):null;++pos});precise&&(doc.frontier=pos);return state}function paddingTop(display){return display.lineSpace.offsetTop}function paddingVert(display){return display.mover.offsetHeight-display.lineSpace.offsetHeight}function paddingH(display){if(display.cachedPaddingH)return display.cachedPaddingH;var e=removeChildrenAndAdd(display.measure,elt("pre","x")),style=window.getComputedStyle?window.getComputedStyle(e):e.currentStyle,data={left:parseInt(style.paddingLeft),right:parseInt(style.paddingRight)};isNaN(data.left)||isNaN(data.right)||(display.cachedPaddingH=data);return data}function scrollGap(cm){return scrollerGap-cm.display.nativeBarWidth}function displayWidth(cm){return cm.display.scroller.clientWidth-scrollGap(cm)-cm.display.barWidth}function displayHeight(cm){return cm.display.scroller.clientHeight-scrollGap(cm)-cm.display.barHeight}function ensureLineHeights(cm,lineView,rect){var wrapping=cm.options.lineWrapping,curWidth=wrapping&&displayWidth(cm);if(!lineView.measure.heights||wrapping&&lineView.measure.width!=curWidth){var heights=lineView.measure.heights=[];if(wrapping){lineView.measure.width=curWidth;for(var rects=lineView.text.firstChild.getClientRects(),i=0;i<rects.length-1;i++){var cur=rects[i],next=rects[i+1];Math.abs(cur.bottom-next.bottom)>2&&heights.push((cur.bottom+next.top)/2-rect.top)}}heights.push(rect.bottom-rect.top)}}function mapFromLineView(lineView,line,lineN){if(lineView.line==line)return{map:lineView.measure.map,cache:lineView.measure.cache};for(var i=0;i<lineView.rest.length;i++)if(lineView.rest[i]==line)return{map:lineView.measure.maps[i],cache:lineView.measure.caches[i]};for(var i=0;i<lineView.rest.length;i++)if(lineNo(lineView.rest[i])>lineN)return{map:lineView.measure.maps[i],cache:lineView.measure.caches[i],before:!0}}function updateExternalMeasurement(cm,line){line=visualLine(line);var lineN=lineNo(line),view=cm.display.externalMeasured=new LineView(cm.doc,line,lineN);view.lineN=lineN;var built=view.built=buildLineContent(cm,view);view.text=built.pre;removeChildrenAndAdd(cm.display.lineMeasure,built.pre);return view}function measureChar(cm,line,ch,bias){return measureCharPrepared(cm,prepareMeasureForLine(cm,line),ch,bias)}function findViewForLine(cm,lineN){if(lineN>=cm.display.viewFrom&&lineN<cm.display.viewTo)return cm.display.view[findViewIndex(cm,lineN)];var ext=cm.display.externalMeasured;return ext&&lineN>=ext.lineN&&lineN<ext.lineN+ext.size?ext:void 0}function prepareMeasureForLine(cm,line){var lineN=lineNo(line),view=findViewForLine(cm,lineN);if(view&&!view.text)view=null;else if(view&&view.changes){updateLineForChanges(cm,view,lineN,getDimensions(cm));cm.curOp.forceUpdate=!0}view||(view=updateExternalMeasurement(cm,line));var info=mapFromLineView(view,line,lineN);return{line:line,view:view,rect:null,map:info.map,cache:info.cache,before:info.before,hasHeights:!1}}function measureCharPrepared(cm,prepared,ch,bias,varHeight){prepared.before&&(ch=-1);var found,key=ch+(bias||"");if(prepared.cache.hasOwnProperty(key))found=prepared.cache[key];else{prepared.rect||(prepared.rect=prepared.view.text.getBoundingClientRect());if(!prepared.hasHeights){ensureLineHeights(cm,prepared.view,prepared.rect);prepared.hasHeights=!0}found=measureCharInner(cm,prepared,ch,bias);found.bogus||(prepared.cache[key]=found)}return{left:found.left,right:found.right,top:varHeight?found.rtop:found.top,bottom:varHeight?found.rbottom:found.bottom}}function nodeAndOffsetInLineMap(map,ch,bias){for(var node,start,end,collapse,i=0;i<map.length;i+=3){var mStart=map[i],mEnd=map[i+1];if(mStart>ch){start=0;end=1;collapse="left"}else if(mEnd>ch){start=ch-mStart;end=start+1}else if(i==map.length-3||ch==mEnd&&map[i+3]>ch){end=mEnd-mStart;start=end-1;ch>=mEnd&&(collapse="right")}if(null!=start){node=map[i+2];mStart==mEnd&&bias==(node.insertLeft?"left":"right")&&(collapse=bias);if("left"==bias&&0==start)for(;i&&map[i-2]==map[i-3]&&map[i-1].insertLeft;){node=map[(i-=3)+2];collapse="left"}if("right"==bias&&start==mEnd-mStart)for(;i<map.length-3&&map[i+3]==map[i+4]&&!map[i+5].insertLeft;){node=map[(i+=3)+2];collapse="right"}break}}return{node:node,start:start,end:end,collapse:collapse,coverStart:mStart,coverEnd:mEnd}}function measureCharInner(cm,prepared,ch,bias){var rect,place=nodeAndOffsetInLineMap(prepared.map,ch,bias),node=place.node,start=place.start,end=place.end,collapse=place.collapse;if(3==node.nodeType){for(var i=0;4>i;i++){for(;start&&isExtendingChar(prepared.line.text.charAt(place.coverStart+start));)--start;for(;place.coverStart+end<place.coverEnd&&isExtendingChar(prepared.line.text.charAt(place.coverStart+end));)++end;if(ie&&9>ie_version&&0==start&&end==place.coverEnd-place.coverStart)rect=node.parentNode.getBoundingClientRect();else if(ie&&cm.options.lineWrapping){var rects=range(node,start,end).getClientRects();rect=rects.length?rects["right"==bias?rects.length-1:0]:nullRect}else rect=range(node,start,end).getBoundingClientRect()||nullRect;if(rect.left||rect.right||0==start)break;end=start;start-=1;collapse="right"}ie&&11>ie_version&&(rect=maybeUpdateRectForZooming(cm.display.measure,rect))}else{start>0&&(collapse=bias="right");var rects;rect=cm.options.lineWrapping&&(rects=node.getClientRects()).length>1?rects["right"==bias?rects.length-1:0]:node.getBoundingClientRect()}if(ie&&9>ie_version&&!start&&(!rect||!rect.left&&!rect.right)){var rSpan=node.parentNode.getClientRects()[0];rect=rSpan?{left:rSpan.left,right:rSpan.left+charWidth(cm.display),top:rSpan.top,bottom:rSpan.bottom}:nullRect}for(var rtop=rect.top-prepared.rect.top,rbot=rect.bottom-prepared.rect.top,mid=(rtop+rbot)/2,heights=prepared.view.measure.heights,i=0;i<heights.length-1&&!(mid<heights[i]);i++);var top=i?heights[i-1]:0,bot=heights[i],result={left:("right"==collapse?rect.right:rect.left)-prepared.rect.left,right:("left"==collapse?rect.left:rect.right)-prepared.rect.left,top:top,bottom:bot};rect.left||rect.right||(result.bogus=!0);if(!cm.options.singleCursorHeightPerLine){result.rtop=rtop;result.rbottom=rbot}return result}function maybeUpdateRectForZooming(measure,rect){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!hasBadZoomedRects(measure))return rect;var scaleX=screen.logicalXDPI/screen.deviceXDPI,scaleY=screen.logicalYDPI/screen.deviceYDPI;return{left:rect.left*scaleX,right:rect.right*scaleX,top:rect.top*scaleY,bottom:rect.bottom*scaleY}}function clearLineMeasurementCacheFor(lineView){if(lineView.measure){lineView.measure.cache={};lineView.measure.heights=null;if(lineView.rest)for(var i=0;i<lineView.rest.length;i++)lineView.measure.caches[i]={}}}function clearLineMeasurementCache(cm){cm.display.externalMeasure=null;removeChildren(cm.display.lineMeasure);for(var i=0;i<cm.display.view.length;i++)clearLineMeasurementCacheFor(cm.display.view[i])}function clearCaches(cm){clearLineMeasurementCache(cm);cm.display.cachedCharWidth=cm.display.cachedTextHeight=cm.display.cachedPaddingH=null;cm.options.lineWrapping||(cm.display.maxLineChanged=!0);cm.display.lineNumChars=null}function pageScrollX(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function pageScrollY(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function intoCoordSystem(cm,lineObj,rect,context){if(lineObj.widgets)for(var i=0;i<lineObj.widgets.length;++i)if(lineObj.widgets[i].above){var size=widgetHeight(lineObj.widgets[i]);rect.top+=size;rect.bottom+=size}if("line"==context)return rect;context||(context="local");var yOff=heightAtLine(lineObj);"local"==context?yOff+=paddingTop(cm.display):yOff-=cm.display.viewOffset;if("page"==context||"window"==context){var lOff=cm.display.lineSpace.getBoundingClientRect();yOff+=lOff.top+("window"==context?0:pageScrollY());var xOff=lOff.left+("window"==context?0:pageScrollX());rect.left+=xOff;rect.right+=xOff}rect.top+=yOff;rect.bottom+=yOff;return rect}function fromCoordSystem(cm,coords,context){if("div"==context)return coords;var left=coords.left,top=coords.top;if("page"==context){left-=pageScrollX();top-=pageScrollY()}else if("local"==context||!context){var localBox=cm.display.sizer.getBoundingClientRect();left+=localBox.left;top+=localBox.top}var lineSpaceBox=cm.display.lineSpace.getBoundingClientRect();return{left:left-lineSpaceBox.left,top:top-lineSpaceBox.top}}function charCoords(cm,pos,context,lineObj,bias){lineObj||(lineObj=getLine(cm.doc,pos.line));return intoCoordSystem(cm,lineObj,measureChar(cm,lineObj,pos.ch,bias),context)}function cursorCoords(cm,pos,context,lineObj,preparedMeasure,varHeight){function get(ch,right){var m=measureCharPrepared(cm,preparedMeasure,ch,right?"right":"left",varHeight);right?m.left=m.right:m.right=m.left;return intoCoordSystem(cm,lineObj,m,context)}function getBidi(ch,partPos){var part=order[partPos],right=part.level%2;if(ch==bidiLeft(part)&&partPos&&part.level<order[partPos-1].level){part=order[--partPos];ch=bidiRight(part)-(part.level%2?0:1);right=!0}else if(ch==bidiRight(part)&&partPos<order.length-1&&part.level<order[partPos+1].level){part=order[++partPos];ch=bidiLeft(part)-part.level%2;right=!1}return right&&ch==part.to&&ch>part.from?get(ch-1):get(ch,right)}lineObj=lineObj||getLine(cm.doc,pos.line);preparedMeasure||(preparedMeasure=prepareMeasureForLine(cm,lineObj));var order=getOrder(lineObj),ch=pos.ch;if(!order)return get(ch);var partPos=getBidiPartAt(order,ch),val=getBidi(ch,partPos);null!=bidiOther&&(val.other=getBidi(ch,bidiOther));return val}function estimateCoords(cm,pos){var left=0,pos=clipPos(cm.doc,pos);cm.options.lineWrapping||(left=charWidth(cm.display)*pos.ch);var lineObj=getLine(cm.doc,pos.line),top=heightAtLine(lineObj)+paddingTop(cm.display);return{left:left,right:left,top:top,bottom:top+lineObj.height}}function PosWithInfo(line,ch,outside,xRel){var pos=Pos(line,ch);pos.xRel=xRel;outside&&(pos.outside=!0);return pos}function coordsChar(cm,x,y){var doc=cm.doc;y+=cm.display.viewOffset;if(0>y)return PosWithInfo(doc.first,0,!0,-1);var lineN=lineAtHeight(doc,y),last=doc.first+doc.size-1;if(lineN>last)return PosWithInfo(doc.first+doc.size-1,getLine(doc,last).text.length,!0,1);0>x&&(x=0);for(var lineObj=getLine(doc,lineN);;){var found=coordsCharInner(cm,lineObj,lineN,x,y),merged=collapsedSpanAtEnd(lineObj),mergedPos=merged&&merged.find(0,!0);if(!merged||!(found.ch>mergedPos.from.ch||found.ch==mergedPos.from.ch&&found.xRel>0))return found;lineN=lineNo(lineObj=mergedPos.to.line)}}function coordsCharInner(cm,lineObj,lineNo,x,y){function getX(ch){var sp=cursorCoords(cm,Pos(lineNo,ch),"line",lineObj,preparedMeasure);wrongLine=!0;if(innerOff>sp.bottom)return sp.left-adjust;if(innerOff<sp.top)return sp.left+adjust;wrongLine=!1;return sp.left}var innerOff=y-heightAtLine(lineObj),wrongLine=!1,adjust=2*cm.display.wrapper.clientWidth,preparedMeasure=prepareMeasureForLine(cm,lineObj),bidi=getOrder(lineObj),dist=lineObj.text.length,from=lineLeft(lineObj),to=lineRight(lineObj),fromX=getX(from),fromOutside=wrongLine,toX=getX(to),toOutside=wrongLine;if(x>toX)return PosWithInfo(lineNo,to,toOutside,1);for(;;){if(bidi?to==from||to==moveVisually(lineObj,from,1):1>=to-from){for(var ch=fromX>x||toX-x>=x-fromX?from:to,xDiff=x-(ch==from?fromX:toX);isExtendingChar(lineObj.text.charAt(ch));)++ch;var pos=PosWithInfo(lineNo,ch,ch==from?fromOutside:toOutside,-1>xDiff?-1:xDiff>1?1:0);return pos}var step=Math.ceil(dist/2),middle=from+step;if(bidi){middle=from;for(var i=0;step>i;++i)middle=moveVisually(lineObj,middle,1)}var middleX=getX(middle);if(middleX>x){to=middle;toX=middleX;(toOutside=wrongLine)&&(toX+=1e3);dist=step}else{from=middle;fromX=middleX;fromOutside=wrongLine;dist-=step}}}function textHeight(display){if(null!=display.cachedTextHeight)return display.cachedTextHeight;if(null==measureText){measureText=elt("pre");for(var i=0;49>i;++i){measureText.appendChild(document.createTextNode("x"));measureText.appendChild(elt("br"))}measureText.appendChild(document.createTextNode("x"))}removeChildrenAndAdd(display.measure,measureText);var height=measureText.offsetHeight/50;height>3&&(display.cachedTextHeight=height);removeChildren(display.measure);return height||1}function charWidth(display){if(null!=display.cachedCharWidth)return display.cachedCharWidth;var anchor=elt("span","xxxxxxxxxx"),pre=elt("pre",[anchor]);removeChildrenAndAdd(display.measure,pre);var rect=anchor.getBoundingClientRect(),width=(rect.right-rect.left)/10;width>2&&(display.cachedCharWidth=width);return width||10}function startOperation(cm){cm.curOp={cm:cm,viewChanged:!1,startHeight:cm.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++nextOpId};operationGroup?operationGroup.ops.push(cm.curOp):cm.curOp.ownsGroup=operationGroup={ops:[cm.curOp],delayedCallbacks:[]}}function fireCallbacksForOps(group){var callbacks=group.delayedCallbacks,i=0;do{for(;i<callbacks.length;i++)callbacks[i].call(null);for(var j=0;j<group.ops.length;j++){var op=group.ops[j];if(op.cursorActivityHandlers)for(;op.cursorActivityCalled<op.cursorActivityHandlers.length;)op.cursorActivityHandlers[op.cursorActivityCalled++].call(null,op.cm)}}while(i<callbacks.length)}function endOperation(cm){var op=cm.curOp,group=op.ownsGroup;if(group)try{fireCallbacksForOps(group)}finally{operationGroup=null;for(var i=0;i<group.ops.length;i++)group.ops[i].cm.curOp=null;endOperations(group)}}function endOperations(group){for(var ops=group.ops,i=0;i<ops.length;i++)endOperation_R1(ops[i]);for(var i=0;i<ops.length;i++)endOperation_W1(ops[i]);for(var i=0;i<ops.length;i++)endOperation_R2(ops[i]);for(var i=0;i<ops.length;i++)endOperation_W2(ops[i]);for(var i=0;i<ops.length;i++)endOperation_finish(ops[i])}function endOperation_R1(op){var cm=op.cm,display=cm.display;maybeClipScrollbars(cm);op.updateMaxLine&&findMaxLine(cm);op.mustUpdate=op.viewChanged||op.forceUpdate||null!=op.scrollTop||op.scrollToPos&&(op.scrollToPos.from.line<display.viewFrom||op.scrollToPos.to.line>=display.viewTo)||display.maxLineChanged&&cm.options.lineWrapping;op.update=op.mustUpdate&&new DisplayUpdate(cm,op.mustUpdate&&{top:op.scrollTop,ensure:op.scrollToPos},op.forceUpdate)}function endOperation_W1(op){op.updatedDisplay=op.mustUpdate&&updateDisplayIfNeeded(op.cm,op.update)}function endOperation_R2(op){var cm=op.cm,display=cm.display;op.updatedDisplay&&updateHeightsInViewport(cm);op.barMeasure=measureForScrollbars(cm);if(display.maxLineChanged&&!cm.options.lineWrapping){op.adjustWidthTo=measureChar(cm,display.maxLine,display.maxLine.text.length).left+3;cm.display.sizerWidth=op.adjustWidthTo;op.barMeasure.scrollWidth=Math.max(display.scroller.clientWidth,display.sizer.offsetLeft+op.adjustWidthTo+scrollGap(cm)+cm.display.barWidth);op.maxScrollLeft=Math.max(0,display.sizer.offsetLeft+op.adjustWidthTo-displayWidth(cm))}(op.updatedDisplay||op.selectionChanged)&&(op.preparedSelection=display.input.prepareSelection())}function endOperation_W2(op){var cm=op.cm;if(null!=op.adjustWidthTo){cm.display.sizer.style.minWidth=op.adjustWidthTo+"px";op.maxScrollLeft<cm.doc.scrollLeft&&setScrollLeft(cm,Math.min(cm.display.scroller.scrollLeft,op.maxScrollLeft),!0);cm.display.maxLineChanged=!1}op.preparedSelection&&cm.display.input.showSelection(op.preparedSelection);(op.updatedDisplay||op.startHeight!=cm.doc.height)&&updateScrollbars(cm,op.barMeasure);op.updatedDisplay&&setDocumentHeight(cm,op.barMeasure);op.selectionChanged&&restartBlink(cm);cm.state.focused&&op.updateInput&&cm.display.input.reset(op.typing);!op.focus||op.focus!=activeElt()||document.hasFocus&&!document.hasFocus()||ensureFocus(op.cm)}function endOperation_finish(op){var cm=op.cm,display=cm.display,doc=cm.doc;op.updatedDisplay&&postUpdateDisplay(cm,op.update);null==display.wheelStartX||null==op.scrollTop&&null==op.scrollLeft&&!op.scrollToPos||(display.wheelStartX=display.wheelStartY=null);if(null!=op.scrollTop&&(display.scroller.scrollTop!=op.scrollTop||op.forceScroll)){doc.scrollTop=Math.max(0,Math.min(display.scroller.scrollHeight-display.scroller.clientHeight,op.scrollTop));display.scrollbars.setScrollTop(doc.scrollTop);display.scroller.scrollTop=doc.scrollTop}if(null!=op.scrollLeft&&(display.scroller.scrollLeft!=op.scrollLeft||op.forceScroll)){doc.scrollLeft=Math.max(0,Math.min(display.scroller.scrollWidth-display.scroller.clientWidth,op.scrollLeft));display.scrollbars.setScrollLeft(doc.scrollLeft);display.scroller.scrollLeft=doc.scrollLeft;alignHorizontally(cm)}if(op.scrollToPos){var coords=scrollPosIntoView(cm,clipPos(doc,op.scrollToPos.from),clipPos(doc,op.scrollToPos.to),op.scrollToPos.margin);op.scrollToPos.isCursor&&cm.state.focused&&maybeScrollWindow(cm,coords)}var hidden=op.maybeHiddenMarkers,unhidden=op.maybeUnhiddenMarkers;if(hidden)for(var i=0;i<hidden.length;++i)hidden[i].lines.length||signal(hidden[i],"hide");if(unhidden)for(var i=0;i<unhidden.length;++i)unhidden[i].lines.length&&signal(unhidden[i],"unhide");display.wrapper.offsetHeight&&(doc.scrollTop=cm.display.scroller.scrollTop);op.changeObjs&&signal(cm,"changes",cm,op.changeObjs);op.update&&op.update.finish()}function runInOp(cm,f){if(cm.curOp)return f();startOperation(cm);try{return f()}finally{endOperation(cm)}}function operation(cm,f){return function(){if(cm.curOp)return f.apply(cm,arguments);startOperation(cm);try{return f.apply(cm,arguments)}finally{endOperation(cm)}}}function methodOp(f){return function(){if(this.curOp)return f.apply(this,arguments);startOperation(this);try{return f.apply(this,arguments)}finally{endOperation(this)}}}function docMethodOp(f){return function(){var cm=this.cm;if(!cm||cm.curOp)return f.apply(this,arguments);startOperation(cm);try{return f.apply(this,arguments)}finally{endOperation(cm)}}}function LineView(doc,line,lineN){this.line=line;this.rest=visualLineContinued(line);this.size=this.rest?lineNo(lst(this.rest))-lineN+1:1;this.node=this.text=null;this.hidden=lineIsHidden(doc,line)}function buildViewArray(cm,from,to){for(var nextPos,array=[],pos=from;to>pos;pos=nextPos){var view=new LineView(cm.doc,getLine(cm.doc,pos),pos);nextPos=pos+view.size;array.push(view)}return array}function regChange(cm,from,to,lendiff){null==from&&(from=cm.doc.first);null==to&&(to=cm.doc.first+cm.doc.size);lendiff||(lendiff=0);var display=cm.display;lendiff&&to<display.viewTo&&(null==display.updateLineNumbers||display.updateLineNumbers>from)&&(display.updateLineNumbers=from);cm.curOp.viewChanged=!0;if(from>=display.viewTo)sawCollapsedSpans&&visualLineNo(cm.doc,from)<display.viewTo&&resetView(cm);else if(to<=display.viewFrom)if(sawCollapsedSpans&&visualLineEndNo(cm.doc,to+lendiff)>display.viewFrom)resetView(cm);else{display.viewFrom+=lendiff;display.viewTo+=lendiff}else if(from<=display.viewFrom&&to>=display.viewTo)resetView(cm);else if(from<=display.viewFrom){var cut=viewCuttingPoint(cm,to,to+lendiff,1);if(cut){display.view=display.view.slice(cut.index);display.viewFrom=cut.lineN;display.viewTo+=lendiff}else resetView(cm)}else if(to>=display.viewTo){var cut=viewCuttingPoint(cm,from,from,-1);if(cut){display.view=display.view.slice(0,cut.index);display.viewTo=cut.lineN}else resetView(cm)}else{var cutTop=viewCuttingPoint(cm,from,from,-1),cutBot=viewCuttingPoint(cm,to,to+lendiff,1);if(cutTop&&cutBot){display.view=display.view.slice(0,cutTop.index).concat(buildViewArray(cm,cutTop.lineN,cutBot.lineN)).concat(display.view.slice(cutBot.index));display.viewTo+=lendiff}else resetView(cm)}var ext=display.externalMeasured;ext&&(to<ext.lineN?ext.lineN+=lendiff:from<ext.lineN+ext.size&&(display.externalMeasured=null))}function regLineChange(cm,line,type){cm.curOp.viewChanged=!0;var display=cm.display,ext=cm.display.externalMeasured;ext&&line>=ext.lineN&&line<ext.lineN+ext.size&&(display.externalMeasured=null);if(!(line<display.viewFrom||line>=display.viewTo)){var lineView=display.view[findViewIndex(cm,line)];if(null!=lineView.node){var arr=lineView.changes||(lineView.changes=[]);-1==indexOf(arr,type)&&arr.push(type)}}}function resetView(cm){cm.display.viewFrom=cm.display.viewTo=cm.doc.first;cm.display.view=[];cm.display.viewOffset=0}function findViewIndex(cm,n){if(n>=cm.display.viewTo)return null;n-=cm.display.viewFrom;if(0>n)return null;for(var view=cm.display.view,i=0;i<view.length;i++){n-=view[i].size;if(0>n)return i}}function viewCuttingPoint(cm,oldN,newN,dir){var diff,index=findViewIndex(cm,oldN),view=cm.display.view;if(!sawCollapsedSpans||newN==cm.doc.first+cm.doc.size)return{index:index,lineN:newN};for(var i=0,n=cm.display.viewFrom;index>i;i++)n+=view[i].size;if(n!=oldN){if(dir>0){if(index==view.length-1)return null;diff=n+view[index].size-oldN;index++}else diff=n-oldN;oldN+=diff;
3
+ newN+=diff}for(;visualLineNo(cm.doc,newN)!=newN;){if(index==(0>dir?0:view.length-1))return null;newN+=dir*view[index-(0>dir?1:0)].size;index+=dir}return{index:index,lineN:newN}}function adjustView(cm,from,to){var display=cm.display,view=display.view;if(0==view.length||from>=display.viewTo||to<=display.viewFrom){display.view=buildViewArray(cm,from,to);display.viewFrom=from}else{display.viewFrom>from?display.view=buildViewArray(cm,from,display.viewFrom).concat(display.view):display.viewFrom<from&&(display.view=display.view.slice(findViewIndex(cm,from)));display.viewFrom=from;display.viewTo<to?display.view=display.view.concat(buildViewArray(cm,display.viewTo,to)):display.viewTo>to&&(display.view=display.view.slice(0,findViewIndex(cm,to)))}display.viewTo=to}function countDirtyView(cm){for(var view=cm.display.view,dirty=0,i=0;i<view.length;i++){var lineView=view[i];lineView.hidden||lineView.node&&!lineView.changes||++dirty}return dirty}function registerEventHandlers(cm){function finishTouch(){if(d.activeTouch){touchFinished=setTimeout(function(){d.activeTouch=null},1e3);prevTouch=d.activeTouch;prevTouch.end=+new Date}}function isMouseLikeTouchEvent(e){if(1!=e.touches.length)return!1;var touch=e.touches[0];return touch.radiusX<=1&&touch.radiusY<=1}function farAway(touch,other){if(null==other.left)return!0;var dx=other.left-touch.left,dy=other.top-touch.top;return dx*dx+dy*dy>400}var d=cm.display;on(d.scroller,"mousedown",operation(cm,onMouseDown));ie&&11>ie_version?on(d.scroller,"dblclick",operation(cm,function(e){if(!signalDOMEvent(cm,e)){var pos=posFromMouse(cm,e);if(pos&&!clickInGutter(cm,e)&&!eventInWidget(cm.display,e)){e_preventDefault(e);var word=cm.findWordAt(pos);extendSelection(cm.doc,word.anchor,word.head)}}})):on(d.scroller,"dblclick",function(e){signalDOMEvent(cm,e)||e_preventDefault(e)});captureRightClick||on(d.scroller,"contextmenu",function(e){onContextMenu(cm,e)});var touchFinished,prevTouch={end:0};on(d.scroller,"touchstart",function(e){if(!signalDOMEvent(cm,e)&&!isMouseLikeTouchEvent(e)){clearTimeout(touchFinished);var now=+new Date;d.activeTouch={start:now,moved:!1,prev:now-prevTouch.end<=300?prevTouch:null};if(1==e.touches.length){d.activeTouch.left=e.touches[0].pageX;d.activeTouch.top=e.touches[0].pageY}}});on(d.scroller,"touchmove",function(){d.activeTouch&&(d.activeTouch.moved=!0)});on(d.scroller,"touchend",function(e){var touch=d.activeTouch;if(touch&&!eventInWidget(d,e)&&null!=touch.left&&!touch.moved&&new Date-touch.start<300){var range,pos=cm.coordsChar(d.activeTouch,"page");range=!touch.prev||farAway(touch,touch.prev)?new Range(pos,pos):!touch.prev.prev||farAway(touch,touch.prev.prev)?cm.findWordAt(pos):new Range(Pos(pos.line,0),clipPos(cm.doc,Pos(pos.line+1,0)));cm.setSelection(range.anchor,range.head);cm.focus();e_preventDefault(e)}finishTouch()});on(d.scroller,"touchcancel",finishTouch);on(d.scroller,"scroll",function(){if(d.scroller.clientHeight){setScrollTop(cm,d.scroller.scrollTop);setScrollLeft(cm,d.scroller.scrollLeft,!0);signal(cm,"scroll",cm)}});on(d.scroller,"mousewheel",function(e){onScrollWheel(cm,e)});on(d.scroller,"DOMMouseScroll",function(e){onScrollWheel(cm,e)});on(d.wrapper,"scroll",function(){d.wrapper.scrollTop=d.wrapper.scrollLeft=0});d.dragFunctions={enter:function(e){signalDOMEvent(cm,e)||e_stop(e)},over:function(e){if(!signalDOMEvent(cm,e)){onDragOver(cm,e);e_stop(e)}},start:function(e){onDragStart(cm,e)},drop:operation(cm,onDrop),leave:function(e){signalDOMEvent(cm,e)||clearDragCursor(cm)}};var inp=d.input.getField();on(inp,"keyup",function(e){onKeyUp.call(cm,e)});on(inp,"keydown",operation(cm,onKeyDown));on(inp,"keypress",operation(cm,onKeyPress));on(inp,"focus",bind(onFocus,cm));on(inp,"blur",bind(onBlur,cm))}function dragDropChanged(cm,value,old){var wasOn=old&&old!=CodeMirror.Init;if(!value!=!wasOn){var funcs=cm.display.dragFunctions,toggle=value?on:off;toggle(cm.display.scroller,"dragstart",funcs.start);toggle(cm.display.scroller,"dragenter",funcs.enter);toggle(cm.display.scroller,"dragover",funcs.over);toggle(cm.display.scroller,"dragleave",funcs.leave);toggle(cm.display.scroller,"drop",funcs.drop)}}function onResize(cm){var d=cm.display;if(d.lastWrapHeight!=d.wrapper.clientHeight||d.lastWrapWidth!=d.wrapper.clientWidth){d.cachedCharWidth=d.cachedTextHeight=d.cachedPaddingH=null;d.scrollbarsClipped=!1;cm.setSize()}}function eventInWidget(display,e){for(var n=e_target(e);n!=display.wrapper;n=n.parentNode)if(!n||1==n.nodeType&&"true"==n.getAttribute("cm-ignore-events")||n.parentNode==display.sizer&&n!=display.mover)return!0}function posFromMouse(cm,e,liberal,forRect){var display=cm.display;if(!liberal&&"true"==e_target(e).getAttribute("cm-not-content"))return null;var x,y,space=display.lineSpace.getBoundingClientRect();try{x=e.clientX-space.left;y=e.clientY-space.top}catch(e){return null}var line,coords=coordsChar(cm,x,y);if(forRect&&1==coords.xRel&&(line=getLine(cm.doc,coords.line).text).length==coords.ch){var colDiff=countColumn(line,line.length,cm.options.tabSize)-line.length;coords=Pos(coords.line,Math.max(0,Math.round((x-paddingH(cm.display).left)/charWidth(cm.display))-colDiff))}return coords}function onMouseDown(e){var cm=this,display=cm.display;if(!(signalDOMEvent(cm,e)||display.activeTouch&&display.input.supportsTouch())){display.shift=e.shiftKey;if(eventInWidget(display,e)){if(!webkit){display.scroller.draggable=!1;setTimeout(function(){display.scroller.draggable=!0},100)}}else if(!clickInGutter(cm,e)){var start=posFromMouse(cm,e);window.focus();switch(e_button(e)){case 1:cm.state.selectingText?cm.state.selectingText(e):start?leftButtonDown(cm,e,start):e_target(e)==display.scroller&&e_preventDefault(e);break;case 2:webkit&&(cm.state.lastMiddleDown=+new Date);start&&extendSelection(cm.doc,start);setTimeout(function(){display.input.focus()},20);e_preventDefault(e);break;case 3:captureRightClick?onContextMenu(cm,e):delayBlurEvent(cm)}}}}function leftButtonDown(cm,e,start){ie?setTimeout(bind(ensureFocus,cm),0):cm.curOp.focus=activeElt();var type,now=+new Date;if(lastDoubleClick&&lastDoubleClick.time>now-400&&0==cmp(lastDoubleClick.pos,start))type="triple";else if(lastClick&&lastClick.time>now-400&&0==cmp(lastClick.pos,start)){type="double";lastDoubleClick={time:now,pos:start}}else{type="single";lastClick={time:now,pos:start}}var contained,sel=cm.doc.sel,modifier=mac?e.metaKey:e.ctrlKey;cm.options.dragDrop&&dragAndDrop&&!cm.isReadOnly()&&"single"==type&&(contained=sel.contains(start))>-1&&(cmp((contained=sel.ranges[contained]).from(),start)<0||start.xRel>0)&&(cmp(contained.to(),start)>0||start.xRel<0)?leftButtonStartDrag(cm,e,start,modifier):leftButtonSelect(cm,e,start,type,modifier)}function leftButtonStartDrag(cm,e,start,modifier){var display=cm.display,startTime=+new Date,dragEnd=operation(cm,function(e2){webkit&&(display.scroller.draggable=!1);cm.state.draggingText=!1;off(document,"mouseup",dragEnd);off(display.scroller,"drop",dragEnd);if(Math.abs(e.clientX-e2.clientX)+Math.abs(e.clientY-e2.clientY)<10){e_preventDefault(e2);!modifier&&+new Date-200<startTime&&extendSelection(cm.doc,start);webkit||ie&&9==ie_version?setTimeout(function(){document.body.focus();display.input.focus()},20):display.input.focus()}});webkit&&(display.scroller.draggable=!0);cm.state.draggingText=dragEnd;display.scroller.dragDrop&&display.scroller.dragDrop();on(document,"mouseup",dragEnd);on(display.scroller,"drop",dragEnd)}function leftButtonSelect(cm,e,start,type,addNew){function extendTo(pos){if(0!=cmp(lastPos,pos)){lastPos=pos;if("rect"==type){for(var ranges=[],tabSize=cm.options.tabSize,startCol=countColumn(getLine(doc,start.line).text,start.ch,tabSize),posCol=countColumn(getLine(doc,pos.line).text,pos.ch,tabSize),left=Math.min(startCol,posCol),right=Math.max(startCol,posCol),line=Math.min(start.line,pos.line),end=Math.min(cm.lastLine(),Math.max(start.line,pos.line));end>=line;line++){var text=getLine(doc,line).text,leftPos=findColumn(text,left,tabSize);left==right?ranges.push(new Range(Pos(line,leftPos),Pos(line,leftPos))):text.length>leftPos&&ranges.push(new Range(Pos(line,leftPos),Pos(line,findColumn(text,right,tabSize))))}ranges.length||ranges.push(new Range(start,start));setSelection(doc,normalizeSelection(startSel.ranges.slice(0,ourIndex).concat(ranges),ourIndex),{origin:"*mouse",scroll:!1});cm.scrollIntoView(pos)}else{var oldRange=ourRange,anchor=oldRange.anchor,head=pos;if("single"!=type){if("double"==type)var range=cm.findWordAt(pos);else var range=new Range(Pos(pos.line,0),clipPos(doc,Pos(pos.line+1,0)));if(cmp(range.anchor,anchor)>0){head=range.head;anchor=minPos(oldRange.from(),range.anchor)}else{head=range.anchor;anchor=maxPos(oldRange.to(),range.head)}}var ranges=startSel.ranges.slice(0);ranges[ourIndex]=new Range(clipPos(doc,anchor),head);setSelection(doc,normalizeSelection(ranges,ourIndex),sel_mouse)}}}function extend(e){var curCount=++counter,cur=posFromMouse(cm,e,!0,"rect"==type);if(cur)if(0!=cmp(cur,lastPos)){cm.curOp.focus=activeElt();extendTo(cur);var visible=visibleLines(display,doc);(cur.line>=visible.to||cur.line<visible.from)&&setTimeout(operation(cm,function(){counter==curCount&&extend(e)}),150)}else{var outside=e.clientY<editorSize.top?-20:e.clientY>editorSize.bottom?20:0;outside&&setTimeout(operation(cm,function(){if(counter==curCount){display.scroller.scrollTop+=outside;extend(e)}}),50)}}function done(e){cm.state.selectingText=!1;counter=1/0;e_preventDefault(e);display.input.focus();off(document,"mousemove",move);off(document,"mouseup",up);doc.history.lastSelOrigin=null}var display=cm.display,doc=cm.doc;e_preventDefault(e);var ourRange,ourIndex,startSel=doc.sel,ranges=startSel.ranges;if(addNew&&!e.shiftKey){ourIndex=doc.sel.contains(start);ourRange=ourIndex>-1?ranges[ourIndex]:new Range(start,start)}else{ourRange=doc.sel.primary();ourIndex=doc.sel.primIndex}if(chromeOS?e.shiftKey&&e.metaKey:e.altKey){type="rect";addNew||(ourRange=new Range(start,start));start=posFromMouse(cm,e,!0,!0);ourIndex=-1}else if("double"==type){var word=cm.findWordAt(start);ourRange=cm.display.shift||doc.extend?extendRange(doc,ourRange,word.anchor,word.head):word}else if("triple"==type){var line=new Range(Pos(start.line,0),clipPos(doc,Pos(start.line+1,0)));ourRange=cm.display.shift||doc.extend?extendRange(doc,ourRange,line.anchor,line.head):line}else ourRange=extendRange(doc,ourRange,start);if(addNew)if(-1==ourIndex){ourIndex=ranges.length;setSelection(doc,normalizeSelection(ranges.concat([ourRange]),ourIndex),{scroll:!1,origin:"*mouse"})}else if(ranges.length>1&&ranges[ourIndex].empty()&&"single"==type&&!e.shiftKey){setSelection(doc,normalizeSelection(ranges.slice(0,ourIndex).concat(ranges.slice(ourIndex+1)),0),{scroll:!1,origin:"*mouse"});startSel=doc.sel}else replaceOneSelection(doc,ourIndex,ourRange,sel_mouse);else{ourIndex=0;setSelection(doc,new Selection([ourRange],0),sel_mouse);startSel=doc.sel}var lastPos=start,editorSize=display.wrapper.getBoundingClientRect(),counter=0,move=operation(cm,function(e){e_button(e)?extend(e):done(e)}),up=operation(cm,done);cm.state.selectingText=up;on(document,"mousemove",move);on(document,"mouseup",up)}function gutterEvent(cm,e,type,prevent){try{var mX=e.clientX,mY=e.clientY}catch(e){return!1}if(mX>=Math.floor(cm.display.gutters.getBoundingClientRect().right))return!1;prevent&&e_preventDefault(e);var display=cm.display,lineBox=display.lineDiv.getBoundingClientRect();if(mY>lineBox.bottom||!hasHandler(cm,type))return e_defaultPrevented(e);mY-=lineBox.top-display.viewOffset;for(var i=0;i<cm.options.gutters.length;++i){var g=display.gutters.childNodes[i];if(g&&g.getBoundingClientRect().right>=mX){var line=lineAtHeight(cm.doc,mY),gutter=cm.options.gutters[i];signal(cm,type,cm,line,gutter,e);return e_defaultPrevented(e)}}}function clickInGutter(cm,e){return gutterEvent(cm,e,"gutterClick",!0)}function onDrop(e){var cm=this;clearDragCursor(cm);if(!signalDOMEvent(cm,e)&&!eventInWidget(cm.display,e)){e_preventDefault(e);ie&&(lastDrop=+new Date);var pos=posFromMouse(cm,e,!0),files=e.dataTransfer.files;if(pos&&!cm.isReadOnly())if(files&&files.length&&window.FileReader&&window.File)for(var n=files.length,text=Array(n),read=0,loadFile=function(file,i){if(!cm.options.allowDropFileTypes||-1!=indexOf(cm.options.allowDropFileTypes,file.type)){var reader=new FileReader;reader.onload=operation(cm,function(){var content=reader.result;/[\x00-\x08\x0e-\x1f]{2}/.test(content)&&(content="");text[i]=content;if(++read==n){pos=clipPos(cm.doc,pos);var change={from:pos,to:pos,text:cm.doc.splitLines(text.join(cm.doc.lineSeparator())),origin:"paste"};makeChange(cm.doc,change);setSelectionReplaceHistory(cm.doc,simpleSelection(pos,changeEnd(change)))}});reader.readAsText(file)}},i=0;n>i;++i)loadFile(files[i],i);else{if(cm.state.draggingText&&cm.doc.sel.contains(pos)>-1){cm.state.draggingText(e);setTimeout(function(){cm.display.input.focus()},20);return}try{var text=e.dataTransfer.getData("Text");if(text){if(cm.state.draggingText&&!(mac?e.altKey:e.ctrlKey))var selected=cm.listSelections();setSelectionNoUndo(cm.doc,simpleSelection(pos,pos));if(selected)for(var i=0;i<selected.length;++i)replaceRange(cm.doc,"",selected[i].anchor,selected[i].head,"drag");cm.replaceSelection(text,"around","paste");cm.display.input.focus()}}catch(e){}}}}function onDragStart(cm,e){if(ie&&(!cm.state.draggingText||+new Date-lastDrop<100))e_stop(e);else if(!signalDOMEvent(cm,e)&&!eventInWidget(cm.display,e)){e.dataTransfer.setData("Text",cm.getSelection());e.dataTransfer.effectAllowed="copyMove";if(e.dataTransfer.setDragImage&&!safari){var img=elt("img",null,null,"position: fixed; left: 0; top: 0;");img.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";if(presto){img.width=img.height=1;cm.display.wrapper.appendChild(img);img._top=img.offsetTop}e.dataTransfer.setDragImage(img,0,0);presto&&img.parentNode.removeChild(img)}}}function onDragOver(cm,e){var pos=posFromMouse(cm,e);if(pos){var frag=document.createDocumentFragment();drawSelectionCursor(cm,pos,frag);if(!cm.display.dragCursor){cm.display.dragCursor=elt("div",null,"CodeMirror-cursors CodeMirror-dragcursors");cm.display.lineSpace.insertBefore(cm.display.dragCursor,cm.display.cursorDiv)}removeChildrenAndAdd(cm.display.dragCursor,frag)}}function clearDragCursor(cm){if(cm.display.dragCursor){cm.display.lineSpace.removeChild(cm.display.dragCursor);cm.display.dragCursor=null}}function setScrollTop(cm,val){if(!(Math.abs(cm.doc.scrollTop-val)<2)){cm.doc.scrollTop=val;gecko||updateDisplaySimple(cm,{top:val});cm.display.scroller.scrollTop!=val&&(cm.display.scroller.scrollTop=val);cm.display.scrollbars.setScrollTop(val);gecko&&updateDisplaySimple(cm);startWorker(cm,100)}}function setScrollLeft(cm,val,isScroller){if(!(isScroller?val==cm.doc.scrollLeft:Math.abs(cm.doc.scrollLeft-val)<2)){val=Math.min(val,cm.display.scroller.scrollWidth-cm.display.scroller.clientWidth);cm.doc.scrollLeft=val;alignHorizontally(cm);cm.display.scroller.scrollLeft!=val&&(cm.display.scroller.scrollLeft=val);cm.display.scrollbars.setScrollLeft(val)}}function onScrollWheel(cm,e){var delta=wheelEventDelta(e),dx=delta.x,dy=delta.y,display=cm.display,scroll=display.scroller,canScrollX=scroll.scrollWidth>scroll.clientWidth,canScrollY=scroll.scrollHeight>scroll.clientHeight;if(dx&&canScrollX||dy&&canScrollY){if(dy&&mac&&webkit)outer:for(var cur=e.target,view=display.view;cur!=scroll;cur=cur.parentNode)for(var i=0;i<view.length;i++)if(view[i].node==cur){cm.display.currentWheelTarget=cur;break outer}if(!dx||gecko||presto||null==wheelPixelsPerUnit){if(dy&&null!=wheelPixelsPerUnit){var pixels=dy*wheelPixelsPerUnit,top=cm.doc.scrollTop,bot=top+display.wrapper.clientHeight;0>pixels?top=Math.max(0,top+pixels-50):bot=Math.min(cm.doc.height,bot+pixels+50);updateDisplaySimple(cm,{top:top,bottom:bot})}if(20>wheelSamples)if(null==display.wheelStartX){display.wheelStartX=scroll.scrollLeft;display.wheelStartY=scroll.scrollTop;display.wheelDX=dx;display.wheelDY=dy;setTimeout(function(){if(null!=display.wheelStartX){var movedX=scroll.scrollLeft-display.wheelStartX,movedY=scroll.scrollTop-display.wheelStartY,sample=movedY&&display.wheelDY&&movedY/display.wheelDY||movedX&&display.wheelDX&&movedX/display.wheelDX;display.wheelStartX=display.wheelStartY=null;if(sample){wheelPixelsPerUnit=(wheelPixelsPerUnit*wheelSamples+sample)/(wheelSamples+1);++wheelSamples}}},200)}else{display.wheelDX+=dx;display.wheelDY+=dy}}else{dy&&canScrollY&&setScrollTop(cm,Math.max(0,Math.min(scroll.scrollTop+dy*wheelPixelsPerUnit,scroll.scrollHeight-scroll.clientHeight)));setScrollLeft(cm,Math.max(0,Math.min(scroll.scrollLeft+dx*wheelPixelsPerUnit,scroll.scrollWidth-scroll.clientWidth)));(!dy||dy&&canScrollY)&&e_preventDefault(e);display.wheelStartX=null}}}function doHandleBinding(cm,bound,dropShift){if("string"==typeof bound){bound=commands[bound];if(!bound)return!1}cm.display.input.ensurePolled();var prevShift=cm.display.shift,done=!1;try{cm.isReadOnly()&&(cm.state.suppressEdits=!0);dropShift&&(cm.display.shift=!1);done=bound(cm)!=Pass}finally{cm.display.shift=prevShift;cm.state.suppressEdits=!1}return done}function lookupKeyForEditor(cm,name,handle){for(var i=0;i<cm.state.keyMaps.length;i++){var result=lookupKey(name,cm.state.keyMaps[i],handle,cm);if(result)return result}return cm.options.extraKeys&&lookupKey(name,cm.options.extraKeys,handle,cm)||lookupKey(name,cm.options.keyMap,handle,cm)}function dispatchKey(cm,name,e,handle){var seq=cm.state.keySeq;if(seq){if(isModifierKey(name))return"handled";stopSeq.set(50,function(){if(cm.state.keySeq==seq){cm.state.keySeq=null;cm.display.input.reset()}});name=seq+" "+name}var result=lookupKeyForEditor(cm,name,handle);"multi"==result&&(cm.state.keySeq=name);"handled"==result&&signalLater(cm,"keyHandled",cm,name,e);if("handled"==result||"multi"==result){e_preventDefault(e);restartBlink(cm)}if(seq&&!result&&/\'$/.test(name)){e_preventDefault(e);return!0}return!!result}function handleKeyBinding(cm,e){var name=keyName(e,!0);return name?e.shiftKey&&!cm.state.keySeq?dispatchKey(cm,"Shift-"+name,e,function(b){return doHandleBinding(cm,b,!0)})||dispatchKey(cm,name,e,function(b){return("string"==typeof b?/^go[A-Z]/.test(b):b.motion)?doHandleBinding(cm,b):void 0}):dispatchKey(cm,name,e,function(b){return doHandleBinding(cm,b)}):!1}function handleCharBinding(cm,e,ch){return dispatchKey(cm,"'"+ch+"'",e,function(b){return doHandleBinding(cm,b,!0)})}function onKeyDown(e){var cm=this;cm.curOp.focus=activeElt();if(!signalDOMEvent(cm,e)){ie&&11>ie_version&&27==e.keyCode&&(e.returnValue=!1);var code=e.keyCode;cm.display.shift=16==code||e.shiftKey;var handled=handleKeyBinding(cm,e);if(presto){lastStoppedKey=handled?code:null;!handled&&88==code&&!hasCopyEvent&&(mac?e.metaKey:e.ctrlKey)&&cm.replaceSelection("",null,"cut")}18!=code||/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className)||showCrossHair(cm)}}function showCrossHair(cm){function up(e){if(18==e.keyCode||!e.altKey){rmClass(lineDiv,"CodeMirror-crosshair");off(document,"keyup",up);off(document,"mouseover",up)}}var lineDiv=cm.display.lineDiv;addClass(lineDiv,"CodeMirror-crosshair");on(document,"keyup",up);on(document,"mouseover",up)}function onKeyUp(e){16==e.keyCode&&(this.doc.sel.shift=!1);signalDOMEvent(this,e)}function onKeyPress(e){var cm=this;if(!(eventInWidget(cm.display,e)||signalDOMEvent(cm,e)||e.ctrlKey&&!e.altKey||mac&&e.metaKey)){var keyCode=e.keyCode,charCode=e.charCode;if(presto&&keyCode==lastStoppedKey){lastStoppedKey=null;e_preventDefault(e)}else if(!presto||e.which&&!(e.which<10)||!handleKeyBinding(cm,e)){var ch=String.fromCharCode(null==charCode?keyCode:charCode);handleCharBinding(cm,e,ch)||cm.display.input.onKeyPress(e)}}}function delayBlurEvent(cm){cm.state.delayingBlurEvent=!0;setTimeout(function(){if(cm.state.delayingBlurEvent){cm.state.delayingBlurEvent=!1;onBlur(cm)}},100)}function onFocus(cm){cm.state.delayingBlurEvent&&(cm.state.delayingBlurEvent=!1);if("nocursor"!=cm.options.readOnly){if(!cm.state.focused){signal(cm,"focus",cm);cm.state.focused=!0;addClass(cm.display.wrapper,"CodeMirror-focused");if(!cm.curOp&&cm.display.selForContextMenu!=cm.doc.sel){cm.display.input.reset();webkit&&setTimeout(function(){cm.display.input.reset(!0)},20)}cm.display.input.receivedFocus()}restartBlink(cm)}}function onBlur(cm){if(!cm.state.delayingBlurEvent){if(cm.state.focused){signal(cm,"blur",cm);cm.state.focused=!1;rmClass(cm.display.wrapper,"CodeMirror-focused")}clearInterval(cm.display.blinker);setTimeout(function(){cm.state.focused||(cm.display.shift=!1)},150)}}function onContextMenu(cm,e){eventInWidget(cm.display,e)||contextMenuInGutter(cm,e)||signalDOMEvent(cm,e,"contextmenu")||cm.display.input.onContextMenu(e)}function contextMenuInGutter(cm,e){return hasHandler(cm,"gutterContextMenu")?gutterEvent(cm,e,"gutterContextMenu",!1):!1}function adjustForChange(pos,change){if(cmp(pos,change.from)<0)return pos;if(cmp(pos,change.to)<=0)return changeEnd(change);var line=pos.line+change.text.length-(change.to.line-change.from.line)-1,ch=pos.ch;pos.line==change.to.line&&(ch+=changeEnd(change).ch-change.to.ch);return Pos(line,ch)}function computeSelAfterChange(doc,change){for(var out=[],i=0;i<doc.sel.ranges.length;i++){var range=doc.sel.ranges[i];out.push(new Range(adjustForChange(range.anchor,change),adjustForChange(range.head,change)))}return normalizeSelection(out,doc.sel.primIndex)}function offsetPos(pos,old,nw){return pos.line==old.line?Pos(nw.line,pos.ch-old.ch+nw.ch):Pos(nw.line+(pos.line-old.line),pos.ch)}function computeReplacedSel(doc,changes,hint){for(var out=[],oldPrev=Pos(doc.first,0),newPrev=oldPrev,i=0;i<changes.length;i++){var change=changes[i],from=offsetPos(change.from,oldPrev,newPrev),to=offsetPos(changeEnd(change),oldPrev,newPrev);oldPrev=change.to;newPrev=to;if("around"==hint){var range=doc.sel.ranges[i],inv=cmp(range.head,range.anchor)<0;out[i]=new Range(inv?to:from,inv?from:to)}else out[i]=new Range(from,from)}return new Selection(out,doc.sel.primIndex)}function filterChange(doc,change,update){var obj={canceled:!1,from:change.from,to:change.to,text:change.text,origin:change.origin,cancel:function(){this.canceled=!0}};update&&(obj.update=function(from,to,text,origin){from&&(this.from=clipPos(doc,from));to&&(this.to=clipPos(doc,to));text&&(this.text=text);void 0!==origin&&(this.origin=origin)});signal(doc,"beforeChange",doc,obj);doc.cm&&signal(doc.cm,"beforeChange",doc.cm,obj);return obj.canceled?null:{from:obj.from,to:obj.to,text:obj.text,origin:obj.origin}}function makeChange(doc,change,ignoreReadOnly){if(doc.cm){if(!doc.cm.curOp)return operation(doc.cm,makeChange)(doc,change,ignoreReadOnly);if(doc.cm.state.suppressEdits)return}if(hasHandler(doc,"beforeChange")||doc.cm&&hasHandler(doc.cm,"beforeChange")){change=filterChange(doc,change,!0);if(!change)return}var split=sawReadOnlySpans&&!ignoreReadOnly&&removeReadOnlyRanges(doc,change.from,change.to);if(split)for(var i=split.length-1;i>=0;--i)makeChangeInner(doc,{from:split[i].from,to:split[i].to,text:i?[""]:change.text});else makeChangeInner(doc,change)}function makeChangeInner(doc,change){if(1!=change.text.length||""!=change.text[0]||0!=cmp(change.from,change.to)){var selAfter=computeSelAfterChange(doc,change);addChangeToHistory(doc,change,selAfter,doc.cm?doc.cm.curOp.id:NaN);makeChangeSingleDoc(doc,change,selAfter,stretchSpansOverChange(doc,change));var rebased=[];linkedDocs(doc,function(doc,sharedHist){if(!sharedHist&&-1==indexOf(rebased,doc.history)){rebaseHist(doc.history,change);rebased.push(doc.history)}makeChangeSingleDoc(doc,change,null,stretchSpansOverChange(doc,change))})}}function makeChangeFromHistory(doc,type,allowSelectionOnly){if(!doc.cm||!doc.cm.state.suppressEdits){for(var event,hist=doc.history,selAfter=doc.sel,source="undo"==type?hist.done:hist.undone,dest="undo"==type?hist.undone:hist.done,i=0;i<source.length;i++){event=source[i];if(allowSelectionOnly?event.ranges&&!event.equals(doc.sel):!event.ranges)break}if(i!=source.length){hist.lastOrigin=hist.lastSelOrigin=null;for(;;){event=source.pop();if(!event.ranges)break;pushSelectionToHistory(event,dest);if(allowSelectionOnly&&!event.equals(doc.sel)){setSelection(doc,event,{clearRedo:!1});return}selAfter=event}var antiChanges=[];pushSelectionToHistory(selAfter,dest);dest.push({changes:antiChanges,generation:hist.generation});hist.generation=event.generation||++hist.maxGeneration;for(var filter=hasHandler(doc,"beforeChange")||doc.cm&&hasHandler(doc.cm,"beforeChange"),i=event.changes.length-1;i>=0;--i){var change=event.changes[i];change.origin=type;if(filter&&!filterChange(doc,change,!1)){source.length=0;return}antiChanges.push(historyChangeFromChange(doc,change));var after=i?computeSelAfterChange(doc,change):lst(source);makeChangeSingleDoc(doc,change,after,mergeOldSpans(doc,change));!i&&doc.cm&&doc.cm.scrollIntoView({from:change.from,to:changeEnd(change)});var rebased=[];linkedDocs(doc,function(doc,sharedHist){if(!sharedHist&&-1==indexOf(rebased,doc.history)){rebaseHist(doc.history,change);rebased.push(doc.history)}makeChangeSingleDoc(doc,change,null,mergeOldSpans(doc,change))})}}}}function shiftDoc(doc,distance){if(0!=distance){doc.first+=distance;doc.sel=new Selection(map(doc.sel.ranges,function(range){return new Range(Pos(range.anchor.line+distance,range.anchor.ch),Pos(range.head.line+distance,range.head.ch))}),doc.sel.primIndex);if(doc.cm){regChange(doc.cm,doc.first,doc.first-distance,distance);for(var d=doc.cm.display,l=d.viewFrom;l<d.viewTo;l++)regLineChange(doc.cm,l,"gutter")}}}function makeChangeSingleDoc(doc,change,selAfter,spans){if(doc.cm&&!doc.cm.curOp)return operation(doc.cm,makeChangeSingleDoc)(doc,change,selAfter,spans);if(change.to.line<doc.first)shiftDoc(doc,change.text.length-1-(change.to.line-change.from.line));else if(!(change.from.line>doc.lastLine())){if(change.from.line<doc.first){var shift=change.text.length-1-(doc.first-change.from.line);shiftDoc(doc,shift);change={from:Pos(doc.first,0),to:Pos(change.to.line+shift,change.to.ch),text:[lst(change.text)],origin:change.origin}}var last=doc.lastLine();change.to.line>last&&(change={from:change.from,to:Pos(last,getLine(doc,last).text.length),text:[change.text[0]],origin:change.origin});change.removed=getBetween(doc,change.from,change.to);selAfter||(selAfter=computeSelAfterChange(doc,change));doc.cm?makeChangeSingleDocInEditor(doc.cm,change,spans):updateDoc(doc,change,spans);setSelectionNoUndo(doc,selAfter,sel_dontScroll)}}function makeChangeSingleDocInEditor(cm,change,spans){var doc=cm.doc,display=cm.display,from=change.from,to=change.to,recomputeMaxLength=!1,checkWidthStart=from.line;if(!cm.options.lineWrapping){checkWidthStart=lineNo(visualLine(getLine(doc,from.line)));doc.iter(checkWidthStart,to.line+1,function(line){if(line==display.maxLine){recomputeMaxLength=!0;return!0}})}doc.sel.contains(change.from,change.to)>-1&&signalCursorActivity(cm);updateDoc(doc,change,spans,estimateHeight(cm));if(!cm.options.lineWrapping){doc.iter(checkWidthStart,from.line+change.text.length,function(line){var len=lineLength(line);if(len>display.maxLineLength){display.maxLine=line;display.maxLineLength=len;display.maxLineChanged=!0;recomputeMaxLength=!1}});recomputeMaxLength&&(cm.curOp.updateMaxLine=!0)}doc.frontier=Math.min(doc.frontier,from.line);startWorker(cm,400);var lendiff=change.text.length-(to.line-from.line)-1;change.full?regChange(cm):from.line!=to.line||1!=change.text.length||isWholeLineUpdate(cm.doc,change)?regChange(cm,from.line,to.line+1,lendiff):regLineChange(cm,from.line,"text");var changesHandler=hasHandler(cm,"changes"),changeHandler=hasHandler(cm,"change");if(changeHandler||changesHandler){var obj={from:from,to:to,text:change.text,removed:change.removed,origin:change.origin};changeHandler&&signalLater(cm,"change",cm,obj);changesHandler&&(cm.curOp.changeObjs||(cm.curOp.changeObjs=[])).push(obj)}cm.display.selForContextMenu=null}function replaceRange(doc,code,from,to,origin){to||(to=from);if(cmp(to,from)<0){var tmp=to;to=from;from=tmp}"string"==typeof code&&(code=doc.splitLines(code));makeChange(doc,{from:from,to:to,text:code,origin:origin})}function maybeScrollWindow(cm,coords){if(!signalDOMEvent(cm,"scrollCursorIntoView")){var display=cm.display,box=display.sizer.getBoundingClientRect(),doScroll=null;coords.top+box.top<0?doScroll=!0:coords.bottom+box.top>(window.innerHeight||document.documentElement.clientHeight)&&(doScroll=!1);if(null!=doScroll&&!phantom){var scrollNode=elt("div","​",null,"position: absolute; top: "+(coords.top-display.viewOffset-paddingTop(cm.display))+"px; height: "+(coords.bottom-coords.top+scrollGap(cm)+display.barHeight)+"px; left: "+coords.left+"px; width: 2px;");cm.display.lineSpace.appendChild(scrollNode);scrollNode.scrollIntoView(doScroll);cm.display.lineSpace.removeChild(scrollNode)}}}function scrollPosIntoView(cm,pos,end,margin){null==margin&&(margin=0);for(var limit=0;5>limit;limit++){var changed=!1,coords=cursorCoords(cm,pos),endCoords=end&&end!=pos?cursorCoords(cm,end):coords,scrollPos=calculateScrollPos(cm,Math.min(coords.left,endCoords.left),Math.min(coords.top,endCoords.top)-margin,Math.max(coords.left,endCoords.left),Math.max(coords.bottom,endCoords.bottom)+margin),startTop=cm.doc.scrollTop,startLeft=cm.doc.scrollLeft;if(null!=scrollPos.scrollTop){setScrollTop(cm,scrollPos.scrollTop);Math.abs(cm.doc.scrollTop-startTop)>1&&(changed=!0)}if(null!=scrollPos.scrollLeft){setScrollLeft(cm,scrollPos.scrollLeft);Math.abs(cm.doc.scrollLeft-startLeft)>1&&(changed=!0)}if(!changed)break}return coords}function scrollIntoView(cm,x1,y1,x2,y2){var scrollPos=calculateScrollPos(cm,x1,y1,x2,y2);null!=scrollPos.scrollTop&&setScrollTop(cm,scrollPos.scrollTop);null!=scrollPos.scrollLeft&&setScrollLeft(cm,scrollPos.scrollLeft)}function calculateScrollPos(cm,x1,y1,x2,y2){var display=cm.display,snapMargin=textHeight(cm.display);0>y1&&(y1=0);var screentop=cm.curOp&&null!=cm.curOp.scrollTop?cm.curOp.scrollTop:display.scroller.scrollTop,screen=displayHeight(cm),result={};y2-y1>screen&&(y2=y1+screen);var docBottom=cm.doc.height+paddingVert(display),atTop=snapMargin>y1,atBottom=y2>docBottom-snapMargin;if(screentop>y1)result.scrollTop=atTop?0:y1;else if(y2>screentop+screen){var newTop=Math.min(y1,(atBottom?docBottom:y2)-screen);newTop!=screentop&&(result.scrollTop=newTop)}var screenleft=cm.curOp&&null!=cm.curOp.scrollLeft?cm.curOp.scrollLeft:display.scroller.scrollLeft,screenw=displayWidth(cm)-(cm.options.fixedGutter?display.gutters.offsetWidth:0),tooWide=x2-x1>screenw;tooWide&&(x2=x1+screenw);10>x1?result.scrollLeft=0:screenleft>x1?result.scrollLeft=Math.max(0,x1-(tooWide?0:10)):x2>screenw+screenleft-3&&(result.scrollLeft=x2+(tooWide?0:10)-screenw);return result}function addToScrollPos(cm,left,top){(null!=left||null!=top)&&resolveScrollToPos(cm);null!=left&&(cm.curOp.scrollLeft=(null==cm.curOp.scrollLeft?cm.doc.scrollLeft:cm.curOp.scrollLeft)+left);null!=top&&(cm.curOp.scrollTop=(null==cm.curOp.scrollTop?cm.doc.scrollTop:cm.curOp.scrollTop)+top)}function ensureCursorVisible(cm){resolveScrollToPos(cm);var cur=cm.getCursor(),from=cur,to=cur;if(!cm.options.lineWrapping){from=cur.ch?Pos(cur.line,cur.ch-1):cur;to=Pos(cur.line,cur.ch+1)}cm.curOp.scrollToPos={from:from,to:to,margin:cm.options.cursorScrollMargin,isCursor:!0}}function resolveScrollToPos(cm){var range=cm.curOp.scrollToPos;if(range){cm.curOp.scrollToPos=null;var from=estimateCoords(cm,range.from),to=estimateCoords(cm,range.to),sPos=calculateScrollPos(cm,Math.min(from.left,to.left),Math.min(from.top,to.top)-range.margin,Math.max(from.right,to.right),Math.max(from.bottom,to.bottom)+range.margin);cm.scrollTo(sPos.scrollLeft,sPos.scrollTop)}}function indentLine(cm,n,how,aggressive){var state,doc=cm.doc;null==how&&(how="add");"smart"==how&&(doc.mode.indent?state=getStateBefore(cm,n):how="prev");var tabSize=cm.options.tabSize,line=getLine(doc,n),curSpace=countColumn(line.text,null,tabSize);line.stateAfter&&(line.stateAfter=null);var indentation,curSpaceString=line.text.match(/^\s*/)[0];if(aggressive||/\S/.test(line.text)){if("smart"==how){indentation=doc.mode.indent(state,line.text.slice(curSpaceString.length),line.text);
4
+ if(indentation==Pass||indentation>150){if(!aggressive)return;how="prev"}}}else{indentation=0;how="not"}"prev"==how?indentation=n>doc.first?countColumn(getLine(doc,n-1).text,null,tabSize):0:"add"==how?indentation=curSpace+cm.options.indentUnit:"subtract"==how?indentation=curSpace-cm.options.indentUnit:"number"==typeof how&&(indentation=curSpace+how);indentation=Math.max(0,indentation);var indentString="",pos=0;if(cm.options.indentWithTabs)for(var i=Math.floor(indentation/tabSize);i;--i){pos+=tabSize;indentString+=" "}indentation>pos&&(indentString+=spaceStr(indentation-pos));if(indentString!=curSpaceString){replaceRange(doc,indentString,Pos(n,0),Pos(n,curSpaceString.length),"+input");line.stateAfter=null;return!0}for(var i=0;i<doc.sel.ranges.length;i++){var range=doc.sel.ranges[i];if(range.head.line==n&&range.head.ch<curSpaceString.length){var pos=Pos(n,curSpaceString.length);replaceOneSelection(doc,i,new Range(pos,pos));break}}}function changeLine(doc,handle,changeType,op){var no=handle,line=handle;"number"==typeof handle?line=getLine(doc,clipLine(doc,handle)):no=lineNo(handle);if(null==no)return null;op(line,no)&&doc.cm&&regLineChange(doc.cm,no,changeType);return line}function deleteNearSelection(cm,compute){for(var ranges=cm.doc.sel.ranges,kill=[],i=0;i<ranges.length;i++){for(var toKill=compute(ranges[i]);kill.length&&cmp(toKill.from,lst(kill).to)<=0;){var replaced=kill.pop();if(cmp(replaced.from,toKill.from)<0){toKill.from=replaced.from;break}}kill.push(toKill)}runInOp(cm,function(){for(var i=kill.length-1;i>=0;i--)replaceRange(cm.doc,"",kill[i].from,kill[i].to,"+delete");ensureCursorVisible(cm)})}function findPosH(doc,pos,dir,unit,visually){function findNextLine(){var l=line+dir;if(l<doc.first||l>=doc.first+doc.size)return!1;line=l;return lineObj=getLine(doc,l)}function moveOnce(boundToLine){var next=(visually?moveVisually:moveLogically)(lineObj,ch,dir,!0);if(null==next){if(boundToLine||!findNextLine())return!1;ch=visually?(0>dir?lineRight:lineLeft)(lineObj):0>dir?lineObj.text.length:0}else ch=next;return!0}var line=pos.line,ch=pos.ch,origDir=dir,lineObj=getLine(doc,line);if("char"==unit)moveOnce();else if("column"==unit)moveOnce(!0);else if("word"==unit||"group"==unit)for(var sawType=null,group="group"==unit,helper=doc.cm&&doc.cm.getHelper(pos,"wordChars"),first=!0;!(0>dir)||moveOnce(!first);first=!1){var cur=lineObj.text.charAt(ch)||"\n",type=isWordChar(cur,helper)?"w":group&&"\n"==cur?"n":!group||/\s/.test(cur)?null:"p";!group||first||type||(type="s");if(sawType&&sawType!=type){if(0>dir){dir=1;moveOnce()}break}type&&(sawType=type);if(dir>0&&!moveOnce(!first))break}var result=skipAtomic(doc,Pos(line,ch),pos,origDir,!0);cmp(pos,result)||(result.hitSide=!0);return result}function findPosV(cm,pos,dir,unit){var y,doc=cm.doc,x=pos.left;if("page"==unit){var pageSize=Math.min(cm.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);y=pos.top+dir*(pageSize-(0>dir?1.5:.5)*textHeight(cm.display))}else"line"==unit&&(y=dir>0?pos.bottom+3:pos.top-3);for(;;){var target=coordsChar(cm,x,y);if(!target.outside)break;if(0>dir?0>=y:y>=doc.height){target.hitSide=!0;break}y+=5*dir}return target}function option(name,deflt,handle,notOnInit){CodeMirror.defaults[name]=deflt;handle&&(optionHandlers[name]=notOnInit?function(cm,val,old){old!=Init&&handle(cm,val,old)}:handle)}function normalizeKeyName(name){for(var alt,ctrl,shift,cmd,parts=name.split(/-(?!$)/),name=parts[parts.length-1],i=0;i<parts.length-1;i++){var mod=parts[i];if(/^(cmd|meta|m)$/i.test(mod))cmd=!0;else if(/^a(lt)?$/i.test(mod))alt=!0;else if(/^(c|ctrl|control)$/i.test(mod))ctrl=!0;else{if(!/^s(hift)$/i.test(mod))throw new Error("Unrecognized modifier name: "+mod);shift=!0}}alt&&(name="Alt-"+name);ctrl&&(name="Ctrl-"+name);cmd&&(name="Cmd-"+name);shift&&(name="Shift-"+name);return name}function getKeyMap(val){return"string"==typeof val?keyMap[val]:val}function markText(doc,from,to,options,type){if(options&&options.shared)return markTextShared(doc,from,to,options,type);if(doc.cm&&!doc.cm.curOp)return operation(doc.cm,markText)(doc,from,to,options,type);var marker=new TextMarker(doc,type),diff=cmp(from,to);options&&copyObj(options,marker,!1);if(diff>0||0==diff&&marker.clearWhenEmpty!==!1)return marker;if(marker.replacedWith){marker.collapsed=!0;marker.widgetNode=elt("span",[marker.replacedWith],"CodeMirror-widget");options.handleMouseEvents||marker.widgetNode.setAttribute("cm-ignore-events","true");options.insertLeft&&(marker.widgetNode.insertLeft=!0)}if(marker.collapsed){if(conflictingCollapsedRange(doc,from.line,from,to,marker)||from.line!=to.line&&conflictingCollapsedRange(doc,to.line,from,to,marker))throw new Error("Inserting collapsed marker partially overlapping an existing one");sawCollapsedSpans=!0}marker.addToHistory&&addChangeToHistory(doc,{from:from,to:to,origin:"markText"},doc.sel,NaN);var updateMaxLine,curLine=from.line,cm=doc.cm;doc.iter(curLine,to.line+1,function(line){cm&&marker.collapsed&&!cm.options.lineWrapping&&visualLine(line)==cm.display.maxLine&&(updateMaxLine=!0);marker.collapsed&&curLine!=from.line&&updateLineHeight(line,0);addMarkedSpan(line,new MarkedSpan(marker,curLine==from.line?from.ch:null,curLine==to.line?to.ch:null));++curLine});marker.collapsed&&doc.iter(from.line,to.line+1,function(line){lineIsHidden(doc,line)&&updateLineHeight(line,0)});marker.clearOnEnter&&on(marker,"beforeCursorEnter",function(){marker.clear()});if(marker.readOnly){sawReadOnlySpans=!0;(doc.history.done.length||doc.history.undone.length)&&doc.clearHistory()}if(marker.collapsed){marker.id=++nextMarkerId;marker.atomic=!0}if(cm){updateMaxLine&&(cm.curOp.updateMaxLine=!0);if(marker.collapsed)regChange(cm,from.line,to.line+1);else if(marker.className||marker.title||marker.startStyle||marker.endStyle||marker.css)for(var i=from.line;i<=to.line;i++)regLineChange(cm,i,"text");marker.atomic&&reCheckSelection(cm.doc);signalLater(cm,"markerAdded",cm,marker)}return marker}function markTextShared(doc,from,to,options,type){options=copyObj(options);options.shared=!1;var markers=[markText(doc,from,to,options,type)],primary=markers[0],widget=options.widgetNode;linkedDocs(doc,function(doc){widget&&(options.widgetNode=widget.cloneNode(!0));markers.push(markText(doc,clipPos(doc,from),clipPos(doc,to),options,type));for(var i=0;i<doc.linked.length;++i)if(doc.linked[i].isParent)return;primary=lst(markers)});return new SharedTextMarker(markers,primary)}function findSharedMarkers(doc){return doc.findMarks(Pos(doc.first,0),doc.clipPos(Pos(doc.lastLine())),function(m){return m.parent})}function copySharedMarkers(doc,markers){for(var i=0;i<markers.length;i++){var marker=markers[i],pos=marker.find(),mFrom=doc.clipPos(pos.from),mTo=doc.clipPos(pos.to);if(cmp(mFrom,mTo)){var subMark=markText(doc,mFrom,mTo,marker.primary,marker.primary.type);marker.markers.push(subMark);subMark.parent=marker}}}function detachSharedMarkers(markers){for(var i=0;i<markers.length;i++){var marker=markers[i],linked=[marker.primary.doc];linkedDocs(marker.primary.doc,function(d){linked.push(d)});for(var j=0;j<marker.markers.length;j++){var subMarker=marker.markers[j];if(-1==indexOf(linked,subMarker.doc)){subMarker.parent=null;marker.markers.splice(j--,1)}}}}function MarkedSpan(marker,from,to){this.marker=marker;this.from=from;this.to=to}function getMarkedSpanFor(spans,marker){if(spans)for(var i=0;i<spans.length;++i){var span=spans[i];if(span.marker==marker)return span}}function removeMarkedSpan(spans,span){for(var r,i=0;i<spans.length;++i)spans[i]!=span&&(r||(r=[])).push(spans[i]);return r}function addMarkedSpan(line,span){line.markedSpans=line.markedSpans?line.markedSpans.concat([span]):[span];span.marker.attachLine(line)}function markedSpansBefore(old,startCh,isInsert){if(old)for(var nw,i=0;i<old.length;++i){var span=old[i],marker=span.marker,startsBefore=null==span.from||(marker.inclusiveLeft?span.from<=startCh:span.from<startCh);if(startsBefore||span.from==startCh&&"bookmark"==marker.type&&(!isInsert||!span.marker.insertLeft)){var endsAfter=null==span.to||(marker.inclusiveRight?span.to>=startCh:span.to>startCh);(nw||(nw=[])).push(new MarkedSpan(marker,span.from,endsAfter?null:span.to))}}return nw}function markedSpansAfter(old,endCh,isInsert){if(old)for(var nw,i=0;i<old.length;++i){var span=old[i],marker=span.marker,endsAfter=null==span.to||(marker.inclusiveRight?span.to>=endCh:span.to>endCh);if(endsAfter||span.from==endCh&&"bookmark"==marker.type&&(!isInsert||span.marker.insertLeft)){var startsBefore=null==span.from||(marker.inclusiveLeft?span.from<=endCh:span.from<endCh);(nw||(nw=[])).push(new MarkedSpan(marker,startsBefore?null:span.from-endCh,null==span.to?null:span.to-endCh))}}return nw}function stretchSpansOverChange(doc,change){if(change.full)return null;var oldFirst=isLine(doc,change.from.line)&&getLine(doc,change.from.line).markedSpans,oldLast=isLine(doc,change.to.line)&&getLine(doc,change.to.line).markedSpans;if(!oldFirst&&!oldLast)return null;var startCh=change.from.ch,endCh=change.to.ch,isInsert=0==cmp(change.from,change.to),first=markedSpansBefore(oldFirst,startCh,isInsert),last=markedSpansAfter(oldLast,endCh,isInsert),sameLine=1==change.text.length,offset=lst(change.text).length+(sameLine?startCh:0);if(first)for(var i=0;i<first.length;++i){var span=first[i];if(null==span.to){var found=getMarkedSpanFor(last,span.marker);found?sameLine&&(span.to=null==found.to?null:found.to+offset):span.to=startCh}}if(last)for(var i=0;i<last.length;++i){var span=last[i];null!=span.to&&(span.to+=offset);if(null==span.from){var found=getMarkedSpanFor(first,span.marker);if(!found){span.from=offset;sameLine&&(first||(first=[])).push(span)}}else{span.from+=offset;sameLine&&(first||(first=[])).push(span)}}first&&(first=clearEmptySpans(first));last&&last!=first&&(last=clearEmptySpans(last));var newMarkers=[first];if(!sameLine){var gapMarkers,gap=change.text.length-2;if(gap>0&&first)for(var i=0;i<first.length;++i)null==first[i].to&&(gapMarkers||(gapMarkers=[])).push(new MarkedSpan(first[i].marker,null,null));for(var i=0;gap>i;++i)newMarkers.push(gapMarkers);newMarkers.push(last)}return newMarkers}function clearEmptySpans(spans){for(var i=0;i<spans.length;++i){var span=spans[i];null!=span.from&&span.from==span.to&&span.marker.clearWhenEmpty!==!1&&spans.splice(i--,1)}return spans.length?spans:null}function mergeOldSpans(doc,change){var old=getOldSpans(doc,change),stretched=stretchSpansOverChange(doc,change);if(!old)return stretched;if(!stretched)return old;for(var i=0;i<old.length;++i){var oldCur=old[i],stretchCur=stretched[i];if(oldCur&&stretchCur)spans:for(var j=0;j<stretchCur.length;++j){for(var span=stretchCur[j],k=0;k<oldCur.length;++k)if(oldCur[k].marker==span.marker)continue spans;oldCur.push(span)}else stretchCur&&(old[i]=stretchCur)}return old}function removeReadOnlyRanges(doc,from,to){var markers=null;doc.iter(from.line,to.line+1,function(line){if(line.markedSpans)for(var i=0;i<line.markedSpans.length;++i){var mark=line.markedSpans[i].marker;!mark.readOnly||markers&&-1!=indexOf(markers,mark)||(markers||(markers=[])).push(mark)}});if(!markers)return null;for(var parts=[{from:from,to:to}],i=0;i<markers.length;++i)for(var mk=markers[i],m=mk.find(0),j=0;j<parts.length;++j){var p=parts[j];if(!(cmp(p.to,m.from)<0||cmp(p.from,m.to)>0)){var newParts=[j,1],dfrom=cmp(p.from,m.from),dto=cmp(p.to,m.to);(0>dfrom||!mk.inclusiveLeft&&!dfrom)&&newParts.push({from:p.from,to:m.from});(dto>0||!mk.inclusiveRight&&!dto)&&newParts.push({from:m.to,to:p.to});parts.splice.apply(parts,newParts);j+=newParts.length-1}}return parts}function detachMarkedSpans(line){var spans=line.markedSpans;if(spans){for(var i=0;i<spans.length;++i)spans[i].marker.detachLine(line);line.markedSpans=null}}function attachMarkedSpans(line,spans){if(spans){for(var i=0;i<spans.length;++i)spans[i].marker.attachLine(line);line.markedSpans=spans}}function extraLeft(marker){return marker.inclusiveLeft?-1:0}function extraRight(marker){return marker.inclusiveRight?1:0}function compareCollapsedMarkers(a,b){var lenDiff=a.lines.length-b.lines.length;if(0!=lenDiff)return lenDiff;var aPos=a.find(),bPos=b.find(),fromCmp=cmp(aPos.from,bPos.from)||extraLeft(a)-extraLeft(b);if(fromCmp)return-fromCmp;var toCmp=cmp(aPos.to,bPos.to)||extraRight(a)-extraRight(b);return toCmp?toCmp:b.id-a.id}function collapsedSpanAtSide(line,start){var found,sps=sawCollapsedSpans&&line.markedSpans;if(sps)for(var sp,i=0;i<sps.length;++i){sp=sps[i];sp.marker.collapsed&&null==(start?sp.from:sp.to)&&(!found||compareCollapsedMarkers(found,sp.marker)<0)&&(found=sp.marker)}return found}function collapsedSpanAtStart(line){return collapsedSpanAtSide(line,!0)}function collapsedSpanAtEnd(line){return collapsedSpanAtSide(line,!1)}function conflictingCollapsedRange(doc,lineNo,from,to,marker){var line=getLine(doc,lineNo),sps=sawCollapsedSpans&&line.markedSpans;if(sps)for(var i=0;i<sps.length;++i){var sp=sps[i];if(sp.marker.collapsed){var found=sp.marker.find(0),fromCmp=cmp(found.from,from)||extraLeft(sp.marker)-extraLeft(marker),toCmp=cmp(found.to,to)||extraRight(sp.marker)-extraRight(marker);if(!(fromCmp>=0&&0>=toCmp||0>=fromCmp&&toCmp>=0)&&(0>=fromCmp&&(cmp(found.to,from)>0||sp.marker.inclusiveRight&&marker.inclusiveLeft)||fromCmp>=0&&(cmp(found.from,to)<0||sp.marker.inclusiveLeft&&marker.inclusiveRight)))return!0}}}function visualLine(line){for(var merged;merged=collapsedSpanAtStart(line);)line=merged.find(-1,!0).line;return line}function visualLineContinued(line){for(var merged,lines;merged=collapsedSpanAtEnd(line);){line=merged.find(1,!0).line;(lines||(lines=[])).push(line)}return lines}function visualLineNo(doc,lineN){var line=getLine(doc,lineN),vis=visualLine(line);return line==vis?lineN:lineNo(vis)}function visualLineEndNo(doc,lineN){if(lineN>doc.lastLine())return lineN;var merged,line=getLine(doc,lineN);if(!lineIsHidden(doc,line))return lineN;for(;merged=collapsedSpanAtEnd(line);)line=merged.find(1,!0).line;return lineNo(line)+1}function lineIsHidden(doc,line){var sps=sawCollapsedSpans&&line.markedSpans;if(sps)for(var sp,i=0;i<sps.length;++i){sp=sps[i];if(sp.marker.collapsed){if(null==sp.from)return!0;if(!sp.marker.widgetNode&&0==sp.from&&sp.marker.inclusiveLeft&&lineIsHiddenInner(doc,line,sp))return!0}}}function lineIsHiddenInner(doc,line,span){if(null==span.to){var end=span.marker.find(1,!0);return lineIsHiddenInner(doc,end.line,getMarkedSpanFor(end.line.markedSpans,span.marker))}if(span.marker.inclusiveRight&&span.to==line.text.length)return!0;for(var sp,i=0;i<line.markedSpans.length;++i){sp=line.markedSpans[i];if(sp.marker.collapsed&&!sp.marker.widgetNode&&sp.from==span.to&&(null==sp.to||sp.to!=span.from)&&(sp.marker.inclusiveLeft||span.marker.inclusiveRight)&&lineIsHiddenInner(doc,line,sp))return!0}}function adjustScrollWhenAboveVisible(cm,line,diff){heightAtLine(line)<(cm.curOp&&cm.curOp.scrollTop||cm.doc.scrollTop)&&addToScrollPos(cm,null,diff)}function widgetHeight(widget){if(null!=widget.height)return widget.height;var cm=widget.doc.cm;if(!cm)return 0;if(!contains(document.body,widget.node)){var parentStyle="position: relative;";widget.coverGutter&&(parentStyle+="margin-left: -"+cm.display.gutters.offsetWidth+"px;");widget.noHScroll&&(parentStyle+="width: "+cm.display.wrapper.clientWidth+"px;");removeChildrenAndAdd(cm.display.measure,elt("div",[widget.node],null,parentStyle))}return widget.height=widget.node.parentNode.offsetHeight}function addLineWidget(doc,handle,node,options){var widget=new LineWidget(doc,node,options),cm=doc.cm;cm&&widget.noHScroll&&(cm.display.alignWidgets=!0);changeLine(doc,handle,"widget",function(line){var widgets=line.widgets||(line.widgets=[]);null==widget.insertAt?widgets.push(widget):widgets.splice(Math.min(widgets.length-1,Math.max(0,widget.insertAt)),0,widget);widget.line=line;if(cm&&!lineIsHidden(doc,line)){var aboveVisible=heightAtLine(line)<doc.scrollTop;updateLineHeight(line,line.height+widgetHeight(widget));aboveVisible&&addToScrollPos(cm,null,widget.height);cm.curOp.forceUpdate=!0}return!0});return widget}function updateLine(line,text,markedSpans,estimateHeight){line.text=text;line.stateAfter&&(line.stateAfter=null);line.styles&&(line.styles=null);null!=line.order&&(line.order=null);detachMarkedSpans(line);attachMarkedSpans(line,markedSpans);var estHeight=estimateHeight?estimateHeight(line):1;estHeight!=line.height&&updateLineHeight(line,estHeight)}function cleanUpLine(line){line.parent=null;detachMarkedSpans(line)}function extractLineClasses(type,output){if(type)for(;;){var lineClass=type.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!lineClass)break;type=type.slice(0,lineClass.index)+type.slice(lineClass.index+lineClass[0].length);var prop=lineClass[1]?"bgClass":"textClass";null==output[prop]?output[prop]=lineClass[2]:new RegExp("(?:^|s)"+lineClass[2]+"(?:$|s)").test(output[prop])||(output[prop]+=" "+lineClass[2])}return type}function callBlankLine(mode,state){if(mode.blankLine)return mode.blankLine(state);if(mode.innerMode){var inner=CodeMirror.innerMode(mode,state);return inner.mode.blankLine?inner.mode.blankLine(inner.state):void 0}}function readToken(mode,stream,state,inner){for(var i=0;10>i;i++){inner&&(inner[0]=CodeMirror.innerMode(mode,state).mode);var style=mode.token(stream,state);if(stream.pos>stream.start)return style}throw new Error("Mode "+mode.name+" failed to advance stream.")}function takeToken(cm,pos,precise,asArray){function getObj(copy){return{start:stream.start,end:stream.pos,string:stream.current(),type:style||null,state:copy?copyState(doc.mode,state):state}}var style,doc=cm.doc,mode=doc.mode;pos=clipPos(doc,pos);var tokens,line=getLine(doc,pos.line),state=getStateBefore(cm,pos.line,precise),stream=new StringStream(line.text,cm.options.tabSize);asArray&&(tokens=[]);for(;(asArray||stream.pos<pos.ch)&&!stream.eol();){stream.start=stream.pos;style=readToken(mode,stream,state);asArray&&tokens.push(getObj(!0))}return asArray?tokens:getObj()}function runMode(cm,text,mode,state,f,lineClasses,forceToEnd){var flattenSpans=mode.flattenSpans;null==flattenSpans&&(flattenSpans=cm.options.flattenSpans);var style,curStart=0,curStyle=null,stream=new StringStream(text,cm.options.tabSize),inner=cm.options.addModeClass&&[null];""==text&&extractLineClasses(callBlankLine(mode,state),lineClasses);for(;!stream.eol();){if(stream.pos>cm.options.maxHighlightLength){flattenSpans=!1;forceToEnd&&processLine(cm,text,state,stream.pos);stream.pos=text.length;style=null}else style=extractLineClasses(readToken(mode,stream,state,inner),lineClasses);if(inner){var mName=inner[0].name;mName&&(style="m-"+(style?mName+" "+style:mName))}if(!flattenSpans||curStyle!=style){for(;curStart<stream.start;){curStart=Math.min(stream.start,curStart+5e4);f(curStart,curStyle)}curStyle=style}stream.start=stream.pos}for(;curStart<stream.pos;){var pos=Math.min(stream.pos,curStart+5e4);f(pos,curStyle);curStart=pos}}function highlightLine(cm,line,state,forceToEnd){var st=[cm.state.modeGen],lineClasses={};runMode(cm,line.text,cm.doc.mode,state,function(end,style){st.push(end,style)},lineClasses,forceToEnd);for(var o=0;o<cm.state.overlays.length;++o){var overlay=cm.state.overlays[o],i=1,at=0;runMode(cm,line.text,overlay.mode,!0,function(end,style){for(var start=i;end>at;){var i_end=st[i];i_end>end&&st.splice(i,1,end,st[i+1],i_end);i+=2;at=Math.min(end,i_end)}if(style)if(overlay.opaque){st.splice(start,i-start,end,"cm-overlay "+style);i=start+2}else for(;i>start;start+=2){var cur=st[start+1];st[start+1]=(cur?cur+" ":"")+"cm-overlay "+style}},lineClasses)}return{styles:st,classes:lineClasses.bgClass||lineClasses.textClass?lineClasses:null}}function getLineStyles(cm,line,updateFrontier){if(!line.styles||line.styles[0]!=cm.state.modeGen){var state=getStateBefore(cm,lineNo(line)),result=highlightLine(cm,line,line.text.length>cm.options.maxHighlightLength?copyState(cm.doc.mode,state):state);line.stateAfter=state;line.styles=result.styles;result.classes?line.styleClasses=result.classes:line.styleClasses&&(line.styleClasses=null);updateFrontier===cm.doc.frontier&&cm.doc.frontier++}return line.styles}function processLine(cm,text,state,startAt){var mode=cm.doc.mode,stream=new StringStream(text,cm.options.tabSize);stream.start=stream.pos=startAt||0;""==text&&callBlankLine(mode,state);for(;!stream.eol();){readToken(mode,stream,state);stream.start=stream.pos}}function interpretTokenStyle(style,options){if(!style||/^\s*$/.test(style))return null;var cache=options.addModeClass?styleToClassCacheWithMode:styleToClassCache;return cache[style]||(cache[style]=style.replace(/\S+/g,"cm-$&"))}function buildLineContent(cm,lineView){var content=elt("span",null,null,webkit?"padding-right: .1px":null),builder={pre:elt("pre",[content],"CodeMirror-line"),content:content,col:0,pos:0,cm:cm,splitSpaces:(ie||webkit)&&cm.getOption("lineWrapping")};lineView.measure={};for(var i=0;i<=(lineView.rest?lineView.rest.length:0);i++){var order,line=i?lineView.rest[i-1]:lineView.line;builder.pos=0;builder.addToken=buildToken;hasBadBidiRects(cm.display.measure)&&(order=getOrder(line))&&(builder.addToken=buildTokenBadBidi(builder.addToken,order));builder.map=[];var allowFrontierUpdate=lineView!=cm.display.externalMeasured&&lineNo(line);insertLineContent(line,builder,getLineStyles(cm,line,allowFrontierUpdate));if(line.styleClasses){line.styleClasses.bgClass&&(builder.bgClass=joinClasses(line.styleClasses.bgClass,builder.bgClass||""));line.styleClasses.textClass&&(builder.textClass=joinClasses(line.styleClasses.textClass,builder.textClass||""))}0==builder.map.length&&builder.map.push(0,0,builder.content.appendChild(zeroWidthElement(cm.display.measure)));if(0==i){lineView.measure.map=builder.map;lineView.measure.cache={}}else{(lineView.measure.maps||(lineView.measure.maps=[])).push(builder.map);(lineView.measure.caches||(lineView.measure.caches=[])).push({})}}webkit&&/\bcm-tab\b/.test(builder.content.lastChild.className)&&(builder.content.className="cm-tab-wrap-hack");signal(cm,"renderLine",cm,lineView.line,builder.pre);builder.pre.className&&(builder.textClass=joinClasses(builder.pre.className,builder.textClass||""));return builder}function defaultSpecialCharPlaceholder(ch){var token=elt("span","•","cm-invalidchar");token.title="\\u"+ch.charCodeAt(0).toString(16);token.setAttribute("aria-label",token.title);return token}function buildToken(builder,text,style,startStyle,endStyle,title,css){if(text){var displayText=builder.splitSpaces?text.replace(/ {3,}/g,splitSpaces):text,special=builder.cm.state.specialChars,mustWrap=!1;if(special.test(text))for(var content=document.createDocumentFragment(),pos=0;;){special.lastIndex=pos;var m=special.exec(text),skipped=m?m.index-pos:text.length-pos;if(skipped){var txt=document.createTextNode(displayText.slice(pos,pos+skipped));ie&&9>ie_version?content.appendChild(elt("span",[txt])):content.appendChild(txt);builder.map.push(builder.pos,builder.pos+skipped,txt);builder.col+=skipped;builder.pos+=skipped}if(!m)break;pos+=skipped+1;if(" "==m[0]){var tabSize=builder.cm.options.tabSize,tabWidth=tabSize-builder.col%tabSize,txt=content.appendChild(elt("span",spaceStr(tabWidth),"cm-tab"));txt.setAttribute("role","presentation");txt.setAttribute("cm-text"," ");builder.col+=tabWidth}else if("\r"==m[0]||"\n"==m[0]){var txt=content.appendChild(elt("span","\r"==m[0]?"␍":"␤","cm-invalidchar"));txt.setAttribute("cm-text",m[0]);builder.col+=1}else{var txt=builder.cm.options.specialCharPlaceholder(m[0]);txt.setAttribute("cm-text",m[0]);ie&&9>ie_version?content.appendChild(elt("span",[txt])):content.appendChild(txt);builder.col+=1}builder.map.push(builder.pos,builder.pos+1,txt);builder.pos++}else{builder.col+=text.length;var content=document.createTextNode(displayText);builder.map.push(builder.pos,builder.pos+text.length,content);ie&&9>ie_version&&(mustWrap=!0);builder.pos+=text.length}if(style||startStyle||endStyle||mustWrap||css){var fullStyle=style||"";startStyle&&(fullStyle+=startStyle);endStyle&&(fullStyle+=endStyle);var token=elt("span",[content],fullStyle,css);title&&(token.title=title);return builder.content.appendChild(token)}builder.content.appendChild(content)}}function splitSpaces(old){for(var out=" ",i=0;i<old.length-2;++i)out+=i%2?" ":" ";out+=" ";return out}function buildTokenBadBidi(inner,order){return function(builder,text,style,startStyle,endStyle,title,css){style=style?style+" cm-force-border":"cm-force-border";for(var start=builder.pos,end=start+text.length;;){for(var i=0;i<order.length;i++){var part=order[i];if(part.to>start&&part.from<=start)break}if(part.to>=end)return inner(builder,text,style,startStyle,endStyle,title,css);inner(builder,text.slice(0,part.to-start),style,startStyle,null,title,css);startStyle=null;text=text.slice(part.to-start);start=part.to}}}function buildCollapsedSpan(builder,size,marker,ignoreWidget){var widget=!ignoreWidget&&marker.widgetNode;widget&&builder.map.push(builder.pos,builder.pos+size,widget);if(!ignoreWidget&&builder.cm.display.input.needsContentAttribute){widget||(widget=builder.content.appendChild(document.createElement("span")));widget.setAttribute("cm-marker",marker.id)}if(widget){builder.cm.display.input.setUneditable(widget);builder.content.appendChild(widget)}builder.pos+=size}function insertLineContent(line,builder,styles){var spans=line.markedSpans,allText=line.text,at=0;if(spans)for(var style,css,spanStyle,spanEndStyle,spanStartStyle,title,collapsed,len=allText.length,pos=0,i=1,text="",nextChange=0;;){if(nextChange==pos){spanStyle=spanEndStyle=spanStartStyle=title=css="";collapsed=null;nextChange=1/0;for(var endStyles,foundBookmarks=[],j=0;j<spans.length;++j){var sp=spans[j],m=sp.marker;if("bookmark"==m.type&&sp.from==pos&&m.widgetNode)foundBookmarks.push(m);else if(sp.from<=pos&&(null==sp.to||sp.to>pos||m.collapsed&&sp.to==pos&&sp.from==pos)){if(null!=sp.to&&sp.to!=pos&&nextChange>sp.to){nextChange=sp.to;spanEndStyle=""}m.className&&(spanStyle+=" "+m.className);m.css&&(css=(css?css+";":"")+m.css);m.startStyle&&sp.from==pos&&(spanStartStyle+=" "+m.startStyle);m.endStyle&&sp.to==nextChange&&(endStyles||(endStyles=[])).push(m.endStyle,sp.to);m.title&&!title&&(title=m.title);m.collapsed&&(!collapsed||compareCollapsedMarkers(collapsed.marker,m)<0)&&(collapsed=sp)}else sp.from>pos&&nextChange>sp.from&&(nextChange=sp.from)}if(endStyles)for(var j=0;j<endStyles.length;j+=2)endStyles[j+1]==nextChange&&(spanEndStyle+=" "+endStyles[j]);if(!collapsed||collapsed.from==pos)for(var j=0;j<foundBookmarks.length;++j)buildCollapsedSpan(builder,0,foundBookmarks[j]);if(collapsed&&(collapsed.from||0)==pos){buildCollapsedSpan(builder,(null==collapsed.to?len+1:collapsed.to)-pos,collapsed.marker,null==collapsed.from);if(null==collapsed.to)return;collapsed.to==pos&&(collapsed=!1)}}if(pos>=len)break;for(var upto=Math.min(len,nextChange);;){if(text){var end=pos+text.length;if(!collapsed){var tokenText=end>upto?text.slice(0,upto-pos):text;builder.addToken(builder,tokenText,style?style+spanStyle:spanStyle,spanStartStyle,pos+tokenText.length==nextChange?spanEndStyle:"",title,css)}if(end>=upto){text=text.slice(upto-pos);pos=upto;break}pos=end;spanStartStyle=""}text=allText.slice(at,at=styles[i++]);style=interpretTokenStyle(styles[i++],builder.cm.options)}}else for(var i=1;i<styles.length;i+=2)builder.addToken(builder,allText.slice(at,at=styles[i]),interpretTokenStyle(styles[i+1],builder.cm.options))}function isWholeLineUpdate(doc,change){return 0==change.from.ch&&0==change.to.ch&&""==lst(change.text)&&(!doc.cm||doc.cm.options.wholeLineUpdateBefore)}function updateDoc(doc,change,markedSpans,estimateHeight){function spansFor(n){return markedSpans?markedSpans[n]:null}function update(line,text,spans){updateLine(line,text,spans,estimateHeight);signalLater(line,"change",line,change)}function linesFor(start,end){for(var i=start,result=[];end>i;++i)result.push(new Line(text[i],spansFor(i),estimateHeight));return result}var from=change.from,to=change.to,text=change.text,firstLine=getLine(doc,from.line),lastLine=getLine(doc,to.line),lastText=lst(text),lastSpans=spansFor(text.length-1),nlines=to.line-from.line;if(change.full){doc.insert(0,linesFor(0,text.length));doc.remove(text.length,doc.size-text.length)}else if(isWholeLineUpdate(doc,change)){var added=linesFor(0,text.length-1);update(lastLine,lastLine.text,lastSpans);nlines&&doc.remove(from.line,nlines);added.length&&doc.insert(from.line,added)}else if(firstLine==lastLine)if(1==text.length)update(firstLine,firstLine.text.slice(0,from.ch)+lastText+firstLine.text.slice(to.ch),lastSpans);else{var added=linesFor(1,text.length-1);added.push(new Line(lastText+firstLine.text.slice(to.ch),lastSpans,estimateHeight));update(firstLine,firstLine.text.slice(0,from.ch)+text[0],spansFor(0));doc.insert(from.line+1,added)}else if(1==text.length){update(firstLine,firstLine.text.slice(0,from.ch)+text[0]+lastLine.text.slice(to.ch),spansFor(0));doc.remove(from.line+1,nlines)}else{update(firstLine,firstLine.text.slice(0,from.ch)+text[0],spansFor(0));update(lastLine,lastText+lastLine.text.slice(to.ch),lastSpans);var added=linesFor(1,text.length-1);nlines>1&&doc.remove(from.line+1,nlines-1);doc.insert(from.line+1,added)}signalLater(doc,"change",doc,change)}function LeafChunk(lines){this.lines=lines;this.parent=null;for(var i=0,height=0;i<lines.length;++i){lines[i].parent=this;height+=lines[i].height}this.height=height}function BranchChunk(children){this.children=children;for(var size=0,height=0,i=0;i<children.length;++i){var ch=children[i];size+=ch.chunkSize();height+=ch.height;ch.parent=this}this.size=size;this.height=height;this.parent=null}function linkedDocs(doc,f,sharedHistOnly){function propagate(doc,skip,sharedHist){if(doc.linked)for(var i=0;i<doc.linked.length;++i){var rel=doc.linked[i];if(rel.doc!=skip){var shared=sharedHist&&rel.sharedHist;if(!sharedHistOnly||shared){f(rel.doc,shared);propagate(rel.doc,doc,shared)}}}}propagate(doc,null,!0)}function attachDoc(cm,doc){if(doc.cm)throw new Error("This document is already in use.");cm.doc=doc;doc.cm=cm;estimateLineHeights(cm);loadMode(cm);cm.options.lineWrapping||findMaxLine(cm);cm.options.mode=doc.modeOption;regChange(cm)}function getLine(doc,n){n-=doc.first;if(0>n||n>=doc.size)throw new Error("There is no line "+(n+doc.first)+" in the document.");for(var chunk=doc;!chunk.lines;)for(var i=0;;++i){var child=chunk.children[i],sz=child.chunkSize();if(sz>n){chunk=child;break}n-=sz}return chunk.lines[n]}function getBetween(doc,start,end){var out=[],n=start.line;doc.iter(start.line,end.line+1,function(line){var text=line.text;n==end.line&&(text=text.slice(0,end.ch));n==start.line&&(text=text.slice(start.ch));out.push(text);++n});return out}function getLines(doc,from,to){var out=[];doc.iter(from,to,function(line){out.push(line.text)});return out}function updateLineHeight(line,height){var diff=height-line.height;if(diff)for(var n=line;n;n=n.parent)n.height+=diff}function lineNo(line){if(null==line.parent)return null;for(var cur=line.parent,no=indexOf(cur.lines,line),chunk=cur.parent;chunk;cur=chunk,chunk=chunk.parent)for(var i=0;chunk.children[i]!=cur;++i)no+=chunk.children[i].chunkSize();return no+cur.first}function lineAtHeight(chunk,h){var n=chunk.first;outer:do{for(var i=0;i<chunk.children.length;++i){var child=chunk.children[i],ch=child.height;if(ch>h){chunk=child;continue outer}h-=ch;n+=child.chunkSize()}return n}while(!chunk.lines);for(var i=0;i<chunk.lines.length;++i){var line=chunk.lines[i],lh=line.height;if(lh>h)break;h-=lh}return n+i}function heightAtLine(lineObj){lineObj=visualLine(lineObj);for(var h=0,chunk=lineObj.parent,i=0;i<chunk.lines.length;++i){var line=chunk.lines[i];if(line==lineObj)break;h+=line.height}for(var p=chunk.parent;p;chunk=p,p=chunk.parent)for(var i=0;i<p.children.length;++i){var cur=p.children[i];if(cur==chunk)break;h+=cur.height}return h}function getOrder(line){var order=line.order;null==order&&(order=line.order=bidiOrdering(line.text));return order}function History(startGen){this.done=[];this.undone=[];this.undoDepth=1/0;this.lastModTime=this.lastSelTime=0;this.lastOp=this.lastSelOp=null;this.lastOrigin=this.lastSelOrigin=null;this.generation=this.maxGeneration=startGen||1;
5
+ }function historyChangeFromChange(doc,change){var histChange={from:copyPos(change.from),to:changeEnd(change),text:getBetween(doc,change.from,change.to)};attachLocalSpans(doc,histChange,change.from.line,change.to.line+1);linkedDocs(doc,function(doc){attachLocalSpans(doc,histChange,change.from.line,change.to.line+1)},!0);return histChange}function clearSelectionEvents(array){for(;array.length;){var last=lst(array);if(!last.ranges)break;array.pop()}}function lastChangeEvent(hist,force){if(force){clearSelectionEvents(hist.done);return lst(hist.done)}if(hist.done.length&&!lst(hist.done).ranges)return lst(hist.done);if(hist.done.length>1&&!hist.done[hist.done.length-2].ranges){hist.done.pop();return lst(hist.done)}}function addChangeToHistory(doc,change,selAfter,opId){var hist=doc.history;hist.undone.length=0;var cur,time=+new Date;if((hist.lastOp==opId||hist.lastOrigin==change.origin&&change.origin&&("+"==change.origin.charAt(0)&&doc.cm&&hist.lastModTime>time-doc.cm.options.historyEventDelay||"*"==change.origin.charAt(0)))&&(cur=lastChangeEvent(hist,hist.lastOp==opId))){var last=lst(cur.changes);0==cmp(change.from,change.to)&&0==cmp(change.from,last.to)?last.to=changeEnd(change):cur.changes.push(historyChangeFromChange(doc,change))}else{var before=lst(hist.done);before&&before.ranges||pushSelectionToHistory(doc.sel,hist.done);cur={changes:[historyChangeFromChange(doc,change)],generation:hist.generation};hist.done.push(cur);for(;hist.done.length>hist.undoDepth;){hist.done.shift();hist.done[0].ranges||hist.done.shift()}}hist.done.push(selAfter);hist.generation=++hist.maxGeneration;hist.lastModTime=hist.lastSelTime=time;hist.lastOp=hist.lastSelOp=opId;hist.lastOrigin=hist.lastSelOrigin=change.origin;last||signal(doc,"historyAdded")}function selectionEventCanBeMerged(doc,origin,prev,sel){var ch=origin.charAt(0);return"*"==ch||"+"==ch&&prev.ranges.length==sel.ranges.length&&prev.somethingSelected()==sel.somethingSelected()&&new Date-doc.history.lastSelTime<=(doc.cm?doc.cm.options.historyEventDelay:500)}function addSelectionToHistory(doc,sel,opId,options){var hist=doc.history,origin=options&&options.origin;opId==hist.lastSelOp||origin&&hist.lastSelOrigin==origin&&(hist.lastModTime==hist.lastSelTime&&hist.lastOrigin==origin||selectionEventCanBeMerged(doc,origin,lst(hist.done),sel))?hist.done[hist.done.length-1]=sel:pushSelectionToHistory(sel,hist.done);hist.lastSelTime=+new Date;hist.lastSelOrigin=origin;hist.lastSelOp=opId;options&&options.clearRedo!==!1&&clearSelectionEvents(hist.undone)}function pushSelectionToHistory(sel,dest){var top=lst(dest);top&&top.ranges&&top.equals(sel)||dest.push(sel)}function attachLocalSpans(doc,change,from,to){var existing=change["spans_"+doc.id],n=0;doc.iter(Math.max(doc.first,from),Math.min(doc.first+doc.size,to),function(line){line.markedSpans&&((existing||(existing=change["spans_"+doc.id]={}))[n]=line.markedSpans);++n})}function removeClearedSpans(spans){if(!spans)return null;for(var out,i=0;i<spans.length;++i)spans[i].marker.explicitlyCleared?out||(out=spans.slice(0,i)):out&&out.push(spans[i]);return out?out.length?out:null:spans}function getOldSpans(doc,change){var found=change["spans_"+doc.id];if(!found)return null;for(var i=0,nw=[];i<change.text.length;++i)nw.push(removeClearedSpans(found[i]));return nw}function copyHistoryArray(events,newGroup,instantiateSel){for(var i=0,copy=[];i<events.length;++i){var event=events[i];if(event.ranges)copy.push(instantiateSel?Selection.prototype.deepCopy.call(event):event);else{var changes=event.changes,newChanges=[];copy.push({changes:newChanges});for(var j=0;j<changes.length;++j){var m,change=changes[j];newChanges.push({from:change.from,to:change.to,text:change.text});if(newGroup)for(var prop in change)if((m=prop.match(/^spans_(\d+)$/))&&indexOf(newGroup,Number(m[1]))>-1){lst(newChanges)[prop]=change[prop];delete change[prop]}}}}return copy}function rebaseHistSelSingle(pos,from,to,diff){if(to<pos.line)pos.line+=diff;else if(from<pos.line){pos.line=from;pos.ch=0}}function rebaseHistArray(array,from,to,diff){for(var i=0;i<array.length;++i){var sub=array[i],ok=!0;if(sub.ranges){if(!sub.copied){sub=array[i]=sub.deepCopy();sub.copied=!0}for(var j=0;j<sub.ranges.length;j++){rebaseHistSelSingle(sub.ranges[j].anchor,from,to,diff);rebaseHistSelSingle(sub.ranges[j].head,from,to,diff)}}else{for(var j=0;j<sub.changes.length;++j){var cur=sub.changes[j];if(to<cur.from.line){cur.from=Pos(cur.from.line+diff,cur.from.ch);cur.to=Pos(cur.to.line+diff,cur.to.ch)}else if(from<=cur.to.line){ok=!1;break}}if(!ok){array.splice(0,i+1);i=0}}}}function rebaseHist(hist,change){var from=change.from.line,to=change.to.line,diff=change.text.length-(to-from)-1;rebaseHistArray(hist.done,from,to,diff);rebaseHistArray(hist.undone,from,to,diff)}function e_defaultPrevented(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function e_target(e){return e.target||e.srcElement}function e_button(e){var b=e.which;null==b&&(1&e.button?b=1:2&e.button?b=3:4&e.button&&(b=2));mac&&e.ctrlKey&&1==b&&(b=3);return b}function getHandlers(emitter,type,copy){var arr=emitter._handlers&&emitter._handlers[type];return copy?arr&&arr.length>0?arr.slice():noHandlers:arr||noHandlers}function signalLater(emitter,type){function bnd(f){return function(){f.apply(null,args)}}var arr=getHandlers(emitter,type,!1);if(arr.length){var list,args=Array.prototype.slice.call(arguments,2);if(operationGroup)list=operationGroup.delayedCallbacks;else if(orphanDelayedCallbacks)list=orphanDelayedCallbacks;else{list=orphanDelayedCallbacks=[];setTimeout(fireOrphanDelayed,0)}for(var i=0;i<arr.length;++i)list.push(bnd(arr[i]))}}function fireOrphanDelayed(){var delayed=orphanDelayedCallbacks;orphanDelayedCallbacks=null;for(var i=0;i<delayed.length;++i)delayed[i]()}function signalDOMEvent(cm,e,override){"string"==typeof e&&(e={type:e,preventDefault:function(){this.defaultPrevented=!0}});signal(cm,override||e.type,cm,e);return e_defaultPrevented(e)||e.codemirrorIgnore}function signalCursorActivity(cm){var arr=cm._handlers&&cm._handlers.cursorActivity;if(arr)for(var set=cm.curOp.cursorActivityHandlers||(cm.curOp.cursorActivityHandlers=[]),i=0;i<arr.length;++i)-1==indexOf(set,arr[i])&&set.push(arr[i])}function hasHandler(emitter,type){return getHandlers(emitter,type).length>0}function eventMixin(ctor){ctor.prototype.on=function(type,f){on(this,type,f)};ctor.prototype.off=function(type,f){off(this,type,f)}}function Delayed(){this.id=null}function spaceStr(n){for(;spaceStrs.length<=n;)spaceStrs.push(lst(spaceStrs)+" ");return spaceStrs[n]}function lst(arr){return arr[arr.length-1]}function indexOf(array,elt){for(var i=0;i<array.length;++i)if(array[i]==elt)return i;return-1}function map(array,f){for(var out=[],i=0;i<array.length;i++)out[i]=f(array[i],i);return out}function nothing(){}function createObj(base,props){var inst;if(Object.create)inst=Object.create(base);else{nothing.prototype=base;inst=new nothing}props&&copyObj(props,inst);return inst}function copyObj(obj,target,overwrite){target||(target={});for(var prop in obj)!obj.hasOwnProperty(prop)||overwrite===!1&&target.hasOwnProperty(prop)||(target[prop]=obj[prop]);return target}function bind(f){var args=Array.prototype.slice.call(arguments,1);return function(){return f.apply(null,args)}}function isWordChar(ch,helper){return helper?helper.source.indexOf("\\w")>-1&&isWordCharBasic(ch)?!0:helper.test(ch):isWordCharBasic(ch)}function isEmpty(obj){for(var n in obj)if(obj.hasOwnProperty(n)&&obj[n])return!1;return!0}function isExtendingChar(ch){return ch.charCodeAt(0)>=768&&extendingChars.test(ch)}function elt(tag,content,className,style){var e=document.createElement(tag);className&&(e.className=className);style&&(e.style.cssText=style);if("string"==typeof content)e.appendChild(document.createTextNode(content));else if(content)for(var i=0;i<content.length;++i)e.appendChild(content[i]);return e}function removeChildren(e){for(var count=e.childNodes.length;count>0;--count)e.removeChild(e.firstChild);return e}function removeChildrenAndAdd(parent,e){return removeChildren(parent).appendChild(e)}function activeElt(){for(var activeElement=document.activeElement;activeElement&&activeElement.root&&activeElement.root.activeElement;)activeElement=activeElement.root.activeElement;return activeElement}function classTest(cls){return new RegExp("(^|\\s)"+cls+"(?:$|\\s)\\s*")}function joinClasses(a,b){for(var as=a.split(" "),i=0;i<as.length;i++)as[i]&&!classTest(as[i]).test(b)&&(b+=" "+as[i]);return b}function forEachCodeMirror(f){if(document.body.getElementsByClassName)for(var byClass=document.body.getElementsByClassName("CodeMirror"),i=0;i<byClass.length;i++){var cm=byClass[i].CodeMirror;cm&&f(cm)}}function ensureGlobalHandlers(){if(!globalsRegistered){registerGlobalHandlers();globalsRegistered=!0}}function registerGlobalHandlers(){var resizeTimer;on(window,"resize",function(){null==resizeTimer&&(resizeTimer=setTimeout(function(){resizeTimer=null;forEachCodeMirror(onResize)},100))});on(window,"blur",function(){forEachCodeMirror(onBlur)})}function zeroWidthElement(measure){if(null==zwspSupported){var test=elt("span","​");removeChildrenAndAdd(measure,elt("span",[test,document.createTextNode("x")]));0!=measure.firstChild.offsetHeight&&(zwspSupported=test.offsetWidth<=1&&test.offsetHeight>2&&!(ie&&8>ie_version))}var node=zwspSupported?elt("span","​"):elt("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");node.setAttribute("cm-text","");return node}function hasBadBidiRects(measure){if(null!=badBidiRects)return badBidiRects;var txt=removeChildrenAndAdd(measure,document.createTextNode("AخA")),r0=range(txt,0,1).getBoundingClientRect();if(!r0||r0.left==r0.right)return!1;var r1=range(txt,1,2).getBoundingClientRect();return badBidiRects=r1.right-r0.right<3}function hasBadZoomedRects(measure){if(null!=badZoomedRects)return badZoomedRects;var node=removeChildrenAndAdd(measure,elt("span","x")),normal=node.getBoundingClientRect(),fromRange=range(node,0,1).getBoundingClientRect();return badZoomedRects=Math.abs(normal.left-fromRange.left)>1}function iterateBidiSections(order,from,to,f){if(!order)return f(from,to,"ltr");for(var found=!1,i=0;i<order.length;++i){var part=order[i];if(part.from<to&&part.to>from||from==to&&part.to==from){f(Math.max(part.from,from),Math.min(part.to,to),1==part.level?"rtl":"ltr");found=!0}}found||f(from,to,"ltr")}function bidiLeft(part){return part.level%2?part.to:part.from}function bidiRight(part){return part.level%2?part.from:part.to}function lineLeft(line){var order=getOrder(line);return order?bidiLeft(order[0]):0}function lineRight(line){var order=getOrder(line);return order?bidiRight(lst(order)):line.text.length}function lineStart(cm,lineN){var line=getLine(cm.doc,lineN),visual=visualLine(line);visual!=line&&(lineN=lineNo(visual));var order=getOrder(visual),ch=order?order[0].level%2?lineRight(visual):lineLeft(visual):0;return Pos(lineN,ch)}function lineEnd(cm,lineN){for(var merged,line=getLine(cm.doc,lineN);merged=collapsedSpanAtEnd(line);){line=merged.find(1,!0).line;lineN=null}var order=getOrder(line),ch=order?order[0].level%2?lineLeft(line):lineRight(line):line.text.length;return Pos(null==lineN?lineNo(line):lineN,ch)}function lineStartSmart(cm,pos){var start=lineStart(cm,pos.line),line=getLine(cm.doc,start.line),order=getOrder(line);if(!order||0==order[0].level){var firstNonWS=Math.max(0,line.text.search(/\S/)),inWS=pos.line==start.line&&pos.ch<=firstNonWS&&pos.ch;return Pos(start.line,inWS?0:firstNonWS)}return start}function compareBidiLevel(order,a,b){var linedir=order[0].level;return a==linedir?!0:b==linedir?!1:b>a}function getBidiPartAt(order,pos){bidiOther=null;for(var found,i=0;i<order.length;++i){var cur=order[i];if(cur.from<pos&&cur.to>pos)return i;if(cur.from==pos||cur.to==pos){if(null!=found){if(compareBidiLevel(order,cur.level,order[found].level)){cur.from!=cur.to&&(bidiOther=found);return i}cur.from!=cur.to&&(bidiOther=i);return found}found=i}}return found}function moveInLine(line,pos,dir,byUnit){if(!byUnit)return pos+dir;do pos+=dir;while(pos>0&&isExtendingChar(line.text.charAt(pos)));return pos}function moveVisually(line,start,dir,byUnit){var bidi=getOrder(line);if(!bidi)return moveLogically(line,start,dir,byUnit);for(var pos=getBidiPartAt(bidi,start),part=bidi[pos],target=moveInLine(line,start,part.level%2?-dir:dir,byUnit);;){if(target>part.from&&target<part.to)return target;if(target==part.from||target==part.to){if(getBidiPartAt(bidi,target)==pos)return target;part=bidi[pos+=dir];return dir>0==part.level%2?part.to:part.from}part=bidi[pos+=dir];if(!part)return null;target=dir>0==part.level%2?moveInLine(line,part.to,-1,byUnit):moveInLine(line,part.from,1,byUnit)}}function moveLogically(line,start,dir,byUnit){var target=start+dir;if(byUnit)for(;target>0&&isExtendingChar(line.text.charAt(target));)target+=dir;return 0>target||target>line.text.length?null:target}var userAgent=navigator.userAgent,platform=navigator.platform,gecko=/gecko\/\d/i.test(userAgent),ie_upto10=/MSIE \d/.test(userAgent),ie_11up=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent),ie=ie_upto10||ie_11up,ie_version=ie&&(ie_upto10?document.documentMode||6:ie_11up[1]),webkit=/WebKit\//.test(userAgent),qtwebkit=webkit&&/Qt\/\d+\.\d+/.test(userAgent),chrome=/Chrome\//.test(userAgent),presto=/Opera\//.test(userAgent),safari=/Apple Computer/.test(navigator.vendor),mac_geMountainLion=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent),phantom=/PhantomJS/.test(userAgent),ios=/AppleWebKit/.test(userAgent)&&/Mobile\/\w+/.test(userAgent),mobile=ios||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent),mac=ios||/Mac/.test(platform),chromeOS=/\bCrOS\b/.test(userAgent),windows=/win/i.test(platform),presto_version=presto&&userAgent.match(/Version\/(\d*\.\d*)/);presto_version&&(presto_version=Number(presto_version[1]));if(presto_version&&presto_version>=15){presto=!1;webkit=!0}var flipCtrlCmd=mac&&(qtwebkit||presto&&(null==presto_version||12.11>presto_version)),captureRightClick=gecko||ie&&ie_version>=9,sawReadOnlySpans=!1,sawCollapsedSpans=!1;NativeScrollbars.prototype=copyObj({update:function(measure){var needsH=measure.scrollWidth>measure.clientWidth+1,needsV=measure.scrollHeight>measure.clientHeight+1,sWidth=measure.nativeBarWidth;if(needsV){this.vert.style.display="block";this.vert.style.bottom=needsH?sWidth+"px":"0";var totalHeight=measure.viewHeight-(needsH?sWidth:0);this.vert.firstChild.style.height=Math.max(0,measure.scrollHeight-measure.clientHeight+totalHeight)+"px"}else{this.vert.style.display="";this.vert.firstChild.style.height="0"}if(needsH){this.horiz.style.display="block";this.horiz.style.right=needsV?sWidth+"px":"0";this.horiz.style.left=measure.barLeft+"px";var totalWidth=measure.viewWidth-measure.barLeft-(needsV?sWidth:0);this.horiz.firstChild.style.width=measure.scrollWidth-measure.clientWidth+totalWidth+"px"}else{this.horiz.style.display="";this.horiz.firstChild.style.width="0"}if(!this.checkedZeroWidth&&measure.clientHeight>0){0==sWidth&&this.zeroWidthHack();this.checkedZeroWidth=!0}return{right:needsV?sWidth:0,bottom:needsH?sWidth:0}},setScrollLeft:function(pos){this.horiz.scrollLeft!=pos&&(this.horiz.scrollLeft=pos);this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz)},setScrollTop:function(pos){this.vert.scrollTop!=pos&&(this.vert.scrollTop=pos);this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert)},zeroWidthHack:function(){var w=mac&&!mac_geMountainLion?"12px":"18px";this.horiz.style.height=this.vert.style.width=w;this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none";this.disableHoriz=new Delayed;this.disableVert=new Delayed},enableZeroWidthBar:function(bar,delay){function maybeDisable(){var box=bar.getBoundingClientRect(),elt=document.elementFromPoint(box.left+1,box.bottom-1);elt!=bar?bar.style.pointerEvents="none":delay.set(1e3,maybeDisable)}bar.style.pointerEvents="auto";delay.set(1e3,maybeDisable)},clear:function(){var parent=this.horiz.parentNode;parent.removeChild(this.horiz);parent.removeChild(this.vert)}},NativeScrollbars.prototype);NullScrollbars.prototype=copyObj({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},NullScrollbars.prototype);CodeMirror.scrollbarModel={"native":NativeScrollbars,"null":NullScrollbars};DisplayUpdate.prototype.signal=function(emitter,type){hasHandler(emitter,type)&&this.events.push(arguments)};DisplayUpdate.prototype.finish=function(){for(var i=0;i<this.events.length;i++)signal.apply(null,this.events[i])};var Pos=CodeMirror.Pos=function(line,ch){if(!(this instanceof Pos))return new Pos(line,ch);this.line=line;this.ch=ch},cmp=CodeMirror.cmpPos=function(a,b){return a.line-b.line||a.ch-b.ch},lastCopied=null;TextareaInput.prototype=copyObj({init:function(display){function prepareCopyCut(e){if(!signalDOMEvent(cm,e)){if(cm.somethingSelected()){lastCopied=cm.getSelections();if(input.inaccurateSelection){input.prevInput="";input.inaccurateSelection=!1;te.value=lastCopied.join("\n");selectInput(te)}}else{if(!cm.options.lineWiseCopyCut)return;var ranges=copyableRanges(cm);lastCopied=ranges.text;if("cut"==e.type)cm.setSelections(ranges.ranges,null,sel_dontScroll);else{input.prevInput="";te.value=ranges.text.join("\n");selectInput(te)}}"cut"==e.type&&(cm.state.cutIncoming=!0)}}var input=this,cm=this.cm,div=this.wrapper=hiddenTextarea(),te=this.textarea=div.firstChild;display.wrapper.insertBefore(div,display.wrapper.firstChild);ios&&(te.style.width="0px");on(te,"input",function(){ie&&ie_version>=9&&input.hasSelection&&(input.hasSelection=null);input.poll()});on(te,"paste",function(e){if(!signalDOMEvent(cm,e)&&!handlePaste(e,cm)){cm.state.pasteIncoming=!0;input.fastPoll()}});on(te,"cut",prepareCopyCut);on(te,"copy",prepareCopyCut);on(display.scroller,"paste",function(e){if(!eventInWidget(display,e)&&!signalDOMEvent(cm,e)){cm.state.pasteIncoming=!0;input.focus()}});on(display.lineSpace,"selectstart",function(e){eventInWidget(display,e)||e_preventDefault(e)});on(te,"compositionstart",function(){var start=cm.getCursor("from");input.composing&&input.composing.range.clear();input.composing={start:start,range:cm.markText(start,cm.getCursor("to"),{className:"CodeMirror-composing"})}});on(te,"compositionend",function(){if(input.composing){input.poll();input.composing.range.clear();input.composing=null}})},prepareSelection:function(){var cm=this.cm,display=cm.display,doc=cm.doc,result=prepareSelection(cm);if(cm.options.moveInputWithCursor){var headPos=cursorCoords(cm,doc.sel.primary().head,"div"),wrapOff=display.wrapper.getBoundingClientRect(),lineOff=display.lineDiv.getBoundingClientRect();result.teTop=Math.max(0,Math.min(display.wrapper.clientHeight-10,headPos.top+lineOff.top-wrapOff.top));result.teLeft=Math.max(0,Math.min(display.wrapper.clientWidth-10,headPos.left+lineOff.left-wrapOff.left))}return result},showSelection:function(drawn){var cm=this.cm,display=cm.display;removeChildrenAndAdd(display.cursorDiv,drawn.cursors);removeChildrenAndAdd(display.selectionDiv,drawn.selection);if(null!=drawn.teTop){this.wrapper.style.top=drawn.teTop+"px";this.wrapper.style.left=drawn.teLeft+"px"}},reset:function(typing){if(!this.contextMenuPending){var minimal,selected,cm=this.cm,doc=cm.doc;if(cm.somethingSelected()){this.prevInput="";var range=doc.sel.primary();minimal=hasCopyEvent&&(range.to().line-range.from().line>100||(selected=cm.getSelection()).length>1e3);var content=minimal?"-":selected||cm.getSelection();this.textarea.value=content;cm.state.focused&&selectInput(this.textarea);ie&&ie_version>=9&&(this.hasSelection=content)}else if(!typing){this.prevInput=this.textarea.value="";ie&&ie_version>=9&&(this.hasSelection=null)}this.inaccurateSelection=minimal}},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if("nocursor"!=this.cm.options.readOnly&&(!mobile||activeElt()!=this.textarea))try{this.textarea.focus()}catch(e){}},blur:function(){this.textarea.blur()},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var input=this;input.pollingFast||input.polling.set(this.cm.options.pollInterval,function(){input.poll();input.cm.state.focused&&input.slowPoll()})},fastPoll:function(){function p(){var changed=input.poll();if(changed||missed){input.pollingFast=!1;input.slowPoll()}else{missed=!0;input.polling.set(60,p)}}var missed=!1,input=this;input.pollingFast=!0;input.polling.set(20,p)},poll:function(){var cm=this.cm,input=this.textarea,prevInput=this.prevInput;if(this.contextMenuPending||!cm.state.focused||hasSelection(input)&&!prevInput&&!this.composing||cm.isReadOnly()||cm.options.disableInput||cm.state.keySeq)return!1;var text=input.value;if(text==prevInput&&!cm.somethingSelected())return!1;if(ie&&ie_version>=9&&this.hasSelection===text||mac&&/[\uf700-\uf7ff]/.test(text)){cm.display.input.reset();return!1}if(cm.doc.sel==cm.display.selForContextMenu){var first=text.charCodeAt(0);8203!=first||prevInput||(prevInput="​");if(8666==first){this.reset();return this.cm.execCommand("undo")}}for(var same=0,l=Math.min(prevInput.length,text.length);l>same&&prevInput.charCodeAt(same)==text.charCodeAt(same);)++same;var self=this;runInOp(cm,function(){applyTextInput(cm,text.slice(same),prevInput.length-same,null,self.composing?"*compose":null);text.length>1e3||text.indexOf("\n")>-1?input.value=self.prevInput="":self.prevInput=text;if(self.composing){self.composing.range.clear();self.composing.range=cm.markText(self.composing.start,cm.getCursor("to"),{className:"CodeMirror-composing"})}});return!0},ensurePolled:function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},onKeyPress:function(){ie&&ie_version>=9&&(this.hasSelection=null);this.fastPoll()},onContextMenu:function(e){function prepareSelectAllHack(){if(null!=te.selectionStart){var selected=cm.somethingSelected(),extval="​"+(selected?te.value:"");te.value="⇚";te.value=extval;input.prevInput=selected?"":"​";te.selectionStart=1;te.selectionEnd=extval.length;display.selForContextMenu=cm.doc.sel}}function rehide(){input.contextMenuPending=!1;input.wrapper.style.cssText=oldWrapperCSS;te.style.cssText=oldCSS;ie&&9>ie_version&&display.scrollbars.setScrollTop(display.scroller.scrollTop=scrollPos);if(null!=te.selectionStart){(!ie||ie&&9>ie_version)&&prepareSelectAllHack();var i=0,poll=function(){display.selForContextMenu==cm.doc.sel&&0==te.selectionStart&&te.selectionEnd>0&&"​"==input.prevInput?operation(cm,commands.selectAll)(cm):i++<10?display.detectingSelectAll=setTimeout(poll,500):display.input.reset()};display.detectingSelectAll=setTimeout(poll,200)}}var input=this,cm=input.cm,display=cm.display,te=input.textarea,pos=posFromMouse(cm,e),scrollPos=display.scroller.scrollTop;if(pos&&!presto){var reset=cm.options.resetSelectionOnContextMenu;reset&&-1==cm.doc.sel.contains(pos)&&operation(cm,setSelection)(cm.doc,simpleSelection(pos),sel_dontScroll);var oldCSS=te.style.cssText,oldWrapperCSS=input.wrapper.style.cssText;input.wrapper.style.cssText="position: absolute";var wrapperBox=input.wrapper.getBoundingClientRect();te.style.cssText="position: absolute; width: 30px; height: 30px; top: "+(e.clientY-wrapperBox.top-5)+"px; left: "+(e.clientX-wrapperBox.left-5)+"px; z-index: 1000; background: "+(ie?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";if(webkit)var oldScrollY=window.scrollY;display.input.focus();webkit&&window.scrollTo(null,oldScrollY);display.input.reset();cm.somethingSelected()||(te.value=input.prevInput=" ");input.contextMenuPending=!0;display.selForContextMenu=cm.doc.sel;clearTimeout(display.detectingSelectAll);ie&&ie_version>=9&&prepareSelectAllHack();if(captureRightClick){e_stop(e);var mouseup=function(){off(window,"mouseup",mouseup);setTimeout(rehide,20)};on(window,"mouseup",mouseup)}else setTimeout(rehide,50)}},readOnlyChanged:function(val){val||this.reset()},setUneditable:nothing,needsContentAttribute:!1},TextareaInput.prototype);ContentEditableInput.prototype=copyObj({init:function(display){function onCopyCut(e){if(!signalDOMEvent(cm,e)){if(cm.somethingSelected()){lastCopied=cm.getSelections();"cut"==e.type&&cm.replaceSelection("",null,"cut")}else{if(!cm.options.lineWiseCopyCut)return;var ranges=copyableRanges(cm);lastCopied=ranges.text;"cut"==e.type&&cm.operation(function(){cm.setSelections(ranges.ranges,0,sel_dontScroll);cm.replaceSelection("",null,"cut")})}if(e.clipboardData&&!ios){e.preventDefault();e.clipboardData.clearData();e.clipboardData.setData("text/plain",lastCopied.join("\n"))}else{var kludge=hiddenTextarea(),te=kludge.firstChild;cm.display.lineSpace.insertBefore(kludge,cm.display.lineSpace.firstChild);te.value=lastCopied.join("\n");var hadFocus=document.activeElement;selectInput(te);setTimeout(function(){cm.display.lineSpace.removeChild(kludge);hadFocus.focus()},50)}}}var input=this,cm=input.cm,div=input.div=display.lineDiv;disableBrowserMagic(div);on(div,"paste",function(e){signalDOMEvent(cm,e)||handlePaste(e,cm)});on(div,"compositionstart",function(e){var data=e.data;input.composing={sel:cm.doc.sel,data:data,startData:data};if(data){var prim=cm.doc.sel.primary(),line=cm.getLine(prim.head.line),found=line.indexOf(data,Math.max(0,prim.head.ch-data.length));found>-1&&found<=prim.head.ch&&(input.composing.sel=simpleSelection(Pos(prim.head.line,found),Pos(prim.head.line,found+data.length)))}});on(div,"compositionupdate",function(e){input.composing.data=e.data});on(div,"compositionend",function(e){var ours=input.composing;if(ours){e.data==ours.startData||/\u200b/.test(e.data)||(ours.data=e.data);setTimeout(function(){ours.handled||input.applyComposition(ours);input.composing==ours&&(input.composing=null)},50)}});on(div,"touchstart",function(){input.forceCompositionEnd()});on(div,"input",function(){input.composing||(cm.isReadOnly()||!input.pollContent())&&runInOp(input.cm,function(){regChange(cm)})});on(div,"copy",onCopyCut);on(div,"cut",onCopyCut)},prepareSelection:function(){var result=prepareSelection(this.cm,!1);result.focus=this.cm.state.focused;return result},showSelection:function(info){if(info&&this.cm.display.view.length){info.focus&&this.showPrimarySelection();this.showMultipleSelections(info)}},showPrimarySelection:function(){var sel=window.getSelection(),prim=this.cm.doc.sel.primary(),curAnchor=domToPos(this.cm,sel.anchorNode,sel.anchorOffset),curFocus=domToPos(this.cm,sel.focusNode,sel.focusOffset);if(!curAnchor||curAnchor.bad||!curFocus||curFocus.bad||0!=cmp(minPos(curAnchor,curFocus),prim.from())||0!=cmp(maxPos(curAnchor,curFocus),prim.to())){var start=posToDOM(this.cm,prim.from()),end=posToDOM(this.cm,prim.to());if(start||end){var view=this.cm.display.view,old=sel.rangeCount&&sel.getRangeAt(0);if(start){if(!end){var measure=view[view.length-1].measure,map=measure.maps?measure.maps[measure.maps.length-1]:measure.map;end={node:map[map.length-1],offset:map[map.length-2]-map[map.length-3]}}}else start={node:view[0].measure.map[2],offset:0};try{var rng=range(start.node,start.offset,end.offset,end.node)}catch(e){}if(rng){if(!gecko&&this.cm.state.focused){sel.collapse(start.node,start.offset);rng.collapsed||sel.addRange(rng)}else{sel.removeAllRanges();sel.addRange(rng)}old&&null==sel.anchorNode?sel.addRange(old):gecko&&this.startGracePeriod()}this.rememberSelection()}}},startGracePeriod:function(){var input=this;clearTimeout(this.gracePeriod);this.gracePeriod=setTimeout(function(){input.gracePeriod=!1;input.selectionChanged()&&input.cm.operation(function(){input.cm.curOp.selectionChanged=!0})},20)},showMultipleSelections:function(info){removeChildrenAndAdd(this.cm.display.cursorDiv,info.cursors);removeChildrenAndAdd(this.cm.display.selectionDiv,info.selection)},rememberSelection:function(){var sel=window.getSelection();this.lastAnchorNode=sel.anchorNode;this.lastAnchorOffset=sel.anchorOffset;this.lastFocusNode=sel.focusNode;this.lastFocusOffset=sel.focusOffset},selectionInEditor:function(){var sel=window.getSelection();if(!sel.rangeCount)return!1;var node=sel.getRangeAt(0).commonAncestorContainer;return contains(this.div,node)},focus:function(){"nocursor"!=this.cm.options.readOnly&&this.div.focus()},blur:function(){this.div.blur()},getField:function(){return this.div},supportsTouch:function(){return!0},receivedFocus:function(){function poll(){if(input.cm.state.focused){input.pollSelection();input.polling.set(input.cm.options.pollInterval,poll)}}var input=this;this.selectionInEditor()?this.pollSelection():runInOp(this.cm,function(){input.cm.curOp.selectionChanged=!0});this.polling.set(this.cm.options.pollInterval,poll)},selectionChanged:function(){var sel=window.getSelection();return sel.anchorNode!=this.lastAnchorNode||sel.anchorOffset!=this.lastAnchorOffset||sel.focusNode!=this.lastFocusNode||sel.focusOffset!=this.lastFocusOffset},pollSelection:function(){if(!this.composing&&!this.gracePeriod&&this.selectionChanged()){var sel=window.getSelection(),cm=this.cm;this.rememberSelection();var anchor=domToPos(cm,sel.anchorNode,sel.anchorOffset),head=domToPos(cm,sel.focusNode,sel.focusOffset);anchor&&head&&runInOp(cm,function(){setSelection(cm.doc,simpleSelection(anchor,head),sel_dontScroll);(anchor.bad||head.bad)&&(cm.curOp.selectionChanged=!0)})}},pollContent:function(){var cm=this.cm,display=cm.display,sel=cm.doc.sel.primary(),from=sel.from(),to=sel.to();if(from.line<display.viewFrom||to.line>display.viewTo-1)return!1;var fromIndex;if(from.line==display.viewFrom||0==(fromIndex=findViewIndex(cm,from.line)))var fromLine=lineNo(display.view[0].line),fromNode=display.view[0].node;else var fromLine=lineNo(display.view[fromIndex].line),fromNode=display.view[fromIndex-1].node.nextSibling;var toIndex=findViewIndex(cm,to.line);if(toIndex==display.view.length-1)var toLine=display.viewTo-1,toNode=display.lineDiv.lastChild;else var toLine=lineNo(display.view[toIndex+1].line)-1,toNode=display.view[toIndex+1].node.previousSibling;for(var newText=cm.doc.splitLines(domTextBetween(cm,fromNode,toNode,fromLine,toLine)),oldText=getBetween(cm.doc,Pos(fromLine,0),Pos(toLine,getLine(cm.doc,toLine).text.length));newText.length>1&&oldText.length>1;)if(lst(newText)==lst(oldText)){newText.pop();oldText.pop();toLine--}else{if(newText[0]!=oldText[0])break;newText.shift();oldText.shift();fromLine++}for(var cutFront=0,cutEnd=0,newTop=newText[0],oldTop=oldText[0],maxCutFront=Math.min(newTop.length,oldTop.length);maxCutFront>cutFront&&newTop.charCodeAt(cutFront)==oldTop.charCodeAt(cutFront);)++cutFront;for(var newBot=lst(newText),oldBot=lst(oldText),maxCutEnd=Math.min(newBot.length-(1==newText.length?cutFront:0),oldBot.length-(1==oldText.length?cutFront:0));maxCutEnd>cutEnd&&newBot.charCodeAt(newBot.length-cutEnd-1)==oldBot.charCodeAt(oldBot.length-cutEnd-1);)++cutEnd;newText[newText.length-1]=newBot.slice(0,newBot.length-cutEnd);newText[0]=newText[0].slice(cutFront);var chFrom=Pos(fromLine,cutFront),chTo=Pos(toLine,oldText.length?lst(oldText).length-cutEnd:0);if(newText.length>1||newText[0]||cmp(chFrom,chTo)){replaceRange(cm.doc,newText,chFrom,chTo,"+input");return!0}},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){if(this.composing&&!this.composing.handled){this.applyComposition(this.composing);this.composing.handled=!0;this.div.blur();this.div.focus()}},applyComposition:function(composing){this.cm.isReadOnly()?operation(this.cm,regChange)(this.cm):composing.data&&composing.data!=composing.startData&&operation(this.cm,applyTextInput)(this.cm,composing.data,0,composing.sel)},setUneditable:function(node){node.contentEditable="false"},onKeyPress:function(e){e.preventDefault();this.cm.isReadOnly()||operation(this.cm,applyTextInput)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0)},readOnlyChanged:function(val){this.div.contentEditable=String("nocursor"!=val)},onContextMenu:nothing,resetPosition:nothing,needsContentAttribute:!0
6
+ },ContentEditableInput.prototype);CodeMirror.inputStyles={textarea:TextareaInput,contenteditable:ContentEditableInput};Selection.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(other){if(other==this)return!0;if(other.primIndex!=this.primIndex||other.ranges.length!=this.ranges.length)return!1;for(var i=0;i<this.ranges.length;i++){var here=this.ranges[i],there=other.ranges[i];if(0!=cmp(here.anchor,there.anchor)||0!=cmp(here.head,there.head))return!1}return!0},deepCopy:function(){for(var out=[],i=0;i<this.ranges.length;i++)out[i]=new Range(copyPos(this.ranges[i].anchor),copyPos(this.ranges[i].head));return new Selection(out,this.primIndex)},somethingSelected:function(){for(var i=0;i<this.ranges.length;i++)if(!this.ranges[i].empty())return!0;return!1},contains:function(pos,end){end||(end=pos);for(var i=0;i<this.ranges.length;i++){var range=this.ranges[i];if(cmp(end,range.from())>=0&&cmp(pos,range.to())<=0)return i}return-1}};Range.prototype={from:function(){return minPos(this.anchor,this.head)},to:function(){return maxPos(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var measureText,lastClick,lastDoubleClick,nullRect={left:0,right:0,top:0,bottom:0},operationGroup=null,nextOpId=0,lastDrop=0,wheelSamples=0,wheelPixelsPerUnit=null;ie?wheelPixelsPerUnit=-.53:gecko?wheelPixelsPerUnit=15:chrome?wheelPixelsPerUnit=-.7:safari&&(wheelPixelsPerUnit=-1/3);var wheelEventDelta=function(e){var dx=e.wheelDeltaX,dy=e.wheelDeltaY;null==dx&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(dx=e.detail);null==dy&&e.detail&&e.axis==e.VERTICAL_AXIS?dy=e.detail:null==dy&&(dy=e.wheelDelta);return{x:dx,y:dy}};CodeMirror.wheelEventPixels=function(e){var delta=wheelEventDelta(e);delta.x*=wheelPixelsPerUnit;delta.y*=wheelPixelsPerUnit;return delta};var stopSeq=new Delayed,lastStoppedKey=null,changeEnd=CodeMirror.changeEnd=function(change){return change.text?Pos(change.from.line+change.text.length-1,lst(change.text).length+(1==change.text.length?change.from.ch:0)):change.to};CodeMirror.prototype={constructor:CodeMirror,focus:function(){window.focus();this.display.input.focus()},setOption:function(option,value){var options=this.options,old=options[option];if(options[option]!=value||"mode"==option){options[option]=value;optionHandlers.hasOwnProperty(option)&&operation(this,optionHandlers[option])(this,value,old)}},getOption:function(option){return this.options[option]},getDoc:function(){return this.doc},addKeyMap:function(map,bottom){this.state.keyMaps[bottom?"push":"unshift"](getKeyMap(map))},removeKeyMap:function(map){for(var maps=this.state.keyMaps,i=0;i<maps.length;++i)if(maps[i]==map||maps[i].name==map){maps.splice(i,1);return!0}},addOverlay:methodOp(function(spec,options){var mode=spec.token?spec:CodeMirror.getMode(this.options,spec);if(mode.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:mode,modeSpec:spec,opaque:options&&options.opaque});this.state.modeGen++;regChange(this)}),removeOverlay:methodOp(function(spec){for(var overlays=this.state.overlays,i=0;i<overlays.length;++i){var cur=overlays[i].modeSpec;if(cur==spec||"string"==typeof spec&&cur.name==spec){overlays.splice(i,1);this.state.modeGen++;regChange(this);return}}}),indentLine:methodOp(function(n,dir,aggressive){"string"!=typeof dir&&"number"!=typeof dir&&(dir=null==dir?this.options.smartIndent?"smart":"prev":dir?"add":"subtract");isLine(this.doc,n)&&indentLine(this,n,dir,aggressive)}),indentSelection:methodOp(function(how){for(var ranges=this.doc.sel.ranges,end=-1,i=0;i<ranges.length;i++){var range=ranges[i];if(range.empty()){if(range.head.line>end){indentLine(this,range.head.line,how,!0);end=range.head.line;i==this.doc.sel.primIndex&&ensureCursorVisible(this)}}else{var from=range.from(),to=range.to(),start=Math.max(end,from.line);end=Math.min(this.lastLine(),to.line-(to.ch?0:1))+1;for(var j=start;end>j;++j)indentLine(this,j,how);var newRanges=this.doc.sel.ranges;0==from.ch&&ranges.length==newRanges.length&&newRanges[i].from().ch>0&&replaceOneSelection(this.doc,i,new Range(from,newRanges[i].to()),sel_dontScroll)}}}),getTokenAt:function(pos,precise){return takeToken(this,pos,precise)},getLineTokens:function(line,precise){return takeToken(this,Pos(line),precise,!0)},getTokenTypeAt:function(pos){pos=clipPos(this.doc,pos);var type,styles=getLineStyles(this,getLine(this.doc,pos.line)),before=0,after=(styles.length-1)/2,ch=pos.ch;if(0==ch)type=styles[2];else for(;;){var mid=before+after>>1;if((mid?styles[2*mid-1]:0)>=ch)after=mid;else{if(!(styles[2*mid+1]<ch)){type=styles[2*mid+2];break}before=mid+1}}var cut=type?type.indexOf("cm-overlay "):-1;return 0>cut?type:0==cut?null:type.slice(0,cut-1)},getModeAt:function(pos){var mode=this.doc.mode;return mode.innerMode?CodeMirror.innerMode(mode,this.getTokenAt(pos).state).mode:mode},getHelper:function(pos,type){return this.getHelpers(pos,type)[0]},getHelpers:function(pos,type){var found=[];if(!helpers.hasOwnProperty(type))return found;var help=helpers[type],mode=this.getModeAt(pos);if("string"==typeof mode[type])help[mode[type]]&&found.push(help[mode[type]]);else if(mode[type])for(var i=0;i<mode[type].length;i++){var val=help[mode[type][i]];val&&found.push(val)}else mode.helperType&&help[mode.helperType]?found.push(help[mode.helperType]):help[mode.name]&&found.push(help[mode.name]);for(var i=0;i<help._global.length;i++){var cur=help._global[i];cur.pred(mode,this)&&-1==indexOf(found,cur.val)&&found.push(cur.val)}return found},getStateAfter:function(line,precise){var doc=this.doc;line=clipLine(doc,null==line?doc.first+doc.size-1:line);return getStateBefore(this,line+1,precise)},cursorCoords:function(start,mode){var pos,range=this.doc.sel.primary();pos=null==start?range.head:"object"==typeof start?clipPos(this.doc,start):start?range.from():range.to();return cursorCoords(this,pos,mode||"page")},charCoords:function(pos,mode){return charCoords(this,clipPos(this.doc,pos),mode||"page")},coordsChar:function(coords,mode){coords=fromCoordSystem(this,coords,mode||"page");return coordsChar(this,coords.left,coords.top)},lineAtHeight:function(height,mode){height=fromCoordSystem(this,{top:height,left:0},mode||"page").top;return lineAtHeight(this.doc,height+this.display.viewOffset)},heightAtLine:function(line,mode){var lineObj,end=!1;if("number"==typeof line){var last=this.doc.first+this.doc.size-1;if(line<this.doc.first)line=this.doc.first;else if(line>last){line=last;end=!0}lineObj=getLine(this.doc,line)}else lineObj=line;return intoCoordSystem(this,lineObj,{top:0,left:0},mode||"page").top+(end?this.doc.height-heightAtLine(lineObj):0)},defaultTextHeight:function(){return textHeight(this.display)},defaultCharWidth:function(){return charWidth(this.display)},setGutterMarker:methodOp(function(line,gutterID,value){return changeLine(this.doc,line,"gutter",function(line){var markers=line.gutterMarkers||(line.gutterMarkers={});markers[gutterID]=value;!value&&isEmpty(markers)&&(line.gutterMarkers=null);return!0})}),clearGutter:methodOp(function(gutterID){var cm=this,doc=cm.doc,i=doc.first;doc.iter(function(line){if(line.gutterMarkers&&line.gutterMarkers[gutterID]){line.gutterMarkers[gutterID]=null;regLineChange(cm,i,"gutter");isEmpty(line.gutterMarkers)&&(line.gutterMarkers=null)}++i})}),lineInfo:function(line){if("number"==typeof line){if(!isLine(this.doc,line))return null;var n=line;line=getLine(this.doc,line);if(!line)return null}else{var n=lineNo(line);if(null==n)return null}return{line:n,handle:line,text:line.text,gutterMarkers:line.gutterMarkers,textClass:line.textClass,bgClass:line.bgClass,wrapClass:line.wrapClass,widgets:line.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(pos,node,scroll,vert,horiz){var display=this.display;pos=cursorCoords(this,clipPos(this.doc,pos));var top=pos.bottom,left=pos.left;node.style.position="absolute";node.setAttribute("cm-ignore-events","true");this.display.input.setUneditable(node);display.sizer.appendChild(node);if("over"==vert)top=pos.top;else if("above"==vert||"near"==vert){var vspace=Math.max(display.wrapper.clientHeight,this.doc.height),hspace=Math.max(display.sizer.clientWidth,display.lineSpace.clientWidth);("above"==vert||pos.bottom+node.offsetHeight>vspace)&&pos.top>node.offsetHeight?top=pos.top-node.offsetHeight:pos.bottom+node.offsetHeight<=vspace&&(top=pos.bottom);left+node.offsetWidth>hspace&&(left=hspace-node.offsetWidth)}node.style.top=top+"px";node.style.left=node.style.right="";if("right"==horiz){left=display.sizer.clientWidth-node.offsetWidth;node.style.right="0px"}else{"left"==horiz?left=0:"middle"==horiz&&(left=(display.sizer.clientWidth-node.offsetWidth)/2);node.style.left=left+"px"}scroll&&scrollIntoView(this,left,top,left+node.offsetWidth,top+node.offsetHeight)},triggerOnKeyDown:methodOp(onKeyDown),triggerOnKeyPress:methodOp(onKeyPress),triggerOnKeyUp:onKeyUp,execCommand:function(cmd){return commands.hasOwnProperty(cmd)?commands[cmd].call(null,this):void 0},triggerElectric:methodOp(function(text){triggerElectric(this,text)}),findPosH:function(from,amount,unit,visually){var dir=1;if(0>amount){dir=-1;amount=-amount}for(var i=0,cur=clipPos(this.doc,from);amount>i;++i){cur=findPosH(this.doc,cur,dir,unit,visually);if(cur.hitSide)break}return cur},moveH:methodOp(function(dir,unit){var cm=this;cm.extendSelectionsBy(function(range){return cm.display.shift||cm.doc.extend||range.empty()?findPosH(cm.doc,range.head,dir,unit,cm.options.rtlMoveVisually):0>dir?range.from():range.to()},sel_move)}),deleteH:methodOp(function(dir,unit){var sel=this.doc.sel,doc=this.doc;sel.somethingSelected()?doc.replaceSelection("",null,"+delete"):deleteNearSelection(this,function(range){var other=findPosH(doc,range.head,dir,unit,!1);return 0>dir?{from:other,to:range.head}:{from:range.head,to:other}})}),findPosV:function(from,amount,unit,goalColumn){var dir=1,x=goalColumn;if(0>amount){dir=-1;amount=-amount}for(var i=0,cur=clipPos(this.doc,from);amount>i;++i){var coords=cursorCoords(this,cur,"div");null==x?x=coords.left:coords.left=x;cur=findPosV(this,coords,dir,unit);if(cur.hitSide)break}return cur},moveV:methodOp(function(dir,unit){var cm=this,doc=this.doc,goals=[],collapse=!cm.display.shift&&!doc.extend&&doc.sel.somethingSelected();doc.extendSelectionsBy(function(range){if(collapse)return 0>dir?range.from():range.to();var headPos=cursorCoords(cm,range.head,"div");null!=range.goalColumn&&(headPos.left=range.goalColumn);goals.push(headPos.left);var pos=findPosV(cm,headPos,dir,unit);"page"==unit&&range==doc.sel.primary()&&addToScrollPos(cm,null,charCoords(cm,pos,"div").top-headPos.top);return pos},sel_move);if(goals.length)for(var i=0;i<doc.sel.ranges.length;i++)doc.sel.ranges[i].goalColumn=goals[i]}),findWordAt:function(pos){var doc=this.doc,line=getLine(doc,pos.line).text,start=pos.ch,end=pos.ch;if(line){var helper=this.getHelper(pos,"wordChars");(pos.xRel<0||end==line.length)&&start?--start:++end;for(var startChar=line.charAt(start),check=isWordChar(startChar,helper)?function(ch){return isWordChar(ch,helper)}:/\s/.test(startChar)?function(ch){return/\s/.test(ch)}:function(ch){return!/\s/.test(ch)&&!isWordChar(ch)};start>0&&check(line.charAt(start-1));)--start;for(;end<line.length&&check(line.charAt(end));)++end}return new Range(Pos(pos.line,start),Pos(pos.line,end))},toggleOverwrite:function(value){if(null==value||value!=this.state.overwrite){(this.state.overwrite=!this.state.overwrite)?addClass(this.display.cursorDiv,"CodeMirror-overwrite"):rmClass(this.display.cursorDiv,"CodeMirror-overwrite");signal(this,"overwriteToggle",this,this.state.overwrite)}},hasFocus:function(){return this.display.input.getField()==activeElt()},isReadOnly:function(){return!(!this.options.readOnly&&!this.doc.cantEdit)},scrollTo:methodOp(function(x,y){(null!=x||null!=y)&&resolveScrollToPos(this);null!=x&&(this.curOp.scrollLeft=x);null!=y&&(this.curOp.scrollTop=y)}),getScrollInfo:function(){var scroller=this.display.scroller;return{left:scroller.scrollLeft,top:scroller.scrollTop,height:scroller.scrollHeight-scrollGap(this)-this.display.barHeight,width:scroller.scrollWidth-scrollGap(this)-this.display.barWidth,clientHeight:displayHeight(this),clientWidth:displayWidth(this)}},scrollIntoView:methodOp(function(range,margin){if(null==range){range={from:this.doc.sel.primary().head,to:null};null==margin&&(margin=this.options.cursorScrollMargin)}else"number"==typeof range?range={from:Pos(range,0),to:null}:null==range.from&&(range={from:range,to:null});range.to||(range.to=range.from);range.margin=margin||0;if(null!=range.from.line){resolveScrollToPos(this);this.curOp.scrollToPos=range}else{var sPos=calculateScrollPos(this,Math.min(range.from.left,range.to.left),Math.min(range.from.top,range.to.top)-range.margin,Math.max(range.from.right,range.to.right),Math.max(range.from.bottom,range.to.bottom)+range.margin);this.scrollTo(sPos.scrollLeft,sPos.scrollTop)}}),setSize:methodOp(function(width,height){function interpret(val){return"number"==typeof val||/^\d+$/.test(String(val))?val+"px":val}var cm=this;null!=width&&(cm.display.wrapper.style.width=interpret(width));null!=height&&(cm.display.wrapper.style.height=interpret(height));cm.options.lineWrapping&&clearLineMeasurementCache(this);var lineNo=cm.display.viewFrom;cm.doc.iter(lineNo,cm.display.viewTo,function(line){if(line.widgets)for(var i=0;i<line.widgets.length;i++)if(line.widgets[i].noHScroll){regLineChange(cm,lineNo,"widget");break}++lineNo});cm.curOp.forceUpdate=!0;signal(cm,"refresh",this)}),operation:function(f){return runInOp(this,f)},refresh:methodOp(function(){var oldHeight=this.display.cachedTextHeight;regChange(this);this.curOp.forceUpdate=!0;clearCaches(this);this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop);updateGutterSpace(this);(null==oldHeight||Math.abs(oldHeight-textHeight(this.display))>.5)&&estimateLineHeights(this);signal(this,"refresh",this)}),swapDoc:methodOp(function(doc){var old=this.doc;old.cm=null;attachDoc(this,doc);clearCaches(this);this.display.input.reset();this.scrollTo(doc.scrollLeft,doc.scrollTop);this.curOp.forceScroll=!0;signalLater(this,"swapDoc",this,old);return old}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}};eventMixin(CodeMirror);var defaults=CodeMirror.defaults={},optionHandlers=CodeMirror.optionHandlers={},Init=CodeMirror.Init={toString:function(){return"CodeMirror.Init"}};option("value","",function(cm,val){cm.setValue(val)},!0);option("mode",null,function(cm,val){cm.doc.modeOption=val;loadMode(cm)},!0);option("indentUnit",2,loadMode,!0);option("indentWithTabs",!1);option("smartIndent",!0);option("tabSize",4,function(cm){resetModeState(cm);clearCaches(cm);regChange(cm)},!0);option("lineSeparator",null,function(cm,val){cm.doc.lineSep=val;if(val){var newBreaks=[],lineNo=cm.doc.first;cm.doc.iter(function(line){for(var pos=0;;){var found=line.text.indexOf(val,pos);if(-1==found)break;pos=found+val.length;newBreaks.push(Pos(lineNo,found))}lineNo++});for(var i=newBreaks.length-1;i>=0;i--)replaceRange(cm.doc,val,newBreaks[i],Pos(newBreaks[i].line,newBreaks[i].ch+val.length))}});option("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(cm,val,old){cm.state.specialChars=new RegExp(val.source+(val.test(" ")?"":"| "),"g");old!=CodeMirror.Init&&cm.refresh()});option("specialCharPlaceholder",defaultSpecialCharPlaceholder,function(cm){cm.refresh()},!0);option("electricChars",!0);option("inputStyle",mobile?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0);option("rtlMoveVisually",!windows);option("wholeLineUpdateBefore",!0);option("theme","default",function(cm){themeChanged(cm);guttersChanged(cm)},!0);option("keyMap","default",function(cm,val,old){var next=getKeyMap(val),prev=old!=CodeMirror.Init&&getKeyMap(old);prev&&prev.detach&&prev.detach(cm,next);next.attach&&next.attach(cm,prev||null)});option("extraKeys",null);option("lineWrapping",!1,wrappingChanged,!0);option("gutters",[],function(cm){setGuttersForLineNumbers(cm.options);guttersChanged(cm)},!0);option("fixedGutter",!0,function(cm,val){cm.display.gutters.style.left=val?compensateForHScroll(cm.display)+"px":"0";cm.refresh()},!0);option("coverGutterNextToScrollbar",!1,function(cm){updateScrollbars(cm)},!0);option("scrollbarStyle","native",function(cm){initScrollbars(cm);updateScrollbars(cm);cm.display.scrollbars.setScrollTop(cm.doc.scrollTop);cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft)},!0);option("lineNumbers",!1,function(cm){setGuttersForLineNumbers(cm.options);guttersChanged(cm)},!0);option("firstLineNumber",1,guttersChanged,!0);option("lineNumberFormatter",function(integer){return integer},guttersChanged,!0);option("showCursorWhenSelecting",!1,updateSelection,!0);option("resetSelectionOnContextMenu",!0);option("lineWiseCopyCut",!0);option("readOnly",!1,function(cm,val){if("nocursor"==val){onBlur(cm);cm.display.input.blur();cm.display.disabled=!0}else cm.display.disabled=!1;cm.display.input.readOnlyChanged(val)});option("disableInput",!1,function(cm,val){val||cm.display.input.reset()},!0);option("dragDrop",!0,dragDropChanged);option("allowDropFileTypes",null);option("cursorBlinkRate",530);option("cursorScrollMargin",0);option("cursorHeight",1,updateSelection,!0);option("singleCursorHeightPerLine",!0,updateSelection,!0);option("workTime",100);option("workDelay",100);option("flattenSpans",!0,resetModeState,!0);option("addModeClass",!1,resetModeState,!0);option("pollInterval",100);option("undoDepth",200,function(cm,val){cm.doc.history.undoDepth=val});option("historyEventDelay",1250);option("viewportMargin",10,function(cm){cm.refresh()},!0);option("maxHighlightLength",1e4,resetModeState,!0);option("moveInputWithCursor",!0,function(cm,val){val||cm.display.input.resetPosition()});option("tabindex",null,function(cm,val){cm.display.input.getField().tabIndex=val||""});option("autofocus",null);var modes=CodeMirror.modes={},mimeModes=CodeMirror.mimeModes={};CodeMirror.defineMode=function(name,mode){CodeMirror.defaults.mode||"null"==name||(CodeMirror.defaults.mode=name);arguments.length>2&&(mode.dependencies=Array.prototype.slice.call(arguments,2));modes[name]=mode};CodeMirror.defineMIME=function(mime,spec){mimeModes[mime]=spec};CodeMirror.resolveMode=function(spec){if("string"==typeof spec&&mimeModes.hasOwnProperty(spec))spec=mimeModes[spec];else if(spec&&"string"==typeof spec.name&&mimeModes.hasOwnProperty(spec.name)){var found=mimeModes[spec.name];"string"==typeof found&&(found={name:found});spec=createObj(found,spec);spec.name=found.name}else if("string"==typeof spec&&/^[\w\-]+\/[\w\-]+\+xml$/.test(spec))return CodeMirror.resolveMode("application/xml");return"string"==typeof spec?{name:spec}:spec||{name:"null"}};CodeMirror.getMode=function(options,spec){var spec=CodeMirror.resolveMode(spec),mfactory=modes[spec.name];if(!mfactory)return CodeMirror.getMode(options,"text/plain");var modeObj=mfactory(options,spec);if(modeExtensions.hasOwnProperty(spec.name)){var exts=modeExtensions[spec.name];for(var prop in exts)if(exts.hasOwnProperty(prop)){modeObj.hasOwnProperty(prop)&&(modeObj["_"+prop]=modeObj[prop]);modeObj[prop]=exts[prop]}}modeObj.name=spec.name;spec.helperType&&(modeObj.helperType=spec.helperType);if(spec.modeProps)for(var prop in spec.modeProps)modeObj[prop]=spec.modeProps[prop];return modeObj};CodeMirror.defineMode("null",function(){return{token:function(stream){stream.skipToEnd()}}});CodeMirror.defineMIME("text/plain","null");var modeExtensions=CodeMirror.modeExtensions={};CodeMirror.extendMode=function(mode,properties){var exts=modeExtensions.hasOwnProperty(mode)?modeExtensions[mode]:modeExtensions[mode]={};copyObj(properties,exts)};CodeMirror.defineExtension=function(name,func){CodeMirror.prototype[name]=func};CodeMirror.defineDocExtension=function(name,func){Doc.prototype[name]=func};CodeMirror.defineOption=option;var initHooks=[];CodeMirror.defineInitHook=function(f){initHooks.push(f)};var helpers=CodeMirror.helpers={};CodeMirror.registerHelper=function(type,name,value){helpers.hasOwnProperty(type)||(helpers[type]=CodeMirror[type]={_global:[]});helpers[type][name]=value};CodeMirror.registerGlobalHelper=function(type,name,predicate,value){CodeMirror.registerHelper(type,name,value);helpers[type]._global.push({pred:predicate,val:value})};var copyState=CodeMirror.copyState=function(mode,state){if(state===!0)return state;if(mode.copyState)return mode.copyState(state);var nstate={};for(var n in state){var val=state[n];val instanceof Array&&(val=val.concat([]));nstate[n]=val}return nstate},startState=CodeMirror.startState=function(mode,a1,a2){return mode.startState?mode.startState(a1,a2):!0};CodeMirror.innerMode=function(mode,state){for(;mode.innerMode;){var info=mode.innerMode(state);if(!info||info.mode==mode)break;state=info.state;mode=info.mode}return info||{mode:mode,state:state}};var commands=CodeMirror.commands={selectAll:function(cm){cm.setSelection(Pos(cm.firstLine(),0),Pos(cm.lastLine()),sel_dontScroll)},singleSelection:function(cm){cm.setSelection(cm.getCursor("anchor"),cm.getCursor("head"),sel_dontScroll)},killLine:function(cm){deleteNearSelection(cm,function(range){if(range.empty()){var len=getLine(cm.doc,range.head.line).text.length;return range.head.ch==len&&range.head.line<cm.lastLine()?{from:range.head,to:Pos(range.head.line+1,0)}:{from:range.head,to:Pos(range.head.line,len)}}return{from:range.from(),to:range.to()}})},deleteLine:function(cm){deleteNearSelection(cm,function(range){return{from:Pos(range.from().line,0),to:clipPos(cm.doc,Pos(range.to().line+1,0))}})},delLineLeft:function(cm){deleteNearSelection(cm,function(range){return{from:Pos(range.from().line,0),to:range.from()}})},delWrappedLineLeft:function(cm){deleteNearSelection(cm,function(range){var top=cm.charCoords(range.head,"div").top+5,leftPos=cm.coordsChar({left:0,top:top},"div");return{from:leftPos,to:range.from()}})},delWrappedLineRight:function(cm){deleteNearSelection(cm,function(range){var top=cm.charCoords(range.head,"div").top+5,rightPos=cm.coordsChar({left:cm.display.lineDiv.offsetWidth+100,top:top},"div");return{from:range.from(),to:rightPos}})},undo:function(cm){cm.undo()},redo:function(cm){cm.redo()},undoSelection:function(cm){cm.undoSelection()},redoSelection:function(cm){cm.redoSelection()},goDocStart:function(cm){cm.extendSelection(Pos(cm.firstLine(),0))},goDocEnd:function(cm){cm.extendSelection(Pos(cm.lastLine()))},goLineStart:function(cm){cm.extendSelectionsBy(function(range){return lineStart(cm,range.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(cm){cm.extendSelectionsBy(function(range){return lineStartSmart(cm,range.head)},{origin:"+move",bias:1})},goLineEnd:function(cm){cm.extendSelectionsBy(function(range){return lineEnd(cm,range.head.line)},{origin:"+move",bias:-1})},goLineRight:function(cm){cm.extendSelectionsBy(function(range){var top=cm.charCoords(range.head,"div").top+5;return cm.coordsChar({left:cm.display.lineDiv.offsetWidth+100,top:top},"div")},sel_move)},goLineLeft:function(cm){cm.extendSelectionsBy(function(range){var top=cm.charCoords(range.head,"div").top+5;return cm.coordsChar({left:0,top:top},"div")},sel_move)},goLineLeftSmart:function(cm){cm.extendSelectionsBy(function(range){var top=cm.charCoords(range.head,"div").top+5,pos=cm.coordsChar({left:0,top:top},"div");return pos.ch<cm.getLine(pos.line).search(/\S/)?lineStartSmart(cm,range.head):pos},sel_move)},goLineUp:function(cm){cm.moveV(-1,"line")},goLineDown:function(cm){cm.moveV(1,"line")},goPageUp:function(cm){cm.moveV(-1,"page")},goPageDown:function(cm){cm.moveV(1,"page")},goCharLeft:function(cm){cm.moveH(-1,"char")},goCharRight:function(cm){cm.moveH(1,"char")},goColumnLeft:function(cm){cm.moveH(-1,"column")},goColumnRight:function(cm){cm.moveH(1,"column")},goWordLeft:function(cm){cm.moveH(-1,"word")},goGroupRight:function(cm){cm.moveH(1,"group")},goGroupLeft:function(cm){cm.moveH(-1,"group")},goWordRight:function(cm){cm.moveH(1,"word")},delCharBefore:function(cm){cm.deleteH(-1,"char")},delCharAfter:function(cm){cm.deleteH(1,"char")},delWordBefore:function(cm){cm.deleteH(-1,"word")},delWordAfter:function(cm){cm.deleteH(1,"word")},delGroupBefore:function(cm){cm.deleteH(-1,"group")},delGroupAfter:function(cm){cm.deleteH(1,"group")},indentAuto:function(cm){cm.indentSelection("smart")},indentMore:function(cm){cm.indentSelection("add")},indentLess:function(cm){cm.indentSelection("subtract")},insertTab:function(cm){cm.replaceSelection(" ")},insertSoftTab:function(cm){for(var spaces=[],ranges=cm.listSelections(),tabSize=cm.options.tabSize,i=0;i<ranges.length;i++){var pos=ranges[i].from(),col=countColumn(cm.getLine(pos.line),pos.ch,tabSize);spaces.push(new Array(tabSize-col%tabSize+1).join(" "))}cm.replaceSelections(spaces)},defaultTab:function(cm){cm.somethingSelected()?cm.indentSelection("add"):cm.execCommand("insertTab")},transposeChars:function(cm){runInOp(cm,function(){for(var ranges=cm.listSelections(),newSel=[],i=0;i<ranges.length;i++){var cur=ranges[i].head,line=getLine(cm.doc,cur.line).text;if(line){cur.ch==line.length&&(cur=new Pos(cur.line,cur.ch-1));if(cur.ch>0){cur=new Pos(cur.line,cur.ch+1);cm.replaceRange(line.charAt(cur.ch-1)+line.charAt(cur.ch-2),Pos(cur.line,cur.ch-2),cur,"+transpose")}else if(cur.line>cm.doc.first){var prev=getLine(cm.doc,cur.line-1).text;prev&&cm.replaceRange(line.charAt(0)+cm.doc.lineSeparator()+prev.charAt(prev.length-1),Pos(cur.line-1,prev.length-1),Pos(cur.line,1),"+transpose")}}newSel.push(new Range(cur,cur))}cm.setSelections(newSel)})},newlineAndIndent:function(cm){runInOp(cm,function(){for(var len=cm.listSelections().length,i=0;len>i;i++){var range=cm.listSelections()[i];cm.replaceRange(cm.doc.lineSeparator(),range.anchor,range.head,"+input");cm.indentLine(range.from().line+1,null,!0)}ensureCursorVisible(cm)})},toggleOverwrite:function(cm){cm.toggleOverwrite()}},keyMap=CodeMirror.keyMap={};keyMap.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"};keyMap.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"};keyMap.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"};keyMap.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]};keyMap["default"]=mac?keyMap.macDefault:keyMap.pcDefault;CodeMirror.normalizeKeyMap=function(keymap){var copy={};for(var keyname in keymap)if(keymap.hasOwnProperty(keyname)){var value=keymap[keyname];if(/^(name|fallthrough|(de|at)tach)$/.test(keyname))continue;if("..."==value){delete keymap[keyname];continue}for(var keys=map(keyname.split(" "),normalizeKeyName),i=0;i<keys.length;i++){var val,name;if(i==keys.length-1){name=keys.join(" ");val=value}else{name=keys.slice(0,i+1).join(" ");val="..."}var prev=copy[name];if(prev){if(prev!=val)throw new Error("Inconsistent bindings for "+name)}else copy[name]=val}delete keymap[keyname]}for(var prop in copy)keymap[prop]=copy[prop];return keymap};var lookupKey=CodeMirror.lookupKey=function(key,map,handle,context){map=getKeyMap(map);var found=map.call?map.call(key,context):map[key];if(found===!1)return"nothing";if("..."===found)return"multi";if(null!=found&&handle(found))return"handled";if(map.fallthrough){if("[object Array]"!=Object.prototype.toString.call(map.fallthrough))return lookupKey(key,map.fallthrough,handle,context);for(var i=0;i<map.fallthrough.length;i++){var result=lookupKey(key,map.fallthrough[i],handle,context);if(result)return result}}},isModifierKey=CodeMirror.isModifierKey=function(value){var name="string"==typeof value?value:keyNames[value.keyCode];return"Ctrl"==name||"Alt"==name||"Shift"==name||"Mod"==name},keyName=CodeMirror.keyName=function(event,noShift){if(presto&&34==event.keyCode&&event["char"])return!1;var base=keyNames[event.keyCode],name=base;if(null==name||event.altGraphKey)return!1;event.altKey&&"Alt"!=base&&(name="Alt-"+name);(flipCtrlCmd?event.metaKey:event.ctrlKey)&&"Ctrl"!=base&&(name="Ctrl-"+name);(flipCtrlCmd?event.ctrlKey:event.metaKey)&&"Cmd"!=base&&(name="Cmd-"+name);!noShift&&event.shiftKey&&"Shift"!=base&&(name="Shift-"+name);return name};CodeMirror.fromTextArea=function(textarea,options){function save(){textarea.value=cm.getValue()}options=options?copyObj(options):{};options.value=textarea.value;!options.tabindex&&textarea.tabIndex&&(options.tabindex=textarea.tabIndex);!options.placeholder&&textarea.placeholder&&(options.placeholder=textarea.placeholder);if(null==options.autofocus){var hasFocus=activeElt();options.autofocus=hasFocus==textarea||null!=textarea.getAttribute("autofocus")&&hasFocus==document.body}if(textarea.form){on(textarea.form,"submit",save);if(!options.leaveSubmitMethodAlone){var form=textarea.form,realSubmit=form.submit;try{var wrappedSubmit=form.submit=function(){save();form.submit=realSubmit;form.submit();form.submit=wrappedSubmit}}catch(e){}}}options.finishInit=function(cm){cm.save=save;cm.getTextArea=function(){return textarea};cm.toTextArea=function(){cm.toTextArea=isNaN;save();textarea.parentNode.removeChild(cm.getWrapperElement());textarea.style.display="";if(textarea.form){off(textarea.form,"submit",save);"function"==typeof textarea.form.submit&&(textarea.form.submit=realSubmit)}}};textarea.style.display="none";var cm=CodeMirror(function(node){textarea.parentNode.insertBefore(node,textarea.nextSibling)},options);return cm};var StringStream=CodeMirror.StringStream=function(string,tabSize){this.pos=this.start=0;this.string=string;this.tabSize=tabSize||8;this.lastColumnPos=this.lastColumnValue=0;this.lineStart=0};StringStream.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.pos<this.string.length?this.string.charAt(this.pos++):void 0},eat:function(match){var ch=this.string.charAt(this.pos);if("string"==typeof match)var ok=ch==match;else var ok=ch&&(match.test?match.test(ch):match(ch));if(ok){++this.pos;return ch}},eatWhile:function(match){
7
+ for(var start=this.pos;this.eat(match););return this.pos>start},eatSpace:function(){for(var start=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>start},skipToEnd:function(){this.pos=this.string.length},skipTo:function(ch){var found=this.string.indexOf(ch,this.pos);if(found>-1){this.pos=found;return!0}},backUp:function(n){this.pos-=n},column:function(){if(this.lastColumnPos<this.start){this.lastColumnValue=countColumn(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue);this.lastColumnPos=this.start}return this.lastColumnValue-(this.lineStart?countColumn(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return countColumn(this.string,null,this.tabSize)-(this.lineStart?countColumn(this.string,this.lineStart,this.tabSize):0)},match:function(pattern,consume,caseInsensitive){if("string"!=typeof pattern){var match=this.string.slice(this.pos).match(pattern);if(match&&match.index>0)return null;match&&consume!==!1&&(this.pos+=match[0].length);return match}var cased=function(str){return caseInsensitive?str.toLowerCase():str},substr=this.string.substr(this.pos,pattern.length);if(cased(substr)==cased(pattern)){consume!==!1&&(this.pos+=pattern.length);return!0}},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(n,inner){this.lineStart+=n;try{return inner()}finally{this.lineStart-=n}}};var nextMarkerId=0,TextMarker=CodeMirror.TextMarker=function(doc,type){this.lines=[];this.type=type;this.doc=doc;this.id=++nextMarkerId};eventMixin(TextMarker);TextMarker.prototype.clear=function(){if(!this.explicitlyCleared){var cm=this.doc.cm,withOp=cm&&!cm.curOp;withOp&&startOperation(cm);if(hasHandler(this,"clear")){var found=this.find();found&&signalLater(this,"clear",found.from,found.to)}for(var min=null,max=null,i=0;i<this.lines.length;++i){var line=this.lines[i],span=getMarkedSpanFor(line.markedSpans,this);if(cm&&!this.collapsed)regLineChange(cm,lineNo(line),"text");else if(cm){null!=span.to&&(max=lineNo(line));null!=span.from&&(min=lineNo(line))}line.markedSpans=removeMarkedSpan(line.markedSpans,span);null==span.from&&this.collapsed&&!lineIsHidden(this.doc,line)&&cm&&updateLineHeight(line,textHeight(cm.display))}if(cm&&this.collapsed&&!cm.options.lineWrapping)for(var i=0;i<this.lines.length;++i){var visual=visualLine(this.lines[i]),len=lineLength(visual);if(len>cm.display.maxLineLength){cm.display.maxLine=visual;cm.display.maxLineLength=len;cm.display.maxLineChanged=!0}}null!=min&&cm&&this.collapsed&&regChange(cm,min,max+1);this.lines.length=0;this.explicitlyCleared=!0;if(this.atomic&&this.doc.cantEdit){this.doc.cantEdit=!1;cm&&reCheckSelection(cm.doc)}cm&&signalLater(cm,"markerCleared",cm,this);withOp&&endOperation(cm);this.parent&&this.parent.clear()}};TextMarker.prototype.find=function(side,lineObj){null==side&&"bookmark"==this.type&&(side=1);for(var from,to,i=0;i<this.lines.length;++i){var line=this.lines[i],span=getMarkedSpanFor(line.markedSpans,this);if(null!=span.from){from=Pos(lineObj?line:lineNo(line),span.from);if(-1==side)return from}if(null!=span.to){to=Pos(lineObj?line:lineNo(line),span.to);if(1==side)return to}}return from&&{from:from,to:to}};TextMarker.prototype.changed=function(){var pos=this.find(-1,!0),widget=this,cm=this.doc.cm;pos&&cm&&runInOp(cm,function(){var line=pos.line,lineN=lineNo(pos.line),view=findViewForLine(cm,lineN);if(view){clearLineMeasurementCacheFor(view);cm.curOp.selectionChanged=cm.curOp.forceUpdate=!0}cm.curOp.updateMaxLine=!0;if(!lineIsHidden(widget.doc,line)&&null!=widget.height){var oldHeight=widget.height;widget.height=null;var dHeight=widgetHeight(widget)-oldHeight;dHeight&&updateLineHeight(line,line.height+dHeight)}})};TextMarker.prototype.attachLine=function(line){if(!this.lines.length&&this.doc.cm){var op=this.doc.cm.curOp;op.maybeHiddenMarkers&&-1!=indexOf(op.maybeHiddenMarkers,this)||(op.maybeUnhiddenMarkers||(op.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(line)};TextMarker.prototype.detachLine=function(line){this.lines.splice(indexOf(this.lines,line),1);if(!this.lines.length&&this.doc.cm){var op=this.doc.cm.curOp;(op.maybeHiddenMarkers||(op.maybeHiddenMarkers=[])).push(this)}};var nextMarkerId=0,SharedTextMarker=CodeMirror.SharedTextMarker=function(markers,primary){this.markers=markers;this.primary=primary;for(var i=0;i<markers.length;++i)markers[i].parent=this};eventMixin(SharedTextMarker);SharedTextMarker.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var i=0;i<this.markers.length;++i)this.markers[i].clear();signalLater(this,"clear")}};SharedTextMarker.prototype.find=function(side,lineObj){return this.primary.find(side,lineObj)};var LineWidget=CodeMirror.LineWidget=function(doc,node,options){if(options)for(var opt in options)options.hasOwnProperty(opt)&&(this[opt]=options[opt]);this.doc=doc;this.node=node};eventMixin(LineWidget);LineWidget.prototype.clear=function(){var cm=this.doc.cm,ws=this.line.widgets,line=this.line,no=lineNo(line);if(null!=no&&ws){for(var i=0;i<ws.length;++i)ws[i]==this&&ws.splice(i--,1);ws.length||(line.widgets=null);var height=widgetHeight(this);updateLineHeight(line,Math.max(0,line.height-height));cm&&runInOp(cm,function(){adjustScrollWhenAboveVisible(cm,line,-height);regLineChange(cm,no,"widget")})}};LineWidget.prototype.changed=function(){var oldH=this.height,cm=this.doc.cm,line=this.line;this.height=null;var diff=widgetHeight(this)-oldH;if(diff){updateLineHeight(line,line.height+diff);cm&&runInOp(cm,function(){cm.curOp.forceUpdate=!0;adjustScrollWhenAboveVisible(cm,line,diff)})}};var Line=CodeMirror.Line=function(text,markedSpans,estimateHeight){this.text=text;attachMarkedSpans(this,markedSpans);this.height=estimateHeight?estimateHeight(this):1};eventMixin(Line);Line.prototype.lineNo=function(){return lineNo(this)};var styleToClassCache={},styleToClassCacheWithMode={};LeafChunk.prototype={chunkSize:function(){return this.lines.length},removeInner:function(at,n){for(var i=at,e=at+n;e>i;++i){var line=this.lines[i];this.height-=line.height;cleanUpLine(line);signalLater(line,"delete")}this.lines.splice(at,n)},collapse:function(lines){lines.push.apply(lines,this.lines)},insertInner:function(at,lines,height){this.height+=height;this.lines=this.lines.slice(0,at).concat(lines).concat(this.lines.slice(at));for(var i=0;i<lines.length;++i)lines[i].parent=this},iterN:function(at,n,op){for(var e=at+n;e>at;++at)if(op(this.lines[at]))return!0}};BranchChunk.prototype={chunkSize:function(){return this.size},removeInner:function(at,n){this.size-=n;for(var i=0;i<this.children.length;++i){var child=this.children[i],sz=child.chunkSize();if(sz>at){var rm=Math.min(n,sz-at),oldHeight=child.height;child.removeInner(at,rm);this.height-=oldHeight-child.height;if(sz==rm){this.children.splice(i--,1);child.parent=null}if(0==(n-=rm))break;at=0}else at-=sz}if(this.size-n<25&&(this.children.length>1||!(this.children[0]instanceof LeafChunk))){var lines=[];this.collapse(lines);this.children=[new LeafChunk(lines)];this.children[0].parent=this}},collapse:function(lines){for(var i=0;i<this.children.length;++i)this.children[i].collapse(lines)},insertInner:function(at,lines,height){this.size+=lines.length;this.height+=height;for(var i=0;i<this.children.length;++i){var child=this.children[i],sz=child.chunkSize();if(sz>=at){child.insertInner(at,lines,height);if(child.lines&&child.lines.length>50){for(;child.lines.length>50;){var spilled=child.lines.splice(child.lines.length-25,25),newleaf=new LeafChunk(spilled);child.height-=newleaf.height;this.children.splice(i+1,0,newleaf);newleaf.parent=this}this.maybeSpill()}break}at-=sz}},maybeSpill:function(){if(!(this.children.length<=10)){var me=this;do{var spilled=me.children.splice(me.children.length-5,5),sibling=new BranchChunk(spilled);if(me.parent){me.size-=sibling.size;me.height-=sibling.height;var myIndex=indexOf(me.parent.children,me);me.parent.children.splice(myIndex+1,0,sibling)}else{var copy=new BranchChunk(me.children);copy.parent=me;me.children=[copy,sibling];me=copy}sibling.parent=me.parent}while(me.children.length>10);me.parent.maybeSpill()}},iterN:function(at,n,op){for(var i=0;i<this.children.length;++i){var child=this.children[i],sz=child.chunkSize();if(sz>at){var used=Math.min(n,sz-at);if(child.iterN(at,used,op))return!0;if(0==(n-=used))break;at=0}else at-=sz}}};var nextDocId=0,Doc=CodeMirror.Doc=function(text,mode,firstLine,lineSep){if(!(this instanceof Doc))return new Doc(text,mode,firstLine,lineSep);null==firstLine&&(firstLine=0);BranchChunk.call(this,[new LeafChunk([new Line("",null)])]);this.first=firstLine;this.scrollTop=this.scrollLeft=0;this.cantEdit=!1;this.cleanGeneration=1;this.frontier=firstLine;var start=Pos(firstLine,0);this.sel=simpleSelection(start);this.history=new History(null);this.id=++nextDocId;this.modeOption=mode;this.lineSep=lineSep;this.extend=!1;"string"==typeof text&&(text=this.splitLines(text));updateDoc(this,{from:start,to:start,text:text});setSelection(this,simpleSelection(start),sel_dontScroll)};Doc.prototype=createObj(BranchChunk.prototype,{constructor:Doc,iter:function(from,to,op){op?this.iterN(from-this.first,to-from,op):this.iterN(this.first,this.first+this.size,from)},insert:function(at,lines){for(var height=0,i=0;i<lines.length;++i)height+=lines[i].height;this.insertInner(at-this.first,lines,height)},remove:function(at,n){this.removeInner(at-this.first,n)},getValue:function(lineSep){var lines=getLines(this,this.first,this.first+this.size);return lineSep===!1?lines:lines.join(lineSep||this.lineSeparator())},setValue:docMethodOp(function(code){var top=Pos(this.first,0),last=this.first+this.size-1;makeChange(this,{from:top,to:Pos(last,getLine(this,last).text.length),text:this.splitLines(code),origin:"setValue",full:!0},!0);setSelection(this,simpleSelection(top))}),replaceRange:function(code,from,to,origin){from=clipPos(this,from);to=to?clipPos(this,to):from;replaceRange(this,code,from,to,origin)},getRange:function(from,to,lineSep){var lines=getBetween(this,clipPos(this,from),clipPos(this,to));return lineSep===!1?lines:lines.join(lineSep||this.lineSeparator())},getLine:function(line){var l=this.getLineHandle(line);return l&&l.text},getLineHandle:function(line){return isLine(this,line)?getLine(this,line):void 0},getLineNumber:function(line){return lineNo(line)},getLineHandleVisualStart:function(line){"number"==typeof line&&(line=getLine(this,line));return visualLine(line)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(pos){return clipPos(this,pos)},getCursor:function(start){var pos,range=this.sel.primary();pos=null==start||"head"==start?range.head:"anchor"==start?range.anchor:"end"==start||"to"==start||start===!1?range.to():range.from();return pos},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:docMethodOp(function(line,ch,options){setSimpleSelection(this,clipPos(this,"number"==typeof line?Pos(line,ch||0):line),null,options)}),setSelection:docMethodOp(function(anchor,head,options){setSimpleSelection(this,clipPos(this,anchor),clipPos(this,head||anchor),options)}),extendSelection:docMethodOp(function(head,other,options){extendSelection(this,clipPos(this,head),other&&clipPos(this,other),options)}),extendSelections:docMethodOp(function(heads,options){extendSelections(this,clipPosArray(this,heads),options)}),extendSelectionsBy:docMethodOp(function(f,options){var heads=map(this.sel.ranges,f);extendSelections(this,clipPosArray(this,heads),options)}),setSelections:docMethodOp(function(ranges,primary,options){if(ranges.length){for(var i=0,out=[];i<ranges.length;i++)out[i]=new Range(clipPos(this,ranges[i].anchor),clipPos(this,ranges[i].head));null==primary&&(primary=Math.min(ranges.length-1,this.sel.primIndex));setSelection(this,normalizeSelection(out,primary),options)}}),addSelection:docMethodOp(function(anchor,head,options){var ranges=this.sel.ranges.slice(0);ranges.push(new Range(clipPos(this,anchor),clipPos(this,head||anchor)));setSelection(this,normalizeSelection(ranges,ranges.length-1),options)}),getSelection:function(lineSep){for(var lines,ranges=this.sel.ranges,i=0;i<ranges.length;i++){var sel=getBetween(this,ranges[i].from(),ranges[i].to());lines=lines?lines.concat(sel):sel}return lineSep===!1?lines:lines.join(lineSep||this.lineSeparator())},getSelections:function(lineSep){for(var parts=[],ranges=this.sel.ranges,i=0;i<ranges.length;i++){var sel=getBetween(this,ranges[i].from(),ranges[i].to());lineSep!==!1&&(sel=sel.join(lineSep||this.lineSeparator()));parts[i]=sel}return parts},replaceSelection:function(code,collapse,origin){for(var dup=[],i=0;i<this.sel.ranges.length;i++)dup[i]=code;this.replaceSelections(dup,collapse,origin||"+input")},replaceSelections:docMethodOp(function(code,collapse,origin){for(var changes=[],sel=this.sel,i=0;i<sel.ranges.length;i++){var range=sel.ranges[i];changes[i]={from:range.from(),to:range.to(),text:this.splitLines(code[i]),origin:origin}}for(var newSel=collapse&&"end"!=collapse&&computeReplacedSel(this,changes,collapse),i=changes.length-1;i>=0;i--)makeChange(this,changes[i]);newSel?setSelectionReplaceHistory(this,newSel):this.cm&&ensureCursorVisible(this.cm)}),undo:docMethodOp(function(){makeChangeFromHistory(this,"undo")}),redo:docMethodOp(function(){makeChangeFromHistory(this,"redo")}),undoSelection:docMethodOp(function(){makeChangeFromHistory(this,"undo",!0)}),redoSelection:docMethodOp(function(){makeChangeFromHistory(this,"redo",!0)}),setExtending:function(val){this.extend=val},getExtending:function(){return this.extend},historySize:function(){for(var hist=this.history,done=0,undone=0,i=0;i<hist.done.length;i++)hist.done[i].ranges||++done;for(var i=0;i<hist.undone.length;i++)hist.undone[i].ranges||++undone;return{undo:done,redo:undone}},clearHistory:function(){this.history=new History(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(forceSplit){forceSplit&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null);return this.history.generation},isClean:function(gen){return this.history.generation==(gen||this.cleanGeneration)},getHistory:function(){return{done:copyHistoryArray(this.history.done),undone:copyHistoryArray(this.history.undone)}},setHistory:function(histData){var hist=this.history=new History(this.history.maxGeneration);hist.done=copyHistoryArray(histData.done.slice(0),null,!0);hist.undone=copyHistoryArray(histData.undone.slice(0),null,!0)},addLineClass:docMethodOp(function(handle,where,cls){return changeLine(this,handle,"gutter"==where?"gutter":"class",function(line){var prop="text"==where?"textClass":"background"==where?"bgClass":"gutter"==where?"gutterClass":"wrapClass";if(line[prop]){if(classTest(cls).test(line[prop]))return!1;line[prop]+=" "+cls}else line[prop]=cls;return!0})}),removeLineClass:docMethodOp(function(handle,where,cls){return changeLine(this,handle,"gutter"==where?"gutter":"class",function(line){var prop="text"==where?"textClass":"background"==where?"bgClass":"gutter"==where?"gutterClass":"wrapClass",cur=line[prop];if(!cur)return!1;if(null==cls)line[prop]=null;else{var found=cur.match(classTest(cls));if(!found)return!1;var end=found.index+found[0].length;line[prop]=cur.slice(0,found.index)+(found.index&&end!=cur.length?" ":"")+cur.slice(end)||null}return!0})}),addLineWidget:docMethodOp(function(handle,node,options){return addLineWidget(this,handle,node,options)}),removeLineWidget:function(widget){widget.clear()},markText:function(from,to,options){return markText(this,clipPos(this,from),clipPos(this,to),options,options&&options.type||"range")},setBookmark:function(pos,options){var realOpts={replacedWith:options&&(null==options.nodeType?options.widget:options),insertLeft:options&&options.insertLeft,clearWhenEmpty:!1,shared:options&&options.shared,handleMouseEvents:options&&options.handleMouseEvents};pos=clipPos(this,pos);return markText(this,pos,pos,realOpts,"bookmark")},findMarksAt:function(pos){pos=clipPos(this,pos);var markers=[],spans=getLine(this,pos.line).markedSpans;if(spans)for(var i=0;i<spans.length;++i){var span=spans[i];(null==span.from||span.from<=pos.ch)&&(null==span.to||span.to>=pos.ch)&&markers.push(span.marker.parent||span.marker)}return markers},findMarks:function(from,to,filter){from=clipPos(this,from);to=clipPos(this,to);var found=[],lineNo=from.line;this.iter(from.line,to.line+1,function(line){var spans=line.markedSpans;if(spans)for(var i=0;i<spans.length;i++){var span=spans[i];null!=span.to&&lineNo==from.line&&from.ch>=span.to||null==span.from&&lineNo!=from.line||null!=span.from&&lineNo==to.line&&span.from>=to.ch||filter&&!filter(span.marker)||found.push(span.marker.parent||span.marker)}++lineNo});return found},getAllMarks:function(){var markers=[];this.iter(function(line){var sps=line.markedSpans;if(sps)for(var i=0;i<sps.length;++i)null!=sps[i].from&&markers.push(sps[i].marker)});return markers},posFromIndex:function(off){var ch,lineNo=this.first,sepSize=this.lineSeparator().length;this.iter(function(line){var sz=line.text.length+sepSize;if(sz>off){ch=off;return!0}off-=sz;++lineNo});return clipPos(this,Pos(lineNo,ch))},indexFromPos:function(coords){coords=clipPos(this,coords);var index=coords.ch;if(coords.line<this.first||coords.ch<0)return 0;var sepSize=this.lineSeparator().length;this.iter(this.first,coords.line,function(line){index+=line.text.length+sepSize});return index},copy:function(copyHistory){var doc=new Doc(getLines(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep);doc.scrollTop=this.scrollTop;doc.scrollLeft=this.scrollLeft;doc.sel=this.sel;doc.extend=!1;if(copyHistory){doc.history.undoDepth=this.history.undoDepth;doc.setHistory(this.getHistory())}return doc},linkedDoc:function(options){options||(options={});var from=this.first,to=this.first+this.size;null!=options.from&&options.from>from&&(from=options.from);null!=options.to&&options.to<to&&(to=options.to);var copy=new Doc(getLines(this,from,to),options.mode||this.modeOption,from,this.lineSep);options.sharedHist&&(copy.history=this.history);(this.linked||(this.linked=[])).push({doc:copy,sharedHist:options.sharedHist});copy.linked=[{doc:this,isParent:!0,sharedHist:options.sharedHist}];copySharedMarkers(copy,findSharedMarkers(this));return copy},unlinkDoc:function(other){other instanceof CodeMirror&&(other=other.doc);if(this.linked)for(var i=0;i<this.linked.length;++i){var link=this.linked[i];if(link.doc==other){this.linked.splice(i,1);other.unlinkDoc(this);detachSharedMarkers(findSharedMarkers(this));break}}if(other.history==this.history){var splitIds=[other.id];linkedDocs(other,function(doc){splitIds.push(doc.id)},!0);other.history=new History(null);other.history.done=copyHistoryArray(this.history.done,splitIds);other.history.undone=copyHistoryArray(this.history.undone,splitIds)}},iterLinkedDocs:function(f){linkedDocs(this,f)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(str){return this.lineSep?str.split(this.lineSep):splitLinesAuto(str)},lineSeparator:function(){return this.lineSep||"\n"}});Doc.prototype.eachLine=Doc.prototype.iter;var dontDelegate="iter insert remove copy getEditor constructor".split(" ");for(var prop in Doc.prototype)Doc.prototype.hasOwnProperty(prop)&&indexOf(dontDelegate,prop)<0&&(CodeMirror.prototype[prop]=function(method){return function(){return method.apply(this.doc,arguments)}}(Doc.prototype[prop]));eventMixin(Doc);var e_preventDefault=CodeMirror.e_preventDefault=function(e){e.preventDefault?e.preventDefault():e.returnValue=!1},e_stopPropagation=CodeMirror.e_stopPropagation=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},e_stop=CodeMirror.e_stop=function(e){e_preventDefault(e);e_stopPropagation(e)},on=CodeMirror.on=function(emitter,type,f){if(emitter.addEventListener)emitter.addEventListener(type,f,!1);else if(emitter.attachEvent)emitter.attachEvent("on"+type,f);else{var map=emitter._handlers||(emitter._handlers={}),arr=map[type]||(map[type]=[]);arr.push(f)}},noHandlers=[],off=CodeMirror.off=function(emitter,type,f){if(emitter.removeEventListener)emitter.removeEventListener(type,f,!1);else if(emitter.detachEvent)emitter.detachEvent("on"+type,f);else for(var handlers=getHandlers(emitter,type,!1),i=0;i<handlers.length;++i)if(handlers[i]==f){handlers.splice(i,1);break}},signal=CodeMirror.signal=function(emitter,type){var handlers=getHandlers(emitter,type,!0);if(handlers.length)for(var args=Array.prototype.slice.call(arguments,2),i=0;i<handlers.length;++i)handlers[i].apply(null,args)},orphanDelayedCallbacks=null,scrollerGap=30,Pass=CodeMirror.Pass={toString:function(){return"CodeMirror.Pass"}},sel_dontScroll={scroll:!1},sel_mouse={origin:"*mouse"},sel_move={origin:"+move"};Delayed.prototype.set=function(ms,f){clearTimeout(this.id);this.id=setTimeout(f,ms)};var countColumn=CodeMirror.countColumn=function(string,end,tabSize,startIndex,startValue){if(null==end){end=string.search(/[^\s\u00a0]/);-1==end&&(end=string.length)}for(var i=startIndex||0,n=startValue||0;;){var nextTab=string.indexOf(" ",i);if(0>nextTab||nextTab>=end)return n+(end-i);n+=nextTab-i;n+=tabSize-n%tabSize;i=nextTab+1}},findColumn=CodeMirror.findColumn=function(string,goal,tabSize){for(var pos=0,col=0;;){var nextTab=string.indexOf(" ",pos);-1==nextTab&&(nextTab=string.length);var skipped=nextTab-pos;if(nextTab==string.length||col+skipped>=goal)return pos+Math.min(skipped,goal-col);col+=nextTab-pos;col+=tabSize-col%tabSize;pos=nextTab+1;if(col>=goal)return pos}},spaceStrs=[""],selectInput=function(node){node.select()};ios?selectInput=function(node){node.selectionStart=0;node.selectionEnd=node.value.length}:ie&&(selectInput=function(node){try{node.select()}catch(_e){}});var range,nonASCIISingleCaseWordChar=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,isWordCharBasic=CodeMirror.isWordChar=function(ch){return/\w/.test(ch)||ch>"€"&&(ch.toUpperCase()!=ch.toLowerCase()||nonASCIISingleCaseWordChar.test(ch))},extendingChars=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;range=document.createRange?function(node,start,end,endNode){var r=document.createRange();r.setEnd(endNode||node,end);r.setStart(node,start);return r}:function(node,start,end){var r=document.body.createTextRange();try{r.moveToElementText(node.parentNode)}catch(e){return r}r.collapse(!0);r.moveEnd("character",end);r.moveStart("character",start);return r};var contains=CodeMirror.contains=function(parent,child){3==child.nodeType&&(child=child.parentNode);if(parent.contains)return parent.contains(child);do{11==child.nodeType&&(child=child.host);if(child==parent)return!0}while(child=child.parentNode)};ie&&11>ie_version&&(activeElt=function(){try{return document.activeElement}catch(e){return document.body}});var zwspSupported,badBidiRects,rmClass=CodeMirror.rmClass=function(node,cls){var current=node.className,match=classTest(cls).exec(current);if(match){var after=current.slice(match.index+match[0].length);node.className=current.slice(0,match.index)+(after?match[1]+after:"")}},addClass=CodeMirror.addClass=function(node,cls){var current=node.className;classTest(cls).test(current)||(node.className+=(current?" ":"")+cls)},globalsRegistered=!1,dragAndDrop=function(){if(ie&&9>ie_version)return!1;var div=elt("div");return"draggable"in div||"dragDrop"in div}(),splitLinesAuto=CodeMirror.splitLines=3!="\n\nb".split(/\n/).length?function(string){for(var pos=0,result=[],l=string.length;l>=pos;){var nl=string.indexOf("\n",pos);-1==nl&&(nl=string.length);var line=string.slice(pos,"\r"==string.charAt(nl-1)?nl-1:nl),rt=line.indexOf("\r");if(-1!=rt){result.push(line.slice(0,rt));pos+=rt+1}else{result.push(line);pos=nl+1}}return result}:function(string){return string.split(/\r\n?|\n/)},hasSelection=window.getSelection?function(te){try{return te.selectionStart!=te.selectionEnd}catch(e){return!1}}:function(te){try{var range=te.ownerDocument.selection.createRange()}catch(e){}return range&&range.parentElement()==te?0!=range.compareEndPoints("StartToEnd",range):!1},hasCopyEvent=function(){var e=elt("div");if("oncopy"in e)return!0;e.setAttribute("oncopy","return;");return"function"==typeof e.oncopy}(),badZoomedRects=null,keyNames=CodeMirror.keyNames={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};!function(){for(var i=0;10>i;i++)keyNames[i+48]=keyNames[i+96]=String(i);for(var i=65;90>=i;i++)keyNames[i]=String.fromCharCode(i);for(var i=1;12>=i;i++)keyNames[i+111]=keyNames[i+63235]="F"+i}();var bidiOther,bidiOrdering=function(){function charType(code){return 247>=code?lowTypes.charAt(code):code>=1424&&1524>=code?"R":code>=1536&&1773>=code?arabicTypes.charAt(code-1536):code>=1774&&2220>=code?"r":code>=8192&&8203>=code?"w":8204==code?"b":"L"}function BidiSpan(level,from,to){this.level=level;this.from=from;this.to=to}var lowTypes="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",arabicTypes="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",bidiRE=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,isNeutral=/[stwN]/,isStrong=/[LRr]/,countsAsLeft=/[Lb1n]/,countsAsNum=/[1n]/,outerType="L";return function(str){if(!bidiRE.test(str))return!1;for(var type,len=str.length,types=[],i=0;len>i;++i)types.push(type=charType(str.charCodeAt(i)));for(var i=0,prev=outerType;len>i;++i){var type=types[i];"m"==type?types[i]=prev:prev=type}for(var i=0,cur=outerType;len>i;++i){var type=types[i];if("1"==type&&"r"==cur)types[i]="n";else if(isStrong.test(type)){cur=type;"r"==type&&(types[i]="R")}}for(var i=1,prev=types[0];len-1>i;++i){var type=types[i];"+"==type&&"1"==prev&&"1"==types[i+1]?types[i]="1":","!=type||prev!=types[i+1]||"1"!=prev&&"n"!=prev||(types[i]=prev);prev=type}for(var i=0;len>i;++i){var type=types[i];if(","==type)types[i]="N";else if("%"==type){for(var end=i+1;len>end&&"%"==types[end];++end);for(var replace=i&&"!"==types[i-1]||len>end&&"1"==types[end]?"1":"N",j=i;end>j;++j)types[j]=replace;i=end-1}}for(var i=0,cur=outerType;len>i;++i){var type=types[i];"L"==cur&&"1"==type?types[i]="L":isStrong.test(type)&&(cur=type)}for(var i=0;len>i;++i)if(isNeutral.test(types[i])){for(var end=i+1;len>end&&isNeutral.test(types[end]);++end);for(var before="L"==(i?types[i-1]:outerType),after="L"==(len>end?types[end]:outerType),replace=before||after?"L":"R",j=i;end>j;++j)types[j]=replace;i=end-1}for(var m,order=[],i=0;len>i;)if(countsAsLeft.test(types[i])){var start=i;for(++i;len>i&&countsAsLeft.test(types[i]);++i);order.push(new BidiSpan(0,start,i))}else{var pos=i,at=order.length;for(++i;len>i&&"L"!=types[i];++i);for(var j=pos;i>j;)if(countsAsNum.test(types[j])){j>pos&&order.splice(at,0,new BidiSpan(1,pos,j));var nstart=j;for(++j;i>j&&countsAsNum.test(types[j]);++j);order.splice(at,0,new BidiSpan(2,nstart,j));pos=j}else++j;i>pos&&order.splice(at,0,new BidiSpan(1,pos,i))}if(1==order[0].level&&(m=str.match(/^\s+/))){order[0].from=m[0].length;order.unshift(new BidiSpan(0,0,m[0].length))}if(1==lst(order).level&&(m=str.match(/\s+$/))){lst(order).to-=m[0].length;order.push(new BidiSpan(0,len-m[0].length,len))}2==order[0].level&&order.unshift(new BidiSpan(1,order[0].to,order[0].to));order[0].level!=lst(order).level&&order.push(new BidiSpan(order[0].level,len,len));return order}}();CodeMirror.version="5.14.2";return CodeMirror});
js/esites_editor/dist/js/vendor/codemirror/mode/css/css.js CHANGED
@@ -1 +1 @@
1
- !function(mod){"object"==typeof exports&&"object"==typeof module?mod(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],mod):mod(CodeMirror)}(function(CodeMirror){"use strict";function keySet(array){for(var keys={},i=0;i<array.length;++i)keys[array[i]]=!0;return keys}function tokenCComment(stream,state){for(var ch,maybeEnd=!1;null!=(ch=stream.next());){if(maybeEnd&&"/"==ch){state.tokenize=null;break}maybeEnd="*"==ch}return["comment","comment"]}CodeMirror.defineMode("css",function(config,parserConfig){function ret(style,tp){type=tp;return style}function tokenBase(stream,state){var ch=stream.next();if(tokenHooks[ch]){var result=tokenHooks[ch](stream,state);if(result!==!1)return result}if("@"==ch){stream.eatWhile(/[\w\\\-]/);return ret("def",stream.current())}if("="==ch||("~"==ch||"|"==ch)&&stream.eat("="))return ret(null,"compare");if('"'==ch||"'"==ch){state.tokenize=tokenString(ch);return state.tokenize(stream,state)}if("#"==ch){stream.eatWhile(/[\w\\\-]/);return ret("atom","hash")}if("!"==ch){stream.match(/^\s*\w*/);return ret("keyword","important")}if(/\d/.test(ch)||"."==ch&&stream.eat(/\d/)){stream.eatWhile(/[\w.%]/);return ret("number","unit")}if("-"!==ch){if(/[,+>*\/]/.test(ch))return ret(null,"select-op");if("."==ch&&stream.match(/^-?[_a-z][_a-z0-9-]*/i))return ret("qualifier","qualifier");if(/[:;{}\[\]\(\)]/.test(ch))return ret(null,ch);if("u"==ch&&stream.match(/rl(-prefix)?\(/)||"d"==ch&&stream.match("omain(")||"r"==ch&&stream.match("egexp(")){stream.backUp(1);state.tokenize=tokenParenthesized;return ret("property","word")}if(/[\w\\\-]/.test(ch)){stream.eatWhile(/[\w\\\-]/);return ret("property","word")}return ret(null,null)}if(/[\d.]/.test(stream.peek())){stream.eatWhile(/[\w.%]/);return ret("number","unit")}if(stream.match(/^-[\w\\\-]+/)){stream.eatWhile(/[\w\\\-]/);return stream.match(/^\s*:/,!1)?ret("variable-2","variable-definition"):ret("variable-2","variable")}return stream.match(/^\w+-/)?ret("meta","meta"):void 0}function tokenString(quote){return function(stream,state){for(var ch,escaped=!1;null!=(ch=stream.next());){if(ch==quote&&!escaped){")"==quote&&stream.backUp(1);break}escaped=!escaped&&"\\"==ch}(ch==quote||!escaped&&")"!=quote)&&(state.tokenize=null);return ret("string","string")}}function tokenParenthesized(stream,state){stream.next();stream.match(/\s*[\"\')]/,!1)?state.tokenize=null:state.tokenize=tokenString(")");return ret(null,"(")}function Context(type,indent,prev){this.type=type;this.indent=indent;this.prev=prev}function pushContext(state,stream,type,indent){state.context=new Context(type,stream.indentation()+(indent===!1?0:indentUnit),state.context);return type}function popContext(state){state.context.prev&&(state.context=state.context.prev);return state.context.type}function pass(type,stream,state){return states[state.context.type](type,stream,state)}function popAndPass(type,stream,state,n){for(var i=n||1;i>0;i--)state.context=state.context.prev;return pass(type,stream,state)}function wordAsValue(stream){var word=stream.current().toLowerCase();override=valueKeywords.hasOwnProperty(word)?"atom":colorKeywords.hasOwnProperty(word)?"keyword":"variable"}var provided=parserConfig;parserConfig.propertyKeywords||(parserConfig=CodeMirror.resolveMode("text/css"));parserConfig.inline=provided.inline;var type,override,indentUnit=config.indentUnit,tokenHooks=parserConfig.tokenHooks,documentTypes=parserConfig.documentTypes||{},mediaTypes=parserConfig.mediaTypes||{},mediaFeatures=parserConfig.mediaFeatures||{},mediaValueKeywords=parserConfig.mediaValueKeywords||{},propertyKeywords=parserConfig.propertyKeywords||{},nonStandardPropertyKeywords=parserConfig.nonStandardPropertyKeywords||{},fontProperties=parserConfig.fontProperties||{},counterDescriptors=parserConfig.counterDescriptors||{},colorKeywords=parserConfig.colorKeywords||{},valueKeywords=parserConfig.valueKeywords||{},allowNested=parserConfig.allowNested,supportsAtComponent=parserConfig.supportsAtComponent===!0,states={};states.top=function(type,stream,state){if("{"==type)return pushContext(state,stream,"block");if("}"==type&&state.context.prev)return popContext(state);if(supportsAtComponent&&/@component/.test(type))return pushContext(state,stream,"atComponentBlock");if(/^@(-moz-)?document$/.test(type))return pushContext(state,stream,"documentTypes");if(/^@(media|supports|(-moz-)?document|import)$/.test(type))return pushContext(state,stream,"atBlock");if(/^@(font-face|counter-style)/.test(type)){state.stateArg=type;return"restricted_atBlock_before"}if(/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type))return"keyframes";if(type&&"@"==type.charAt(0))return pushContext(state,stream,"at");if("hash"==type)override="builtin";else if("word"==type)override="tag";else{if("variable-definition"==type)return"maybeprop";if("interpolation"==type)return pushContext(state,stream,"interpolation");if(":"==type)return"pseudo";if(allowNested&&"("==type)return pushContext(state,stream,"parens")}return state.context.type};states.block=function(type,stream,state){if("word"==type){var word=stream.current().toLowerCase();if(propertyKeywords.hasOwnProperty(word)){override="property";return"maybeprop"}if(nonStandardPropertyKeywords.hasOwnProperty(word)){override="string-2";return"maybeprop"}if(allowNested){override=stream.match(/^\s*:(?:\s|$)/,!1)?"property":"tag";return"block"}override+=" error";return"maybeprop"}if("meta"==type)return"block";if(allowNested||"hash"!=type&&"qualifier"!=type)return states.top(type,stream,state);override="error";return"block"};states.maybeprop=function(type,stream,state){return":"==type?pushContext(state,stream,"prop"):pass(type,stream,state)};states.prop=function(type,stream,state){if(";"==type)return popContext(state);if("{"==type&&allowNested)return pushContext(state,stream,"propBlock");if("}"==type||"{"==type)return popAndPass(type,stream,state);if("("==type)return pushContext(state,stream,"parens");if("hash"!=type||/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(stream.current())){if("word"==type)wordAsValue(stream);else if("interpolation"==type)return pushContext(state,stream,"interpolation")}else override+=" error";return"prop"};states.propBlock=function(type,_stream,state){if("}"==type)return popContext(state);if("word"==type){override="property";return"maybeprop"}return state.context.type};states.parens=function(type,stream,state){if("{"==type||"}"==type)return popAndPass(type,stream,state);if(")"==type)return popContext(state);if("("==type)return pushContext(state,stream,"parens");if("interpolation"==type)return pushContext(state,stream,"interpolation");"word"==type&&wordAsValue(stream);return"parens"};states.pseudo=function(type,stream,state){if("word"==type){override="variable-3";return state.context.type}return pass(type,stream,state)};states.documentTypes=function(type,stream,state){if("word"==type&&documentTypes.hasOwnProperty(stream.current())){override="tag";return state.context.type}return states.atBlock(type,stream,state)};states.atBlock=function(type,stream,state){if("("==type)return pushContext(state,stream,"atBlock_parens");if("}"==type||";"==type)return popAndPass(type,stream,state);if("{"==type)return popContext(state)&&pushContext(state,stream,allowNested?"block":"top");if("interpolation"==type)return pushContext(state,stream,"interpolation");if("word"==type){var word=stream.current().toLowerCase();override="only"==word||"not"==word||"and"==word||"or"==word?"keyword":mediaTypes.hasOwnProperty(word)?"attribute":mediaFeatures.hasOwnProperty(word)?"property":mediaValueKeywords.hasOwnProperty(word)?"keyword":propertyKeywords.hasOwnProperty(word)?"property":nonStandardPropertyKeywords.hasOwnProperty(word)?"string-2":valueKeywords.hasOwnProperty(word)?"atom":colorKeywords.hasOwnProperty(word)?"keyword":"error"}return state.context.type};states.atComponentBlock=function(type,stream,state){if("}"==type)return popAndPass(type,stream,state);if("{"==type)return popContext(state)&&pushContext(state,stream,allowNested?"block":"top",!1);"word"==type&&(override="error");return state.context.type};states.atBlock_parens=function(type,stream,state){return")"==type?popContext(state):"{"==type||"}"==type?popAndPass(type,stream,state,2):states.atBlock(type,stream,state)};states.restricted_atBlock_before=function(type,stream,state){if("{"==type)return pushContext(state,stream,"restricted_atBlock");if("word"==type&&"@counter-style"==state.stateArg){override="variable";return"restricted_atBlock_before"}return pass(type,stream,state)};states.restricted_atBlock=function(type,stream,state){if("}"==type){state.stateArg=null;return popContext(state)}if("word"==type){override="@font-face"==state.stateArg&&!fontProperties.hasOwnProperty(stream.current().toLowerCase())||"@counter-style"==state.stateArg&&!counterDescriptors.hasOwnProperty(stream.current().toLowerCase())?"error":"property";return"maybeprop"}return"restricted_atBlock"};states.keyframes=function(type,stream,state){if("word"==type){override="variable";return"keyframes"}return"{"==type?pushContext(state,stream,"top"):pass(type,stream,state)};states.at=function(type,stream,state){if(";"==type)return popContext(state);if("{"==type||"}"==type)return popAndPass(type,stream,state);"word"==type?override="tag":"hash"==type&&(override="builtin");return"at"};states.interpolation=function(type,stream,state){if("}"==type)return popContext(state);if("{"==type||";"==type)return popAndPass(type,stream,state);"word"==type?override="variable":"variable"!=type&&"("!=type&&")"!=type&&(override="error");return"interpolation"};return{startState:function(base){return{tokenize:null,state:parserConfig.inline?"block":"top",stateArg:null,context:new Context(parserConfig.inline?"block":"top",base||0,null)}},token:function(stream,state){if(!state.tokenize&&stream.eatSpace())return null;var style=(state.tokenize||tokenBase)(stream,state);if(style&&"object"==typeof style){type=style[1];style=style[0]}override=style;state.state=states[state.state](type,stream,state);return override},indent:function(state,textAfter){var cx=state.context,ch=textAfter&&textAfter.charAt(0),indent=cx.indent;"prop"!=cx.type||"}"!=ch&&")"!=ch||(cx=cx.prev);if(cx.prev)if("}"!=ch||"block"!=cx.type&&"top"!=cx.type&&"interpolation"!=cx.type&&"restricted_atBlock"!=cx.type){if(")"==ch&&("parens"==cx.type||"atBlock_parens"==cx.type)||"{"==ch&&("at"==cx.type||"atBlock"==cx.type)){indent=Math.max(0,cx.indent-indentUnit);cx=cx.prev}}else{cx=cx.prev;indent=cx.indent}return indent},electricChars:"}",blockCommentStart:"/*",blockCommentEnd:"*/",fold:"brace"}});var documentTypes_=["domain","regexp","url","url-prefix"],documentTypes=keySet(documentTypes_),mediaTypes_=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],mediaTypes=keySet(mediaTypes_),mediaFeatures_=["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid","orientation","device-pixel-ratio","min-device-pixel-ratio","max-device-pixel-ratio","pointer","any-pointer","hover","any-hover"],mediaFeatures=keySet(mediaFeatures_),mediaValueKeywords_=["landscape","portrait","none","coarse","fine","on-demand","hover","interlace","progressive"],mediaValueKeywords=keySet(mediaValueKeywords_),propertyKeywords_=["align-content","align-items","align-self","alignment-adjust","alignment-baseline","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backface-visibility","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-feature-settings","font-family","font-kerning","font-language-override","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-position","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","justify-content","left","letter-spacing","line-break","line-height","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marker-offset","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotation","rotation-point","ruby-align","ruby-overhang","ruby-position","ruby-span","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","word-break","word-spacing","word-wrap","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode"],propertyKeywords=keySet(propertyKeywords_),nonStandardPropertyKeywords_=["scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-3d-light-color","scrollbar-track-color","shape-inside","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","zoom"],nonStandardPropertyKeywords=keySet(nonStandardPropertyKeywords_),fontProperties_=["font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],fontProperties=keySet(fontProperties_),counterDescriptors_=["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"],counterDescriptors=keySet(counterDescriptors_),colorKeywords_=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],colorKeywords=keySet(colorKeywords_),valueKeywords_=["above","absolute","activeborder","additive","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","attr","auto","avoid","avoid-column","avoid-page","avoid-region","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","column","column-reverse","compact","condensed","contain","content","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","dashed","decimal","decimal-leading-zero","default","default-button","destination-atop","destination-in","destination-out","destination-over","devanagari","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ethiopic-numeric","ew-resize","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","georgian","graytext","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-table","inset","inside","intrinsic","invert","italic","japanese-formal","japanese-informal","justify","kannada","katakana","katakana-iroha","keep-all","khmer","korean-hangul-formal","korean-hanja-formal","korean-hanja-informal","landscape","lao","large","larger","left","level","lighter","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","malayalam","match","matrix","matrix3d","media-controls-background","media-current-time-display","media-fullscreen-button","media-mute-button","media-play-button","media-return-to-realtime-button","media-rewind-button","media-seek-back-button","media-seek-forward-button","media-slider","media-sliderthumb","media-time-remaining-display","media-volume-slider","media-volume-slider-container","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menulist-text","menulist-textfield","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","octal","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","perspective","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","scale","scale3d","scaleX","scaleY","scaleZ","scroll","scrollbar","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","semi-condensed","semi-expanded","separate","serif","show","sidama","simp-chinese-formal","simp-chinese-informal","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","solid","somali","source-atop","source-in","source-out","source-over","space","space-around","space-between","spell-out","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","symbolic","symbols","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","tamil","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","trad-chinese-formal","trad-chinese-informal","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","var","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"],valueKeywords=keySet(valueKeywords_),allWords=documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(mediaValueKeywords_).concat(propertyKeywords_).concat(nonStandardPropertyKeywords_).concat(colorKeywords_).concat(valueKeywords_);CodeMirror.registerHelper("hintWords","css",allWords);CodeMirror.defineMIME("text/css",{documentTypes:documentTypes,mediaTypes:mediaTypes,mediaFeatures:mediaFeatures,mediaValueKeywords:mediaValueKeywords,propertyKeywords:propertyKeywords,nonStandardPropertyKeywords:nonStandardPropertyKeywords,fontProperties:fontProperties,counterDescriptors:counterDescriptors,colorKeywords:colorKeywords,valueKeywords:valueKeywords,tokenHooks:{"/":function(stream,state){if(!stream.eat("*"))return!1;state.tokenize=tokenCComment;return tokenCComment(stream,state)}},name:"css"});CodeMirror.defineMIME("text/x-scss",{mediaTypes:mediaTypes,mediaFeatures:mediaFeatures,mediaValueKeywords:mediaValueKeywords,propertyKeywords:propertyKeywords,nonStandardPropertyKeywords:nonStandardPropertyKeywords,colorKeywords:colorKeywords,valueKeywords:valueKeywords,fontProperties:fontProperties,allowNested:!0,tokenHooks:{"/":function(stream,state){if(stream.eat("/")){stream.skipToEnd();return["comment","comment"]}if(stream.eat("*")){state.tokenize=tokenCComment;return tokenCComment(stream,state)}return["operator","operator"]},":":function(stream){return stream.match(/\s*\{/)?[null,"{"]:!1},$:function(stream){stream.match(/^[\w-]+/);return stream.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"]},"#":function(stream){return stream.eat("{")?[null,"interpolation"]:!1}},name:"css",helperType:"scss"});CodeMirror.defineMIME("text/x-less",{mediaTypes:mediaTypes,mediaFeatures:mediaFeatures,mediaValueKeywords:mediaValueKeywords,propertyKeywords:propertyKeywords,nonStandardPropertyKeywords:nonStandardPropertyKeywords,colorKeywords:colorKeywords,valueKeywords:valueKeywords,fontProperties:fontProperties,allowNested:!0,tokenHooks:{"/":function(stream,state){if(stream.eat("/")){stream.skipToEnd();return["comment","comment"]}if(stream.eat("*")){state.tokenize=tokenCComment;return tokenCComment(stream,state)}return["operator","operator"]},"@":function(stream){if(stream.eat("{"))return[null,"interpolation"];if(stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/,!1))return!1;stream.eatWhile(/[\w\\\-]/);return stream.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"]},"&":function(){return["atom","atom"]}},name:"css",helperType:"less"});CodeMirror.defineMIME("text/x-gss",{documentTypes:documentTypes,mediaTypes:mediaTypes,mediaFeatures:mediaFeatures,propertyKeywords:propertyKeywords,nonStandardPropertyKeywords:nonStandardPropertyKeywords,fontProperties:fontProperties,counterDescriptors:counterDescriptors,colorKeywords:colorKeywords,valueKeywords:valueKeywords,supportsAtComponent:!0,tokenHooks:{"/":function(stream,state){if(!stream.eat("*"))return!1;state.tokenize=tokenCComment;return tokenCComment(stream,state)}},name:"css",helperType:"gss"})});
1
+ !function(mod){"object"==typeof exports&&"object"==typeof module?mod(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],mod):mod(CodeMirror)}(function(CodeMirror){"use strict";function keySet(array){for(var keys={},i=0;i<array.length;++i)keys[array[i]]=!0;return keys}function tokenCComment(stream,state){for(var ch,maybeEnd=!1;null!=(ch=stream.next());){if(maybeEnd&&"/"==ch){state.tokenize=null;break}maybeEnd="*"==ch}return["comment","comment"]}CodeMirror.defineMode("css",function(config,parserConfig){function ret(style,tp){type=tp;return style}function tokenBase(stream,state){var ch=stream.next();if(tokenHooks[ch]){var result=tokenHooks[ch](stream,state);if(result!==!1)return result}if("@"==ch){stream.eatWhile(/[\w\\\-]/);return ret("def",stream.current())}if("="==ch||("~"==ch||"|"==ch)&&stream.eat("="))return ret(null,"compare");if('"'==ch||"'"==ch){state.tokenize=tokenString(ch);return state.tokenize(stream,state)}if("#"==ch){stream.eatWhile(/[\w\\\-]/);return ret("atom","hash")}if("!"==ch){stream.match(/^\s*\w*/);return ret("keyword","important")}if(/\d/.test(ch)||"."==ch&&stream.eat(/\d/)){stream.eatWhile(/[\w.%]/);return ret("number","unit")}if("-"!==ch){if(/[,+>*\/]/.test(ch))return ret(null,"select-op");if("."==ch&&stream.match(/^-?[_a-z][_a-z0-9-]*/i))return ret("qualifier","qualifier");if(/[:;{}\[\]\(\)]/.test(ch))return ret(null,ch);if("u"==ch&&stream.match(/rl(-prefix)?\(/)||"d"==ch&&stream.match("omain(")||"r"==ch&&stream.match("egexp(")){stream.backUp(1);state.tokenize=tokenParenthesized;return ret("property","word")}if(/[\w\\\-]/.test(ch)){stream.eatWhile(/[\w\\\-]/);return ret("property","word")}return ret(null,null)}if(/[\d.]/.test(stream.peek())){stream.eatWhile(/[\w.%]/);return ret("number","unit")}if(stream.match(/^-[\w\\\-]+/)){stream.eatWhile(/[\w\\\-]/);return stream.match(/^\s*:/,!1)?ret("variable-2","variable-definition"):ret("variable-2","variable")}return stream.match(/^\w+-/)?ret("meta","meta"):void 0}function tokenString(quote){return function(stream,state){for(var ch,escaped=!1;null!=(ch=stream.next());){if(ch==quote&&!escaped){")"==quote&&stream.backUp(1);break}escaped=!escaped&&"\\"==ch}(ch==quote||!escaped&&")"!=quote)&&(state.tokenize=null);return ret("string","string")}}function tokenParenthesized(stream,state){stream.next();stream.match(/\s*[\"\')]/,!1)?state.tokenize=null:state.tokenize=tokenString(")");return ret(null,"(")}function Context(type,indent,prev){this.type=type;this.indent=indent;this.prev=prev}function pushContext(state,stream,type,indent){state.context=new Context(type,stream.indentation()+(indent===!1?0:indentUnit),state.context);return type}function popContext(state){state.context.prev&&(state.context=state.context.prev);return state.context.type}function pass(type,stream,state){return states[state.context.type](type,stream,state)}function popAndPass(type,stream,state,n){for(var i=n||1;i>0;i--)state.context=state.context.prev;return pass(type,stream,state)}function wordAsValue(stream){var word=stream.current().toLowerCase();override=valueKeywords.hasOwnProperty(word)?"atom":colorKeywords.hasOwnProperty(word)?"keyword":"variable"}var inline=parserConfig.inline;parserConfig.propertyKeywords||(parserConfig=CodeMirror.resolveMode("text/css"));var type,override,indentUnit=config.indentUnit,tokenHooks=parserConfig.tokenHooks,documentTypes=parserConfig.documentTypes||{},mediaTypes=parserConfig.mediaTypes||{},mediaFeatures=parserConfig.mediaFeatures||{},mediaValueKeywords=parserConfig.mediaValueKeywords||{},propertyKeywords=parserConfig.propertyKeywords||{},nonStandardPropertyKeywords=parserConfig.nonStandardPropertyKeywords||{},fontProperties=parserConfig.fontProperties||{},counterDescriptors=parserConfig.counterDescriptors||{},colorKeywords=parserConfig.colorKeywords||{},valueKeywords=parserConfig.valueKeywords||{},allowNested=parserConfig.allowNested,supportsAtComponent=parserConfig.supportsAtComponent===!0,states={};states.top=function(type,stream,state){if("{"==type)return pushContext(state,stream,"block");if("}"==type&&state.context.prev)return popContext(state);if(supportsAtComponent&&/@component/.test(type))return pushContext(state,stream,"atComponentBlock");if(/^@(-moz-)?document$/.test(type))return pushContext(state,stream,"documentTypes");if(/^@(media|supports|(-moz-)?document|import)$/.test(type))return pushContext(state,stream,"atBlock");if(/^@(font-face|counter-style)/.test(type)){state.stateArg=type;return"restricted_atBlock_before"}if(/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type))return"keyframes";if(type&&"@"==type.charAt(0))return pushContext(state,stream,"at");if("hash"==type)override="builtin";else if("word"==type)override="tag";else{if("variable-definition"==type)return"maybeprop";if("interpolation"==type)return pushContext(state,stream,"interpolation");if(":"==type)return"pseudo";if(allowNested&&"("==type)return pushContext(state,stream,"parens")}return state.context.type};states.block=function(type,stream,state){if("word"==type){var word=stream.current().toLowerCase();if(propertyKeywords.hasOwnProperty(word)){override="property";return"maybeprop"}if(nonStandardPropertyKeywords.hasOwnProperty(word)){override="string-2";return"maybeprop"}if(allowNested){override=stream.match(/^\s*:(?:\s|$)/,!1)?"property":"tag";return"block"}override+=" error";return"maybeprop"}if("meta"==type)return"block";if(allowNested||"hash"!=type&&"qualifier"!=type)return states.top(type,stream,state);override="error";return"block"};states.maybeprop=function(type,stream,state){return":"==type?pushContext(state,stream,"prop"):pass(type,stream,state)};states.prop=function(type,stream,state){if(";"==type)return popContext(state);if("{"==type&&allowNested)return pushContext(state,stream,"propBlock");if("}"==type||"{"==type)return popAndPass(type,stream,state);if("("==type)return pushContext(state,stream,"parens");if("hash"!=type||/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(stream.current())){if("word"==type)wordAsValue(stream);else if("interpolation"==type)return pushContext(state,stream,"interpolation")}else override+=" error";return"prop"};states.propBlock=function(type,_stream,state){if("}"==type)return popContext(state);if("word"==type){override="property";return"maybeprop"}return state.context.type};states.parens=function(type,stream,state){if("{"==type||"}"==type)return popAndPass(type,stream,state);if(")"==type)return popContext(state);if("("==type)return pushContext(state,stream,"parens");if("interpolation"==type)return pushContext(state,stream,"interpolation");"word"==type&&wordAsValue(stream);return"parens"};states.pseudo=function(type,stream,state){if("word"==type){override="variable-3";return state.context.type}return pass(type,stream,state)};states.documentTypes=function(type,stream,state){if("word"==type&&documentTypes.hasOwnProperty(stream.current())){override="tag";return state.context.type}return states.atBlock(type,stream,state)};states.atBlock=function(type,stream,state){if("("==type)return pushContext(state,stream,"atBlock_parens");if("}"==type||";"==type)return popAndPass(type,stream,state);if("{"==type)return popContext(state)&&pushContext(state,stream,allowNested?"block":"top");if("interpolation"==type)return pushContext(state,stream,"interpolation");if("word"==type){var word=stream.current().toLowerCase();override="only"==word||"not"==word||"and"==word||"or"==word?"keyword":mediaTypes.hasOwnProperty(word)?"attribute":mediaFeatures.hasOwnProperty(word)?"property":mediaValueKeywords.hasOwnProperty(word)?"keyword":propertyKeywords.hasOwnProperty(word)?"property":nonStandardPropertyKeywords.hasOwnProperty(word)?"string-2":valueKeywords.hasOwnProperty(word)?"atom":colorKeywords.hasOwnProperty(word)?"keyword":"error"}return state.context.type};states.atComponentBlock=function(type,stream,state){if("}"==type)return popAndPass(type,stream,state);if("{"==type)return popContext(state)&&pushContext(state,stream,allowNested?"block":"top",!1);"word"==type&&(override="error");return state.context.type};states.atBlock_parens=function(type,stream,state){return")"==type?popContext(state):"{"==type||"}"==type?popAndPass(type,stream,state,2):states.atBlock(type,stream,state)};states.restricted_atBlock_before=function(type,stream,state){if("{"==type)return pushContext(state,stream,"restricted_atBlock");if("word"==type&&"@counter-style"==state.stateArg){override="variable";return"restricted_atBlock_before"}return pass(type,stream,state)};states.restricted_atBlock=function(type,stream,state){if("}"==type){state.stateArg=null;return popContext(state)}if("word"==type){override="@font-face"==state.stateArg&&!fontProperties.hasOwnProperty(stream.current().toLowerCase())||"@counter-style"==state.stateArg&&!counterDescriptors.hasOwnProperty(stream.current().toLowerCase())?"error":"property";return"maybeprop"}return"restricted_atBlock"};states.keyframes=function(type,stream,state){if("word"==type){override="variable";return"keyframes"}return"{"==type?pushContext(state,stream,"top"):pass(type,stream,state)};states.at=function(type,stream,state){if(";"==type)return popContext(state);if("{"==type||"}"==type)return popAndPass(type,stream,state);"word"==type?override="tag":"hash"==type&&(override="builtin");return"at"};states.interpolation=function(type,stream,state){if("}"==type)return popContext(state);if("{"==type||";"==type)return popAndPass(type,stream,state);"word"==type?override="variable":"variable"!=type&&"("!=type&&")"!=type&&(override="error");return"interpolation"};return{startState:function(base){return{tokenize:null,state:inline?"block":"top",stateArg:null,context:new Context(inline?"block":"top",base||0,null)}},token:function(stream,state){if(!state.tokenize&&stream.eatSpace())return null;var style=(state.tokenize||tokenBase)(stream,state);if(style&&"object"==typeof style){type=style[1];style=style[0]}override=style;state.state=states[state.state](type,stream,state);return override},indent:function(state,textAfter){var cx=state.context,ch=textAfter&&textAfter.charAt(0),indent=cx.indent;"prop"!=cx.type||"}"!=ch&&")"!=ch||(cx=cx.prev);if(cx.prev)if("}"!=ch||"block"!=cx.type&&"top"!=cx.type&&"interpolation"!=cx.type&&"restricted_atBlock"!=cx.type){if(")"==ch&&("parens"==cx.type||"atBlock_parens"==cx.type)||"{"==ch&&("at"==cx.type||"atBlock"==cx.type)){indent=Math.max(0,cx.indent-indentUnit);cx=cx.prev}}else{cx=cx.prev;indent=cx.indent}return indent},electricChars:"}",blockCommentStart:"/*",blockCommentEnd:"*/",fold:"brace"}});var documentTypes_=["domain","regexp","url","url-prefix"],documentTypes=keySet(documentTypes_),mediaTypes_=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],mediaTypes=keySet(mediaTypes_),mediaFeatures_=["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid","orientation","device-pixel-ratio","min-device-pixel-ratio","max-device-pixel-ratio","pointer","any-pointer","hover","any-hover"],mediaFeatures=keySet(mediaFeatures_),mediaValueKeywords_=["landscape","portrait","none","coarse","fine","on-demand","hover","interlace","progressive"],mediaValueKeywords=keySet(mediaValueKeywords_),propertyKeywords_=["align-content","align-items","align-self","alignment-adjust","alignment-baseline","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-feature-settings","font-family","font-kerning","font-language-override","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-position","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","justify-content","left","letter-spacing","line-break","line-height","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marker-offset","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotation","rotation-point","ruby-align","ruby-overhang","ruby-position","ruby-span","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","word-break","word-spacing","word-wrap","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode"],propertyKeywords=keySet(propertyKeywords_),nonStandardPropertyKeywords_=["scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-3d-light-color","scrollbar-track-color","shape-inside","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","zoom"],nonStandardPropertyKeywords=keySet(nonStandardPropertyKeywords_),fontProperties_=["font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],fontProperties=keySet(fontProperties_),counterDescriptors_=["additive-symbols","fallback","negative","pad","prefix","range","speak-as","suffix","symbols","system"],counterDescriptors=keySet(counterDescriptors_),colorKeywords_=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],colorKeywords=keySet(colorKeywords_),valueKeywords_=["above","absolute","activeborder","additive","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","attr","auto","avoid","avoid-column","avoid-page","avoid-region","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","contain","content","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","destination-atop","destination-in","destination-out","destination-over","devanagari","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ethiopic-numeric","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","georgian","graytext","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hard-light","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","hue","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-table","inset","inside","intrinsic","invert","italic","japanese-formal","japanese-informal","justify","kannada","katakana","katakana-iroha","keep-all","khmer","korean-hangul-formal","korean-hanja-formal","korean-hanja-informal","landscape","lao","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","luminosity","malayalam","match","matrix","matrix3d","media-controls-background","media-current-time-display","media-fullscreen-button","media-mute-button","media-play-button","media-return-to-realtime-button","media-rewind-button","media-seek-back-button","media-seek-forward-button","media-slider","media-sliderthumb","media-time-remaining-display","media-volume-slider","media-volume-slider-container","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menulist-text","menulist-textfield","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","multiply","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","octal","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","perspective","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","semi-condensed","semi-expanded","separate","serif","show","sidama","simp-chinese-formal","simp-chinese-informal","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","somali","source-atop","source-in","source-out","source-over","space","space-around","space-between","spell-out","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","symbolic","symbols","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","tamil","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","trad-chinese-formal","trad-chinese-informal","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","var","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"],valueKeywords=keySet(valueKeywords_),allWords=documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(mediaValueKeywords_).concat(propertyKeywords_).concat(nonStandardPropertyKeywords_).concat(colorKeywords_).concat(valueKeywords_);CodeMirror.registerHelper("hintWords","css",allWords);CodeMirror.defineMIME("text/css",{documentTypes:documentTypes,mediaTypes:mediaTypes,mediaFeatures:mediaFeatures,mediaValueKeywords:mediaValueKeywords,propertyKeywords:propertyKeywords,nonStandardPropertyKeywords:nonStandardPropertyKeywords,fontProperties:fontProperties,counterDescriptors:counterDescriptors,colorKeywords:colorKeywords,valueKeywords:valueKeywords,tokenHooks:{"/":function(stream,state){if(!stream.eat("*"))return!1;state.tokenize=tokenCComment;return tokenCComment(stream,state)}},name:"css"});CodeMirror.defineMIME("text/x-scss",{mediaTypes:mediaTypes,mediaFeatures:mediaFeatures,mediaValueKeywords:mediaValueKeywords,propertyKeywords:propertyKeywords,nonStandardPropertyKeywords:nonStandardPropertyKeywords,colorKeywords:colorKeywords,valueKeywords:valueKeywords,fontProperties:fontProperties,allowNested:!0,tokenHooks:{"/":function(stream,state){if(stream.eat("/")){stream.skipToEnd();return["comment","comment"]}if(stream.eat("*")){state.tokenize=tokenCComment;return tokenCComment(stream,state)}return["operator","operator"]},":":function(stream){return stream.match(/\s*\{/)?[null,"{"]:!1},$:function(stream){stream.match(/^[\w-]+/);return stream.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"]},"#":function(stream){return stream.eat("{")?[null,"interpolation"]:!1}},name:"css",helperType:"scss"});CodeMirror.defineMIME("text/x-less",{mediaTypes:mediaTypes,mediaFeatures:mediaFeatures,mediaValueKeywords:mediaValueKeywords,propertyKeywords:propertyKeywords,nonStandardPropertyKeywords:nonStandardPropertyKeywords,colorKeywords:colorKeywords,valueKeywords:valueKeywords,fontProperties:fontProperties,allowNested:!0,tokenHooks:{"/":function(stream,state){if(stream.eat("/")){stream.skipToEnd();return["comment","comment"]}if(stream.eat("*")){state.tokenize=tokenCComment;return tokenCComment(stream,state)}return["operator","operator"]},"@":function(stream){if(stream.eat("{"))return[null,"interpolation"];if(stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/,!1))return!1;stream.eatWhile(/[\w\\\-]/);return stream.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"]},"&":function(){return["atom","atom"]}},name:"css",helperType:"less"});CodeMirror.defineMIME("text/x-gss",{documentTypes:documentTypes,mediaTypes:mediaTypes,mediaFeatures:mediaFeatures,propertyKeywords:propertyKeywords,nonStandardPropertyKeywords:nonStandardPropertyKeywords,fontProperties:fontProperties,counterDescriptors:counterDescriptors,colorKeywords:colorKeywords,valueKeywords:valueKeywords,supportsAtComponent:!0,tokenHooks:{"/":function(stream,state){if(!stream.eat("*"))return!1;state.tokenize=tokenCComment;return tokenCComment(stream,state)}},name:"css",helperType:"gss"})});
js/esites_editor/dist/js/vendor/codemirror/mode/handlebars/handlebars.js CHANGED
@@ -1 +1 @@
1
- !function(mod){"object"==typeof exports&&"object"==typeof module?mod(require("../../lib/codemirror"),require("../../addon/mode/simple")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../../addon/mode/simple"],mod):mod(CodeMirror)}(function(CodeMirror){"use strict";CodeMirror.defineSimpleMode("handlebars",{start:[{regex:/\{\{!--/,push:"dash_comment",token:"comment"},{regex:/\{\{!/,push:"comment",token:"comment"},{regex:/\{\{/,push:"handlebars",token:"tag"}],handlebars:[{regex:/\}\}/,pop:!0,token:"tag"},{regex:/"(?:[^\\]|\\.)*?"/,token:"string"},{regex:/'(?:[^\\]|\\.)*?'/,token:"string"},{regex:/>|[#\/]([A-Za-z_]\w*)/,token:"keyword"},{regex:/(?:else|this)\b/,token:"keyword"},{regex:/\d+/i,token:"number"},{regex:/=|~|@|true|false/,token:"atom"},{regex:/(?:\.\.\/)*(?:[A-Za-z_][\w\.]*)+/,token:"variable-2"}],dash_comment:[{regex:/--\}\}/,pop:!0,token:"comment"},{regex:/./,token:"comment"}],comment:[{regex:/\}\}/,pop:!0,token:"comment"},{regex:/./,token:"comment"}]});CodeMirror.defineMIME("text/x-handlebars-template","handlebars")});
1
+ !function(mod){"object"==typeof exports&&"object"==typeof module?mod(require("../../lib/codemirror"),require("../../addon/mode/simple"),require("../../addon/mode/multiplex")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../../addon/mode/simple","../../addon/mode/multiplex"],mod):mod(CodeMirror)}(function(CodeMirror){"use strict";CodeMirror.defineSimpleMode("handlebars-tags",{start:[{regex:/\{\{!--/,push:"dash_comment",token:"comment"},{regex:/\{\{!/,push:"comment",token:"comment"},{regex:/\{\{/,push:"handlebars",token:"tag"}],handlebars:[{regex:/\}\}/,pop:!0,token:"tag"},{regex:/"(?:[^\\"]|\\.)*"?/,token:"string"},{regex:/'(?:[^\\']|\\.)*'?/,token:"string"},{regex:/>|[#\/]([A-Za-z_]\w*)/,token:"keyword"},{regex:/(?:else|this)\b/,token:"keyword"},{regex:/\d+/i,token:"number"},{regex:/=|~|@|true|false/,token:"atom"},{regex:/(?:\.\.\/)*(?:[A-Za-z_][\w\.]*)+/,token:"variable-2"}],dash_comment:[{regex:/--\}\}/,pop:!0,token:"comment"},{regex:/./,token:"comment"}],comment:[{regex:/\}\}/,pop:!0,token:"comment"},{regex:/./,token:"comment"}]});CodeMirror.defineMode("handlebars",function(config,parserConfig){var handlebars=CodeMirror.getMode(config,"handlebars-tags");return parserConfig&&parserConfig.base?CodeMirror.multiplexingMode(CodeMirror.getMode(config,parserConfig.base),{open:"{{",close:"}}",mode:handlebars,parseDelimiters:!0}):handlebars});CodeMirror.defineMIME("text/x-handlebars-template","handlebars")});
js/esites_editor/dist/js/vendor/codemirror/mode/htmlmixed/htmlmixed.js CHANGED
@@ -1 +1 @@
1
- !function(mod){"object"==typeof exports&&"object"==typeof module?mod(require("../../lib/codemirror"),require("../xml/xml"),require("../javascript/javascript"),require("../css/css")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../javascript/javascript","../css/css"],mod):mod(CodeMirror)}(function(CodeMirror){"use strict";function maybeBackup(stream,pat,style){var cur=stream.current(),close=cur.search(pat);if(close>-1)stream.backUp(cur.length-close);else if(cur.match(/<\/?$/)){stream.backUp(cur.length);stream.match(pat,!1)||stream.match(cur)}return style}function getAttrRegexp(attr){var regexp=attrRegexpCache[attr];return regexp?regexp:attrRegexpCache[attr]=new RegExp("\\s+"+attr+"\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*")}function getAttrValue(stream,attr){for(var match,pos=stream.pos;pos>=0&&"<"!==stream.string.charAt(pos);)pos--;return 0>pos?pos:(match=stream.string.slice(pos,stream.pos).match(getAttrRegexp(attr)))?match[2]:""}function getTagRegexp(tagName,anchored){return new RegExp((anchored?"^":"")+"</s*"+tagName+"s*>","i")}function addTags(from,to){for(var tag in from)for(var dest=to[tag]||(to[tag]=[]),source=from[tag],i=source.length-1;i>=0;i--)dest.unshift(source[i])}function findMatchingMode(tagInfo,stream){for(var i=0;i<tagInfo.length;i++){var spec=tagInfo[i];if(!spec[0]||spec[1].test(getAttrValue(stream,spec[0])))return spec[2]}}var defaultTags={script:[["lang",/(javascript|babel)/i,"javascript"],["type",/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i,"javascript"],["type",/./,"text/plain"],[null,null,"javascript"]],style:[["lang",/^css$/i,"css"],["type",/^(text\/)?(x-)?(stylesheet|css)$/i,"css"],["type",/./,"text/plain"],[null,null,"css"]]},attrRegexpCache={};CodeMirror.defineMode("htmlmixed",function(config,parserConfig){function html(stream,state){var modeSpec,tagName=state.htmlState.tagName&&state.htmlState.tagName.toLowerCase(),tagInfo=tagName&&tags.hasOwnProperty(tagName)&&tags[tagName],style=htmlMode.token(stream,state.htmlState);if(tagInfo&&/\btag\b/.test(style)&&">"===stream.current()&&(modeSpec=findMatchingMode(tagInfo,stream))){var mode=CodeMirror.getMode(config,modeSpec),endTagA=getTagRegexp(tagName,!0),endTag=getTagRegexp(tagName,!1);state.token=function(stream,state){if(stream.match(endTagA,!1)){state.token=html;state.localState=state.localMode=null;return null}return maybeBackup(stream,endTag,state.localMode.token(stream,state.localState))};state.localMode=mode;state.localState=CodeMirror.startState(mode,htmlMode.indent(state.htmlState,""))}return style}var htmlMode=CodeMirror.getMode(config,{name:"xml",htmlMode:!0,multilineTagIndentFactor:parserConfig.multilineTagIndentFactor,multilineTagIndentPastTag:parserConfig.multilineTagIndentPastTag}),tags={},configTags=parserConfig&&parserConfig.tags,configScript=parserConfig&&parserConfig.scriptTypes;addTags(defaultTags,tags);configTags&&addTags(configTags,tags);if(configScript)for(var i=configScript.length-1;i>=0;i--)tags.script.unshift(["type",configScript[i].matches,configScript[i].mode]);return{startState:function(){var state=htmlMode.startState();return{token:html,localMode:null,localState:null,htmlState:state}},copyState:function(state){var local;state.localState&&(local=CodeMirror.copyState(state.localMode,state.localState));return{token:state.token,localMode:state.localMode,localState:local,htmlState:CodeMirror.copyState(htmlMode,state.htmlState)}},token:function(stream,state){return state.token(stream,state)},indent:function(state,textAfter){return!state.localMode||/^\s*<\//.test(textAfter)?htmlMode.indent(state.htmlState,textAfter):state.localMode.indent?state.localMode.indent(state.localState,textAfter):CodeMirror.Pass},innerMode:function(state){return{state:state.localState||state.htmlState,mode:state.localMode||htmlMode}}}},"xml","javascript","css");CodeMirror.defineMIME("text/html","htmlmixed")});
1
+ !function(mod){"object"==typeof exports&&"object"==typeof module?mod(require("../../lib/codemirror"),require("../xml/xml"),require("../javascript/javascript"),require("../css/css")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../javascript/javascript","../css/css"],mod):mod(CodeMirror)}(function(CodeMirror){"use strict";function maybeBackup(stream,pat,style){var cur=stream.current(),close=cur.search(pat);if(close>-1)stream.backUp(cur.length-close);else if(cur.match(/<\/?$/)){stream.backUp(cur.length);stream.match(pat,!1)||stream.match(cur)}return style}function getAttrRegexp(attr){var regexp=attrRegexpCache[attr];return regexp?regexp:attrRegexpCache[attr]=new RegExp("\\s+"+attr+"\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*")}function getAttrValue(text,attr){var match=text.match(getAttrRegexp(attr));return match?match[2]:""}function getTagRegexp(tagName,anchored){return new RegExp((anchored?"^":"")+"</s*"+tagName+"s*>","i")}function addTags(from,to){for(var tag in from)for(var dest=to[tag]||(to[tag]=[]),source=from[tag],i=source.length-1;i>=0;i--)dest.unshift(source[i])}function findMatchingMode(tagInfo,tagText){for(var i=0;i<tagInfo.length;i++){var spec=tagInfo[i];if(!spec[0]||spec[1].test(getAttrValue(tagText,spec[0])))return spec[2]}}var defaultTags={script:[["lang",/(javascript|babel)/i,"javascript"],["type",/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i,"javascript"],["type",/./,"text/plain"],[null,null,"javascript"]],style:[["lang",/^css$/i,"css"],["type",/^(text\/)?(x-)?(stylesheet|css)$/i,"css"],["type",/./,"text/plain"],[null,null,"css"]]},attrRegexpCache={};CodeMirror.defineMode("htmlmixed",function(config,parserConfig){function html(stream,state){var tagName,style=htmlMode.token(stream,state.htmlState),tag=/\btag\b/.test(style);if(tag&&!/[<>\s\/]/.test(stream.current())&&(tagName=state.htmlState.tagName&&state.htmlState.tagName.toLowerCase())&&tags.hasOwnProperty(tagName))state.inTag=tagName+" ";else if(state.inTag&&tag&&/>$/.test(stream.current())){var inTag=/^([\S]+) (.*)/.exec(state.inTag);state.inTag=null;var modeSpec=">"==stream.current()&&findMatchingMode(tags[inTag[1]],inTag[2]),mode=CodeMirror.getMode(config,modeSpec),endTagA=getTagRegexp(inTag[1],!0),endTag=getTagRegexp(inTag[1],!1);state.token=function(stream,state){if(stream.match(endTagA,!1)){state.token=html;state.localState=state.localMode=null;return null}return maybeBackup(stream,endTag,state.localMode.token(stream,state.localState))};state.localMode=mode;state.localState=CodeMirror.startState(mode,htmlMode.indent(state.htmlState,""))}else if(state.inTag){state.inTag+=stream.current();stream.eol()&&(state.inTag+=" ")}return style}var htmlMode=CodeMirror.getMode(config,{name:"xml",htmlMode:!0,multilineTagIndentFactor:parserConfig.multilineTagIndentFactor,multilineTagIndentPastTag:parserConfig.multilineTagIndentPastTag}),tags={},configTags=parserConfig&&parserConfig.tags,configScript=parserConfig&&parserConfig.scriptTypes;addTags(defaultTags,tags);configTags&&addTags(configTags,tags);if(configScript)for(var i=configScript.length-1;i>=0;i--)tags.script.unshift(["type",configScript[i].matches,configScript[i].mode]);return{startState:function(){var state=htmlMode.startState();return{token:html,inTag:null,localMode:null,localState:null,htmlState:state}},copyState:function(state){var local;state.localState&&(local=CodeMirror.copyState(state.localMode,state.localState));return{token:state.token,inTag:state.inTag,localMode:state.localMode,localState:local,htmlState:CodeMirror.copyState(htmlMode,state.htmlState)}},token:function(stream,state){return state.token(stream,state)},indent:function(state,textAfter){return!state.localMode||/^\s*<\//.test(textAfter)?htmlMode.indent(state.htmlState,textAfter):state.localMode.indent?state.localMode.indent(state.localState,textAfter):CodeMirror.Pass},innerMode:function(state){return{state:state.localState||state.htmlState,mode:state.localMode||htmlMode}}}},"xml","javascript","css");CodeMirror.defineMIME("text/html","htmlmixed")});
js/esites_editor/dist/js/vendor/codemirror/mode/javascript/javascript.js CHANGED
@@ -1 +1 @@
1
- !function(mod){"object"==typeof exports&&"object"==typeof module?mod(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],mod):mod(CodeMirror)}(function(CodeMirror){"use strict";CodeMirror.defineMode("javascript",function(config,parserConfig){function readRegexp(stream){for(var next,escaped=!1,inSet=!1;null!=(next=stream.next());){if(!escaped){if("/"==next&&!inSet)return;"["==next?inSet=!0:inSet&&"]"==next&&(inSet=!1)}escaped=!escaped&&"\\"==next}}function ret(tp,style,cont){type=tp;content=cont;return style}function tokenBase(stream,state){var ch=stream.next();if('"'==ch||"'"==ch){state.tokenize=tokenString(ch);return state.tokenize(stream,state)}if("."==ch&&stream.match(/^\d+(?:[eE][+\-]?\d+)?/))return ret("number","number");if("."==ch&&stream.match(".."))return ret("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(ch))return ret(ch);if("="==ch&&stream.eat(">"))return ret("=>","operator");if("0"==ch&&stream.eat(/x/i)){stream.eatWhile(/[\da-f]/i);return ret("number","number")}if("0"==ch&&stream.eat(/o/i)){stream.eatWhile(/[0-7]/i);return ret("number","number")}if("0"==ch&&stream.eat(/b/i)){stream.eatWhile(/[01]/i);return ret("number","number")}if(/\d/.test(ch)){stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);return ret("number","number")}if("/"==ch){if(stream.eat("*")){state.tokenize=tokenComment;return tokenComment(stream,state)}if(stream.eat("/")){stream.skipToEnd();return ret("comment","comment")}if("operator"==state.lastType||"keyword c"==state.lastType||"sof"==state.lastType||/^[\[{}\(,;:]$/.test(state.lastType)){readRegexp(stream);stream.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/);return ret("regexp","string-2")}stream.eatWhile(isOperatorChar);return ret("operator","operator",stream.current())}if("`"==ch){state.tokenize=tokenQuasi;return tokenQuasi(stream,state)}if("#"==ch){stream.skipToEnd();return ret("error","error")}if(isOperatorChar.test(ch)){stream.eatWhile(isOperatorChar);return ret("operator","operator",stream.current())}if(wordRE.test(ch)){stream.eatWhile(wordRE);var word=stream.current(),known=keywords.propertyIsEnumerable(word)&&keywords[word];return known&&"."!=state.lastType?ret(known.type,known.style,word):ret("variable","variable",word)}}function tokenString(quote){return function(stream,state){var next,escaped=!1;if(jsonldMode&&"@"==stream.peek()&&stream.match(isJsonldKeyword)){state.tokenize=tokenBase;return ret("jsonld-keyword","meta")}for(;null!=(next=stream.next())&&(next!=quote||escaped);)escaped=!escaped&&"\\"==next;escaped||(state.tokenize=tokenBase);return ret("string","string")}}function tokenComment(stream,state){for(var ch,maybeEnd=!1;ch=stream.next();){if("/"==ch&&maybeEnd){state.tokenize=tokenBase;break}maybeEnd="*"==ch}return ret("comment","comment")}function tokenQuasi(stream,state){for(var next,escaped=!1;null!=(next=stream.next());){if(!escaped&&("`"==next||"$"==next&&stream.eat("{"))){state.tokenize=tokenBase;break}escaped=!escaped&&"\\"==next}return ret("quasi","string-2",stream.current())}function findFatArrow(stream,state){state.fatArrowAt&&(state.fatArrowAt=null);var arrow=stream.string.indexOf("=>",stream.start);if(!(0>arrow)){for(var depth=0,sawSomething=!1,pos=arrow-1;pos>=0;--pos){var ch=stream.string.charAt(pos),bracket=brackets.indexOf(ch);if(bracket>=0&&3>bracket){if(!depth){++pos;break}if(0==--depth)break}else if(bracket>=3&&6>bracket)++depth;else if(wordRE.test(ch))sawSomething=!0;else{if(/["'\/]/.test(ch))return;if(sawSomething&&!depth){++pos;break}}}sawSomething&&!depth&&(state.fatArrowAt=pos)}}function JSLexical(indented,column,type,align,prev,info){this.indented=indented;this.column=column;this.type=type;this.prev=prev;this.info=info;null!=align&&(this.align=align)}function inScope(state,varname){for(var v=state.localVars;v;v=v.next)if(v.name==varname)return!0;for(var cx=state.context;cx;cx=cx.prev)for(var v=cx.vars;v;v=v.next)if(v.name==varname)return!0}function parseJS(state,style,type,content,stream){var cc=state.cc;cx.state=state;cx.stream=stream;cx.marked=null,cx.cc=cc;cx.style=style;state.lexical.hasOwnProperty("align")||(state.lexical.align=!0);for(;;){var combinator=cc.length?cc.pop():jsonMode?expression:statement;if(combinator(type,content)){for(;cc.length&&cc[cc.length-1].lex;)cc.pop()();return cx.marked?cx.marked:"variable"==type&&inScope(state,content)?"variable-2":style}}}function pass(){for(var i=arguments.length-1;i>=0;i--)cx.cc.push(arguments[i])}function cont(){pass.apply(null,arguments);return!0}function register(varname){function inList(list){for(var v=list;v;v=v.next)if(v.name==varname)return!0;return!1}var state=cx.state;cx.marked="def";if(state.context){if(inList(state.localVars))return;state.localVars={name:varname,next:state.localVars}}else{if(inList(state.globalVars))return;parserConfig.globalVars&&(state.globalVars={name:varname,next:state.globalVars})}}function pushcontext(){cx.state.context={prev:cx.state.context,vars:cx.state.localVars};cx.state.localVars=defaultVars}function popcontext(){cx.state.localVars=cx.state.context.vars;cx.state.context=cx.state.context.prev}function pushlex(type,info){var result=function(){var state=cx.state,indent=state.indented;if("stat"==state.lexical.type)indent=state.lexical.indented;else for(var outer=state.lexical;outer&&")"==outer.type&&outer.align;outer=outer.prev)indent=outer.indented;state.lexical=new JSLexical(indent,cx.stream.column(),type,null,state.lexical,info)};result.lex=!0;return result}function poplex(){var state=cx.state;if(state.lexical.prev){")"==state.lexical.type&&(state.indented=state.lexical.indented);state.lexical=state.lexical.prev}}function expect(wanted){function exp(type){return type==wanted?cont():";"==wanted?pass():cont(exp)}return exp}function statement(type,value){if("var"==type)return cont(pushlex("vardef",value.length),vardef,expect(";"),poplex);if("keyword a"==type)return cont(pushlex("form"),expression,statement,poplex);if("keyword b"==type)return cont(pushlex("form"),statement,poplex);if("{"==type)return cont(pushlex("}"),block,poplex);if(";"==type)return cont();if("if"==type){"else"==cx.state.lexical.info&&cx.state.cc[cx.state.cc.length-1]==poplex&&cx.state.cc.pop()();return cont(pushlex("form"),expression,statement,poplex,maybeelse)}return"function"==type?cont(functiondef):"for"==type?cont(pushlex("form"),forspec,statement,poplex):"variable"==type?cont(pushlex("stat"),maybelabel):"switch"==type?cont(pushlex("form"),expression,pushlex("}","switch"),expect("{"),block,poplex,poplex):"case"==type?cont(expression,expect(":")):"default"==type?cont(expect(":")):"catch"==type?cont(pushlex("form"),pushcontext,expect("("),funarg,expect(")"),statement,poplex,popcontext):"class"==type?cont(pushlex("form"),className,poplex):"export"==type?cont(pushlex("stat"),afterExport,poplex):"import"==type?cont(pushlex("stat"),afterImport,poplex):pass(pushlex("stat"),expression,expect(";"),poplex)}function expression(type){return expressionInner(type,!1)}function expressionNoComma(type){return expressionInner(type,!0)}function expressionInner(type,noComma){if(cx.state.fatArrowAt==cx.stream.start){var body=noComma?arrowBodyNoComma:arrowBody;if("("==type)return cont(pushcontext,pushlex(")"),commasep(pattern,")"),poplex,expect("=>"),body,popcontext);if("variable"==type)return pass(pushcontext,pattern,expect("=>"),body,popcontext)}var maybeop=noComma?maybeoperatorNoComma:maybeoperatorComma;return atomicTypes.hasOwnProperty(type)?cont(maybeop):"async"==type?cont(expression):"function"==type?cont(functiondef,maybeop):"keyword c"==type?cont(noComma?maybeexpressionNoComma:maybeexpression):"("==type?cont(pushlex(")"),maybeexpression,comprehension,expect(")"),poplex,maybeop):"operator"==type||"spread"==type?cont(noComma?expressionNoComma:expression):"["==type?cont(pushlex("]"),arrayLiteral,poplex,maybeop):"{"==type?contCommasep(objprop,"}",null,maybeop):"quasi"==type?pass(quasi,maybeop):"new"==type?cont(maybeTarget(noComma)):cont()}function maybeexpression(type){return type.match(/[;\}\)\],]/)?pass():pass(expression)}function maybeexpressionNoComma(type){return type.match(/[;\}\)\],]/)?pass():pass(expressionNoComma)}function maybeoperatorComma(type,value){return","==type?cont(expression):maybeoperatorNoComma(type,value,!1)}function maybeoperatorNoComma(type,value,noComma){var me=0==noComma?maybeoperatorComma:maybeoperatorNoComma,expr=0==noComma?expression:expressionNoComma;return"=>"==type?cont(pushcontext,noComma?arrowBodyNoComma:arrowBody,popcontext):"operator"==type?/\+\+|--/.test(value)?cont(me):"?"==value?cont(expression,expect(":"),expr):cont(expr):"quasi"==type?pass(quasi,me):";"!=type?"("==type?contCommasep(expressionNoComma,")","call",me):"."==type?cont(property,me):"["==type?cont(pushlex("]"),maybeexpression,expect("]"),poplex,me):void 0:void 0}function quasi(type,value){return"quasi"!=type?pass():"${"!=value.slice(value.length-2)?cont(quasi):cont(expression,continueQuasi)}function continueQuasi(type){if("}"==type){cx.marked="string-2";cx.state.tokenize=tokenQuasi;return cont(quasi)}}function arrowBody(type){findFatArrow(cx.stream,cx.state);return pass("{"==type?statement:expression)}function arrowBodyNoComma(type){findFatArrow(cx.stream,cx.state);return pass("{"==type?statement:expressionNoComma)}function maybeTarget(noComma){return function(type){return"."==type?cont(noComma?targetNoComma:target):pass(noComma?expressionNoComma:expression)}}function target(_,value){if("target"==value){cx.marked="keyword";return cont(maybeoperatorComma)}}function targetNoComma(_,value){if("target"==value){cx.marked="keyword";return cont(maybeoperatorNoComma)}}function maybelabel(type){return":"==type?cont(poplex,statement):pass(maybeoperatorComma,expect(";"),poplex)}function property(type){if("variable"==type){cx.marked="property";return cont()}}function objprop(type,value){if("async"==type)return cont(objprop);if("variable"==type||"keyword"==cx.style){cx.marked="property";return cont("get"==value||"set"==value?getterSetter:afterprop)}if("number"==type||"string"==type){cx.marked=jsonldMode?"property":cx.style+" property";return cont(afterprop)}return"jsonld-keyword"==type?cont(afterprop):"["==type?cont(expression,expect("]"),afterprop):void 0}function getterSetter(type){if("variable"!=type)return pass(afterprop);cx.marked="property";return cont(functiondef)}function afterprop(type){return":"==type?cont(expressionNoComma):"("==type?pass(functiondef):void 0}function commasep(what,end){function proceed(type){if(","==type){var lex=cx.state.lexical;"call"==lex.info&&(lex.pos=(lex.pos||0)+1);return cont(what,proceed)}return type==end?cont():cont(expect(end))}return function(type){return type==end?cont():pass(what,proceed)}}function contCommasep(what,end,info){for(var i=3;i<arguments.length;i++)cx.cc.push(arguments[i]);return cont(pushlex(end,info),commasep(what,end),poplex)}function block(type){return"}"==type?cont():pass(statement,block)}function maybetype(type){return isTS&&":"==type?cont(typedef):void 0}function maybedefault(_,value){return"="==value?cont(expressionNoComma):void 0}function typedef(type){if("variable"==type){cx.marked="variable-3";return cont()}}function vardef(){return pass(pattern,maybetype,maybeAssign,vardefCont)}function pattern(type,value){if("variable"==type){register(value);return cont()}return"spread"==type?cont(pattern):"["==type?contCommasep(pattern,"]"):"{"==type?contCommasep(proppattern,"}"):void 0}function proppattern(type,value){if("variable"==type&&!cx.stream.match(/^\s*:/,!1)){register(value);return cont(maybeAssign)}"variable"==type&&(cx.marked="property");return"spread"==type?cont(pattern):cont(expect(":"),pattern,maybeAssign)}function maybeAssign(_type,value){return"="==value?cont(expressionNoComma):void 0}function vardefCont(type){return","==type?cont(vardef):void 0}function maybeelse(type,value){return"keyword b"==type&&"else"==value?cont(pushlex("form","else"),statement,poplex):void 0}function forspec(type){return"("==type?cont(pushlex(")"),forspec1,expect(")"),poplex):void 0}function forspec1(type){return"var"==type?cont(vardef,expect(";"),forspec2):";"==type?cont(forspec2):"variable"==type?cont(formaybeinof):pass(expression,expect(";"),forspec2)}function formaybeinof(_type,value){if("in"==value||"of"==value){cx.marked="keyword";return cont(expression)}return cont(maybeoperatorComma,forspec2)}function forspec2(type,value){if(";"==type)return cont(forspec3);if("in"==value||"of"==value){cx.marked="keyword";return cont(expression)}return pass(expression,expect(";"),forspec3)}function forspec3(type){")"!=type&&cont(expression)}function functiondef(type,value){if("*"==value){cx.marked="keyword";return cont(functiondef)}if("variable"==type){register(value);return cont(functiondef)}return"("==type?cont(pushcontext,pushlex(")"),commasep(funarg,")"),poplex,statement,popcontext):void 0}function funarg(type){return"spread"==type?cont(funarg):pass(pattern,maybetype,maybedefault)}function className(type,value){if("variable"==type){register(value);return cont(classNameAfter)}}function classNameAfter(type,value){return"extends"==value?cont(expression,classNameAfter):"{"==type?cont(pushlex("}"),classBody,poplex):void 0}function classBody(type,value){if("variable"==type||"keyword"==cx.style){if("static"==value){cx.marked="keyword";return cont(classBody)}cx.marked="property";return"get"==value||"set"==value?cont(classGetterSetter,functiondef,classBody):cont(functiondef,classBody)}if("*"==value){cx.marked="keyword";return cont(classBody)}return";"==type?cont(classBody):"}"==type?cont():void 0}function classGetterSetter(type){if("variable"!=type)return pass();cx.marked="property";return cont()}function afterExport(_type,value){if("*"==value){cx.marked="keyword";return cont(maybeFrom,expect(";"))}if("default"==value){cx.marked="keyword";return cont(expression,expect(";"))}return pass(statement)}function afterImport(type){return"string"==type?cont():pass(importSpec,maybeFrom)}function importSpec(type,value){if("{"==type)return contCommasep(importSpec,"}");"variable"==type&&register(value);"*"==value&&(cx.marked="keyword");return cont(maybeAs)}function maybeAs(_type,value){if("as"==value){cx.marked="keyword";return cont(importSpec)}}function maybeFrom(_type,value){if("from"==value){cx.marked="keyword";return cont(expression)}}function arrayLiteral(type){return"]"==type?cont():pass(expressionNoComma,maybeArrayComprehension)}function maybeArrayComprehension(type){return"for"==type?pass(comprehension,expect("]")):","==type?cont(commasep(maybeexpressionNoComma,"]")):pass(commasep(expressionNoComma,"]"))}function comprehension(type){return"for"==type?cont(forspec,comprehension):"if"==type?cont(expression,comprehension):void 0}function isContinuedStatement(state,textAfter){return"operator"==state.lastType||","==state.lastType||isOperatorChar.test(textAfter.charAt(0))||/[,.]/.test(textAfter.charAt(0))}var type,content,indentUnit=config.indentUnit,statementIndent=parserConfig.statementIndent,jsonldMode=parserConfig.jsonld,jsonMode=parserConfig.json||jsonldMode,isTS=parserConfig.typescript,wordRE=parserConfig.wordCharacters||/[\w$\xa1-\uffff]/,keywords=function(){function kw(type){return{type:type,style:"keyword"}}var A=kw("keyword a"),B=kw("keyword b"),C=kw("keyword c"),operator=kw("operator"),atom={type:"atom",style:"atom"},jsKeywords={"if":kw("if"),"while":A,"with":A,"else":B,"do":B,"try":B,"finally":B,"return":C,"break":C,"continue":C,"new":kw("new"),"delete":C,"throw":C,"debugger":C,"var":kw("var"),"const":kw("var"),let:kw("var"),async:kw("async"),"function":kw("function"),"catch":kw("catch"),"for":kw("for"),"switch":kw("switch"),"case":kw("case"),"default":kw("default"),"in":operator,"typeof":operator,"instanceof":operator,"true":atom,"false":atom,"null":atom,undefined:atom,NaN:atom,Infinity:atom,"this":kw("this"),"class":kw("class"),"super":kw("atom"),await:C,"yield":C,"export":kw("export"),"import":kw("import"),"extends":C};if(isTS){var type={type:"variable",style:"variable-3"},tsKeywords={"interface":kw("interface"),"extends":kw("extends"),constructor:kw("constructor"),"public":kw("public"),"private":kw("private"),"protected":kw("protected"),"static":kw("static"),string:type,number:type,"boolean":type,any:type};for(var attr in tsKeywords)jsKeywords[attr]=tsKeywords[attr]}return jsKeywords}(),isOperatorChar=/[+\-*&%=<>!?|~^]/,isJsonldKeyword=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/,brackets="([{}])",atomicTypes={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,"this":!0,"jsonld-keyword":!0},cx={state:null,column:null,marked:null,cc:null},defaultVars={name:"this",next:{name:"arguments"}};poplex.lex=!0;return{startState:function(basecolumn){var state={tokenize:tokenBase,lastType:"sof",cc:[],lexical:new JSLexical((basecolumn||0)-indentUnit,0,"block",!1),localVars:parserConfig.localVars,context:parserConfig.localVars&&{vars:parserConfig.localVars},indented:0};parserConfig.globalVars&&"object"==typeof parserConfig.globalVars&&(state.globalVars=parserConfig.globalVars);return state},token:function(stream,state){if(stream.sol()){state.lexical.hasOwnProperty("align")||(state.lexical.align=!1);state.indented=stream.indentation();findFatArrow(stream,state)}if(state.tokenize!=tokenComment&&stream.eatSpace())return null;var style=state.tokenize(stream,state);if("comment"==type)return style;state.lastType="operator"!=type||"++"!=content&&"--"!=content?type:"incdec";return parseJS(state,style,type,content,stream)},indent:function(state,textAfter){if(state.tokenize==tokenComment)return CodeMirror.Pass;if(state.tokenize!=tokenBase)return 0;var firstChar=textAfter&&textAfter.charAt(0),lexical=state.lexical;if(!/^\s*else\b/.test(textAfter))for(var i=state.cc.length-1;i>=0;--i){var c=state.cc[i];if(c==poplex)lexical=lexical.prev;else if(c!=maybeelse)break}"stat"==lexical.type&&"}"==firstChar&&(lexical=lexical.prev);statementIndent&&")"==lexical.type&&"stat"==lexical.prev.type&&(lexical=lexical.prev);var type=lexical.type,closing=firstChar==type;return"vardef"==type?lexical.indented+("operator"==state.lastType||","==state.lastType?lexical.info+1:0):"form"==type&&"{"==firstChar?lexical.indented:"form"==type?lexical.indented+indentUnit:"stat"==type?lexical.indented+(isContinuedStatement(state,textAfter)?statementIndent||indentUnit:0):"switch"!=lexical.info||closing||0==parserConfig.doubleIndentSwitch?lexical.align?lexical.column+(closing?0:1):lexical.indented+(closing?0:indentUnit):lexical.indented+(/^(?:case|default)\b/.test(textAfter)?indentUnit:2*indentUnit)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:jsonMode?null:"/*",blockCommentEnd:jsonMode?null:"*/",lineComment:jsonMode?null:"//",fold:"brace",closeBrackets:"()[]{}''\"\"``",helperType:jsonMode?"json":"javascript",jsonldMode:jsonldMode,jsonMode:jsonMode}});CodeMirror.registerHelper("wordChars","javascript",/[\w$]/);CodeMirror.defineMIME("text/javascript","javascript");CodeMirror.defineMIME("text/ecmascript","javascript");CodeMirror.defineMIME("application/javascript","javascript");CodeMirror.defineMIME("application/x-javascript","javascript");CodeMirror.defineMIME("application/ecmascript","javascript");CodeMirror.defineMIME("application/json",{name:"javascript",json:!0});CodeMirror.defineMIME("application/x-json",{name:"javascript",json:!0});CodeMirror.defineMIME("application/ld+json",{name:"javascript",jsonld:!0});CodeMirror.defineMIME("text/typescript",{name:"javascript",typescript:!0});CodeMirror.defineMIME("application/typescript",{name:"javascript",typescript:!0})});
1
+ !function(mod){"object"==typeof exports&&"object"==typeof module?mod(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],mod):mod(CodeMirror)}(function(CodeMirror){"use strict";function expressionAllowed(stream,state,backUp){return/^(?:operator|sof|keyword c|case|new|[\[{}\(,;:]|=>)$/.test(state.lastType)||"quasi"==state.lastType&&/\{\s*$/.test(stream.string.slice(0,stream.pos-(backUp||0)))}CodeMirror.defineMode("javascript",function(config,parserConfig){function readRegexp(stream){for(var next,escaped=!1,inSet=!1;null!=(next=stream.next());){if(!escaped){if("/"==next&&!inSet)return;"["==next?inSet=!0:inSet&&"]"==next&&(inSet=!1)}escaped=!escaped&&"\\"==next}}function ret(tp,style,cont){type=tp;content=cont;return style}function tokenBase(stream,state){var ch=stream.next();if('"'==ch||"'"==ch){state.tokenize=tokenString(ch);return state.tokenize(stream,state)}if("."==ch&&stream.match(/^\d+(?:[eE][+\-]?\d+)?/))return ret("number","number");if("."==ch&&stream.match(".."))return ret("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(ch))return ret(ch);if("="==ch&&stream.eat(">"))return ret("=>","operator");if("0"==ch&&stream.eat(/x/i)){stream.eatWhile(/[\da-f]/i);return ret("number","number")}if("0"==ch&&stream.eat(/o/i)){stream.eatWhile(/[0-7]/i);return ret("number","number")}if("0"==ch&&stream.eat(/b/i)){stream.eatWhile(/[01]/i);return ret("number","number")}if(/\d/.test(ch)){stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);return ret("number","number")}if("/"==ch){if(stream.eat("*")){state.tokenize=tokenComment;return tokenComment(stream,state)}if(stream.eat("/")){stream.skipToEnd();return ret("comment","comment")}if(expressionAllowed(stream,state,1)){readRegexp(stream);stream.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/);return ret("regexp","string-2")}stream.eatWhile(isOperatorChar);return ret("operator","operator",stream.current())}if("`"==ch){state.tokenize=tokenQuasi;return tokenQuasi(stream,state)}if("#"==ch){stream.skipToEnd();return ret("error","error")}if(isOperatorChar.test(ch)){stream.eatWhile(isOperatorChar);return ret("operator","operator",stream.current())}if(wordRE.test(ch)){stream.eatWhile(wordRE);var word=stream.current(),known=keywords.propertyIsEnumerable(word)&&keywords[word];return known&&"."!=state.lastType?ret(known.type,known.style,word):ret("variable","variable",word)}}function tokenString(quote){return function(stream,state){var next,escaped=!1;if(jsonldMode&&"@"==stream.peek()&&stream.match(isJsonldKeyword)){state.tokenize=tokenBase;return ret("jsonld-keyword","meta")}for(;null!=(next=stream.next())&&(next!=quote||escaped);)escaped=!escaped&&"\\"==next;escaped||(state.tokenize=tokenBase);return ret("string","string")}}function tokenComment(stream,state){for(var ch,maybeEnd=!1;ch=stream.next();){if("/"==ch&&maybeEnd){state.tokenize=tokenBase;break}maybeEnd="*"==ch}return ret("comment","comment")}function tokenQuasi(stream,state){for(var next,escaped=!1;null!=(next=stream.next());){if(!escaped&&("`"==next||"$"==next&&stream.eat("{"))){state.tokenize=tokenBase;break}escaped=!escaped&&"\\"==next}return ret("quasi","string-2",stream.current())}function findFatArrow(stream,state){state.fatArrowAt&&(state.fatArrowAt=null);var arrow=stream.string.indexOf("=>",stream.start);if(!(0>arrow)){for(var depth=0,sawSomething=!1,pos=arrow-1;pos>=0;--pos){var ch=stream.string.charAt(pos),bracket=brackets.indexOf(ch);if(bracket>=0&&3>bracket){if(!depth){++pos;break}if(0==--depth)break}else if(bracket>=3&&6>bracket)++depth;else if(wordRE.test(ch))sawSomething=!0;else{if(/["'\/]/.test(ch))return;if(sawSomething&&!depth){++pos;break}}}sawSomething&&!depth&&(state.fatArrowAt=pos)}}function JSLexical(indented,column,type,align,prev,info){this.indented=indented;this.column=column;this.type=type;this.prev=prev;this.info=info;null!=align&&(this.align=align)}function inScope(state,varname){for(var v=state.localVars;v;v=v.next)if(v.name==varname)return!0;for(var cx=state.context;cx;cx=cx.prev)for(var v=cx.vars;v;v=v.next)if(v.name==varname)return!0}function parseJS(state,style,type,content,stream){var cc=state.cc;cx.state=state;cx.stream=stream;cx.marked=null,cx.cc=cc;cx.style=style;state.lexical.hasOwnProperty("align")||(state.lexical.align=!0);for(;;){var combinator=cc.length?cc.pop():jsonMode?expression:statement;if(combinator(type,content)){for(;cc.length&&cc[cc.length-1].lex;)cc.pop()();return cx.marked?cx.marked:"variable"==type&&inScope(state,content)?"variable-2":style}}}function pass(){for(var i=arguments.length-1;i>=0;i--)cx.cc.push(arguments[i])}function cont(){pass.apply(null,arguments);return!0}function register(varname){function inList(list){for(var v=list;v;v=v.next)if(v.name==varname)return!0;return!1}var state=cx.state;cx.marked="def";if(state.context){if(inList(state.localVars))return;state.localVars={name:varname,next:state.localVars}}else{if(inList(state.globalVars))return;parserConfig.globalVars&&(state.globalVars={name:varname,next:state.globalVars})}}function pushcontext(){cx.state.context={prev:cx.state.context,vars:cx.state.localVars};cx.state.localVars=defaultVars}function popcontext(){cx.state.localVars=cx.state.context.vars;cx.state.context=cx.state.context.prev}function pushlex(type,info){var result=function(){var state=cx.state,indent=state.indented;if("stat"==state.lexical.type)indent=state.lexical.indented;else for(var outer=state.lexical;outer&&")"==outer.type&&outer.align;outer=outer.prev)indent=outer.indented;state.lexical=new JSLexical(indent,cx.stream.column(),type,null,state.lexical,info)};result.lex=!0;return result}function poplex(){var state=cx.state;if(state.lexical.prev){")"==state.lexical.type&&(state.indented=state.lexical.indented);state.lexical=state.lexical.prev}}function expect(wanted){function exp(type){return type==wanted?cont():";"==wanted?pass():cont(exp)}return exp}function statement(type,value){if("var"==type)return cont(pushlex("vardef",value.length),vardef,expect(";"),poplex);if("keyword a"==type)return cont(pushlex("form"),expression,statement,poplex);if("keyword b"==type)return cont(pushlex("form"),statement,poplex);if("{"==type)return cont(pushlex("}"),block,poplex);if(";"==type)return cont();if("if"==type){"else"==cx.state.lexical.info&&cx.state.cc[cx.state.cc.length-1]==poplex&&cx.state.cc.pop()();return cont(pushlex("form"),expression,statement,poplex,maybeelse)}return"function"==type?cont(functiondef):"for"==type?cont(pushlex("form"),forspec,statement,poplex):"variable"==type?cont(pushlex("stat"),maybelabel):"switch"==type?cont(pushlex("form"),expression,pushlex("}","switch"),expect("{"),block,poplex,poplex):"case"==type?cont(expression,expect(":")):"default"==type?cont(expect(":")):"catch"==type?cont(pushlex("form"),pushcontext,expect("("),funarg,expect(")"),statement,poplex,popcontext):"class"==type?cont(pushlex("form"),className,poplex):"export"==type?cont(pushlex("stat"),afterExport,poplex):"import"==type?cont(pushlex("stat"),afterImport,poplex):"module"==type?cont(pushlex("form"),pattern,pushlex("}"),expect("{"),block,poplex,poplex):pass(pushlex("stat"),expression,expect(";"),poplex)}function expression(type){return expressionInner(type,!1)}function expressionNoComma(type){return expressionInner(type,!0)}function expressionInner(type,noComma){if(cx.state.fatArrowAt==cx.stream.start){var body=noComma?arrowBodyNoComma:arrowBody;if("("==type)return cont(pushcontext,pushlex(")"),commasep(pattern,")"),poplex,expect("=>"),body,popcontext);if("variable"==type)return pass(pushcontext,pattern,expect("=>"),body,popcontext)}var maybeop=noComma?maybeoperatorNoComma:maybeoperatorComma;return atomicTypes.hasOwnProperty(type)?cont(maybeop):"function"==type?cont(functiondef,maybeop):"keyword c"==type?cont(noComma?maybeexpressionNoComma:maybeexpression):"("==type?cont(pushlex(")"),maybeexpression,comprehension,expect(")"),poplex,maybeop):"operator"==type||"spread"==type?cont(noComma?expressionNoComma:expression):"["==type?cont(pushlex("]"),arrayLiteral,poplex,maybeop):"{"==type?contCommasep(objprop,"}",null,maybeop):"quasi"==type?pass(quasi,maybeop):"new"==type?cont(maybeTarget(noComma)):cont()}function maybeexpression(type){return type.match(/[;\}\)\],]/)?pass():pass(expression)}function maybeexpressionNoComma(type){return type.match(/[;\}\)\],]/)?pass():pass(expressionNoComma)}function maybeoperatorComma(type,value){return","==type?cont(expression):maybeoperatorNoComma(type,value,!1)}function maybeoperatorNoComma(type,value,noComma){var me=0==noComma?maybeoperatorComma:maybeoperatorNoComma,expr=0==noComma?expression:expressionNoComma;return"=>"==type?cont(pushcontext,noComma?arrowBodyNoComma:arrowBody,popcontext):"operator"==type?/\+\+|--/.test(value)?cont(me):"?"==value?cont(expression,expect(":"),expr):cont(expr):"quasi"==type?pass(quasi,me):";"!=type?"("==type?contCommasep(expressionNoComma,")","call",me):"."==type?cont(property,me):"["==type?cont(pushlex("]"),maybeexpression,expect("]"),poplex,me):void 0:void 0}function quasi(type,value){return"quasi"!=type?pass():"${"!=value.slice(value.length-2)?cont(quasi):cont(expression,continueQuasi)}function continueQuasi(type){if("}"==type){cx.marked="string-2";cx.state.tokenize=tokenQuasi;return cont(quasi)}}function arrowBody(type){findFatArrow(cx.stream,cx.state);return pass("{"==type?statement:expression)}function arrowBodyNoComma(type){findFatArrow(cx.stream,cx.state);return pass("{"==type?statement:expressionNoComma)}function maybeTarget(noComma){return function(type){return"."==type?cont(noComma?targetNoComma:target):pass(noComma?expressionNoComma:expression)}}function target(_,value){if("target"==value){cx.marked="keyword";return cont(maybeoperatorComma)}}function targetNoComma(_,value){if("target"==value){cx.marked="keyword";return cont(maybeoperatorNoComma)}}function maybelabel(type){return":"==type?cont(poplex,statement):pass(maybeoperatorComma,expect(";"),poplex)}function property(type){if("variable"==type){cx.marked="property";return cont()}}function objprop(type,value){if("variable"==type||"keyword"==cx.style){cx.marked="property";return cont("get"==value||"set"==value?getterSetter:afterprop)}if("number"==type||"string"==type){cx.marked=jsonldMode?"property":cx.style+" property";return cont(afterprop)}return"jsonld-keyword"==type?cont(afterprop):"modifier"==type?cont(objprop):"["==type?cont(expression,expect("]"),afterprop):"spread"==type?cont(expression):void 0}function getterSetter(type){if("variable"!=type)return pass(afterprop);cx.marked="property";return cont(functiondef)}function afterprop(type){return":"==type?cont(expressionNoComma):"("==type?pass(functiondef):void 0}function commasep(what,end){function proceed(type){if(","==type){var lex=cx.state.lexical;"call"==lex.info&&(lex.pos=(lex.pos||0)+1);return cont(what,proceed)}return type==end?cont():cont(expect(end))}return function(type){return type==end?cont():pass(what,proceed)}}function contCommasep(what,end,info){for(var i=3;i<arguments.length;i++)cx.cc.push(arguments[i]);return cont(pushlex(end,info),commasep(what,end),poplex)}function block(type){return"}"==type?cont():pass(statement,block)}function maybetype(type){return isTS&&":"==type?cont(typedef):void 0}function maybedefault(_,value){return"="==value?cont(expressionNoComma):void 0}function typedef(type){if("variable"==type){cx.marked="variable-3";return cont()}}function vardef(){return pass(pattern,maybetype,maybeAssign,vardefCont)}function pattern(type,value){if("modifier"==type)return cont(pattern);if("variable"==type){register(value);return cont()}return"spread"==type?cont(pattern):"["==type?contCommasep(pattern,"]"):"{"==type?contCommasep(proppattern,"}"):void 0}function proppattern(type,value){if("variable"==type&&!cx.stream.match(/^\s*:/,!1)){register(value);return cont(maybeAssign)}"variable"==type&&(cx.marked="property");return"spread"==type?cont(pattern):"}"==type?pass():cont(expect(":"),pattern,maybeAssign)}function maybeAssign(_type,value){return"="==value?cont(expressionNoComma):void 0}function vardefCont(type){return","==type?cont(vardef):void 0}function maybeelse(type,value){return"keyword b"==type&&"else"==value?cont(pushlex("form","else"),statement,poplex):void 0}function forspec(type){return"("==type?cont(pushlex(")"),forspec1,expect(")"),poplex):void 0}function forspec1(type){return"var"==type?cont(vardef,expect(";"),forspec2):";"==type?cont(forspec2):"variable"==type?cont(formaybeinof):pass(expression,expect(";"),forspec2)}function formaybeinof(_type,value){if("in"==value||"of"==value){cx.marked="keyword";return cont(expression)}return cont(maybeoperatorComma,forspec2)}function forspec2(type,value){if(";"==type)return cont(forspec3);if("in"==value||"of"==value){cx.marked="keyword";return cont(expression)}return pass(expression,expect(";"),forspec3)}function forspec3(type){")"!=type&&cont(expression)}function functiondef(type,value){if("*"==value){cx.marked="keyword";return cont(functiondef)}if("variable"==type){register(value);return cont(functiondef)}return"("==type?cont(pushcontext,pushlex(")"),commasep(funarg,")"),poplex,statement,popcontext):void 0}function funarg(type){return"spread"==type?cont(funarg):pass(pattern,maybetype,maybedefault)}function className(type,value){if("variable"==type){register(value);return cont(classNameAfter)}}function classNameAfter(type,value){return"extends"==value?cont(expression,classNameAfter):"{"==type?cont(pushlex("}"),classBody,poplex):void 0}function classBody(type,value){if("variable"==type||"keyword"==cx.style){if("static"==value){cx.marked="keyword";return cont(classBody)}cx.marked="property";return"get"==value||"set"==value?cont(classGetterSetter,functiondef,classBody):cont(functiondef,classBody)}if("*"==value){cx.marked="keyword";return cont(classBody)}return";"==type?cont(classBody):"}"==type?cont():void 0}function classGetterSetter(type){if("variable"!=type)return pass();cx.marked="property";return cont()}function afterExport(_type,value){if("*"==value){cx.marked="keyword";return cont(maybeFrom,expect(";"))}if("default"==value){cx.marked="keyword";return cont(expression,expect(";"))}return pass(statement)}function afterImport(type){return"string"==type?cont():pass(importSpec,maybeFrom)}function importSpec(type,value){if("{"==type)return contCommasep(importSpec,"}");"variable"==type&&register(value);"*"==value&&(cx.marked="keyword");return cont(maybeAs)}function maybeAs(_type,value){if("as"==value){cx.marked="keyword";return cont(importSpec)}}function maybeFrom(_type,value){if("from"==value){cx.marked="keyword";return cont(expression)}}function arrayLiteral(type){return"]"==type?cont():pass(expressionNoComma,maybeArrayComprehension)}function maybeArrayComprehension(type){return"for"==type?pass(comprehension,expect("]")):","==type?cont(commasep(maybeexpressionNoComma,"]")):pass(commasep(expressionNoComma,"]"))}function comprehension(type){return"for"==type?cont(forspec,comprehension):"if"==type?cont(expression,comprehension):void 0}function isContinuedStatement(state,textAfter){return"operator"==state.lastType||","==state.lastType||isOperatorChar.test(textAfter.charAt(0))||/[,.]/.test(textAfter.charAt(0))}var type,content,indentUnit=config.indentUnit,statementIndent=parserConfig.statementIndent,jsonldMode=parserConfig.jsonld,jsonMode=parserConfig.json||jsonldMode,isTS=parserConfig.typescript,wordRE=parserConfig.wordCharacters||/[\w$\xa1-\uffff]/,keywords=function(){function kw(type){return{type:type,style:"keyword"}}var A=kw("keyword a"),B=kw("keyword b"),C=kw("keyword c"),operator=kw("operator"),atom={type:"atom",style:"atom"},jsKeywords={"if":kw("if"),"while":A,"with":A,"else":B,"do":B,"try":B,"finally":B,"return":C,"break":C,"continue":C,"new":kw("new"),"delete":C,"throw":C,"debugger":C,"var":kw("var"),"const":kw("var"),let:kw("var"),"function":kw("function"),"catch":kw("catch"),"for":kw("for"),"switch":kw("switch"),"case":kw("case"),"default":kw("default"),"in":operator,"typeof":operator,"instanceof":operator,"true":atom,"false":atom,"null":atom,undefined:atom,NaN:atom,Infinity:atom,"this":kw("this"),"class":kw("class"),"super":kw("atom"),"yield":C,"export":kw("export"),"import":kw("import"),"extends":C};if(isTS){var type={type:"variable",style:"variable-3"},tsKeywords={"interface":kw("class"),"implements":C,namespace:C,module:kw("module"),"enum":kw("module"),"public":kw("modifier"),"private":kw("modifier"),"protected":kw("modifier"),"abstract":kw("modifier"),as:operator,string:type,number:type,"boolean":type,any:type};for(var attr in tsKeywords)jsKeywords[attr]=tsKeywords[attr]}return jsKeywords}(),isOperatorChar=/[+\-*&%=<>!?|~^]/,isJsonldKeyword=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/,brackets="([{}])",atomicTypes={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,"this":!0,"jsonld-keyword":!0},cx={state:null,column:null,marked:null,cc:null},defaultVars={name:"this",next:{name:"arguments"}};poplex.lex=!0;return{startState:function(basecolumn){var state={tokenize:tokenBase,lastType:"sof",cc:[],lexical:new JSLexical((basecolumn||0)-indentUnit,0,"block",!1),localVars:parserConfig.localVars,context:parserConfig.localVars&&{vars:parserConfig.localVars},indented:basecolumn||0};parserConfig.globalVars&&"object"==typeof parserConfig.globalVars&&(state.globalVars=parserConfig.globalVars);return state},token:function(stream,state){if(stream.sol()){state.lexical.hasOwnProperty("align")||(state.lexical.align=!1);state.indented=stream.indentation();findFatArrow(stream,state)}if(state.tokenize!=tokenComment&&stream.eatSpace())return null;var style=state.tokenize(stream,state);if("comment"==type)return style;state.lastType="operator"!=type||"++"!=content&&"--"!=content?type:"incdec";return parseJS(state,style,type,content,stream)},indent:function(state,textAfter){if(state.tokenize==tokenComment)return CodeMirror.Pass;if(state.tokenize!=tokenBase)return 0;var firstChar=textAfter&&textAfter.charAt(0),lexical=state.lexical;if(!/^\s*else\b/.test(textAfter))for(var i=state.cc.length-1;i>=0;--i){var c=state.cc[i];if(c==poplex)lexical=lexical.prev;else if(c!=maybeelse)break}"stat"==lexical.type&&"}"==firstChar&&(lexical=lexical.prev);statementIndent&&")"==lexical.type&&"stat"==lexical.prev.type&&(lexical=lexical.prev);var type=lexical.type,closing=firstChar==type;return"vardef"==type?lexical.indented+("operator"==state.lastType||","==state.lastType?lexical.info+1:0):"form"==type&&"{"==firstChar?lexical.indented:"form"==type?lexical.indented+indentUnit:"stat"==type?lexical.indented+(isContinuedStatement(state,textAfter)?statementIndent||indentUnit:0):"switch"!=lexical.info||closing||0==parserConfig.doubleIndentSwitch?lexical.align?lexical.column+(closing?0:1):lexical.indented+(closing?0:indentUnit):lexical.indented+(/^(?:case|default)\b/.test(textAfter)?indentUnit:2*indentUnit)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:jsonMode?null:"/*",blockCommentEnd:jsonMode?null:"*/",lineComment:jsonMode?null:"//",fold:"brace",closeBrackets:"()[]{}''\"\"``",helperType:jsonMode?"json":"javascript",jsonldMode:jsonldMode,jsonMode:jsonMode,expressionAllowed:expressionAllowed,skipExpression:function(state){var top=state.cc[state.cc.length-1];(top==expression||top==expressionNoComma)&&state.cc.pop()}}});CodeMirror.registerHelper("wordChars","javascript",/[\w$]/);CodeMirror.defineMIME("text/javascript","javascript");CodeMirror.defineMIME("text/ecmascript","javascript");CodeMirror.defineMIME("application/javascript","javascript");CodeMirror.defineMIME("application/x-javascript","javascript");CodeMirror.defineMIME("application/ecmascript","javascript");CodeMirror.defineMIME("application/json",{name:"javascript",json:!0});CodeMirror.defineMIME("application/x-json",{name:"javascript",json:!0});CodeMirror.defineMIME("application/ld+json",{name:"javascript",jsonld:!0});CodeMirror.defineMIME("text/typescript",{name:"javascript",typescript:!0});CodeMirror.defineMIME("application/typescript",{name:"javascript",typescript:!0})});
js/esites_editor/dist/js/vendor/codemirror/mode/xml/xml.js CHANGED
@@ -1 +1 @@
1
- !function(mod){"object"==typeof exports&&"object"==typeof module?mod(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],mod):mod(CodeMirror)}(function(CodeMirror){"use strict";CodeMirror.defineMode("xml",function(config,parserConfig){function inText(stream,state){function chain(parser){state.tokenize=parser;return parser(stream,state)}var ch=stream.next();if("<"==ch){if(stream.eat("!")){if(stream.eat("["))return stream.match("CDATA[")?chain(inBlock("atom","]]>")):null;if(stream.match("--"))return chain(inBlock("comment","-->"));if(stream.match("DOCTYPE",!0,!0)){stream.eatWhile(/[\w\._\-]/);return chain(doctype(1))}return null}if(stream.eat("?")){stream.eatWhile(/[\w\._\-]/);state.tokenize=inBlock("meta","?>");return"meta"}type=stream.eat("/")?"closeTag":"openTag";state.tokenize=inTag;return"tag bracket"}if("&"==ch){var ok;ok=stream.eat("#")?stream.eat("x")?stream.eatWhile(/[a-fA-F\d]/)&&stream.eat(";"):stream.eatWhile(/[\d]/)&&stream.eat(";"):stream.eatWhile(/[\w\.\-:]/)&&stream.eat(";");return ok?"atom":"error"}stream.eatWhile(/[^&<]/);return null}function inTag(stream,state){var ch=stream.next();if(">"==ch||"/"==ch&&stream.eat(">")){state.tokenize=inText;type=">"==ch?"endTag":"selfcloseTag";return"tag bracket"}if("="==ch){type="equals";return null}if("<"==ch){state.tokenize=inText;state.state=baseState;state.tagName=state.tagStart=null;var next=state.tokenize(stream,state);return next?next+" tag error":"tag error"}if(/[\'\"]/.test(ch)){state.tokenize=inAttribute(ch);state.stringStartCol=stream.column();return state.tokenize(stream,state)}stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/);return"word"}function inAttribute(quote){var closure=function(stream,state){for(;!stream.eol();)if(stream.next()==quote){state.tokenize=inTag;break}return"string"};closure.isInAttribute=!0;return closure}function inBlock(style,terminator){return function(stream,state){for(;!stream.eol();){if(stream.match(terminator)){state.tokenize=inText;break}stream.next()}return style}}function doctype(depth){return function(stream,state){for(var ch;null!=(ch=stream.next());){if("<"==ch){state.tokenize=doctype(depth+1);return state.tokenize(stream,state)}if(">"==ch){if(1==depth){state.tokenize=inText;break}state.tokenize=doctype(depth-1);return state.tokenize(stream,state)}}return"meta"}}function Context(state,tagName,startOfLine){this.prev=state.context;this.tagName=tagName;this.indent=state.indented;this.startOfLine=startOfLine;(Kludges.doNotIndent.hasOwnProperty(tagName)||state.context&&state.context.noIndent)&&(this.noIndent=!0)}function popContext(state){state.context&&(state.context=state.context.prev)}function maybePopContext(state,nextTagName){for(var parentTagName;;){if(!state.context)return;parentTagName=state.context.tagName;if(!Kludges.contextGrabbers.hasOwnProperty(parentTagName)||!Kludges.contextGrabbers[parentTagName].hasOwnProperty(nextTagName))return;popContext(state)}}function baseState(type,stream,state){if("openTag"==type){state.tagStart=stream.column();return tagNameState}return"closeTag"==type?closeTagNameState:baseState}function tagNameState(type,stream,state){if("word"==type){state.tagName=stream.current();setStyle="tag";return attrState}setStyle="error";return tagNameState}function closeTagNameState(type,stream,state){if("word"==type){var tagName=stream.current();state.context&&state.context.tagName!=tagName&&Kludges.implicitlyClosed.hasOwnProperty(state.context.tagName)&&popContext(state);if(state.context&&state.context.tagName==tagName){setStyle="tag";return closeState}setStyle="tag error";return closeStateErr}setStyle="error";return closeStateErr}function closeState(type,_stream,state){if("endTag"!=type){setStyle="error";return closeState}popContext(state);return baseState}function closeStateErr(type,stream,state){setStyle="error";return closeState(type,stream,state)}function attrState(type,_stream,state){if("word"==type){setStyle="attribute";return attrEqState}if("endTag"==type||"selfcloseTag"==type){var tagName=state.tagName,tagStart=state.tagStart;state.tagName=state.tagStart=null;if("selfcloseTag"==type||Kludges.autoSelfClosers.hasOwnProperty(tagName))maybePopContext(state,tagName);else{maybePopContext(state,tagName);state.context=new Context(state,tagName,tagStart==state.indented)}return baseState}setStyle="error";return attrState}function attrEqState(type,stream,state){if("equals"==type)return attrValueState;Kludges.allowMissing||(setStyle="error");return attrState(type,stream,state)}function attrValueState(type,stream,state){if("string"==type)return attrContinuedState;if("word"==type&&Kludges.allowUnquoted){setStyle="string";return attrState}setStyle="error";return attrState(type,stream,state)}function attrContinuedState(type,stream,state){return"string"==type?attrContinuedState:attrState(type,stream,state)}var indentUnit=config.indentUnit,multilineTagIndentFactor=parserConfig.multilineTagIndentFactor||1,multilineTagIndentPastTag=parserConfig.multilineTagIndentPastTag;null==multilineTagIndentPastTag&&(multilineTagIndentPastTag=!0);var type,setStyle,Kludges=parserConfig.htmlMode?{autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0}:{autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,caseFold:!1},alignCDATA=parserConfig.alignCDATA;inText.isInText=!0;return{startState:function(){return{tokenize:inText,state:baseState,indented:0,tagName:null,tagStart:null,context:null}},token:function(stream,state){!state.tagName&&stream.sol()&&(state.indented=stream.indentation());if(stream.eatSpace())return null;type=null;var style=state.tokenize(stream,state);if((style||type)&&"comment"!=style){setStyle=null;state.state=state.state(type||style,stream,state);setStyle&&(style="error"==setStyle?style+" error":setStyle)}return style},indent:function(state,textAfter,fullLine){var context=state.context;if(state.tokenize.isInAttribute)return state.tagStart==state.indented?state.stringStartCol+1:state.indented+indentUnit;if(context&&context.noIndent)return CodeMirror.Pass;if(state.tokenize!=inTag&&state.tokenize!=inText)return fullLine?fullLine.match(/^(\s*)/)[0].length:0;if(state.tagName)return multilineTagIndentPastTag?state.tagStart+state.tagName.length+2:state.tagStart+indentUnit*multilineTagIndentFactor;if(alignCDATA&&/<!\[CDATA\[/.test(textAfter))return 0;var tagAfter=textAfter&&/^<(\/)?([\w_:\.-]*)/.exec(textAfter);if(tagAfter&&tagAfter[1])for(;context;){if(context.tagName==tagAfter[2]){context=context.prev;break}if(!Kludges.implicitlyClosed.hasOwnProperty(context.tagName))break;context=context.prev}else if(tagAfter)for(;context;){var grabbers=Kludges.contextGrabbers[context.tagName];if(!grabbers||!grabbers.hasOwnProperty(tagAfter[2]))break;context=context.prev}for(;context&&!context.startOfLine;)context=context.prev;return context?context.indent+indentUnit:0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:parserConfig.htmlMode?"html":"xml",helperType:parserConfig.htmlMode?"html":"xml"}});CodeMirror.defineMIME("text/xml","xml");CodeMirror.defineMIME("application/xml","xml");CodeMirror.mimeModes.hasOwnProperty("text/html")||CodeMirror.defineMIME("text/html",{name:"xml",htmlMode:!0})});
1
+ !function(mod){"object"==typeof exports&&"object"==typeof module?mod(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],mod):mod(CodeMirror)}(function(CodeMirror){"use strict";var htmlConfig={autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0},xmlConfig={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,caseFold:!1};CodeMirror.defineMode("xml",function(editorConf,config_){function inText(stream,state){function chain(parser){state.tokenize=parser;return parser(stream,state)}var ch=stream.next();if("<"==ch){if(stream.eat("!")){if(stream.eat("["))return stream.match("CDATA[")?chain(inBlock("atom","]]>")):null;if(stream.match("--"))return chain(inBlock("comment","-->"));if(stream.match("DOCTYPE",!0,!0)){stream.eatWhile(/[\w\._\-]/);return chain(doctype(1))}return null}if(stream.eat("?")){stream.eatWhile(/[\w\._\-]/);state.tokenize=inBlock("meta","?>");return"meta"}type=stream.eat("/")?"closeTag":"openTag";state.tokenize=inTag;return"tag bracket"}if("&"==ch){var ok;ok=stream.eat("#")?stream.eat("x")?stream.eatWhile(/[a-fA-F\d]/)&&stream.eat(";"):stream.eatWhile(/[\d]/)&&stream.eat(";"):stream.eatWhile(/[\w\.\-:]/)&&stream.eat(";");return ok?"atom":"error"}stream.eatWhile(/[^&<]/);return null}function inTag(stream,state){var ch=stream.next();if(">"==ch||"/"==ch&&stream.eat(">")){state.tokenize=inText;type=">"==ch?"endTag":"selfcloseTag";return"tag bracket"}if("="==ch){type="equals";return null}if("<"==ch){state.tokenize=inText;state.state=baseState;state.tagName=state.tagStart=null;var next=state.tokenize(stream,state);return next?next+" tag error":"tag error"}if(/[\'\"]/.test(ch)){state.tokenize=inAttribute(ch);state.stringStartCol=stream.column();return state.tokenize(stream,state)}stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/);return"word"}function inAttribute(quote){var closure=function(stream,state){for(;!stream.eol();)if(stream.next()==quote){state.tokenize=inTag;break}return"string"};closure.isInAttribute=!0;return closure}function inBlock(style,terminator){return function(stream,state){for(;!stream.eol();){if(stream.match(terminator)){state.tokenize=inText;break}stream.next()}return style}}function doctype(depth){return function(stream,state){for(var ch;null!=(ch=stream.next());){if("<"==ch){state.tokenize=doctype(depth+1);return state.tokenize(stream,state)}if(">"==ch){if(1==depth){state.tokenize=inText;break}state.tokenize=doctype(depth-1);return state.tokenize(stream,state)}}return"meta"}}function Context(state,tagName,startOfLine){this.prev=state.context;this.tagName=tagName;this.indent=state.indented;this.startOfLine=startOfLine;(config.doNotIndent.hasOwnProperty(tagName)||state.context&&state.context.noIndent)&&(this.noIndent=!0)}function popContext(state){state.context&&(state.context=state.context.prev)}function maybePopContext(state,nextTagName){for(var parentTagName;;){if(!state.context)return;parentTagName=state.context.tagName;if(!config.contextGrabbers.hasOwnProperty(parentTagName)||!config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName))return;popContext(state)}}function baseState(type,stream,state){if("openTag"==type){state.tagStart=stream.column();return tagNameState}return"closeTag"==type?closeTagNameState:baseState}function tagNameState(type,stream,state){if("word"==type){state.tagName=stream.current();setStyle="tag";return attrState}setStyle="error";return tagNameState}function closeTagNameState(type,stream,state){if("word"==type){var tagName=stream.current();state.context&&state.context.tagName!=tagName&&config.implicitlyClosed.hasOwnProperty(state.context.tagName)&&popContext(state);if(state.context&&state.context.tagName==tagName||config.matchClosing===!1){setStyle="tag";return closeState}setStyle="tag error";return closeStateErr}setStyle="error";return closeStateErr}function closeState(type,_stream,state){if("endTag"!=type){setStyle="error";return closeState}popContext(state);return baseState}function closeStateErr(type,stream,state){setStyle="error";return closeState(type,stream,state)}function attrState(type,_stream,state){if("word"==type){setStyle="attribute";return attrEqState}if("endTag"==type||"selfcloseTag"==type){var tagName=state.tagName,tagStart=state.tagStart;state.tagName=state.tagStart=null;if("selfcloseTag"==type||config.autoSelfClosers.hasOwnProperty(tagName))maybePopContext(state,tagName);else{maybePopContext(state,tagName);state.context=new Context(state,tagName,tagStart==state.indented)}return baseState}setStyle="error";return attrState}function attrEqState(type,stream,state){if("equals"==type)return attrValueState;config.allowMissing||(setStyle="error");return attrState(type,stream,state)}function attrValueState(type,stream,state){if("string"==type)return attrContinuedState;if("word"==type&&config.allowUnquoted){setStyle="string";return attrState}setStyle="error";return attrState(type,stream,state)}function attrContinuedState(type,stream,state){return"string"==type?attrContinuedState:attrState(type,stream,state)}var indentUnit=editorConf.indentUnit,config={},defaults=config_.htmlMode?htmlConfig:xmlConfig;for(var prop in defaults)config[prop]=defaults[prop];for(var prop in config_)config[prop]=config_[prop];var type,setStyle;inText.isInText=!0;return{startState:function(baseIndent){var state={tokenize:inText,state:baseState,indented:baseIndent||0,tagName:null,tagStart:null,context:null};null!=baseIndent&&(state.baseIndent=baseIndent);return state},token:function(stream,state){!state.tagName&&stream.sol()&&(state.indented=stream.indentation());if(stream.eatSpace())return null;type=null;var style=state.tokenize(stream,state);if((style||type)&&"comment"!=style){setStyle=null;state.state=state.state(type||style,stream,state);setStyle&&(style="error"==setStyle?style+" error":setStyle)}return style},indent:function(state,textAfter,fullLine){var context=state.context;if(state.tokenize.isInAttribute)return state.tagStart==state.indented?state.stringStartCol+1:state.indented+indentUnit;if(context&&context.noIndent)return CodeMirror.Pass;if(state.tokenize!=inTag&&state.tokenize!=inText)return fullLine?fullLine.match(/^(\s*)/)[0].length:0;if(state.tagName)return config.multilineTagIndentPastTag!==!1?state.tagStart+state.tagName.length+2:state.tagStart+indentUnit*(config.multilineTagIndentFactor||1);if(config.alignCDATA&&/<!\[CDATA\[/.test(textAfter))return 0;var tagAfter=textAfter&&/^<(\/)?([\w_:\.-]*)/.exec(textAfter);if(tagAfter&&tagAfter[1])for(;context;){if(context.tagName==tagAfter[2]){context=context.prev;break}if(!config.implicitlyClosed.hasOwnProperty(context.tagName))break;context=context.prev}else if(tagAfter)for(;context;){var grabbers=config.contextGrabbers[context.tagName];if(!grabbers||!grabbers.hasOwnProperty(tagAfter[2]))break;context=context.prev}for(;context&&context.prev&&!context.startOfLine;)context=context.prev;return context?context.indent+indentUnit:state.baseIndent||0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:config.htmlMode?"html":"xml",helperType:config.htmlMode?"html":"xml",skipAttribute:function(state){state.state==attrValueState&&(state.state=attrState)}}});CodeMirror.defineMIME("text/xml","xml");CodeMirror.defineMIME("application/xml","xml");CodeMirror.mimeModes.hasOwnProperty("text/html")||CodeMirror.defineMIME("text/html",{name:"xml",htmlMode:!0})});
js/esites_editor/dist/js/vendor/codemirror/theme/icecoder.css CHANGED
@@ -1 +1 @@
1
- .cm-s-icecoder{color:#666;background:#141612}.cm-s-icecoder span.cm-keyword{color:#eee;font-weight:700}.cm-s-icecoder span.cm-atom{color:#e1c76e}.cm-s-icecoder span.cm-number{color:#6cb5d9}.cm-s-icecoder span.cm-def{color:#b9ca4a}.cm-s-icecoder span.cm-variable{color:#6cb5d9}.cm-s-icecoder span.cm-variable-2{color:#cc1e5c}.cm-s-icecoder span.cm-variable-3{color:#f9602c}.cm-s-icecoder span.cm-property{color:#eee}.cm-s-icecoder span.cm-operator{color:#9179bb}.cm-s-icecoder span.cm-comment{color:#97a3aa}.cm-s-icecoder span.cm-string{color:#b9ca4a}.cm-s-icecoder span.cm-string-2{color:#6cb5d9}.cm-s-icecoder span.cm-meta,.cm-s-icecoder span.cm-qualifier{color:#555}.cm-s-icecoder span.cm-builtin{color:#214e7b}.cm-s-icecoder span.cm-bracket{color:#cc7}.cm-s-icecoder span.cm-tag{color:#e8e8e8}.cm-s-icecoder span.cm-attribute{color:#099}.cm-s-icecoder span.cm-header{color:#6a0d6a}.cm-s-icecoder span.cm-quote{color:#186718}.cm-s-icecoder span.cm-hr{color:#888}.cm-s-icecoder span.cm-link{color:#e1c76e}.cm-s-icecoder span.cm-error{color:#d00}.cm-s-icecoder .CodeMirror-cursor{border-left:1px solid #fff}.cm-s-icecoder div.CodeMirror-selected{color:#fff;background:#037}.cm-s-icecoder .CodeMirror-gutters{background:#141612;min-width:41px;border-right:0}.cm-s-icecoder .CodeMirror-linenumber{color:#555;cursor:default}.cm-s-icecoder .CodeMirror-matchingbracket{border:1px solid grey;color:#000!important}.cm-s-icecoder .CodeMirror-activeline-background{background:#000}
1
+ .cm-s-icecoder{color:#666;background:#1d1d1b}.cm-s-icecoder span.cm-keyword{color:#eee;font-weight:700}.cm-s-icecoder span.cm-atom{color:#e1c76e}.cm-s-icecoder span.cm-number{color:#6cb5d9}.cm-s-icecoder span.cm-def{color:#b9ca4a}.cm-s-icecoder span.cm-variable{color:#6cb5d9}.cm-s-icecoder span.cm-variable-2{color:#cc1e5c}.cm-s-icecoder span.cm-variable-3{color:#f9602c}.cm-s-icecoder span.cm-property{color:#eee}.cm-s-icecoder span.cm-operator{color:#9179bb}.cm-s-icecoder span.cm-comment{color:#97a3aa}.cm-s-icecoder span.cm-string{color:#b9ca4a}.cm-s-icecoder span.cm-string-2{color:#6cb5d9}.cm-s-icecoder span.cm-meta,.cm-s-icecoder span.cm-qualifier{color:#555}.cm-s-icecoder span.cm-builtin{color:#214e7b}.cm-s-icecoder span.cm-bracket{color:#cc7}.cm-s-icecoder span.cm-tag{color:#e8e8e8}.cm-s-icecoder span.cm-attribute{color:#099}.cm-s-icecoder span.cm-header{color:#6a0d6a}.cm-s-icecoder span.cm-quote{color:#186718}.cm-s-icecoder span.cm-hr{color:#888}.cm-s-icecoder span.cm-link{color:#e1c76e}.cm-s-icecoder span.cm-error{color:#d00}.cm-s-icecoder .CodeMirror-cursor{border-left:1px solid #fff}.cm-s-icecoder div.CodeMirror-selected{color:#fff;background:#037}.cm-s-icecoder .CodeMirror-gutters{background:#1d1d1b;min-width:41px;border-right:0}.cm-s-icecoder .CodeMirror-linenumber{color:#555;cursor:default}.cm-s-icecoder .CodeMirror-matchingbracket{color:#fff!important;background:#555!important}.cm-s-icecoder .CodeMirror-activeline-background{background:#000}
js/esites_editor/dist/js/vendor/codemirror/theme/material.css CHANGED
@@ -1 +1 @@
1
- .cm-s-material{background-color:#263238;color:rgba(233,237,237,1)}.cm-s-material .CodeMirror-gutters{background:#263238;color:#537f7e;border:none}.cm-s-material .CodeMirror-guttermarker,.cm-s-material .CodeMirror-guttermarker-subtle,.cm-s-material .CodeMirror-linenumber{color:#537f7e}.cm-s-material .CodeMirror-cursor{border-left:1px solid #f8f8f0}.cm-s-material div.CodeMirror-selected{background:rgba(255,255,255,.15)}.cm-s-material .CodeMirror-line::selection,.cm-s-material .CodeMirror-line>span::selection,.cm-s-material .CodeMirror-line>span>span::selection,.cm-s-material.CodeMirror-focused div.CodeMirror-selected{background:rgba(255,255,255,.1)}.cm-s-material .CodeMirror-line::-moz-selection,.cm-s-material .CodeMirror-line>span::-moz-selection,.cm-s-material .CodeMirror-line>span>span::-moz-selection{background:rgba(255,255,255,.1)}.cm-s-material .CodeMirror-activeline-background{background:0 0}.cm-s-material .cm-keyword{color:rgba(199,146,234,1)}.cm-s-material .cm-operator{color:rgba(233,237,237,1)}.cm-s-material .cm-variable-2{color:#80CBC4}.cm-s-material .cm-builtin{color:#DECB6B}.cm-s-material .cm-atom,.cm-s-material .cm-number{color:#F77669}.cm-s-material .cm-def{color:rgba(233,237,237,1)}.cm-s-material .cm-error{color:rgba(255,255,255,1);background-color:#EC5F67}.cm-s-material .cm-string{color:#C3E88D}.cm-s-material .cm-string-2{color:#80CBC4}.cm-s-material .cm-comment{color:#546E7A}.cm-s-material .cm-variable{color:#82B1FF}.cm-s-material .cm-meta,.cm-s-material .cm-tag{color:#80CBC4}.cm-s-material .cm-attribute{color:#FFCB6B}.cm-s-material .cm-property{color:#80CBAE}.cm-s-material .cm-qualifier,.cm-s-material .cm-variable-3{color:#DECB6B}.cm-s-material .cm-tag{color:rgba(255,83,112,1)}.cm-s-material .CodeMirror-matchingbracket{text-decoration:underline;color:#fff!important}
1
+ .cm-s-material{background-color:#263238;color:rgba(233,237,237,1)}.cm-s-material .CodeMirror-gutters{background:#263238;color:#537f7e;border:none}.cm-s-material .CodeMirror-guttermarker,.cm-s-material .CodeMirror-guttermarker-subtle,.cm-s-material .CodeMirror-linenumber{color:#537f7e}.cm-s-material .CodeMirror-cursor{border-left:1px solid #f8f8f0}.cm-s-material div.CodeMirror-selected{background:rgba(255,255,255,.15)}.cm-s-material .CodeMirror-line::selection,.cm-s-material .CodeMirror-line>span::selection,.cm-s-material .CodeMirror-line>span>span::selection,.cm-s-material.CodeMirror-focused div.CodeMirror-selected{background:rgba(255,255,255,.1)}.cm-s-material .CodeMirror-line::-moz-selection,.cm-s-material .CodeMirror-line>span::-moz-selection,.cm-s-material .CodeMirror-line>span>span::-moz-selection{background:rgba(255,255,255,.1)}.cm-s-material .CodeMirror-activeline-background{background:0 0}.cm-s-material .cm-keyword{color:rgba(199,146,234,1)}.cm-s-material .cm-operator{color:rgba(233,237,237,1)}.cm-s-material .cm-variable-2{color:#80CBC4}.cm-s-material .cm-builtin{color:#DECB6B}.cm-s-material .cm-atom,.cm-s-material .cm-number{color:#F77669}.cm-s-material .cm-def{color:rgba(233,237,237,1)}.cm-s-material .cm-string{color:#C3E88D}.cm-s-material .cm-string-2{color:#80CBC4}.cm-s-material .cm-comment{color:#546E7A}.cm-s-material .cm-variable{color:#82B1FF}.cm-s-material .cm-meta,.cm-s-material .cm-tag{color:#80CBC4}.cm-s-material .cm-attribute{color:#FFCB6B}.cm-s-material .cm-property{color:#80CBAE}.cm-s-material .cm-qualifier,.cm-s-material .cm-variable-3{color:#DECB6B}.cm-s-material .cm-tag{color:rgba(255,83,112,1)}.cm-s-material .cm-error{color:rgba(255,255,255,1);background-color:#EC5F67}.cm-s-material .CodeMirror-matchingbracket{text-decoration:underline;color:#fff!important}
js/esites_editor/dist/js/vendor/codemirror/theme/mbo.css CHANGED
@@ -1 +1 @@
1
- .cm-s-mbo.CodeMirror{background:#2c2c2c;color:#ffffec}.cm-s-mbo div.CodeMirror-selected{background:#716C62}.cm-s-mbo .CodeMirror-line::selection,.cm-s-mbo .CodeMirror-line>span::selection,.cm-s-mbo .CodeMirror-line>span>span::selection{background:rgba(113,108,98,.99)}.cm-s-mbo .CodeMirror-line::-moz-selection,.cm-s-mbo .CodeMirror-line>span::-moz-selection,.cm-s-mbo .CodeMirror-line>span>span::-moz-selection{background:rgba(113,108,98,.99)}.cm-s-mbo .CodeMirror-gutters{background:#4e4e4e;border-right:0}.cm-s-mbo .CodeMirror-guttermarker{color:#fff}.cm-s-mbo .CodeMirror-guttermarker-subtle{color:grey}.cm-s-mbo .CodeMirror-linenumber{color:#dadada}.cm-s-mbo .CodeMirror-cursor{border-left:1px solid #ffffec}.cm-s-mbo span.cm-comment{color:#95958a}.cm-s-mbo span.cm-atom,.cm-s-mbo span.cm-number{color:#00a8c6}.cm-s-mbo span.cm-attribute,.cm-s-mbo span.cm-property{color:#9ddfe9}.cm-s-mbo span.cm-keyword{color:#ffb928}.cm-s-mbo span.cm-string{color:#ffcf6c}.cm-s-mbo span.cm-string.cm-property,.cm-s-mbo span.cm-variable{color:#ffffec}.cm-s-mbo span.cm-variable-2{color:#00a8c6}.cm-s-mbo span.cm-def{color:#ffffec}.cm-s-mbo span.cm-bracket{color:#fffffc;font-weight:700}.cm-s-mbo span.cm-tag{color:#9ddfe9}.cm-s-mbo span.cm-link{color:#f54b07}.cm-s-mbo span.cm-error{border-bottom:#636363;color:#ffffec}.cm-s-mbo span.cm-qualifier{color:#ffffec}.cm-s-mbo .CodeMirror-activeline-background{background:#494b41}.cm-s-mbo .CodeMirror-matchingbracket{color:#222!important}.cm-s-mbo .CodeMirror-matchingtag{background:rgba(255,255,255,.37)}
1
+ .cm-s-mbo.CodeMirror{background:#2c2c2c;color:#ffffec}.cm-s-mbo div.CodeMirror-selected{background:#716C62}.cm-s-mbo .CodeMirror-line::selection,.cm-s-mbo .CodeMirror-line>span::selection,.cm-s-mbo .CodeMirror-line>span>span::selection{background:rgba(113,108,98,.99)}.cm-s-mbo .CodeMirror-line::-moz-selection,.cm-s-mbo .CodeMirror-line>span::-moz-selection,.cm-s-mbo .CodeMirror-line>span>span::-moz-selection{background:rgba(113,108,98,.99)}.cm-s-mbo .CodeMirror-gutters{background:#4e4e4e;border-right:0}.cm-s-mbo .CodeMirror-guttermarker{color:#fff}.cm-s-mbo .CodeMirror-guttermarker-subtle{color:grey}.cm-s-mbo .CodeMirror-linenumber{color:#dadada}.cm-s-mbo .CodeMirror-cursor{border-left:1px solid #ffffec}.cm-s-mbo span.cm-comment{color:#95958a}.cm-s-mbo span.cm-atom,.cm-s-mbo span.cm-number{color:#00a8c6}.cm-s-mbo span.cm-attribute,.cm-s-mbo span.cm-property{color:#9ddfe9}.cm-s-mbo span.cm-keyword{color:#ffb928}.cm-s-mbo span.cm-string{color:#ffcf6c}.cm-s-mbo span.cm-string.cm-property,.cm-s-mbo span.cm-variable{color:#ffffec}.cm-s-mbo span.cm-variable-2{color:#00a8c6}.cm-s-mbo span.cm-def{color:#ffffec}.cm-s-mbo span.cm-bracket{color:#fffffc;font-weight:700}.cm-s-mbo span.cm-tag{color:#9ddfe9}.cm-s-mbo span.cm-link{color:#f54b07}.cm-s-mbo span.cm-error{border-bottom:#636363;color:#ffffec}.cm-s-mbo span.cm-qualifier{color:#ffffec}.cm-s-mbo .CodeMirror-activeline-background{background:#494b41}.cm-s-mbo .CodeMirror-matchingbracket{color:#ffb928!important}.cm-s-mbo .CodeMirror-matchingtag{background:rgba(255,255,255,.37)}
js/esites_editor/dist/js/vendor/codemirror/theme/monokai.css CHANGED
@@ -1 +1 @@
1
- .cm-s-monokai.CodeMirror{background:#272822;color:#f8f8f2}.cm-s-monokai div.CodeMirror-selected{background:#49483E}.cm-s-monokai .CodeMirror-line::selection,.cm-s-monokai .CodeMirror-line>span::selection,.cm-s-monokai .CodeMirror-line>span>span::selection{background:rgba(73,72,62,.99)}.cm-s-monokai .CodeMirror-line::-moz-selection,.cm-s-monokai .CodeMirror-line>span::-moz-selection,.cm-s-monokai .CodeMirror-line>span>span::-moz-selection{background:rgba(73,72,62,.99)}.cm-s-monokai .CodeMirror-gutters{background:#272822;border-right:0}.cm-s-monokai .CodeMirror-guttermarker{color:#fff}.cm-s-monokai .CodeMirror-guttermarker-subtle,.cm-s-monokai .CodeMirror-linenumber{color:#d0d0d0}.cm-s-monokai .CodeMirror-cursor{border-left:1px solid #f8f8f0}.cm-s-monokai span.cm-comment{color:#75715e}.cm-s-monokai span.cm-atom,.cm-s-monokai span.cm-number{color:#ae81ff}.cm-s-monokai span.cm-attribute,.cm-s-monokai span.cm-property{color:#a6e22e}.cm-s-monokai span.cm-keyword{color:#f92672}.cm-s-monokai span.cm-string{color:#e6db74}.cm-s-monokai span.cm-variable{color:#f8f8f2}.cm-s-monokai span.cm-variable-2{color:#9effff}.cm-s-monokai span.cm-variable-3{color:#66d9ef}.cm-s-monokai span.cm-def{color:#fd971f}.cm-s-monokai span.cm-bracket{color:#f8f8f2}.cm-s-monokai span.cm-tag{color:#f92672}.cm-s-monokai span.cm-header,.cm-s-monokai span.cm-link{color:#ae81ff}.cm-s-monokai span.cm-error{background:#f92672;color:#f8f8f0}.cm-s-monokai .CodeMirror-activeline-background{background:#373831}.cm-s-monokai .CodeMirror-matchingbracket{text-decoration:underline;color:#fff!important}
1
+ .cm-s-monokai.CodeMirror{background:#272822;color:#f8f8f2}.cm-s-monokai div.CodeMirror-selected{background:#49483E}.cm-s-monokai .CodeMirror-line::selection,.cm-s-monokai .CodeMirror-line>span::selection,.cm-s-monokai .CodeMirror-line>span>span::selection{background:rgba(73,72,62,.99)}.cm-s-monokai .CodeMirror-line::-moz-selection,.cm-s-monokai .CodeMirror-line>span::-moz-selection,.cm-s-monokai .CodeMirror-line>span>span::-moz-selection{background:rgba(73,72,62,.99)}.cm-s-monokai .CodeMirror-gutters{background:#272822;border-right:0}.cm-s-monokai .CodeMirror-guttermarker{color:#fff}.cm-s-monokai .CodeMirror-guttermarker-subtle,.cm-s-monokai .CodeMirror-linenumber{color:#d0d0d0}.cm-s-monokai .CodeMirror-cursor{border-left:1px solid #f8f8f0}.cm-s-monokai span.cm-comment{color:#75715e}.cm-s-monokai span.cm-atom,.cm-s-monokai span.cm-number{color:#ae81ff}.cm-s-monokai span.cm-attribute,.cm-s-monokai span.cm-property{color:#a6e22e}.cm-s-monokai span.cm-keyword{color:#f92672}.cm-s-monokai span.cm-builtin{color:#66d9ef}.cm-s-monokai span.cm-string{color:#e6db74}.cm-s-monokai span.cm-variable{color:#f8f8f2}.cm-s-monokai span.cm-variable-2{color:#9effff}.cm-s-monokai span.cm-variable-3{color:#66d9ef}.cm-s-monokai span.cm-def{color:#fd971f}.cm-s-monokai span.cm-bracket{color:#f8f8f2}.cm-s-monokai span.cm-tag{color:#f92672}.cm-s-monokai span.cm-header,.cm-s-monokai span.cm-link{color:#ae81ff}.cm-s-monokai span.cm-error{background:#f92672;color:#f8f8f0}.cm-s-monokai .CodeMirror-activeline-background{background:#373831}.cm-s-monokai .CodeMirror-matchingbracket{text-decoration:underline;color:#fff!important}
js/esites_editor/dist/js/vendor/codemirror/theme/night.css CHANGED
@@ -1 +1 @@
1
- .cm-s-night.CodeMirror{background:#0a001f;color:#f8f8f8}.cm-s-night div.CodeMirror-selected{background:#447}.cm-s-night .CodeMirror-line::selection,.cm-s-night .CodeMirror-line>span::selection,.cm-s-night .CodeMirror-line>span>span::selection{background:rgba(68,68,119,.99)}.cm-s-night .CodeMirror-line::-moz-selection,.cm-s-night .CodeMirror-line>span::-moz-selection,.cm-s-night .CodeMirror-line>span>span::-moz-selection{background:rgba(68,68,119,.99)}.cm-s-night .CodeMirror-gutters{background:#0a001f;border-right:1px solid #aaa}.cm-s-night .CodeMirror-guttermarker{color:#fff}.cm-s-night .CodeMirror-guttermarker-subtle{color:#bbb}.cm-s-night .CodeMirror-linenumber{color:#f8f8f8}.cm-s-night .CodeMirror-cursor{border-left:1px solid #fff}.cm-s-night span.cm-atom{color:#845dc4}.cm-s-night span.cm-attribute,.cm-s-night span.cm-number{color:#ffd500}.cm-s-night span.cm-keyword{color:#599eff}.cm-s-night span.cm-string{color:#37f14a}.cm-s-night span.cm-meta{color:#7678e2}.cm-s-night span.cm-tag,.cm-s-night span.cm-variable-2{color:#99b2ff}.cm-s-night span.cm-def,.cm-s-night span.cm-variable-3{color:#fff}.cm-s-night span.cm-bracket{color:#8da6ce}.cm-s-night span.cm-comment{color:#6900a1}.cm-s-night span.cm-builtin,.cm-s-night span.cm-special{color:#ff9e59}.cm-s-night span.cm-link{color:#845dc4}.cm-s-night span.cm-error{color:#9d1e15}.cm-s-night .CodeMirror-activeline-background{background:#1C005A}.cm-s-night .CodeMirror-matchingbracket{outline:grey solid 1px;color:#fff!important}
1
+ .cm-s-night.CodeMirror{background:#0a001f;color:#f8f8f8}.cm-s-night div.CodeMirror-selected{background:#447}.cm-s-night .CodeMirror-line::selection,.cm-s-night .CodeMirror-line>span::selection,.cm-s-night .CodeMirror-line>span>span::selection{background:rgba(68,68,119,.99)}.cm-s-night .CodeMirror-line::-moz-selection,.cm-s-night .CodeMirror-line>span::-moz-selection,.cm-s-night .CodeMirror-line>span>span::-moz-selection{background:rgba(68,68,119,.99)}.cm-s-night .CodeMirror-gutters{background:#0a001f;border-right:1px solid #aaa}.cm-s-night .CodeMirror-guttermarker{color:#fff}.cm-s-night .CodeMirror-guttermarker-subtle{color:#bbb}.cm-s-night .CodeMirror-linenumber{color:#f8f8f8}.cm-s-night .CodeMirror-cursor{border-left:1px solid #fff}.cm-s-night span.cm-comment{color:#8900d1}.cm-s-night span.cm-atom{color:#845dc4}.cm-s-night span.cm-attribute,.cm-s-night span.cm-number{color:#ffd500}.cm-s-night span.cm-keyword{color:#599eff}.cm-s-night span.cm-string{color:#37f14a}.cm-s-night span.cm-meta{color:#7678e2}.cm-s-night span.cm-tag,.cm-s-night span.cm-variable-2{color:#99b2ff}.cm-s-night span.cm-def,.cm-s-night span.cm-variable-3{color:#fff}.cm-s-night span.cm-bracket{color:#8da6ce}.cm-s-night span.cm-builtin,.cm-s-night span.cm-special{color:#ff9e59}.cm-s-night span.cm-link{color:#845dc4}.cm-s-night span.cm-error{color:#9d1e15}.cm-s-night .CodeMirror-activeline-background{background:#1C005A}.cm-s-night .CodeMirror-matchingbracket{outline:grey solid 1px;color:#fff!important}
js/tiny_mce/plugins/esites_editor/css/styles.min-0d97256b.css ADDED
@@ -0,0 +1 @@
 
1
+ .CodeMirror{height:300px;color:#000}.CodeMirror-lines{padding:4px 0}.CodeMirror pre{padding:0 4px}.CodeMirror-gutter-filler,.CodeMirror-scrollbar-filler{background-color:#fff}.CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;white-space:nowrap}.CodeMirror-guttermarker{color:#000}.CodeMirror-guttermarker-subtle{color:#999}.CodeMirror-cursor{border-left:1px solid #000;border-right:none;width:0}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.cm-fat-cursor .CodeMirror-cursor{width:auto;border:0;background:#7e7}.cm-fat-cursor div.CodeMirror-cursors{z-index:1}.cm-animate-fat-cursor{width:auto;border:0;-webkit-animation:blink 1.06s steps(1) infinite;-moz-animation:blink 1.06s steps(1) infinite;animation:blink 1.06s steps(1) infinite;background-color:#7e7}@-moz-keyframes blink{50%{background-color:transparent}}@-webkit-keyframes blink{50%{background-color:transparent}}@keyframes blink{50%{background-color:transparent}}.cm-tab{display:inline-block;text-decoration:inherit}.CodeMirror-ruler{border-left:1px solid #ccc;position:absolute}.cm-s-default .cm-header{color:#00f}.cm-s-default .cm-quote{color:#090}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:700}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-strikethrough{text-decoration:line-through}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta,.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-invalidchar,.cm-s-default .cm-error{color:red}.CodeMirror-composing{border-bottom:2px solid}div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}.CodeMirror-matchingtag{background:rgba(255,150,0,.3)}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{position:relative;overflow:hidden;background:#fff}.CodeMirror-scroll{overflow:scroll!important;margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;height:100%;outline:0;position:relative}.CodeMirror-sizer{position:relative;border-right:30px solid transparent}.CodeMirror-gutter-filler,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-vscrollbar{position:absolute;z-index:6;display:none}.CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom:0}.CodeMirror-gutters{position:absolute;left:0;top:0;min-height:100%;z-index:3}.CodeMirror-gutter{white-space:normal;height:100%;display:inline-block;vertical-align:top;margin-bottom:-30px}.CodeMirror-gutter-wrapper{position:absolute;z-index:4;background:0 0!important;border:none!important}.CodeMirror-gutter-background{position:absolute;top:0;bottom:0;z-index:4}.CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.CodeMirror-gutter-wrapper{-webkit-user-select:none;-moz-user-select:none;user-select:none}.CodeMirror-lines{cursor:text;min-height:1px}.CodeMirror pre{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:0 0;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible;-webkit-tap-highlight-color:transparent;-webkit-font-variant-ligatures:none;font-variant-ligatures:none}.CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.CodeMirror-linewidget{position:relative;z-index:2;overflow:auto}.CodeMirror-code{outline:0}.CodeMirror-gutter,.CodeMirror-gutters,.CodeMirror-linenumber,.CodeMirror-scroll,.CodeMirror-sizer{-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.CodeMirror-cursor{position:absolute}.CodeMirror-measure pre{position:static}div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:3}.CodeMirror-focused div.CodeMirror-cursors,div.CodeMirror-dragcursors{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.CodeMirror-crosshair{cursor:crosshair}.CodeMirror-line::selection,.CodeMirror-line>span::selection,.CodeMirror-line>span>span::selection{background:#d7d4f0}.CodeMirror-line::-moz-selection,.CodeMirror-line>span::-moz-selection,.CodeMirror-line>span>span::-moz-selection{background:#d7d4f0}.cm-searching{background:#ffa;background:rgba(255,255,0,.4)}.cm-force-border{padding-right:.1px}@media print{.CodeMirror div.CodeMirror-cursors{visibility:hidden}}.cm-tab-wrap-hack:after{content:''}span.CodeMirror-selectedtext{background:0 0}#htmlSource{opacity:0}.CodeMirror{font-size:12px;font-family:'Source Code Pro',Menlo,Monaco,consolas,monospace;border:1px solid #ccc}.CodeMirror-focused .cm-matchhighlight{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAFklEQVQI12NgYGBgkKzc8x9CMDAwAAAmhwSbidEoSQAAAABJRU5ErkJggg==);background-position:bottom;background-repeat:repeat-x}.cm-trailingspace{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAACCAYAAAB/qH1jAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QUXCToH00Y1UgAAACFJREFUCNdjPMDBUc/AwNDAAAFMTAwMDA0OP34wQgX/AQBYgwYEx4f9lQAAAABJRU5ErkJggg==);background-position:bottom left;background-repeat:repeat-x}.cm-tab{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAMCAYAAAAkuj5RAAAAAXNSR0IArs4c6QAAAGFJREFUSMft1LsRQFAQheHPowAKoACx3IgEKtaEHujDjORSgWTH/ZOdnZOcM/sgk/kFFWY0qV8foQwS4MKBCS3qR6ixBJvElOobYAtivseIE120FaowJPN75GMu8j/LfMwNjh4HUpwg4LUAAAAASUVORK5CYII=) right no-repeat}.CodeMirror-lines{line-height:normal}td.value textarea{opacity:1}td.value .CodeMirror-wrap{border:1px solid;border-color:#aaa #c8c8c8 #c8c8c8 #aaa}
js/tiny_mce/plugins/esites_editor/css/styles.min-47f779f9.css DELETED
@@ -1 +0,0 @@
1
- .CodeMirror{height:300px;color:#000}.CodeMirror-lines{padding:4px 0}.CodeMirror pre{padding:0 4px}.CodeMirror-gutter-filler,.CodeMirror-scrollbar-filler{background-color:#fff}.CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;white-space:nowrap}.CodeMirror-guttermarker{color:#000}.CodeMirror-guttermarker-subtle{color:#999}.CodeMirror-cursor{border-left:1px solid #000;border-right:none;width:0}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.cm-fat-cursor .CodeMirror-cursor{width:auto;border:0;background:#7e7}.cm-fat-cursor div.CodeMirror-cursors{z-index:1}.cm-animate-fat-cursor{width:auto;border:0;-webkit-animation:blink 1.06s steps(1) infinite;-moz-animation:blink 1.06s steps(1) infinite;animation:blink 1.06s steps(1) infinite;background-color:#7e7}@-moz-keyframes blink{50%{background-color:transparent}}@-webkit-keyframes blink{50%{background-color:transparent}}@keyframes blink{50%{background-color:transparent}}.cm-tab{display:inline-block;text-decoration:inherit}.CodeMirror-ruler{border-left:1px solid #ccc;position:absolute}.cm-s-default .cm-header{color:#00f}.cm-s-default .cm-quote{color:#090}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:700}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-strikethrough{text-decoration:line-through}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta,.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-invalidchar,.cm-s-default .cm-error{color:red}.CodeMirror-composing{border-bottom:2px solid}div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}.CodeMirror-matchingtag{background:rgba(255,150,0,.3)}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{position:relative;overflow:hidden;background:#fff}.CodeMirror-scroll{overflow:scroll!important;margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;height:100%;outline:0;position:relative}.CodeMirror-sizer{position:relative;border-right:30px solid transparent}.CodeMirror-gutter-filler,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-vscrollbar{position:absolute;z-index:6;display:none}.CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom:0}.CodeMirror-gutters{position:absolute;left:0;top:0;z-index:3}.CodeMirror-gutter{white-space:normal;height:100%;display:inline-block;margin-bottom:-30px}.CodeMirror-gutter-wrapper{position:absolute;z-index:4;background:0 0!important;border:none!important}.CodeMirror-gutter-background{position:absolute;top:0;bottom:0;z-index:4}.CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.CodeMirror-gutter-wrapper{-webkit-user-select:none;-moz-user-select:none;user-select:none}.CodeMirror-lines{cursor:text;min-height:1px}.CodeMirror pre{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:0 0;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible;-webkit-tap-highlight-color:transparent}.CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.CodeMirror-linewidget{position:relative;z-index:2;overflow:auto}.CodeMirror-code{outline:0}.CodeMirror-gutter,.CodeMirror-gutters,.CodeMirror-linenumber,.CodeMirror-scroll,.CodeMirror-sizer{-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.CodeMirror-cursor{position:absolute}.CodeMirror-measure pre{position:static}div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:3}.CodeMirror-focused div.CodeMirror-cursors,div.CodeMirror-dragcursors{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.CodeMirror-crosshair{cursor:crosshair}.CodeMirror-line::selection,.CodeMirror-line>span::selection,.CodeMirror-line>span>span::selection{background:#d7d4f0}.CodeMirror-line::-moz-selection,.CodeMirror-line>span::-moz-selection,.CodeMirror-line>span>span::-moz-selection{background:#d7d4f0}.cm-searching{background:#ffa;background:rgba(255,255,0,.4)}.cm-force-border{padding-right:.1px}@media print{.CodeMirror div.CodeMirror-cursors{visibility:hidden}}.cm-tab-wrap-hack:after{content:''}span.CodeMirror-selectedtext{background:0 0}#htmlSource{opacity:0}.CodeMirror{font-size:12px;font-family:'Source Code Pro',Menlo,Monaco,consolas,monospace;border:1px solid #ccc}.CodeMirror-focused .cm-matchhighlight{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAFklEQVQI12NgYGBgkKzc8x9CMDAwAAAmhwSbidEoSQAAAABJRU5ErkJggg==);background-position:bottom;background-repeat:repeat-x}.cm-trailingspace{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAACCAYAAAB/qH1jAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QUXCToH00Y1UgAAACFJREFUCNdjPMDBUc/AwNDAAAFMTAwMDA0OP34wQgX/AQBYgwYEx4f9lQAAAABJRU5ErkJggg==);background-position:bottom left;background-repeat:repeat-x}.cm-tab{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAMCAYAAAAkuj5RAAAAAXNSR0IArs4c6QAAAGFJREFUSMft1LsRQFAQheHPowAKoACx3IgEKtaEHujDjORSgWTH/ZOdnZOcM/sgk/kFFWY0qV8foQwS4MKBCS3qR6ixBJvElOobYAtivseIE120FaowJPN75GMu8j/LfMwNjh4HUpwg4LUAAAAASUVORK5CYII=) right no-repeat}.CodeMirror-lines{line-height:normal}td.value textarea{opacity:1}td.value .CodeMirror-wrap{border:1px solid;border-color:#aaa #c8c8c8 #c8c8c8 #aaa}
 
js/tiny_mce/plugins/esites_editor/esites_editor.html CHANGED
@@ -4,7 +4,7 @@
4
  <meta charset="utf-8">
5
  <title>Advanced Editor</title>
6
  <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Source+Code+Pro:400,700">
7
- <link rel="stylesheet" href="css/styles.min-47f779f9.css">
8
  </head>
9
  <body>
10
  <form name="source" id="form-editor">
4
  <meta charset="utf-8">
5
  <title>Advanced Editor</title>
6
  <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Source+Code+Pro:400,700">
7
+ <link rel="stylesheet" href="css/styles.min-0d97256b.css">
8
  </head>
9
  <body>
10
  <form name="source" id="form-editor">
js/tiny_mce/plugins/esites_editor/esites_editor_plugin_src.js CHANGED
@@ -3,7 +3,7 @@
3
  * This is the TinyMCE plugin of the Magento extension that incorporates the CodeMirror library
4
  *
5
  * @author : Boye Oomens <boye@e-sites.nl>
6
- * @version : 0.5.1
7
  * @license : OSL 3.0
8
  * @see : https://github.com/e-sites/magento-advanced-html-editor
9
  * @see : http://codemirror.net/
3
  * This is the TinyMCE plugin of the Magento extension that incorporates the CodeMirror library
4
  *
5
  * @author : Boye Oomens <boye@e-sites.nl>
6
+ * @version : 0.6.0
7
  * @license : OSL 3.0
8
  * @see : https://github.com/e-sites/magento-advanced-html-editor
9
  * @see : http://codemirror.net/
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Esites_Editor</name>
4
- <version>0.5.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
@@ -12,13 +12,15 @@
12
  Of course you can open up the default source editor and go from there. But you probably know that this will not be very pleasant as well, the code looks like a big bowl of tag soup and editing it can give you a real headache.&#xD;
13
  &#xD;
14
  This extension offers both a standalone editor as well as a plugin for Magento's WYSIWYG editor and is similar to your favorite IDE. It offers a lot of great features that will not only save you quite a bit of time but also makes editing code a lot easier.</description>
15
- <notes>Hotfix release for an issue where the TinyMCE plugin didn't load correctly in the product catalog section.&#xD;
 
 
16
  &#xD;
17
  The GitHub repo can be found at: https://github.com/e-sites/magento-advanced-code-editor</notes>
18
  <authors><author><name>Boye Oomens</name><user>boye</user><email>github@e-sites.nl</email></author></authors>
19
- <date>2015-10-27</date>
20
- <time>17:18:02</time>
21
- <contents><target name="magecommunity"><dir name="Esites"><dir name="Editor"><dir name="Block"><file name="Standalone.php" hash="e057b4f909ec16cd818d67e40f92ffda"/></dir><dir name="Helper"><file name="Data.php" hash="cd176392637a27912dbc252d677404df"/></dir><dir name="Model"><file name="Config.php" hash="1eaab7b9d466b2f5083e4590b208899e"/><file name="Observer.php" hash="e240c58023d2a803c0cda1c0f669ac81"/><dir name="Source"><file name="Status.php" hash="d39a6881e1dce9e85248414864ed81fc"/></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Indentunit"><file name="Values.php" hash="6201a40c6cf6ff70a945d1f14e8a0c1c"/></dir><dir name="Keymap"><file name="Values.php" hash="439483ce69cbca9dd47265dcae8e14b2"/></dir><dir name="Scrollbars"><file name="Values.php" hash="7ebd442a08469b5a676a97692b93c96f"/></dir><dir name="Sections"><file name="Values.php" hash="ecc683806bfd751925df2adff0eec72c"/></dir><dir name="Theme"><file name="Values.php" hash="5a19d932e7d2ad93b2a328402c7bd2ce"/></dir></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="f0e94ba8bf81d9d4232029053bef3db1"/><file name="system.xml" hash="41395b18eb02426257c6ee1ce2fb2e56"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Esites_Editor.xml" hash="71f3494666fd734e43eae430a4de79b5"/></dir></target><target name="mageweb"><dir name="js"><dir name="tiny_mce"><dir name="plugins"><dir name="esites_editor"><dir name="css"><file name="styles.min-47f779f9.css" hash="47f779f9ee2490e07f255bac17325da6"/></dir><file name="esites_editor.html" hash="4332fe12f09136d6f1decc21f2339ef6"/><file name="esites_editor_plugin.js" hash="327298e7be6eb930048ad2f116ce9ade"/><file name="esites_editor_plugin_src.js" hash="1fa5cf2b572da5bb9fd835fbaf5ba9fb"/><dir name="img"><file name="icon-esites-editor.png" hash="44c722d1cfa0465a94d0244583240812"/></dir><dir name="js"><file name="require.min-7f752fef.js" hash="7f752fef626edafefdd4813b84b99e73"/></dir><dir name="langs"><file name="en.js" hash="a2c57cb6a344c19bbcfc13e45bc97906"/></dir></dir></dir></dir><dir name="esites_editor"><dir name="dist"><dir name="css"><file name="styles.css" hash="fc545b4567f76a222472e681b0caa272"/></dir><dir name="js"><dir name="app"><file name="main.js" hash="dbdc5766dda6d9d12ff83df0196f97e8"/><dir name="module"><file name="code.js" hash="e788b214b0846e796fa99365e7ffbd65"/><file name="dialog.js" hash="f937badb8927ce6ea5797c57e35be97b"/><file name="editor.js" hash="39f1fb1d0fc58601ed1edb9778c4d54f"/><file name="setup.js" hash="0965d950770ded3fa3f873f342ecd917"/><file name="standalone.js" hash="17916387328810c479268c3df759800c"/><file name="util.js" hash="ea66828f78718fc103fe690fb1e0f375"/></dir><dir name="var"><file name="addons.js" hash="d10f40d6a25b81ef9bb7351f65e44de6"/><file name="cmOptions.js" hash="9ab75f2ba06f1f6e4caec3bf0bb0539e"/><file name="deps.js" hash="26a6e08b8bd29982bdf757a92e79790d"/><file name="plugin.js" hash="cdaff0e3525fff98f35584f44e375d57"/><file name="targets.js" hash="6aed00abcab39cc1cf803881912eb498"/><file name="tinymcePopup.js" hash="ea543a1cfb4bc3525468ee853428de0f"/></dir></dir><file name="app.js" hash="e346b8c76f13377cbdb19194f5213bba"/><dir name="vendor"><dir name="codemirror"><dir name="addon"><dir name="comment"><file name="comment.js" hash="20835405ef886de298b473a99db6ae7a"/><file name="continuecomment.js" hash="2bad52d5a0b57d8f43e0e5b90bb25725"/></dir><dir name="dialog"><file name="dialog.css" hash="c89dce10b44d2882a024e7befc2b63f5"/><file name="dialog.js" hash="3429ebaf286acb91f04b8d3433251c1d"/></dir><dir name="display"><file name="autorefresh.js" hash="5acf6d9221a489bbd0a1d5868eeeaa6f"/><file name="fullscreen.css" hash="1a278e72b51528270f8ce9ec991929a1"/><file name="fullscreen.js" hash="fb86184c4fb36398188f2199fd28f167"/><file name="panel.js" hash="56e9558f431d1dffd85bf18ff2c9cd8d"/><file name="placeholder.js" hash="3e9bbc56a72f7edf5ac61c45d10a87af"/><file name="rulers.js" hash="ff4f724e824fe42d72404a4fe4a756fe"/></dir><dir name="edit"><file name="closebrackets.js" hash="fb4edbeca178980a335a0e02395acef5"/><file name="closetag.js" hash="c85e0e28f335f2e00c993ae90cee18a2"/><file name="continuelist.js" hash="1f902d5931a4c5d75b3d2b13aff71168"/><file name="matchbrackets.js" hash="94c58e98823144e56932aa2611c51dff"/><file name="matchtags.js" hash="545127ffedea5d77c0f68c809c75c5b6"/><file name="trailingspace.js" hash="650f095b187881451b0166d16ffd4091"/></dir><dir name="fold"><file name="brace-fold.js" hash="13f986f14247d953551bdfe93b27699e"/><file name="comment-fold.js" hash="5e5bdebcd4acb30c3aed47164e2af6b3"/><file name="foldcode.js" hash="76c21fd4c3f14d1a61765324ec82266b"/><file name="foldgutter.css" hash="38bb68770b6f7ebaa7adea770a68e0b1"/><file name="foldgutter.js" hash="021b76e831daea34fb2dd2f300077be0"/><file name="indent-fold.js" hash="b17f35bdd388f737113271b9e9070ea3"/><file name="markdown-fold.js" hash="c8783b56c820030045a57f291660ea20"/><file name="xml-fold.js" hash="f173dec3ccb5d6df5f37b9a99ecc438a"/></dir><dir name="hint"><file name="anyword-hint.js" hash="6b1df80699158516007e9172861f5ba3"/><file name="css-hint.js" hash="0331f17931864c79688b80c3a8fcf0bf"/><file name="html-hint.js" hash="6b398a6ef3473b9f889092495fcc1545"/><file name="javascript-hint.js" hash="8febf4d6664e133fac9da1da672564cd"/><file name="show-hint.css" hash="630e320a614e7732f6ce1bf37147f27f"/><file name="show-hint.js" hash="62f40cb9640a4477236c8124133edc3b"/><file name="sql-hint.js" hash="3320167f10ccb11e1fb6d43e10e0c4f8"/><file name="xml-hint.js" hash="21d019d58516804262957d8879576908"/></dir><dir name="lint"><file name="coffeescript-lint.js" hash="a867c61ab04b4309206ba371bdde9fb7"/><file name="css-lint.js" hash="fd09f81d97cf3eb681cc5742d76ec47f"/><file name="html-lint.js" hash="ebc76e3d7446c73104fae7d143261a9e"/><file name="javascript-lint.js" hash="5576a5092afdae4e7990abcbc92d0425"/><file name="json-lint.js" hash="49afe4d1a791c115de21553c28f1a6cf"/><file name="lint.css" hash="5f5d243947ec3ae1b8f37d85f0fa2a2d"/><file name="lint.js" hash="e04582b9ae434c625f597fd04e45177f"/><file name="yaml-lint.js" hash="117815f724aa2c3d671801ccedaa86ac"/></dir><dir name="merge"><file name="merge.css" hash="842786722589d900ffaf32652e89dac9"/><file name="merge.js" hash="449ce478a8070cab4c458f55b4a59d13"/></dir><dir name="mode"><file name="loadmode.js" hash="bc3c29fecceff0785b086b6e1c6f6b7c"/><file name="multiplex.js" hash="5bd0e78901200adb66a095501bffe61a"/><file name="multiplex_test.js" hash="f517110cde96b5b4356557a7792fdcf3"/><file name="overlay.js" hash="7abff7c501c40008fc541414e803d954"/><file name="simple.js" hash="b3f550bd7554a29d6929e20aba3456ac"/></dir><dir name="runmode"><file name="colorize.js" hash="b0d93d54ee9bf76b246ea7cae39d6e75"/><file name="runmode-standalone.js" hash="54b1bc5448bbdfb53fdb3cbdc6740ef7"/><file name="runmode.js" hash="3266201540178df80d191c73bbd88152"/><file name="runmode.node.js" hash="e0d6deb878b58ce2329eb676b1146a1d"/></dir><dir name="scroll"><file name="annotatescrollbar.js" hash="48c6d9945674a1f807d164190094090c"/><file name="scrollpastend.js" hash="68e06dd3d77a87661790bbb7ebe2f080"/><file name="simplescrollbars.css" hash="0352ba51fd6a422fe6cc44925e33ad88"/><file name="simplescrollbars.js" hash="3a02029c076fb34aac136dd8c745be94"/></dir><dir name="search"><file name="match-highlighter.js" hash="b59268b1e4b6872df69110776d7f7934"/><file name="matchesonscrollbar.css" hash="00ea2770c568a848190bcf52e4241276"/><file name="matchesonscrollbar.js" hash="2cece6de1e3ad73489c170c8f08dd561"/><file name="search.js" hash="eb5466a61637ebc83ff9fea025984d86"/><file name="searchcursor.js" hash="a11e9186f471515209a5583f1af6421c"/></dir><dir name="selection"><file name="active-line.js" hash="c7c0cb21951ca1ba74837a74bbcd4b47"/><file name="mark-selection.js" hash="49df440e41a6f54264bce4f7ed7d7d05"/><file name="selection-pointer.js" hash="394ed7c792ed1954c6473d72e17156f9"/></dir><dir name="tern"><file name="tern.css" hash="4d57ced774b5f3fa9f00dfa398e74819"/><file name="tern.js" hash="3d239850b3d0718aef8216c474c69abc"/><file name="worker.js" hash="d6b55f3e776aafc6b1d1cd5bdf148e1d"/></dir><dir name="wrap"><file name="hardwrap.js" hash="c256c76283cc03d9b9a7a3c746894bb2"/></dir></dir><dir name="keymap"><file name="emacs.js" hash="32b711e4207100748a23bde6ad2b5607"/><file name="sublime.js" hash="784cd4692a1728bc67615c8c5a999199"/><file name="vim.js" hash="b6b16f45780c888ef119a806506a079b"/></dir><dir name="lib"><file name="codemirror.css" hash="064e66cbac22da58441b578f27ebded8"/><file name="codemirror.js" hash="0d7fefa49d10c9a0118d7fa293ad47a3"/></dir><dir name="mode"><dir name="css"><file name="css.js" hash="cd3e8d3f4eb7db7e245aafc1fcbb1e83"/></dir><dir name="handlebars"><file name="handlebars.js" hash="8a042e57cb81b21e1feb31e7e3932e20"/></dir><dir name="htmlmixed"><file name="htmlmixed.js" hash="eb095983c2bf9b8daced23d252ce06d6"/></dir><dir name="javascript"><file name="javascript.js" hash="d81a7fd4197876eeb81be1bac9dbe9a2"/></dir><dir name="xml"><file name="xml.js" hash="d9b6313362eb7786a374357cc1c54efc"/></dir></dir><dir name="theme"><file name="3024-day.css" hash="2b259ecd423f3ce94a722c1f5d46a31f"/><file name="3024-night.css" hash="ab94fd59ab96fb1aa3e81dfddb6987cb"/><file name="abcdef.css" hash="a8ccb14d4be49cf68affcf33b77fce3f"/><file name="ambiance-mobile.css" hash="75d6e3e84df3d2d0fd6263587900a9f2"/><file name="ambiance.css" hash="df554079ab89352e7b407f9db17d50fd"/><file name="base16-dark.css" hash="fdae4f313cca84cf7867d7695a809e97"/><file name="base16-light.css" hash="75b47de25ea8faf2f9dd6db40a579c35"/><file name="bespin.css" hash="0d4911d305080973de85c044584806aa"/><file name="blackboard.css" hash="022d790d189e391efa1fcb4e1ce4b7ca"/><file name="cobalt.css" hash="523b38d22f2e0c0ce166576a16ca0281"/><file name="colorforth.css" hash="ba27b85d9a988cdc24ddbe56bce9eb07"/><file name="dracula.css" hash="5ec23e6634c26a2fea63343213835726"/><file name="eclipse.css" hash="314ec24dd09cb97222a2535ed7715f0b"/><file name="elegant.css" hash="f0f6623f96dfbe7860b8d6afd44498a0"/><file name="erlang-dark.css" hash="3ff34e94c01ce38a26e3e174ad642001"/><file name="hopscotch.css" hash="e530e187dbe39f12c778029895175d93"/><file name="icecoder.css" hash="79bd1ef097bf94e2ce7cb13c43e2c24e"/><file name="isotope.css" hash="22e3d07dc710ca1fc6809459623cd1bd"/><file name="lesser-dark.css" hash="b73404c4e3a2a3b9481157ebd2d76610"/><file name="liquibyte.css" hash="63a5489eb042bc4d8611cd88fa8acab1"/><file name="material.css" hash="85c9718b83ec8df6f36132fe2f30d35f"/><file name="mbo.css" hash="e3cceb469d5d8cbc6c12c6b5de516330"/><file name="mdn-like.css" hash="ded52290c03f1c2e978e266d7d971178"/><file name="midnight.css" hash="bdce9536d0e57a463c54450600e48b13"/><file name="monokai.css" hash="985e65966de94892a49201d89c708602"/><file name="neat.css" hash="23a5db706b96502df2c24d8114b47fe0"/><file name="neo.css" hash="e5206a0a0dd891c5fe3bccca068e47a7"/><file name="night.css" hash="64b987262e86d3da91ba7181b801b90d"/><file name="paraiso-dark.css" hash="98ac9857e72bc2c18d1fb962e7234f03"/><file name="paraiso-light.css" hash="95830052862d184f7e4990608a9f4d61"/><file name="pastel-on-dark.css" hash="747143af8c34743ab6010c2b823ea9bb"/><file name="railscasts.css" hash="51f1577ecaaae0cc532f1159eebfb564"/><file name="rubyblue.css" hash="86fe07d4c88d8e2c43a68120d5c148a8"/><file name="seti.css" hash="87435dbb891fa7b564c2342dbc201dd9"/><file name="solarized.css" hash="5cce80f3253dde99eaf27f1827e5de55"/><file name="the-matrix.css" hash="081300ef7d26e3ebdc986aeeab3df0f7"/><file name="tomorrow-night-bright.css" hash="c6a2d6679ec30cc81bdd7823a37639da"/><file name="tomorrow-night-eighties.css" hash="b9498f6b1a1c31f75b3f248a74b992df"/><file name="ttcn.css" hash="cbb49c6b4866a208097ab7ab38765495"/><file name="twilight.css" hash="75d129c0ba7b878c5322f8ba7f2f6009"/><file name="vibrant-ink.css" hash="95cb7e6fac9c22f53c08a071174606cc"/><file name="xq-dark.css" hash="8effe912f98ba011fad79d7d2d1e65ff"/><file name="xq-light.css" hash="ced9231fe2df68da3345089704488434"/><file name="yeti.css" hash="50184fc2a49072b496ddd54d68a7ed7b"/><file name="zenburn.css" hash="84fb6d3264fe6ebce7e76b3e916ea25a"/></dir></dir><dir name="emmet-codemirror"><dir name="dist"><file name="emmet.js" hash="86e93251ef948432b389b618aeb33935"/></dir></dir><dir name="gator"><file name="gator.min.js" hash="baeed415b14018f2cce187a2919a99b9"/></dir><dir name="htmlhint"><dir name="lib"><file name="htmlhint.js" hash="b0387560e3736d7cdf843d71b826b743"/></dir></dir><dir name="js-beautify"><dir name="js"><dir name="lib"><file name="beautify-css.js" hash="1ee2ff52ccf2ffc359a8766e77af6b95"/><file name="beautify-html.js" hash="398727902a3d8c263ab173b77c6ad03b"/><file name="beautify.js" hash="9c403178a89aa18c820b9f79b19652f0"/></dir></dir></dir><dir name="require-css"><file name="css.js" hash="ba3becc9467b6dbb264799be028a3d3c"/></dir><dir name="requirejs"><file name="require.js" hash="7f752fef626edafefdd4813b84b99e73"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Esites_Editor.csv" hash="8daece7277a99e5af1c72b591016c112"/></dir><dir name="nl_NL"><file name="Esites_Editor.csv" hash="817bd8de0a88b1223837dbc424ea9e6d"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="esites_editor"><file name="standalone.phtml" hash="50f813eabf10462dca48f131e0248763"/></dir></dir><dir name="layout"><file name="esites_editor.xml" hash="c48e255f7cf2ce058f772e9cfa8d46ae"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="esites_editor"><file name="standalone.phtml" hash="09eef47884926f502d82f0a835ce30f1"/></dir></dir><dir name="layout"><file name="esites_editor.xml" hash="781b0966e3e1be48e7a2e56674d67998"/></dir></dir></dir></dir></target></contents>
22
  <compatible/>
23
  <dependencies><required><php><min>5.4.0</min><max>6.0.0</max></php></required></dependencies>
24
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Esites_Editor</name>
4
+ <version>0.6.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
12
  Of course you can open up the default source editor and go from there. But you probably know that this will not be very pleasant as well, the code looks like a big bowl of tag soup and editing it can give you a real headache.&#xD;
13
  &#xD;
14
  This extension offers both a standalone editor as well as a plugin for Magento's WYSIWYG editor and is similar to your favorite IDE. It offers a lot of great features that will not only save you quite a bit of time but also makes editing code a lot easier.</description>
15
+ <notes>As of this version the standalone editor is disabled by default for the front-end and can be enabled via the configuration panel.&#xD;
16
+ &#xD;
17
+ Further more we enhanced the standalone editor by landing the support for inserting widgets and images. Also, there are new themes available due to upgrading to the latest CodeMirror version.&#xD;
18
  &#xD;
19
  The GitHub repo can be found at: https://github.com/e-sites/magento-advanced-code-editor</notes>
20
  <authors><author><name>Boye Oomens</name><user>boye</user><email>github@e-sites.nl</email></author></authors>
21
+ <date>2016-05-13</date>
22
+ <time>15:44:08</time>
23
+ <contents><target name="magecommunity"><dir name="Esites"><dir name="Editor"><dir name="Block"><dir name="Adminhtml"><file name="Version.php" hash="3b6d54bb049419ef130c9bef2dc59f71"/></dir><file name="Standalone.php" hash="20626a0aa63add103a5b6c2c677068d3"/></dir><dir name="Helper"><file name="Data.php" hash="2c3c41e98ad792423858468cab4e72c8"/></dir><dir name="Model"><file name="Config.php" hash="1eaab7b9d466b2f5083e4590b208899e"/><file name="Observer.php" hash="e240c58023d2a803c0cda1c0f669ac81"/><dir name="Source"><file name="Status.php" hash="d39a6881e1dce9e85248414864ed81fc"/></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Indentunit"><file name="Values.php" hash="6201a40c6cf6ff70a945d1f14e8a0c1c"/></dir><dir name="Keymap"><file name="Values.php" hash="439483ce69cbca9dd47265dcae8e14b2"/></dir><dir name="Scrollbars"><file name="Values.php" hash="7ebd442a08469b5a676a97692b93c96f"/></dir><dir name="Sections"><file name="Values.php" hash="ecc683806bfd751925df2adff0eec72c"/></dir><dir name="Theme"><file name="Values.php" hash="c6215d8cc25fe31e7ba926c8f9e003bb"/></dir></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="fa7dc84fd4d49345cb34577aed983ecd"/><file name="system.xml" hash="d83af7b70ed4978d3ea1140de5679201"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Esites_Editor.xml" hash="71f3494666fd734e43eae430a4de79b5"/></dir></target><target name="mageweb"><dir name="js"><dir name="tiny_mce"><dir name="plugins"><dir name="esites_editor"><dir name="css"><file name="styles.min-0d97256b.css" hash="0d97256b807c6ca1ca24563f1f092193"/></dir><file name="esites_editor.html" hash="b4e33ecce1ba7ee4634aedc39e0b022c"/><file name="esites_editor_plugin.js" hash="327298e7be6eb930048ad2f116ce9ade"/><file name="esites_editor_plugin_src.js" hash="19d6d41f6d57084018df4e92e4f17e62"/><dir name="img"><file name="icon-esites-editor.png" hash="44c722d1cfa0465a94d0244583240812"/></dir><dir name="js"><file name="require.min-7f752fef.js" hash="7f752fef626edafefdd4813b84b99e73"/></dir><dir name="langs"><file name="en.js" hash="a2c57cb6a344c19bbcfc13e45bc97906"/></dir></dir></dir></dir><dir name="esites_editor"><dir name="dist"><dir name="css"><file name="styles.css" hash="fc545b4567f76a222472e681b0caa272"/></dir><dir name="js"><dir name="app"><file name="main.js" hash="dbdc5766dda6d9d12ff83df0196f97e8"/><dir name="module"><file name="code.js" hash="e788b214b0846e796fa99365e7ffbd65"/><file name="dialog.js" hash="f937badb8927ce6ea5797c57e35be97b"/><file name="editor.js" hash="800219fd8b3625ea59820bb84518901b"/><file name="setup.js" hash="0965d950770ded3fa3f873f342ecd917"/><file name="standalone.js" hash="bafa5e9cb92b0411e6e624a186d10753"/><file name="util.js" hash="ea66828f78718fc103fe690fb1e0f375"/></dir><dir name="var"><file name="addons.js" hash="d10f40d6a25b81ef9bb7351f65e44de6"/><file name="cmOptions.js" hash="9ab75f2ba06f1f6e4caec3bf0bb0539e"/><file name="deps.js" hash="26a6e08b8bd29982bdf757a92e79790d"/><file name="plugin.js" hash="cdaff0e3525fff98f35584f44e375d57"/><file name="targets.js" hash="6aed00abcab39cc1cf803881912eb498"/><file name="tinymcePopup.js" hash="ea543a1cfb4bc3525468ee853428de0f"/></dir></dir><file name="app.js" hash="e346b8c76f13377cbdb19194f5213bba"/><dir name="vendor"><dir name="codemirror"><dir name="addon"><dir name="comment"><file name="comment.js" hash="a9274c537d40a25aa372ff4a511b6857"/><file name="continuecomment.js" hash="2bad52d5a0b57d8f43e0e5b90bb25725"/></dir><dir name="dialog"><file name="dialog.css" hash="c89dce10b44d2882a024e7befc2b63f5"/><file name="dialog.js" hash="eb78922db190627d63be39f54b6ae864"/></dir><dir name="display"><file name="autorefresh.js" hash="5acf6d9221a489bbd0a1d5868eeeaa6f"/><file name="fullscreen.css" hash="1a278e72b51528270f8ce9ec991929a1"/><file name="fullscreen.js" hash="fb86184c4fb36398188f2199fd28f167"/><file name="panel.js" hash="56e9558f431d1dffd85bf18ff2c9cd8d"/><file name="placeholder.js" hash="d11008c6283fa41c5aab8cd99ac78975"/><file name="rulers.js" hash="ff4f724e824fe42d72404a4fe4a756fe"/></dir><dir name="edit"><file name="closebrackets.js" hash="16b8a913cb345f7105b1e5df9990bf0a"/><file name="closetag.js" hash="c85e0e28f335f2e00c993ae90cee18a2"/><file name="continuelist.js" hash="1f902d5931a4c5d75b3d2b13aff71168"/><file name="matchbrackets.js" hash="94c58e98823144e56932aa2611c51dff"/><file name="matchtags.js" hash="545127ffedea5d77c0f68c809c75c5b6"/><file name="trailingspace.js" hash="650f095b187881451b0166d16ffd4091"/></dir><dir name="fold"><file name="brace-fold.js" hash="13f986f14247d953551bdfe93b27699e"/><file name="comment-fold.js" hash="418aa5a8cc030ec09fdbf3d3f91e79d1"/><file name="foldcode.js" hash="76c21fd4c3f14d1a61765324ec82266b"/><file name="foldgutter.css" hash="38bb68770b6f7ebaa7adea770a68e0b1"/><file name="foldgutter.js" hash="f7933de4d024fe89401a12ec7652627e"/><file name="indent-fold.js" hash="b17f35bdd388f737113271b9e9070ea3"/><file name="markdown-fold.js" hash="c8783b56c820030045a57f291660ea20"/><file name="xml-fold.js" hash="f173dec3ccb5d6df5f37b9a99ecc438a"/></dir><dir name="hint"><file name="anyword-hint.js" hash="6b1df80699158516007e9172861f5ba3"/><file name="css-hint.js" hash="0331f17931864c79688b80c3a8fcf0bf"/><file name="html-hint.js" hash="6b398a6ef3473b9f889092495fcc1545"/><file name="javascript-hint.js" hash="8febf4d6664e133fac9da1da672564cd"/><file name="show-hint.css" hash="630e320a614e7732f6ce1bf37147f27f"/><file name="show-hint.js" hash="1bfbe68cfd92aad65aa1e49d54fd0c3e"/><file name="sql-hint.js" hash="1513156d6c3bb094e19f4759fbabd7cf"/><file name="xml-hint.js" hash="21d019d58516804262957d8879576908"/></dir><dir name="lint"><file name="coffeescript-lint.js" hash="a867c61ab04b4309206ba371bdde9fb7"/><file name="css-lint.js" hash="fd09f81d97cf3eb681cc5742d76ec47f"/><file name="html-lint.js" hash="ebc76e3d7446c73104fae7d143261a9e"/><file name="javascript-lint.js" hash="5576a5092afdae4e7990abcbc92d0425"/><file name="json-lint.js" hash="49afe4d1a791c115de21553c28f1a6cf"/><file name="lint.css" hash="5f5d243947ec3ae1b8f37d85f0fa2a2d"/><file name="lint.js" hash="e937b42165f6ac84a30182c1a93ac878"/><file name="yaml-lint.js" hash="117815f724aa2c3d671801ccedaa86ac"/></dir><dir name="merge"><file name="merge.css" hash="5f8663128b0643bdca32ae2ad8867a8a"/><file name="merge.js" hash="cf788339fad81d9ca0f499ccce9e9d78"/></dir><dir name="mode"><file name="loadmode.js" hash="bc3c29fecceff0785b086b6e1c6f6b7c"/><file name="multiplex.js" hash="5bd0e78901200adb66a095501bffe61a"/><file name="multiplex_test.js" hash="f517110cde96b5b4356557a7792fdcf3"/><file name="overlay.js" hash="7abff7c501c40008fc541414e803d954"/><file name="simple.js" hash="aebf64be9a16aa3dfe45ab91b5b0b588"/></dir><dir name="runmode"><file name="colorize.js" hash="b0d93d54ee9bf76b246ea7cae39d6e75"/><file name="runmode-standalone.js" hash="54b1bc5448bbdfb53fdb3cbdc6740ef7"/><file name="runmode.js" hash="44916ba81dd868098922bdb8e6874e80"/><file name="runmode.node.js" hash="c9af1698167e3de82a5e590e6ae23a73"/></dir><dir name="scroll"><file name="annotatescrollbar.js" hash="7206739f16151e2b54468fc9b8cea190"/><file name="scrollpastend.js" hash="68e06dd3d77a87661790bbb7ebe2f080"/><file name="simplescrollbars.css" hash="0352ba51fd6a422fe6cc44925e33ad88"/><file name="simplescrollbars.js" hash="19ac106aee495b013b170a8ff82ac532"/></dir><dir name="search"><file name="jump-to-line.js" hash="3299737b0d8205f1e67d112de17a9b2d"/><file name="match-highlighter.js" hash="4d39f82e7181fa156b171b576f631efc"/><file name="matchesonscrollbar.css" hash="00ea2770c568a848190bcf52e4241276"/><file name="matchesonscrollbar.js" hash="2cece6de1e3ad73489c170c8f08dd561"/><file name="search.js" hash="f0ee6a4ceb2ae7a0d112af53f98c40d1"/><file name="searchcursor.js" hash="a11e9186f471515209a5583f1af6421c"/></dir><dir name="selection"><file name="active-line.js" hash="b855254be1455e111bdbc6916552e8d7"/><file name="mark-selection.js" hash="49df440e41a6f54264bce4f7ed7d7d05"/><file name="selection-pointer.js" hash="394ed7c792ed1954c6473d72e17156f9"/></dir><dir name="tern"><file name="tern.css" hash="4d57ced774b5f3fa9f00dfa398e74819"/><file name="tern.js" hash="6f74c41f96a1d701c0a3907301aa06ff"/><file name="worker.js" hash="d6b55f3e776aafc6b1d1cd5bdf148e1d"/></dir><dir name="wrap"><file name="hardwrap.js" hash="c256c76283cc03d9b9a7a3c746894bb2"/></dir></dir><dir name="keymap"><file name="emacs.js" hash="32b711e4207100748a23bde6ad2b5607"/><file name="sublime.js" hash="fa64844a3ff01d70724de30843d0b75a"/><file name="vim.js" hash="ee2973ea0b61203affd2edfbc9e23fcc"/></dir><dir name="lib"><file name="codemirror.css" hash="ff4cc448ab65098d73a4d70a65a109f8"/><file name="codemirror.js" hash="5e577661cda6d039f0e31e8426480bd9"/></dir><dir name="mode"><dir name="css"><file name="css.js" hash="93fc8d5e33b08813176d27141654d5a6"/></dir><dir name="handlebars"><file name="handlebars.js" hash="1e3a1d4cc25ce95190b4718ca12707c8"/></dir><dir name="htmlmixed"><file name="htmlmixed.js" hash="86f13daf9bde3a57644c5f57ad56afdf"/></dir><dir name="javascript"><file name="javascript.js" hash="c37f3794a5496441f168915bb10ec83d"/></dir><dir name="xml"><file name="xml.js" hash="d79787a62c1a9dc8c9218a0ae330a682"/></dir></dir><dir name="theme"><file name="3024-day.css" hash="2b259ecd423f3ce94a722c1f5d46a31f"/><file name="3024-night.css" hash="ab94fd59ab96fb1aa3e81dfddb6987cb"/><file name="abcdef.css" hash="a8ccb14d4be49cf68affcf33b77fce3f"/><file name="ambiance-mobile.css" hash="75d6e3e84df3d2d0fd6263587900a9f2"/><file name="ambiance.css" hash="df554079ab89352e7b407f9db17d50fd"/><file name="base16-dark.css" hash="fdae4f313cca84cf7867d7695a809e97"/><file name="base16-light.css" hash="75b47de25ea8faf2f9dd6db40a579c35"/><file name="bespin.css" hash="0d4911d305080973de85c044584806aa"/><file name="blackboard.css" hash="022d790d189e391efa1fcb4e1ce4b7ca"/><file name="cobalt.css" hash="523b38d22f2e0c0ce166576a16ca0281"/><file name="colorforth.css" hash="ba27b85d9a988cdc24ddbe56bce9eb07"/><file name="dracula.css" hash="5ec23e6634c26a2fea63343213835726"/><file name="eclipse.css" hash="314ec24dd09cb97222a2535ed7715f0b"/><file name="elegant.css" hash="f0f6623f96dfbe7860b8d6afd44498a0"/><file name="erlang-dark.css" hash="3ff34e94c01ce38a26e3e174ad642001"/><file name="hopscotch.css" hash="e530e187dbe39f12c778029895175d93"/><file name="icecoder.css" hash="614dcba65fd0fb1844cca326530d71a9"/><file name="isotope.css" hash="22e3d07dc710ca1fc6809459623cd1bd"/><file name="lesser-dark.css" hash="b73404c4e3a2a3b9481157ebd2d76610"/><file name="liquibyte.css" hash="63a5489eb042bc4d8611cd88fa8acab1"/><file name="material.css" hash="3ae7b0981901f96974b874dba203bf23"/><file name="mbo.css" hash="dd64e520b08ca240cd316d34b0fb4954"/><file name="mdn-like.css" hash="ded52290c03f1c2e978e266d7d971178"/><file name="midnight.css" hash="bdce9536d0e57a463c54450600e48b13"/><file name="monokai.css" hash="cf7bc36167d46b635350c303b393505d"/><file name="neat.css" hash="23a5db706b96502df2c24d8114b47fe0"/><file name="neo.css" hash="e5206a0a0dd891c5fe3bccca068e47a7"/><file name="night.css" hash="d7ece6eff6e01835632b6ce8747c89ac"/><file name="paraiso-dark.css" hash="98ac9857e72bc2c18d1fb962e7234f03"/><file name="paraiso-light.css" hash="95830052862d184f7e4990608a9f4d61"/><file name="pastel-on-dark.css" hash="747143af8c34743ab6010c2b823ea9bb"/><file name="railscasts.css" hash="51f1577ecaaae0cc532f1159eebfb564"/><file name="rubyblue.css" hash="86fe07d4c88d8e2c43a68120d5c148a8"/><file name="seti.css" hash="87435dbb891fa7b564c2342dbc201dd9"/><file name="solarized.css" hash="5cce80f3253dde99eaf27f1827e5de55"/><file name="the-matrix.css" hash="081300ef7d26e3ebdc986aeeab3df0f7"/><file name="tomorrow-night-bright.css" hash="c6a2d6679ec30cc81bdd7823a37639da"/><file name="tomorrow-night-eighties.css" hash="b9498f6b1a1c31f75b3f248a74b992df"/><file name="ttcn.css" hash="cbb49c6b4866a208097ab7ab38765495"/><file name="twilight.css" hash="75d129c0ba7b878c5322f8ba7f2f6009"/><file name="vibrant-ink.css" hash="95cb7e6fac9c22f53c08a071174606cc"/><file name="xq-dark.css" hash="8effe912f98ba011fad79d7d2d1e65ff"/><file name="xq-light.css" hash="ced9231fe2df68da3345089704488434"/><file name="yeti.css" hash="50184fc2a49072b496ddd54d68a7ed7b"/><file name="zenburn.css" hash="84fb6d3264fe6ebce7e76b3e916ea25a"/></dir></dir><dir name="emmet-codemirror"><dir name="dist"><file name="emmet.js" hash="86e93251ef948432b389b618aeb33935"/></dir></dir><dir name="gator"><file name="gator.min.js" hash="baeed415b14018f2cce187a2919a99b9"/></dir><dir name="htmlhint"><dir name="lib"><file name="htmlhint.js" hash="b0387560e3736d7cdf843d71b826b743"/></dir></dir><dir name="js-beautify"><dir name="js"><dir name="lib"><file name="beautify-css.js" hash="1ee2ff52ccf2ffc359a8766e77af6b95"/><file name="beautify-html.js" hash="398727902a3d8c263ab173b77c6ad03b"/><file name="beautify.js" hash="9c403178a89aa18c820b9f79b19652f0"/></dir></dir></dir><dir name="require-css"><file name="css.js" hash="ba3becc9467b6dbb264799be028a3d3c"/></dir><dir name="requirejs"><file name="require.js" hash="7f752fef626edafefdd4813b84b99e73"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Esites_Editor.csv" hash="8daece7277a99e5af1c72b591016c112"/></dir><dir name="nl_NL"><file name="Esites_Editor.csv" hash="817bd8de0a88b1223837dbc424ea9e6d"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="esites_editor"><file name="standalone.phtml" hash="8bb314fd3f83beb7003971a20ba390a8"/></dir></dir><dir name="layout"><file name="esites_editor.xml" hash="e1dde00db3c7d436621a1b4ae21260f7"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="esites_editor"><file name="standalone.phtml" hash="8aa8afe17d77dc0aca49cc1b0ad03f8f"/></dir></dir><dir name="layout"><file name="esites_editor.xml" hash="ac7b19e4bd567a5ee551f918238a9666"/></dir></dir></dir></dir></target></contents>
24
  <compatible/>
25
  <dependencies><required><php><min>5.4.0</min><max>6.0.0</max></php></required></dependencies>
26
  </package>