WPide - Version 2.0

Version Description

  • Recreated this plugin as a dedicated WPide section/app rather than extending the built in plugin/theme editor (just incase WP remove it)
  • Now using the WP filesystem API (although currently restricted to local access)
  • More security checks on file opening and editing
  • Added new file tree for exploring the file system and opening files (any file in wp-content)
  • Massive overhaul to code autocomplete functionality with the addition of function information right in the app
  • Update the ajaxorg Ace Editor to the current branch
  • Tabbed editing
Download this release

Release Info

Developer WPsites
Plugin Icon 128x128 WPide
Version 2.0
Comparing to
See all releases

Code changes from version 1.0.6 to 2.0

WPide.php CHANGED
@@ -1,252 +1,303 @@
1
  <?php
2
  /*
3
-
4
- Plugin Name: WPide
5
  Plugin URI: https://github.com/WPsites/WPide
6
- Description: Replace the default WordPress code editor for plugins and themes. Adding syntax highlighting, autocomplete of WordPress functions + PHP, line numbers, auto backup of files before editing.
7
- Version: 1.0.6
8
  Author: Simon Dunton
9
  Author URI: http://www.wpsites.co.uk
10
-
11
  */
12
 
13
 
14
-
15
- class WPide
16
 
17
  {
18
 
19
-
 
20
  function __construct() {
21
-
22
- // Uncomment any of these calls to add the functionality that you need.
23
- add_action('admin_head', 'WPide::add_admin_head');
24
- add_action('admin_init', 'WPide::add_admin_js');
25
-
26
- //setup ajax function to save a backup
27
- add_action('wp_ajax_ace_backup_call', 'WPide::ace_backup_call');
28
-
29
-
30
- }
31
 
32
- public static function add_admin_head()
33
- {
34
-
35
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
- <style type="text/css">
38
- #quicktags, #post-status-info, #editor-toolbar, #newcontent, .ace_print_margin { display: none; }
39
- #fancyeditordiv {
40
- position: relative;
41
- width: 500px;
42
- height: 400px;
43
  }
44
- #template div{margin-right:0 !important;}
45
- </style>
46
-
47
- <?php
48
-
49
- }
50
 
51
- public static function add_admin_js()
52
- {
53
- $plugin_path = get_bloginfo('url').'/wp-content/plugins/' . basename(dirname(__FILE__)) .'/';
54
- //include ace
55
- wp_enqueue_script('ace', $plugin_path . 'ace-0.2.0/src/ace.js');
56
- //include ace modes for css, javascript & php
57
- wp_enqueue_script('ace-mode-css', $plugin_path . 'ace-0.2.0/src/mode-css.js');
58
- wp_enqueue_script('ace-mode-javascript', $plugin_path . 'ace-0.2.0/src/mode-javascript.js');
59
- wp_enqueue_script('ace-mode-php', $plugin_path . 'ace-0.2.0/src/mode-php.js');
60
- //include ace theme
61
- wp_enqueue_script('ace-theme', $plugin_path . 'ace-0.2.0/src/theme-dawn.js');//monokai is nice
62
- // html tags for completion
63
- wp_enqueue_script('wpide-editor-completion', $plugin_path . 'js/html-tags.js');
64
- // load & prepare editor
65
- wp_enqueue_script('wpide-editor-load', $plugin_path . 'js/load-editor.js');
66
- }
67
 
68
 
69
- public static function ace_backup_call() {
70
-
71
- $backup_path = get_bloginfo('url').'/wp-content/plugins/' . basename(dirname(__FILE__)) .'/backups/';
72
- $file_name = $_POST['filename'];
73
- $edit_type = $_POST['edittype'];
74
 
75
- if ($edit_type==='theme'){
76
- $theme_root = get_theme_root();
77
- $short_path = str_replace($theme_root, '', $file_name);
78
 
79
- $new_file_path_daily = WP_PLUGIN_DIR.'/wpide/backups/themes'.$short_path.'.'.date("Ymd");
80
- $new_file_path_hourly = WP_PLUGIN_DIR.'/wpide/backups/themes'.$short_path.'.'.date("YmdH");
81
 
82
- $new_file_info = pathinfo($new_file_path_daily);
83
 
84
- if (!is_dir($new_file_info['dirname'])) mkdir($new_file_info['dirname'], 0777, true); //make directory if not exist
85
 
86
- //check for todays backup if non existant then create
87
- if (!file_exists($new_file_path_daily)){
88
- $backup_result = copy($file_name, $new_file_path_daily); //make a copy of the file
89
 
90
- //check for a backup this hour if doesn't exist then create
91
- }else if(!file_exists($new_file_path_hourly)){
92
- $backup_result = copy($file_name, $new_file_path_hourly); //make a copy of the file
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  }
94
-
95
- //do no further backups since one intial backup for today and an hourly one is plenty!
96
-
97
- }else if ($edit_type==='plugin'){
98
-
99
- $plugin_root = WP_PLUGIN_DIR;
100
- $short_path = str_replace($plugin_root, '', $file_name);
101
-
102
- $new_file_path_daily = WP_PLUGIN_DIR.'/wpide/backups/plugins/'.$short_path.'.'.date("Ymd");
103
- $new_file_path_hourly = WP_PLUGIN_DIR.'/wpide/backups/plugins/'.$short_path.'.'.date("YmdH");
104
-
105
- $new_file_info = pathinfo($new_file_path_daily);
106
-
107
- if (!is_dir($new_file_info['dirname'])) mkdir($new_file_info['dirname'], 0777, true); //make directory if not exist
108
-
109
- //check for todays backup if non existant then create
110
- if (!file_exists($new_file_path_daily)){
111
- $backup_result = copy($plugin_root.'/'.$file_name, $new_file_path_daily); //make a copy of the file
112
-
113
- //check for a backup this hour if doesn't exist then create
114
- }else if(!file_exists($new_file_path_hourly)){
115
- $backup_result = copy($plugin_root.'/'.$file_name, $new_file_path_hourly); //make a copy of the file
116
-
117
  }
118
-
119
- //do no further backups since one intial backup for today and an hourly one is plenty!
120
-
121
  }
122
-
123
- if ($backup_result){
124
- echo "success";
125
- }
126
-
127
- //echo "final debug info : " . WP_PLUGIN_DIR.'/wpide/backups/'.$short_path.'.backup';
128
  die(); // this is required to return a proper result
129
-
130
  }
131
 
132
- }
133
-
134
- //only include this plugin if on theme or plugin editors (Or Multisite network equivalents) or an ajax call
135
- $is_ms = '';
136
- if ( is_multisite() )
137
- $is_ms = 'network/';
138
-
139
- if ( $_SERVER['PHP_SELF'] === '/wp-admin/' . $is_ms . 'plugin-editor.php' ||
140
- $_SERVER['PHP_SELF'] === '/wp-admin/' . $is_ms . 'theme-editor.php' ||
141
- $_SERVER['PHP_SELF'] === '/wp-admin/admin-ajax.php' ){
142
-
143
- add_action( 'init', create_function( '', 'new WPide();' ) );
144
- }
145
-
146
 
147
- add_filter("plugin_row_meta", 'wpide_dev_links', 10, 2);
148
-
149
- function wpide_dev_links($links, $file) {
150
- static $this_plugin;
151
-
152
- if (!$this_plugin) {
153
- $this_plugin = plugin_basename(__FILE__);
154
- }
155
-
156
- // check to make sure we are on the correct plugin
157
- if ($file === $this_plugin) {
158
- // the anchor tag and href to the URL we want. For a "Settings" link, this needs to be the url of your settings page
159
- $settings_link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/plugins.php?page=install-required-plugins" style="font-weight:bold;">Download and install V2 Development version</a>';
160
- // add the link to the list
161
- array_push($links, $settings_link);
162
- }
163
- return $links;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  }
165
-
166
-
167
-
168
-
169
-
170
-
171
- /**
172
- * Include the TGM_Plugin_Activation class.
173
- */
174
- require_once dirname( __FILE__ ) . '/tgm-plugin-activation/class-tgm-plugin-activation.php';
175
-
176
- add_action( 'tgmpa_register', 'wpide_run_dev' );
177
- /**
178
- * Register the required plugins for this theme.
179
- *
180
- * In this example, we register two plugins - one included with the TGMPA library
181
- * and one from the .org repo.
182
- *
183
- * The variable passed to tgmpa_register_plugins() should be an array of plugin
184
- * arrays.
185
- *
186
- * This function is hooked into tgmpa_init, which is fired within the
187
- * TGM_Plugin_Activation class constructor.
188
- */
189
- function wpide_run_dev() {
190
-
191
- /**
192
- * Array of plugin arrays. Required keys are name and slug.
193
- * If the source is NOT from the .org repo, then source is also required.
194
- */
195
- $plugins = array(
196
-
197
- // This is an example of how to include a plugin from the WordPress Plugin Repository
198
- array(
199
- 'name' => 'WPide V2 Dev',
200
- 'slug' => 'WPideV2',
201
- 'version' => '2.0',
202
- 'required' => false,
203
- 'external_url' => 'https://github.com/WPsites/WPide/tree/v2dev',
204
- 'source' => 'https://github.com/WPsites/WPide/zipball/v2dev',
205
- ),
206
-
207
- );
208
-
209
- // Change this to your theme text domain, used for internationalising strings
210
- $theme_text_domain = 'tgmpa';
211
-
212
- /**
213
- * Array of configuration settings. Amend each line as needed.
214
- * If you want the default strings to be available under your own theme domain,
215
- * leave the strings uncommented.
216
- * Some of the strings are added into a sprintf, so see the comments at the
217
- * end of each line for what each argument will be.
218
- */
219
- $config = array(
220
- 'domain' => $theme_text_domain, // Text domain - likely want to be the same as your theme.
221
- 'default_path' => '', // Default absolute path to pre-packaged plugins
222
- 'parent_menu_slug' => 'plugins.php', // Default parent menu slug
223
- 'parent_url_slug' => 'plugins.php', // Default parent URL slug
224
- 'menu' => 'install-required-plugins', // Menu slug
225
- 'has_notices' => true, // Show admin notices or not
226
- 'is_automatic' => true, // Automatically activate plugins after installation or not
227
- 'message' => '', // Message to output right before the plugins table
228
- 'strings' => array(
229
- 'page_title' => __( 'Install Suggested Plugins', $theme_text_domain ),
230
- 'menu_title' => __( 'Install Plugins', $theme_text_domain ),
231
- 'installing' => __( 'Installing Plugin: %s', $theme_text_domain ), // %1$s = plugin name
232
- 'oops' => __( 'Something went wrong with the plugin API.', $theme_text_domain ),
233
- 'notice_can_install_required' => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.' ), // %1$s = plugin name(s)
234
- 'notice_can_install_recommended' => _n_noop( 'The V2 Development branch of WPide is available for testing - With new features such as multi tab editing.<br />Word of warning: this is the cutting edge development version which could contain bugs so use at your own risk! ', 'WPide recommends the following plugins: %1$s.' ), // %1$s = plugin name(s)
235
- 'notice_cannot_install' => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.' ), // %1$s = plugin name(s)
236
- 'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s)
237
- 'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s)
238
- 'notice_cannot_activate' => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.' ), // %1$s = plugin name(s)
239
- 'notice_ask_to_update' => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.' ), // %1$s = plugin name(s)
240
- 'notice_cannot_update' => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.' ), // %1$s = plugin name(s)
241
- 'install_link' => _n_noop( 'Begin installing the development version of WPide', 'Begin installing plugins' ),
242
- 'activate_link' => _n_noop( 'Activate WPide V2 Dev', 'Activate installed plugins' ),
243
- 'return' => __( 'Return to Suggested Plugins Installer', $theme_text_domain ),
244
- 'plugin_activated' => __( 'Plugin activated successfully.', $theme_text_domain ),
245
- 'complete' => __( 'All plugins installed and activated successfully. %s', $theme_text_domain ) // %1$s = dashboard link
246
- )
247
- );
248
-
249
- tgmpa( $plugins, $config );
250
 
251
  }
252
- ?>
 
1
  <?php
2
  /*
3
+ Plugin Name: WPide
 
4
  Plugin URI: https://github.com/WPsites/WPide
5
+ Description: WordPress code editor with auto completion of both WordPress and PHP functions with reference, syntax highlighting, line numbers, tabbed editing, automatic backup.
6
+ Version: 2.0
7
  Author: Simon Dunton
8
  Author URI: http://www.wpsites.co.uk
 
9
  */
10
 
11
 
12
+
13
+ class WPide2
14
 
15
  {
16
 
17
+ public $site_url, $plugin_url;
18
+
19
  function __construct() {
 
 
 
 
 
 
 
 
 
 
20
 
21
+ //add WPide to the menu
22
+ add_action( 'admin_menu', array( &$this, 'add_my_menu_page' ) );
23
+
24
+ //only include this plugin if on theme editor, plugin editor or an ajax call
25
+ if ( $_SERVER['PHP_SELF'] === '/wp-admin/admin-ajax.php' ||
26
+ $_GET['page'] === 'wpide' ){
27
+
28
+ //force local file method for testing - you could force other methods 'direct', 'ssh', 'ftpext' or 'ftpsockets'
29
+ define('FS_METHOD', 'direct');
30
+
31
+ // Uncomment any of these calls to add the functionality that you need.
32
+ //add_action('admin_head', 'WPide2::add_admin_head');
33
+ add_action('admin_init', 'WPide2::add_admin_js');
34
+ add_action('admin_init', 'WPide2::add_admin_styles');
35
+
36
+ //setup jqueryFiletree list callback
37
+ add_action('wp_ajax_jqueryFileTree', 'WPide2::jqueryFileTree_get_list');
38
+ //setup ajax function to get file contents for editing
39
+ add_action('wp_ajax_wpide_get_file', 'WPide2::wpide_get_file' );
40
+ //setup ajax function to save file contents and do automatic backup if needed
41
+ add_action('wp_ajax_wpide_save_file', 'WPide2::wpide_save_file' );
42
+
43
+ }
44
+
45
+ $WPide->site_url = get_bloginfo('url');
46
+
47
 
 
 
 
 
 
 
48
  }
 
 
 
 
 
 
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
 
52
+ public static function add_admin_head()
53
+ {
54
+
55
+ }
 
56
 
 
 
 
57
 
 
 
58
 
 
59
 
 
60
 
 
 
 
61
 
62
+ public static function add_admin_js(){
63
+
64
+ $plugin_path = plugin_dir_url( __FILE__ );
65
+ //include file tree
66
+ wp_enqueue_script('jquery-file-tree', plugins_url("jqueryFileTree.js", __FILE__ ) );
67
+ //include ace
68
+ wp_enqueue_script('ace', plugins_url("ace-0.2.0/src/ace.js", __FILE__ ) );
69
+ //include ace modes for css, javascript & php
70
+ wp_enqueue_script('ace-mode-css', $plugin_path . 'ace-0.2.0/src/mode-css.js');
71
+ wp_enqueue_script('ace-mode-javascript', $plugin_path . 'ace-0.2.0/src/mode-javascript.js');
72
+ wp_enqueue_script('ace-mode-php', $plugin_path . 'ace-0.2.0/src/mode-php.js');
73
+ //include ace theme
74
+ wp_enqueue_script('ace-theme', plugins_url("ace-0.2.0/src/theme-dawn.js", __FILE__ ) );//monokai is nice
75
+ // wordpress-completion tags
76
+ wp_enqueue_script('wpide-wordpress-completion', plugins_url("js/autocomplete.wordpress.js", __FILE__ ) );
77
+ // php-completion tags
78
+ wp_enqueue_script('wpide-php-completion', plugins_url("js/autocomplete.php.js", __FILE__ ) );
79
+ // load editor
80
+ wp_enqueue_script('wpide-load-editor', plugins_url("js/load-editor.js", __FILE__ ) );
81
+ // load autocomplete dropdown
82
+ wp_enqueue_script('wpide-dd', plugins_url("js/jquery.dd.js", __FILE__ ) );
83
+
84
+
85
+ }
86
+
87
+ public static function add_admin_styles(){
88
+
89
+ //main wpide styles
90
+ wp_register_style( 'wpide_style', plugins_url('wpide.css', __FILE__) );
91
+ wp_enqueue_style( 'wpide_style' );
92
+ //filetree styles
93
+ wp_register_style( 'wpide_filetree_style', plugins_url('jqueryFileTree.css', __FILE__) );
94
+ wp_enqueue_style( 'wpide_filetree_style' );
95
+ //autocomplete dropdown styles
96
+ wp_register_style( 'wpide_dd_style', plugins_url('dd.css', __FILE__) );
97
+ wp_enqueue_style( 'wpide_dd_style' );
98
+
99
+
100
+ }
101
+
102
+
103
+
104
+ public static function jqueryFileTree_get_list() {
105
+ //check the user has the permissions
106
+ check_admin_referer('plugin-name-action_wpidenonce');
107
+ if ( !current_user_can('edit_themes') )
108
+ wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this site. SORRY').'</p>');
109
+
110
+ //setup wp_filesystem api
111
+ global $wp_filesystem;
112
+ if ( ! WP_Filesystem($creds) )
113
+ return false;
114
+
115
+ $_POST['dir'] = urldecode($_POST['dir']);
116
+ $root = WP_CONTENT_DIR;
117
+
118
+ if( $wp_filesystem->exists($root . $_POST['dir']) ) {
119
+ //$files = scandir($root . $_POST['dir']);
120
+ //print_r($files);
121
+ $files = $wp_filesystem->dirlist($root . $_POST['dir']);
122
+ //print_r($files);
123
+
124
+ if( count($files) > 2 ) { /* The 2 accounts for . and .. */
125
+ echo "<ul class=\"jqueryFileTree\" style=\"display: none;\">";
126
+ // All dirs
127
+ foreach( $files as $file => $file_info ) {
128
+ if( $file != '.' && $file != '..' && $file_info['type']=='d' ) {
129
+ echo "<li class=\"directory collapsed\"><a href=\"#\" rel=\"" . htmlentities($_POST['dir'] . $file) . "/\">" . htmlentities($file) . "</a></li>";
130
+ }
131
  }
132
+ // All files
133
+ foreach( $files as $file => $file_info ) {
134
+ if( $file != '.' && $file != '..' && $file_info['type']!='d') {
135
+ $ext = preg_replace('/^.*\./', '', $file);
136
+ echo "<li class=\"file ext_$ext\"><a href=\"#\" rel=\"" . htmlentities($_POST['dir'] . $file) . "\">" . htmlentities($file) . "</a></li>";
137
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  }
139
+ echo "</ul>";
140
+ }
 
141
  }
142
+
 
 
 
 
 
143
  die(); // this is required to return a proper result
 
144
  }
145
 
146
+
147
+ public static function wpide_get_file() {
148
+ //check the user has the permissions
149
+ check_admin_referer('plugin-name-action_wpidenonce');
150
+ if ( !current_user_can('edit_themes') )
151
+ wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this site. SORRY').'</p>');
 
 
 
 
 
 
 
 
152
 
153
+ //setup wp_filesystem api
154
+ global $wp_filesystem;
155
+ if ( ! WP_Filesystem($creds) )
156
+ return false;
157
+
158
+
159
+ $root = WP_CONTENT_DIR;
160
+ $file_name = $root . stripslashes($_POST['filename']);
161
+ echo $wp_filesystem->get_contents($file_name);
162
+ die(); // this is required to return a proper result
163
+ }
164
+
165
+ public static function wpide_save_file() {
166
+ //check the user has the permissions
167
+ check_admin_referer('plugin-name-action_wpidenonce');
168
+ if ( !current_user_can('edit_themes') )
169
+ wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this site. SORRY').'</p>');
170
+
171
+ //setup wp_filesystem api
172
+ global $wp_filesystem;
173
+ if ( ! WP_Filesystem($creds) )
174
+ echo "Cannot initialise the WP file system API";
175
+
176
+ //save a copy of the file and create a backup just in case
177
+ $root = WP_CONTENT_DIR;
178
+ $file_name = $root . stripslashes($_POST['filename']);
179
+
180
+ //set backup filename
181
+ $backup_path = ABSPATH .'wp-content/plugins/' . basename(dirname(__FILE__)) .'/backups/' . str_replace( str_replace('\\', "/", ABSPATH), '', $file_name) .'.'.date("YmdH");
182
+ //create backup directory if not there
183
+ $new_file_info = pathinfo($backup_path);
184
+ if (!$wp_filesystem->is_dir($new_file_info['dirname'])) $wp_filesystem->mkdir($new_file_info['dirname'], 0775);
185
+
186
+ //do backup
187
+ $wp_filesystem->copy( $file_name, $backup_path );
188
+
189
+ //save file
190
+ if( $wp_filesystem->put_contents( $file_name, stripslashes($_POST['content'])) ) echo "success";
191
+ die(); // this is required to return a proper result
192
+ }
193
+
194
+ public function add_my_menu_page() {
195
+ //add_menu_page("wpide", "wpide","edit_themes", "wpidesettings", array( &$this, 'my_menu_page') );
196
+ add_menu_page('WPide', 'WPide', 'edit_themes', "wpide", array( &$this, 'my_menu_page' ));
197
+ }
198
+
199
+ public function my_menu_page() {
200
+ if ( !current_user_can('edit_themes') )
201
+ wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this site. SORRY').'</p>');
202
+
203
+ ?>
204
+ <script>
205
+
206
+ var wpide_app_path = "<?php echo plugin_dir_url( __FILE__ ); ?>";
207
+
208
+
209
+ jQuery(document).ready( function($) {
210
+ $('#wpide_file_browser').fileTree({ script: ajaxurl }, function(parent, file) {
211
+
212
+ if ( $(".wpide_tab[rel='"+file+"']").length > 0) {
213
+ $(".wpide_tab[sessionrel='"+ $(".wpide_tab[rel='"+file+"']").attr("sessionrel") +"']").click();//focus the already open tab
214
+ }else{
215
+
216
+ var image_patern =new RegExp("(\.jpg|\.gif|\.png|\.bmp)$");
217
+ if ( image_patern.test(file) ){
218
+ alert("Image editing is not currently available. It's a planned feature using http://pixlr.com/");
219
+ }else{
220
+ $(parent).addClass('wait');
221
+
222
+ wpide_set_file_contents(file, function(){
223
+
224
+ //once file loaded remove the wait class/indicator
225
+ $(parent).removeClass('wait');
226
+
227
+ });
228
+
229
+ $('#filename').val(file);
230
+ }
231
+
232
+ }
233
+
234
+ });
235
+ });
236
+ </script>
237
+
238
+ <?php
239
+ $url = wp_nonce_url('admin.php?page=wpide','plugin-name-action_wpidenonce');
240
+ if ( ! WP_Filesystem($creds) ) {
241
+ request_filesystem_credentials($url, '', true, false, null);
242
+ return;
243
+ }
244
+ ?>
245
+
246
+ <div id="poststuff" class="metabox-holder has-right-sidebar">
247
+
248
+ <div id="side-info-column" class="inner-sidebar">
249
+
250
+ <div id="wpide_info"><div id="wpide_info_content"></div> </div>
251
+
252
+ <div id="submitdiv" class="postbox ">
253
+ <h3 class="hndle"><span>Files</span></h3>
254
+ <div class="inside">
255
+ <div class="submitbox" id="submitpost">
256
+ <div id="minor-publishing">
257
+ </div>
258
+ <div id="major-publishing-actions">
259
+ <div id="wpide_file_browser"></div>
260
+ <br style="clear:both;" />
261
+
262
+ <div class="clear"></div>
263
+ </div>
264
+ </div>
265
+ </div>
266
+ </div>
267
+
268
+
269
+ </div>
270
+
271
+ <div id="post-body">
272
+ <div id="wpide_toolbar" class="quicktags-toolbar">
273
+ <div id="wpide_toolbar_tabs"> </div>
274
+ </div>
275
+
276
+ <div id="wpide_toolbar_buttons">
277
+ <div id="wpide_message" class="error highlight"></div>
278
+ <a href="#"></a> <a href="#"></a> </div>
279
+
280
+
281
+ <div id='fancyeditordiv'></div>
282
+
283
+ <form id="wpide_save_container" action="" method="get">
284
+ <a href="#" id="wpide_save" class="button-primary">SAVE
285
+ FILE</a>
286
+ <input type="hidden" id="filename" name="filename" value="" />
287
+ <?php
288
+ if ( function_exists('wp_nonce_field') )
289
+ wp_nonce_field('plugin-name-action_wpidenonce');
290
+ ?>
291
+ </form>
292
+ </div>
293
+
294
+
295
+
296
+ </div>
297
+
298
+ <?php
299
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
300
 
301
  }
302
+ add_action("init", create_function('', 'new WPide2();'));
303
+ ?>
ace-0.2.0/src/ace-compat-noconflict.js ADDED
@@ -0,0 +1 @@
 
1
+ ace.define("pilot/index",["require","exports","module","pilot/browser_focus","pilot/dom","pilot/event","pilot/event_emitter","pilot/fixoldbrowsers","pilot/keys","pilot/lang","pilot/oop","pilot/useragent","pilot/canon"],function(a,b,c){a("pilot/browser_focus"),a("pilot/dom"),a("pilot/event"),a("pilot/event_emitter"),a("pilot/fixoldbrowsers"),a("pilot/keys"),a("pilot/lang"),a("pilot/oop"),a("pilot/useragent"),a("pilot/canon")}),ace.define("pilot/browser_focus",["require","exports","module","ace/lib/browser_focus"],function(a,b,c){console.warn("DEPRECATED: 'pilot/browser_focus' is deprecated. Use 'ace/lib/browser_focus' instead"),c.exports=a("ace/lib/browser_focus")}),ace.define("pilot/dom",["require","exports","module","ace/lib/dom"],function(a,b,c){console.warn("DEPRECATED: 'pilot/dom' is deprecated. Use 'ace/lib/dom' instead"),c.exports=a("ace/lib/dom")}),ace.define("pilot/event",["require","exports","module","ace/lib/event"],function(a,b,c){console.warn("DEPRECATED: 'pilot/event' is deprecated. Use 'ace/lib/event' instead"),c.exports=a("ace/lib/event")}),ace.define("pilot/event_emitter",["require","exports","module","ace/lib/event_emitter"],function(a,b,c){console.warn("DEPRECATED: 'pilot/event_emitter' is deprecated. Use 'ace/lib/event_emitter' instead"),c.exports=a("ace/lib/event_emitter")}),ace.define("pilot/fixoldbrowsers",["require","exports","module","ace/lib/fixoldbrowsers"],function(a,b,c){console.warn("DEPRECATED: 'pilot/fixoldbrowsers' is deprecated. Use 'ace/lib/fixoldbrowsers' instead"),c.exports=a("ace/lib/fixoldbrowsers")}),ace.define("pilot/keys",["require","exports","module","ace/lib/keys"],function(a,b,c){console.warn("DEPRECATED: 'pilot/keys' is deprecated. Use 'ace/lib/keys' instead"),c.exports=a("ace/lib/keys")}),ace.define("pilot/lang",["require","exports","module","ace/lib/lang"],function(a,b,c){console.warn("DEPRECATED: 'pilot/lang' is deprecated. Use 'ace/lib/lang' instead"),c.exports=a("ace/lib/lang")}),ace.define("pilot/oop",["require","exports","module","ace/lib/oop"],function(a,b,c){console.warn("DEPRECATED: 'pilot/oop' is deprecated. Use 'ace/lib/oop' instead"),c.exports=a("ace/lib/oop")}),ace.define("pilot/useragent",["require","exports","module","ace/lib/useragent"],function(a,b,c){console.warn("DEPRECATED: 'pilot/useragent' is deprecated. Use 'ace/lib/useragent' instead"),c.exports=a("ace/lib/useragent")}),ace.define("pilot/canon",["require","exports","module"],function(a,b,c){console.warn("DEPRECATED: 'pilot/canon' is deprecated."),b.addCommand=function(){console.warn("DEPRECATED: 'canon.addCommand()' is deprecated. Use 'editor.commands.addCommand(command)' instead."),console.trace()},b.removeCommand=function(){console.warn("DEPRECATED: 'canon.removeCommand()' is deprecated. Use 'editor.commands.removeCommand(command)' instead."),console.trace()}})
ace-0.2.0/src/ace-compat-uncompressed-noconflict.js ADDED
@@ -0,0 +1,480 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* vim:ts=4:sts=4:sw=4:
2
+ * ***** BEGIN LICENSE BLOCK *****
3
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
+ *
5
+ * The contents of this file are subject to the Mozilla Public License Version
6
+ * 1.1 (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ * http://www.mozilla.org/MPL/
9
+ *
10
+ * Software distributed under the License is distributed on an "AS IS" basis,
11
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
+ * for the specific language governing rights and limitations under the
13
+ * License.
14
+ *
15
+ * The Original Code is Ajax.org Code Editor (ACE).
16
+ *
17
+ * The Initial Developer of the Original Code is
18
+ * Ajax.org B.V.
19
+ * Portions created by the Initial Developer are Copyright (C) 2010
20
+ * the Initial Developer. All Rights Reserved.
21
+ *
22
+ * Contributor(s):
23
+ * Fabian Jakobs <fabian AT ajax DOT org>
24
+ *
25
+ * Alternatively, the contents of this file may be used under the terms of
26
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
27
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
+ * in which case the provisions of the GPL or the LGPL are applicable instead
29
+ * of those above. If you wish to allow use of your version of this file only
30
+ * under the terms of either the GPL or the LGPL, and not to allow others to
31
+ * use your version of this file under the terms of the MPL, indicate your
32
+ * decision by deleting the provisions above and replace them with the notice
33
+ * and other provisions required by the GPL or the LGPL. If you do not delete
34
+ * the provisions above, a recipient may use your version of this file under
35
+ * the terms of any one of the MPL, the GPL or the LGPL.
36
+ *
37
+ * ***** END LICENSE BLOCK ***** */
38
+
39
+ ace.define('pilot/index', ['require', 'exports', 'module' , 'pilot/browser_focus', 'pilot/dom', 'pilot/event', 'pilot/event_emitter', 'pilot/fixoldbrowsers', 'pilot/keys', 'pilot/lang', 'pilot/oop', 'pilot/useragent', 'pilot/canon'], function(require, exports, module) {
40
+ require("pilot/browser_focus");
41
+ require("pilot/dom");
42
+ require("pilot/event");
43
+ require("pilot/event_emitter");
44
+ require("pilot/fixoldbrowsers");
45
+ require("pilot/keys");
46
+ require("pilot/lang");
47
+ require("pilot/oop");
48
+ require("pilot/useragent");
49
+ require("pilot/canon");
50
+ });
51
+ /* vim:ts=4:sts=4:sw=4:
52
+ * ***** BEGIN LICENSE BLOCK *****
53
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
54
+ *
55
+ * The contents of this file are subject to the Mozilla Public License Version
56
+ * 1.1 (the "License"); you may not use this file except in compliance with
57
+ * the License. You may obtain a copy of the License at
58
+ * http://www.mozilla.org/MPL/
59
+ *
60
+ * Software distributed under the License is distributed on an "AS IS" basis,
61
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
62
+ * for the specific language governing rights and limitations under the
63
+ * License.
64
+ *
65
+ * The Original Code is Ajax.org Code Editor (ACE).
66
+ *
67
+ * The Initial Developer of the Original Code is
68
+ * Ajax.org B.V.
69
+ * Portions created by the Initial Developer are Copyright (C) 2010
70
+ * the Initial Developer. All Rights Reserved.
71
+ *
72
+ * Contributor(s):
73
+ * Fabian Jakobs <fabian AT ajax DOT org>
74
+ *
75
+ * Alternatively, the contents of this file may be used under the terms of
76
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
77
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
78
+ * in which case the provisions of the GPL or the LGPL are applicable instead
79
+ * of those above. If you wish to allow use of your version of this file only
80
+ * under the terms of either the GPL or the LGPL, and not to allow others to
81
+ * use your version of this file under the terms of the MPL, indicate your
82
+ * decision by deleting the provisions above and replace them with the notice
83
+ * and other provisions required by the GPL or the LGPL. If you do not delete
84
+ * the provisions above, a recipient may use your version of this file under
85
+ * the terms of any one of the MPL, the GPL or the LGPL.
86
+ *
87
+ * ***** END LICENSE BLOCK ***** */
88
+
89
+ ace.define('pilot/browser_focus', ['require', 'exports', 'module' , 'ace/lib/browser_focus'], function(require, exports, module) {
90
+ console.warn("DEPRECATED: 'pilot/browser_focus' is deprecated. Use 'ace/lib/browser_focus' instead");
91
+ module.exports = require("ace/lib/browser_focus");
92
+ });
93
+ /* vim:ts=4:sts=4:sw=4:
94
+ * ***** BEGIN LICENSE BLOCK *****
95
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
96
+ *
97
+ * The contents of this file are subject to the Mozilla Public License Version
98
+ * 1.1 (the "License"); you may not use this file except in compliance with
99
+ * the License. You may obtain a copy of the License at
100
+ * http://www.mozilla.org/MPL/
101
+ *
102
+ * Software distributed under the License is distributed on an "AS IS" basis,
103
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
104
+ * for the specific language governing rights and limitations under the
105
+ * License.
106
+ *
107
+ * The Original Code is Ajax.org Code Editor (ACE).
108
+ *
109
+ * The Initial Developer of the Original Code is
110
+ * Ajax.org B.V.
111
+ * Portions created by the Initial Developer are Copyright (C) 2010
112
+ * the Initial Developer. All Rights Reserved.
113
+ *
114
+ * Contributor(s):
115
+ * Fabian Jakobs <fabian AT ajax DOT org>
116
+ *
117
+ * Alternatively, the contents of this file may be used under the terms of
118
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
119
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
120
+ * in which case the provisions of the GPL or the LGPL are applicable instead
121
+ * of those above. If you wish to allow use of your version of this file only
122
+ * under the terms of either the GPL or the LGPL, and not to allow others to
123
+ * use your version of this file under the terms of the MPL, indicate your
124
+ * decision by deleting the provisions above and replace them with the notice
125
+ * and other provisions required by the GPL or the LGPL. If you do not delete
126
+ * the provisions above, a recipient may use your version of this file under
127
+ * the terms of any one of the MPL, the GPL or the LGPL.
128
+ *
129
+ * ***** END LICENSE BLOCK ***** */
130
+
131
+ ace.define('pilot/dom', ['require', 'exports', 'module' , 'ace/lib/dom'], function(require, exports, module) {
132
+ console.warn("DEPRECATED: 'pilot/dom' is deprecated. Use 'ace/lib/dom' instead");
133
+ module.exports = require("ace/lib/dom");
134
+ });
135
+ /* vim:ts=4:sts=4:sw=4:
136
+ * ***** BEGIN LICENSE BLOCK *****
137
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
138
+ *
139
+ * The contents of this file are subject to the Mozilla Public License Version
140
+ * 1.1 (the "License"); you may not use this file except in compliance with
141
+ * the License. You may obtain a copy of the License at
142
+ * http://www.mozilla.org/MPL/
143
+ *
144
+ * Software distributed under the License is distributed on an "AS IS" basis,
145
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
146
+ * for the specific language governing rights and limitations under the
147
+ * License.
148
+ *
149
+ * The Original Code is Ajax.org Code Editor (ACE).
150
+ *
151
+ * The Initial Developer of the Original Code is
152
+ * Ajax.org B.V.
153
+ * Portions created by the Initial Developer are Copyright (C) 2010
154
+ * the Initial Developer. All Rights Reserved.
155
+ *
156
+ * Contributor(s):
157
+ * Fabian Jakobs <fabian AT ajax DOT org>
158
+ *
159
+ * Alternatively, the contents of this file may be used under the terms of
160
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
161
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
162
+ * in which case the provisions of the GPL or the LGPL are applicable instead
163
+ * of those above. If you wish to allow use of your version of this file only
164
+ * under the terms of either the GPL or the LGPL, and not to allow others to
165
+ * use your version of this file under the terms of the MPL, indicate your
166
+ * decision by deleting the provisions above and replace them with the notice
167
+ * and other provisions required by the GPL or the LGPL. If you do not delete
168
+ * the provisions above, a recipient may use your version of this file under
169
+ * the terms of any one of the MPL, the GPL or the LGPL.
170
+ *
171
+ * ***** END LICENSE BLOCK ***** */
172
+
173
+ ace.define('pilot/event', ['require', 'exports', 'module' , 'ace/lib/event'], function(require, exports, module) {
174
+ console.warn("DEPRECATED: 'pilot/event' is deprecated. Use 'ace/lib/event' instead");
175
+ module.exports = require("ace/lib/event");
176
+ });
177
+ /* vim:ts=4:sts=4:sw=4:
178
+ * ***** BEGIN LICENSE BLOCK *****
179
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
180
+ *
181
+ * The contents of this file are subject to the Mozilla Public License Version
182
+ * 1.1 (the "License"); you may not use this file except in compliance with
183
+ * the License. You may obtain a copy of the License at
184
+ * http://www.mozilla.org/MPL/
185
+ *
186
+ * Software distributed under the License is distributed on an "AS IS" basis,
187
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
188
+ * for the specific language governing rights and limitations under the
189
+ * License.
190
+ *
191
+ * The Original Code is Ajax.org Code Editor (ACE).
192
+ *
193
+ * The Initial Developer of the Original Code is
194
+ * Ajax.org B.V.
195
+ * Portions created by the Initial Developer are Copyright (C) 2010
196
+ * the Initial Developer. All Rights Reserved.
197
+ *
198
+ * Contributor(s):
199
+ * Fabian Jakobs <fabian AT ajax DOT org>
200
+ *
201
+ * Alternatively, the contents of this file may be used under the terms of
202
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
203
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
204
+ * in which case the provisions of the GPL or the LGPL are applicable instead
205
+ * of those above. If you wish to allow use of your version of this file only
206
+ * under the terms of either the GPL or the LGPL, and not to allow others to
207
+ * use your version of this file under the terms of the MPL, indicate your
208
+ * decision by deleting the provisions above and replace them with the notice
209
+ * and other provisions required by the GPL or the LGPL. If you do not delete
210
+ * the provisions above, a recipient may use your version of this file under
211
+ * the terms of any one of the MPL, the GPL or the LGPL.
212
+ *
213
+ * ***** END LICENSE BLOCK ***** */
214
+
215
+ ace.define('pilot/event_emitter', ['require', 'exports', 'module' , 'ace/lib/event_emitter'], function(require, exports, module) {
216
+ console.warn("DEPRECATED: 'pilot/event_emitter' is deprecated. Use 'ace/lib/event_emitter' instead");
217
+ module.exports = require("ace/lib/event_emitter");
218
+ });
219
+ /* vim:ts=4:sts=4:sw=4:
220
+ * ***** BEGIN LICENSE BLOCK *****
221
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
222
+ *
223
+ * The contents of this file are subject to the Mozilla Public License Version
224
+ * 1.1 (the "License"); you may not use this file except in compliance with
225
+ * the License. You may obtain a copy of the License at
226
+ * http://www.mozilla.org/MPL/
227
+ *
228
+ * Software distributed under the License is distributed on an "AS IS" basis,
229
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
230
+ * for the specific language governing rights and limitations under the
231
+ * License.
232
+ *
233
+ * The Original Code is Ajax.org Code Editor (ACE).
234
+ *
235
+ * The Initial Developer of the Original Code is
236
+ * Ajax.org B.V.
237
+ * Portions created by the Initial Developer are Copyright (C) 2010
238
+ * the Initial Developer. All Rights Reserved.
239
+ *
240
+ * Contributor(s):
241
+ * Fabian Jakobs <fabian AT ajax DOT org>
242
+ *
243
+ * Alternatively, the contents of this file may be used under the terms of
244
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
245
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
246
+ * in which case the provisions of the GPL or the LGPL are applicable instead
247
+ * of those above. If you wish to allow use of your version of this file only
248
+ * under the terms of either the GPL or the LGPL, and not to allow others to
249
+ * use your version of this file under the terms of the MPL, indicate your
250
+ * decision by deleting the provisions above and replace them with the notice
251
+ * and other provisions required by the GPL or the LGPL. If you do not delete
252
+ * the provisions above, a recipient may use your version of this file under
253
+ * the terms of any one of the MPL, the GPL or the LGPL.
254
+ *
255
+ * ***** END LICENSE BLOCK ***** */
256
+
257
+ ace.define('pilot/fixoldbrowsers', ['require', 'exports', 'module' , 'ace/lib/fixoldbrowsers'], function(require, exports, module) {
258
+ console.warn("DEPRECATED: 'pilot/fixoldbrowsers' is deprecated. Use 'ace/lib/fixoldbrowsers' instead");
259
+ module.exports = require("ace/lib/fixoldbrowsers");
260
+ });
261
+ /* vim:ts=4:sts=4:sw=4:
262
+ * ***** BEGIN LICENSE BLOCK *****
263
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
264
+ *
265
+ * The contents of this file are subject to the Mozilla Public License Version
266
+ * 1.1 (the "License"); you may not use this file except in compliance with
267
+ * the License. You may obtain a copy of the License at
268
+ * http://www.mozilla.org/MPL/
269
+ *
270
+ * Software distributed under the License is distributed on an "AS IS" basis,
271
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
272
+ * for the specific language governing rights and limitations under the
273
+ * License.
274
+ *
275
+ * The Original Code is Ajax.org Code Editor (ACE).
276
+ *
277
+ * The Initial Developer of the Original Code is
278
+ * Ajax.org B.V.
279
+ * Portions created by the Initial Developer are Copyright (C) 2010
280
+ * the Initial Developer. All Rights Reserved.
281
+ *
282
+ * Contributor(s):
283
+ * Fabian Jakobs <fabian AT ajax DOT org>
284
+ *
285
+ * Alternatively, the contents of this file may be used under the terms of
286
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
287
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
288
+ * in which case the provisions of the GPL or the LGPL are applicable instead
289
+ * of those above. If you wish to allow use of your version of this file only
290
+ * under the terms of either the GPL or the LGPL, and not to allow others to
291
+ * use your version of this file under the terms of the MPL, indicate your
292
+ * decision by deleting the provisions above and replace them with the notice
293
+ * and other provisions required by the GPL or the LGPL. If you do not delete
294
+ * the provisions above, a recipient may use your version of this file under
295
+ * the terms of any one of the MPL, the GPL or the LGPL.
296
+ *
297
+ * ***** END LICENSE BLOCK ***** */
298
+
299
+ ace.define('pilot/keys', ['require', 'exports', 'module' , 'ace/lib/keys'], function(require, exports, module) {
300
+ console.warn("DEPRECATED: 'pilot/keys' is deprecated. Use 'ace/lib/keys' instead");
301
+ module.exports = require("ace/lib/keys");
302
+ });
303
+ /* vim:ts=4:sts=4:sw=4:
304
+ * ***** BEGIN LICENSE BLOCK *****
305
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
306
+ *
307
+ * The contents of this file are subject to the Mozilla Public License Version
308
+ * 1.1 (the "License"); you may not use this file except in compliance with
309
+ * the License. You may obtain a copy of the License at
310
+ * http://www.mozilla.org/MPL/
311
+ *
312
+ * Software distributed under the License is distributed on an "AS IS" basis,
313
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
314
+ * for the specific language governing rights and limitations under the
315
+ * License.
316
+ *
317
+ * The Original Code is Ajax.org Code Editor (ACE).
318
+ *
319
+ * The Initial Developer of the Original Code is
320
+ * Ajax.org B.V.
321
+ * Portions created by the Initial Developer are Copyright (C) 2010
322
+ * the Initial Developer. All Rights Reserved.
323
+ *
324
+ * Contributor(s):
325
+ * Fabian Jakobs <fabian AT ajax DOT org>
326
+ *
327
+ * Alternatively, the contents of this file may be used under the terms of
328
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
329
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
330
+ * in which case the provisions of the GPL or the LGPL are applicable instead
331
+ * of those above. If you wish to allow use of your version of this file only
332
+ * under the terms of either the GPL or the LGPL, and not to allow others to
333
+ * use your version of this file under the terms of the MPL, indicate your
334
+ * decision by deleting the provisions above and replace them with the notice
335
+ * and other provisions required by the GPL or the LGPL. If you do not delete
336
+ * the provisions above, a recipient may use your version of this file under
337
+ * the terms of any one of the MPL, the GPL or the LGPL.
338
+ *
339
+ * ***** END LICENSE BLOCK ***** */
340
+
341
+ ace.define('pilot/lang', ['require', 'exports', 'module' , 'ace/lib/lang'], function(require, exports, module) {
342
+ console.warn("DEPRECATED: 'pilot/lang' is deprecated. Use 'ace/lib/lang' instead");
343
+ module.exports = require("ace/lib/lang");
344
+ });
345
+ /* vim:ts=4:sts=4:sw=4:
346
+ * ***** BEGIN LICENSE BLOCK *****
347
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
348
+ *
349
+ * The contents of this file are subject to the Mozilla Public License Version
350
+ * 1.1 (the "License"); you may not use this file except in compliance with
351
+ * the License. You may obtain a copy of the License at
352
+ * http://www.mozilla.org/MPL/
353
+ *
354
+ * Software distributed under the License is distributed on an "AS IS" basis,
355
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
356
+ * for the specific language governing rights and limitations under the
357
+ * License.
358
+ *
359
+ * The Original Code is Ajax.org Code Editor (ACE).
360
+ *
361
+ * The Initial Developer of the Original Code is
362
+ * Ajax.org B.V.
363
+ * Portions created by the Initial Developer are Copyright (C) 2010
364
+ * the Initial Developer. All Rights Reserved.
365
+ *
366
+ * Contributor(s):
367
+ * Fabian Jakobs <fabian AT ajax DOT org>
368
+ *
369
+ * Alternatively, the contents of this file may be used under the terms of
370
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
371
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
372
+ * in which case the provisions of the GPL or the LGPL are applicable instead
373
+ * of those above. If you wish to allow use of your version of this file only
374
+ * under the terms of either the GPL or the LGPL, and not to allow others to
375
+ * use your version of this file under the terms of the MPL, indicate your
376
+ * decision by deleting the provisions above and replace them with the notice
377
+ * and other provisions required by the GPL or the LGPL. If you do not delete
378
+ * the provisions above, a recipient may use your version of this file under
379
+ * the terms of any one of the MPL, the GPL or the LGPL.
380
+ *
381
+ * ***** END LICENSE BLOCK ***** */
382
+
383
+ ace.define('pilot/oop', ['require', 'exports', 'module' , 'ace/lib/oop'], function(require, exports, module) {
384
+ console.warn("DEPRECATED: 'pilot/oop' is deprecated. Use 'ace/lib/oop' instead");
385
+ module.exports = require("ace/lib/oop");
386
+ });
387
+ /* vim:ts=4:sts=4:sw=4:
388
+ * ***** BEGIN LICENSE BLOCK *****
389
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
390
+ *
391
+ * The contents of this file are subject to the Mozilla Public License Version
392
+ * 1.1 (the "License"); you may not use this file except in compliance with
393
+ * the License. You may obtain a copy of the License at
394
+ * http://www.mozilla.org/MPL/
395
+ *
396
+ * Software distributed under the License is distributed on an "AS IS" basis,
397
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
398
+ * for the specific language governing rights and limitations under the
399
+ * License.
400
+ *
401
+ * The Original Code is Ajax.org Code Editor (ACE).
402
+ *
403
+ * The Initial Developer of the Original Code is
404
+ * Ajax.org B.V.
405
+ * Portions created by the Initial Developer are Copyright (C) 2010
406
+ * the Initial Developer. All Rights Reserved.
407
+ *
408
+ * Contributor(s):
409
+ * Fabian Jakobs <fabian AT ajax DOT org>
410
+ *
411
+ * Alternatively, the contents of this file may be used under the terms of
412
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
413
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
414
+ * in which case the provisions of the GPL or the LGPL are applicable instead
415
+ * of those above. If you wish to allow use of your version of this file only
416
+ * under the terms of either the GPL or the LGPL, and not to allow others to
417
+ * use your version of this file under the terms of the MPL, indicate your
418
+ * decision by deleting the provisions above and replace them with the notice
419
+ * and other provisions required by the GPL or the LGPL. If you do not delete
420
+ * the provisions above, a recipient may use your version of this file under
421
+ * the terms of any one of the MPL, the GPL or the LGPL.
422
+ *
423
+ * ***** END LICENSE BLOCK ***** */
424
+
425
+ ace.define('pilot/useragent', ['require', 'exports', 'module' , 'ace/lib/useragent'], function(require, exports, module) {
426
+ console.warn("DEPRECATED: 'pilot/useragent' is deprecated. Use 'ace/lib/useragent' instead");
427
+ module.exports = require("ace/lib/useragent");
428
+ });
429
+ /* vim:ts=4:sts=4:sw=4:
430
+ * ***** BEGIN LICENSE BLOCK *****
431
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
432
+ *
433
+ * The contents of this file are subject to the Mozilla Public License Version
434
+ * 1.1 (the "License"); you may not use this file except in compliance with
435
+ * the License. You may obtain a copy of the License at
436
+ * http://www.mozilla.org/MPL/
437
+ *
438
+ * Software distributed under the License is distributed on an "AS IS" basis,
439
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
440
+ * for the specific language governing rights and limitations under the
441
+ * License.
442
+ *
443
+ * The Original Code is Ajax.org Code Editor (ACE).
444
+ *
445
+ * The Initial Developer of the Original Code is
446
+ * Ajax.org B.V.
447
+ * Portions created by the Initial Developer are Copyright (C) 2010
448
+ * the Initial Developer. All Rights Reserved.
449
+ *
450
+ * Contributor(s):
451
+ * Fabian Jakobs <fabian AT ajax DOT org>
452
+ *
453
+ * Alternatively, the contents of this file may be used under the terms of
454
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
455
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
456
+ * in which case the provisions of the GPL or the LGPL are applicable instead
457
+ * of those above. If you wish to allow use of your version of this file only
458
+ * under the terms of either the GPL or the LGPL, and not to allow others to
459
+ * use your version of this file under the terms of the MPL, indicate your
460
+ * decision by deleting the provisions above and replace them with the notice
461
+ * and other provisions required by the GPL or the LGPL. If you do not delete
462
+ * the provisions above, a recipient may use your version of this file under
463
+ * the terms of any one of the MPL, the GPL or the LGPL.
464
+ *
465
+ * ***** END LICENSE BLOCK ***** */
466
+
467
+ ace.define('pilot/canon', ['require', 'exports', 'module' ], function(require, exports, module) {
468
+ console.warn("DEPRECATED: 'pilot/canon' is deprecated.");
469
+ //return require("ace/lib/dom");
470
+
471
+ exports.addCommand = function() {
472
+ console.warn("DEPRECATED: 'canon.addCommand()' is deprecated. Use 'editor.commands.addCommand(command)' instead.");
473
+ console.trace();
474
+ }
475
+
476
+ exports.removeCommand = function() {
477
+ console.warn("DEPRECATED: 'canon.removeCommand()' is deprecated. Use 'editor.commands.removeCommand(command)' instead.");
478
+ console.trace();
479
+ }
480
+ });
ace-0.2.0/src/ace-compat-uncompressed.js ADDED
@@ -0,0 +1,480 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* vim:ts=4:sts=4:sw=4:
2
+ * ***** BEGIN LICENSE BLOCK *****
3
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
+ *
5
+ * The contents of this file are subject to the Mozilla Public License Version
6
+ * 1.1 (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ * http://www.mozilla.org/MPL/
9
+ *
10
+ * Software distributed under the License is distributed on an "AS IS" basis,
11
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
+ * for the specific language governing rights and limitations under the
13
+ * License.
14
+ *
15
+ * The Original Code is Ajax.org Code Editor (ACE).
16
+ *
17
+ * The Initial Developer of the Original Code is
18
+ * Ajax.org B.V.
19
+ * Portions created by the Initial Developer are Copyright (C) 2010
20
+ * the Initial Developer. All Rights Reserved.
21
+ *
22
+ * Contributor(s):
23
+ * Fabian Jakobs <fabian AT ajax DOT org>
24
+ *
25
+ * Alternatively, the contents of this file may be used under the terms of
26
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
27
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
+ * in which case the provisions of the GPL or the LGPL are applicable instead
29
+ * of those above. If you wish to allow use of your version of this file only
30
+ * under the terms of either the GPL or the LGPL, and not to allow others to
31
+ * use your version of this file under the terms of the MPL, indicate your
32
+ * decision by deleting the provisions above and replace them with the notice
33
+ * and other provisions required by the GPL or the LGPL. If you do not delete
34
+ * the provisions above, a recipient may use your version of this file under
35
+ * the terms of any one of the MPL, the GPL or the LGPL.
36
+ *
37
+ * ***** END LICENSE BLOCK ***** */
38
+
39
+ define('pilot/index', ['require', 'exports', 'module' , 'pilot/browser_focus', 'pilot/dom', 'pilot/event', 'pilot/event_emitter', 'pilot/fixoldbrowsers', 'pilot/keys', 'pilot/lang', 'pilot/oop', 'pilot/useragent', 'pilot/canon'], function(require, exports, module) {
40
+ require("pilot/browser_focus");
41
+ require("pilot/dom");
42
+ require("pilot/event");
43
+ require("pilot/event_emitter");
44
+ require("pilot/fixoldbrowsers");
45
+ require("pilot/keys");
46
+ require("pilot/lang");
47
+ require("pilot/oop");
48
+ require("pilot/useragent");
49
+ require("pilot/canon");
50
+ });
51
+ /* vim:ts=4:sts=4:sw=4:
52
+ * ***** BEGIN LICENSE BLOCK *****
53
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
54
+ *
55
+ * The contents of this file are subject to the Mozilla Public License Version
56
+ * 1.1 (the "License"); you may not use this file except in compliance with
57
+ * the License. You may obtain a copy of the License at
58
+ * http://www.mozilla.org/MPL/
59
+ *
60
+ * Software distributed under the License is distributed on an "AS IS" basis,
61
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
62
+ * for the specific language governing rights and limitations under the
63
+ * License.
64
+ *
65
+ * The Original Code is Ajax.org Code Editor (ACE).
66
+ *
67
+ * The Initial Developer of the Original Code is
68
+ * Ajax.org B.V.
69
+ * Portions created by the Initial Developer are Copyright (C) 2010
70
+ * the Initial Developer. All Rights Reserved.
71
+ *
72
+ * Contributor(s):
73
+ * Fabian Jakobs <fabian AT ajax DOT org>
74
+ *
75
+ * Alternatively, the contents of this file may be used under the terms of
76
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
77
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
78
+ * in which case the provisions of the GPL or the LGPL are applicable instead
79
+ * of those above. If you wish to allow use of your version of this file only
80
+ * under the terms of either the GPL or the LGPL, and not to allow others to
81
+ * use your version of this file under the terms of the MPL, indicate your
82
+ * decision by deleting the provisions above and replace them with the notice
83
+ * and other provisions required by the GPL or the LGPL. If you do not delete
84
+ * the provisions above, a recipient may use your version of this file under
85
+ * the terms of any one of the MPL, the GPL or the LGPL.
86
+ *
87
+ * ***** END LICENSE BLOCK ***** */
88
+
89
+ define('pilot/browser_focus', ['require', 'exports', 'module' , 'ace/lib/browser_focus'], function(require, exports, module) {
90
+ console.warn("DEPRECATED: 'pilot/browser_focus' is deprecated. Use 'ace/lib/browser_focus' instead");
91
+ module.exports = require("ace/lib/browser_focus");
92
+ });
93
+ /* vim:ts=4:sts=4:sw=4:
94
+ * ***** BEGIN LICENSE BLOCK *****
95
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
96
+ *
97
+ * The contents of this file are subject to the Mozilla Public License Version
98
+ * 1.1 (the "License"); you may not use this file except in compliance with
99
+ * the License. You may obtain a copy of the License at
100
+ * http://www.mozilla.org/MPL/
101
+ *
102
+ * Software distributed under the License is distributed on an "AS IS" basis,
103
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
104
+ * for the specific language governing rights and limitations under the
105
+ * License.
106
+ *
107
+ * The Original Code is Ajax.org Code Editor (ACE).
108
+ *
109
+ * The Initial Developer of the Original Code is
110
+ * Ajax.org B.V.
111
+ * Portions created by the Initial Developer are Copyright (C) 2010
112
+ * the Initial Developer. All Rights Reserved.
113
+ *
114
+ * Contributor(s):
115
+ * Fabian Jakobs <fabian AT ajax DOT org>
116
+ *
117
+ * Alternatively, the contents of this file may be used under the terms of
118
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
119
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
120
+ * in which case the provisions of the GPL or the LGPL are applicable instead
121
+ * of those above. If you wish to allow use of your version of this file only
122
+ * under the terms of either the GPL or the LGPL, and not to allow others to
123
+ * use your version of this file under the terms of the MPL, indicate your
124
+ * decision by deleting the provisions above and replace them with the notice
125
+ * and other provisions required by the GPL or the LGPL. If you do not delete
126
+ * the provisions above, a recipient may use your version of this file under
127
+ * the terms of any one of the MPL, the GPL or the LGPL.
128
+ *
129
+ * ***** END LICENSE BLOCK ***** */
130
+
131
+ define('pilot/dom', ['require', 'exports', 'module' , 'ace/lib/dom'], function(require, exports, module) {
132
+ console.warn("DEPRECATED: 'pilot/dom' is deprecated. Use 'ace/lib/dom' instead");
133
+ module.exports = require("ace/lib/dom");
134
+ });
135
+ /* vim:ts=4:sts=4:sw=4:
136
+ * ***** BEGIN LICENSE BLOCK *****
137
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
138
+ *
139
+ * The contents of this file are subject to the Mozilla Public License Version
140
+ * 1.1 (the "License"); you may not use this file except in compliance with
141
+ * the License. You may obtain a copy of the License at
142
+ * http://www.mozilla.org/MPL/
143
+ *
144
+ * Software distributed under the License is distributed on an "AS IS" basis,
145
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
146
+ * for the specific language governing rights and limitations under the
147
+ * License.
148
+ *
149
+ * The Original Code is Ajax.org Code Editor (ACE).
150
+ *
151
+ * The Initial Developer of the Original Code is
152
+ * Ajax.org B.V.
153
+ * Portions created by the Initial Developer are Copyright (C) 2010
154
+ * the Initial Developer. All Rights Reserved.
155
+ *
156
+ * Contributor(s):
157
+ * Fabian Jakobs <fabian AT ajax DOT org>
158
+ *
159
+ * Alternatively, the contents of this file may be used under the terms of
160
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
161
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
162
+ * in which case the provisions of the GPL or the LGPL are applicable instead
163
+ * of those above. If you wish to allow use of your version of this file only
164
+ * under the terms of either the GPL or the LGPL, and not to allow others to
165
+ * use your version of this file under the terms of the MPL, indicate your
166
+ * decision by deleting the provisions above and replace them with the notice
167
+ * and other provisions required by the GPL or the LGPL. If you do not delete
168
+ * the provisions above, a recipient may use your version of this file under
169
+ * the terms of any one of the MPL, the GPL or the LGPL.
170
+ *
171
+ * ***** END LICENSE BLOCK ***** */
172
+
173
+ define('pilot/event', ['require', 'exports', 'module' , 'ace/lib/event'], function(require, exports, module) {
174
+ console.warn("DEPRECATED: 'pilot/event' is deprecated. Use 'ace/lib/event' instead");
175
+ module.exports = require("ace/lib/event");
176
+ });
177
+ /* vim:ts=4:sts=4:sw=4:
178
+ * ***** BEGIN LICENSE BLOCK *****
179
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
180
+ *
181
+ * The contents of this file are subject to the Mozilla Public License Version
182
+ * 1.1 (the "License"); you may not use this file except in compliance with
183
+ * the License. You may obtain a copy of the License at
184
+ * http://www.mozilla.org/MPL/
185
+ *
186
+ * Software distributed under the License is distributed on an "AS IS" basis,
187
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
188
+ * for the specific language governing rights and limitations under the
189
+ * License.
190
+ *
191
+ * The Original Code is Ajax.org Code Editor (ACE).
192
+ *
193
+ * The Initial Developer of the Original Code is
194
+ * Ajax.org B.V.
195
+ * Portions created by the Initial Developer are Copyright (C) 2010
196
+ * the Initial Developer. All Rights Reserved.
197
+ *
198
+ * Contributor(s):
199
+ * Fabian Jakobs <fabian AT ajax DOT org>
200
+ *
201
+ * Alternatively, the contents of this file may be used under the terms of
202
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
203
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
204
+ * in which case the provisions of the GPL or the LGPL are applicable instead
205
+ * of those above. If you wish to allow use of your version of this file only
206
+ * under the terms of either the GPL or the LGPL, and not to allow others to
207
+ * use your version of this file under the terms of the MPL, indicate your
208
+ * decision by deleting the provisions above and replace them with the notice
209
+ * and other provisions required by the GPL or the LGPL. If you do not delete
210
+ * the provisions above, a recipient may use your version of this file under
211
+ * the terms of any one of the MPL, the GPL or the LGPL.
212
+ *
213
+ * ***** END LICENSE BLOCK ***** */
214
+
215
+ define('pilot/event_emitter', ['require', 'exports', 'module' , 'ace/lib/event_emitter'], function(require, exports, module) {
216
+ console.warn("DEPRECATED: 'pilot/event_emitter' is deprecated. Use 'ace/lib/event_emitter' instead");
217
+ module.exports = require("ace/lib/event_emitter");
218
+ });
219
+ /* vim:ts=4:sts=4:sw=4:
220
+ * ***** BEGIN LICENSE BLOCK *****
221
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
222
+ *
223
+ * The contents of this file are subject to the Mozilla Public License Version
224
+ * 1.1 (the "License"); you may not use this file except in compliance with
225
+ * the License. You may obtain a copy of the License at
226
+ * http://www.mozilla.org/MPL/
227
+ *
228
+ * Software distributed under the License is distributed on an "AS IS" basis,
229
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
230
+ * for the specific language governing rights and limitations under the
231
+ * License.
232
+ *
233
+ * The Original Code is Ajax.org Code Editor (ACE).
234
+ *
235
+ * The Initial Developer of the Original Code is
236
+ * Ajax.org B.V.
237
+ * Portions created by the Initial Developer are Copyright (C) 2010
238
+ * the Initial Developer. All Rights Reserved.
239
+ *
240
+ * Contributor(s):
241
+ * Fabian Jakobs <fabian AT ajax DOT org>
242
+ *
243
+ * Alternatively, the contents of this file may be used under the terms of
244
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
245
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
246
+ * in which case the provisions of the GPL or the LGPL are applicable instead
247
+ * of those above. If you wish to allow use of your version of this file only
248
+ * under the terms of either the GPL or the LGPL, and not to allow others to
249
+ * use your version of this file under the terms of the MPL, indicate your
250
+ * decision by deleting the provisions above and replace them with the notice
251
+ * and other provisions required by the GPL or the LGPL. If you do not delete
252
+ * the provisions above, a recipient may use your version of this file under
253
+ * the terms of any one of the MPL, the GPL or the LGPL.
254
+ *
255
+ * ***** END LICENSE BLOCK ***** */
256
+
257
+ define('pilot/fixoldbrowsers', ['require', 'exports', 'module' , 'ace/lib/fixoldbrowsers'], function(require, exports, module) {
258
+ console.warn("DEPRECATED: 'pilot/fixoldbrowsers' is deprecated. Use 'ace/lib/fixoldbrowsers' instead");
259
+ module.exports = require("ace/lib/fixoldbrowsers");
260
+ });
261
+ /* vim:ts=4:sts=4:sw=4:
262
+ * ***** BEGIN LICENSE BLOCK *****
263
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
264
+ *
265
+ * The contents of this file are subject to the Mozilla Public License Version
266
+ * 1.1 (the "License"); you may not use this file except in compliance with
267
+ * the License. You may obtain a copy of the License at
268
+ * http://www.mozilla.org/MPL/
269
+ *
270
+ * Software distributed under the License is distributed on an "AS IS" basis,
271
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
272
+ * for the specific language governing rights and limitations under the
273
+ * License.
274
+ *
275
+ * The Original Code is Ajax.org Code Editor (ACE).
276
+ *
277
+ * The Initial Developer of the Original Code is
278
+ * Ajax.org B.V.
279
+ * Portions created by the Initial Developer are Copyright (C) 2010
280
+ * the Initial Developer. All Rights Reserved.
281
+ *
282
+ * Contributor(s):
283
+ * Fabian Jakobs <fabian AT ajax DOT org>
284
+ *
285
+ * Alternatively, the contents of this file may be used under the terms of
286
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
287
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
288
+ * in which case the provisions of the GPL or the LGPL are applicable instead
289
+ * of those above. If you wish to allow use of your version of this file only
290
+ * under the terms of either the GPL or the LGPL, and not to allow others to
291
+ * use your version of this file under the terms of the MPL, indicate your
292
+ * decision by deleting the provisions above and replace them with the notice
293
+ * and other provisions required by the GPL or the LGPL. If you do not delete
294
+ * the provisions above, a recipient may use your version of this file under
295
+ * the terms of any one of the MPL, the GPL or the LGPL.
296
+ *
297
+ * ***** END LICENSE BLOCK ***** */
298
+
299
+ define('pilot/keys', ['require', 'exports', 'module' , 'ace/lib/keys'], function(require, exports, module) {
300
+ console.warn("DEPRECATED: 'pilot/keys' is deprecated. Use 'ace/lib/keys' instead");
301
+ module.exports = require("ace/lib/keys");
302
+ });
303
+ /* vim:ts=4:sts=4:sw=4:
304
+ * ***** BEGIN LICENSE BLOCK *****
305
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
306
+ *
307
+ * The contents of this file are subject to the Mozilla Public License Version
308
+ * 1.1 (the "License"); you may not use this file except in compliance with
309
+ * the License. You may obtain a copy of the License at
310
+ * http://www.mozilla.org/MPL/
311
+ *
312
+ * Software distributed under the License is distributed on an "AS IS" basis,
313
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
314
+ * for the specific language governing rights and limitations under the
315
+ * License.
316
+ *
317
+ * The Original Code is Ajax.org Code Editor (ACE).
318
+ *
319
+ * The Initial Developer of the Original Code is
320
+ * Ajax.org B.V.
321
+ * Portions created by the Initial Developer are Copyright (C) 2010
322
+ * the Initial Developer. All Rights Reserved.
323
+ *
324
+ * Contributor(s):
325
+ * Fabian Jakobs <fabian AT ajax DOT org>
326
+ *
327
+ * Alternatively, the contents of this file may be used under the terms of
328
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
329
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
330
+ * in which case the provisions of the GPL or the LGPL are applicable instead
331
+ * of those above. If you wish to allow use of your version of this file only
332
+ * under the terms of either the GPL or the LGPL, and not to allow others to
333
+ * use your version of this file under the terms of the MPL, indicate your
334
+ * decision by deleting the provisions above and replace them with the notice
335
+ * and other provisions required by the GPL or the LGPL. If you do not delete
336
+ * the provisions above, a recipient may use your version of this file under
337
+ * the terms of any one of the MPL, the GPL or the LGPL.
338
+ *
339
+ * ***** END LICENSE BLOCK ***** */
340
+
341
+ define('pilot/lang', ['require', 'exports', 'module' , 'ace/lib/lang'], function(require, exports, module) {
342
+ console.warn("DEPRECATED: 'pilot/lang' is deprecated. Use 'ace/lib/lang' instead");
343
+ module.exports = require("ace/lib/lang");
344
+ });
345
+ /* vim:ts=4:sts=4:sw=4:
346
+ * ***** BEGIN LICENSE BLOCK *****
347
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
348
+ *
349
+ * The contents of this file are subject to the Mozilla Public License Version
350
+ * 1.1 (the "License"); you may not use this file except in compliance with
351
+ * the License. You may obtain a copy of the License at
352
+ * http://www.mozilla.org/MPL/
353
+ *
354
+ * Software distributed under the License is distributed on an "AS IS" basis,
355
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
356
+ * for the specific language governing rights and limitations under the
357
+ * License.
358
+ *
359
+ * The Original Code is Ajax.org Code Editor (ACE).
360
+ *
361
+ * The Initial Developer of the Original Code is
362
+ * Ajax.org B.V.
363
+ * Portions created by the Initial Developer are Copyright (C) 2010
364
+ * the Initial Developer. All Rights Reserved.
365
+ *
366
+ * Contributor(s):
367
+ * Fabian Jakobs <fabian AT ajax DOT org>
368
+ *
369
+ * Alternatively, the contents of this file may be used under the terms of
370
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
371
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
372
+ * in which case the provisions of the GPL or the LGPL are applicable instead
373
+ * of those above. If you wish to allow use of your version of this file only
374
+ * under the terms of either the GPL or the LGPL, and not to allow others to
375
+ * use your version of this file under the terms of the MPL, indicate your
376
+ * decision by deleting the provisions above and replace them with the notice
377
+ * and other provisions required by the GPL or the LGPL. If you do not delete
378
+ * the provisions above, a recipient may use your version of this file under
379
+ * the terms of any one of the MPL, the GPL or the LGPL.
380
+ *
381
+ * ***** END LICENSE BLOCK ***** */
382
+
383
+ define('pilot/oop', ['require', 'exports', 'module' , 'ace/lib/oop'], function(require, exports, module) {
384
+ console.warn("DEPRECATED: 'pilot/oop' is deprecated. Use 'ace/lib/oop' instead");
385
+ module.exports = require("ace/lib/oop");
386
+ });
387
+ /* vim:ts=4:sts=4:sw=4:
388
+ * ***** BEGIN LICENSE BLOCK *****
389
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
390
+ *
391
+ * The contents of this file are subject to the Mozilla Public License Version
392
+ * 1.1 (the "License"); you may not use this file except in compliance with
393
+ * the License. You may obtain a copy of the License at
394
+ * http://www.mozilla.org/MPL/
395
+ *
396
+ * Software distributed under the License is distributed on an "AS IS" basis,
397
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
398
+ * for the specific language governing rights and limitations under the
399
+ * License.
400
+ *
401
+ * The Original Code is Ajax.org Code Editor (ACE).
402
+ *
403
+ * The Initial Developer of the Original Code is
404
+ * Ajax.org B.V.
405
+ * Portions created by the Initial Developer are Copyright (C) 2010
406
+ * the Initial Developer. All Rights Reserved.
407
+ *
408
+ * Contributor(s):
409
+ * Fabian Jakobs <fabian AT ajax DOT org>
410
+ *
411
+ * Alternatively, the contents of this file may be used under the terms of
412
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
413
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
414
+ * in which case the provisions of the GPL or the LGPL are applicable instead
415
+ * of those above. If you wish to allow use of your version of this file only
416
+ * under the terms of either the GPL or the LGPL, and not to allow others to
417
+ * use your version of this file under the terms of the MPL, indicate your
418
+ * decision by deleting the provisions above and replace them with the notice
419
+ * and other provisions required by the GPL or the LGPL. If you do not delete
420
+ * the provisions above, a recipient may use your version of this file under
421
+ * the terms of any one of the MPL, the GPL or the LGPL.
422
+ *
423
+ * ***** END LICENSE BLOCK ***** */
424
+
425
+ define('pilot/useragent', ['require', 'exports', 'module' , 'ace/lib/useragent'], function(require, exports, module) {
426
+ console.warn("DEPRECATED: 'pilot/useragent' is deprecated. Use 'ace/lib/useragent' instead");
427
+ module.exports = require("ace/lib/useragent");
428
+ });
429
+ /* vim:ts=4:sts=4:sw=4:
430
+ * ***** BEGIN LICENSE BLOCK *****
431
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
432
+ *
433
+ * The contents of this file are subject to the Mozilla Public License Version
434
+ * 1.1 (the "License"); you may not use this file except in compliance with
435
+ * the License. You may obtain a copy of the License at
436
+ * http://www.mozilla.org/MPL/
437
+ *
438
+ * Software distributed under the License is distributed on an "AS IS" basis,
439
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
440
+ * for the specific language governing rights and limitations under the
441
+ * License.
442
+ *
443
+ * The Original Code is Ajax.org Code Editor (ACE).
444
+ *
445
+ * The Initial Developer of the Original Code is
446
+ * Ajax.org B.V.
447
+ * Portions created by the Initial Developer are Copyright (C) 2010
448
+ * the Initial Developer. All Rights Reserved.
449
+ *
450
+ * Contributor(s):
451
+ * Fabian Jakobs <fabian AT ajax DOT org>
452
+ *
453
+ * Alternatively, the contents of this file may be used under the terms of
454
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
455
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
456
+ * in which case the provisions of the GPL or the LGPL are applicable instead
457
+ * of those above. If you wish to allow use of your version of this file only
458
+ * under the terms of either the GPL or the LGPL, and not to allow others to
459
+ * use your version of this file under the terms of the MPL, indicate your
460
+ * decision by deleting the provisions above and replace them with the notice
461
+ * and other provisions required by the GPL or the LGPL. If you do not delete
462
+ * the provisions above, a recipient may use your version of this file under
463
+ * the terms of any one of the MPL, the GPL or the LGPL.
464
+ *
465
+ * ***** END LICENSE BLOCK ***** */
466
+
467
+ define('pilot/canon', ['require', 'exports', 'module' ], function(require, exports, module) {
468
+ console.warn("DEPRECATED: 'pilot/canon' is deprecated.");
469
+ //return require("ace/lib/dom");
470
+
471
+ exports.addCommand = function() {
472
+ console.warn("DEPRECATED: 'canon.addCommand()' is deprecated. Use 'editor.commands.addCommand(command)' instead.");
473
+ console.trace();
474
+ }
475
+
476
+ exports.removeCommand = function() {
477
+ console.warn("DEPRECATED: 'canon.removeCommand()' is deprecated. Use 'editor.commands.removeCommand(command)' instead.");
478
+ console.trace();
479
+ }
480
+ });
ace-0.2.0/src/ace-compat.js ADDED
@@ -0,0 +1 @@
 
1
+ define("pilot/index",["require","exports","module","pilot/browser_focus","pilot/dom","pilot/event","pilot/event_emitter","pilot/fixoldbrowsers","pilot/keys","pilot/lang","pilot/oop","pilot/useragent","pilot/canon"],function(a,b,c){a("pilot/browser_focus"),a("pilot/dom"),a("pilot/event"),a("pilot/event_emitter"),a("pilot/fixoldbrowsers"),a("pilot/keys"),a("pilot/lang"),a("pilot/oop"),a("pilot/useragent"),a("pilot/canon")}),define("pilot/browser_focus",["require","exports","module","ace/lib/browser_focus"],function(a,b,c){console.warn("DEPRECATED: 'pilot/browser_focus' is deprecated. Use 'ace/lib/browser_focus' instead"),c.exports=a("ace/lib/browser_focus")}),define("pilot/dom",["require","exports","module","ace/lib/dom"],function(a,b,c){console.warn("DEPRECATED: 'pilot/dom' is deprecated. Use 'ace/lib/dom' instead"),c.exports=a("ace/lib/dom")}),define("pilot/event",["require","exports","module","ace/lib/event"],function(a,b,c){console.warn("DEPRECATED: 'pilot/event' is deprecated. Use 'ace/lib/event' instead"),c.exports=a("ace/lib/event")}),define("pilot/event_emitter",["require","exports","module","ace/lib/event_emitter"],function(a,b,c){console.warn("DEPRECATED: 'pilot/event_emitter' is deprecated. Use 'ace/lib/event_emitter' instead"),c.exports=a("ace/lib/event_emitter")}),define("pilot/fixoldbrowsers",["require","exports","module","ace/lib/fixoldbrowsers"],function(a,b,c){console.warn("DEPRECATED: 'pilot/fixoldbrowsers' is deprecated. Use 'ace/lib/fixoldbrowsers' instead"),c.exports=a("ace/lib/fixoldbrowsers")}),define("pilot/keys",["require","exports","module","ace/lib/keys"],function(a,b,c){console.warn("DEPRECATED: 'pilot/keys' is deprecated. Use 'ace/lib/keys' instead"),c.exports=a("ace/lib/keys")}),define("pilot/lang",["require","exports","module","ace/lib/lang"],function(a,b,c){console.warn("DEPRECATED: 'pilot/lang' is deprecated. Use 'ace/lib/lang' instead"),c.exports=a("ace/lib/lang")}),define("pilot/oop",["require","exports","module","ace/lib/oop"],function(a,b,c){console.warn("DEPRECATED: 'pilot/oop' is deprecated. Use 'ace/lib/oop' instead"),c.exports=a("ace/lib/oop")}),define("pilot/useragent",["require","exports","module","ace/lib/useragent"],function(a,b,c){console.warn("DEPRECATED: 'pilot/useragent' is deprecated. Use 'ace/lib/useragent' instead"),c.exports=a("ace/lib/useragent")}),define("pilot/canon",["require","exports","module"],function(a,b,c){console.warn("DEPRECATED: 'pilot/canon' is deprecated."),b.addCommand=function(){console.warn("DEPRECATED: 'canon.addCommand()' is deprecated. Use 'editor.commands.addCommand(command)' instead."),console.trace()},b.removeCommand=function(){console.warn("DEPRECATED: 'canon.removeCommand()' is deprecated. Use 'editor.commands.removeCommand(command)' instead."),console.trace()}})
ace-0.2.0/src/ace-noconflict.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ (function(){function g(a){if(typeof requirejs!="undefined"){var e=b.define;b.define=function(a,b,c){return typeof c!="function"?e.apply(this,arguments):ace.define(a,b,function(a,d,e){return b[2]=="module"&&(e.packaged=!0),c.apply(this,arguments)})},b.define.packaged=!0;return}var f=function(a,b){return d("",a,b)};f.packaged=!0;var g=b;a&&(b[a]||(b[a]={}),g=b[a]),g.define&&(c.original=g.define),g.define=c,g.require&&(d.original=g.require),g.require=f}var a="ace",b=function(){return this}(),c=function(a,b,d){if(typeof a!="string"){c.original?c.original.apply(window,arguments):(console.error("dropping module because define wasn't a string."),console.trace());return}arguments.length==2&&(d=b),c.modules||(c.modules={}),c.modules[a]=d},d=function(a,b,c){if(Object.prototype.toString.call(b)==="[object Array]"){var e=[];for(var g=0,h=b.length;g<h;++g){var i=f(a,b[g]);if(!i&&d.original)return d.original.apply(window,arguments);e.push(i)}c&&c.apply(null,e)}else{if(typeof b=="string"){var j=f(a,b);return!j&&d.original?d.original.apply(window,arguments):(c&&c(),j)}if(d.original)return d.original.apply(window,arguments)}},e=function(a,b){if(b.indexOf("!")!==-1){var c=b.split("!");return e(a,c[0])+"!"+e(a,c[1])}if(b.charAt(0)=="."){var d=a.split("/").slice(0,-1).join("/");b=d+"/"+b;while(b.indexOf(".")!==-1&&f!=b){var f=b;b=b.replace(/\/\.\//,"/").replace(/[^\/]+\/\.\.\//,"")}}return b},f=function(a,b){b=e(a,b);var f=c.modules[b];if(!f)return null;if(typeof f=="function"){var g={},h={id:b,uri:"",exports:g,packaged:!0},i=function(a,c){return d(b,a,c)},j=f(i,g,h);return g=j||h.exports,c.modules[b]=g,g}return f};g(a)})(),ace.define("ace/ace",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/dom","ace/lib/event","ace/editor","ace/edit_session","ace/undomanager","ace/virtual_renderer","ace/worker/worker_client","ace/keyboard/hash_handler","ace/keyboard/state_handler","ace/lib/net","ace/placeholder","ace/config","ace/theme/textmate"],function(a,b,c){"use strict",a("./lib/fixoldbrowsers");var d=a("./lib/dom"),e=a("./lib/event"),f=a("./editor").Editor,g=a("./edit_session").EditSession,h=a("./undomanager").UndoManager,i=a("./virtual_renderer").VirtualRenderer;a("./worker/worker_client"),a("./keyboard/hash_handler"),a("./keyboard/state_handler"),a("./lib/net"),a("./placeholder"),a("./config").init(),b.edit=function(b){typeof b=="string"&&(b=document.getElementById(b));var c=new g(d.getInnerText(b));c.setUndoManager(new h),b.innerHTML="";var j=new f(new i(b,a("./theme/textmate")));j.setSession(c);var k={};return k.document=c,k.editor=j,j.resize(),e.addListener(window,"resize",function(){j.resize()}),b.env=k,j.env=k,j}}),ace.define("ace/lib/fixoldbrowsers",["require","exports","module","ace/lib/regexp","ace/lib/es5-shim"],function(a,b,c){"use strict",a("./regexp"),a("./es5-shim")}),ace.define("ace/lib/regexp",["require","exports","module"],function(a,b,c){function g(a){return(a.global?"g":"")+(a.ignoreCase?"i":"")+(a.multiline?"m":"")+(a.extended?"x":"")+(a.sticky?"y":"")}function h(a,b,c){if(Array.prototype.indexOf)return a.indexOf(b,c);for(var d=c||0;d<a.length;d++)if(a[d]===b)return d;return-1}"use strict";var d={exec:RegExp.prototype.exec,test:RegExp.prototype.test,match:String.prototype.match,replace:String.prototype.replace,split:String.prototype.split},e=d.exec.call(/()??/,"")[1]===undefined,f=function(){var a=/^/g;return d.test.call(a,""),!a.lastIndex}();RegExp.prototype.exec=function(a){var b=d.exec.apply(this,arguments),c,i;if(typeof a=="string"&&b){!e&&b.length>1&&h(b,"")>-1&&(i=RegExp(this.source,d.replace.call(g(this),"g","")),d.replace.call(a.slice(b.index),i,function(){for(var a=1;a<arguments.length-2;a++)arguments[a]===undefined&&(b[a]=undefined)}));if(this._xregexp&&this._xregexp.captureNames)for(var j=1;j<b.length;j++)c=this._xregexp.captureNames[j-1],c&&(b[c]=b[j]);!f&&this.global&&!b[0].length&&this.lastIndex>b.index&&this.lastIndex--}return b},f||(RegExp.prototype.test=function(a){var b=d.exec.call(this,a);return b&&this.global&&!b[0].length&&this.lastIndex>b.index&&this.lastIndex--,!!b})}),ace.define("ace/lib/es5-shim",["require","exports","module"],function(a,b,c){function p(a){try{return Object.defineProperty(a,"sentinel",{}),"sentinel"in a}catch(b){}}Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=g.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,h=c.apply(f,d.concat(g.call(arguments)));return h!==null&&Object(h)===h?h:f}return c.apply(b,d.concat(g.call(arguments)))};return e});var d=Function.prototype.call,e=Array.prototype,f=Object.prototype,g=e.slice,h=d.bind(f.toString),i=d.bind(f.hasOwnProperty),j,k,l,m,n;if(n=i(f,"__defineGetter__"))j=d.bind(f.__defineGetter__),k=d.bind(f.__defineSetter__),l=d.bind(f.__lookupGetter__),m=d.bind(f.__lookupSetter__);Array.isArray||(Array.isArray=function(b){return h(b)=="[object Array]"}),Array.prototype.forEach||(Array.prototype.forEach=function(b){var c=G(this),d=arguments[1],e=0,f=c.length>>>0;if(h(b)!="[object Function]")throw new TypeError;while(e<f)e in c&&b.call(d,c[e],e,c),e++}),Array.prototype.map||(Array.prototype.map=function(b){var c=G(this),d=c.length>>>0,e=Array(d),f=arguments[1];if(h(b)!="[object Function]")throw new TypeError;for(var g=0;g<d;g++)g in c&&(e[g]=b.call(f,c[g],g,c));return e}),Array.prototype.filter||(Array.prototype.filter=function(b){var c=G(this),d=c.length>>>0,e=[],f=arguments[1];if(h(b)!="[object Function]")throw new TypeError;for(var g=0;g<d;g++)g in c&&b.call(f,c[g],g,c)&&e.push(c[g]);return e}),Array.prototype.every||(Array.prototype.every=function(b){var c=G(this),d=c.length>>>0,e=arguments[1];if(h(b)!="[object Function]")throw new TypeError;for(var f=0;f<d;f++)if(f in c&&!b.call(e,c[f],f,c))return!1;return!0}),Array.prototype.some||(Array.prototype.some=function(b){var c=G(this),d=c.length>>>0,e=arguments[1];if(h(b)!="[object Function]")throw new TypeError;for(var f=0;f<d;f++)if(f in c&&b.call(e,c[f],f,c))return!0;return!1}),Array.prototype.reduce||(Array.prototype.reduce=function(b){var c=G(this),d=c.length>>>0;if(h(b)!="[object Function]")throw new TypeError;if(!d&&arguments.length==1)throw new TypeError;var e=0,f;if(arguments.length>=2)f=arguments[1];else do{if(e in c){f=c[e++];break}if(++e>=d)throw new TypeError}while(!0);for(;e<d;e++)e in c&&(f=b.call(void 0,f,c[e],e,c));return f}),Array.prototype.reduceRight||(Array.prototype.reduceRight=function(b){var c=G(this),d=c.length>>>0;if(h(b)!="[object Function]")throw new TypeError;if(!d&&arguments.length==1)throw new TypeError;var e,f=d-1;if(arguments.length>=2)e=arguments[1];else do{if(f in c){e=c[f--];break}if(--f<0)throw new TypeError}while(!0);do f in this&&(e=b.call(void 0,e,c[f],f,c));while(f--);return e}),Array.prototype.indexOf||(Array.prototype.indexOf=function(b){var c=G(this),d=c.length>>>0;if(!d)return-1;var e=0;arguments.length>1&&(e=E(arguments[1])),e=e>=0?e:Math.max(0,d+e);for(;e<d;e++)if(e in c&&c[e]===b)return e;return-1}),Array.prototype.lastIndexOf||(Array.prototype.lastIndexOf=function(b){var c=G(this),d=c.length>>>0;if(!d)return-1;var e=d-1;arguments.length>1&&(e=Math.min(e,E(arguments[1]))),e=e>=0?e:d-Math.abs(e);for(;e>=0;e--)if(e in c&&b===c[e])return e;return-1}),Object.getPrototypeOf||(Object.getPrototypeOf=function(b){return b.__proto__||(b.constructor?b.constructor.prototype:f)});if(!Object.getOwnPropertyDescriptor){var o="Object.getOwnPropertyDescriptor called on a non-object: ";Object.getOwnPropertyDescriptor=function(b,c){if(typeof b!="object"&&typeof b!="function"||b===null)throw new TypeError(o+b);if(!i(b,c))return;var d,e,g;d={enumerable:!0,configurable:!0};if(n){var h=b.__proto__;b.__proto__=f;var e=l(b,c),g=m(b,c);b.__proto__=h;if(e||g)return e&&(d.get=e),g&&(d.set=g),d}return d.value=b[c],d}}Object.getOwnPropertyNames||(Object.getOwnPropertyNames=function(b){return Object.keys(b)}),Object.create||(Object.create=function(b,c){var d;if(b===null)d={__proto__:null};else{if(typeof b!="object")throw new TypeError("typeof prototype["+typeof b+"] != 'object'");var e=function(){};e.prototype=b,d=new e,d.__proto__=b}return c!==void 0&&Object.defineProperties(d,c),d});if(Object.defineProperty){var q=p({}),r=typeof document=="undefined"||p(document.createElement("div"));if(!q||!r)var s=Object.defineProperty}if(!Object.defineProperty||s){var t="Property description must be an object: ",u="Object.defineProperty called on non-object: ",v="getters & setters can not be defined on this javascript engine";Object.defineProperty=function(b,c,d){if(typeof b!="object"&&typeof b!="function"||b===null)throw new TypeError(u+b);if(typeof d!="object"&&typeof d!="function"||d===null)throw new TypeError(t+d);if(s)try{return s.call(Object,b,c,d)}catch(e){}if(i(d,"value"))if(n&&(l(b,c)||m(b,c))){var g=b.__proto__;b.__proto__=f,delete b[c],b[c]=d.value,b.__proto__=g}else b[c]=d.value;else{if(!n)throw new TypeError(v);i(d,"get")&&j(b,c,d.get),i(d,"set")&&k(b,c,d.set)}return b}}Object.defineProperties||(Object.defineProperties=function(b,c){for(var d in c)i(c,d)&&Object.defineProperty(b,d,c[d]);return b}),Object.seal||(Object.seal=function(b){return b}),Object.freeze||(Object.freeze=function(b){return b});try{Object.freeze(function(){})}catch(w){Object.freeze=function(b){return function(c){return typeof c=="function"?c:b(c)}}(Object.freeze)}Object.preventExtensions||(Object.preventExtensions=function(b){return b}),Object.isSealed||(Object.isSealed=function(b){return!1}),Object.isFrozen||(Object.isFrozen=function(b){return!1}),Object.isExtensible||(Object.isExtensible=function(b){if(Object(b)===b)throw new TypeError;var c="";while(i(b,c))c+="?";b[c]=!0;var d=i(b,c);return delete b[c],d});if(!Object.keys){var x=!0,y=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],z=y.length;for(var A in{toString:null})x=!1;Object.keys=function H(a){if(typeof a!="object"&&typeof a!="function"||a===null)throw new TypeError("Object.keys called on a non-object");var H=[];for(var b in a)i(a,b)&&H.push(b);if(x)for(var c=0,d=z;c<d;c++){var e=y[c];i(a,e)&&H.push(e)}return H}}if(!Date.prototype.toISOString||(new Date(-621987552e5)).toISOString().indexOf("-000001")===-1)Date.prototype.toISOString=function(){var b,c,d,e;if(!isFinite(this))throw new RangeError;b=[this.getUTCMonth()+1,this.getUTCDate(),this.getUTCHours(),this.getUTCMinutes(),this.getUTCSeconds()],e=this.getUTCFullYear(),e=(e<0?"-":e>9999?"+":"")+("00000"+Math.abs(e)).slice(0<=e&&e<=9999?-4:-6),c=b.length;while(c--)d=b[c],d<10&&(b[c]="0"+d);return e+"-"+b.slice(0,2).join("-")+"T"+b.slice(2).join(":")+"."+("000"+this.getUTCMilliseconds()).slice(-3)+"Z"};Date.now||(Date.now=function(){return(new Date).getTime()}),Date.prototype.toJSON||(Date.prototype.toJSON=function(b){if(typeof this.toISOString!="function")throw new TypeError;return this.toISOString()}),Date.parse("+275760-09-13T00:00:00.000Z")!==864e13&&(Date=function(a){var b=function e(b,c,d,f,g,h,i){var j=arguments.length;if(this instanceof a){var k=j==1&&String(b)===b?new a(e.parse(b)):j>=7?new a(b,c,d,f,g,h,i):j>=6?new a(b,c,d,f,g,h):j>=5?new a(b,c,d,f,g):j>=4?new a(b,c,d,f):j>=3?new a(b,c,d):j>=2?new a(b,c):j>=1?new a(b):new a;return k.constructor=e,k}return a.apply(this,arguments)},c=new RegExp("^(\\d{4}|[+-]\\d{6})(?:-(\\d{2})(?:-(\\d{2})(?:T(\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{3}))?)?(?:Z|(?:([-+])(\\d{2}):(\\d{2})))?)?)?)?$");for(var d in a)b[d]=a[d];return b.now=a.now,b.UTC=a.UTC,b.prototype=a.prototype,b.prototype.constructor=b,b.parse=function(d){var e=c.exec(d);if(e){e.shift();for(var f=1;f<7;f++)e[f]=+(e[f]||(f<3?1:0)),f==1&&e[f]--;var g=+e.pop(),h=+e.pop(),i=e.pop(),j=0;if(i){if(h>23||g>59)return NaN;j=(h*60+g)*6e4*(i=="+"?-1:1)}var k=+e[0];return 0<=k&&k<=99?(e[0]=k+400,a.UTC.apply(this,e)+j-126227808e5):a.UTC.apply(this,e)+j}return a.parse.apply(this,arguments)},b}(Date));var B=" \n\f\r   ᠎              \u2028\u2029";if(!String.prototype.trim||B.trim()){B="["+B+"]";var C=new RegExp("^"+B+B+"*"),D=new RegExp(B+B+"*$");String.prototype.trim=function(){return String(this).replace(C,"").replace(D,"")}}var E=function(a){return a=+a,a!==a?a=0:a!==0&&a!==1/0&&a!==-Infinity&&(a=(a>0||-1)*Math.floor(Math.abs(a))),a},F="a"[0]!="a",G=function(a){if(a==null)throw new TypeError;return F&&typeof a=="string"&&a?a.split(""):Object(a)}}),ace.define("ace/lib/dom",["require","exports","module"],function(a,b,c){"use strict";var d="http://www.w3.org/1999/xhtml";b.createElement=function(a,b){return document.createElementNS?document.createElementNS(b||d,a):document.createElement(a)},b.setText=function(a,b){a.innerText!==undefined&&(a.innerText=b),a.textContent!==undefined&&(a.textContent=b)},b.hasCssClass=function(a,b){var c=a.className.split(/\s+/g);return c.indexOf(b)!==-1},b.addCssClass=function(a,c){b.hasCssClass(a,c)||(a.className+=" "+c)},b.removeCssClass=function(a,b){var c=a.className.split(/\s+/g);for(;;){var d=c.indexOf(b);if(d==-1)break;c.splice(d,1)}a.className=c.join(" ")},b.toggleCssClass=function(a,b){var c=a.className.split(/\s+/g),d=!0;for(;;){var e=c.indexOf(b);if(e==-1)break;d=!1,c.splice(e,1)}return d&&c.push(b),a.className=c.join(" "),d},b.setCssClass=function(a,c,d){d?b.addCssClass(a,c):b.removeCssClass(a,c)},b.hasCssString=function(a,b){var c=0,d;b=b||document;if(b.createStyleSheet&&(d=b.styleSheets)){while(c<d.length)if(d[c++].owningElement.id===a)return!0}else if(d=b.getElementsByTagName("style"))while(c<d.length)if(d[c++].id===a)return!0;return!1},b.importCssString=function(c,e,f){f=f||document;if(e&&b.hasCssString(e,f))return null;var g;if(f.createStyleSheet)g=f.createStyleSheet(),g.cssText=c,e&&(g.owningElement.id=e);else{g=f.createElementNS?f.createElementNS(d,"style"):f.createElement("style"),g.appendChild(f.createTextNode(c)),e&&(g.id=e);var h=f.getElementsByTagName("head")[0]||f.documentElement;h.appendChild(g)}},b.importCssStylsheet=function(a,c){if(c.createStyleSheet)c.createStyleSheet(a);else{var d=b.createElement("link");d.rel="stylesheet",d.href=a;var e=c.getElementsByTagName("head")[0]||c.documentElement;e.appendChild(d)}},b.getInnerWidth=function(a){return parseInt(b.computedStyle(a,"paddingLeft"),10)+parseInt(b.computedStyle(a,"paddingRight"),10)+a.clientWidth},b.getInnerHeight=function(a){return parseInt(b.computedStyle(a,"paddingTop"),10)+parseInt(b.computedStyle(a,"paddingBottom"),10)+a.clientHeight},window.pageYOffset!==undefined?(b.getPageScrollTop=function(){return window.pageYOffset},b.getPageScrollLeft=function(){return window.pageXOffset}):(b.getPageScrollTop=function(){return document.body.scrollTop},b.getPageScrollLeft=function(){return document.body.scrollLeft}),window.getComputedStyle?b.computedStyle=function(a,b){return b?(window.getComputedStyle(a,"")||{})[b]||"":window.getComputedStyle(a,"")||{}}:b.computedStyle=function(a,b){return b?a.currentStyle[b]:a.currentStyle},b.scrollbarWidth=function(a){var c=b.createElement("p");c.style.width="100%",c.style.minWidth="0px",c.style.height="200px";var d=b.createElement("div"),e=d.style;e.position="absolute",e.left="-10000px",e.overflow="hidden",e.width="200px",e.minWidth="0px",e.height="150px",d.appendChild(c);var f=a.body||a.documentElement;f.appendChild(d);var g=c.offsetWidth;e.overflow="scroll";var h=c.offsetWidth;return g==h&&(h=d.clientWidth),f.removeChild(d),g-h},b.setInnerHtml=function(a,b){var c=a.cloneNode(!1);return c.innerHTML=b,a.parentNode.replaceChild(c,a),c},b.setInnerText=function(a,b){var c=a.ownerDocument;c.body&&"textContent"in c.body?a.textContent=b:a.innerText=b},b.getInnerText=function(a){var b=a.ownerDocument;return b.body&&"textContent"in b.body?a.textContent:a.innerText||a.textContent||""},b.getParentWindow=function(a){return a.defaultView||a.parentWindow}}),ace.define("ace/lib/event",["require","exports","module","ace/lib/keys","ace/lib/useragent","ace/lib/dom"],function(a,b,c){function g(a,b,c){var f=0;e.isOpera&&e.isMac?f=0|(b.metaKey?1:0)|(b.altKey?2:0)|(b.shiftKey?4:0)|(b.ctrlKey?8:0):f=0|(b.ctrlKey?1:0)|(b.altKey?2:0)|(b.shiftKey?4:0)|(b.metaKey?8:0);if(c in d.MODIFIER_KEYS){switch(d.MODIFIER_KEYS[c]){case"Alt":f=2;break;case"Shift":f=4;break;case"Ctrl":f=1;break;default:f=8}c=0}return f&8&&(c==91||c==93)&&(c=0),!!f||c in d.FUNCTION_KEYS||c in d.PRINTABLE_KEYS?a(b,f,c):!1}"use strict";var d=a("./keys"),e=a("./useragent"),f=a("./dom");b.addListener=function(a,b,c){if(a.addEventListener)return a.addEventListener(b,c,!1);if(a.attachEvent){var d=function(){c(window.event)};c._wrapper=d,a.attachEvent("on"+b,d)}},b.removeListener=function(a,b,c){if(a.removeEventListener)return a.removeEventListener(b,c,!1);a.detachEvent&&a.detachEvent("on"+b,c._wrapper||c)},b.stopEvent=function(a){return b.stopPropagation(a),b.preventDefault(a),!1},b.stopPropagation=function(a){a.stopPropagation?a.stopPropagation():a.cancelBubble=!0},b.preventDefault=function(a){a.preventDefault?a.preventDefault():a.returnValue=!1},b.getDocumentX=function(a){return a.clientX?a.clientX+f.getPageScrollLeft():a.pageX},b.getDocumentY=function(a){return a.clientY?a.clientY+f.getPageScrollTop():a.pageY},b.getButton=function(a){return a.type=="dblclick"?0:a.type=="contextmenu"?2:a.preventDefault?a.button:{1:0,2:2,4:1}[a.button]},document.documentElement.setCapture?b.capture=function(a,c,d){function e(a){return c(a),b.stopPropagation(a)}function g(e){c(e),f||(f=!0,d(e)),b.removeListener(a,"mousemove",c),b.removeListener(a,"mouseup",g),b.removeListener(a,"losecapture",g),a.releaseCapture()}var f=!1;b.addListener(a,"mousemove",c),b.addListener(a,"mouseup",g),b.addListener(a,"losecapture",g),a.setCapture()}:b.capture=function(a,b,c){function d(a){b(a),a.stopPropagation()}function e(a){b&&b(a),c&&c(a),document.removeEventListener("mousemove",d,!0),document.removeEventListener("mouseup",e,!0),a.stopPropagation()}document.addEventListener("mousemove",d,!0),document.addEventListener("mouseup",e,!0)},b.addMouseWheelListener=function(a,c){var d=8,e=function(a){a.wheelDelta!==undefined?a.wheelDeltaX!==undefined?(a.wheelX=-a.wheelDeltaX/d,a.wheelY=-a.wheelDeltaY/d):(a.wheelX=0,a.wheelY=-a.wheelDelta/d):a.axis&&a.axis==a.HORIZONTAL_AXIS?(a.wheelX=(a.detail||0)*5,a.wheelY=0):(a.wheelX=0,a.wheelY=(a.detail||0)*5),c(a)};b.addListener(a,"DOMMouseScroll",e),b.addListener(a,"mousewheel",e)},b.addMultiMouseDownListener=function(a,c,d,f,g){var h=0,i,j,k=function(a){h+=1,h==1&&(i=a.clientX,j=a.clientY,setTimeout(function(){h=0},f||600));var e=b.getButton(a)==c;if(!e||Math.abs(a.clientX-i)>5||Math.abs(a.clientY-j)>5)h=0;h==d&&(h=0,g(a));if(e)return b.preventDefault(a)};b.addListener(a,"mousedown",k),e.isOldIE&&b.addListener(a,"dblclick",k)},b.addCommandKeyListener=function(a,c){var d=b.addListener;if(e.isOldGecko||e.isOpera){var f=null;d(a,"keydown",function(a){f=a.keyCode}),d(a,"keypress",function(a){return g(c,a,f)})}else{var h=null;d(a,"keydown",function(a){return h=a.keyIdentifier||a.keyCode,g(c,a,a.keyCode)})}};if(window.postMessage){var h=1;b.nextTick=function(a,c){c=c||window;var d="zero-timeout-message-"+h;b.addListener(c,"message",function e(f){f.data==d&&(b.stopPropagation(f),b.removeListener(c,"message",e),a())}),c.postMessage(d,"*")}}else b.nextTick=function(a,b){b=b||window,window.setTimeout(a,0)}}),ace.define("ace/lib/keys",["require","exports","module","ace/lib/oop"],function(a,b,c){"use strict";var d=a("./oop"),e=function(){var a={MODIFIER_KEYS:{16:"Shift",17:"Ctrl",18:"Alt",224:"Meta"},KEY_MODS:{ctrl:1,alt:2,option:2,shift:4,meta:8,command:8},FUNCTION_KEYS:{8:"Backspace",9:"Tab",13:"Return",19:"Pause",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"Print",45:"Insert",46:"Delete",96:"Numpad0",97:"Numpad1",98:"Numpad2",99:"Numpad3",100:"Numpad4",101:"Numpad5",102:"Numpad6",103:"Numpad7",104:"Numpad8",105:"Numpad9",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"Numlock",145:"Scrolllock"},PRINTABLE_KEYS:{32:" ",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",61:"=",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",107:"+",109:"-",110:".",188:",",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:'"'}};for(var b in a.FUNCTION_KEYS){var c=a.FUNCTION_KEYS[b].toUpperCase();a[c]=parseInt(b,10)}return d.mixin(a,a.MODIFIER_KEYS),d.mixin(a,a.PRINTABLE_KEYS),d.mixin(a,a.FUNCTION_KEYS),a}();d.mixin(b,e),b.keyCodeToString=function(a){return(e[a]||String.fromCharCode(a)).toLowerCase()}}),ace.define("ace/lib/oop",["require","exports","module"],function(a,b,c){"use strict",b.inherits=function(){var a=function(){};return function(b,c){a.prototype=c.prototype,b.super_=c.prototype,b.prototype=new a,b.prototype.constructor=b}}(),b.mixin=function(a,b){for(var c in b)a[c]=b[c]},b.implement=function(a,c){b.mixin(a,c)}}),ace.define("ace/lib/useragent",["require","exports","module"],function(a,b,c){"use strict";var d=(navigator.platform.match(/mac|win|linux/i)||["other"])[0].toLowerCase(),e=navigator.userAgent;b.isWin=d=="win",b.isMac=d=="mac",b.isLinux=d=="linux",b.isIE=navigator.appName=="Microsoft Internet Explorer"&&parseFloat(navigator.userAgent.match(/MSIE ([0-9]+[\.0-9]+)/)[1]),b.isOldIE=b.isIE&&b.isIE<9,b.isGecko=b.isMozilla=window.controllers&&window.navigator.product==="Gecko",b.isOldGecko=b.isGecko&&parseInt((navigator.userAgent.match(/rv\:(\d+)/)||[])[1],10)<4,b.isOpera=window.opera&&Object.prototype.toString.call(window.opera)=="[object Opera]",b.isWebKit=parseFloat(e.split("WebKit/")[1])||undefined,b.isChrome=parseFloat(e.split(" Chrome/")[1])||undefined,b.isAIR=e.indexOf("AdobeAIR")>=0,b.isIPad=e.indexOf("iPad")>=0,b.isTouchPad=e.indexOf("TouchPad")>=0,b.OS={LINUX:"LINUX",MAC:"MAC",WINDOWS:"WINDOWS"},b.getOS=function(){return b.isMac?b.OS.MAC:b.isLinux?b.OS.LINUX:b.OS.WINDOWS}}),ace.define("ace/editor",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop","ace/lib/lang","ace/lib/useragent","ace/keyboard/textinput","ace/mouse/mouse_handler","ace/mouse/fold_handler","ace/keyboard/keybinding","ace/edit_session","ace/search","ace/range","ace/lib/event_emitter","ace/commands/command_manager","ace/commands/default_commands"],function(a,b,c){"use strict",a("./lib/fixoldbrowsers");var d=a("./lib/oop"),e=a("./lib/lang"),f=a("./lib/useragent"),g=a("./keyboard/textinput").TextInput,h=a("./mouse/mouse_handler").MouseHandler,i=a("./mouse/fold_handler").FoldHandler,j=a("./keyboard/keybinding").KeyBinding,k=a("./edit_session").EditSession,l=a("./search").Search,m=a("./range").Range,n=a("./lib/event_emitter").EventEmitter,o=a("./commands/command_manager").CommandManager,p=a("./commands/default_commands").commands,q=function(a,b){var c=a.getContainerElement();this.container=c,this.renderer=a,this.textInput=new g(a.getTextAreaContainer(),this),this.keyBinding=new j(this),f.isIPad||(this.$mouseHandler=new h(this),new i(this)),this.$blockScrolling=0,this.$search=(new l).set({wrap:!0}),this.commands=new o(f.isMac?"mac":"win",p),this.setSession(b||new k(""))};(function(){d.implement(this,n),this.setKeyboardHandler=function(a){this.keyBinding.setKeyboardHandler(a)},this.getKeyboardHandler=function(){return this.keyBinding.getKeyboardHandler()},this.setSession=function(a){if(this.session==a)return;if(this.session){var b=this.session;this.session.removeEventListener("change",this.$onDocumentChange),this.session.removeEventListener("changeMode",this.$onChangeMode),this.session.removeEventListener("tokenizerUpdate",this.$onTokenizerUpdate),this.session.removeEventListener("changeTabSize",this.$onChangeTabSize),this.session.removeEventListener("changeWrapLimit",this.$onChangeWrapLimit),this.session.removeEventListener("changeWrapMode",this.$onChangeWrapMode),this.session.removeEventListener("onChangeFold",this.$onChangeFold),this.session.removeEventListener("changeFrontMarker",this.$onChangeFrontMarker),this.session.removeEventListener("changeBackMarker",this.$onChangeBackMarker),this.session.removeEventListener("changeBreakpoint",this.$onChangeBreakpoint),this.session.removeEventListener("changeAnnotation",this.$onChangeAnnotation),this.session.removeEventListener("changeOverwrite",this.$onCursorChange),this.session.removeEventListener("changeScrollTop",this.$onScrollTopChange),this.session.removeEventListener("changeLeftTop",this.$onScrollLeftChange);var c=this.session.getSelection();c.removeEventListener("changeCursor",this.$onCursorChange),c.removeEventListener("changeSelection",this.$onSelectionChange)}this.session=a,this.$onDocumentChange=this.onDocumentChange.bind(this),a.addEventListener("change",this.$onDocumentChange),this.renderer.setSession(a),this.$onChangeMode=this.onChangeMode.bind(this),a.addEventListener("changeMode",this.$onChangeMode),this.$onTokenizerUpdate=this.onTokenizerUpdate.bind(this),a.addEventListener("tokenizerUpdate",this.$onTokenizerUpdate),this.$onChangeTabSize=this.renderer.updateText.bind(this.renderer),a.addEventListener("changeTabSize",this.$onChangeTabSize),this.$onChangeWrapLimit=this.onChangeWrapLimit.bind(this),a.addEventListener("changeWrapLimit",this.$onChangeWrapLimit),this.$onChangeWrapMode=this.onChangeWrapMode.bind(this),a.addEventListener("changeWrapMode",this.$onChangeWrapMode),this.$onChangeFold=this.onChangeFold.bind(this),a.addEventListener("changeFold",this.$onChangeFold),this.$onChangeFrontMarker=this.onChangeFrontMarker.bind(this),this.session.addEventListener("changeFrontMarker",this.$onChangeFrontMarker),this.$onChangeBackMarker=this.onChangeBackMarker.bind(this),this.session.addEventListener("changeBackMarker",this.$onChangeBackMarker),this.$onChangeBreakpoint=this.onChangeBreakpoint.bind(this),this.session.addEventListener("changeBreakpoint",this.$onChangeBreakpoint),this.$onChangeAnnotation=this.onChangeAnnotation.bind(this),this.session.addEventListener("changeAnnotation",this.$onChangeAnnotation),this.$onCursorChange=this.onCursorChange.bind(this),this.session.addEventListener("changeOverwrite",this.$onCursorChange),this.$onScrollTopChange=this.onScrollTopChange.bind(this),this.session.addEventListener("changeScrollTop",this.$onScrollTopChange),this.$onScrollLeftChange=this.onScrollLeftChange.bind(this),this.session.addEventListener("changeScrollLeft",this.$onScrollLeftChange),this.selection=a.getSelection(),this.selection.addEventListener("changeCursor",this.$onCursorChange),this.$onSelectionChange=this.onSelectionChange.bind(this),this.selection.addEventListener("changeSelection",this.$onSelectionChange),this.onChangeMode(),this.$blockScrolling+=1,this.onCursorChange(),this.$blockScrolling-=1,this.onScrollTopChange(),this.onScrollLeftChange(),this.onSelectionChange(),this.onChangeFrontMarker(),this.onChangeBackMarker(),this.onChangeBreakpoint(),this.onChangeAnnotation(),this.session.getUseWrapMode()&&this.renderer.adjustWrapLimit(),this.renderer.updateFull(),this._emit("changeSession",{session:a,oldSession:b})},this.getSession=function(){return this.session},this.getSelection=function(){return this.selection},this.resize=function(){this.renderer.onResize()},this.setTheme=function(a){this.renderer.setTheme(a)},this.getTheme=function(){return this.renderer.getTheme()},this.setStyle=function(a){this.renderer.setStyle(a)},this.unsetStyle=function(a){this.renderer.unsetStyle(a)},this.setFontSize=function(a){this.container.style.fontSize=a,this.renderer.updateFontSize()},this.$highlightBrackets=function(){this.session.$bracketHighlight&&(this.session.removeMarker(this.session.$bracketHighlight),this.session.$bracketHighlight=null);if(this.$highlightPending)return;var a=this;this.$highlightPending=!0,setTimeout(function(){a.$highlightPending=!1;var b=a.session.findMatchingBracket(a.getCursorPosition());if(b){var c=new m(b.row,b.column,b.row,b.column+1);a.session.$bracketHighlight=a.session.addMarker(c,"ace_bracket","text")}},10)},this.focus=function(){var a=this;setTimeout(function(){a.textInput.focus()}),this.textInput.focus()},this.isFocused=function(){return this.textInput.isFocused()},this.blur=function(){this.textInput.blur()},this.onFocus=function(){this.renderer.showCursor(),this.renderer.visualizeFocus(),this._emit("focus")},this.onBlur=function(){this.renderer.hideCursor(),this.renderer.visualizeBlur(),this._emit("blur")},this.onDocumentChange=function(a){var b=a.data,c=b.range,d;c.start.row==c.end.row&&b.action!="insertLines"&&b.action!="removeLines"?d=c.end.row:d=Infinity,this.renderer.updateLines(c.start.row,d),this._emit("change",a),this.onCursorChange()},this.onTokenizerUpdate=function(a){var b=a.data;this.renderer.updateLines(b.first,b.last)},this.onScrollTopChange=function(){this.renderer.scrollToY(this.session.getScrollTop())},this.onScrollLeftChange=function(){this.renderer.scrollToX(this.session.getScrollLeft())},this.onCursorChange=function(){this.renderer.updateCursor();if(!this.$blockScrolling){var a=this.getSelection();a.isEmpty()?this.renderer.scrollCursorIntoView(a.getCursor()):this.renderer.scrollSelectionIntoView(a.getSelectionLead(),a.getSelectionAnchor())}this.renderer.moveTextAreaToCursor(this.textInput.getElement()),this.$highlightBrackets(),this.$updateHighlightActiveLine()},this.$updateHighlightActiveLine=function(){var a=this.getSession();a.$highlightLineMarker&&a.removeMarker(a.$highlightLineMarker),a.$highlightLineMarker=null;if(this.getHighlightActiveLine()&&(this.getSelectionStyle()!="line"||!this.selection.isMultiLine())){var b=this.getCursorPosition(),c=this.session.getFoldLine(b.row),d;c?d=new m(c.start.row,0,c.end.row+1,0):d=new m(b.row,0,b.row+1,0),a.$highlightLineMarker=a.addMarker(d,"ace_active_line","background")}},this.onSelectionChange=function(a){var b=this.getSession();b.$selectionMarker&&b.removeMarker(b.$selectionMarker),b.$selectionMarker=null;if(!this.selection.isEmpty()){var c=this.selection.getRange(),d=this.getSelectionStyle();b.$selectionMarker=b.addMarker(c,"ace_selection",d)}else this.$updateHighlightActiveLine();this.$highlightSelectedWord&&this.session.getMode().highlightSelection(this)},this.onChangeFrontMarker=function(){this.renderer.updateFrontMarkers()},this.onChangeBackMarker=function(){this.renderer.updateBackMarkers()},this.onChangeBreakpoint=function(){this.renderer.setBreakpoints(this.session.getBreakpoints())},this.onChangeAnnotation=function(){this.renderer.setAnnotations(this.session.getAnnotations())},this.onChangeMode=function(){this.renderer.updateText()},this.onChangeWrapLimit=function(){this.renderer.updateFull()},this.onChangeWrapMode=function(){this.renderer.onResize(!0)},this.onChangeFold=function(){this.$updateHighlightActiveLine(),this.renderer.updateFull()},this.getCopyText=function(){var a="";return this.selection.isEmpty()||(a=this.session.getTextRange(this.getSelectionRange())),this._emit("copy",a),a},this.onCut=function(){if(this.$readOnly)return;var a=this.getSelectionRange();this._emit("cut",a),this.selection.isEmpty()||(this.session.remove(a),this.clearSelection())},this.insert=function(a){var b=this.session,c=b.getMode(),d=this.getCursorPosition();if(this.getBehavioursEnabled()){var e=c.transformAction(b.getState(d.row),"insertion",this,b,a);e&&(a=e.text)}a=a.replace(" ",this.session.getTabString());if(!this.selection.isEmpty())d=this.session.remove(this.getSelectionRange()),this.clearSelection();else if(this.session.getOverwrite()){var f=new m.fromPoints(d,d);f.end.column+=a.length,this.session.remove(f)}this.clearSelection();var g=d.column,h=b.getState(d.row),i=c.checkOutdent(h,b.getLine(d.row),a),j=b.getLine(d.row),k=c.getNextLineIndent(h,j.slice(0,d.column),b.getTabString()),l=b.insert(d,a);e&&e.selection&&(e.selection.length==2?this.selection.setSelectionRange(new m(d.row,g+e.selection[0],d.row,g+e.selection[1])):this.selection.setSelectionRange(new m(d.row+e.selection[0],e.selection[1],d.row+e.selection[2],e.selection[3])));var h=b.getState(d.row);if(b.getDocument().isNewLine(a)){this.moveCursorTo(d.row+1,0);var n=b.getTabSize(),o=Number.MAX_VALUE;for(var p=d.row+1;p<=l.row;++p){var q=0;j=b.getLine(p);for(var r=0;r<j.length;++r)if(j.charAt(r)==" ")q+=n;else{if(j.charAt(r)!=" ")break;q+=1}/[^\s]/.test(j)&&(o=Math.min(q,o))}for(var p=d.row+1;p<=l.row;++p){var s=o;j=b.getLine(p);for(var r=0;r<j.length&&s>0;++r)j.charAt(r)==" "?s-=n:j.charAt(r)==" "&&(s-=1);b.remove(new m(p,0,p,r))}b.indentRows(d.row+1,l.row,k)}i&&c.autoOutdent(h,b,d.row)},this.onTextInput=function(a,b){b&&this._emit("paste",a),this.keyBinding.onTextInput(a,b)},this.onCommandKey=function(a,b,c){this.keyBinding.onCommandKey(a,b,c)},this.setOverwrite=function(a){this.session.setOverwrite(a)},this.getOverwrite=function(){return this.session.getOverwrite()},this.toggleOverwrite=function(){this.session.toggleOverwrite()},this.setScrollSpeed=function(a){this.$mouseHandler.setScrollSpeed(a)},this.getScrollSpeed=function(){return this.$mouseHandler.getScrollSpeed()},this.setDragDelay=function(a){this.$mouseHandler.setDragDelay(a)},this.getDragDelay=function(){return this.$mouseHandler.getDragDelay()},this.$selectionStyle="line",this.setSelectionStyle=function(a){if(this.$selectionStyle==a)return;this.$selectionStyle=a,this.onSelectionChange(),this._emit("changeSelectionStyle",{data:a})},this.getSelectionStyle=function(){return this.$selectionStyle},this.$highlightActiveLine=!0,this.setHighlightActiveLine=function(a){if(this.$highlightActiveLine==a)return;this.$highlightActiveLine=a,this.$updateHighlightActiveLine()},this.getHighlightActiveLine=function(){return this.$highlightActiveLine},this.$highlightSelectedWord=!0,this.setHighlightSelectedWord=function(a){if(this.$highlightSelectedWord==a)return;this.$highlightSelectedWord=a,a?this.session.getMode().highlightSelection(this):this.session.getMode().clearSelectionHighlight(this)},this.getHighlightSelectedWord=function(){return this.$highlightSelectedWord},this.setShowInvisibles=function(a){if(this.getShowInvisibles()==a)return;this.renderer.setShowInvisibles(a)},this.getShowInvisibles=function(){return this.renderer.getShowInvisibles()},this.setShowPrintMargin=function(a){this.renderer.setShowPrintMargin(a)},this.getShowPrintMargin=function(){return this.renderer.getShowPrintMargin()},this.setPrintMarginColumn=function(a){this.renderer.setPrintMarginColumn(a)},this.getPrintMarginColumn=function(){return this.renderer.getPrintMarginColumn()},this.$readOnly=!1,this.setReadOnly=function(a){this.$readOnly=a},this.getReadOnly=function(){return this.$readOnly},this.$modeBehaviours=!0,this.setBehavioursEnabled=function(a){this.$modeBehaviours=a},this.getBehavioursEnabled=function(){return this.$modeBehaviours},this.setShowFoldWidgets=function(a){var b=this.renderer.$gutterLayer;if(b.getShowFoldWidgets()==a)return;this.renderer.$gutterLayer.setShowFoldWidgets(a),this.$showFoldWidgets=a,this.renderer.updateFull()},this.getShowFoldWidgets=function(){return this.renderer.$gutterLayer.getShowFoldWidgets()},this.remove=function(a){this.selection.isEmpty()&&(a=="left"?this.selection.selectLeft():this.selection.selectRight());var b=this.getSelectionRange();if(this.getBehavioursEnabled()){var c=this.session,d=c.getState(b.start.row),e=c.getMode().transformAction(d,"deletion",this,c,b);e&&(b=e)}this.session.remove(b),this.clearSelection()},this.removeWordRight=function(){this.selection.isEmpty()&&this.selection.selectWordRight(),this.session.remove(this.getSelectionRange()),this.clearSelection()},this.removeWordLeft=function(){this.selection.isEmpty()&&this.selection.selectWordLeft(),this.session.remove(this.getSelectionRange()),this.clearSelection()},this.removeToLineStart=function(){this.selection.isEmpty()&&this.selection.selectLineStart(),this.session.remove(this.getSelectionRange()),this.clearSelection()},this.removeToLineEnd=function(){this.selection.isEmpty()&&this.selection.selectLineEnd();var a=this.getSelectionRange();a.start.column==a.end.column&&a.start.row==a.end.row&&(a.end.column=0,a.end.row++),this.session.remove(a),this.clearSelection()},this.splitLine=function(){this.selection.isEmpty()||(this.session.remove(this.getSelectionRange()),this.clearSelection());var a=this.getCursorPosition();this.insert("\n"),this.moveCursorToPosition(a)},this.transposeLetters=function(){if(!this.selection.isEmpty())return;var a=this.getCursorPosition(),b=a.column;if(b===0)return;var c=this.session.getLine(a.row),d,e;b<c.length?(d=c.charAt(b)+c.charAt(b-1),e=new m(a.row,b-1,a.row,b+1)):(d=c.charAt(b-1)+c.charAt(b-2),e=new m(a.row,b-2,a.row,b)),this.session.replace(e,d)},this.toLowerCase=function(){var a=this.getSelectionRange();this.selection.isEmpty()&&this.selection.selectWord();var b=this.getSelectionRange(),c=this.session.getTextRange(b);this.session.replace(b,c.toLowerCase()),this.selection.setSelectionRange(a)},this.toUpperCase=function(){var a=this.getSelectionRange();this.selection.isEmpty()&&this.selection.selectWord();var b=this.getSelectionRange(),c=this.session.getTextRange(b);this.session.replace(b,c.toUpperCase()),this.selection.setSelectionRange(a)},this.indent=function(){var a=this.session,b=this.getSelectionRange();if(!(b.start.row<b.end.row||b.start.column<b.end.column)){var d;if(this.session.getUseSoftTabs()){var f=a.getTabSize(),g=this.getCursorPosition(),h=a.documentToScreenColumn(g.row,g.column),i=f-h%f;d=e.stringRepeat(" ",i)}else d=" ";return this.insert(d)}var c=this.$getSelectedRows();a.indentRows(c.first,c.last," ")},this.blockOutdent=function(){var a=this.session.getSelection();this.session.outdentRows(a.getRange())},this.toggleCommentLines=function(){var a=this.session.getState(this.getCursorPosition().row),b=this.$getSelectedRows();this.session.getMode().toggleCommentLines(a,this.session,b.first,b.last)},this.removeLines=function(){var a=this.$getSelectedRows(),b;a.first===0||a.last+1<this.session.getLength()?b=new m(a.first,0,a.last+1,0):b=new m(a.first-1,this.session.getLine(a.first-1).length,a.last,this.session.getLine(a.last).length),this.session.remove(b),this.clearSelection()},this.moveLinesDown=function(){this.$moveLines(function(a,b){return this.session.moveLinesDown(a,b)})},this.moveLinesUp=function(){this.$moveLines(function(a,b){return this.session.moveLinesUp(a,b)})},this.moveText=function(a,b){return this.$readOnly?null:this.session.moveText(a,b)},this.copyLinesUp=function(){this.$moveLines(function(a,b){return this.session.duplicateLines(a,b),0})},this.copyLinesDown=function(){this.$moveLines(function(a,b){return this.session.duplicateLines(a,b)})},this.$moveLines=function(a){var b=this.$getSelectedRows(),c=this.selection;if(!c.isMultiLine())var d=c.getRange(),e=c.isBackwards();var f=a.call(this,b.first,b.last);d?(d.start.row+=f,d.end.row+=f,c.setSelectionRange(d,e)):(c.setSelectionAnchor(b.last+f+1,0),c.$moveSelection(function(){c.moveCursorTo(b.first+f,0)}))},this.$getSelectedRows=function(){var a=this.getSelectionRange().collapseRows();return{first:a.start.row,last:a.end.row}},this.onCompositionStart=function(a){this.renderer.showComposition(this.getCursorPosition())},this.onCompositionUpdate=function(a){this.renderer.setCompositionText(a)},this.onCompositionEnd=function(){this.renderer.hideComposition()},this.getFirstVisibleRow=function(){return this.renderer.getFirstVisibleRow()},this.getLastVisibleRow=function(){return this.renderer.getLastVisibleRow()},this.isRowVisible=function(a){return a>=this.getFirstVisibleRow()&&a<=this.getLastVisibleRow()},this.isRowFullyVisible=function(a){return a>=this.renderer.getFirstFullyVisibleRow()&&a<=this.renderer.getLastFullyVisibleRow()},this.$getVisibleRowCount=function(){return this.renderer.getScrollBottomRow()-this.renderer.getScrollTopRow()+1},this.$getPageDownRow=function(){return this.renderer.getScrollBottomRow()},this.$getPageUpRow=function(){var a=this.renderer.getScrollTopRow(),b=this.renderer.getScrollBottomRow();return a-(b-a)},this.selectPageDown=function(){var a=this.$getPageDownRow()+Math.floor(this.$getVisibleRowCount()/2);this.scrollPageDown();var b=this.getSelection(),c=this.session.documentToScreenPosition(b.getSelectionLead()),d=this.session.screenToDocumentPosition(a,c.column);b.selectTo(d.row,d.column)},this.selectPageUp=function(){var a=this.renderer.getScrollTopRow()-this.renderer.getScrollBottomRow(),b=this.$getPageUpRow()+Math.round(a/2);this.scrollPageUp();var c=this.getSelection(),d=this.session.documentToScreenPosition(c.getSelectionLead()),e=this.session.screenToDocumentPosition(b,d.column);c.selectTo(e.row,e.column)},this.gotoPageDown=function(){var a=this.$getPageDownRow(),b=this.getCursorPositionScreen().column;this.scrollToRow(a),this.getSelection().moveCursorToScreen(a,b)},this.gotoPageUp=function(){var a=this.$getPageUpRow(),b=this.getCursorPositionScreen().column;this.scrollToRow(a),this.getSelection().moveCursorToScreen(a,b)},this.scrollPageDown=function(){this.scrollToRow(this.$getPageDownRow())},this.scrollPageUp=function(){this.renderer.scrollToRow(this.$getPageUpRow())},this.scrollToRow=function(a){this.renderer.scrollToRow(a)},this.scrollToLine=function(a,b){this.renderer.scrollToLine(a,b)},this.centerSelection=function(){var a=this.getSelectionRange(),b=Math.floor(a.start.row+(a.end.row-a.start.row)/2);this.renderer.scrollToLine(b,!0)},this.getCursorPosition=function(){return this.selection.getCursor()},this.getCursorPositionScreen=function(){return this.session.documentToScreenPosition(this.getCursorPosition())},this.getSelectionRange=function(){return this.selection.getRange()},this.selectAll=function(){this.$blockScrolling+=1,this.selection.selectAll(),this.$blockScrolling-=1},this.clearSelection=function(){this.selection.clearSelection()},this.moveCursorTo=function(a,b){this.selection.moveCursorTo(a,b)},this.moveCursorToPosition=function(a){this.selection.moveCursorToPosition(a)},this.jumpToMatching=function(){var a=this.getCursorPosition(),b=this.session.findMatchingBracket(a);b||(a.column+=1,b=this.session.findMatchingBracket(a)),b||(a.column-=2,b=this.session.findMatchingBracket(a)),b&&(this.clearSelection(),this.moveCursorTo(b.row,b.column))},this.gotoLine=function(a,b){this.selection.clearSelection(),this.session.unfold({row:a-1,column:b||0}),this.$blockScrolling+=1,this.moveCursorTo(a-1,b||0),this.$blockScrolling-=1,this.isRowFullyVisible(this.getCursorPosition().row)||this.scrollToLine(a,!0)},this.navigateTo=function(a,b){this.clearSelection(),this.moveCursorTo(a,b)},this.navigateUp=function(a){this.selection.clearSelection(),a=a||1,this.selection.moveCursorBy(-a,0)},this.navigateDown=function(a){this.selection.clearSelection(),a=a||1,this.selection.moveCursorBy(a,0)},this.navigateLeft=function(a){if(!this.selection.isEmpty()){var b=this.getSelectionRange().start;this.moveCursorToPosition(b)}else{a=a||1;while(a--)this.selection.moveCursorLeft()}this.clearSelection()},this.navigateRight=function(a){if(!this.selection.isEmpty()){var b=this.getSelectionRange().end;this.moveCursorToPosition(b)}else{a=a||1;while(a--)this.selection.moveCursorRight()}this.clearSelection()},this.navigateLineStart=function(){this.selection.moveCursorLineStart(),this.clearSelection()},this.navigateLineEnd=function(){this.selection.moveCursorLineEnd(),this.clearSelection()},this.navigateFileEnd=function(){this.selection.moveCursorFileEnd(),this.clearSelection()},this.navigateFileStart=function(){this.selection.moveCursorFileStart(),this.clearSelection()},this.navigateWordRight=function(){this.selection.moveCursorWordRight(),this.clearSelection()},this.navigateWordLeft=function(){this.selection.moveCursorWordLeft(),this.clearSelection()},this.replace=function(a,b){b&&this.$search.set(b);var c=this.$search.find(this.session);if(!c)return;this.$tryReplace(c,a),c!==null&&this.selection.setSelectionRange(c)},this.replaceAll=function(a,b){b&&this.$search.set(b);var c=this.$search.findAll(this.session);if(!c.length)return;var d=this.getSelectionRange();this.clearSelection(),this.selection.moveCursorTo(0,0),this.$blockScrolling+=1;for(var e=c.length-1;e>=0;--e)this.$tryReplace(c[e],a);this.selection.setSelectionRange(d),this.$blockScrolling-=1},this.$tryReplace=function(a,b){var c=this.session.getTextRange(a);return b=this.$search.replace(c,b),b!==null?(a.end=this.session.replace(a,b),a):null},this.getLastSearchOptions=function(){return this.$search.getOptions()},this.find=function(a,b){this.clearSelection(),b=b||{},b.needle=a,this.$search.set(b),this.$find()},this.findNext=function(a){a=a||{},typeof a.backwards=="undefined"&&(a.backwards=!1),this.$search.set(a),this.$find()},this.findPrevious=function(a){a=a||{},typeof a.backwards=="undefined"&&(a.backwards=!0),this.$search.set(a),this.$find()},this.$find=function(a){this.selection.isEmpty()||this.$search.set({needle:this.session.getTextRange(this.getSelectionRange())}),typeof a!="undefined"&&this.$search.set({backwards:a});var b=this.$search.find(this.session);b&&(this.session.unfold(b),this.selection.setSelectionRange(b))},this.undo=function(){this.session.getUndoManager().undo()},this.redo=function(){this.session.getUndoManager().redo()},this.destroy=function(){this.renderer.destroy()}}).call(q.prototype),b.Editor=q}),ace.define("ace/lib/lang",["require","exports","module"],function(a,b,c){"use strict",b.stringReverse=function(a){return a.split("").reverse().join("")},b.stringRepeat=function(a,b){return(new Array(b+1)).join(a)};var d=/^\s\s*/,e=/\s\s*$/;b.stringTrimLeft=function(a){return a.replace(d,"")},b.stringTrimRight=function(a){return a.replace(e,"")},b.copyObject=function(a){var b={};for(var c in a)b[c]=a[c];return b},b.copyArray=function(a){var b=[];for(var c=0,d=a.length;c<d;c++)a[c]&&typeof a[c]=="object"?b[c]=this.copyObject(a[c]):b[c]=a[c];return b},b.deepCopy=function(a){if(typeof a!="object")return a;var b=a.constructor();for(var c in a)typeof a[c]=="object"?b[c]=this.deepCopy(a[c]):b[c]=a[c];return b},b.arrayToMap=function(a){var b={};for(var c=0;c<a.length;c++)b[a[c]]=1;return b},b.arrayRemove=function(a,b){for(var c=0;c<=a.length;c++)b===a[c]&&a.splice(c,1)},b.escapeRegExp=function(a){return a.replace(/([.*+?^${}()|[\]\/\\])/g,"\\$1")},b.deferredCall=function(a){var b=null,c=function(){b=null,a()},d=function(a){return d.cancel(),b=setTimeout(c,a||0),d};return d.schedule=d,d.call=function(){return this.cancel(),a(),d},d.cancel=function(){return clearTimeout(b),b=null,d},d}}),ace.define("ace/keyboard/textinput",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/dom"],function(a,b,c){"use strict";var d=a("../lib/event"),e=a("../lib/useragent"),f=a("../lib/dom"),g=function(a,b){function l(){try{c.select()}catch(a){}}function m(a){if(!i){var d=a||c.value;if(d){d.charCodeAt(d.length-1)==g.charCodeAt(0)?(d=d.slice(0,-1),d&&b.onTextInput(d,j)):b.onTextInput(d,j);if(!v())return!1}}i=!1,j=!1,c.value=g,l()}function v(){return document.activeElement===c}var c=f.createElement("textarea");e.isTouchPad&&c.setAttribute("x-palm-disable-auto-cap",!0),c.style.left="-10000px",c.style.position="fixed",a.insertBefore(c,a.firstChild);var g=String.fromCharCode(0);m();var h=!1,i=!1,j=!1,k="",n=function(a){setTimeout(function(){h||m(a.data)},0)},o=function(a){if(e.isOldIE&&c.value.charCodeAt(0)>128)return;setTimeout(function(){h||m()},0)},p=function(a){h=!0,b.onCompositionStart(),e.isGecko||setTimeout(q,0)},q=function(){if(!h)return;b.onCompositionUpdate(c.value)},r=function(a){h=!1,b.onCompositionEnd()},s=function(a){i=!0;var d=b.getCopyText();d?c.value=d:a.preventDefault(),l(),setTimeout(function(){m()},0)},t=function(a){i=!0;var d=b.getCopyText();d?(c.value=d,b.onCut()):a.preventDefault(),l(),setTimeout(function(){m()},0)};d.addCommandKeyListener(c,b.onCommandKey.bind(b));if(e.isOldIE){var u={13:1,27:1};d.addListener(c,"keyup",function(a){h&&(!c.value||u[a.keyCode])&&setTimeout(r,0);if((c.value.charCodeAt(0)|0)<129)return;h?q():p()})}"onpropertychange"in c&&!("oninput"in c)?d.addListener(c,"propertychange",o):d.addListener(c,"input",n),d.addListener(c,"paste",function(a){j=!0,a.clipboardData&&a.clipboardData.getData?(m(a.clipboardData.getData("text/plain")),a.preventDefault()):o()}),"onbeforecopy"in c&&typeof clipboardData!="undefined"?(d.addListener(c,"beforecopy",function(a){var c=b.getCopyText();c?clipboardData.setData("Text",c):a.preventDefault()}),d.addListener(a,"keydown",function(a){if(a.ctrlKey&&a.keyCode==88){var c=b.getCopyText();c&&(clipboardData.setData("Text",c),b.onCut()),d.preventDefault(a)}})):(d.addListener(c,"copy",s),d.addListener(c,"cut",t)),d.addListener(c,"compositionstart",p),e.isGecko&&d.addListener(c,"text",q),e.isWebKit&&d.addListener(c,"keyup",q),d.addListener(c,"compositionend",r),d.addListener(c,"blur",function(){b.onBlur()}),d.addListener(c,"focus",function(){b.onFocus(),l()}),this.focus=function(){b.onFocus(),l(),c.focus()},this.blur=function(){c.blur()},this.isFocused=v,this.getElement=function(){return c},this.onContextMenu=function(a,b){a&&(k||(k=c.style.cssText),c.style.cssText="position:fixed; z-index:1000;left:"+(a.x-2)+"px; top:"+(a.y-2)+"px;"),b&&(c.value="")},this.onContextMenuClose=function(){setTimeout(function(){k&&(c.style.cssText=k,k=""),m()},0)}};b.TextInput=g}),ace.define("ace/mouse/mouse_handler",["require","exports","module","ace/lib/event","ace/mouse/default_handlers","ace/mouse/default_gutter_handler","ace/mouse/mouse_event"],function(a,b,c){"use strict";var d=a("../lib/event"),e=a("./default_handlers").DefaultHandlers,f=a("./default_gutter_handler").GutterHandler,g=a("./mouse_event").MouseEvent,h=function(a){this.editor=a,new e(a),new f(a),d.addListener(a.container,"mousedown",function(b){return a.focus(),d.preventDefault(b)}),d.addListener(a.container,"selectstart",function(a){return d.preventDefault(a)});var b=a.renderer.getMouseEventTarget();d.addListener(b,"mousedown",this.onMouseEvent.bind(this,"mousedown")),d.addListener(b,"click",this.onMouseEvent.bind(this,"click")),d.addListener(b,"mousemove",this.onMouseMove.bind(this,"mousemove")),d.addMultiMouseDownListener(b,0,2,500,this.onMouseEvent.bind(this,"dblclick")),d.addMultiMouseDownListener(b,0,3,600,this.onMouseEvent.bind(this,"tripleclick")),d.addMultiMouseDownListener(b,0,4,600,this.onMouseEvent.bind(this,"quadclick")),d.addMouseWheelListener(a.container,this.onMouseWheel.bind(this,"mousewheel"));var c=a.renderer.$gutter;d.addListener(c,"mousedown",this.onMouseEvent.bind(this,"guttermousedown")),d.addListener(c,"click",this.onMouseEvent.bind(this,"gutterclick")),d.addListener(c,"dblclick",this.onMouseEvent.bind(this,"gutterdblclick")),d.addListener(c,"mousemove",this.onMouseMove.bind(this,"gutter"))};(function(){this.$scrollSpeed=1,this.setScrollSpeed=function(a){this.$scrollSpeed=a},this.getScrollSpeed=function(){return this.$scrollSpeed},this.onMouseEvent=function(a,b){this.editor._emit(a,new g(b,this.editor))},this.$dragDelay=250,this.setDragDelay=function(a){this.$dragDelay=a},this.getDragDelay=function(){return this.$dragDelay},this.onMouseMove=function(a,b){var c=this.editor._eventRegistry&&this.editor._eventRegistry.mousemove;if(!c||!c.length)return;this.editor._emit(a,new g(b,this.editor))},this.onMouseWheel=function(a,b){var c=new g(b,this.editor);c.speed=this.$scrollSpeed*2,c.wheelX=b.wheelX,c.wheelY=b.wheelY,this.editor._emit(a,c)}}).call(h.prototype),b.MouseHandler=h}),ace.define("ace/mouse/default_handlers",["require","exports","module","ace/lib/event","ace/lib/dom","ace/lib/browser_focus"],function(a,b,c){function k(a){this.editor=a,this.$clickSelection=null,this.browserFocus=new f,a.setDefaultHandler("mousedown",this.onMouseDown.bind(this)),a.setDefaultHandler("dblclick",this.onDoubleClick.bind(this)),a.setDefaultHandler("tripleclick",this.onTripleClick.bind(this)),a.setDefaultHandler("quadclick",this.onQuadClick.bind(this)),a.setDefaultHandler("mousewheel",this.onScroll.bind(this))}function l(a,b,c,d){return Math.sqrt(Math.pow(c-a,2)+Math.pow(d-b,2))}"use strict";var d=a("../lib/event"),e=a("../lib/dom"),f=a("../lib/browser_focus").BrowserFocus,g=0,h=1,i=2,j=5;(function(){this.onMouseDown=function(a){function C(b){a.getShiftKey()?m.selection.selectToPosition(b):n.$clickSelection||(m.moveCursorToPosition(b),m.selection.clearSelection(b.row,b.column)),q=h}var b=a.inSelection(),c=a.pageX,f=a.pageY,k=a.getDocumentPosition(),m=this.editor,n=this,o=m.getSelectionRange(),p=o.isEmpty(),q=g;if(b&&(!this.browserFocus.isFocused()||(new Date).getTime()-this.browserFocus.lastFocus<20||!m.isFocused())){m.focus();return}var r=a.getButton();if(r!==0){p&&m.moveCursorToPosition(k),r==2&&(m.textInput.onContextMenu({x:a.clientX,y:a.clientY},p),d.capture(m.container,function(){},m.textInput.onContextMenuClose));return}b||C(k);var s=c,t=f,u=(new Date).getTime(),v,w,x,y=function(a){s=d.getDocumentX(a),t=d.getDocumentY(a)},z=function(a){clearInterval(F),q==g?C(k):q==i&&A(a),n.$clickSelection=null,q=g},A=function(a){e.removeCssClass(m.container,"ace_dragging"),m.session.removeMarker(x),m.$mouseHandler.$clickSelection||v||(m.moveCursorToPosition(k),m.selection.clearSelection(k.row,k.column));if(!v)return;if(w.contains(v.row,v.column)){v=null;return}m.clearSelection();if(a&&(a.ctrlKey||a.altKey))var b=m.session,c=b.insert(v,b.getTextRange(w));else var c=m.moveText(w,v);if(!c){v=null;return}m.selection.setSelectionRange(c)},B=function(){if(q==g){var a=l(c,f,s,t),b=(new Date).getTime();if(a>j){q=h;var d=m.renderer.screenToTextCoordinates(s,t);d.row=Math.max(0,Math.min(d.row,m.session.getLength()-1)),C(d)}else if(b-u>m.getDragDelay()){q=i,w=m.getSelectionRange();var k=m.getSelectionStyle();x=m.session.addMarker(w,"ace_selection",k),m.clearSelection(),e.addCssClass(m.container,"ace_dragging")}}q==i?E():q==h&&D()},D=function(){var a,b=m.renderer.screenToTextCoordinates(s,t);b.row=Math.max(0,Math.min(b.row,m.session.getLength()-1)),n.$clickSelection?n.$clickSelection.contains(b.row,b.column)?m.selection.setSelectionRange(n.$clickSelection):(n.$clickSelection.compare(b.row,b.column)==-1?a=n.$clickSelection.end:a=n.$clickSelection.start,m.selection.setSelectionAnchor(a.row,a.column),m.selection.selectToPosition(b)):m.selection.selectToPosition(b),m.renderer.scrollCursorIntoView()},E=function(){v=m.renderer.screenToTextCoordinates(s,t),v.row=Math.max(0,Math.min(v.row,m.session.getLength()-1)),m.moveCursorToPosition(v)};d.capture(m.container,y,z);var F=setInterval(B,20);return a.preventDefault()},this.onDoubleClick=function(a){var b=a.getDocumentPosition(),c=this.editor;c.moveCursorToPosition(b),c.selection.selectWord(),this.$clickSelection=c.getSelectionRange()},this.onTripleClick=function(a){var b=a.getDocumentPosition(),c=this.editor;c.moveCursorToPosition(b),c.selection.selectLine(),this.$clickSelection=c.getSelectionRange()},this.onQuadClick=function(a){var b=this.editor;b.selectAll(),this.$clickSelection=b.getSelectionRange()},this.onScroll=function(a){var b=this.editor;b.renderer.scrollBy(a.wheelX*a.speed,a.wheelY*a.speed);if(b.renderer.isScrollableBy(a.wheelX*a.speed,a.wheelY*a.speed))return a.preventDefault()}}).call(k.prototype),b.DefaultHandlers=k}),ace.define("ace/lib/browser_focus",["require","exports","module","ace/lib/oop","ace/lib/event","ace/lib/event_emitter"],function(a,b,c){"use strict";var d=a("./oop"),e=a("./event"),f=a("./event_emitter").EventEmitter,g=function(a){a=a||window,this.lastFocus=(new Date).getTime(),this._isFocused=!0;var b=this;"onfocusin"in a.document?(e.addListener(a.document,"focusin",function(a){b._setFocused(!0)}),e.addListener(a.document,"focusout",function(a){b._setFocused(!!a.toElement)})):(e.addListener(a,"blur",function(a){b._setFocused(!1)}),e.addListener(a,"focus",function(a){b._setFocused(!0)}))};(function(){d.implement(this,f),this.isFocused=function(){return this._isFocused},this._setFocused=function(a){if(this._isFocused==a)return;a&&(this.lastFocus=(new Date).getTime()),this._isFocused=a,this._emit("changeFocus")}}).call(g.prototype),b.BrowserFocus=g}),ace.define("ace/lib/event_emitter",["require","exports","module"],function(a,b,c){"use strict";var d={};d._emit=d._dispatchEvent=function(a,b){this._eventRegistry=this._eventRegistry||{},this._defaultHandlers=this._defaultHandlers||{};var c=this._eventRegistry[a]||[],d=this._defaultHandlers[a];if(!c.length&&!d)return;b=b||{},b.type=a,b.stopPropagation||(b.stopPropagation=function(){this.propagationStopped=!0}),b.preventDefault||(b.preventDefault=function(){this.defaultPrevented=!0});for(var e=0;e<c.length;e++){c[e](b);if(b.propagationStopped)break}d&&!b.defaultPrevented&&d(b)},d.setDefaultHandler=function(a,b){this._defaultHandlers=this._defaultHandlers||{};if(this._defaultHandlers[a])throw new Error("The default handler for '"+a+"' is already set");this._defaultHandlers[a]=b},d.on=d.addEventListener=function(a,b){this._eventRegistry=this._eventRegistry||{};var c=this._eventRegistry[a];if(!c)var c=this._eventRegistry[a]=[];c.indexOf(b)==-1&&c.push(b)},d.removeListener=d.removeEventListener=function(a,b){this._eventRegistry=this._eventRegistry||{};var c=this._eventRegistry[a];if(!c)return;var d=c.indexOf(b);d!==-1&&c.splice(d,1)},d.removeAllListeners=function(a){this._eventRegistry&&(this._eventRegistry[a]=[])},b.EventEmitter=d}),ace.define("ace/mouse/default_gutter_handler",["require","exports","module"],function(a,b,c){function d(a){a.setDefaultHandler("gutterclick",function(b){var c=b.getDocumentPosition().row,d=a.session.selection;d.moveCursorTo(c,0),d.selectLine()})}"use strict",b.GutterHandler=d}),ace.define("ace/mouse/mouse_event",["require","exports","module","ace/lib/event"],function(a,b,c){"use strict";var d=a("../lib/event"),e=b.MouseEvent=function(a,b){this.domEvent=a,this.editor=b,this.pageX=d.getDocumentX(a),this.pageY=d.getDocumentY(a),this.clientX=a.clientX,this.clientY=a.clientY,this.$pos=null,this.$inSelection=null,this.propagationStopped=!1,this.defaultPrevented=!1};(function(){this.stopPropagation=function(){d.stopPropagation(this.domEvent),this.propagationStopped=!0},this.preventDefault=function(){d.preventDefault(this.domEvent),this.defaultPrevented=!0},this.stop=function(){this.stopPropagation(),this.preventDefault()},this.getDocumentPosition=function(){if(this.$pos)return this.$pos;var a=d.getDocumentX(this.domEvent),b=d.getDocumentY(this.domEvent);return this.$pos=this.editor.renderer.screenToTextCoordinates(a,b),this.$pos.row=Math.max(0,Math.min(this.$pos.row,this.editor.session.getLength()-1)),this.$pos},this.inSelection=function(){if(this.$inSelection!==null)return this.$inSelection;var a=this.editor;if(a.getReadOnly())this.$inSelection=!1;else{var b=a.getSelectionRange();if(b.isEmpty())this.$inSelection=!1;else{var c=this.getDocumentPosition();this.$inSelection=b.contains(c.row,c.column)}}return this.$inSelection},this.getButton=function(){return d.getButton(this.domEvent)},this.getShiftKey=function(){return this.domEvent.shiftKey},this.getAccelKey=function(){return this.domEvent.ctrlKey||this.domEvent.metaKey}}).call(e.prototype)}),ace.define("ace/mouse/fold_handler",["require","exports","module"],function(a,b,c){function d(a){a.on("click",function(b){var c=b.getDocumentPosition(),d=a.session,e=d.getFoldAt(c.row,c.column,1);e&&(b.getAccelKey()?d.removeFold(e):d.expandFold(e),b.stop())}),a.on("gutterclick",function(b){if(b.domEvent.target.className.indexOf("ace_fold-widget")!=-1){var c=b.getDocumentPosition().row;a.session.onFoldWidgetClick(c,b.domEvent),b.stop()}})}"use strict",b.FoldHandler=d}),ace.define("ace/keyboard/keybinding",["require","exports","module","ace/lib/keys","ace/lib/event","ace/commands/default_commands"],function(a,b,c){"use strict";var d=a("../lib/keys"),e=a("../lib/event");a("../commands/default_commands");var f=function(a){this.$editor=a,this.$data={},this.$handlers=[this]};(function(){this.setKeyboardHandler=function(a){if(this.$handlers[this.$handlers.length-1]==a)return;this.$data={},this.$handlers=a?[this,a]:[this]},this.addKeyboardHandler=function(a){this.removeKeyboardHandler(a),this.$handlers.push(a)},this.removeKeyboardHandler=function(a){var b=this.$handlers.indexOf(a);return b==-1?!1:(this.$handlers.splice(b,1),!0)},this.getKeyboardHandler=function(){return this.$handlers[this.$handlers.length-1]},this.$callKeyboardHandlers=function(a,b,c,d){var f;for(var g=this.$handlers.length;g--;){f=this.$handlers[g].handleKeyboard(this.$data,a,b,c,d);if(f&&f.command)break}if(!f||!f.command)return!1;var h=!1,i=this.$editor.commands;return f.command!="null"?h=i.exec(f.command,this.$editor,f.args):h=!0,h&&d&&e.stopEvent(d),h},this.handleKeyboard=function(a,b,c){return{command:this.$editor.commands.findKeyCommand(b,c)}},this.onCommandKey=function(a,b,c){var e=d.keyCodeToString(c);this.$callKeyboardHandlers(b,e,c,a)},this.onTextInput=function(a,b){var c=!1;!b&&a.length==1&&(c=this.$callKeyboardHandlers(0,a)),c||this.$editor.commands.exec("insertstring",this.$editor,a)}}).call(f.prototype),b.KeyBinding=f}),ace.define("ace/commands/default_commands",["require","exports","module","ace/lib/lang"],function(a,b,c){function e(a,b){return{win:a,mac:b}}"use strict";var d=a("../lib/lang");b.commands=[{name:"selectall",bindKey:e("Ctrl-A","Command-A"),exec:function(a){a.selectAll()},readOnly:!0},{name:"centerselection",bindKey:e(null,"Ctrl-L"),exec:function(a){a.centerSelection()},readOnly:!0},{name:"gotoline",bindKey:e("Ctrl-L","Command-L"),exec:function(a){var b=parseInt(prompt("Enter line number:"),10);isNaN(b)||a.gotoLine(b)},readOnly:!0},{name:"fold",bindKey:e("Alt-L","Alt-L"),exec:function(a){a.session.toggleFold(!1)},readOnly:!0},{name:"unfold",bindKey:e("Alt-Shift-L","Alt-Shift-L"),exec:function(a){a.session.toggleFold(!0)},readOnly:!0},{name:"foldall",bindKey:e("Alt-0","Alt-0"),exec:function(a){a.session.foldAll()},readOnly:!0},{name:"unfoldall",bindKey:e("Alt-Shift-0","Alt-Shift-0"),exec:function(a){a.session.unfold()},readOnly:!0},{name:"findnext",bindKey:e("Ctrl-K","Command-G"),exec:function(a){a.findNext()},readOnly:!0},{name:"findprevious",bindKey:e("Ctrl-Shift-K","Command-Shift-G"),exec:function(a){a.findPrevious()},readOnly:!0},{name:"find",bindKey:e("Ctrl-F","Command-F"),exec:function(a){var b=prompt("Find:",a.getCopyText());a.find(b)},readOnly:!0},{name:"overwrite",bindKey:e("Insert","Insert"),exec:function(a){a.toggleOverwrite()},readOnly:!0},{name:"selecttostart",bindKey:e("Ctrl-Shift-Home|Alt-Shift-Up","Command-Shift-Up"),exec:function(a){a.getSelection().selectFileStart()},readOnly:!0},{name:"gotostart",bindKey:e("Ctrl-Home|Ctrl-Up","Command-Home|Command-Up"),exec:function(a){a.navigateFileStart()},readOnly:!0},{name:"selectup",bindKey:e("Shift-Up","Shift-Up"),exec:function(a){a.getSelection().selectUp()},readOnly:!0},{name:"golineup",bindKey:e("Up","Up|Ctrl-P"),exec:function(a,b){a.navigateUp(b.times)},readOnly:!0},{name:"selecttoend",bindKey:e("Ctrl-Shift-End|Alt-Shift-Down","Command-Shift-Down"),exec:function(a){a.getSelection().selectFileEnd()},readOnly:!0},{name:"gotoend",bindKey:e("Ctrl-End|Ctrl-Down","Command-End|Command-Down"),exec:function(a){a.navigateFileEnd()},readOnly:!0},{name:"selectdown",bindKey:e("Shift-Down","Shift-Down"),exec:function(a){a.getSelection().selectDown()},readOnly:!0},{name:"golinedown",bindKey:e("Down","Down|Ctrl-N"),exec:function(a,b){a.navigateDown(b.times)},readOnly:!0},{name:"selectwordleft",bindKey:e("Ctrl-Shift-Left","Option-Shift-Left"),exec:function(a){a.getSelection().selectWordLeft()},readOnly:!0},{name:"gotowordleft",bindKey:e("Ctrl-Left","Option-Left"),exec:function(a){a.navigateWordLeft()},readOnly:!0},{name:"selecttolinestart",bindKey:e("Alt-Shift-Left","Command-Shift-Left"),exec:function(a){a.getSelection().selectLineStart()},readOnly:!0},{name:"gotolinestart",bindKey:e("Alt-Left|Home","Command-Left|Home|Ctrl-A"),exec:function(a){a.navigateLineStart()},readOnly:!0},{name:"selectleft",bindKey:e("Shift-Left","Shift-Left"),exec:function(a){a.getSelection().selectLeft()},readOnly:!0},{name:"gotoleft",bindKey:e("Left","Left|Ctrl-B"),exec:function(a,b){a.navigateLeft(b.times)},readOnly:!0},{name:"selectwordright",bindKey:e("Ctrl-Shift-Right","Option-Shift-Right"),exec:function(a){a.getSelection().selectWordRight()},readOnly:!0},{name:"gotowordright",bindKey:e("Ctrl-Right","Option-Right"),exec:function(a){a.navigateWordRight()},readOnly:!0},{name:"selecttolineend",bindKey:e("Alt-Shift-Right","Command-Shift-Right"),exec:function(a){a.getSelection().selectLineEnd()},readOnly:!0},{name:"gotolineend",bindKey:e("Alt-Right|End","Command-Right|End|Ctrl-E"),exec:function(a){a.navigateLineEnd()},readOnly:!0},{name:"selectright",bindKey:e("Shift-Right","Shift-Right"),exec:function(a){a.getSelection().selectRight()},readOnly:!0},{name:"gotoright",bindKey:e("Right","Right|Ctrl-F"),exec:function(a,b){a.navigateRight(b.times)},readOnly:!0},{name:"selectpagedown",bindKey:e("Shift-PageDown","Shift-PageDown"),exec:function(a){a.selectPageDown()},readOnly:!0},{name:"pagedown",bindKey:e(null,"PageDown"),exec:function(a){a.scrollPageDown()},readOnly:!0},{name:"gotopagedown",bindKey:e("PageDown","Option-PageDown|Ctrl-V"),exec:function(a){a.gotoPageDown()},readOnly:!0},{name:"selectpageup",bindKey:e("Shift-PageUp","Shift-PageUp"),exec:function(a){a.selectPageUp()},readOnly:!0},{name:"pageup",bindKey:e(null,"PageUp"),exec:function(a){a.scrollPageUp()},readOnly:!0},{name:"gotopageup",bindKey:e("PageUp","Option-PageUp"),exec:function(a){a.gotoPageUp()},readOnly:!0},{name:"selectlinestart",bindKey:e("Shift-Home","Shift-Home"),exec:function(a){a.getSelection().selectLineStart()},readOnly:!0},{name:"selectlineend",bindKey:e("Shift-End","Shift-End"),exec:function(a){a.getSelection().selectLineEnd()},readOnly:!0},{name:"togglerecording",bindKey:e("Ctrl-Alt-E","Command-Option-E"),exec:function(a){a.commands.toggleRecording()},readOnly:!0},{name:"replaymacro",bindKey:e("Ctrl-Shift-E","Command-Shift-E"),exec:function(a){a.commands.replay(a)},readOnly:!0},{name:"jumptomatching",bindKey:e("Ctrl-Shift-P","Ctrl-Shift-P"),exec:function(a){a.jumpToMatching()},readOnly:!0},{name:"removeline",bindKey:e("Ctrl-D","Command-D"),exec:function(a){a.removeLines()}},{name:"togglecomment",bindKey:e("Ctrl-7","Command-7"),exec:function(a){a.toggleCommentLines()}},{name:"replace",bindKey:e("Ctrl-R","Command-Option-F"),exec:function(a){var b=prompt("Find:",a.getCopyText());if(!b)return;var c=prompt("Replacement:");if(!c)return;a.replace(c,{needle:b})}},{name:"replaceall",bindKey:e("Ctrl-Shift-R","Command-Shift-Option-F"),exec:function(a){var b=prompt("Find:");if(!b)return;var c=prompt("Replacement:");if(!c)return;a.replaceAll(c,{needle:b})}},{name:"undo",bindKey:e("Ctrl-Z","Command-Z"),exec:function(a){a.undo()}},{name:"redo",bindKey:e("Ctrl-Shift-Z|Ctrl-Y","Command-Shift-Z|Command-Y"),exec:function(a){a.redo()}},{name:"copylinesup",bindKey:e("Ctrl-Alt-Up","Command-Option-Up"),exec:function(a){a.copyLinesUp()}},{name:"movelinesup",bindKey:e("Alt-Up","Option-Up"),exec:function(a){a.moveLinesUp()}},{name:"copylinesdown",bindKey:e("Ctrl-Alt-Down","Command-Option-Down"),exec:function(a){a.copyLinesDown()}},{name:"movelinesdown",bindKey:e("Alt-Down","Option-Down"),exec:function(a){a.moveLinesDown()}},{name:"del",bindKey:e("Delete","Delete|Ctrl-D"),exec:function(a){a.remove("right")}},{name:"backspace",bindKey:e("Command-Backspace|Option-Backspace|Shift-Backspace|Backspace","Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H"),exec:function(a){a.remove("left")}},{name:"removetolinestart",bindKey:e("Alt-Backspace","Command-Backspace"),exec:function(a){a.removeToLineStart()}},{name:"removetolineend",bindKey:e("Alt-Delete","Ctrl-K"),exec:function(a){a.removeToLineEnd()}},{name:"removewordleft",bindKey:e("Ctrl-Backspace","Alt-Backspace|Ctrl-Alt-Backspace"),exec:function(a){a.removeWordLeft()}},{name:"removewordright",bindKey:e("Ctrl-Delete","Alt-Delete"),exec:function(a){a.removeWordRight()}},{name:"outdent",bindKey:e("Shift-Tab","Shift-Tab"),exec:function(a){a.blockOutdent()}},{name:"indent",bindKey:e("Tab","Tab"),exec:function(a){a.indent()}},{name:"insertstring",exec:function(a,b){a.insert(b)}},{name:"inserttext",exec:function(a,b){a.insert(d.stringRepeat(b.text||"",b.times||1))}},{name:"splitline",bindKey:e(null,"Ctrl-O"),exec:function(a){a.splitLine()}},{name:"transposeletters",bindKey:e("Ctrl-T","Ctrl-T"),exec:function(a){a.transposeLetters()}},{name:"touppercase",bindKey:e("Ctrl-U","Ctrl-U"),exec:function(a){a.toUpperCase()}},{name:"tolowercase",bindKey:e("Ctrl-Shift-U","Ctrl-Shift-U"),exec:function(a){a.toLowerCase()}}]}),ace.define("ace/edit_session",["require","exports","module","ace/config","ace/lib/oop","ace/lib/lang","ace/lib/net","ace/lib/event_emitter","ace/selection","ace/mode/text","ace/range","ace/document","ace/background_tokenizer","ace/edit_session/folding","ace/edit_session/bracket_match"],function(a,b,c){"use strict";var d=a("./config"),e=a("./lib/oop"),f=a("./lib/lang"),g=a("./lib/net"),h=a("./lib/event_emitter").EventEmitter,i=a("./selection").Selection,j=a("./mode/text").Mode,k=a("./range").Range,l=a("./document").Document,m=a("./background_tokenizer").BackgroundTokenizer,n=function(a,b){this.$modified=!0,this.$breakpoints=[],this.$frontMarkers={},this.$backMarkers={},this.$markerId=1,this.$rowCache=[],this.$wrapData=[],this.$foldData=[],this.$undoSelect=!0,this.$foldData.toString=function(){var a="";return this.forEach(function(b){a+="\n"+b.toString()}),a},a instanceof l?this.setDocument(a):this.setDocument(new l(a)),this.selection=new i(this),b?this.setMode(b):this.setMode(new j)};(function(){function q(a){return a<4352?!1:a>=4352&&a<=4447||a>=4515&&a<=4519||a>=4602&&a<=4607||a>=9001&&a<=9002||a>=11904&&a<=11929||a>=11931&&a<=12019||a>=12032&&a<=12245||a>=12272&&a<=12283||a>=12288&&a<=12350||a>=12353&&a<=12438||a>=12441&&a<=12543||a>=12549&&a<=12589||a>=12593&&a<=12686||a>=12688&&a<=12730||a>=12736&&a<=12771||a>=12784&&a<=12830||a>=12832&&a<=12871||a>=12880&&a<=13054||a>=13056&&a<=19903||a>=19968&&a<=42124||a>=42128&&a<=42182||a>=43360&&a<=43388||a>=44032&&a<=55203||a>=55216&&a<=55238||a>=55243&&a<=55291||a>=63744&&a<=64255||a>=65040&&a<=65049||a>=65072&&a<=65106||a>=65108&&a<=65126||a>=65128&&a<=65131||a>=65281&&a<=65376||a>=65504&&a<=65510}e.implement(this,h),this.setDocument=function(a){if(this.doc)throw new Error("Document is already set");this.doc=a,a.on("change",this.onChange.bind(this)),this.on("changeFold",this.onChangeFold.bind(this)),this.bgTokenizer&&(this.bgTokenizer.setDocument(this.getDocument()),this.bgTokenizer.start(0))},this.getDocument=function(){return this.doc},this.$resetRowCache=function(a){if(a==0){this.$rowCache=[];return}var b=this.$rowCache;for(var c=0;c<b.length;c++)if(b[c].docRow>=a){b.splice(c,b.length);return}},this.onChangeFold=function(a){var b=a.data;this.$resetRowCache(b.start.row)},this.onChange=function(a){var b=a.data;this.$modified=!0,this.$resetRowCache(b.range.start.row);var c=this.$updateInternalDataOnChange(a);!this.$fromUndo&&this.$undoManager&&!b.ignore&&(this.$deltasDoc.push(b),c&&c.length!=0&&this.$deltasFold.push({action:"removeFolds",folds:c}),this.$informUndoManager.schedule()),this.bgTokenizer.start(b.range.start.row),this._emit("change",a)},this.setValue=function(a){this.doc.setValue(a),this.selection.moveCursorTo(0,0),this.selection.clearSelection(),this.$resetRowCache(0),this.$deltas=[],this.$deltasDoc=[],this.$deltasFold=[],this.getUndoManager().reset()},this.getValue=this.toString=function(){return this.doc.getValue()},this.getSelection=function(){return this.selection},this.getState=function(a){return this.bgTokenizer.getState(a)},this.getTokens=function(a,b){return this.bgTokenizer.getTokens(a,b)},this.getTokenAt=function(a,b){var c=this.bgTokenizer.getTokens(a,a)[0].tokens,d,e=0;if(b==null)f=c.length-1,e=this.getLine(a).length;else for(var f=0;f<c.length;f++){e+=c[f].value.length;if(e>=b)break}return d=c[f],d?(d.index=f,d.start=e-d.value.length,d):null},this.setUndoManager=function(a){this.$undoManager=a,this.$resetRowCache(0),this.$deltas=[],this.$deltasDoc=[],this.$deltasFold=[],this.$informUndoManager&&this.$informUndoManager.cancel();if(a){var b=this;this.$syncInformUndoManager=function(){b.$informUndoManager.cancel(),b.$deltasFold.length&&(b.$deltas.push({group:"fold",deltas:b.$deltasFold}),b.$deltasFold=[]),b.$deltasDoc.length&&(b.$deltas.push({group:"doc",deltas:b.$deltasDoc}),b.$deltasDoc=[]),b.$deltas.length>0&&a.execute({action:"aceupdate",args:[b.$deltas,b]}),b.$deltas=[]},this.$informUndoManager=f.deferredCall(this.$syncInformUndoManager)}},this.$defaultUndoManager={undo:function(){},redo:function(){},reset:function(){}},this.getUndoManager=function(){return this.$undoManager||this.$defaultUndoManager},this.getTabString=function(){return this.getUseSoftTabs()?f.stringRepeat(" ",this.getTabSize()):" "},this.$useSoftTabs=!0,this.setUseSoftTabs=function(a){if(this.$useSoftTabs===a)return;this.$useSoftTabs=a},this.getUseSoftTabs=function(){return this.$useSoftTabs},this.$tabSize=4,this.setTabSize=function(a){if(isNaN(a)||this.$tabSize===a)return;this.$modified=!0,this.$tabSize=a,this._emit("changeTabSize")},this.getTabSize=function(){return this.$tabSize},this.isTabStop=function(a){return this.$useSoftTabs&&a.column%this.$tabSize==0},this.$overwrite=!1,this.setOverwrite=function(a){if(this.$overwrite==a)return;this.$overwrite=a,this._emit("changeOverwrite")},this.getOverwrite=function(){return this.$overwrite},this.toggleOverwrite=function(){this.setOverwrite(!this.$overwrite)},this.getBreakpoints=function(){return this.$breakpoints},this.setBreakpoints=function(a){this.$breakpoints=[];for(var b=0;b<a.length;b++)this.$breakpoints[a[b]]=!0;this._emit("changeBreakpoint",{})},this.clearBreakpoints=function(){this.$breakpoints=[],this._emit("changeBreakpoint",{})},this.setBreakpoint=function(a){this.$breakpoints[a]=!0,this._emit("changeBreakpoint",{})},this.clearBreakpoint=function(a){delete this.$breakpoints[a],this._emit("changeBreakpoint",{})},this.getBreakpoints=function(){return this.$breakpoints},this.addMarker=function(a,b,c,d){var e=this.$markerId++,f={range:a,type:c||"line",renderer:typeof c=="function"?c:null,clazz:b,inFront:!!d};return d?(this.$frontMarkers[e]=f,this._emit("changeFrontMarker")):(this.$backMarkers[e]=f,this._emit("changeBackMarker")),e},this.removeMarker=function(a){var b=this.$frontMarkers[a]||this.$backMarkers[a];if(!b)return;var c=b.inFront?this.$frontMarkers:this.$backMarkers;b&&(delete c[a],this._emit(b.inFront?"changeFrontMarker":"changeBackMarker"))},this.getMarkers=function(a){return a?this.$frontMarkers:this.$backMarkers},this.setAnnotations=function(a){this.$annotations={};for(var b=0;b<a.length;b++){var c=a[b],d=c.row;this.$annotations[d]?this.$annotations[d].push(c):this.$annotations[d]=[c]}this._emit("changeAnnotation",{})},this.getAnnotations=function(){return this.$annotations||{}},this.clearAnnotations=function(){this.$annotations={},this._emit("changeAnnotation",{})},this.$detectNewLine=function(a){var b=a.match(/^.*?(\r?\n)/m);b?this.$autoNewLine=b[1]:this.$autoNewLine="\n"},this.getWordRange=function(a,b){var c=this.getLine(a),d=!1;b>0&&(d=!!c.charAt(b-1).match(this.tokenRe)),d||(d=!!c.charAt(b).match(this.tokenRe));var e=d?this.tokenRe:this.nonTokenRe,f=b;if(f>0){do f--;while(f>=0&&c.charAt(f).match(e));f++}var g=b;while(g<c.length&&c.charAt(g).match(e))g++;return new k(a,f,a,g)},this.getAWordRange=function(a,b){var c=this.getWordRange(a,b),d=this.getLine(c.end.row);while(d.charAt(c.end.column).match(/[ \t]/))c.end.column+=1;return c},this.setNewLineMode=function(a){this.doc.setNewLineMode(a)},this.getNewLineMode=function(){return this.doc.getNewLineMode()},this.$useWorker=!0,this.setUseWorker=function(a){if(this.$useWorker==a)return;this.$useWorker=a,this.$stopWorker(),a&&this.$startWorker()},this.getUseWorker=function(){return this.$useWorker},this.onReloadTokenizer=function(a){var b=a.data;this.bgTokenizer.start(b.first),this._emit("tokenizerUpdate",a)},this.$modes={},this._loadMode=function(b,c){function i(a){if(e.$modes[b])return c(e.$modes[b]);e.$modes[b]=new a.Mode,e._emit("loadmode",{name:b,mode:e.$modes[b]}),c(e.$modes[b])}function j(a){if(!d.get("packaged"))return a();var c=b.split("/").pop(),e=d.get("modePath")+"/mode-"+c+d.get("suffix");g.loadScript(e,a)}if(this.$modes[b])return c(this.$modes[b]);var e=this,f;try{f=a(b)}catch(h){}if(f)return i(f);j(function(){a([b],i)})},this.$mode=null,this.$origMode=null,this.setMode=function(a){this.$origMode=a;if(typeof a=="string"){var b=this;this._loadMode(a,function(c){if(b.$origMode!==a)return;b.setMode(c)});return}if(this.$mode===a)return;this.$mode=a,this.$stopWorker(),this.$useWorker&&this.$startWorker();var c=a.getTokenizer();if(c.addEventListener!==undefined){var d=this.onReloadTokenizer.bind(this);c.addEventListener("update",d)}if(!this.bgTokenizer){this.bgTokenizer=new m(c);var b=this;this.bgTokenizer.addEventListener("update",function(a){b._emit("tokenizerUpdate",a)})}else this.bgTokenizer.setTokenizer(c);this.bgTokenizer.setDocument(this.getDocument()),this.bgTokenizer.start(0),this.tokenRe=a.tokenRe,this.nonTokenRe=a.nonTokenRe,this.$setFolding(a.foldingRules),this._emit("changeMode")},this.$stopWorker=function(){this.$worker&&this.$worker.terminate(),this.$worker=null},this.$startWorker=function(){if(typeof Worker!="undefined"&&!a.noWorker)try{this.$worker=this.$mode.createWorker(this)}catch(b){console.log("Could not load worker"),console.log(b),this.$worker=null}else this.$worker=null},this.getMode=function(){return this.$mode},this.$scrollTop=0,this.setScrollTop=function(a){a=Math.round(Math.max(0,a));if(this.$scrollTop===a)return;this.$scrollTop=a,this._emit("changeScrollTop",a)},this.getScrollTop=function(){return this.$scrollTop},this.$scrollLeft=0,this.setScrollLeft=function(a){a=Math.round(Math.max(0,a));if(this.$scrollLeft===a)return;this.$scrollLeft=a,this._emit("changeScrollLeft",a)},this.getScrollLeft=function(){return this.$scrollLeft},this.getWidth=function(){return this.$computeWidth(),this.width},this.getScreenWidth=function(){return this.$computeWidth(),this.screenWidth},this.$computeWidth=function(a){if(this.$modified||a){this.$modified=!1;var b=this.doc.getAllLines(),c=0,d=0;for(var e=0;e<b.length;e++){var f=this.getFoldLine(e),g,h;g=b[e];if(f){var i=f.range.end;g=this.getFoldDisplayLine(f),e=i.row}h=g.length,c=Math.max(c,h),this.$useWrapMode||(d=Math.max(d,this.$getStringScreenWidth(g)[0]))}this.width=c,this.$useWrapMode?this.screenWidth=this.$wrapLimit:this.screenWidth=d}},this.getLine=function(a){return this.doc.getLine(a)},this.getLines=function(a,b){return this.doc.getLines(a,b)},this.getLength=function(){return this.doc.getLength()},this.getTextRange=function(a){return this.doc.getTextRange(a)},this.insert=function(a,b){return this.doc.insert(a,b)},this.remove=function(a){return this.doc.remove(a)},this.undoChanges=function(a,b){if(!a.length)return;this.$fromUndo=!0;var c=null;for(var d=a.length-1;d!=-1;d--){var e=a[d];e.group=="doc"?(this.doc.revertDeltas(e.deltas),c=this.$getUndoSelection(e.deltas,!0,c)):e.deltas.forEach(function(a){this.addFolds(a.folds)},this)}return this.$fromUndo=!1,c&&this.$undoSelect&&!b&&this.selection.setSelectionRange(c),c},this.redoChanges=function(a,b){if(!a.length)return;this.$fromUndo=!0;var c=null;for(var d=0;d<a.length;d++){var e=a[d];e.group=="doc"&&(this.doc.applyDeltas(e.deltas),c=this.$getUndoSelection(e.deltas,!1,c))}return this.$fromUndo=!1,c&&this.$undoSelect&&!b&&this.selection.setSelectionRange(c),c},this.setUndoSelect=function(a){this.$undoSelect=a},this.$getUndoSelection=function(a,b,c){function d(a){var c=a.action=="insertText"||a.action=="insertLines";return b?!c:c}var e=a[0],f,g,h=!1;d(e)?(f=e.range.clone(),h=!0):(f=k.fromPoints(e.range.start,e.range.start),h=!1);for(var i=1;i<a.length;i++)e=a[i],d(e)?(g=e.range.start,f.compare(g.row,g.column)==-1&&f.setStart(e.range.start),g=e.range.end,f.compare(g.row,g.column)==1&&f.setEnd(e.range.end),h=!0):(g=e.range.start,f.compare(g.row,g.column)==-1&&(f=k.fromPoints(e.range.start,e.range.start)),h=!1);if(c!=null){var j=c.compareRange(f);j==1?f.setStart(c.start):j==-1&&f.setEnd(c.end)}return f},this.replace=function(a,b){return this.doc.replace(a,b)},this.moveText=function(a,b){var c=this.getTextRange(a);this.remove(a);var d=b.row,e=b.column;!a.isMultiLine()&&a.start.row==d&&a.end.column<e&&(e-=c.length);if(a.isMultiLine()&&a.end.row<d){var f=this.doc.$split(c);d-=f.length-1}var g=d+a.end.row-a.start.row,h=a.isMultiLine()?a.end.column:e+a.end.column-a.start.column,i=new k(d,e,g,h);return this.insert(i.start,c),i},this.indentRows=function(a,b,c){c=c.replace(/\t/g,this.getTabString());for(var d=a;d<=b;d++)this.insert({row:d,column:0},c)},this.outdentRows=function(a){var b=a.collapseRows(),c=new k(0,0,0,0),d=this.getTabSize();for(var e=b.start.row;e<=b.end.row;++e){var f=this.getLine(e);c.start.row=e,c.end.row=e;for(var g=0;g<d;++g)if(f.charAt(g)!=" ")break;g<d&&f.charAt(g)==" "?(c.start.column=g,c.end.column=g+1):(c.start.column=0,c.end.column=g),this.remove(c)}},this.moveLinesUp=function(a,b){if(a<=0)return 0;var c=this.doc.removeLines(a,b);return this.doc.insertLines(a-1,c),-1},this.moveLinesDown=function(a,b){if(b>=this.doc.getLength()-1)return 0;var c=this.doc.removeLines(a,b);return this.doc.insertLines(a+1,c),1},this.duplicateLines=function(a,b){var a=this.$clipRowToDocument(a),b=this.$clipRowToDocument(b),c=this.getLines(a,b);this.doc.insertLines(a,c);var d=b-a+1;return d},this.$clipRowToDocument=function(a){return Math.max(0,Math.min(a,this.doc.getLength()-1))},this.$clipColumnToRow=function(a,b){return b<0?0:Math.min(this.doc.getLine(a).length,b)},this.$clipPositionToDocument=function(a,b){b=Math.max(0,b);if(a<0)a=0,b=0;else{var c=this.doc.getLength();a>=c?(a=c-1,b=this.doc.getLine(c-1).length):b=Math.min(this.doc.getLine(a).length,b)}return{row:a,column:b}},this.$clipRangeToDocument=function(a){a.start.row<0?(a.start.row=0,a.start.column=0):a.start.column=this.$clipColumnToRow(a.start.row,a.start.column);var b=this.doc.getLength()-1;return a.end.row>b?(a.end.row=b,a.end.column=this.doc.getLine(b).length):a.end.column=this.$clipColumnToRow(a.end.row,a.end.column),a},this.$wrapLimit=80,this.$useWrapMode=!1,this.$wrapLimitRange={min:null,max:null},this.setUseWrapMode=function(a){if(a!=this.$useWrapMode){this.$useWrapMode=a,this.$modified=!0,this.$resetRowCache(0);if(a){var b=this.getLength();this.$wrapData=[];for(var c=0;c<b;c++)this.$wrapData.push([]);this.$updateWrapData(0,b-1)}this._emit("changeWrapMode")}},this.getUseWrapMode=function(){return this.$useWrapMode},this.setWrapLimitRange=function(a,b){if(this.$wrapLimitRange.min!==a||this.$wrapLimitRange.max!==b)this.$wrapLimitRange.min=a,this.$wrapLimitRange.max=b,this.$modified=!0,this._emit("changeWrapMode")},this.adjustWrapLimit=function(a){var b=this.$constrainWrapLimit(a);return b!=this.$wrapLimit&&b>0?(this.$wrapLimit=b,this.$modified=!0,this.$useWrapMode&&(this.$updateWrapData(0,this.getLength()-1),this.$resetRowCache(0),this._emit("changeWrapLimit")),!0):!1},this.$constrainWrapLimit=function(a){var b=this.$wrapLimitRange.min;b&&(a=Math.max(b,a));var c=this.$wrapLimitRange.max;return c&&(a=Math.min(c,a)),Math.max(1,a)},this.getWrapLimit=function(){return this.$wrapLimit},this.getWrapLimitRange=function(){return{min:this.$wrapLimitRange.min,max:this.$wrapLimitRange.max}},this.$updateInternalDataOnChange=function(a){var b=this.$useWrapMode,c,d=a.data.action,e=a.data.range.start.row,f=a.data.range.end.row,g=a.data.range.start,h=a.data.range.end,i=null;d.indexOf("Lines")!=-1?(d=="insertLines"?f=e+a.data.lines.length:f=e,c=a.data.lines?a.data.lines.length:f-e):c=f-e;if(c!=0)if(d.indexOf("remove")!=-1){b&&this.$wrapData.splice(e,c);var j=this.$foldData;i=this.getFoldsInRange(a.data.range),this.removeFolds(i);var k=this.getFoldLine(h.row),l=0;if(k){k.addRemoveChars(h.row,h.column,g.column-h.column),k.shiftRow(-c);var m=this.getFoldLine(e);m&&m!==k&&(m.merge(k),k=m),l=j.indexOf(k)+1}for(l;l<j.length;l++){var k=j[l];k.start.row>=h.row&&k.shiftRow(-c)}f=e}else{var n;if(b){n=[e,0];for(var o=0;o<c;o++)n.push([]);this.$wrapData.splice.apply(this.$wrapData,n)}var j=this.$foldData,k=this.getFoldLine(e),l=0;if(k){var p=k.range.compareInside(g.row,g.column);p==0?(k=k.split(g.row,g.column),k.shiftRow(c),k.addRemoveChars(f,0,h.column-g.column)):p==-1&&(k.addRemoveChars(e,0,h.column-g.column),k.shiftRow(c)),l=j.indexOf(k)+1}for(l;l<j.length;l++){var k=j[l];k.start.row>=e&&k.shiftRow(c)}}else{c=Math.abs(a.data.range.start.column-a.data.range.end.column),d.indexOf("remove")!=-1&&(i=this.getFoldsInRange(a.data.range),this.removeFolds(i),c=-c);var k=this.getFoldLine(e);k&&k.addRemoveChars(e,g.column,c)}return b&&this.$wrapData.length!=this.doc.getLength()&&console.error("doc.getLength() and $wrapData.length have to be the same!"),b&&this.$updateWrapData(e,f),i},this.$updateWrapData=function(a,b){var c=this.doc.getAllLines(),d=this.getTabSize(),e=this.$wrapData,g=this.$wrapLimit,h,k,l=a;b=Math.min(b,c.length-1);while(l<=b){k=this.getFoldLine(l,k);if(!k)h=this.$getDisplayTokens(f.stringTrimRight(c[l])),e[l]=this.$computeWrapSplits(h,g,d),l++;else{h=[],k.walk(function(a,b,d,e){var f;if(a){f=this.$getDisplayTokens(a,h.length),f[0]=i;for(var g=1;g<f.length;g++)f[g]=j}else f=this.$getDisplayTokens(c[b].substring(e,d),h.length);h=h.concat(f)}.bind(this),k.end.row,c[k.end.row].length+1);while(h.length!=0&&h[h.length-1]>=n)h.pop();e[k.start.row]=this.$computeWrapSplits(h,g,d),l=k.end.row+1}}};var b=1,c=2,i=3,j=4,l=9,n=10,o=11,p=12;this.$computeWrapSplits=function(a,b){function g(b){var d=a.slice(e,b),g=d.length;d.join("").replace(/12/g,function(){g-=1}).replace(/2/g,function(){g-=1}),f+=g,c.push(f),e=b}if(a.length==0)return[];var c=[],d=a.length,e=0,f=0;while(d-e>b){var h=e+b;if(a[h]>=n){while(a[h]>=n)h++;g(h);continue}if(a[h]==i||a[h]==j){for(h;h!=e-1;h--)if(a[h]==i)break;if(h>e){g(h);continue}h=e+b;for(h;h<a.length;h++)if(a[h]!=j)break;if(h==a.length)break;g(h);continue}var k=Math.max(h-10,e-1);while(h>k&&a[h]<i)h--;while(h>k&&a[h]==l)h--;if(h>k){g(++h);continue}h=e+b,g(h)}return c},this.$getDisplayTokens=function(a,d){var e=[],f;d=d||0;for(var g=0;g<a.length;g++){var h=a.charCodeAt(g);if(h==9){f=this.getScreenTabSize(e.length+d),e.push(o);for(var i=1;i<f;i++)e.push(p)}else h==32?e.push(n):h>39&&h<48||h>57&&h<64?e.push(l):h>=4352&&q(h)?e.push(b,c):e.push(b)}return e},this.$getStringScreenWidth=function(a,b,c){if(b==0)return[0,0];b==null&&(b=c+a.length*Math.max(this.getTabSize(),2)),c=c||0;var d,e;for(e=0;e<a.length;e++){d=a.charCodeAt(e),d==9?c+=this.getScreenTabSize(c):d>=4352&&q(d)?c+=2:c+=1;if(c>b)break}return[c,e]},this.getRowLength=function(a){return!this.$useWrapMode||!this.$wrapData[a]?1:this.$wrapData[a].length+1},this.getRowHeight=function(a,b){return this.getRowLength(b)*a.lineHeight},this.getScreenLastRowColumn=function(a){return this.documentToScreenColumn(a,this.doc.getLine(a).length)},this.getDocumentLastRowColumn=function(a,b){var c=this.documentToScreenRow(a,b);return this.getScreenLastRowColumn(c)},this.getDocumentLastRowColumnPosition=function(a,b){var c=this.documentToScreenRow(a,b);return this.screenToDocumentPosition(c,Number.MAX_VALUE/10)},this.getRowSplitData=function(a){return this.$useWrapMode?this.$wrapData[a]:undefined},this.getScreenTabSize=function(a){return this.$tabSize-a%this.$tabSize},this.screenToDocumentRow=function(a,b){return this.screenToDocumentPosition(a,b).row},this.screenToDocumentColumn=function(a,b){return this.screenToDocumentPosition(a,b).column},this.screenToDocumentPosition=function(a,b){if(a<0)return{row:0,column:0};var c,d=0,e=0,f,g=0,h=0,i=this.$rowCache;for(var j=0;j<i.length;j++){if(!(i[j].screenRow<a))break;g=i[j].screenRow,d=i[j].docRow}var k=!i.length||j==i.length,l=this.getLength()-1,m=this.getNextFoldLine(d),n=m?m.start.row:Infinity;while(g<=a){h=this.getRowLength(d);if(g+h-1>=a||d>=l)break;g+=h,d++,d>n&&(d=m.end.row+1,m=this.getNextFoldLine(d,m),n=m?m.start.row:Infinity),k&&i.push({docRow:d,screenRow:g})}if(m&&m.start.row<=d)c=this.getFoldDisplayLine(m),d=m.start.row;else{if(g+h<=a||d>l)return{row:l,column:this.getLine(l).length};c=this.getLine(d),m=null}if(this.$useWrapMode){var o=this.$wrapData[d];o&&(f=o[a-g],a>g&&o.length&&(e=o[a-g-1]||o[o.length-1],c=c.substring(e)))}return e+=this.$getStringScreenWidth(c,b)[1],this.$useWrapMode?e>=f&&(e=f-1):e=Math.min(e,c.length),m?m.idxToPosition(e):{row:d,column:e}},this.documentToScreenPosition=function(a,b){if(typeof b=="undefined")var c=this.$clipPositionToDocument(a.row,a.column);else c=this.$clipPositionToDocument(a,b);a=c.row,b=c.column;var d;if(this.$useWrapMode){d=this.$wrapData;if(a>d.length-1)return{row:this.getScreenLength(),column:d.length==0?0:d[d.length-1].length-1}}var e=0,f=null,g=null;g=this.getFoldAt(a,b,1),g&&(a=g.start.row,b=g.start.column);var h,i=0,j=this.$rowCache;for(var k=0;k<j.length;k++){if(!(j[k].docRow<a))break;e=j[k].screenRow,i=j[k].docRow}var l=!j.length||k==j.length,m=this.getNextFoldLine(i),n=m?m.start.row:Infinity;while(i<a){if(i>=n){h=m.end.row+1;if(h>a)break;m=this.getNextFoldLine(h,m),n=m?m.start.row:Infinity}else h=i+1;e+=this.getRowLength(i),i=h,l&&j.push({docRow:i,screenRow:e})}var o="";m&&i>=n?(o=this.getFoldDisplayLine(m,a,b),f=m.start.row):(o=this.getLine(a).substring(0,b),f=a);if(this.$useWrapMode){var p=d[f],q=0;while(o.length>=p[q])e++,q++;o=o.substring(p[q-1]||0,o.length)}return{row:e,column:this.$getStringScreenWidth(o)[0]}},this.documentToScreenColumn=function(a,b){return this.documentToScreenPosition(a,b).column},this.documentToScreenRow=function(a,b){return this.documentToScreenPosition(a,b).row},this.getScreenLength=function(){var a=0,b=null;if(!this.$useWrapMode){a=this.getLength();var c=this.$foldData;for(var d=0;d<c.length;d++)b=c[d],a-=b.end.row-b.start.row}else{var e=this.$wrapData.length,f=0,d=0,b=this.$foldData[d++],g=b?b.start.row:Infinity;while(f<e)a+=this.$wrapData[f].length+1,f++,f>g&&(f=b.end.row+1,b=this.$foldData[d++],g=b?b.start.row:Infinity)}return a}}).call(n.prototype),a("./edit_session/folding").Folding.call(n.prototype),a("./edit_session/bracket_match").BracketMatch.call(n.prototype),b.EditSession=n}),ace.define("ace/config",["require","exports","module","ace/lib/lang"],function(a,b,c){function g(a){return a.replace(/-(.)/g,function(a,b){return b.toUpperCase()})}"no use strict";var d=a("./lib/lang"),e=function(){return this}(),f={packaged:!1,workerPath:"",modePath:"",themePath:"",suffix:".js"};b.get=function(a){if(!f.hasOwnProperty(a))throw new Error("Unknown confik key: "+a);return f[a]},b.set=function(a,b){if(!f.hasOwnProperty(a))throw new Error("Unknown confik key: "+a);f[a]=b},b.all=function(){return d.copyObject(f)},b.init=function(){f.packaged=a.packaged||c.packaged||e.define&&define.packaged;if(!e.document)return"";var d={},h="",i,j=document.getElementsByTagName("script");for(var k=0;k<j.length;k++){var l=j[k],m=l.src||l.getAttribute("src");if(!m)continue;var n=l.attributes;for(var o=0,p=n.length;o<p;o++){var q=n[o];q.name.indexOf("data-ace-")===0&&(d[g(q.name.replace(/^data-ace-/,""))]=q.value)}var r=m.match(/^(?:(.*\/)ace\.js|(.*\/)ace((-uncompressed)?(-noconflict)?\.js))(?:\?|$)/);r&&(h=r[1]||r[2],i=r[3])}h&&(d.base=d.base||h,d.packaged=!0),d.suffix=d.suffix||i,d.workerPath=d.workerPath||d.base,d.modePath=d.modePath||d.base,d.themePath=d.themePath||d.base,delete d.base;for(var s in d)typeof d[s]!="undefined"&&b.set(s,d[s])}}),ace.define("ace/lib/net",["require","exports","module"],function(a,b,c){"use strict",b.get=function(a,c){var d=b.createXhr();d.open("GET",a,!0),d.onreadystatechange=function(a){d.readyState===4&&c(d.responseText)},d.send(null)};var d=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"];b.createXhr=function(){var a,b,c;if(typeof XMLHttpRequest!="undefined")return new XMLHttpRequest;for(b=0;b<3;b++){c=d[b];try{a=new ActiveXObject(c)}catch(e){}if(a){d=[c];break}}if(!a)throw new Error("createXhr(): XMLHttpRequest not available");return a},b.loadScript=function(a,b){var c=document.getElementsByTagName("head")[0],d=document.createElement("script");d.src=a,c.appendChild(d),d.onload=b}}),ace.define("ace/selection",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/range"],function(a,b,c){"use strict";var d=a("./lib/oop"),e=a("./lib/lang"),f=a("./lib/event_emitter").EventEmitter,g=a("./range").Range,h=function(a){this.session=a,this.doc=a.getDocument(),this.clearSelection(),this.selectionLead=this.doc.createAnchor(0,0),this.selectionAnchor=this.doc.createAnchor(0,0);var b=this;this.selectionLead.on("change",function(a){b._emit("changeCursor"),b.$isEmpty||b._emit("changeSelection"),!b.$preventUpdateDesiredColumnOnChange&&a.old.column!=a.value.column&&b.$updateDesiredColumn()}),this.selectionAnchor.on("change",function(){b.$isEmpty||b._emit("changeSelection")})};(function(){d.implement(this,f),this.isEmpty=function(){return this.$isEmpty||this.selectionAnchor.row==this.selectionLead.row&&this.selectionAnchor.column==this.selectionLead.column},this.isMultiLine=function(){return this.isEmpty()?!1:this.getRange().isMultiLine()},this.getCursor=function(){return this.selectionLead.getPosition()},this.setSelectionAnchor=function(a,b){this.selectionAnchor.setPosition(a,b),this.$isEmpty&&(this.$isEmpty=!1,this._emit("changeSelection"))},this.getSelectionAnchor=function(){return this.$isEmpty?this.getSelectionLead():this.selectionAnchor.getPosition()},this.getSelectionLead=function(){return this.selectionLead.getPosition()},this.shiftSelection=function(a){if(this.$isEmpty){this.moveCursorTo(this.selectionLead.row,this.selectionLead.column+a);return}var b=this.getSelectionAnchor(),c=this.getSelectionLead(),d=this.isBackwards();(!d||b.column!==0)&&this.setSelectionAnchor(b.row,b.column+a),(d||c.column!==0)&&this.$moveSelection(function(){this.moveCursorTo(c.row,c.column+a)})},this.isBackwards=function(){var a=this.selectionAnchor,b=this.selectionLead;return a.row>b.row||a.row==b.row&&a.column>b.column},this.getRange=function(){var a=this.selectionAnchor,b=this.selectionLead;return this.isEmpty()?g.fromPoints(b,b):this.isBackwards()?g.fromPoints(b,a):g.fromPoints(a,b)},this.clearSelection=function(){this.$isEmpty||(this.$isEmpty=!0,this._emit("changeSelection"))},this.selectAll=function(){var a=this.doc.getLength()-1;this.setSelectionAnchor(a,this.doc.getLine(a).length),this.moveCursorTo(0,0)},this.setSelectionRange=function(a,b){b?(this.setSelectionAnchor(a.end.row,a.end.column),this.selectTo(a.start.row,a.start.column)):(this.setSelectionAnchor(a.start.row,a.start.column),this.selectTo(a.end.row,a.end.column)),this.$updateDesiredColumn()},this.$updateDesiredColumn=function(){var a=this.getCursor();this.$desiredColumn=this.session.documentToScreenColumn(a.row,a.column)},this.$moveSelection=function(a){var b=this.selectionLead;this.$isEmpty&&this.setSelectionAnchor(b.row,b.column),a.call(this)},this.selectTo=function(a,b){this.$moveSelection(function(){this.moveCursorTo(a,b)})},this.selectToPosition=function(a){this.$moveSelection(function(){this.moveCursorToPosition(a)})},this.selectUp=function(){this.$moveSelection(this.moveCursorUp)},this.selectDown=function(){this.$moveSelection(this.moveCursorDown)},this.selectRight=function(){this.$moveSelection(this.moveCursorRight)},this.selectLeft=function(){this.$moveSelection(this.moveCursorLeft)},this.selectLineStart=function(){this.$moveSelection(this.moveCursorLineStart)},this.selectLineEnd=function(){this.$moveSelection(this.moveCursorLineEnd)},this.selectFileEnd=function(){this.$moveSelection(this.moveCursorFileEnd)},this.selectFileStart=function(){this.$moveSelection(this.moveCursorFileStart)},this.selectWordRight=function(){this.$moveSelection(this.moveCursorWordRight)},this.selectWordLeft=function(){this.$moveSelection(this.moveCursorWordLeft)},this.selectWord=function(){var a=this.getCursor(),b=this.session.getWordRange(a.row,a.column);this.setSelectionRange(b)},this.selectAWord=function(){var a=this.getCursor(),b=this.session.getAWordRange(a.row,a.column);this.setSelectionRange(b)},this.selectLine=function(){var a=this.selectionLead.row,b,c=this.session.getFoldLine(a);c?(a=c.start.row,b=c.end.row):b=a,this.setSelectionAnchor(a,0),this.$moveSelection(function(){this.moveCursorTo(b+1,0)})},this.moveCursorUp=function(){this.moveCursorBy(-1,0)},this.moveCursorDown=function(){this.moveCursorBy(1,0)},this.moveCursorLeft=function(){var a=this.selectionLead.getPosition(),b;if(b=this.session.getFoldAt(a.row,a.column,-1))this.moveCursorTo(b.start.row,b.start.column);else if(a.column==0)a.row>0&&this.moveCursorTo(a.row-1,this.doc.getLine(a.row-1).length);else{var c=this.session.getTabSize();this.session.isTabStop(a)&&this.doc.getLine(a.row).slice(a.column-c,a.column).split(" ").length-1==c?this.moveCursorBy(0,-c):this.moveCursorBy(0,-1)}},this.moveCursorRight=function(){var a=this.selectionLead.getPosition(),b;if(b=this.session.getFoldAt(a.row,a.column,1))this.moveCursorTo(b.end.row,b.end.column);else if(this.selectionLead.column==this.doc.getLine(this.selectionLead.row).length)this.selectionLead.row<this.doc.getLength()-1&&this.moveCursorTo(this.selectionLead.row+1,0);else{var c=this.session.getTabSize(),a=this.selectionLead;this.session.isTabStop(a)&&this.doc.getLine(a.row).slice(a.column,a.column+c).split(" ").length-1==c?this.moveCursorBy(0,c):this.moveCursorBy(0,1)}},this.moveCursorLineStart=function(){var a=this.selectionLead.row,b=this.selectionLead.column,c=this.session.documentToScreenRow(a,b),d=this.session.screenToDocumentPosition(c,0),e=this.session.getDisplayLine(a,null,d.row,d.column),f=e.match(/^\s*/);f[0].length==b?this.moveCursorTo(d.row,d.column):this.moveCursorTo(d.row,d.column+f[0].length)},this.moveCursorLineEnd=function(){var a=this.selectionLead,b=this.session.getDocumentLastRowColumnPosition(a.row,a.column);this.moveCursorTo(b.row,b.column)},this.moveCursorFileEnd=function(){var a=this.doc.getLength()-1,b=this.doc.getLine(a).length;this.moveCursorTo(a,b)},this.moveCursorFileStart=function(){this.moveCursorTo(0,0)},this.moveCursorWordRight=function(){var a=this.selectionLead.row,b=this.selectionLead.column,c=this.doc.getLine(a),d=c.substring(b),e;this.session.nonTokenRe.lastIndex=0,this.session.tokenRe.lastIndex=0;var f=this.session.getFoldAt(a,b,1);if(f){this.moveCursorTo(f.end.row,f.end.column);return}if(e=this.session.nonTokenRe.exec(d))b+=this.session.nonTokenRe.lastIndex,this.session.nonTokenRe.lastIndex=0,d=c.substring(b);if(b>=c.length){this.moveCursorTo(a,c.length),this.moveCursorRight(),a<this.doc.getLength()-1&&this.moveCursorWordRight();return}if(e=this.session.tokenRe.exec(d))b+=this.session.tokenRe.lastIndex,this.session.tokenRe.lastIndex=0;this.moveCursorTo(a,b)},this.moveCursorWordLeft=function(){var a=this.selectionLead.row,b=this.selectionLead.column,c;if(c=this.session.getFoldAt(a,b,-1)){this.moveCursorTo(c.start.row,c.start.column);return}var d=this.session.getFoldStringAt(a,b,-1);d==null&&(d=this.doc.getLine(a).substring(0,b));var f=e.stringReverse(d),g;this.session.nonTokenRe.lastIndex=0,this.session.tokenRe.lastIndex=0;if(g=this.session.nonTokenRe.exec(f))b-=this.session.nonTokenRe.lastIndex,f=f.slice(this.session.nonTokenRe.lastIndex),this.session.nonTokenRe.lastIndex=0;if(b<=0){this.moveCursorTo(a,0),this.moveCursorLeft(),a>0&&this.moveCursorWordLeft();return}if(g=this.session.tokenRe.exec(f))b-=this.session.tokenRe.lastIndex,this.session.tokenRe.lastIndex=0;this.moveCursorTo(a,b)},this.moveCursorBy=function(a,b){var c=this.session.documentToScreenPosition(this.selectionLead.row,this.selectionLead.column),d=b===0&&this.$desiredColumn||c.column,e=this.session.screenToDocumentPosition(c.row+a,d);this.moveCursorTo(e.row,e.column+b,b===0)},this.moveCursorToPosition=function(a){this.moveCursorTo(a.row,a.column)},this.moveCursorTo=function(a,b,c){var d=this.session.getFoldAt(a,b,1);d&&(a=d.start.row,b=d.start.column),this.$preventUpdateDesiredColumnOnChange=!0,this.selectionLead.setPosition(a,b),this.$preventUpdateDesiredColumnOnChange=!1,c||this.$updateDesiredColumn(this.selectionLead.column)},this.moveCursorToScreen=function(a,b,c){var d=this.session.screenToDocumentPosition(a,b);a=d.row,b=d.column,this.moveCursorTo(a,b,c)}}).call(h.prototype),b.Selection=h}),ace.define("ace/range",["require","exports","module"],function(a,b,c){"use strict";var d=function(a,b,c,d){this.start={row:a,column:b},this.end={row:c,column:d}};(function(){this.isEequal=function(a){return this.start.row==a.start.row&&this.end.row==a.end.row&&this.start.column==a.start.column&&this.end.column==a.end.column},this.toString=function(){return"Range: ["+this.start.row+"/"+this.start.column+"] -> ["+this.end.row+"/"+this.end.column+"]"},this.contains=function(a,b){return this.compare(a,b)==0},this.compareRange=function(a){var b,c=a.end,d=a.start;return b=this.compare(c.row,c.column),b==1?(b=this.compare(d.row,d.column),b==1?2:b==0?1:0):b==-1?-2:(b=this.compare(d.row,d.column),b==-1?-1:b==1?42:0)},this.comparePoint=function(a){return this.compare(a.row,a.column)},this.containsRange=function(a){return this.comparePoint(a.start)==0&&this.comparePoint(a.end)==0},this.isEnd=function(a,b){return this.end.row==a&&this.end.column==b},this.isStart=function(a,b){return this.start.row==a&&this.start.column==b},this.setStart=function(a,b){typeof a=="object"?(this.start.column=a.column,this.start.row=a.row):(this.start.row=a,this.start.column=b)},this.setEnd=function(a,b){typeof a=="object"?(this.end.column=a.column,this.end.row=a.row):(this.end.row=a,this.end.column=b)},this.inside=function(a,b){return this.compare(a,b)==0?this.isEnd(a,b)||this.isStart(a,b)?!1:!0:!1},this.insideStart=function(a,b){return this.compare(a,b)==0?this.isEnd(a,b)?!1:!0:!1},this.insideEnd=function(a,b){return this.compare(a,b)==0?this.isStart(a,b)?!1:!0:!1},this.compare=function(a,b){return!this.isMultiLine()&&a===this.start.row?b<this.start.column?-1:b>this.end.column?1:0:a<this.start.row?-1:a>this.end.row?1:this.start.row===a?b>=this.start.column?0:-1:this.end.row===a?b<=this.end.column?0:1:0},this.compareStart=function(a,b){return this.start.row==a&&this.start.column==b?-1:this.compare(a,b)},this.compareEnd=function(a,b){return this.end.row==a&&this.end.column==b?1:this.compare(a,b)},this.compareInside=function(a,b){return this.end.row==a&&this.end.column==b?1:this.start.row==a&&this.start.column==b?-1:this.compare(a,b)},this.clipRows=function(a,b){if(this.end.row>b)var c={row:b+1,column:0};if(this.start.row>b)var e={row:b+1,column:0};if(this.start.row<a)var e={row:a,column:0};if(this.end.row<a)var c={row:a,column:0};return d.fromPoints(e||this.start,c||this.end)},this.extend=function(a,b){var c=this.compare(a,b);if(c==0)return this;if(c==-1)var e={row:a,column:b};else var f={row:a,column:b};return d.fromPoints(e||this.start,f||this.end)},this.isEmpty=function(){return this.start.row==this.end.row&&this.start.column==this.end.column},this.isMultiLine=function(){return this.start.row!==this.end.row},this.clone=function(){return d.fromPoints(this.start,this.end)},this.collapseRows=function(){return this.end.column==0?new d(this.start.row,0,Math.max(this.start.row,this.end.row-1),0):new d(this.start.row,0,this.end.row,0)},this.toScreenRange=function(a){var b=a.documentToScreenPosition(this.start),c=a.documentToScreenPosition(this.end);return new d(b.row,b.column,c.row,c.column)}}).call(d.prototype),d.fromPoints=function(a,b){return new d(a.row,a.column,b.row,b.column)},b.Range=d}),ace.define("ace/mode/text",["require","exports","module","ace/tokenizer","ace/mode/text_highlight_rules","ace/mode/behaviour","ace/unicode"],function(a,b,c){"use strict";var d=a("../tokenizer").Tokenizer,e=a("./text_highlight_rules").TextHighlightRules,f=a("./behaviour").Behaviour,g=a("../unicode"),h=function(){this.$tokenizer=new d((new e).getRules()),this.$behaviour=new f};(function(){this.tokenRe=new RegExp("^["+g.packages.L+g.packages.Mn+g.packages.Mc+g.packages.Nd+g.packages.Pc+"\\$_]+","g"),this.nonTokenRe=new RegExp("^(?:[^"+g.packages.L+g.packages.Mn+g.packages.Mc+g.packages.Nd+g.packages.Pc+"\\$_]|s])+","g"),this.getTokenizer=function(){return this.$tokenizer},this.toggleCommentLines=function(a,b,c,d){},this.getNextLineIndent=function(a,b,c){return""},this.checkOutdent=function(a,b,c){return!1},this.autoOutdent=function(a,b,c){},this.$getIndent=function(a){var b=a.match(/^(\s+)/);return b?b[1]:""},this.createWorker=function(a){return null},this.highlightSelection=function(a){var b=a.session;b.$selectionOccurrences||(b.$selectionOccurrences=[]),b.$selectionOccurrences.length&&this.clearSelectionHighlight(a);var c=a.getSelectionRange();if(c.isEmpty()||c.isMultiLine())return;var d=c.start.column-1,e=c.end.column+1,f=b.getLine(c.start.row),g=f.length,h=f.substring(Math.max(d,0),Math.min(e,g));if(d>=0&&/^[\w\d]/.test(h)||e<=g&&/[\w\d]$/.test(h))return;h=f.substring(c.start.column,c.end.column);if(!/^[\w\d]+$/.test(h))return;var i=a.getCursorPosition(),j={wrap:!0,wholeWord:!0,caseSensitive:!0,needle:h},k=a.$search.getOptions();a.$search.set(j);var l=a.$search.findAll(b);l.forEach(function(a){if(!a.contains(i.row,i.column)){var c=b.addMarker(a,"ace_selected_word","text");b.$selectionOccurrences.push(c)}}),a.$search.set(k)},this.clearSelectionHighlight=function(a){if(!a.session.$selectionOccurrences)return;a.session.$selectionOccurrences.forEach(function(b){a.session.removeMarker(b)}),a.session.$selectionOccurrences=[]},this.createModeDelegates=function(a){if(!this.$embeds)return;this.$modes={};for(var b=0;b<this.$embeds.length;b++)a[this.$embeds[b]]&&(this.$modes[this.$embeds[b]]=new a[this.$embeds[b]]);var c=["toggleCommentLines","getNextLineIndent","checkOutdent","autoOutdent","transformAction"];for(var b=0;b<c.length;b++)(function(a){var d=c[b],e=a[d];a[c[b]]=function(){return this.$delegator(d,arguments,e)}})(this)},this.$delegator=function(a,b,c){var d=b[0];for(var e=0;e<this.$embeds.length;e++){if(!this.$modes[this.$embeds[e]])continue;var f=d.split(this.$embeds[e]);if(!f[0]&&f[1]){b[0]=f[1];var g=this.$modes[this.$embeds[e]];return g[a].apply(g,b)}}var h=c.apply(this,b);return c?h:undefined},this.transformAction=function(a,b,c,d,e){if(this.$behaviour){var f=this.$behaviour.getBehaviours();for(var g in f)if(f[g][b]){var h=f[g][b].apply(this,arguments);if(h)return h}}}}).call(h.prototype),b.Mode=h}),ace.define("ace/tokenizer",["require","exports","module"],function(a,b,c){"use strict";var d=function(a,b){b=b?"g"+b:"g",this.rules=a,this.regExps={},this.matchMappings={};for(var c in this.rules){var d=this.rules[c],e=d,f=[],g=0,h=this.matchMappings[c]={};for(var i=0;i<e.length;i++){e[i].regex instanceof RegExp&&(e[i].regex=e[i].regex.toString().slice(1,-1));var j=(new RegExp("(?:("+e[i].regex+")|(.))")).exec("a").length-2,k=e[i].regex.replace(/\\([0-9]+)/g,function(a,b){return"\\"+(parseInt(b,10)+g+1)});if(j>1&&e[i].token.length!==j-1)throw new Error("Matching groups and length of the token array don't match in rule #"+i+" of state "+c);h[g]={rule:i,len:j},g+=j,f.push(k)}this.regExps[c]=new RegExp("(?:("+f.join(")|(")+")|(.))",b)}};(function(){this.getLineTokens=function(a,b){var c=b,d=this.rules[c],e=this.matchMappings[c],f=this.regExps[c];f.lastIndex=0;var g,h=[],i=0,j={type:null,value:""};while(g=f.exec(a)){var k="text",l=null,m=[g[0]];for(var n=0;n<g.length-2;n++){if(g[n+1]===undefined)continue;l=d[e[n].rule],e[n].len>1&&(m=g.slice(n+2,n+1+e[n].len)),typeof l.token=="function"?k=l.token.apply(this,m):k=l.token;var o=l.next;o&&o!==c&&(c=o,d=this.rules[c],e=this.matchMappings[c],i=f.lastIndex,f=this.regExps[c],f.lastIndex=i);break}if(m[0]){typeof k=="string"&&(m=[m.join("")],k=[k]);for(var n=0;n<m.length;n++){if(!m[n])continue;(!l||l.merge||k[n]==="text")&&j.type===k[n]?j.value+=m[n]:(j.type&&h.push(j),j={type:k[n],value:m[n]})}}if(i==a.length)break;i=f.lastIndex}return j.type&&h.push(j),{tokens:h,state:c}}}).call(d.prototype),b.Tokenizer=d}),ace.define("ace/mode/text_highlight_rules",["require","exports","module","ace/lib/lang"],function(a,b,c){"use strict";var d=a("../lib/lang"),e=function(){this.$rules={start:[{token:"empty_line",regex:"^$"},{token:"text",regex:".+"}]}};(function(){this.addRules=function(a,b){for(var c in a){var d=a[c];for(var e=0;e<d.length;e++){var f=d[e];f.next?f.next=b+f.next:f.next=b+c}this.$rules[b+c]=d}},this.getRules=function(){return this.$rules},this.embedRules=function(a,b,c,e){var f=(new a).getRules();if(e)for(var g=0;g<e.length;g++)e[g]=b+e[g];else{e=[];for(var h in f)e.push(b+h)}this.addRules(f,b);for(var g=0;g<e.length;g++)Array.prototype.unshift.apply(this.$rules[e[g]],d.deepCopy(c));this.$embeds||(this.$embeds=[]),this.$embeds.push(b)},this.getEmbeds=function(){return this.$embeds}}).call(e.prototype),b.TextHighlightRules=e}),ace.define("ace/mode/behaviour",["require","exports","module"],function(a,b,c){"use strict";var d=function(){this.$behaviours={}};(function(){this.add=function(a,b,c){switch(undefined){case this.$behaviours:this.$behaviours={};case this.$behaviours[a]:this.$behaviours[a]={}}this.$behaviours[a][b]=c},this.addBehaviours=function(a){for(var b in a)for(var c in a[b])this.add(b,c,a[b][c])},this.remove=function(a){this.$behaviours&&this.$behaviours[a]&&delete this.$behaviours[a]},this.inherit=function(a,b){if(typeof a=="function")var c=(new a).getBehaviours(b);else var c=a.getBehaviours(b);this.addBehaviours(c)},this.getBehaviours=function(a){if(!a)return this.$behaviours;var b={};for(var c=0;c<a.length;c++)this.$behaviours[a[c]]&&(b[a[c]]=this.$behaviours[a[c]]);return b}}).call(d.prototype),b.Behaviour=d}),ace.define("ace/unicode",["require","exports","module"],function(a,b,c){function d(a){var c=/\w{4}/g;for(var d in a)b.packages[d]=a[d].replace(c,"\\u$&")}"use strict",b.packages={},d({L:"0041-005A0061-007A00AA00B500BA00C0-00D600D8-00F600F8-02C102C6-02D102E0-02E402EC02EE0370-037403760377037A-037D03860388-038A038C038E-03A103A3-03F503F7-0481048A-05250531-055605590561-058705D0-05EA05F0-05F20621-064A066E066F0671-06D306D506E506E606EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA07F407F507FA0800-0815081A082408280904-0939093D09500958-0961097109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E460E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EC60EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10A0-10C510D0-10FA10FC1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317D717DC1820-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541AA71B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C7D1CE9-1CEC1CEE-1CF11D00-1DBF1E00-1F151F18-1F1D1F20-1F451F48-1F4D1F50-1F571F591F5B1F5D1F5F-1F7D1F80-1FB41FB6-1FBC1FBE1FC2-1FC41FC6-1FCC1FD0-1FD31FD6-1FDB1FE0-1FEC1FF2-1FF41FF6-1FFC2071207F2090-209421022107210A-211321152119-211D212421262128212A-212D212F-2139213C-213F2145-2149214E218321842C00-2C2E2C30-2C5E2C60-2CE42CEB-2CEE2D00-2D252D30-2D652D6F2D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE2E2F300530063031-3035303B303C3041-3096309D-309F30A1-30FA30FC-30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A48CA4D0-A4FDA500-A60CA610-A61FA62AA62BA640-A65FA662-A66EA67F-A697A6A0-A6E5A717-A71FA722-A788A78BA78CA7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2A9CFAA00-AA28AA40-AA42AA44-AA4BAA60-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADB-AADDABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB00-FB06FB13-FB17FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF21-FF3AFF41-FF5AFF66-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC",Ll:"0061-007A00AA00B500BA00DF-00F600F8-00FF01010103010501070109010B010D010F01110113011501170119011B011D011F01210123012501270129012B012D012F01310133013501370138013A013C013E014001420144014601480149014B014D014F01510153015501570159015B015D015F01610163016501670169016B016D016F0171017301750177017A017C017E-0180018301850188018C018D019201950199-019B019E01A101A301A501A801AA01AB01AD01B001B401B601B901BA01BD-01BF01C601C901CC01CE01D001D201D401D601D801DA01DC01DD01DF01E101E301E501E701E901EB01ED01EF01F001F301F501F901FB01FD01FF02010203020502070209020B020D020F02110213021502170219021B021D021F02210223022502270229022B022D022F02310233-0239023C023F0240024202470249024B024D024F-02930295-02AF037103730377037B-037D039003AC-03CE03D003D103D5-03D703D903DB03DD03DF03E103E303E503E703E903EB03ED03EF-03F303F503F803FB03FC0430-045F04610463046504670469046B046D046F04710473047504770479047B047D047F0481048B048D048F04910493049504970499049B049D049F04A104A304A504A704A904AB04AD04AF04B104B304B504B704B904BB04BD04BF04C204C404C604C804CA04CC04CE04CF04D104D304D504D704D904DB04DD04DF04E104E304E504E704E904EB04ED04EF04F104F304F504F704F904FB04FD04FF05010503050505070509050B050D050F05110513051505170519051B051D051F0521052305250561-05871D00-1D2B1D62-1D771D79-1D9A1E011E031E051E071E091E0B1E0D1E0F1E111E131E151E171E191E1B1E1D1E1F1E211E231E251E271E291E2B1E2D1E2F1E311E331E351E371E391E3B1E3D1E3F1E411E431E451E471E491E4B1E4D1E4F1E511E531E551E571E591E5B1E5D1E5F1E611E631E651E671E691E6B1E6D1E6F1E711E731E751E771E791E7B1E7D1E7F1E811E831E851E871E891E8B1E8D1E8F1E911E931E95-1E9D1E9F1EA11EA31EA51EA71EA91EAB1EAD1EAF1EB11EB31EB51EB71EB91EBB1EBD1EBF1EC11EC31EC51EC71EC91ECB1ECD1ECF1ED11ED31ED51ED71ED91EDB1EDD1EDF1EE11EE31EE51EE71EE91EEB1EED1EEF1EF11EF31EF51EF71EF91EFB1EFD1EFF-1F071F10-1F151F20-1F271F30-1F371F40-1F451F50-1F571F60-1F671F70-1F7D1F80-1F871F90-1F971FA0-1FA71FB0-1FB41FB61FB71FBE1FC2-1FC41FC61FC71FD0-1FD31FD61FD71FE0-1FE71FF2-1FF41FF61FF7210A210E210F2113212F21342139213C213D2146-2149214E21842C30-2C5E2C612C652C662C682C6A2C6C2C712C732C742C76-2C7C2C812C832C852C872C892C8B2C8D2C8F2C912C932C952C972C992C9B2C9D2C9F2CA12CA32CA52CA72CA92CAB2CAD2CAF2CB12CB32CB52CB72CB92CBB2CBD2CBF2CC12CC32CC52CC72CC92CCB2CCD2CCF2CD12CD32CD52CD72CD92CDB2CDD2CDF2CE12CE32CE42CEC2CEE2D00-2D25A641A643A645A647A649A64BA64DA64FA651A653A655A657A659A65BA65DA65FA663A665A667A669A66BA66DA681A683A685A687A689A68BA68DA68FA691A693A695A697A723A725A727A729A72BA72DA72F-A731A733A735A737A739A73BA73DA73FA741A743A745A747A749A74BA74DA74FA751A753A755A757A759A75BA75DA75FA761A763A765A767A769A76BA76DA76FA771-A778A77AA77CA77FA781A783A785A787A78CFB00-FB06FB13-FB17FF41-FF5A",Lu:"0041-005A00C0-00D600D8-00DE01000102010401060108010A010C010E01100112011401160118011A011C011E01200122012401260128012A012C012E01300132013401360139013B013D013F0141014301450147014A014C014E01500152015401560158015A015C015E01600162016401660168016A016C016E017001720174017601780179017B017D018101820184018601870189-018B018E-0191019301940196-0198019C019D019F01A001A201A401A601A701A901AC01AE01AF01B1-01B301B501B701B801BC01C401C701CA01CD01CF01D101D301D501D701D901DB01DE01E001E201E401E601E801EA01EC01EE01F101F401F6-01F801FA01FC01FE02000202020402060208020A020C020E02100212021402160218021A021C021E02200222022402260228022A022C022E02300232023A023B023D023E02410243-02460248024A024C024E03700372037603860388-038A038C038E038F0391-03A103A3-03AB03CF03D2-03D403D803DA03DC03DE03E003E203E403E603E803EA03EC03EE03F403F703F903FA03FD-042F04600462046404660468046A046C046E04700472047404760478047A047C047E0480048A048C048E04900492049404960498049A049C049E04A004A204A404A604A804AA04AC04AE04B004B204B404B604B804BA04BC04BE04C004C104C304C504C704C904CB04CD04D004D204D404D604D804DA04DC04DE04E004E204E404E604E804EA04EC04EE04F004F204F404F604F804FA04FC04FE05000502050405060508050A050C050E05100512051405160518051A051C051E0520052205240531-055610A0-10C51E001E021E041E061E081E0A1E0C1E0E1E101E121E141E161E181E1A1E1C1E1E1E201E221E241E261E281E2A1E2C1E2E1E301E321E341E361E381E3A1E3C1E3E1E401E421E441E461E481E4A1E4C1E4E1E501E521E541E561E581E5A1E5C1E5E1E601E621E641E661E681E6A1E6C1E6E1E701E721E741E761E781E7A1E7C1E7E1E801E821E841E861E881E8A1E8C1E8E1E901E921E941E9E1EA01EA21EA41EA61EA81EAA1EAC1EAE1EB01EB21EB41EB61EB81EBA1EBC1EBE1EC01EC21EC41EC61EC81ECA1ECC1ECE1ED01ED21ED41ED61ED81EDA1EDC1EDE1EE01EE21EE41EE61EE81EEA1EEC1EEE1EF01EF21EF41EF61EF81EFA1EFC1EFE1F08-1F0F1F18-1F1D1F28-1F2F1F38-1F3F1F48-1F4D1F591F5B1F5D1F5F1F68-1F6F1FB8-1FBB1FC8-1FCB1FD8-1FDB1FE8-1FEC1FF8-1FFB21022107210B-210D2110-211221152119-211D212421262128212A-212D2130-2133213E213F214521832C00-2C2E2C602C62-2C642C672C692C6B2C6D-2C702C722C752C7E-2C802C822C842C862C882C8A2C8C2C8E2C902C922C942C962C982C9A2C9C2C9E2CA02CA22CA42CA62CA82CAA2CAC2CAE2CB02CB22CB42CB62CB82CBA2CBC2CBE2CC02CC22CC42CC62CC82CCA2CCC2CCE2CD02CD22CD42CD62CD82CDA2CDC2CDE2CE02CE22CEB2CEDA640A642A644A646A648A64AA64CA64EA650A652A654A656A658A65AA65CA65EA662A664A666A668A66AA66CA680A682A684A686A688A68AA68CA68EA690A692A694A696A722A724A726A728A72AA72CA72EA732A734A736A738A73AA73CA73EA740A742A744A746A748A74AA74CA74EA750A752A754A756A758A75AA75CA75EA760A762A764A766A768A76AA76CA76EA779A77BA77DA77EA780A782A784A786A78BFF21-FF3A",Lt:"01C501C801CB01F21F88-1F8F1F98-1F9F1FA8-1FAF1FBC1FCC1FFC",Lm:"02B0-02C102C6-02D102E0-02E402EC02EE0374037A0559064006E506E607F407F507FA081A0824082809710E460EC610FC17D718431AA71C78-1C7D1D2C-1D611D781D9B-1DBF2071207F2090-20942C7D2D6F2E2F30053031-3035303B309D309E30FC-30FEA015A4F8-A4FDA60CA67FA717-A71FA770A788A9CFAA70AADDFF70FF9EFF9F",Lo:"01BB01C0-01C3029405D0-05EA05F0-05F20621-063F0641-064A066E066F0671-06D306D506EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA0800-08150904-0939093D09500958-096109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E450E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10D0-10FA1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317DC1820-18421844-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C771CE9-1CEC1CEE-1CF12135-21382D30-2D652D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE3006303C3041-3096309F30A1-30FA30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A014A016-A48CA4D0-A4F7A500-A60BA610-A61FA62AA62BA66EA6A0-A6E5A7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2AA00-AA28AA40-AA42AA44-AA4BAA60-AA6FAA71-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADBAADCABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF66-FF6FFF71-FF9DFFA0-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC",M:"0300-036F0483-04890591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DE-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0903093C093E-094E0951-0955096209630981-098309BC09BE-09C409C709C809CB-09CD09D709E209E30A01-0A030A3C0A3E-0A420A470A480A4B-0A4D0A510A700A710A750A81-0A830ABC0ABE-0AC50AC7-0AC90ACB-0ACD0AE20AE30B01-0B030B3C0B3E-0B440B470B480B4B-0B4D0B560B570B620B630B820BBE-0BC20BC6-0BC80BCA-0BCD0BD70C01-0C030C3E-0C440C46-0C480C4A-0C4D0C550C560C620C630C820C830CBC0CBE-0CC40CC6-0CC80CCA-0CCD0CD50CD60CE20CE30D020D030D3E-0D440D46-0D480D4A-0D4D0D570D620D630D820D830DCA0DCF-0DD40DD60DD8-0DDF0DF20DF30E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F3E0F3F0F71-0F840F860F870F90-0F970F99-0FBC0FC6102B-103E1056-1059105E-10601062-10641067-106D1071-10741082-108D108F109A-109D135F1712-17141732-1734175217531772177317B6-17D317DD180B-180D18A91920-192B1930-193B19B0-19C019C819C91A17-1A1B1A55-1A5E1A60-1A7C1A7F1B00-1B041B34-1B441B6B-1B731B80-1B821BA1-1BAA1C24-1C371CD0-1CD21CD4-1CE81CED1CF21DC0-1DE61DFD-1DFF20D0-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66F-A672A67CA67DA6F0A6F1A802A806A80BA823-A827A880A881A8B4-A8C4A8E0-A8F1A926-A92DA947-A953A980-A983A9B3-A9C0AA29-AA36AA43AA4CAA4DAA7BAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE3-ABEAABECABEDFB1EFE00-FE0FFE20-FE26",Mn:"0300-036F0483-04870591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DF-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0902093C0941-0948094D0951-095509620963098109BC09C1-09C409CD09E209E30A010A020A3C0A410A420A470A480A4B-0A4D0A510A700A710A750A810A820ABC0AC1-0AC50AC70AC80ACD0AE20AE30B010B3C0B3F0B41-0B440B4D0B560B620B630B820BC00BCD0C3E-0C400C46-0C480C4A-0C4D0C550C560C620C630CBC0CBF0CC60CCC0CCD0CE20CE30D41-0D440D4D0D620D630DCA0DD2-0DD40DD60E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F71-0F7E0F80-0F840F860F870F90-0F970F99-0FBC0FC6102D-10301032-10371039103A103D103E10581059105E-10601071-1074108210851086108D109D135F1712-17141732-1734175217531772177317B7-17BD17C617C9-17D317DD180B-180D18A91920-19221927192819321939-193B1A171A181A561A58-1A5E1A601A621A65-1A6C1A73-1A7C1A7F1B00-1B031B341B36-1B3A1B3C1B421B6B-1B731B801B811BA2-1BA51BA81BA91C2C-1C331C361C371CD0-1CD21CD4-1CE01CE2-1CE81CED1DC0-1DE61DFD-1DFF20D0-20DC20E120E5-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66FA67CA67DA6F0A6F1A802A806A80BA825A826A8C4A8E0-A8F1A926-A92DA947-A951A980-A982A9B3A9B6-A9B9A9BCAA29-AA2EAA31AA32AA35AA36AA43AA4CAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE5ABE8ABEDFB1EFE00-FE0FFE20-FE26",Mc:"0903093E-09400949-094C094E0982098309BE-09C009C709C809CB09CC09D70A030A3E-0A400A830ABE-0AC00AC90ACB0ACC0B020B030B3E0B400B470B480B4B0B4C0B570BBE0BBF0BC10BC20BC6-0BC80BCA-0BCC0BD70C01-0C030C41-0C440C820C830CBE0CC0-0CC40CC70CC80CCA0CCB0CD50CD60D020D030D3E-0D400D46-0D480D4A-0D4C0D570D820D830DCF-0DD10DD8-0DDF0DF20DF30F3E0F3F0F7F102B102C10311038103B103C105610571062-10641067-106D108310841087-108C108F109A-109C17B617BE-17C517C717C81923-19261929-192B193019311933-193819B0-19C019C819C91A19-1A1B1A551A571A611A631A641A6D-1A721B041B351B3B1B3D-1B411B431B441B821BA11BA61BA71BAA1C24-1C2B1C341C351CE11CF2A823A824A827A880A881A8B4-A8C3A952A953A983A9B4A9B5A9BAA9BBA9BD-A9C0AA2FAA30AA33AA34AA4DAA7BABE3ABE4ABE6ABE7ABE9ABEAABEC",Me:"0488048906DE20DD-20E020E2-20E4A670-A672",N:"0030-003900B200B300B900BC-00BE0660-066906F0-06F907C0-07C90966-096F09E6-09EF09F4-09F90A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BF20C66-0C6F0C78-0C7E0CE6-0CEF0D66-0D750E50-0E590ED0-0ED90F20-0F331040-10491090-10991369-137C16EE-16F017E0-17E917F0-17F91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C5920702074-20792080-20892150-21822185-21892460-249B24EA-24FF2776-27932CFD30073021-30293038-303A3192-31953220-32293251-325F3280-328932B1-32BFA620-A629A6E6-A6EFA830-A835A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19",Nd:"0030-00390660-066906F0-06F907C0-07C90966-096F09E6-09EF0A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BEF0C66-0C6F0CE6-0CEF0D66-0D6F0E50-0E590ED0-0ED90F20-0F291040-10491090-109917E0-17E91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C59A620-A629A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19",Nl:"16EE-16F02160-21822185-218830073021-30293038-303AA6E6-A6EF",No:"00B200B300B900BC-00BE09F4-09F90BF0-0BF20C78-0C7E0D70-0D750F2A-0F331369-137C17F0-17F920702074-20792080-20892150-215F21892460-249B24EA-24FF2776-27932CFD3192-31953220-32293251-325F3280-328932B1-32BFA830-A835",P:"0021-00230025-002A002C-002F003A003B003F0040005B-005D005F007B007D00A100AB00B700BB00BF037E0387055A-055F0589058A05BE05C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F3A-0F3D0F850FD0-0FD4104A-104F10FB1361-13681400166D166E169B169C16EB-16ED1735173617D4-17D617D8-17DA1800-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD32010-20272030-20432045-20512053-205E207D207E208D208E2329232A2768-277527C527C627E6-27EF2983-299829D8-29DB29FC29FD2CF9-2CFC2CFE2CFF2E00-2E2E2E302E313001-30033008-30113014-301F3030303D30A030FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFD3EFD3FFE10-FE19FE30-FE52FE54-FE61FE63FE68FE6AFE6BFF01-FF03FF05-FF0AFF0C-FF0FFF1AFF1BFF1FFF20FF3B-FF3DFF3FFF5BFF5DFF5F-FF65",Pd:"002D058A05BE140018062010-20152E172E1A301C303030A0FE31FE32FE58FE63FF0D",Ps:"0028005B007B0F3A0F3C169B201A201E2045207D208D23292768276A276C276E27702772277427C527E627E827EA27EC27EE2983298529872989298B298D298F299129932995299729D829DA29FC2E222E242E262E283008300A300C300E3010301430163018301A301DFD3EFE17FE35FE37FE39FE3BFE3DFE3FFE41FE43FE47FE59FE5BFE5DFF08FF3BFF5BFF5FFF62",Pe:"0029005D007D0F3B0F3D169C2046207E208E232A2769276B276D276F27712773277527C627E727E927EB27ED27EF298429862988298A298C298E2990299229942996299829D929DB29FD2E232E252E272E293009300B300D300F3011301530173019301B301E301FFD3FFE18FE36FE38FE3AFE3CFE3EFE40FE42FE44FE48FE5AFE5CFE5EFF09FF3DFF5DFF60FF63",Pi:"00AB2018201B201C201F20392E022E042E092E0C2E1C2E20",Pf:"00BB2019201D203A2E032E052E0A2E0D2E1D2E21",Pc:"005F203F20402054FE33FE34FE4D-FE4FFF3F",Po:"0021-00230025-0027002A002C002E002F003A003B003F0040005C00A100B700BF037E0387055A-055F058905C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F850FD0-0FD4104A-104F10FB1361-1368166D166E16EB-16ED1735173617D4-17D617D8-17DA1800-18051807-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD3201620172020-20272030-2038203B-203E2041-20432047-205120532055-205E2CF9-2CFC2CFE2CFF2E002E012E06-2E082E0B2E0E-2E162E182E192E1B2E1E2E1F2E2A-2E2E2E302E313001-3003303D30FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFE10-FE16FE19FE30FE45FE46FE49-FE4CFE50-FE52FE54-FE57FE5F-FE61FE68FE6AFE6BFF01-FF03FF05-FF07FF0AFF0CFF0EFF0FFF1AFF1BFF1FFF20FF3CFF61FF64FF65",S:"0024002B003C-003E005E0060007C007E00A2-00A900AC00AE-00B100B400B600B800D700F702C2-02C502D2-02DF02E5-02EB02ED02EF-02FF03750384038503F604820606-0608060B060E060F06E906FD06FE07F609F209F309FA09FB0AF10B700BF3-0BFA0C7F0CF10CF20D790E3F0F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-139917DB194019E0-19FF1B61-1B6A1B74-1B7C1FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE20442052207A-207C208A-208C20A0-20B8210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B2140-2144214A-214D214F2190-2328232B-23E82400-24262440-244A249C-24E92500-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE27C0-27C427C7-27CA27CC27D0-27E527F0-29822999-29D729DC-29FB29FE-2B4C2B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F309B309C319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A700-A716A720A721A789A78AA828-A82BA836-A839AA77-AA79FB29FDFCFDFDFE62FE64-FE66FE69FF04FF0BFF1C-FF1EFF3EFF40FF5CFF5EFFE0-FFE6FFE8-FFEEFFFCFFFD",Sm:"002B003C-003E007C007E00AC00B100D700F703F60606-060820442052207A-207C208A-208C2140-2144214B2190-2194219A219B21A021A321A621AE21CE21CF21D221D421F4-22FF2308-230B23202321237C239B-23B323DC-23E125B725C125F8-25FF266F27C0-27C427C7-27CA27CC27D0-27E527F0-27FF2900-29822999-29D729DC-29FB29FE-2AFF2B30-2B442B47-2B4CFB29FE62FE64-FE66FF0BFF1C-FF1EFF5CFF5EFFE2FFE9-FFEC",Sc:"002400A2-00A5060B09F209F309FB0AF10BF90E3F17DB20A0-20B8A838FDFCFE69FF04FFE0FFE1FFE5FFE6",Sk:"005E006000A800AF00B400B802C2-02C502D2-02DF02E5-02EB02ED02EF-02FF0375038403851FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE309B309CA700-A716A720A721A789A78AFF3EFF40FFE3",So:"00A600A700A900AE00B000B60482060E060F06E906FD06FE07F609FA0B700BF3-0BF80BFA0C7F0CF10CF20D790F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-1399194019E0-19FF1B61-1B6A1B74-1B7C210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B214A214C214D214F2195-2199219C-219F21A121A221A421A521A7-21AD21AF-21CD21D021D121D321D5-21F32300-2307230C-231F2322-2328232B-237B237D-239A23B4-23DB23E2-23E82400-24262440-244A249C-24E92500-25B625B8-25C025C2-25F72600-266E2670-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE2800-28FF2B00-2B2F2B452B462B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A828-A82BA836A837A839AA77-AA79FDFDFFE4FFE8FFEDFFEEFFFCFFFD",Z:"002000A01680180E2000-200A20282029202F205F3000",Zs:"002000A01680180E2000-200A202F205F3000",Zl:"2028",Zp:"2029",C:"0000-001F007F-009F00AD03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-0605061C061D0620065F06DD070E070F074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17B417B517DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF200B-200F202A-202E2060-206F20722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-F8FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFD-FF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFFBFFFEFFFF",Cc:"0000-001F007F-009F",Cf:"00AD0600-060306DD070F17B417B5200B-200F202A-202E2060-2064206A-206FFEFFFFF9-FFFB",Co:"E000-F8FF",Cs:"D800-DFFF",Cn:"03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-05FF06040605061C061D0620065F070E074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF2065-206920722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-D7FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFDFEFEFF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFF8FFFEFFFF"})}),ace.define("ace/document",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/range","ace/anchor"],function(a,b,c){"use strict";var d=a("./lib/oop"),e=a("./lib/event_emitter").EventEmitter,f=a("./range").Range,g=a("./anchor").Anchor,h=function(a){this.$lines=[],Array.isArray(a)?this.insertLines(0,a):a.length==0?this.$lines=[""]:this.insert({row:0,column:0},a)};(function(){d.implement(this,e),this.setValue=function(a){var b=this.getLength();this.remove(new f(0,0,b,this.getLine(b-1).length)),this.insert({row:0,column:0},a)},this.getValue=function(){return this.getAllLines().join(this.getNewLineCharacter())},this.createAnchor=function(a,b){return new g(this,a,b)},"aaa".split(/a/).length==0?this.$split=function(a){return a.replace(/\r\n|\r/g,"\n").split("\n")}:this.$split=function(a){return a.split(/\r\n|\r|\n/)},this.$detectNewLine=function(a){var b=a.match(/^.*?(\r\n|\r|\n)/m);b?this.$autoNewLine=b[1]:this.$autoNewLine="\n"},this.getNewLineCharacter=function(){switch(this.$newLineMode){case"windows":return"\r\n";case"unix":return"\n";case"auto":return this.$autoNewLine}},this.$autoNewLine="\n",this.$newLineMode="auto",this.setNewLineMode=function(a){if(this.$newLineMode===a)return;this.$newLineMode=a},this.getNewLineMode=function(){return this.$newLineMode},this.isNewLine=function(a){return a=="\r\n"||a=="\r"||a=="\n"},this.getLine=function(a){return this.$lines[a]||""},this.getLines=function(a,b){return this.$lines.slice(a,b+1)},this.getAllLines=function(){return this.getLines(0,this.getLength())},this.getLength=function(){return this.$lines.length},this.getTextRange=function(a){if(a.start.row==a.end.row)return this.$lines[a.start.row].substring(a.start.column,a.end.column);var b=[];return b.push(this.$lines[a.start.row].substring(a.start.column)),b.push.apply(b,this.getLines(a.start.row+1,a.end.row-1)),b.push(this.$lines[a.end.row].substring(0,a.end.column)),b.join(this.getNewLineCharacter())},this.$clipPosition=function(a){var b=this.getLength();return a.row>=b&&(a.row=Math.max(0,b-1),a.column=this.getLine(b-1).length),a},this.insert=function(a,b){if(!b||b.length===0)return a;a=this.$clipPosition(a),this.getLength()<=1&&this.$detectNewLine(b);var c=this.$split(b),d=c.splice(0,1)[0],e=c.length==0?null:c.splice(c.length-1,1)[0];return a=this.insertInLine(a,d),e!==null&&(a=this.insertNewLine(a),a=this.insertLines(a.row,c),a=this.insertInLine(a,e||"")),a},this.insertLines=function(a,b){if(b.length==0)return{row:a,column:0};var c=[a,0];c.push.apply(c,b),this.$lines.splice.apply(this.$lines,c);var d=new f(a,0,a+b.length,0),e={action:"insertLines",range:d,lines:b};return this._emit("change",{data:e}),d.end},this.insertNewLine=function(a){a=this.$clipPosition(a);var b=this.$lines[a.row]||"";this.$lines[a.row]=b.substring(0,a.column),this.$lines.splice(a.row+1,0,b.substring(a.column,b.length));var c={row:a.row+1,column:0},d={action:"insertText",range:f.fromPoints(a,c),text:this.getNewLineCharacter()};return this._emit("change",{data:d}),c},this.insertInLine=function(a,b){if(b.length==0)return a;var c=this.$lines[a.row]||"";this.$lines[a.row]=c.substring(0,a.column)+b+c.substring(a.column);var d={row:a.row,column:a.column+b.length},e={action:"insertText",range:f.fromPoints(a,d),text:b};return this._emit("change",{data:e}),d},this.remove=function(a){a.start=this.$clipPosition(a.start),a.end=this.$clipPosition(a.end);if(a.isEmpty())return a.start;var b=a.start.row,c=a.end.row;if(a.isMultiLine()){var d=a.start.column==0?b:b+1,e=c-1;a.end.column>0&&this.removeInLine(c,0,a.end.column),e>=d&&this.removeLines(d,e),d!=b&&(this.removeInLine(b,a.start.column,this.getLine(b).length),this.removeNewLine(a.start.row))}else this.removeInLine(b,a.start.column,a.end.column);return a.start},this.removeInLine=function(a,b,c){if(b==c)return;var d=new f(a,b,a,c),e=this.getLine(a),g=e.substring(b,c),h=e.substring(0,b)+e.substring(c,e.length);this.$lines.splice(a,1,h);var i={action:"removeText",range:d,text:g};return this._emit("change",{data:i}),d.start},this.removeLines=function(a,b){var c=new f(a,0,b+1,0),d=this.$lines.splice(a,b-a+1),e={action:"removeLines",range:c,nl:this.getNewLineCharacter(),lines:d};return this._emit("change",{data:e}),d},this.removeNewLine=function(a){var b=this.getLine(a),c=this.getLine(a+1),d=new f(a,b.length,a+1,0),e=b+c;this.$lines.splice(a,2,e);var g={action:"removeText",range:d,text:this.getNewLineCharacter()};this._emit("change",{data:g})},this.replace=function(a,b){if(b.length==0&&a.isEmpty())return a.start;if(b==this.getTextRange(a))return a.end;this.remove(a);if(b)var c=this.insert(a.start,b);else c=a.start;return c},this.applyDeltas=function(a){for(var b=0;b<a.length;b++){var c=a[b],d=f.fromPoints(c.range.start,c.range.end);c.action=="insertLines"?this.insertLines(d.start.row,c.lines):c.action=="insertText"?this.insert(d.start,c.text):c.action=="removeLines"?this.removeLines(d.start.row,d.end.row-1):c.action=="removeText"&&this.remove(d)}},this.revertDeltas=function(a){for(var b=a.length-1;b>=0;b--){var c=a[b],d=f.fromPoints(c.range.start,c.range.end);c.action=="insertLines"?this.removeLines(d.start.row,d.end.row-1):c.action=="insertText"?this.remove(d):c.action=="removeLines"?this.insertLines(d.start.row,c.lines):c.action=="removeText"&&this.insert(d.start,c.text)}}}).call(h.prototype),b.Document=h}),ace.define("ace/anchor",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"],function(a,b,c){"use strict";var d=a("./lib/oop"),e=a("./lib/event_emitter").EventEmitter,f=b.Anchor=function(a,b,c){this.document=a,typeof c=="undefined"?this.setPosition(b.row,b.column):this.setPosition(b,c),this.$onChange=this.onChange.bind(this),a.on("change",this.$onChange)};(function(){d.implement(this,e),this.getPosition=function(){return this.$clipPositionToDocument(this.row,this.column)},this.getDocument=function(){return this.document},this.onChange=function(a){var b=a.data,c=b.range;if(c.start.row==c.end.row&&c.start.row!=this.row)return;if(c.start.row>this.row)return;if(c.start.row==this.row&&c.start.column>this.column)return;var d=this.row,e=this.column;b.action==="insertText"?c.start.row===d&&c.start.column<=e?c.start.row===c.end.row?e+=c.end.column-c.start.column:(e-=c.start.column,d+=c.end.row-c.start.row):c.start.row!==c.end.row&&c.start.row<d&&(d+=c.end.row-c.start.row):b.action==="insertLines"?c.start.row<=d&&(d+=c.end.row-c.start.row):b.action=="removeText"?c.start.row==d&&c.start.column<e?c.end.column>=e?e=c.start.column:e=Math.max(0,e-(c.end.column-c.start.column)):c.start.row!==c.end.row&&c.start.row<d?(c.end.row==d&&(e=Math.max(0,e-c.end.column)+c.start.column),d-=c.end.row-c.start.row):c.end.row==d&&(d-=c.end.row-c.start.row,e=Math.max(0,e-c.end.column)+c.start.column):b.action=="removeLines"&&c.start.row<=d&&(c.end.row<=d?d-=c.end.row-c.start.row:(d=c.start.row,e=0)),this.setPosition(d,e,!0)},this.setPosition=function(a,b,c){var d;c?d={row:a,column:b}:d=this.$clipPositionToDocument(a,b);if(this.row==d.row&&this.column==d.column)return;var e={row:this.row,column:this.column};this.row=d.row,this.column=d.column,this._emit("change",{old:e,value:d})},this.detach=function(){this.document.removeEventListener("change",this.$onChange)},this.$clipPositionToDocument=function(a,b){var c={};return a>=this.document.getLength()?(c.row=Math.max(0,this.document.getLength()-1),c.column=this.document.getLine(c.row).length):a<0?(c.row=0,c.column=0):(c.row=a,c.column=Math.min(this.document.getLine(c.row).length,Math.max(0,b))),b<0&&(c.column=0),c}}).call(f.prototype)}),ace.define("ace/background_tokenizer",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"],function(a,b,c){"use strict";var d=a("./lib/oop"),e=a("./lib/event_emitter").EventEmitter,f=function(a,b){this.running=!1,this.lines=[],this.currentLine=0,this.tokenizer=a;var c=this;this.$worker=function(){if(!c.running)return;var a=new Date,b=c.currentLine,d=c.doc,e=0,f=d.getLength();while(c.currentLine<f){c.lines[c.currentLine]=c.$tokenizeRows(c.currentLine,c.currentLine)[0],c.currentLine++,e+=1;if(e%5==0&&new Date-a>20){c.fireUpdateEvent(b,c.currentLine-1),c.running=setTimeout(c.$worker,20);return}}c.running=!1,c.fireUpdateEvent(b,f-1)}};(function(){d.implement(this,e),this.setTokenizer=function(a){this.tokenizer=a,this.lines=[],this.start(0)},this.setDocument=function(a){this.doc=a,this.lines=[],this.stop()},this.fireUpdateEvent=function(a,b){var c={first:a,last:b};this._emit("update",{data:c})},this.start=function(a){this.currentLine=Math.min(a||0,this.currentLine,this.doc.getLength()),this.lines.splice(this.currentLine,this.lines.length),this.stop(),this.running=setTimeout(this.$worker,700)},this.stop=function(){this.running&&clearTimeout(this.running),this.running=!1},this.getTokens=function(a,b){return this.$tokenizeRows(a,b)},this.getState=function(a){return this.$tokenizeRows(a,a)[0].state},this.$tokenizeRows=function(a,b){if(!this.doc||isNaN(a)||isNaN(b))return[{state:"start",tokens:[]}];var c=[],d="start",e=!1;a>0&&this.lines[a-1]?(d=this.lines[a-1].state,e=!0):a==0?(d="start",e=!0):this.lines.length>0&&(d=this.lines[this.lines.length-1].state);var f=this.doc.getLines(a,b);for(var g=a;g<=b;g++)if(!this.lines[g]){var h=this.tokenizer.getLineTokens(f[g-a]||"",d),d=h.state;c.push(h),e&&(this.lines[g]=h)}else{var h=this.lines[g];d=h.state,c.push(h)}return c}}).call(f.prototype),b.BackgroundTokenizer=f}),ace.define("ace/edit_session/folding",["require","exports","module","ace/range","ace/edit_session/fold_line","ace/edit_session/fold","ace/token_iterator"],function(a,b,c){function h(){this.getFoldAt=function(a,b,c){var d=this.getFoldLine(a);if(!d)return null;var e=d.folds;for(var f=0;f<e.length;f++){var g=e[f];if(g.range.contains(a,b)){if(c==1&&g.range.isEnd(a,b))continue;if(c==-1&&g.range.isStart(a,b))continue;return g}}},this.getFoldsInRange=function(a){a=a.clone();var b=a.start,c=a.end,d=this.$foldData,e=[];b.column+=1,c.column-=1;for(var f=0;f<d.length;f++){var g=d[f].range.compareRange(a);if(g==2)continue;if(g==-2)break;var h=d[f].folds;for(var i=0;i<h.length;i++){var j=h[i];g=j.range.compareRange(a);if(g==-2)break;if(g==2)continue;if(g==42)break;e.push(j)}}return e},this.getAllFolds=function(){function c(b){a.push(b);if(!b.subFolds)return;for(var d=0;d<b.subFolds.length;d++)c(b.subFolds[d])}var a=[],b=this.$foldData;for(var d=0;d<b.length;d++)for(var e=0;e<b[d].folds.length;e++)c(b[d].folds[e]);return a},this.getFoldStringAt=function(a,b,c,d){d=d||this.getFoldLine(a);if(!d)return null;var e={end:{column:0}},f,g;for(var h=0;h<d.folds.length;h++){g=d.folds[h];var i=g.range.compareEnd(a,b);if(i==-1){f=this.getLine(g.start.row).substring(e.end.column,g.start.column);break}if(i===0)return null;e=g}return f||(f=this.getLine(g.start.row).substring(e.end.column)),c==-1?f.substring(0,b-e.end.column):c==1?f.substring(b-e.end.column):f},this.getFoldLine=function(a,b){var c=this.$foldData,d=0;b&&(d=c.indexOf(b)),d==-1&&(d=0);for(d;d<c.length;d++){var e=c[d];if(e.start.row<=a&&e.end.row>=a)return e;if(e.end.row>a)return null}return null},this.getNextFoldLine=function(a,b){var c=this.$foldData,d=0;b&&(d=c.indexOf(b)),d==-1&&(d=0);for(d;d<c.length;d++){var e=c[d];if(e.end.row>=a)return e}return null},this.getFoldedRowCount=function(a,b){var c=this.$foldData,d=b-a+1;for(var e=0;e<c.length;e++){var f=c[e],g=f.end.row,h=f.start.row;if(g>=b){h<b&&(h>=a?d-=b-h:d=0);break}g>=a&&(h>=a?d-=g-h:d-=g-a+1)}return d},this.$addFoldLine=function(a){return this.$foldData.push(a),this.$foldData.sort(function(a,b){return a.start.row-b.start.row}),a},this.addFold=function(a,b){var c=this.$foldData,d=!1,g;a instanceof f?g=a:g=new f(b,a),this.$clipRangeToDocument(g.range);var h=g.start.row,i=g.start.column,j=g.end.row,k=g.end.column;if(g.placeholder.length<2)throw"Placeholder has to be at least 2 characters";if(h==j&&k-i<2)throw"The range has to be at least 2 characters width";var l=this.getFoldAt(h,i,1),m=this.getFoldAt(j,k,-1);if(l&&m==l)return l.addSubFold(g);if(l&&!l.range.isStart(h,i)||m&&!m.range.isEnd(j,k))throw"A fold can't intersect already existing fold"+g.range+l.range;var n=this.getFoldsInRange(g.range);n.length>0&&(this.removeFolds(n),g.subFolds=n);for(var o=0;o<c.length;o++){var p=c[o];if(j==p.start.row){p.addFold(g),d=!0;break}if(h==p.end.row){p.addFold(g),d=!0;if(!g.sameRow){var q=c[o+1];if(q&&q.start.row==j){p.merge(q);break}}break}if(j<=p.start.row)break}return d||(p=this.$addFoldLine(new e(this.$foldData,g))),this.$useWrapMode&&this.$updateWrapData(p.start.row,p.start.row),this.$modified=!0,this._emit("changeFold",{data:g}),g},this.addFolds=function(a){a.forEach(function(a){this.addFold(a)},this)},this.removeFold=function(a){var b=a.foldLine,c=b.start.row,d=b.end.row,e=this.$foldData,f=b.folds;if(f.length==1)e.splice(e.indexOf(b),1);else if(b.range.isEnd(a.end.row,a.end.column))f.pop(),b.end.row=f[f.length-1].end.row,b.end.column=f[f.length-1].end.column;else if(b.range.isStart(a.start.row,a.start.column))f.shift(),b.start.row=f[0].start.row,b.start.column=f[0].start.column;else if(a.sameRow)f.splice(f.indexOf(a),1);else{var g=b.split(a.start.row,a.start.column);f=g.folds,f.shift(),g.start.row=f[0].start.row,g.start.column=f[0].start.column}this.$useWrapMode&&this.$updateWrapData(c,d),this.$modified=!0,this._emit("changeFold",{data:a})},this.removeFolds=function(a){var b=[];for(var c=0;c<a.length;c++)b.push(a[c]);b.forEach(function(a){this.removeFold(a)},this),this.$modified=!0},this.expandFold=function(a){this.removeFold(a),a.subFolds.forEach(function(a){this.addFold(a)},this),a.subFolds=[]},this.expandFolds=function(a){a.forEach(function(a){this.expandFold(a)},this)},this.unfold=function(a,b){var c,e;a==null?c=new d(0,0,this.getLength(),0):typeof a=="number"?c=new d(a,0,a,this.getLine(a).length):"row"in a?c=d.fromPoints(a,a):c=a,e=this.getFoldsInRange(c);if(b)this.removeFolds(e);else while(e.length)this.expandFolds(e),e=this.getFoldsInRange(c)},this.isRowFolded=function(a,b){return!!this.getFoldLine(a,b)},this.getRowFoldEnd=function(a,b){var c=this.getFoldLine(a,b);return c?c.end.row:a},this.getFoldDisplayLine=function(a,b,c,d,e){d==null&&(d=a.start.row,e=0),b==null&&(b=a.end.row,c=this.getLine(b).length);var f=this.doc,g="";return a.walk(function(a,b,c,h){if(b<d)return;if(b==d){if(c<e)return;h=Math.max(e,h)}a?g+=a:g+=f.getLine(b).substring(h,c)}.bind(this),b,c),g},this.getDisplayLine=function(a,b,c,d){var e=this.getFoldLine(a);if(!e){var f;return f=this.doc.getLine(a),f.substring(d||0,b||f.length)}return this.getFoldDisplayLine(e,a,b,c,d)},this.$cloneFoldData=function(){var a=[];return a=this.$foldData.map(function(b){var c=b.folds.map(function(a){return a.clone()});return new e(a,c)}),a},this.toggleFold=function(a){var b=this.selection,c=b.getRange(),d,e;if(c.isEmpty()){var f=c.start;d=this.getFoldAt(f.row,f.column);if(d){this.expandFold(d);return}(e=this.findMatchingBracket(f))?c.comparePoint(e)==1?c.end=e:(c.start=e,c.start.column++,c.end.column--):(e=this.findMatchingBracket({row:f.row,column:f.column+1}))?(c.comparePoint(e)==1?c.end=e:c.start=e,c.start.column++):c=this.getCommentFoldRange(f.row,f.column)||c}else{var g=this.getFoldsInRange(c);if(a&&g.length){this.expandFolds(g);return}g.length==1&&(d=g[0])}d||(d=this.getFoldAt(c.start.row,c.start.column));if(d&&d.range.toString()==c.toString()){this.expandFold(d);return}var h="...";if(!c.isMultiLine()){h=this.getTextRange(c);if(h.length<4)return;h=h.trim().substring(0,2)+".."}this.addFold(h,c)},this.getCommentFoldRange=function(a,b){var c=new g(this,a,b),e=c.getCurrentToken();if(e&&/^comment|string/.test(e.type)){var f=new d,h=new RegExp(e.type.replace(/\..*/,"\\."));do e=c.stepBackward();while(e&&h.test(e.type));c.stepForward(),f.start.row=c.getCurrentTokenRow(),f.start.column=c.getCurrentTokenColumn()+2,c=new g(this,a,b);do e=c.stepForward();while(e&&h.test(e.type));return e=c.stepBackward(),f.end.row=c.getCurrentTokenRow(),f.end.column=c.getCurrentTokenColumn()+e.value.length,f}},this.foldAll=function(a,b){var c=this.foldWidgets;b=b||this.getLength();for(var d=a||0;d<b;d++){c[d]==null&&(c[d]=this.getFoldWidget(d));if(c[d]!="start")continue;var e=this.getFoldWidgetRange(d);if(e&&e.end.row<b)try{this.addFold("...",e)}catch(f){}}},this.$foldStyles={manual:1,markbegin:1,markbeginend:1},this.$foldStyle="markbegin",this.setFoldStyle=function(a){if(!this.$foldStyles[a])throw new Error("invalid fold style: "+a+"["+Object.keys(this.$foldStyles).join(", ")+"]");if(this.$foldStyle==a)return;this.$foldStyle=a,a=="manual"&&this.unfold();var b=this.$foldMode;this.$setFolding(null),this.$setFolding(b)},this.$setFolding=function(a){if(this.$foldMode==a)return;this.$foldMode=a,this.removeListener("change",this.$updateFoldWidgets),this._emit("changeAnnotation");if(!a||this.$foldStyle=="manual"){this.foldWidgets=null;return}this.foldWidgets=[],this.getFoldWidget=a.getFoldWidget.bind(a,this,this.$foldStyle),this.getFoldWidgetRange=a.getFoldWidgetRange.bind(a,this,this.$foldStyle),this.$updateFoldWidgets=this.updateFoldWidgets.bind(this),this.on("change",this.$updateFoldWidgets)},this.onFoldWidgetClick=function(a,b){var c=this.getFoldWidget(a),d=this.getLine(a),e=b.shiftKey,f=e||b.ctrlKey||b.altKey||b.metaKey,g;c=="end"?g=this.getFoldAt(a,0,-1):g=this.getFoldAt(a,d.length,1);if(g){f?this.removeFold(g):this.expandFold(g);return}var h=this.getFoldWidgetRange(a);if(h){if(!h.isMultiLine()){g=this.getFoldAt(h.start.row,h.start.column,1);if(g&&h.isEequal(g.range)){this.removeFold(g);return}}e||this.addFold("...",h),f&&this.foldAll(h.start.row+1,h.end.row)}else f&&this.foldAll(a+1,this.getLength()),b.target.className+=" invalid"},this.updateFoldWidgets=function(a){var b=a.data,c=b.range,d=c.start.row,e=c.end.row-d;if(e===0)this.foldWidgets[d]=null;else if(b.action=="removeText"||b.action=="removeLines")this.foldWidgets.splice(d,e+1,null);else{var f=Array(e+1);f.unshift(d,1),this.foldWidgets.splice.apply(this.foldWidgets,f)}}}"use strict";var d=a("../range").Range,e=a("./fold_line").FoldLine,f=a("./fold").Fold,g=a("../token_iterator").TokenIterator;b.Folding=h}),ace.define("ace/edit_session/fold_line",["require","exports","module","ace/range"],function(a,b,c){function e(a,b){this.foldData=a,Array.isArray(b)?this.folds=b:b=this.folds=[b];var c=b[b.length-1];this.range=new d(b[0].start.row,b[0].start.column,c.end.row,c.end.column),this.start=this.range.start,this.end=this.range.end,this.folds.forEach(function(a){a.setFoldLine(this)},this)}"use strict";var d=a("../range").Range;(function(){this.shiftRow=function(a){this.start.row+=a,this.end.row+=a,this.folds.forEach(function(b){b.start.row+=a,b.end.row+=a})},this.addFold=function(a){if(a.sameRow){if(a.start.row<this.startRow||a.endRow>this.endRow)throw"Can't add a fold to this FoldLine as it has no connection";this.folds.push(a),this.folds.sort(function(a,b){return-a.range.compareEnd(b.start.row,b.start.column)}),this.range.compareEnd(a.start.row,a.start.column)>0?(this.end.row=a.end.row,this.end.column=a.end.column):this.range.compareStart(a.end.row,a.end.column)<0&&(this.start.row=a.start.row,this.start.column=a.start.column)}else if(a.start.row==this.end.row)this.folds.push(a),this.end.row=a.end.row,this.end.column=a.end.column;else{if(a.end.row!=this.start.row)throw"Trying to add fold to FoldRow that doesn't have a matching row";this.folds.unshift(a),this.start.row=a.start.row,this.start.column=a.start.column}a.foldLine=this},this.containsRow=function(a){return a>=this.start.row&&a<=this.end.row},this.walk=function(a,b,c){var d=0,e=this.folds,f,g,h,i=!0;b==null&&(b=this.end.row,c=this.end.column);for(var j=0;j<e.length;j++){f=e[j],g=f.range.compareStart(b,c);if(g==-1){a(null,b,c,d,i);return}h=a(null,f.start.row,f.start.column,d,i),h=!h&&a(f.placeholder,f.start.row,f.start.column,d);if(h||g==0)return;i=!f.sameRow,d=f.end.column}a(null,b,c,d,i)},this.getNextFoldTo=function(a,b){var c,d;for(var e=0;e<this.folds.length;e++){c=this.folds[e],d=c.range.compareEnd(a,b);if(d==-1)return{fold:c,kind:"after"};if(d==0)return{fold:c,kind:"inside"}}return null},this.addRemoveChars=function(a,b,c){var d=this.getNextFoldTo(a,b),e,f;if(d){e=d.fold;if(d.kind=="inside"&&e.start.column!=b&&e.start.row!=a)throw"Moving characters inside of a fold should never be reached";if(e.start.row==a){f=this.folds;var g=f.indexOf(e);g==0&&(this.start.column+=c);for(g;g<f.length;g++){e=f[g],e.start.column+=c;if(!e.sameRow)return;e.end.column+=c}this.end.column+=c}}},this.split=function(a,b){var c=this.getNextFoldTo(a,b).fold,d=this.folds,f=this.foldData;if(!c)return null;var g=d.indexOf(c),h=d[g-1];this.end.row=h.end.row,this.end.column=h.end.column,d=d.splice(g,d.length-g);var i=new e(f,d);return f.splice(f.indexOf(this)+1,0,i),i},this.merge=function(a){var b=a.folds;for(var c=0;c<b.length;c++)this.addFold(b[c]);var d=this.foldData;d.splice(d.indexOf(a),1)},this.toString=function(){var a=[this.range.toString()+": ["];return this.folds.forEach(function(b){a.push(" "+b.toString())}),a.push("]"),a.join("\n")},this.idxToPosition=function(a){var b=0,c;for(var d=0;d<this.folds.length;d++){var c=this.folds[d];a-=c.start.column-b;if(a<0)return{row:c.start.row,column:c.start.column+a};a-=c.placeholder.length;if(a<0)return c.start;b=c.end.column}return{row:this.end.row,column:this.end.column+a}}}).call(e.prototype),b.FoldLine=e}),ace.define("ace/edit_session/fold",["require","exports","module"],function(a,b,c){"use strict";var d=b.Fold=function(a,b){this.foldLine=null,this.placeholder=b,this.range=a,this.start=a.start,this.end=a.end,this.sameRow=a.start.row==a.end.row,this.subFolds=[]};(function(){this.toString=function(){return'"'+this.placeholder+'" '+this.range.toString()},this.setFoldLine=function(a){this.foldLine=a,this.subFolds.forEach(function(b){b.setFoldLine(a)})},this.clone=function(){var a=this.range.clone(),b=new d(a,this.placeholder);return this.subFolds.forEach(function(a){b.subFolds.push(a.clone())}),b},this.addSubFold=function(a){if(this.range.isEequal(a))return this;if(!this.range.containsRange(a))throw"A fold can't intersect already existing fold"+a.range+this.range;var b=a.range.start.row,c=a.range.start.column;for(var d=0,e=-1;d<this.subFolds.length;d++){e=this.subFolds[d].range.compare(b,c);if(e!=1)break}var f=this.subFolds[d];if(e==0)return f.addSubFold(a);var b=a.range.end.row,c=a.range.end.column;for(var g=d,e=-1;g<this.subFolds.length;g++){e=this.subFolds[g].range.compare(b,c);if(e!=1)break}var h=this.subFolds[g];if(e==0)throw"A fold can't intersect already existing fold"+a.range+this.range;var i=this.subFolds.splice(d,g-d,a);return a.setFoldLine(this.foldLine),a}}).call(d.prototype)}),ace.define("ace/token_iterator",["require","exports","module"],function(a,b,c){"use strict";var d=function(a,b,c){this.$session=a,this.$row=b,this.$rowTokens=a.getTokens(b,b)[0].tokens;var d=a.getTokenAt(b,c);this.$tokenIndex=d?d.index:-1};(function(){this.stepBackward=function(){this.$tokenIndex-=1;while(this.$tokenIndex<0){this.$row-=1;if(this.$row<0)return this.$row=0,null;this.$rowTokens=this.$session.getTokens(this.$row,this.$row)[0].tokens,this.$tokenIndex=this.$rowTokens.length-1}return this.$rowTokens[this.$tokenIndex]},this.stepForward=function(){var a=this.$session.getLength();this.$tokenIndex+=1;while(this.$tokenIndex>=this.$rowTokens.length){this.$row+=1;if(this.$row>=a)return this.$row=a-1,null;this.$rowTokens=this.$session.getTokens(this.$row,this.$row)[0].tokens,this.$tokenIndex=0}return this.$rowTokens[this.$tokenIndex]},this.getCurrentToken=function(){return this.$rowTokens[this.$tokenIndex]},this.getCurrentTokenRow=function(){return this.$row},this.getCurrentTokenColumn=function(){var a=this.$rowTokens,b=this.$tokenIndex,c=a[b].start;if(c!==undefined)return c;c=0;while(b>0)b-=1,c+=a[b].value.length;return c}}).call(d.prototype),b.TokenIterator=d}),ace.define("ace/edit_session/bracket_match",["require","exports","module","ace/token_iterator"],function(a,b,c){function e(){this.findMatchingBracket=function(a){if(a.column==0)return null;var b=this.getLine(a.row).charAt(a.column-1);if(b=="")return null;var c=b.match(/([\(\[\{])|([\)\]\}])/);return c?c[1]?this.$findClosingBracket(c[1],a):this.$findOpeningBracket(c[2],a):null},this.$brackets={")":"(","(":")","]":"[","[":"]","{":"}","}":"{"},this.$findOpeningBracket=function(a,b){var c=this.$brackets[a],e=1,f=new d(this,b.row,b.column),g=f.getCurrentToken();if(!g)return null;var h=new RegExp("(\\.?"+g.type.replace(".","|").replace("rparen","lparen|rparen")+")+"),i=b.column-f.getCurrentTokenColumn()-2,j=g.value;for(;;){while(i>=0){var k=j.charAt(i);if(k==c){e-=1;if(e==0)return{row:f.getCurrentTokenRow(),column:i+f.getCurrentTokenColumn()}}else k==a&&(e+=1);i-=1}do g=f.stepBackward();while(g&&!h.test(g.type));if(g==null)break;j=g.value,i=j.length-1}return null},this.$findClosingBracket=function(a,b){var c=this.$brackets[a],e=1,f=new d(this,b.row,b.column),g=f.getCurrentToken();if(!g)return null;var h=new RegExp("(\\.?"+g.type.replace(".","|").replace("lparen","lparen|rparen")+")+"),i=b.column-f.getCurrentTokenColumn();for(;;){var j=g.value,k=j.length;while(i<k){var l=j.charAt(i);if(l==c){e-=1;if(e==0)return{row:f.getCurrentTokenRow(),column:i+f.getCurrentTokenColumn()}}else l==a&&(e+=1);i+=1}do g=f.stepForward();while(g&&!h.test(g.type));if(g==null)break;i=0}return null}}"use strict";var d=a("../token_iterator").TokenIterator;b.BracketMatch=e}),ace.define("ace/search",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"],function(a,b,c){"use strict";var d=a("./lib/lang"),e=a("./lib/oop"),f=a("./range").Range,g=function(){this.$options={needle:"",backwards:!1,wrap:!1,caseSensitive:!1,wholeWord:!1,scope:g.ALL,regExp:!1}};g.ALL=1,g.SELECTION=2,function(){this.set=function(a){return e.mixin(this.$options,a),this},this.getOptions=function(){return d.copyObject(this.$options)},this.find=function(a){if(!this.$options.needle)return null;if(this.$options.backwards)var b=this.$backwardMatchIterator(a);else b=this.$forwardMatchIterator(a);var c=null;return b.forEach(function(a){return c=a,!0}),c},this.findAll=function(a){var b=this.$options;if(!b.needle)return[];if(b.backwards)var c=this.$backwardMatchIterator(a);else c=this.$forwardMatchIterator(a);var d=!b.start&&b.wrap&&b.scope==g.ALL;d&&(b.start={row:0,column:0});var e=[];return c.forEach(function(a){e.push(a)}),d&&(b.start=null),e},this.replace=function(a,b){var c=this.$assembleRegExp(),d=c.exec(a);return d&&d[0].length==a.length?this.$options.regExp?a.replace(c,b):b:null},this.$forwardMatchIterator=function(a){var b=this.$assembleRegExp(),c=this;return{forEach:function(d){c.$forwardLineIterator(a).forEach(function(a,e,f){e&&(a=a.substring(e));var g=[];a.replace(b,function(a){var b=arguments[arguments.length-2];return g.push({str:a,offset:e+b}),a});for(var h=0;h<g.length;h++){var i=g[h],j=c.$rangeFromMatch(f,i.offset,i.str.length);if(d(j))return!0}})}}},this.$backwardMatchIterator=function(a){var b=this.$assembleRegExp(),c=this;return{forEach:function(d){c.$backwardLineIterator(a).forEach(function(a,e,f){e&&(a=a.substring(e));var g=[];a.replace(b,function(a,b){return g.push({str:a,offset:e+b}),a});for(var h=g.length-1;h>=0;h--){var i=g[h],j=c.$rangeFromMatch(f,i.offset,i.str.length);if(d(j))return!0}})}}},this.$rangeFromMatch=function(a,b,c){return new f(a,b,a,b+c)},this.$assembleRegExp=function(){if(this.$options.regExp)var a=this.$options.needle;else a=d.escapeRegExp(this.$options.needle);this.$options.wholeWord&&(a="\\b"+a+"\\b");var b="g";this.$options.caseSensitive||(b+="i");var c=new RegExp(a,b);return c},this.$forwardLineIterator=function(a){function k(e){var f=a.getLine(e);return b&&e==c.end.row&&(f=f.substring(0,c.end.column)),j&&e==d.row&&(f=f.substring(0,d.column)),f}var b=this.$options.scope==g.SELECTION,c=this.$options.range||a.getSelection().getRange(),d=this.$options.start||c[b?"start":"end"],e=b?c.start.row:0,f=b?c.start.column:0,h=b?c.end.row:a.getLength()-1,i=this.$options.wrap,j=!1;return{forEach:function(a){var b=d.row,c=k(b),g=d.column,l=!1;j=!1;while(!a(c,g,b)){if(l)return;b++,g=0;if(b>h){if(!i)return;b=e,g=f,j=!0}b==d.row&&(l=!0),c=k(b)}}}},this.$backwardLineIterator=function(a){var b=this.$options.scope==g.SELECTION,c=this.$options.range||a.getSelection().getRange(),d=this.$options.start||c[b?"end":"start"],e=b?c.start.row:0,f=b?c.start.column:0,h=b?c.end.row:a.getLength()-1,i=this.$options.wrap;return{forEach:function(g){var j=d.row,k=a.getLine(j).substring(0,d.column),l=0,m=!1,n=!1;while(!g(k,l,j)){if(m)return;j--,l=0;if(j<e){if(!i)return;j=h,n=!0}j==d.row&&(m=!0),k=a.getLine(j),b&&(j==e?l=f:j==h&&(k=k.substring(0,c.end.column))),n&&j==d.row&&(l=d.column)}}}}}.call(g.prototype),b.Search=g}),ace.define("ace/commands/command_manager",["require","exports","module","ace/lib/keys"],function(a,b,c){"use strict";var d=a("../lib/keys"),e=function(a,b){if(typeof a!="string")throw new TypeError("'platform' argument must be either 'mac' or 'win'");this.platform=a,this.commands={},this.commmandKeyBinding={},b&&b.forEach(this.addCommand,this)};(function(){function a(a,c,e){var f,g=0,h=b(a);for(var i=0,j=h.length;i<j;i++)d.KEY_MODS[h[i]]?g|=d.KEY_MODS[h[i]]:f=h[i]||"-";return{key:f,hashId:g}}function b(a){return a.toLowerCase().trim().split(new RegExp("[\\s ]*\\-[\\s ]*","g"),999)}this.addCommand=function(a){this.commands[a.name]&&this.removeCommand(a),this.commands[a.name]=a,a.bindKey&&this._buildKeyHash(a)},this.removeCommand=function(a){var b=typeof a=="string"?a:a.name;a=this.commands[b],delete this.commands[b];var c=this.commmandKeyBinding;for(var d in c)for(var e in c[d])c[d][e]==a&&delete c[d][e]},this.addCommands=function(a){Object.keys(a).forEach(function(b){var c=a[b];if(typeof c=="string")return this.bindKey(c,b);typeof c=="function"&&(c={exec:c}),c.name||(c.name=b),this.addCommand(c)},this)},this.removeCommands=function(a){Object.keys(a).forEach(function(b){this.removeCommand(a[b])},this)},this.bindKey=function(b,c){if(!b)return;var d=this.commmandKeyBinding;b.split("|").forEach(function(b){var e=a(b,c),f=e.hashId;(d[f]||(d[f]={}))[e.key]=c})},this.bindKeys=function(a){Object.keys(a).forEach(function(b){this.bindKey(b,a[b])},this)},this._buildKeyHash=function(a){var b=a.bindKey;if(!b)return;var c=typeof b=="string"?b:b[this.platform];this.bindKey(c,a)},this.findKeyCommand=function(b,c){typeof c=="number"&&(c=d.keyCodeToString(c));var e=this.commmandKeyBinding;return e[b]&&e[b][c.toLowerCase()]},this.exec=function(a,b,c){return typeof a=="string"&&(a=this.commands[a]),a?b&&b.$readOnly&&!a.readOnly?!1:(a.exec(b,c||{}),!0):!1},this.toggleRecording=function(){if(this.$inReplay)return;return this.recording?(this.macro.pop(),this.exec=this.normal_exec,this.macro.length||(this.macro=this.oldMacro),this.recording=!1):(this.oldMacro=this.macro,this.macro=[],this.normal_exec=this.exec,this.exec=function(a,b,c){return this.macro.push([a,c]),this.normal_exec(a,b,c)},this.recording=!0)},this.replay=function(a){if(this.$inReplay||!this.macro)return;if(this.recording)return this.toggleRecording();try{this.$inReplay=!0,this.macro.forEach(function(b){typeof b=="string"?this.exec(b,a):this.exec(b[0],a,b[1])},this)}finally{this.$inReplay=!1}},this.trimMacro=function(a){return a.map(function(a){return typeof a[0]!="string"&&(a[0]=a[0].name),a[1]||(a=a[0]),a})}}).call(e.prototype),b.CommandManager=e}),ace.define("ace/undomanager",["require","exports","module"],function(a,b,c){"use strict";var d=function(){this.reset()};(function(){this.execute=function(a){var b=a.args[0];this.$doc=a.args[1],this.$undoStack.push(b),this.$redoStack=[]},this.undo=function(a){var b=this.$undoStack.pop(),c=null;return b&&(c=this.$doc.undoChanges(b,a),this.$redoStack.push(b)),c},this.redo=function(a){var b=this.$redoStack.pop(),c=null;return b&&(c=this.$doc.redoChanges(b,a),this.$undoStack.push(b)),c},this.reset=function(){this.$undoStack=[],this.$redoStack=[]},this.hasUndo=function(){return this.$undoStack.length>0},this.hasRedo=function(){return this.$redoStack.length>0}}).call(d.prototype),b.UndoManager=d}),ace.define("ace/virtual_renderer",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/useragent","ace/config","ace/lib/net","ace/layer/gutter","ace/layer/marker","ace/layer/text","ace/layer/cursor","ace/scrollbar","ace/renderloop","ace/lib/event_emitter","text!ace/css/editor.css"],function(a,b,c){"use strict";var d=a("./lib/oop"),e=a("./lib/dom"),f=a("./lib/event"),g=a("./lib/useragent"),h=a("./config"),i=a("./lib/net"),j=a("./layer/gutter").Gutter,k=a("./layer/marker").Marker,l=a("./layer/text").Text,m=a("./layer/cursor").Cursor,n=a("./scrollbar").ScrollBar,o=a("./renderloop").RenderLoop,p=a("./lib/event_emitter").EventEmitter,q=a("text!./css/editor.css");e.importCssString(q,"ace_editor");var r=function(a,b){var c=this;this.container=a,e.addCssClass(a,"ace_editor"),this.setTheme(b),this.$gutter=e.createElement("div"),this.$gutter.className="ace_gutter",this.container.appendChild(this.$gutter),this.scroller=e.createElement("div"),this.scroller.className="ace_scroller",this.container.appendChild(this.scroller),this.content=e.createElement("div"),this.content.className="ace_content",this.scroller.appendChild(this.content),this.$gutterLayer=new j(this.$gutter),this.$gutterLayer.on("changeGutterWidth",this.onResize.bind(this,!0)),this.$markerBack=new k(this.content);var d=this.$textLayer=new l(this.content);this.canvas=d.element,this.$markerFront=new k(this.content),this.characterWidth=d.getCharacterWidth(),this.lineHeight=d.getLineHeight(),this.$cursorLayer=new m(this.content),this.$cursorPadding=8,this.$horizScroll=!0,this.$horizScrollAlwaysVisible=!0,this.scrollBar=new n(a),this.scrollBar.addEventListener("scroll",function(a){c.session.setScrollTop(a.data)}),this.scrollTop=0,this.scrollLeft=0,f.addListener(this.scroller,"scroll",function(){var a=c.scroller.scrollLeft;c.scrollLeft=a,c.session.setScrollLeft(a)}),this.cursorPos={row:0,column:0},this.$textLayer.addEventListener("changeCharacterSize",function(){c.characterWidth=d.getCharacterWidth(),c.lineHeight=d.getLineHeight(),c.$updatePrintMargin(),c.onResize(!0),c.$loop.schedule(c.CHANGE_FULL)}),this.$size={width:0,height:0,scrollerHeight:0,scrollerWidth:0},this.layerConfig={width:1,padding:0,firstRow:0,firstRowScreen:0,lastRow:0,lineHeight:1,characterWidth:1,minHeight:1,maxHeight:1,offset:0,height:1},this.$loop=new o(this.$renderChanges.bind(this),this.container.ownerDocument.defaultView),this.$loop.schedule(this.CHANGE_FULL),this.setPadding(4),this.$updatePrintMargin()};(function(){this.showGutter=!0,this.CHANGE_CURSOR=1,this.CHANGE_MARKER=2,this.CHANGE_GUTTER=4,this.CHANGE_SCROLL=8,this.CHANGE_LINES=16,this.CHANGE_TEXT=32,this.CHANGE_SIZE=64,this.CHANGE_MARKER_BACK=128,this.CHANGE_MARKER_FRONT=256,this.CHANGE_FULL=512,this.CHANGE_H_SCROLL=1024,d.implement(this,p),this.setSession=function(a){this.session=a,this.$cursorLayer.setSession(a),this.$markerBack.setSession(a),this.$markerFront.setSession(a),this.$gutterLayer.setSession(a),this.$textLayer.setSession(a),this.$loop.schedule(this.CHANGE_FULL)},this.updateLines=function(a,b){b===undefined&&(b=Infinity),this.$changedLines?(this.$changedLines.firstRow>a&&(this.$changedLines.firstRow=a),this.$changedLines.lastRow<b&&(this.$changedLines.lastRow=b)):this.$changedLines={firstRow:a,lastRow:b},this.$loop.schedule(this.CHANGE_LINES)},this.updateText=function(){this.$loop.schedule(this.CHANGE_TEXT)},this.updateFull=function(){this.$loop.schedule(this.CHANGE_FULL)},this.updateFontSize=function(){this.$textLayer.checkForSizeChanges()},this.onResize=function(a){var b=this.CHANGE_SIZE,c=this.$size,d=e.getInnerHeight(this.container);if(a||c.height!=d)c.height=d,this.scroller.style.height=d+"px",c.scrollerHeight=this.scroller.clientHeight,this.scrollBar.setHeight(c.scrollerHeight),this.session&&(this.session.setScrollTop(this.getScrollTop()),b|=this.CHANGE_FULL);var f=e.getInnerWidth(this.container);if(a||c.width!=f){c.width=f;var g=this.showGutter?this.$gutter.offsetWidth:0;this.scroller.style.left=g+"px",c.scrollerWidth=Math.max(0,f-g-this.scrollBar.getWidth()),this.scroller.style.width=c.scrollerWidth+"px";if(this.session.getUseWrapMode()&&this.adjustWrapLimit()||a)b|=this.CHANGE_FULL}this.$loop.schedule(b)},this.adjustWrapLimit=function(){var a=this.$size.scrollerWidth-this.$padding*2,b=Math.floor(a/this.characterWidth);return this.session.adjustWrapLimit(b)},this.setShowInvisibles=function(a){this.$textLayer.setShowInvisibles(a)&&this.$loop.schedule(this.CHANGE_TEXT)},this.getShowInvisibles=function(){return this.$textLayer.showInvisibles},this.$showPrintMargin=!0,this.setShowPrintMargin=function(a){this.$showPrintMargin=a,this.$updatePrintMargin()},this.getShowPrintMargin=function(){return this.$showPrintMargin},this.$printMarginColumn=80,this.setPrintMarginColumn=function(a){this.$printMarginColumn=a,this.$updatePrintMargin()},this.getPrintMarginColumn=function(){return this.$printMarginColumn},this.getShowGutter=function(){return this.showGutter},this.setShowGutter=function(a){if(this.showGutter===a)return;this.$gutter.style.display=a?"block":"none",this.showGutter=a,this.onResize(!0)},this.$updatePrintMargin=function(){var a;if(!this.$showPrintMargin&&!this.$printMarginEl)return;this.$printMarginEl||(a=e.createElement("div"),a.className="ace_print_margin_layer",this.$printMarginEl=e.createElement("div"),this.$printMarginEl.className="ace_print_margin",a.appendChild(this.$printMarginEl),this.content.insertBefore(a,this.$textLayer.element));var b=this.$printMarginEl.style;b.left=this.characterWidth*this.$printMarginColumn+this.$padding+"px",b.visibility=this.$showPrintMargin?"visible":"hidden"},this.getContainerElement=function(){return this.container},this.getMouseEventTarget=function(){return this.content},this.getTextAreaContainer=function(){return this.container},this.moveTextAreaToCursor=function(a){if(g.isIE)return;if(this.layerConfig.lastRow===0)return;var b=this.$cursorLayer.getPixelPosition();if(!b)return;var c=this.content.getBoundingClientRect(),d=this.layerConfig.offset;a.style.left=c.left+b.left+"px",a.style.top=c.top+b.top-this.scrollTop+d+"px"},this.getFirstVisibleRow=function(){return this.layerConfig.firstRow},this.getFirstFullyVisibleRow=function(){return this.layerConfig.firstRow+(this.layerConfig.offset===0?0:1)},this.getLastFullyVisibleRow=function(){var a=Math.floor((this.layerConfig.height+this.layerConfig.offset)/this.layerConfig.lineHeight);return this.layerConfig.firstRow-1+a},this.getLastVisibleRow=function(){return this.layerConfig.lastRow},this.$padding=null,this.setPadding=function(a){this.$padding=a,this.$textLayer.setPadding(a),this.$cursorLayer.setPadding(a),this.$markerFront.setPadding(a),this.$markerBack.setPadding(a),this.$loop.schedule(this.CHANGE_FULL),this.$updatePrintMargin()},this.getHScrollBarAlwaysVisible=function(){return this.$horizScrollAlwaysVisible},this.setHScrollBarAlwaysVisible=function(a){this.$horizScrollAlwaysVisible!=a&&(this.$horizScrollAlwaysVisible=a,(!this.$horizScrollAlwaysVisible||!this.$horizScroll)&&this.$loop.schedule(this.CHANGE_SCROLL))},this.$updateScrollBar=function(){this.scrollBar.setInnerHeight(this.layerConfig.maxHeight),this.scrollBar.setScrollTop(this.scrollTop)},this.$renderChanges=function(a){if(!a||!this.session||!this.container.offsetWidth)return;(a&this.CHANGE_FULL||a&this.CHANGE_SIZE||a&this.CHANGE_TEXT||a&this.CHANGE_LINES||a&this.CHANGE_SCROLL)&&this.$computeLayerConfig();if(a&this.CHANGE_H_SCROLL){this.scroller.scrollLeft=this.scrollLeft;var b=this.scroller.scrollLeft;this.scrollLeft=b,this.session.setScrollLeft(b)}if(a&this.CHANGE_FULL){this.$textLayer.checkForSizeChanges(),this.$updateScrollBar(),this.$textLayer.update(this.layerConfig),this.showGutter&&this.$gutterLayer.update(this.layerConfig),this.$markerBack.update(this.layerConfig),this.$markerFront.update(this.layerConfig),this.$cursorLayer.update(this.layerConfig);return}if(a&this.CHANGE_SCROLL){this.$updateScrollBar(),a&this.CHANGE_TEXT||a&this.CHANGE_LINES?this.$textLayer.update(this.layerConfig):this.$textLayer.scrollLines(this.layerConfig),this.showGutter&&this.$gutterLayer.update(this.layerConfig),this.$markerBack.update(this.layerConfig),this.$markerFront.update(this.layerConfig),this.$cursorLayer.update(this.layerConfig);return}a&this.CHANGE_TEXT?(this.$textLayer.update(this.layerConfig),this.showGutter&&this.$gutterLayer.update(this.layerConfig)):a&this.CHANGE_LINES?this.$updateLines()&&(this.$updateScrollBar(),this.showGutter&&this.$gutterLayer.update(this.layerConfig)):a&this.CHANGE_GUTTER&&this.showGutter&&this.$gutterLayer.update(this.layerConfig),a&this.CHANGE_CURSOR&&this.$cursorLayer.update(this.layerConfig),a&(this.CHANGE_MARKER|this.CHANGE_MARKER_FRONT)&&this.$markerFront.update(this.layerConfig),a&(this.CHANGE_MARKER|this.CHANGE_MARKER_BACK)&&this.$markerBack.update(this.layerConfig),a&this.CHANGE_SIZE&&this.$updateScrollBar()},this.$computeLayerConfig=function(){var a=this.session,b=this.scrollTop%this.lineHeight,c=this.$size.scrollerHeight+this.lineHeight,d=this.$getLongestLine(),e=this.$horizScrollAlwaysVisible||this.$size.scrollerWidth-d<0,f=this.$horizScroll!==e;this.$horizScroll=e,f&&(this.scroller.style.overflowX=e?"scroll":"hidden",e||this.session.setScrollLeft(0));var g=this.session.getScreenLength()*this.lineHeight;this.session.setScrollTop(Math.max(0,Math.min(this.scrollTop,g-this.$size.scrollerHeight)));var h=Math.ceil(c/this.lineHeight)-1,i=Math.max(0,Math.round((this.scrollTop-b)/this.lineHeight)),j=i+h,k,l,m={lineHeight:this.lineHeight};i=a.screenToDocumentRow(i,0);var n=a.getFoldLine(i);n&&(i=n.start.row),k=a.documentToScreenRow(i,0),l=a.getRowHeight(m,i),j=Math.min(a.screenToDocumentRow(j,0),a.getLength()-1),c=this.$size.scrollerHeight+a.getRowHeight(m,j)+l,b=this.scrollTop-k*this.lineHeight,this.layerConfig={width:d,padding:this.$padding,firstRow:i,firstRowScreen:k,lastRow:j,lineHeight:this.lineHeight,characterWidth:this.characterWidth,minHeight:c,maxHeight:g,offset:b,height:this.$size.scrollerHeight},this.$gutterLayer.element.style.marginTop=-b+"px",this.content.style.marginTop=-b+"px",this.content.style.width=d+2*this.$padding+"px",this.content.style.height=c+"px",f&&this.onResize(!0)},this.$updateLines=function(){var a=this.$changedLines.firstRow,b=this.$changedLines.lastRow;this.$changedLines=null;var c=this.layerConfig;if(c.width!=this.$getLongestLine())return this.$textLayer.update(c);if(a>c.lastRow+1)return;if(b<c.firstRow)return;if(b===Infinity){this.showGutter&&this.$gutterLayer.update(c),this.$textLayer.update(c);return}return this.$textLayer.updateLines(c,a,b),!0},this.$getLongestLine=function(){var a=this.session.getScreenWidth();return this.$textLayer.showInvisibles&&(a+=1),Math.max(this.$size.scrollerWidth-2*this.$padding,Math.round(a*this.characterWidth))},this.updateFrontMarkers=function(){this.$markerFront.setMarkers(this.session.getMarkers(!0)),this.$loop.schedule(this.CHANGE_MARKER_FRONT)},this.updateBackMarkers=function(){this.$markerBack.setMarkers(this.session.getMarkers()),this.$loop.schedule(this.CHANGE_MARKER_BACK)},this.addGutterDecoration=function(a,b){this.$gutterLayer.addGutterDecoration(a,b),this.$loop.schedule(this.CHANGE_GUTTER)},this.removeGutterDecoration=function(a,b){this.$gutterLayer.removeGutterDecoration(a,b),this.$loop.schedule(this.CHANGE_GUTTER)},this.setBreakpoints=function(a){this.$gutterLayer.setBreakpoints(a),this.$loop.schedule(this.CHANGE_GUTTER)},this.setAnnotations=function(a){this.$gutterLayer.setAnnotations(a),this.$loop.schedule(this.CHANGE_GUTTER)},this.updateCursor=function(){this.$loop.schedule(this.CHANGE_CURSOR)},this.hideCursor=function(){this.$cursorLayer.hideCursor()},this.showCursor=function(){this.$cursorLayer.showCursor()},this.scrollSelectionIntoView=function(a,b){this.scrollCursorIntoView(a),this.scrollCursorIntoView(b)},this.scrollCursorIntoView=function(a){if(this.$size.scrollerHeight===0)return;var b=this.$cursorLayer.getPixelPosition(a),c=b.left,d=b.top;this.scrollTop>d&&this.session.setScrollTop(d),this.scrollTop+this.$size.scrollerHeight<d+this.lineHeight&&this.session.setScrollTop(d+this.lineHeight-this.$size.scrollerHeight);var e=this.scrollLeft;e>c&&(c<this.$padding+2*this.layerConfig.characterWidth&&(c=0),this.session.setScrollLeft(c)),e+this.$size.scrollerWidth<c+this.characterWidth&&this.session.setScrollLeft(Math.round(c+this.characterWidth-this.$size.scrollerWidth))},this.getScrollTop=function(){return this.session.getScrollTop()},this.getScrollLeft=function(){return this.session.getScrollLeft()},this.getScrollTopRow=function(){return this.scrollTop/this.lineHeight},this.getScrollBottomRow=function(){return Math.max(0,Math.floor((this.scrollTop+this.$size.scrollerHeight)/this.lineHeight)-1)},this.scrollToRow=function(a){this.session.setScrollTop(a*this.lineHeight)},this.scrollToLine=function(a,b){var c=this.$cursorLayer.getPixelPosition({row:a,column:0}),d=c.top;b&&(d-=this.$size.scrollerHeight/2),this.session.setScrollTop(d)},this.scrollToY=function(a){this.scrollTop!==a&&(this.$loop.schedule(this.CHANGE_SCROLL),this.scrollTop=a)},this.scrollToX=function(a){a<=this.$padding&&(a=0),this.scrollLeft!==a&&(this.scrollLeft=a),this.$loop.schedule(this.CHANGE_H_SCROLL)},this.scrollBy=function(a,b){b&&this.session.setScrollTop(this.session.getScrollTop()+b),a&&this.session.setScrollLeft(this.session.getScrollLeft()+a)},this.isScrollableBy=function(a,b){if(b<0&&this.session.getScrollTop()>0)return!0;if(b>0&&this.session.getScrollTop()+this.$size.scrollerHeight<this.layerConfig.maxHeight)return!0},this.screenToTextCoordinates=function(a,b){var c=this.scroller.getBoundingClientRect(),d=Math.round((a+this.scrollLeft-c.left-this.$padding-e.getPageScrollLeft())/this.characterWidth),f=Math.floor((b+this.scrollTop-c.top-e.getPageScrollTop())/this.lineHeight);return this.session.screenToDocumentPosition(f,Math.max(d,0))},this.textToScreenCoordinates=function(a,b){var c=this.scroller.getBoundingClientRect(),d=this.session.documentToScreenPosition(a,b),e=this.$padding+Math.round(d.column*this.characterWidth),f=d.row*this.lineHeight;return{pageX:c.left+e-this.scrollLeft,pageY:c.top+f-this.scrollTop}},this.visualizeFocus=function(){e.addCssClass(this.container,"ace_focus")},this.visualizeBlur=function(){e.removeCssClass(this.container,"ace_focus")},this.showComposition=function(a){this.$composition||(this.$composition=e.createElement("div"),this.$composition.className="ace_composition",this.content.appendChild(this.$composition)),this.$composition.innerHTML="&#160;";var b=this.$cursorLayer.getPixelPosition(),c=this.$composition.style;c.top=b.top+"px",c.left=b.left+this.$padding+"px",c.height=this.lineHeight+"px",this.hideCursor()},this.setCompositionText=function(a){e.setInnerText(this.$composition,a)},this.hideComposition=function(){this.showCursor();if(!this.$composition)return;var a=this.$composition.style;a.top="-10000px",a.left="-10000px"},this._loadTheme=function(a,b){if(!h.get("packaged"))return b();var c=a.split("/").pop(),d=h.get("themePath")+"/theme-"+c+h.get("suffix");i.loadScript(d,b)},this.setTheme=function(b){function h(a){e.importCssString(a.cssText,a.cssClass,c.container.ownerDocument),c.$theme&&e.removeCssClass(c.container,c.$theme),c.$theme=a?a.cssClass:null,c.$theme&&e.addCssClass(c.container,c.$theme),a&&a.isDark?e.addCssClass(c.container,"ace_dark"):e.removeCssClass(c.container,"ace_dark"),c.$size&&(c.$size.width=0,c.onResize())}var c=this;this.$themeValue=b;if(!b||typeof b=="string"){var d=b||"ace/theme/textmate",f;try{f=a(d)}catch(g){}if(f)return h(f);c._loadTheme(d,function(){a([b],function(a){if(c.$themeValue!==b)return;h(a)})})}else h(b)},this.getTheme=function(){return this.$themeValue},this.setStyle=function(b){e.addCssClass(this.container,b)},this.unsetStyle=function(b){e.removeCssClass(this.container,b)},this.destroy=function(){this.$textLayer.destroy(),this.$cursorLayer.destroy()}}).call(r.prototype),b.VirtualRenderer=r}),ace.define("ace/layer/gutter",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event_emitter"],function(a,b,c){"use strict";var d=a("../lib/dom"),e=a("../lib/oop"),f=a("../lib/event_emitter").EventEmitter,g=function(a){this.element=d.createElement("div"),this.element.className="ace_layer ace_gutter-layer",a.appendChild(this.element),this.setShowFoldWidgets(this.$showFoldWidgets),this.gutterWidth=0,this.$breakpoints=[],this.$annotations=[],this.$decorations=[]};(function(){e.implement(this,f),this.setSession=function(a){this.session=a},this.addGutterDecoration=function(a,b){this.$decorations[a]||(this.$decorations[a]=""),this.$decorations[a]+=" ace_"+b},this.removeGutterDecoration=function(a,b){this.$decorations[a]=this.$decorations[a].replace(" ace_"+b,"")},this.setBreakpoints=function(a){this.$breakpoints=a.concat()},this.setAnnotations=function(a){this.$annotations=[];for(var b in a)if(a.hasOwnProperty(b)){var c=a[b];if(!c)continue;var d=this.$annotations[b]={text:[]};for(var e=0;e<c.length;e++){var f=c[e],g=f.text.replace(/"/g,"&quot;").replace(/'/g,"&#8217;").replace(/</,"&lt;");d.text.indexOf(g)===-1&&d.text.push(g);var h=f.type;h=="error"?d.className="ace_error":h=="warning"&&d.className!="ace_error"?d.className="ace_warning":h=="info"&&!d.className&&(d.className="ace_info")}}},this.update=function(a){this.$config=a;var b={className:"",text:[]},c=[],e=a.firstRow,f=a.lastRow,g=this.session.getNextFoldLine(e),h=g?g.start.row:Infinity,i=this.$showFoldWidgets&&this.session.foldWidgets;for(;;){e>h&&(e=g.end.row+1,g=this.session.getNextFoldLine(e,g),h=g?g.start.row:Infinity);if(e>f)break;var j=this.$annotations[e]||b;c.push("<div class='ace_gutter-cell",this.$decorations[e]||"",this.$breakpoints[e]?" ace_breakpoint ":" ",j.className,"' title='",j.text.join("\n"),"' style='height:",a.lineHeight,"px;'>",e+1);if(i){var k=i[e];k==null&&(k=i[e]=this.session.getFoldWidget(e)),k&&c.push("<span class='ace_fold-widget ",k,k=="start"&&e==h&&e<g.end.row?" closed":" open","'></span>")}var l=this.session.getRowLength(e)-1;while(l--)c.push("</div><div class='ace_gutter-cell' style='height:",a.lineHeight,"px'>¦");c.push("</div>"),e++}this.element=d.setInnerHtml(this.element,c.join("")),this.element.style.height=a.minHeight+"px";var m=this.element.offsetWidth;m!==this.gutterWidth&&(this.gutterWidth=m,this._emit("changeGutterWidth",m))},this.$showFoldWidgets=!0,this.setShowFoldWidgets=function(a){a?d.addCssClass(this.element,"ace_folding-enabled"):d.removeCssClass(this.element,"ace_folding-enabled"),this.$showFoldWidgets=a},this.getShowFoldWidgets=function(){return this.$showFoldWidgets}}).call(g.prototype),b.Gutter=g}),ace.define("ace/layer/marker",["require","exports","module","ace/range","ace/lib/dom"],function(a,b,c){"use strict";var d=a("../range").Range,e=a("../lib/dom"),f=function(a){this.element=e.createElement("div"),this.element.className="ace_layer ace_marker-layer",a.appendChild(this.element)};(function(){this.$padding=0,this.setPadding=function(a){this.$padding=a},this.setSession=function(a){this.session=a},this.setMarkers=function(a){this.markers=a},this.update=function(a){var a=a||this.config;if(!a)return;this.config=a;var b=[];for(var c in this.markers){var d=this.markers[c],f=d.range.clipRows(a.firstRow,a.lastRow);if(f.isEmpty())continue;f=f.toScreenRange(this.session);if(d.renderer){var g=this.$getTop(f.start.row,a),h=Math.round(this.$padding+f.start.column*a.characterWidth);d.renderer(b,f,h,g,a)}else f.isMultiLine()?d.type=="text"?this.drawTextMarker(b,f,d.clazz,a):this.drawMultiLineMarker(b,f,d.clazz,a,d.type):this.drawSingleLineMarker(b,f,d.clazz,a,null,d.type)}this.element=e.setInnerHtml(this.element,b.join(""))},this.$getTop=function(a,b){return(a-b.firstRowScreen)*b.lineHeight},this.drawTextMarker=function(a,b,c,e){var f=b.start.row,g=new d(f,b.start.column,f,this.session.getScreenLastRowColumn(f));this.drawSingleLineMarker(a,g,c,e,1,"text"),f=b.end.row,g=new d(f,0,f,b.end.column),this.drawSingleLineMarker(a,g,c,e,0,"text");for(f=b.start.row+1;f<b.end.row;f++)g.start.row=f,g.end.row=f,g.end.column=this.session.getScreenLastRowColumn(f),this.drawSingleLineMarker(a,g,c,e,1,"text")},this.drawMultiLineMarker=function(a,b,c,d,e){var f=e==="background"?0:this.$padding,g=d.width+2*this.$padding-f,h=d.lineHeight,i=Math.round(g-b.start.column*d.characterWidth),j=this.$getTop(b.start.row,d),k=Math.round(f+b.start.column*d.characterWidth);a.push("<div class='",c,"' style='","height:",h,"px;","width:",i,"px;","top:",j,"px;","left:",k,"px;'></div>"),j=this.$getTop(b.end.row,d),i=Math.round(b.end.column*d.characterWidth),a.push("<div class='",c,"' style='","height:",h,"px;","width:",i,"px;","top:",j,"px;","left:",f,"px;'></div>"),h=(b.end.row-b.start.row-1)*d.lineHeight;if(h<0)return;j=this.$getTop(b.start.row+1,d),a.push("<div class='",c,"' style='","height:",h,"px;","width:",g,"px;","top:",j,"px;","left:",f,"px;'></div>")},this.drawSingleLineMarker=function(a,b,c,d,e,f){var g=f==="background"?0:this.$padding,h=d.lineHeight;if(f==="background")var i=d.width;else i=Math.round((b.end.column+(e||0)-b.start.column)*d.characterWidth);var j=this.$getTop(b.start.row,d),k=Math.round(g+b.start.column*d.characterWidth);a.push("<div class='",c,"' style='","height:",h,"px;","width:",i,"px;","top:",j,"px;","left:",k,"px;'></div>")}}).call(f.prototype),b.Marker=f}),ace.define("ace/layer/text",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/lib/event_emitter"],function(a,b,c){"use strict";var d=a("../lib/oop"),e=a("../lib/dom"),f=a("../lib/lang"),g=a("../lib/useragent"),h=a("../lib/event_emitter").EventEmitter,i=function(a){this.element=e.createElement("div"),this.element.className="ace_layer ace_text-layer",a.appendChild(this.element),this.$characterSize=this.$measureSizes()||{width:0,height:0},this.$pollSizeChanges()};(function(){d.implement(this,h),this.EOF_CHAR="¶",this.EOL_CHAR="¬",this.TAB_CHAR="→",this.SPACE_CHAR="·",this.$padding=0,this.setPadding=function(a){this.$padding=a,this.element.style.padding="0 "+a+"px"},this.getLineHeight=function(){return this.$characterSize.height||1},this.getCharacterWidth=function(){return this.$characterSize.width||1},this.checkForSizeChanges=function(){var a=this.$measureSizes();a&&(this.$characterSize.width!==a.width||this.$characterSize.height!==a.height)&&(this.$characterSize=a,this._emit("changeCharacterSize",{data:a}))},this.$pollSizeChanges=function(){var a=this;this.$pollSizeChangesTimer=setInterval(function(){a.checkForSizeChanges()},500)},this.$fontStyles={fontFamily:1,fontSize:1,fontWeight:1,fontStyle:1,lineHeight:1},this.$measureSizes=function(){var a=1e3;if(!this.$measureNode){var b=this.$measureNode=e.createElement("div"),c=b.style;c.width=c.height="auto",c.left=c.top=-a*40+"px",c.visibility="hidden",c.position="absolute",c.overflow="visible",c.whiteSpace="nowrap",b.innerHTML=f.stringRepeat("Xy",a);if(this.element.ownerDocument.body)this.element.ownerDocument.body.appendChild(b);else{var d=this.element.parentNode;while(!e.hasCssClass(d,"ace_editor"))d=d.parentNode;d.appendChild(b)}}if(!this.element.offsetWidth)return null;var c=this.$measureNode.style,g=e.computedStyle(this.element);for(var h in this.$fontStyles)c[h]=g[h];var i={height:this.$measureNode.offsetHeight,width:this.$measureNode.offsetWidth/(a*2)};return i.width==0&&i.height==0?null:i},this.setSession=function(a){this.session=a},this.showInvisibles=!1,this.setShowInvisibles=function(a){return this.showInvisibles==a?!1:(this.showInvisibles=a,!0)},this.$tabStrings=[],this.$computeTabString=function(){var a=this.session.getTabSize(),b=this.$tabStrings=[0];for(var c=1;c<a+1;c++)this.showInvisibles?b.push("<span class='ace_invisible'>"+this.TAB_CHAR+(new Array(c)).join("&#160;")+"</span>"):b.push((new Array(c+1)).join("&#160;"))},this.updateLines=function(a,b,c){this.$computeTabString(),(this.config.lastRow!=a.lastRow||this.config.firstRow!=a.firstRow)&&this.scrollLines(a),this.config=a;var d=Math.max(b,a.firstRow),f=Math.min(c,a.lastRow),g=this.element.childNodes,h=0;for(var i=a.firstRow;i<d;i++){var j=this.session.getFoldLine(i);if(j){if(j.containsRow(d)){d=j.start.row;break}i=j.end.row}h++}for(var k=d;k<=f;k++){var l=g[h++];if(!l)continue;var m=[],n=this.session.getTokens(k,k);this.$renderLine(m,k,n[0].tokens,!this.$useLineGroups()),l=e.setInnerHtml(l,m.join("")),k=this.session.getRowFoldEnd(k)}},this.scrollLines=function(a){this.$computeTabString();var b=this.config;this.config=a;if(!b||b.lastRow<a.firstRow)return this.update(a);if(a.lastRow<b.firstRow)return this.update(a);var c=this.element;if(b.firstRow<a.firstRow)for(var d=this.session.getFoldedRowCount(b.firstRow,a.firstRow-1);d>0;d--)c.removeChild(c.firstChild);if(b.lastRow>a.lastRow)for(var d=this.session.getFoldedRowCount(a.lastRow+1,b.lastRow);d>0;d--)c.removeChild(c.lastChild);if(a.firstRow<b.firstRow){var e=this.$renderLinesFragment(a,a.firstRow,b.firstRow-1);c.firstChild?c.insertBefore(e,c.firstChild):c.appendChild(e)}if(a.lastRow>b.lastRow){var e=this.$renderLinesFragment(a,b.lastRow+1,a.lastRow);c.appendChild(e)}},this.$renderLinesFragment=function(a,b,c){var d=this.element.ownerDocument.createDocumentFragment(),f=b,g=this.session.getNextFoldLine(f),h=g?g.start.row:Infinity;for(;;){f>h&&(f=g.end.row+1,g=this.session.getNextFoldLine(f,g),h=g?g.start.row:Infinity);if(f>c)break;var i=e.createElement("div"),j=[],k=this.session.getTokens(f,f);k.length==1&&this.$renderLine(j,f,k[0].tokens,!1),i.innerHTML=j.join("");if(this.$useLineGroups())i.className="ace_line_group",d.appendChild(i);else{var l=i.childNodes;while(l.length)d.appendChild(l[0])}f++}return d},this.update=function(a){this.$computeTabString(),this.config=a;var b=[],c=a.firstRow,d=a.lastRow,f=c,g=this.session.getNextFoldLine(f),h=g?g.start.row:Infinity;for(;;){f>h&&(f=g.end.row+1,g=this.session.getNextFoldLine(f,g),h=g?g.start.row:Infinity);if(f>d)break;this.$useLineGroups()&&b.push("<div class='ace_line_group'>");var i=this.session.getTokens(f,f);i.length==1&&this.$renderLine(b,f,i[0].tokens,!1),this.$useLineGroups()&&b.push("</div>"),f++}this.element=e.setInnerHtml(this.element,b.join(""))},this.$textToken={text:!0,rparen:!0,lparen:!0},this.$renderToken=function(a,b,c,d){var e=this,f=/\t|&|<|( +)|([\v\f \u00a0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000])|[\u1100-\u115F]|[\u11A3-\u11A7]|[\u11FA-\u11FF]|[\u2329-\u232A]|[\u2E80-\u2E99]|[\u2E9B-\u2EF3]|[\u2F00-\u2FD5]|[\u2FF0-\u2FFB]|[\u3000-\u303E]|[\u3041-\u3096]|[\u3099-\u30FF]|[\u3105-\u312D]|[\u3131-\u318E]|[\u3190-\u31BA]|[\u31C0-\u31E3]|[\u31F0-\u321E]|[\u3220-\u3247]|[\u3250-\u32FE]|[\u3300-\u4DBF]|[\u4E00-\uA48C]|[\uA490-\uA4C6]|[\uA960-\uA97C]|[\uAC00-\uD7A3]|[\uD7B0-\uD7C6]|[\uD7CB-\uD7FB]|[\uF900-\uFAFF]|[\uFE10-\uFE19]|[\uFE30-\uFE52]|[\uFE54-\uFE66]|[\uFE68-\uFE6B]|[\uFF01-\uFF60]|[\uFFE0-\uFFE6]/g,h=function(a,c,d,f,h){if(a.charCodeAt(0)==32)return(new Array(a.length+1)).join("&#160;");if(a==" "){var i=e.session.getScreenTabSize(b+f);return b+=i-1,e.$tabStrings[i]}if(a=="&")return g.isOldGecko?"&":"&amp;";if(a=="<")return"&lt;";if(a==" "){var j=e.showInvisibles?"ace_cjk ace_invisible":"ace_cjk",k=e.showInvisibles?e.SPACE_CHAR:"";return b+=1,"<span class='"+j+"' style='width:"+e.config.characterWidth*2+"px'>"+k+"</span>"}if(a.match(/[\v\f \u00a0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000]/)){if(e.showInvisibles){var k=(new Array(a.length+1)).join(e.SPACE_CHAR);return"<span class='ace_invisible'>"+k+"</span>"}return"&#160;"}return b+=1,"<span class='ace_cjk' style='width:"+e.config.characterWidth*2+"px'>"+a+"</span>"},i=d.replace(f,h);if(!this.$textToken[c.type]){var j="ace_"+c.type.replace(/\./g," ace_"),k="";c.type=="fold"&&(k=" style='width:"+c.value.length*this.config.characterWidth+"px;' "),a.push("<span class='",j,"'",k,">",i,"</span>")}else a.push(i);return b+d.length},this.$renderLineCore=function(a,b,c,d,e){var f=0,g=0,h,i=0,j=this;!d||d.length==0?h=Number.MAX_VALUE:h=d[0],e||a.push("<div class='ace_line' style='height:",this.config.lineHeight,"px","'>");for(var k=0;k<c.length;k++){var l=c[k],m=l.value;if(f+m.length<h)i=j.$renderToken(a,i,l,m),f+=m.length;else{while(f+m.length>=h)i=j.$renderToken(a,i,l,m.substring(0,h-f)),m=m.substring(h-f),f=h,e||a.push("</div>","<div class='ace_line' style='height:",this.config.lineHeight,"px","'>"),g++,i=0,h=d[g]||Number.MAX_VALUE;m.length!=0&&(f+=m.length,i=j.$renderToken(a,i,l,m))}}this.showInvisibles&&(b!==this.session.getLength()-1?a.push("<span class='ace_invisible'>"+this.EOL_CHAR+"</span>"):a.push("<span class='ace_invisible'>"+this.EOF_CHAR+"</span>")),e||a.push("</div>")},this.$renderLine=function(a,b,c,d){if(!this.session.isRowFolded(b)){var e=this.session.getRowSplitData(b);this.$renderLineCore(a,b,c,e,d)}else this.$renderFoldLine(a,b,c,d)},this.$renderFoldLine=function(a,b,c,d){function h(a,b,c){var d=0,e=0;while(e+a[d].value.length<b){e+=a[d].value.length,d++;if(d==a.length)return}if(e!=b){var f=a[d].value.substring(b-e);f.length>c-b&&(f=f.substring(0,c-b)),g.push({type:a[d].type,value:f}),e=b+f.length,d+=1}while(e<c){var f=a[d].value;f.length+e>c&&(f=f.substring(0,c-e)),g.push({type:a[d].type,value:f}),e+=f.length,d+=1}}var e=this.session,f=e.getFoldLine(b),g=[];f.walk(function(a,b,d,e,f){a?g.push({type:"fold",value:a}):(f&&(c=this.session.getTokens(b,b)[0].tokens),c.length!=0&&h(c,e,d))}.bind(this),f.end.row,this.session.getLine(f.end.row).length);var i=this.session.$useWrapMode?this.session.$wrapData[b]:null;this.$renderLineCore(a,b,g,i,d)},this.$useLineGroups=function(){return this.session.getUseWrapMode()},this.destroy=function(){clearInterval(this.$pollSizeChangesTimer),this.$measureNode&&this.$measureNode.parentNode.removeChild(this.$measureNode),delete this.$measureNode}}).call(i.prototype),b.Text=i}),ace.define("ace/layer/cursor",["require","exports","module","ace/lib/dom"],function(a,b,c){"use strict";var d=a("../lib/dom"),e=function(a){this.element=d.createElement("div"),this.element.className="ace_layer ace_cursor-layer",a.appendChild(this.element),this.cursor=d.createElement("div"),this.cursor.className="ace_cursor ace_hidden",this.element.appendChild(this.cursor),this.isVisible=!1};(function(){this.$padding=0,this.setPadding=function(a){this.$padding=a},this.setSession=function(a){this.session=a},this.hideCursor=function(){this.isVisible=!1,d.addCssClass(this.cursor,"ace_hidden"),clearInterval(this.blinkId)},this.showCursor=function(){this.isVisible=!0,d.removeCssClass(this.cursor,"ace_hidden"),this.cursor.style.visibility="visible",this.restartTimer()},this.restartTimer=function(){clearInterval(this.blinkId);if(!this.isVisible)return;var a=this.cursor;this.blinkId=setInterval(function(){a.style.visibility="hidden",setTimeout(function(){a.style.visibility="visible"},400)},1e3)},this.getPixelPosition=function(a,b){if(!this.config||!this.session)return{left:0,top:0};a||(a=this.session.selection.getCursor());var c=this.session.documentToScreenPosition(a),d=Math.round(this.$padding+c.column*this.config.characterWidth),e=(c.row-(b?this.config.firstRowScreen:0))*this.config.lineHeight;return{left:d,top:e}},this.update=function(a){this.config=a,this.pixelPos=this.getPixelPosition(null,!0),this.cursor.style.left=this.pixelPos.left+"px",this.cursor.style.top=this.pixelPos.top+"px",this.cursor.style.width=a.characterWidth+"px",this.cursor.style.height=a.lineHeight+"px";var b=this.session.getOverwrite();b!=this.overwrite&&(this.overwrite=b,b?d.addCssClass(this.cursor,"ace_overwrite"):d.removeCssClass(this.cursor,"ace_overwrite")),this.restartTimer()},this.destroy=function(){clearInterval(this.blinkId)}}).call(e.prototype),b.Cursor=e}),ace.define("ace/scrollbar",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/event_emitter"],function(a,b,c){"use strict";var d=a("./lib/oop"),e=a("./lib/dom"),f=a("./lib/event"),g=a("./lib/event_emitter").EventEmitter,h=function(a){this.element=e.createElement("div"),this.element.className="ace_sb",this.inner=e.createElement("div"),this.element.appendChild(this.inner),a.appendChild(this.element),this.width=e.scrollbarWidth(a.ownerDocument),this.element.style.width=(this.width||15)+5+"px",f.addListener(this.element,"scroll",this.onScroll.bind(this))};(function(){d.implement(this,g),this.onScroll=function(){this._emit("scroll",{data:this.element.scrollTop})},this.getWidth=function(){return this.width},this.setHeight=function(a){this.element.style.height=a+"px"},this.setInnerHeight=function(a){this.inner.style.height=a+"px"},this.setScrollTop=function(a){this.element.scrollTop=a}}).call(h.prototype),b.ScrollBar=h}),ace.define("ace/renderloop",["require","exports","module","ace/lib/event"],function(a,b,c){"use strict";var d=a("./lib/event"),e=function(a,b){this.onRender=a,this.pending=!1,this.changes=0,this.window=b||window};(function(){this.schedule=function(a){this.changes=this.changes|a;if(!this.pending){this.pending=!0;var b=this;d.nextTick(function(){b.pending=!1;var a;while(a=b.changes)b.changes=0,b.onRender(a)},this.window)}}}).call(e.prototype),b.RenderLoop=e}),ace.define("text!ace/css/editor.css",[],"@import url(//fonts.googleapis.com/css?family=Droid+Sans+Mono);\n\n\n.ace_editor {\n position: absolute;\n overflow: hidden;\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Droid Sans Mono', 'Consolas', monospace;\n font-size: 12px;\n}\n\n.ace_scroller {\n position: absolute;\n overflow-x: scroll;\n overflow-y: hidden;\n}\n\n.ace_content {\n position: absolute;\n box-sizing: border-box;\n -moz-box-sizing: border-box;\n -webkit-box-sizing: border-box;\n cursor: text;\n}\n\n.ace_composition {\n position: absolute;\n background: #555;\n color: #DDD;\n z-index: 4;\n}\n\n.ace_gutter {\n position: absolute;\n overflow : hidden;\n height: 100%;\n width: auto;\n cursor: default;\n}\n\n.ace_gutter-cell {\n padding-left: 19px;\n padding-right: 6px;\n}\n\n.ace_gutter-cell.ace_error {\n background-image: url(\"data:image/gif,GIF89a%10%00%10%00%D5%00%00%F5or%F5%87%88%F5nr%F4ns%EBmq%F5z%7F%DDJT%DEKS%DFOW%F1Yc%F2ah%CE(7%CE)8%D18E%DD%40M%F2KZ%EBU%60%F4%60m%DCir%C8%16(%C8%19*%CE%255%F1%3FR%F1%3FS%E6%AB%B5%CA%5DI%CEn%5E%F7%A2%9A%C9G%3E%E0a%5B%F7%89%85%F5yy%F6%82%80%ED%82%80%FF%BF%BF%E3%C4%C4%FF%FF%FF%FF%FF%FF%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00!%F9%04%01%00%00%25%00%2C%00%00%00%00%10%00%10%00%00%06p%C0%92pH%2C%1A%8F%C8%D2H%93%E1d4%23%E4%88%D3%09mB%1DN%B48%F5%90%40%60%92G%5B%94%20%3E%22%D2%87%24%FA%20%24%C5%06A%00%20%B1%07%02B%A38%89X.v%17%82%11%13q%10%0Fi%24%0F%8B%10%7BD%12%0Ei%09%92%09%0EpD%18%15%24%0A%9Ci%05%0C%18F%18%0B%07%04%01%04%06%A0H%18%12%0D%14%0D%12%A1I%B3%B4%B5IA%00%3B\");\n background-repeat: no-repeat;\n background-position: 2px center;\n}\n\n.ace_gutter-cell.ace_warning {\n background-image: url(\"data:image/gif,GIF89a%10%00%10%00%D5%00%00%FF%DBr%FF%DE%81%FF%E2%8D%FF%E2%8F%FF%E4%96%FF%E3%97%FF%E5%9D%FF%E6%9E%FF%EE%C1%FF%C8Z%FF%CDk%FF%D0s%FF%D4%81%FF%D5%82%FF%D5%83%FF%DC%97%FF%DE%9D%FF%E7%B8%FF%CCl%7BQ%13%80U%15%82W%16%81U%16%89%5B%18%87%5B%18%8C%5E%1A%94d%1D%C5%83-%C9%87%2F%C6%84.%C6%85.%CD%8B2%C9%871%CB%8A3%CD%8B5%DC%98%3F%DF%9BB%E0%9CC%E1%A5U%CB%871%CF%8B5%D1%8D6%DB%97%40%DF%9AB%DD%99B%E3%B0p%E7%CC%AE%FF%FF%FF%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00!%F9%04%01%00%00%2F%00%2C%00%00%00%00%10%00%10%00%00%06a%C0%97pH%2C%1A%8FH%A1%ABTr%25%87%2B%04%82%F4%7C%B9X%91%08%CB%99%1C!%26%13%84*iJ9(%15G%CA%84%14%01%1A%97%0C%03%80%3A%9A%3E%81%84%3E%11%08%B1%8B%20%02%12%0F%18%1A%0F%0A%03'F%1C%04%0B%10%16%18%10%0B%05%1CF%1D-%06%07%9A%9A-%1EG%1B%A0%A1%A0U%A4%A5%A6BA%00%3B\");\n background-repeat: no-repeat;\n background-position: 2px center;\n}\n\n.ace_gutter-cell.ace_info {\n background-image: url(\"data:image/gif;base64,R0lGODlhEAAQAMQAAAAAAEFBQVJSUl5eXmRkZGtra39/f4WFhYmJiZGRkaampry8vMPDw8zMzNXV1dzc3OTk5Orq6vDw8P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABQALAAAAAAQABAAAAUuICWOZGmeaBml5XGwFCQSBGyXRSAwtqQIiRuiwIM5BoYVbEFIyGCQoeJGrVptIQA7\");\n background-repeat: no-repeat;\n background-position: 2px center;\n}\n\n.ace_editor .ace_sb {\n position: absolute;\n overflow-x: hidden;\n overflow-y: scroll;\n right: 0;\n}\n\n.ace_editor .ace_sb div {\n position: absolute;\n width: 1px;\n left: 0;\n}\n\n.ace_editor .ace_print_margin_layer {\n z-index: 0;\n position: absolute;\n overflow: hidden;\n margin: 0;\n left: 0;\n height: 100%;\n width: 100%;\n}\n\n.ace_editor .ace_print_margin {\n position: absolute;\n height: 100%;\n}\n\n.ace_editor textarea {\n position: fixed;\n z-index: 0;\n width: 10px;\n height: 30px;\n opacity: 0;\n background: transparent;\n appearance: none;\n -moz-appearance: none;\n border: none;\n resize: none;\n outline: none;\n overflow: hidden;\n}\n\n.ace_layer {\n z-index: 1;\n position: absolute;\n overflow: hidden;\n white-space: nowrap;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n -moz-box-sizing: border-box;\n -webkit-box-sizing: border-box;\n /* setting pointer-events: auto; on node under the mouse, which changes\n during scroll, will break mouse wheel scrolling in Safari */\n pointer-events: none;\n}\n\n.ace_gutter .ace_layer {\n position: relative;\n min-width: 40px;\n text-align: right;\n pointer-events: auto;\n}\n\n.ace_text-layer {\n color: black;\n}\n\n.ace_cjk {\n display: inline-block;\n text-align: center;\n}\n\n.ace_cursor-layer {\n z-index: 4;\n}\n\n.ace_cursor {\n z-index: 4;\n position: absolute;\n}\n\n.ace_cursor.ace_hidden {\n opacity: 0.2;\n}\n\n.ace_line {\n white-space: nowrap;\n}\n\n.ace_marker-layer .ace_step {\n position: absolute;\n z-index: 3;\n}\n\n.ace_marker-layer .ace_selection {\n position: absolute;\n z-index: 4;\n}\n\n.ace_marker-layer .ace_bracket {\n position: absolute;\n z-index: 5;\n}\n\n.ace_marker-layer .ace_active_line {\n position: absolute;\n z-index: 2;\n}\n\n.ace_marker-layer .ace_selected_word {\n position: absolute;\n z-index: 6;\n box-sizing: border-box;\n -moz-box-sizing: border-box;\n -webkit-box-sizing: border-box;\n}\n\n.ace_line .ace_fold {\n box-sizing: border-box;\n -moz-box-sizing: border-box;\n -webkit-box-sizing: border-box;\n \n display: inline-block;\n height: 11px;\n margin-top: -2px;\n vertical-align: middle;\n\n background-image: \n url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%11%00%00%00%09%08%06%00%00%00%D4%E8%C7%0C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%00%B5IDAT(%15%A5%91%3D%0E%02!%10%85ac%E1%05%D6%CE%D6%C6%CE%D2%E8%ED%CD%DE%C0%C6%D6N.%E0V%F8%3D%9Ca%891XH%C2%BE%D9y%3F%90!%E6%9C%C3%BFk%E5%011%C6-%F5%C8N%04%DF%BD%FF%89%DFt%83DN%60%3E%F3%AB%A0%DE%1A%5Dg%BE%10Q%97%1B%40%9C%A8o%10%8F%5E%828%B4%1B%60%87%F6%02%26%85%1Ch%1E%C1%2B%5Bk%FF%86%EE%B7j%09%9A%DA%9B%ACe%A3%F9%EC%DA!9%B4%D5%A6%81%86%86%98%CC%3C%5B%40%FA%81%B3%E9%CB%23%94%C16Azo%05%D4%E1%C1%95a%3B%8A'%A0%E8%CC%17%22%85%1D%BA%00%A2%FA%DC%0A%94%D1%D1%8D%8B%3A%84%17B%C7%60%1A%25Z%FC%8D%00%00%00%00IEND%AEB%60%82\"),\n url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%007%08%06%00%00%00%C4%DD%80C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%00%3AIDAT8%11c%FC%FF%FF%7F%18%03%1A%60%01%F2%3F%A0%891%80%04%FF%11-%F8%17%9BJ%E2%05%B1ZD%81v%26t%E7%80%F8%A3%82h%A12%1A%20%A3%01%02%0F%01%BA%25%06%00%19%C0%0D%AEF%D5%3ES%00%00%00%00IEND%AEB%60%82\");\n background-repeat: no-repeat, repeat-x;\n background-position: center center, top left;\n color: transparent;\n\n border: 1px solid black;\n -moz-border-radius: 2px;\n -webkit-border-radius: 2px;\n border-radius: 2px;\n \n cursor: pointer;\n pointer-events: auto;\n}\n\n.ace_dark .ace_fold {\n}\n\n.ace_fold:hover{\n background-image: \n url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%11%00%00%00%09%08%06%00%00%00%D4%E8%C7%0C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%00%B5IDAT(%15%A5%91%3D%0E%02!%10%85ac%E1%05%D6%CE%D6%C6%CE%D2%E8%ED%CD%DE%C0%C6%D6N.%E0V%F8%3D%9Ca%891XH%C2%BE%D9y%3F%90!%E6%9C%C3%BFk%E5%011%C6-%F5%C8N%04%DF%BD%FF%89%DFt%83DN%60%3E%F3%AB%A0%DE%1A%5Dg%BE%10Q%97%1B%40%9C%A8o%10%8F%5E%828%B4%1B%60%87%F6%02%26%85%1Ch%1E%C1%2B%5Bk%FF%86%EE%B7j%09%9A%DA%9B%ACe%A3%F9%EC%DA!9%B4%D5%A6%81%86%86%98%CC%3C%5B%40%FA%81%B3%E9%CB%23%94%C16Azo%05%D4%E1%C1%95a%3B%8A'%A0%E8%CC%17%22%85%1D%BA%00%A2%FA%DC%0A%94%D1%D1%8D%8B%3A%84%17B%C7%60%1A%25Z%FC%8D%00%00%00%00IEND%AEB%60%82\"),\n url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%007%08%06%00%00%00%C4%DD%80C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%003IDAT8%11c%FC%FF%FF%7F%3E%03%1A%60%01%F2%3F%A3%891%80%04%FFQ%26%F8w%C0%B43%A1%DB%0C%E2%8F%0A%A2%85%CAh%80%8C%06%08%3C%04%E8%96%18%00%A3S%0D%CD%CF%D8%C1%9D%00%00%00%00IEND%AEB%60%82\");\n background-repeat: no-repeat, repeat-x;\n background-position: center center, top left;\n}\n\n.ace_dragging .ace_content {\n cursor: move;\n}\n\n.ace_folding-enabled > .ace_gutter-cell {\n padding-right: 13px;\n}\n\n.ace_fold-widget {\n box-sizing: border-box;\n -moz-box-sizing: border-box;\n -webkit-box-sizing: border-box;\n\n margin: 0 -12px 1px 1px;\n display: inline-block;\n height: 14px;\n width: 11px;\n vertical-align: text-bottom;\n \n background-image: url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%00%05%08%06%00%00%00%8Do%26%E5%00%00%004IDATx%DAe%8A%B1%0D%000%0C%C2%F2%2CK%96%BC%D0%8F9%81%88H%E9%D0%0E%96%C0%10%92%3E%02%80%5E%82%E4%A9*-%EEsw%C8%CC%11%EE%96w%D8%DC%E9*Eh%0C%151(%00%00%00%00IEND%AEB%60%82\");\n background-repeat: no-repeat;\n background-position: center 5px;\n\n border-radius: 3px;\n}\n\n.ace_fold-widget.end {\n background-image: url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%00%05%08%06%00%00%00%8Do%26%E5%00%00%004IDATx%DAm%C7%C1%09%000%08C%D1%8C%ECE%C8E(%8E%EC%02)%1EZJ%F1%C1'%04%07I%E1%E5%EE%CAL%F5%A2%99%99%22%E2%D6%1FU%B5%FE0%D9x%A7%26Wz5%0E%D5%00%00%00%00IEND%AEB%60%82\");\n}\n\n.ace_fold-widget.closed {\n background-image: url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%03%00%00%00%06%08%06%00%00%00%06%E5%24%0C%00%00%009IDATx%DA5%CA%C1%09%000%08%03%C0%AC*(%3E%04%C1%0D%BA%B1%23%A4Uh%E0%20%81%C0%CC%F8%82%81%AA%A2%AArGfr%88%08%11%11%1C%DD%7D%E0%EE%5B%F6%F6%CB%B8%05Q%2F%E9tai%D9%00%00%00%00IEND%AEB%60%82\");\n}\n\n.ace_fold-widget:hover {\n border: 1px solid rgba(0, 0, 0, 0.3);\n background-color: rgba(255, 255, 255, 0.2);\n -moz-box-shadow:inset 0 1px 1px rgba(255, 255, 255, 0.7);\n -moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\n -webkit-box-shadow:inset 0 1px 1px rgba(255, 255, 255, 0.7);\n -webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\n box-shadow:inset 0 1px 1px rgba(255, 255, 255, 0.7);\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\n background-position: center 4px;\n}\n\n.ace_fold-widget:active {\n border: 1px solid rgba(0, 0, 0, 0.4);\n background-color: rgba(0, 0, 0, 0.05);\n -moz-box-shadow:inset 0 1px 1px rgba(255, 255, 255);\n -moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\n -webkit-box-shadow:inset 0 1px 1px rgba(255, 255, 255);\n -webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\n box-shadow:inset 0 1px 1px rgba(255, 255, 255);\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\n}\n\n.ace_fold-widget.invalid {\n background-color: #FFB4B4;\n border-color: #DE5555;\n}\n"),ace.define("ace/worker/worker_client",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/config"],function(a,b,c){"use strict";var d=a("../lib/oop"),e=a("../lib/event_emitter").EventEmitter,f=a("../config"),g=function(b,c,d,e){this.changeListener=this.changeListener.bind(this);if(f.get("packaged"))this.$worker=new Worker(f.get("workerPath")+"/"+c);else{var g=this.$normalizePath(a.nameToUrl("ace/worker/worker",null,"_"));this.$worker=new Worker(g);var h={};for(var i=0;i<b.length;i++){var j=b[i],k=this.$normalizePath(a.nameToUrl(j,null,"_").replace(/.js$/,""));h[j]=k}}this.$worker.postMessage({init:!0,tlns:h,module:d,classname:e}),this.callbackId=1,this.callbacks={};var l=this;this.$worker.onerror=function(a){throw window.console&&console.log&&console.log(a),a},this.$worker.onmessage=function(a){var b=a.data;switch(b.type){case"log":window.console&&console.log&&console.log(b.data);break;case"event":l._emit(b.name,{data:b.data});break;case"call":var c=l.callbacks[b.id];c&&(c(b.data),delete l.callbacks[b.id])}}};(function(){d.implement(this,e),this.$normalizePath=function(a){return a=a.replace(/^[a-z]+:\/\/[^\/]+/,""),a=location.protocol+"//"+location.host+(a.charAt(0)=="/"?"":location.pathname.replace(/\/[^\/]*$/,""))+"/"+a.replace(/^[\/]+/,""),a},this.terminate=function(){this._emit("terminate",{}),this.$worker.terminate(),this.$worker=null,this.$doc.removeEventListener("change",this.changeListener),this.$doc=null},this.send=function(a,b){this.$worker.postMessage({command:a,args:b})},this.call=function(a,b,c){if(c){var d=this.callbackId++;this.callbacks[d]=c,b.push(d)}this.send(a,b)},this.emit=function(a,b){try{this.$worker.postMessage({event:a,data:{data:b.data}})}catch(c){}},this.attachToDocument=function(a){this.$doc&&this.terminate(),this.$doc=a,this.call("setValue",[a.getValue()]),a.on("change",this.changeListener)},this.changeListener=function(a){a.range={start:a.data.range.start,end:a.data.range.end},this.emit("change",a)}}).call(g.prototype),b.WorkerClient=g}),ace.define("ace/keyboard/hash_handler",["require","exports","module","ace/lib/keys"],function(a,b,c){function e(a){this.setConfig(a)}"use strict";var d=a("../lib/keys");(function(){function a(a,b,c,d){return(d&&a.toLowerCase()||a).replace(/(?:^\s+|\n|\s+$)/g,"").split(new RegExp("[\\s ]*"+b+"[\\s ]*","g"),c||999)}function b(b,c,e){var f,g=0,h=a(b,"\\-",null,!0),i=0,j=h.length;for(;i<j;++i)d.KEY_MODS[h[i]]?g|=d.KEY_MODS[h[i]]:f=h[i]||"-";return(e[g]||(e[g]={}))[f]=c,e}function c(a,c){var d,e,f,g,h={};for(d in a){g=a[d];if(c&&typeof g=="string"){g=g.split(c);for(e=0,f=g.length;e<f;++e)b.call(this,g[e],d,h)}else b.call(this,g,d,h)}return h}this.setConfig=function(a){this.$config=a,typeof this.$config.reverse=="undefined"&&(this.$config.reverse=c.call(this,this.$config,"|"))},this.handleKeyboard=function(a,b,c,d){return b!=0||d!=0?{command:(this.$config.reverse[b]||{})[c]}:{command:"inserttext",args:{text:c}}}}).call(e.prototype),b.HashHandler=e}),ace.define("ace/keyboard/state_handler",["require","exports","module"],function(a,b,c){function e(a){this.keymapping=this.$buildKeymappingRegex(a)}"use strict";var d=!1;e.prototype={$buildKeymappingRegex:function(a){for(var b in a)this.$buildBindingsRegex(a[b]);return a},$buildBindingsRegex:function(a){a.forEach(function(a){a.key?a.key=new RegExp("^"+a.key+"$"):Array.isArray(a.regex)?("key"in a||(a.key=new RegExp("^"+a.regex[1]+"$")),a.regex=new RegExp(a.regex.join("")+"$")):a.regex&&(a.regex=new RegExp(a.regex+"$"))})},$composeBuffer:function(a,b,c,d){if(a.state==null||a.buffer==null)a.state="start",a.buffer="";var e=[];b&1&&e.push("ctrl"),b&8&&e.push("command"),b&2&&e.push("option"),b&4&&e.push("shift"),c&&e.push(c);var f=e.join("-"),g=a.buffer+f;b!=2&&(a.buffer=g);var h={bufferToUse:g,symbolicName:f};return d&&(h.keyIdentifier=d.keyIdentifier),h},$find:function(a,b,c,e,f,g){var h={};return this.keymapping[a.state].some(function(i){var j;if(i.key&&!i.key.test(c))return!1;if(i.regex&&!(j=i.regex.exec(b)))return!1;if(i.match&&!i.match(b,e,f,c,g))return!1;if(i.disallowMatches)for(var k=0;k<i.disallowMatches.length;k++)if(!!j[i.disallowMatches[k]])return!1;if(i.exec){h.command=i.exec;if(i.params){var l;h.args={},i.params.forEach(function(a){a.match!=null&&j!=null?l=j[a.match]||a.defaultValue:l=a.defaultValue,a.type==="number"&&(l=parseInt(l)),h.args[a.name]=l})}a.buffer=""}return i.then&&(a.state=i.then,a.buffer=""),h.command==null&&(h.command="null"),d&&console.log("KeyboardStateMapper#find",i),!0}),h.command?h:(a.buffer="",!1)},handleKeyboard:function(a,b,c,e,f){if(b==0||c!=""&&c!=String.fromCharCode(0)){var g=this.$composeBuffer(a,b,c,f),h=g.bufferToUse,i=g.symbolicName,j=g.keyIdentifier;return g=this.$find(a,h,i,b,c,j),d&&console.log("KeyboardStateMapper#match",h,i,g),g}return null}},b.matchCharacterOnly=function(a,b,c,d){return b==0?!0:b==4&&c.length==1?!0:!1},b.StateHandler=e}),ace.define("ace/placeholder",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/oop"],function(a,b,c){"use strict";var d=a("./range").Range,e=a("./lib/event_emitter").EventEmitter,f=a("./lib/oop"),g=function(a,b,c,d,e,f){var g=this;this.length=b,this.session=a,this.doc=a.getDocument(),this.mainClass=e,this.othersClass=f,this.$onUpdate=this.onUpdate.bind(this),this.doc.on("change",this.$onUpdate),this.$others=d,this.$onCursorChange=function(){setTimeout(function(){g.onCursorChange()})},this.$pos=c;var h=a.getUndoManager().$undoStack||a.getUndoManager().$undostack||{length:-1};this.$undoStackDepth=h.length,this.setup(),a.selection.on("changeCursor",this.$onCursorChange)};(function(){f.implement(this,e),this.setup=function(){var a=this,b=this.doc,c=this.session,e=this.$pos;this.pos=b.createAnchor(e.row,e.column),this.markerId=c.addMarker(new d(e.row,e.column,e.row,e.column+this.length),this.mainClass,null,!1),this.pos.on("change",function(b){c.removeMarker(a.markerId),a.markerId=c.addMarker(new d(b.value.row,b.value.column,b.value.row,b.value.column+a.length),a.mainClass,null,!1)}),this.others=[],this.$others.forEach(function(c){var d=b.createAnchor(c.row,c.column);a.others.push(d)}),c.setUndoSelect(!1)},this.showOtherMarkers=function(){if(this.othersActive)return;var a=this.session,b=this;this.othersActive=!0,this.others.forEach(function(c){c.markerId=a.addMarker(new d(c.row,c.column,c.row,c.column+b.length),b.othersClass,null,!1),c.on("change",function(e){a.removeMarker(c.markerId),c.markerId=a.addMarker(new d(e.value.row,e.value.column,e.value.row,e.value.column+b.length),b.othersClass,null,!1)})})},this.hideOtherMarkers=function(){if(!this.othersActive)return;this.othersActive=!1;for(var a=0;a<this.others.length;a++)this.session.removeMarker(this.others[a].markerId)},this.onUpdate=function(a){var b=a.data,c=b.range;if(c.start.row!==c.end.row)return;if(c.start.row!==this.pos.row)return;if(this.$updating)return;this.$updating=!0;var e=b.action==="insertText"?c.end.column-c.start.column:c.start.column-c.end.column;if(c.start.column>=this.pos.column&&c.start.column<=this.pos.column+this.length+1){var f=c.start.column-this.pos.column;this.length+=e;if(!this.session.$fromUndo){if(b.action==="insertText")for(var g=this.others.length-1;g>=0;g--){var h=this.others[g],i={row:h.row,column:h.column+f};h.row===c.start.row&&c.start.column<h.column&&(i.column+=e),this.doc.insert(i,b.text)}else if(b.action==="removeText")for(var g=this.others.length-1;g>=0;g--){var h=this.others[g],i={row:h.row,column:h.column+f};h.row===c.start.row&&c.start.column<h.column&&(i.column+=e),this.doc.remove(new d(i.row,i.column,i.row,i.column-e))}c.start.column===this.pos.column&&b.action==="insertText"?setTimeout(function(){this.pos.setPosition(this.pos.row,this.pos.column-e);for(var a=0;a<this.others.length;a++){var b=this.others[a],d={row:b.row,column:b.column-e};b.row===c.start.row&&c.start.column<b.column&&(d.column+=e),b.setPosition(d.row,d.column)}}.bind(this),0):c.start.column===this.pos.column&&b.action==="removeText"&&setTimeout(function(){for(var a=0;a<this.others.length;a++){var b=this.others[a];b.row===c.start.row&&c.start.column<b.column&&b.setPosition(b.row,b.column-e)}}.bind(this),0)}this.pos._emit("change",{value:this.pos});for(var g=0;g<this.others.length;g++)this.others[g]._emit("change",{value:this.others[g]})}this.$updating=!1},this.onCursorChange=function(a){if(this.$updating)return;var b=this.session.selection.getCursor();b.row===this.pos.row&&b.column>=this.pos.column&&b.column<=this.pos.column+this.length?(this.showOtherMarkers(),this._emit("cursorEnter",a)):(this.hideOtherMarkers(),this._emit("cursorLeave",a))},this.detach=function(){this.session.removeMarker(this.markerId),this.hideOtherMarkers(),this.doc.removeEventListener("change",this.$onUpdate),this.session.selection.removeEventListener("changeCursor",this.$onCursorChange),this.pos.detach();for(var a=0;a<this.others.length;a++)this.others[a].detach();this.session.setUndoSelect(!0)},this.cancel=function(){if(this.$undoStackDepth===-1)throw Error("Canceling placeholders only supported with undo manager attached to session.");var a=this.session.getUndoManager(),b=(a.$undoStack||a.$undostack).length-this.$undoStackDepth;for(var c=0;c<b;c++)a.undo(!0)}}).call(g.prototype),b.PlaceHolder=g}),ace.define("ace/theme/textmate",["require","exports","module","ace/lib/dom"],function(a,b,c){"use strict",b.isDark=!1,b.cssClass="ace-tm",b.cssText=".ace-tm .ace_editor { border: 2px solid rgb(159, 159, 159);}.ace-tm .ace_editor.ace_focus { border: 2px solid #327fbd;}.ace-tm .ace_gutter { background: #e8e8e8; color: #333;}.ace-tm .ace_print_margin { width: 1px; background: #e8e8e8;}.ace-tm .ace_fold { background-color: #6B72E6;}.ace-tm .ace_text-layer { cursor: text;}.ace-tm .ace_cursor { border-left: 2px solid black;}.ace-tm .ace_cursor.ace_overwrite { border-left: 0px; border-bottom: 1px solid black;} .ace-tm .ace_line .ace_invisible { color: rgb(191, 191, 191);}.ace-tm .ace_line .ace_storage,.ace-tm .ace_line .ace_keyword { color: blue;}.ace-tm .ace_line .ace_constant.ace_buildin { color: rgb(88, 72, 246);}.ace-tm .ace_line .ace_constant.ace_language { color: rgb(88, 92, 246);}.ace-tm .ace_line .ace_constant.ace_library { color: rgb(6, 150, 14);}.ace-tm .ace_line .ace_invalid { background-color: rgb(153, 0, 0); color: white;}.ace-tm .ace_line .ace_support.ace_function { color: rgb(60, 76, 114);}.ace-tm .ace_line .ace_support.ace_constant { color: rgb(6, 150, 14);}.ace-tm .ace_line .ace_support.ace_type,.ace-tm .ace_line .ace_support.ace_class { color: rgb(109, 121, 222);}.ace-tm .ace_line .ace_keyword.ace_operator { color: rgb(104, 118, 135);}.ace-tm .ace_line .ace_string { color: rgb(3, 106, 7);}.ace-tm .ace_line .ace_comment { color: rgb(76, 136, 107);}.ace-tm .ace_line .ace_comment.ace_doc { color: rgb(0, 102, 255);}.ace-tm .ace_line .ace_comment.ace_doc.ace_tag { color: rgb(128, 159, 191);}.ace-tm .ace_line .ace_constant.ace_numeric { color: rgb(0, 0, 205);}.ace-tm .ace_line .ace_variable { color: rgb(49, 132, 149);}.ace-tm .ace_line .ace_xml_pe { color: rgb(104, 104, 91);}.ace-tm .ace_entity.ace_name.ace_function { color: #0000A2;}.ace-tm .ace_markup.ace_markupine { text-decoration:underline;}.ace-tm .ace_markup.ace_heading { color: rgb(12, 7, 255);}.ace-tm .ace_markup.ace_list { color:rgb(185, 6, 144);}.ace-tm .ace_marker-layer .ace_selection { background: rgb(181, 213, 255);}.ace-tm .ace_marker-layer .ace_step { background: rgb(252, 255, 0);}.ace-tm .ace_marker-layer .ace_stack { background: rgb(164, 229, 101);}.ace-tm .ace_marker-layer .ace_bracket { margin: -1px 0 0 -1px; border: 1px solid rgb(192, 192, 192);}.ace-tm .ace_marker-layer .ace_active_line { background: rgba(0, 0, 0, 0.07);}.ace-tm .ace_marker-layer .ace_selected_word { background: rgb(250, 250, 255); border: 1px solid rgb(200, 200, 250);}.ace-tm .ace_meta.ace_tag { color:rgb(28, 2, 255);}.ace-tm .ace_string.ace_regex { color: rgb(255, 0, 0)}";var d=a("../lib/dom");d.importCssString(b.cssText,b.cssClass)});
2
+ (function() {
3
+ ace.require(["ace/ace"], function(a) {
4
+ if (!window.ace)
5
+ window.ace = {};
6
+ for (var key in a) if (a.hasOwnProperty(key))
7
+ ace[key] = a[key];
8
+ });
9
+ })();
10
+
ace-0.2.0/src/ace-uncompressed-noconflict.js ADDED
@@ -0,0 +1,15264 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* ***** BEGIN LICENSE BLOCK *****
2
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3
+ *
4
+ * The contents of this file are subject to the Mozilla Public License Version
5
+ * 1.1 (the "License"); you may not use this file except in compliance with
6
+ * the License. You may obtain a copy of the License at
7
+ * http://www.mozilla.org/MPL/
8
+ *
9
+ * Software distributed under the License is distributed on an "AS IS" basis,
10
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
+ * for the specific language governing rights and limitations under the
12
+ * License.
13
+ *
14
+ * The Original Code is Ajax.org Code Editor (ACE).
15
+ *
16
+ * The Initial Developer of the Original Code is
17
+ * Ajax.org B.V.
18
+ * Portions created by the Initial Developer are Copyright (C) 2010
19
+ * the Initial Developer. All Rights Reserved.
20
+ *
21
+ * Contributor(s):
22
+ * Fabian Jakobs <fabian AT ajax DOT org>
23
+ *
24
+ * Alternatively, the contents of this file may be used under the terms of
25
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
26
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
+ * in which case the provisions of the GPL or the LGPL are applicable instead
28
+ * of those above. If you wish to allow use of your version of this file only
29
+ * under the terms of either the GPL or the LGPL, and not to allow others to
30
+ * use your version of this file under the terms of the MPL, indicate your
31
+ * decision by deleting the provisions above and replace them with the notice
32
+ * and other provisions required by the GPL or the LGPL. If you do not delete
33
+ * the provisions above, a recipient may use your version of this file under
34
+ * the terms of any one of the MPL, the GPL or the LGPL.
35
+ *
36
+ * ***** END LICENSE BLOCK ***** */
37
+
38
+ /**
39
+ * Define a module along with a payload
40
+ * @param module a name for the payload
41
+ * @param payload a function to call with (require, exports, module) params
42
+ */
43
+
44
+ (function() {
45
+
46
+ var ACE_NAMESPACE = "ace";
47
+
48
+ var global = (function() {
49
+ return this;
50
+ })();
51
+
52
+ var _define = function(module, deps, payload) {
53
+ if (typeof module !== 'string') {
54
+ if (_define.original)
55
+ _define.original.apply(window, arguments);
56
+ else {
57
+ console.error('dropping module because define wasn\'t a string.');
58
+ console.trace();
59
+ }
60
+ return;
61
+ }
62
+
63
+ if (arguments.length == 2)
64
+ payload = deps;
65
+
66
+ if (!_define.modules)
67
+ _define.modules = {};
68
+
69
+ _define.modules[module] = payload;
70
+ };
71
+
72
+ /**
73
+ * Get at functionality ace.define()ed using the function above
74
+ */
75
+ var _require = function(parentId, module, callback) {
76
+ if (Object.prototype.toString.call(module) === "[object Array]") {
77
+ var params = [];
78
+ for (var i = 0, l = module.length; i < l; ++i) {
79
+ var dep = lookup(parentId, module[i]);
80
+ if (!dep && _require.original)
81
+ return _require.original.apply(window, arguments);
82
+ params.push(dep);
83
+ }
84
+ if (callback) {
85
+ callback.apply(null, params);
86
+ }
87
+ }
88
+ else if (typeof module === 'string') {
89
+ var payload = lookup(parentId, module);
90
+ if (!payload && _require.original)
91
+ return _require.original.apply(window, arguments);
92
+
93
+ if (callback) {
94
+ callback();
95
+ }
96
+
97
+ return payload;
98
+ }
99
+ else {
100
+ if (_require.original)
101
+ return _require.original.apply(window, arguments);
102
+ }
103
+ };
104
+
105
+ var normalizeModule = function(parentId, moduleName) {
106
+ // normalize plugin requires
107
+ if (moduleName.indexOf("!") !== -1) {
108
+ var chunks = moduleName.split("!");
109
+ return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]);
110
+ }
111
+ // normalize relative requires
112
+ if (moduleName.charAt(0) == ".") {
113
+ var base = parentId.split("/").slice(0, -1).join("/");
114
+ moduleName = base + "/" + moduleName;
115
+
116
+ while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
117
+ var previous = moduleName;
118
+ moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
119
+ }
120
+ }
121
+
122
+ return moduleName;
123
+ };
124
+
125
+ /**
126
+ * Internal function to lookup moduleNames and resolve them by calling the
127
+ * definition function if needed.
128
+ */
129
+ var lookup = function(parentId, moduleName) {
130
+
131
+ moduleName = normalizeModule(parentId, moduleName);
132
+
133
+ var module = _define.modules[moduleName];
134
+ if (!module) {
135
+ return null;
136
+ }
137
+
138
+ if (typeof module === 'function') {
139
+ var exports = {};
140
+ var mod = {
141
+ id: moduleName,
142
+ uri: '',
143
+ exports: exports,
144
+ packaged: true
145
+ };
146
+
147
+ var req = function(module, callback) {
148
+ return _require(moduleName, module, callback);
149
+ };
150
+
151
+ var returnValue = module(req, exports, mod);
152
+ exports = returnValue || mod.exports;
153
+
154
+ // cache the resulting module object for next time
155
+ _define.modules[moduleName] = exports;
156
+ return exports;
157
+ }
158
+
159
+ return module;
160
+ };
161
+
162
+ function exportAce(ns) {
163
+
164
+ if (typeof requirejs !== "undefined") {
165
+
166
+ var define = global.define;
167
+ global.define = function(id, deps, callback) {
168
+ if (typeof callback !== "function")
169
+ return define.apply(this, arguments);
170
+
171
+ return ace.define(id, deps, function(require, exports, module) {
172
+ if (deps[2] == "module")
173
+ module.packaged = true;
174
+ return callback.apply(this, arguments);
175
+ });
176
+ };
177
+ global.define.packaged = true;
178
+
179
+ return;
180
+ }
181
+
182
+ var require = function(module, callback) {
183
+ return _require("", module, callback);
184
+ };
185
+ require.packaged = true;
186
+
187
+ var root = global;
188
+ if (ns) {
189
+ if (!global[ns])
190
+ global[ns] = {};
191
+ root = global[ns];
192
+ }
193
+
194
+ if (root.define)
195
+ _define.original = root.define;
196
+
197
+ root.define = _define;
198
+
199
+ if (root.require)
200
+ _require.original = root.require;
201
+
202
+ root.require = require;
203
+ }
204
+
205
+ exportAce(ACE_NAMESPACE);
206
+
207
+ })();/* ***** BEGIN LICENSE BLOCK *****
208
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
209
+ *
210
+ * The contents of this file are subject to the Mozilla Public License Version
211
+ * 1.1 (the "License"); you may not use this file except in compliance with
212
+ * the License. You may obtain a copy of the License at
213
+ * http://www.mozilla.org/MPL/
214
+ *
215
+ * Software distributed under the License is distributed on an "AS IS" basis,
216
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
217
+ * for the specific language governing rights and limitations under the
218
+ * License.
219
+ *
220
+ * The Original Code is Mozilla Skywriter.
221
+ *
222
+ * The Initial Developer of the Original Code is
223
+ * Mozilla.
224
+ * Portions created by the Initial Developer are Copyright (C) 2009
225
+ * the Initial Developer. All Rights Reserved.
226
+ *
227
+ * Contributor(s):
228
+ * Kevin Dangoor (kdangoor@mozilla.com)
229
+ *
230
+ * Alternatively, the contents of this file may be used under the terms of
231
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
232
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
233
+ * in which case the provisions of the GPL or the LGPL are applicable instead
234
+ * of those above. If you wish to allow use of your version of this file only
235
+ * under the terms of either the GPL or the LGPL, and not to allow others to
236
+ * use your version of this file under the terms of the MPL, indicate your
237
+ * decision by deleting the provisions above and replace them with the notice
238
+ * and other provisions required by the GPL or the LGPL. If you do not delete
239
+ * the provisions above, a recipient may use your version of this file under
240
+ * the terms of any one of the MPL, the GPL or the LGPL.
241
+ *
242
+ * ***** END LICENSE BLOCK ***** */
243
+
244
+ ace.define('ace/ace', ['require', 'exports', 'module' , 'ace/lib/fixoldbrowsers', 'ace/lib/dom', 'ace/lib/event', 'ace/editor', 'ace/edit_session', 'ace/undomanager', 'ace/virtual_renderer', 'ace/worker/worker_client', 'ace/keyboard/hash_handler', 'ace/keyboard/state_handler', 'ace/lib/net', 'ace/placeholder', 'ace/config', 'ace/theme/textmate'], function(require, exports, module) {
245
+ "use strict";
246
+
247
+ require("./lib/fixoldbrowsers");
248
+
249
+ var Dom = require("./lib/dom");
250
+ var Event = require("./lib/event");
251
+
252
+ var Editor = require("./editor").Editor;
253
+ var EditSession = require("./edit_session").EditSession;
254
+ var UndoManager = require("./undomanager").UndoManager;
255
+ var Renderer = require("./virtual_renderer").VirtualRenderer;
256
+
257
+ // The following require()s are for inclusion in the built ace file
258
+ require("./worker/worker_client");
259
+ require("./keyboard/hash_handler");
260
+ require("./keyboard/state_handler");
261
+ require("./lib/net");
262
+ require("./placeholder");
263
+ require("./config").init();
264
+
265
+ exports.edit = function(el) {
266
+ if (typeof(el) == "string") {
267
+ el = document.getElementById(el);
268
+ }
269
+
270
+ var doc = new EditSession(Dom.getInnerText(el));
271
+ doc.setUndoManager(new UndoManager());
272
+ el.innerHTML = '';
273
+
274
+ var editor = new Editor(new Renderer(el, require("./theme/textmate")));
275
+ editor.setSession(doc);
276
+
277
+ var env = {};
278
+ env.document = doc;
279
+ env.editor = editor;
280
+ editor.resize();
281
+ Event.addListener(window, "resize", function() {
282
+ editor.resize();
283
+ });
284
+ el.env = env;
285
+ // Store env on editor such that it can be accessed later on from
286
+ // the returned object.
287
+ editor.env = env;
288
+ return editor;
289
+ };
290
+
291
+ });// vim:set ts=4 sts=4 sw=4 st:
292
+ // -- kriskowal Kris Kowal Copyright (C) 2009-2010 MIT License
293
+ // -- tlrobinson Tom Robinson Copyright (C) 2009-2010 MIT License (Narwhal Project)
294
+ // -- dantman Daniel Friesen Copyright(C) 2010 XXX No License Specified
295
+ // -- fschaefer Florian Schäfer Copyright (C) 2010 MIT License
296
+ // -- Irakli Gozalishvili Copyright (C) 2010 MIT License
297
+
298
+ /*!
299
+ Copyright (c) 2009, 280 North Inc. http://280north.com/
300
+ MIT License. http://github.com/280north/narwhal/blob/master/README.md
301
+ */
302
+
303
+ ace.define('ace/lib/fixoldbrowsers', ['require', 'exports', 'module' , 'ace/lib/regexp', 'ace/lib/es5-shim'], function(require, exports, module) {
304
+ "use strict";
305
+
306
+ require("./regexp");
307
+ require("./es5-shim");
308
+
309
+ });/**
310
+ * Based on code from:
311
+ *
312
+ * XRegExp 1.5.0
313
+ * (c) 2007-2010 Steven Levithan
314
+ * MIT License
315
+ * <http://xregexp.com>
316
+ * Provides an augmented, extensible, cross-browser implementation of regular expressions,
317
+ * including support for additional syntax, flags, and methods
318
+ */
319
+
320
+ ace.define('ace/lib/regexp', ['require', 'exports', 'module' ], function(require, exports, module) {
321
+ "use strict";
322
+
323
+ //---------------------------------
324
+ // Private variables
325
+ //---------------------------------
326
+
327
+ var real = {
328
+ exec: RegExp.prototype.exec,
329
+ test: RegExp.prototype.test,
330
+ match: String.prototype.match,
331
+ replace: String.prototype.replace,
332
+ split: String.prototype.split
333
+ },
334
+ compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups
335
+ compliantLastIndexIncrement = function () {
336
+ var x = /^/g;
337
+ real.test.call(x, "");
338
+ return !x.lastIndex;
339
+ }();
340
+
341
+ //---------------------------------
342
+ // Overriden native methods
343
+ //---------------------------------
344
+
345
+ // Adds named capture support (with backreferences returned as `result.name`), and fixes two
346
+ // cross-browser issues per ES3:
347
+ // - Captured values for nonparticipating capturing groups should be returned as `undefined`,
348
+ // rather than the empty string.
349
+ // - `lastIndex` should not be incremented after zero-length matches.
350
+ RegExp.prototype.exec = function (str) {
351
+ var match = real.exec.apply(this, arguments),
352
+ name, r2;
353
+ if ( typeof(str) == 'string' && match) {
354
+ // Fix browsers whose `exec` methods don't consistently return `undefined` for
355
+ // nonparticipating capturing groups
356
+ if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) {
357
+ r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", ""));
358
+ // Using `str.slice(match.index)` rather than `match[0]` in case lookahead allowed
359
+ // matching due to characters outside the match
360
+ real.replace.call(str.slice(match.index), r2, function () {
361
+ for (var i = 1; i < arguments.length - 2; i++) {
362
+ if (arguments[i] === undefined)
363
+ match[i] = undefined;
364
+ }
365
+ });
366
+ }
367
+ // Attach named capture properties
368
+ if (this._xregexp && this._xregexp.captureNames) {
369
+ for (var i = 1; i < match.length; i++) {
370
+ name = this._xregexp.captureNames[i - 1];
371
+ if (name)
372
+ match[name] = match[i];
373
+ }
374
+ }
375
+ // Fix browsers that increment `lastIndex` after zero-length matches
376
+ if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))
377
+ this.lastIndex--;
378
+ }
379
+ return match;
380
+ };
381
+
382
+ // Don't override `test` if it won't change anything
383
+ if (!compliantLastIndexIncrement) {
384
+ // Fix browser bug in native method
385
+ RegExp.prototype.test = function (str) {
386
+ // Use the native `exec` to skip some processing overhead, even though the overriden
387
+ // `exec` would take care of the `lastIndex` fix
388
+ var match = real.exec.call(this, str);
389
+ // Fix browsers that increment `lastIndex` after zero-length matches
390
+ if (match && this.global && !match[0].length && (this.lastIndex > match.index))
391
+ this.lastIndex--;
392
+ return !!match;
393
+ };
394
+ }
395
+
396
+ //---------------------------------
397
+ // Private helper functions
398
+ //---------------------------------
399
+
400
+ function getNativeFlags (regex) {
401
+ return (regex.global ? "g" : "") +
402
+ (regex.ignoreCase ? "i" : "") +
403
+ (regex.multiline ? "m" : "") +
404
+ (regex.extended ? "x" : "") + // Proposed for ES4; included in AS3
405
+ (regex.sticky ? "y" : "");
406
+ };
407
+
408
+ function indexOf (array, item, from) {
409
+ if (Array.prototype.indexOf) // Use the native array method if available
410
+ return array.indexOf(item, from);
411
+ for (var i = from || 0; i < array.length; i++) {
412
+ if (array[i] === item)
413
+ return i;
414
+ }
415
+ return -1;
416
+ };
417
+
418
+ });
419
+ // vim: ts=4 sts=4 sw=4 expandtab
420
+ // -- kriskowal Kris Kowal Copyright (C) 2009-2011 MIT License
421
+ // -- tlrobinson Tom Robinson Copyright (C) 2009-2010 MIT License (Narwhal Project)
422
+ // -- dantman Daniel Friesen Copyright (C) 2010 XXX TODO License or CLA
423
+ // -- fschaefer Florian Schäfer Copyright (C) 2010 MIT License
424
+ // -- Gozala Irakli Gozalishvili Copyright (C) 2010 MIT License
425
+ // -- kitcambridge Kit Cambridge Copyright (C) 2011 MIT License
426
+ // -- kossnocorp Sasha Koss XXX TODO License or CLA
427
+ // -- bryanforbes Bryan Forbes XXX TODO License or CLA
428
+ // -- killdream Quildreen Motta Copyright (C) 2011 MIT Licence
429
+ // -- michaelficarra Michael Ficarra Copyright (C) 2011 3-clause BSD License
430
+ // -- sharkbrainguy Gerard Paapu Copyright (C) 2011 MIT License
431
+ // -- bbqsrc Brendan Molloy (C) 2011 Creative Commons Zero (public domain)
432
+ // -- iwyg XXX TODO License or CLA
433
+ // -- DomenicDenicola Domenic Denicola Copyright (C) 2011 MIT License
434
+ // -- xavierm02 Montillet Xavier XXX TODO License or CLA
435
+ // -- Raynos Raynos XXX TODO License or CLA
436
+ // -- samsonjs Sami Samhuri Copyright (C) 2010 MIT License
437
+ // -- rwldrn Rick Waldron Copyright (C) 2011 MIT License
438
+ // -- lexer Alexey Zakharov XXX TODO License or CLA
439
+
440
+ /*!
441
+ Copyright (c) 2009, 280 North Inc. http://280north.com/
442
+ MIT License. http://github.com/280north/narwhal/blob/master/README.md
443
+ */
444
+
445
+ ace.define('ace/lib/es5-shim', ['require', 'exports', 'module' ], function(require, exports, module) {
446
+
447
+ /**
448
+ * Brings an environment as close to ECMAScript 5 compliance
449
+ * as is possible with the facilities of erstwhile engines.
450
+ *
451
+ * Annotated ES5: http://es5.github.com/ (specific links below)
452
+ * ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
453
+ *
454
+ * @module
455
+ */
456
+
457
+ /*whatsupdoc*/
458
+
459
+ //
460
+ // Function
461
+ // ========
462
+ //
463
+
464
+ // ES-5 15.3.4.5
465
+ // http://es5.github.com/#x15.3.4.5
466
+
467
+ if (!Function.prototype.bind) {
468
+ Function.prototype.bind = function bind(that) { // .length is 1
469
+ // 1. Let Target be the this value.
470
+ var target = this;
471
+ // 2. If IsCallable(Target) is false, throw a TypeError exception.
472
+ if (typeof target != "function")
473
+ throw new TypeError(); // TODO message
474
+ // 3. Let A be a new (possibly empty) internal list of all of the
475
+ // argument values provided after thisArg (arg1, arg2 etc), in order.
476
+ // XXX slicedArgs will stand in for "A" if used
477
+ var args = slice.call(arguments, 1); // for normal call
478
+ // 4. Let F be a new native ECMAScript object.
479
+ // 11. Set the [[Prototype]] internal property of F to the standard
480
+ // built-in Function prototype object as specified in 15.3.3.1.
481
+ // 12. Set the [[Call]] internal property of F as described in
482
+ // 15.3.4.5.1.
483
+ // 13. Set the [[Construct]] internal property of F as described in
484
+ // 15.3.4.5.2.
485
+ // 14. Set the [[HasInstance]] internal property of F as described in
486
+ // 15.3.4.5.3.
487
+ var bound = function () {
488
+
489
+ if (this instanceof bound) {
490
+ // 15.3.4.5.2 [[Construct]]
491
+ // When the [[Construct]] internal method of a function object,
492
+ // F that was created using the bind function is called with a
493
+ // list of arguments ExtraArgs, the following steps are taken:
494
+ // 1. Let target be the value of F's [[TargetFunction]]
495
+ // internal property.
496
+ // 2. If target has no [[Construct]] internal method, a
497
+ // TypeError exception is thrown.
498
+ // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
499
+ // property.
500
+ // 4. Let args be a new list containing the same values as the
501
+ // list boundArgs in the same order followed by the same
502
+ // values as the list ExtraArgs in the same order.
503
+ // 5. Return the result of calling the [[Construct]] internal
504
+ // method of target providing args as the arguments.
505
+
506
+ var F = function(){};
507
+ F.prototype = target.prototype;
508
+ var self = new F;
509
+
510
+ var result = target.apply(
511
+ self,
512
+ args.concat(slice.call(arguments))
513
+ );
514
+ if (result !== null && Object(result) === result)
515
+ return result;
516
+ return self;
517
+
518
+ } else {
519
+ // 15.3.4.5.1 [[Call]]
520
+ // When the [[Call]] internal method of a function object, F,
521
+ // which was created using the bind function is called with a
522
+ // this value and a list of arguments ExtraArgs, the following
523
+ // steps are taken:
524
+ // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
525
+ // property.
526
+ // 2. Let boundThis be the value of F's [[BoundThis]] internal
527
+ // property.
528
+ // 3. Let target be the value of F's [[TargetFunction]] internal
529
+ // property.
530
+ // 4. Let args be a new list containing the same values as the
531
+ // list boundArgs in the same order followed by the same
532
+ // values as the list ExtraArgs in the same order.
533
+ // 5. Return the result of calling the [[Call]] internal method
534
+ // of target providing boundThis as the this value and
535
+ // providing args as the arguments.
536
+
537
+ // equiv: target.call(this, ...boundArgs, ...args)
538
+ return target.apply(
539
+ that,
540
+ args.concat(slice.call(arguments))
541
+ );
542
+
543
+ }
544
+
545
+ };
546
+ // XXX bound.length is never writable, so don't even try
547
+ //
548
+ // 15. If the [[Class]] internal property of Target is "Function", then
549
+ // a. Let L be the length property of Target minus the length of A.
550
+ // b. Set the length own property of F to either 0 or L, whichever is
551
+ // larger.
552
+ // 16. Else set the length own property of F to 0.
553
+ // 17. Set the attributes of the length own property of F to the values
554
+ // specified in 15.3.5.1.
555
+
556
+ // TODO
557
+ // 18. Set the [[Extensible]] internal property of F to true.
558
+
559
+ // TODO
560
+ // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
561
+ // 20. Call the [[DefineOwnProperty]] internal method of F with
562
+ // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
563
+ // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
564
+ // false.
565
+ // 21. Call the [[DefineOwnProperty]] internal method of F with
566
+ // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
567
+ // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
568
+ // and false.
569
+
570
+ // TODO
571
+ // NOTE Function objects created using Function.prototype.bind do not
572
+ // have a prototype property or the [[Code]], [[FormalParameters]], and
573
+ // [[Scope]] internal properties.
574
+ // XXX can't delete prototype in pure-js.
575
+
576
+ // 22. Return F.
577
+ return bound;
578
+ };
579
+ }
580
+
581
+ // Shortcut to an often accessed properties, in order to avoid multiple
582
+ // dereference that costs universally.
583
+ // _Please note: Shortcuts are defined after `Function.prototype.bind` as we
584
+ // us it in defining shortcuts.
585
+ var call = Function.prototype.call;
586
+ var prototypeOfArray = Array.prototype;
587
+ var prototypeOfObject = Object.prototype;
588
+ var slice = prototypeOfArray.slice;
589
+ var toString = call.bind(prototypeOfObject.toString);
590
+ var owns = call.bind(prototypeOfObject.hasOwnProperty);
591
+
592
+ // If JS engine supports accessors creating shortcuts.
593
+ var defineGetter;
594
+ var defineSetter;
595
+ var lookupGetter;
596
+ var lookupSetter;
597
+ var supportsAccessors;
598
+ if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
599
+ defineGetter = call.bind(prototypeOfObject.__defineGetter__);
600
+ defineSetter = call.bind(prototypeOfObject.__defineSetter__);
601
+ lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
602
+ lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
603
+ }
604
+
605
+ //
606
+ // Array
607
+ // =====
608
+ //
609
+
610
+ // ES5 15.4.3.2
611
+ // http://es5.github.com/#x15.4.3.2
612
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
613
+ if (!Array.isArray) {
614
+ Array.isArray = function isArray(obj) {
615
+ return toString(obj) == "[object Array]";
616
+ };
617
+ }
618
+
619
+ // The IsCallable() check in the Array functions
620
+ // has been replaced with a strict check on the
621
+ // internal class of the object to trap cases where
622
+ // the provided function was actually a regular
623
+ // expression literal, which in V8 and
624
+ // JavaScriptCore is a typeof "function". Only in
625
+ // V8 are regular expression literals permitted as
626
+ // reduce parameters, so it is desirable in the
627
+ // general case for the shim to match the more
628
+ // strict and common behavior of rejecting regular
629
+ // expressions.
630
+
631
+ // ES5 15.4.4.18
632
+ // http://es5.github.com/#x15.4.4.18
633
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach
634
+ if (!Array.prototype.forEach) {
635
+ Array.prototype.forEach = function forEach(fun /*, thisp*/) {
636
+ var self = toObject(this),
637
+ thisp = arguments[1],
638
+ i = 0,
639
+ length = self.length >>> 0;
640
+
641
+ // If no callback function or if callback is not a callable function
642
+ if (toString(fun) != "[object Function]") {
643
+ throw new TypeError(); // TODO message
644
+ }
645
+
646
+ while (i < length) {
647
+ if (i in self) {
648
+ // Invoke the callback function with call, passing arguments:
649
+ // context, property value, property key, thisArg object context
650
+ fun.call(thisp, self[i], i, self);
651
+ }
652
+ i++;
653
+ }
654
+ };
655
+ }
656
+
657
+ // ES5 15.4.4.19
658
+ // http://es5.github.com/#x15.4.4.19
659
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
660
+ if (!Array.prototype.map) {
661
+ Array.prototype.map = function map(fun /*, thisp*/) {
662
+ var self = toObject(this),
663
+ length = self.length >>> 0,
664
+ result = Array(length),
665
+ thisp = arguments[1];
666
+
667
+ // If no callback function or if callback is not a callable function
668
+ if (toString(fun) != "[object Function]") {
669
+ throw new TypeError(); // TODO message
670
+ }
671
+
672
+ for (var i = 0; i < length; i++) {
673
+ if (i in self)
674
+ result[i] = fun.call(thisp, self[i], i, self);
675
+ }
676
+ return result;
677
+ };
678
+ }
679
+
680
+ // ES5 15.4.4.20
681
+ // http://es5.github.com/#x15.4.4.20
682
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
683
+ if (!Array.prototype.filter) {
684
+ Array.prototype.filter = function filter(fun /*, thisp */) {
685
+ var self = toObject(this),
686
+ length = self.length >>> 0,
687
+ result = [],
688
+ thisp = arguments[1];
689
+
690
+ // If no callback function or if callback is not a callable function
691
+ if (toString(fun) != "[object Function]") {
692
+ throw new TypeError(); // TODO message
693
+ }
694
+
695
+ for (var i = 0; i < length; i++) {
696
+ if (i in self && fun.call(thisp, self[i], i, self))
697
+ result.push(self[i]);
698
+ }
699
+ return result;
700
+ };
701
+ }
702
+
703
+ // ES5 15.4.4.16
704
+ // http://es5.github.com/#x15.4.4.16
705
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every
706
+ if (!Array.prototype.every) {
707
+ Array.prototype.every = function every(fun /*, thisp */) {
708
+ var self = toObject(this),
709
+ length = self.length >>> 0,
710
+ thisp = arguments[1];
711
+
712
+ // If no callback function or if callback is not a callable function
713
+ if (toString(fun) != "[object Function]") {
714
+ throw new TypeError(); // TODO message
715
+ }
716
+
717
+ for (var i = 0; i < length; i++) {
718
+ if (i in self && !fun.call(thisp, self[i], i, self))
719
+ return false;
720
+ }
721
+ return true;
722
+ };
723
+ }
724
+
725
+ // ES5 15.4.4.17
726
+ // http://es5.github.com/#x15.4.4.17
727
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
728
+ if (!Array.prototype.some) {
729
+ Array.prototype.some = function some(fun /*, thisp */) {
730
+ var self = toObject(this),
731
+ length = self.length >>> 0,
732
+ thisp = arguments[1];
733
+
734
+ // If no callback function or if callback is not a callable function
735
+ if (toString(fun) != "[object Function]") {
736
+ throw new TypeError(); // TODO message
737
+ }
738
+
739
+ for (var i = 0; i < length; i++) {
740
+ if (i in self && fun.call(thisp, self[i], i, self))
741
+ return true;
742
+ }
743
+ return false;
744
+ };
745
+ }
746
+
747
+ // ES5 15.4.4.21
748
+ // http://es5.github.com/#x15.4.4.21
749
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
750
+ if (!Array.prototype.reduce) {
751
+ Array.prototype.reduce = function reduce(fun /*, initial*/) {
752
+ var self = toObject(this),
753
+ length = self.length >>> 0;
754
+
755
+ // If no callback function or if callback is not a callable function
756
+ if (toString(fun) != "[object Function]") {
757
+ throw new TypeError(); // TODO message
758
+ }
759
+
760
+ // no value to return if no initial value and an empty array
761
+ if (!length && arguments.length == 1)
762
+ throw new TypeError(); // TODO message
763
+
764
+ var i = 0;
765
+ var result;
766
+ if (arguments.length >= 2) {
767
+ result = arguments[1];
768
+ } else {
769
+ do {
770
+ if (i in self) {
771
+ result = self[i++];
772
+ break;
773
+ }
774
+
775
+ // if array contains no values, no initial value to return
776
+ if (++i >= length)
777
+ throw new TypeError(); // TODO message
778
+ } while (true);
779
+ }
780
+
781
+ for (; i < length; i++) {
782
+ if (i in self)
783
+ result = fun.call(void 0, result, self[i], i, self);
784
+ }
785
+
786
+ return result;
787
+ };
788
+ }
789
+
790
+ // ES5 15.4.4.22
791
+ // http://es5.github.com/#x15.4.4.22
792
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
793
+ if (!Array.prototype.reduceRight) {
794
+ Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
795
+ var self = toObject(this),
796
+ length = self.length >>> 0;
797
+
798
+ // If no callback function or if callback is not a callable function
799
+ if (toString(fun) != "[object Function]") {
800
+ throw new TypeError(); // TODO message
801
+ }
802
+
803
+ // no value to return if no initial value, empty array
804
+ if (!length && arguments.length == 1)
805
+ throw new TypeError(); // TODO message
806
+
807
+ var result, i = length - 1;
808
+ if (arguments.length >= 2) {
809
+ result = arguments[1];
810
+ } else {
811
+ do {
812
+ if (i in self) {
813
+ result = self[i--];
814
+ break;
815
+ }
816
+
817
+ // if array contains no values, no initial value to return
818
+ if (--i < 0)
819
+ throw new TypeError(); // TODO message
820
+ } while (true);
821
+ }
822
+
823
+ do {
824
+ if (i in this)
825
+ result = fun.call(void 0, result, self[i], i, self);
826
+ } while (i--);
827
+
828
+ return result;
829
+ };
830
+ }
831
+
832
+ // ES5 15.4.4.14
833
+ // http://es5.github.com/#x15.4.4.14
834
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
835
+ if (!Array.prototype.indexOf) {
836
+ Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
837
+ var self = toObject(this),
838
+ length = self.length >>> 0;
839
+
840
+ if (!length)
841
+ return -1;
842
+
843
+ var i = 0;
844
+ if (arguments.length > 1)
845
+ i = toInteger(arguments[1]);
846
+
847
+ // handle negative indices
848
+ i = i >= 0 ? i : Math.max(0, length + i);
849
+ for (; i < length; i++) {
850
+ if (i in self && self[i] === sought) {
851
+ return i;
852
+ }
853
+ }
854
+ return -1;
855
+ };
856
+ }
857
+
858
+ // ES5 15.4.4.15
859
+ // http://es5.github.com/#x15.4.4.15
860
+ // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
861
+ if (!Array.prototype.lastIndexOf) {
862
+ Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
863
+ var self = toObject(this),
864
+ length = self.length >>> 0;
865
+
866
+ if (!length)
867
+ return -1;
868
+ var i = length - 1;
869
+ if (arguments.length > 1)
870
+ i = Math.min(i, toInteger(arguments[1]));
871
+ // handle negative indices
872
+ i = i >= 0 ? i : length - Math.abs(i);
873
+ for (; i >= 0; i--) {
874
+ if (i in self && sought === self[i])
875
+ return i;
876
+ }
877
+ return -1;
878
+ };
879
+ }
880
+
881
+ //
882
+ // Object
883
+ // ======
884
+ //
885
+
886
+ // ES5 15.2.3.2
887
+ // http://es5.github.com/#x15.2.3.2
888
+ if (!Object.getPrototypeOf) {
889
+ // https://github.com/kriskowal/es5-shim/issues#issue/2
890
+ // http://ejohn.org/blog/objectgetprototypeof/
891
+ // recommended by fschaefer on github
892
+ Object.getPrototypeOf = function getPrototypeOf(object) {
893
+ return object.__proto__ || (
894
+ object.constructor ?
895
+ object.constructor.prototype :
896
+ prototypeOfObject
897
+ );
898
+ };
899
+ }
900
+
901
+ // ES5 15.2.3.3
902
+ // http://es5.github.com/#x15.2.3.3
903
+ if (!Object.getOwnPropertyDescriptor) {
904
+ var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
905
+ "non-object: ";
906
+ Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
907
+ if ((typeof object != "object" && typeof object != "function") || object === null)
908
+ throw new TypeError(ERR_NON_OBJECT + object);
909
+ // If object does not owns property return undefined immediately.
910
+ if (!owns(object, property))
911
+ return;
912
+
913
+ var descriptor, getter, setter;
914
+
915
+ // If object has a property then it's for sure both `enumerable` and
916
+ // `configurable`.
917
+ descriptor = { enumerable: true, configurable: true };
918
+
919
+ // If JS engine supports accessor properties then property may be a
920
+ // getter or setter.
921
+ if (supportsAccessors) {
922
+ // Unfortunately `__lookupGetter__` will return a getter even
923
+ // if object has own non getter property along with a same named
924
+ // inherited getter. To avoid misbehavior we temporary remove
925
+ // `__proto__` so that `__lookupGetter__` will return getter only
926
+ // if it's owned by an object.
927
+ var prototype = object.__proto__;
928
+ object.__proto__ = prototypeOfObject;
929
+
930
+ var getter = lookupGetter(object, property);
931
+ var setter = lookupSetter(object, property);
932
+
933
+ // Once we have getter and setter we can put values back.
934
+ object.__proto__ = prototype;
935
+
936
+ if (getter || setter) {
937
+ if (getter) descriptor.get = getter;
938
+ if (setter) descriptor.set = setter;
939
+
940
+ // If it was accessor property we're done and return here
941
+ // in order to avoid adding `value` to the descriptor.
942
+ return descriptor;
943
+ }
944
+ }
945
+
946
+ // If we got this far we know that object has an own property that is
947
+ // not an accessor so we set it as a value and return descriptor.
948
+ descriptor.value = object[property];
949
+ return descriptor;
950
+ };
951
+ }
952
+
953
+ // ES5 15.2.3.4
954
+ // http://es5.github.com/#x15.2.3.4
955
+ if (!Object.getOwnPropertyNames) {
956
+ Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
957
+ return Object.keys(object);
958
+ };
959
+ }
960
+
961
+ // ES5 15.2.3.5
962
+ // http://es5.github.com/#x15.2.3.5
963
+ if (!Object.create) {
964
+ Object.create = function create(prototype, properties) {
965
+ var object;
966
+ if (prototype === null) {
967
+ object = { "__proto__": null };
968
+ } else {
969
+ if (typeof prototype != "object")
970
+ throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
971
+ var Type = function () {};
972
+ Type.prototype = prototype;
973
+ object = new Type();
974
+ // IE has no built-in implementation of `Object.getPrototypeOf`
975
+ // neither `__proto__`, but this manually setting `__proto__` will
976
+ // guarantee that `Object.getPrototypeOf` will work as expected with
977
+ // objects created using `Object.create`
978
+ object.__proto__ = prototype;
979
+ }
980
+ if (properties !== void 0)
981
+ Object.defineProperties(object, properties);
982
+ return object;
983
+ };
984
+ }
985
+
986
+ // ES5 15.2.3.6
987
+ // http://es5.github.com/#x15.2.3.6
988
+
989
+ // Patch for WebKit and IE8 standard mode
990
+ // Designed by hax <hax.github.com>
991
+ // related issue: https://github.com/kriskowal/es5-shim/issues#issue/5
992
+ // IE8 Reference:
993
+ // http://msdn.microsoft.com/en-us/library/dd282900.aspx
994
+ // http://msdn.microsoft.com/en-us/library/dd229916.aspx
995
+ // WebKit Bugs:
996
+ // https://bugs.webkit.org/show_bug.cgi?id=36423
997
+
998
+ function doesDefinePropertyWork(object) {
999
+ try {
1000
+ Object.defineProperty(object, "sentinel", {});
1001
+ return "sentinel" in object;
1002
+ } catch (exception) {
1003
+ // returns falsy
1004
+ }
1005
+ }
1006
+
1007
+ // check whether defineProperty works if it's given. Otherwise,
1008
+ // shim partially.
1009
+ if (Object.defineProperty) {
1010
+ var definePropertyWorksOnObject = doesDefinePropertyWork({});
1011
+ var definePropertyWorksOnDom = typeof document == "undefined" ||
1012
+ doesDefinePropertyWork(document.createElement("div"));
1013
+ if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
1014
+ var definePropertyFallback = Object.defineProperty;
1015
+ }
1016
+ }
1017
+
1018
+ if (!Object.defineProperty || definePropertyFallback) {
1019
+ var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
1020
+ var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
1021
+ var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
1022
+ "on this javascript engine";
1023
+
1024
+ Object.defineProperty = function defineProperty(object, property, descriptor) {
1025
+ if ((typeof object != "object" && typeof object != "function") || object === null)
1026
+ throw new TypeError(ERR_NON_OBJECT_TARGET + object);
1027
+ if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
1028
+ throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
1029
+
1030
+ // make a valiant attempt to use the real defineProperty
1031
+ // for I8's DOM elements.
1032
+ if (definePropertyFallback) {
1033
+ try {
1034
+ return definePropertyFallback.call(Object, object, property, descriptor);
1035
+ } catch (exception) {
1036
+ // try the shim if the real one doesn't work
1037
+ }
1038
+ }
1039
+
1040
+ // If it's a data property.
1041
+ if (owns(descriptor, "value")) {
1042
+ // fail silently if "writable", "enumerable", or "configurable"
1043
+ // are requested but not supported
1044
+ /*
1045
+ // alternate approach:
1046
+ if ( // can't implement these features; allow false but not true
1047
+ !(owns(descriptor, "writable") ? descriptor.writable : true) ||
1048
+ !(owns(descriptor, "enumerable") ? descriptor.enumerable : true) ||
1049
+ !(owns(descriptor, "configurable") ? descriptor.configurable : true)
1050
+ )
1051
+ throw new RangeError(
1052
+ "This implementation of Object.defineProperty does not " +
1053
+ "support configurable, enumerable, or writable."
1054
+ );
1055
+ */
1056
+
1057
+ if (supportsAccessors && (lookupGetter(object, property) ||
1058
+ lookupSetter(object, property)))
1059
+ {
1060
+ // As accessors are supported only on engines implementing
1061
+ // `__proto__` we can safely override `__proto__` while defining
1062
+ // a property to make sure that we don't hit an inherited
1063
+ // accessor.
1064
+ var prototype = object.__proto__;
1065
+ object.__proto__ = prototypeOfObject;
1066
+ // Deleting a property anyway since getter / setter may be
1067
+ // defined on object itself.
1068
+ delete object[property];
1069
+ object[property] = descriptor.value;
1070
+ // Setting original `__proto__` back now.
1071
+ object.__proto__ = prototype;
1072
+ } else {
1073
+ object[property] = descriptor.value;
1074
+ }
1075
+ } else {
1076
+ if (!supportsAccessors)
1077
+ throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
1078
+ // If we got that far then getters and setters can be defined !!
1079
+ if (owns(descriptor, "get"))
1080
+ defineGetter(object, property, descriptor.get);
1081
+ if (owns(descriptor, "set"))
1082
+ defineSetter(object, property, descriptor.set);
1083
+ }
1084
+
1085
+ return object;
1086
+ };
1087
+ }
1088
+
1089
+ // ES5 15.2.3.7
1090
+ // http://es5.github.com/#x15.2.3.7
1091
+ if (!Object.defineProperties) {
1092
+ Object.defineProperties = function defineProperties(object, properties) {
1093
+ for (var property in properties) {
1094
+ if (owns(properties, property))
1095
+ Object.defineProperty(object, property, properties[property]);
1096
+ }
1097
+ return object;
1098
+ };
1099
+ }
1100
+
1101
+ // ES5 15.2.3.8
1102
+ // http://es5.github.com/#x15.2.3.8
1103
+ if (!Object.seal) {
1104
+ Object.seal = function seal(object) {
1105
+ // this is misleading and breaks feature-detection, but
1106
+ // allows "securable" code to "gracefully" degrade to working
1107
+ // but insecure code.
1108
+ return object;
1109
+ };
1110
+ }
1111
+
1112
+ // ES5 15.2.3.9
1113
+ // http://es5.github.com/#x15.2.3.9
1114
+ if (!Object.freeze) {
1115
+ Object.freeze = function freeze(object) {
1116
+ // this is misleading and breaks feature-detection, but
1117
+ // allows "securable" code to "gracefully" degrade to working
1118
+ // but insecure code.
1119
+ return object;
1120
+ };
1121
+ }
1122
+
1123
+ // detect a Rhino bug and patch it
1124
+ try {
1125
+ Object.freeze(function () {});
1126
+ } catch (exception) {
1127
+ Object.freeze = (function freeze(freezeObject) {
1128
+ return function freeze(object) {
1129
+ if (typeof object == "function") {
1130
+ return object;
1131
+ } else {
1132
+ return freezeObject(object);
1133
+ }
1134
+ };
1135
+ })(Object.freeze);
1136
+ }
1137
+
1138
+ // ES5 15.2.3.10
1139
+ // http://es5.github.com/#x15.2.3.10
1140
+ if (!Object.preventExtensions) {
1141
+ Object.preventExtensions = function preventExtensions(object) {
1142
+ // this is misleading and breaks feature-detection, but
1143
+ // allows "securable" code to "gracefully" degrade to working
1144
+ // but insecure code.
1145
+ return object;
1146
+ };
1147
+ }
1148
+
1149
+ // ES5 15.2.3.11
1150
+ // http://es5.github.com/#x15.2.3.11
1151
+ if (!Object.isSealed) {
1152
+ Object.isSealed = function isSealed(object) {
1153
+ return false;
1154
+ };
1155
+ }
1156
+
1157
+ // ES5 15.2.3.12
1158
+ // http://es5.github.com/#x15.2.3.12
1159
+ if (!Object.isFrozen) {
1160
+ Object.isFrozen = function isFrozen(object) {
1161
+ return false;
1162
+ };
1163
+ }
1164
+
1165
+ // ES5 15.2.3.13
1166
+ // http://es5.github.com/#x15.2.3.13
1167
+ if (!Object.isExtensible) {
1168
+ Object.isExtensible = function isExtensible(object) {
1169
+ // 1. If Type(O) is not Object throw a TypeError exception.
1170
+ if (Object(object) === object) {
1171
+ throw new TypeError(); // TODO message
1172
+ }
1173
+ // 2. Return the Boolean value of the [[Extensible]] internal property of O.
1174
+ var name = '';
1175
+ while (owns(object, name)) {
1176
+ name += '?';
1177
+ }
1178
+ object[name] = true;
1179
+ var returnValue = owns(object, name);
1180
+ delete object[name];
1181
+ return returnValue;
1182
+ };
1183
+ }
1184
+
1185
+ // ES5 15.2.3.14
1186
+ // http://es5.github.com/#x15.2.3.14
1187
+ if (!Object.keys) {
1188
+ // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
1189
+ var hasDontEnumBug = true,
1190
+ dontEnums = [
1191
+ "toString",
1192
+ "toLocaleString",
1193
+ "valueOf",
1194
+ "hasOwnProperty",
1195
+ "isPrototypeOf",
1196
+ "propertyIsEnumerable",
1197
+ "constructor"
1198
+ ],
1199
+ dontEnumsLength = dontEnums.length;
1200
+
1201
+ for (var key in {"toString": null})
1202
+ hasDontEnumBug = false;
1203
+
1204
+ Object.keys = function keys(object) {
1205
+
1206
+ if ((typeof object != "object" && typeof object != "function") || object === null)
1207
+ throw new TypeError("Object.keys called on a non-object");
1208
+
1209
+ var keys = [];
1210
+ for (var name in object) {
1211
+ if (owns(object, name)) {
1212
+ keys.push(name);
1213
+ }
1214
+ }
1215
+
1216
+ if (hasDontEnumBug) {
1217
+ for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
1218
+ var dontEnum = dontEnums[i];
1219
+ if (owns(object, dontEnum)) {
1220
+ keys.push(dontEnum);
1221
+ }
1222
+ }
1223
+ }
1224
+
1225
+ return keys;
1226
+ };
1227
+
1228
+ }
1229
+
1230
+ //
1231
+ // Date
1232
+ // ====
1233
+ //
1234
+
1235
+ // ES5 15.9.5.43
1236
+ // http://es5.github.com/#x15.9.5.43
1237
+ // This function returns a String value represent the instance in time
1238
+ // represented by this Date object. The format of the String is the Date Time
1239
+ // string format defined in 15.9.1.15. All fields are present in the String.
1240
+ // The time zone is always UTC, denoted by the suffix Z. If the time value of
1241
+ // this object is not a finite Number a RangeError exception is thrown.
1242
+ if (!Date.prototype.toISOString || (new Date(-62198755200000).toISOString().indexOf('-000001') === -1)) {
1243
+ Date.prototype.toISOString = function toISOString() {
1244
+ var result, length, value, year;
1245
+ if (!isFinite(this))
1246
+ throw new RangeError;
1247
+
1248
+ // the date time string format is specified in 15.9.1.15.
1249
+ result = [this.getUTCMonth() + 1, this.getUTCDate(),
1250
+ this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
1251
+ year = this.getUTCFullYear();
1252
+ year = (year < 0 ? '-' : (year > 9999 ? '+' : '')) + ('00000' + Math.abs(year)).slice(0 <= year && year <= 9999 ? -4 : -6);
1253
+
1254
+ length = result.length;
1255
+ while (length--) {
1256
+ value = result[length];
1257
+ // pad months, days, hours, minutes, and seconds to have two digits.
1258
+ if (value < 10)
1259
+ result[length] = "0" + value;
1260
+ }
1261
+ // pad milliseconds to have three digits.
1262
+ return year + "-" + result.slice(0, 2).join("-") + "T" + result.slice(2).join(":") + "." +
1263
+ ("000" + this.getUTCMilliseconds()).slice(-3) + "Z";
1264
+ }
1265
+ }
1266
+
1267
+ // ES5 15.9.4.4
1268
+ // http://es5.github.com/#x15.9.4.4
1269
+ if (!Date.now) {
1270
+ Date.now = function now() {
1271
+ return new Date().getTime();
1272
+ };
1273
+ }
1274
+
1275
+ // ES5 15.9.5.44
1276
+ // http://es5.github.com/#x15.9.5.44
1277
+ // This function provides a String representation of a Date object for use by
1278
+ // JSON.stringify (15.12.3).
1279
+ if (!Date.prototype.toJSON) {
1280
+ Date.prototype.toJSON = function toJSON(key) {
1281
+ // When the toJSON method is called with argument key, the following
1282
+ // steps are taken:
1283
+
1284
+ // 1. Let O be the result of calling ToObject, giving it the this
1285
+ // value as its argument.
1286
+ // 2. Let tv be ToPrimitive(O, hint Number).
1287
+ // 3. If tv is a Number and is not finite, return null.
1288
+ // XXX
1289
+ // 4. Let toISO be the result of calling the [[Get]] internal method of
1290
+ // O with argument "toISOString".
1291
+ // 5. If IsCallable(toISO) is false, throw a TypeError exception.
1292
+ if (typeof this.toISOString != "function")
1293
+ throw new TypeError(); // TODO message
1294
+ // 6. Return the result of calling the [[Call]] internal method of
1295
+ // toISO with O as the this value and an empty argument list.
1296
+ return this.toISOString();
1297
+
1298
+ // NOTE 1 The argument is ignored.
1299
+
1300
+ // NOTE 2 The toJSON function is intentionally generic; it does not
1301
+ // require that its this value be a Date object. Therefore, it can be
1302
+ // transferred to other kinds of objects for use as a method. However,
1303
+ // it does require that any such object have a toISOString method. An
1304
+ // object is free to use the argument key to filter its
1305
+ // stringification.
1306
+ };
1307
+ }
1308
+
1309
+ // ES5 15.9.4.2
1310
+ // http://es5.github.com/#x15.9.4.2
1311
+ // based on work shared by Daniel Friesen (dantman)
1312
+ // http://gist.github.com/303249
1313
+ if (Date.parse("+275760-09-13T00:00:00.000Z") !== 8.64e15) {
1314
+ // XXX global assignment won't work in embeddings that use
1315
+ // an alternate object for the context.
1316
+ Date = (function(NativeDate) {
1317
+
1318
+ // Date.length === 7
1319
+ var Date = function Date(Y, M, D, h, m, s, ms) {
1320
+ var length = arguments.length;
1321
+ if (this instanceof NativeDate) {
1322
+ var date = length == 1 && String(Y) === Y ? // isString(Y)
1323
+ // We explicitly pass it through parse:
1324
+ new NativeDate(Date.parse(Y)) :
1325
+ // We have to manually make calls depending on argument
1326
+ // length here
1327
+ length >= 7 ? new NativeDate(Y, M, D, h, m, s, ms) :
1328
+ length >= 6 ? new NativeDate(Y, M, D, h, m, s) :
1329
+ length >= 5 ? new NativeDate(Y, M, D, h, m) :
1330
+ length >= 4 ? new NativeDate(Y, M, D, h) :
1331
+ length >= 3 ? new NativeDate(Y, M, D) :
1332
+ length >= 2 ? new NativeDate(Y, M) :
1333
+ length >= 1 ? new NativeDate(Y) :
1334
+ new NativeDate();
1335
+ // Prevent mixups with unfixed Date object
1336
+ date.constructor = Date;
1337
+ return date;
1338
+ }
1339
+ return NativeDate.apply(this, arguments);
1340
+ };
1341
+
1342
+ // 15.9.1.15 Date Time String Format.
1343
+ var isoDateExpression = new RegExp("^" +
1344
+ "(\\d{4}|[\+\-]\\d{6})" + // four-digit year capture or sign + 6-digit extended year
1345
+ "(?:-(\\d{2})" + // optional month capture
1346
+ "(?:-(\\d{2})" + // optional day capture
1347
+ "(?:" + // capture hours:minutes:seconds.milliseconds
1348
+ "T(\\d{2})" + // hours capture
1349
+ ":(\\d{2})" + // minutes capture
1350
+ "(?:" + // optional :seconds.milliseconds
1351
+ ":(\\d{2})" + // seconds capture
1352
+ "(?:\\.(\\d{3}))?" + // milliseconds capture
1353
+ ")?" +
1354
+ "(?:" + // capture UTC offset component
1355
+ "Z|" + // UTC capture
1356
+ "(?:" + // offset specifier +/-hours:minutes
1357
+ "([-+])" + // sign capture
1358
+ "(\\d{2})" + // hours offset capture
1359
+ ":(\\d{2})" + // minutes offset capture
1360
+ ")" +
1361
+ ")?)?)?)?" +
1362
+ "$");
1363
+
1364
+ // Copy any custom methods a 3rd party library may have added
1365
+ for (var key in NativeDate)
1366
+ Date[key] = NativeDate[key];
1367
+
1368
+ // Copy "native" methods explicitly; they may be non-enumerable
1369
+ Date.now = NativeDate.now;
1370
+ Date.UTC = NativeDate.UTC;
1371
+ Date.prototype = NativeDate.prototype;
1372
+ Date.prototype.constructor = Date;
1373
+
1374
+ // Upgrade Date.parse to handle simplified ISO 8601 strings
1375
+ Date.parse = function parse(string) {
1376
+ var match = isoDateExpression.exec(string);
1377
+ if (match) {
1378
+ match.shift(); // kill match[0], the full match
1379
+ // parse months, days, hours, minutes, seconds, and milliseconds
1380
+ for (var i = 1; i < 7; i++) {
1381
+ // provide default values if necessary
1382
+ match[i] = +(match[i] || (i < 3 ? 1 : 0));
1383
+ // match[1] is the month. Months are 0-11 in JavaScript
1384
+ // `Date` objects, but 1-12 in ISO notation, so we
1385
+ // decrement.
1386
+ if (i == 1)
1387
+ match[i]--;
1388
+ }
1389
+
1390
+ // parse the UTC offset component
1391
+ var minuteOffset = +match.pop(), hourOffset = +match.pop(), sign = match.pop();
1392
+
1393
+ // compute the explicit time zone offset if specified
1394
+ var offset = 0;
1395
+ if (sign) {
1396
+ // detect invalid offsets and return early
1397
+ if (hourOffset > 23 || minuteOffset > 59)
1398
+ return NaN;
1399
+
1400
+ // express the provided time zone offset in minutes. The offset is
1401
+ // negative for time zones west of UTC; positive otherwise.
1402
+ offset = (hourOffset * 60 + minuteOffset) * 6e4 * (sign == "+" ? -1 : 1);
1403
+ }
1404
+
1405
+ // Date.UTC for years between 0 and 99 converts year to 1900 + year
1406
+ // The Gregorian calendar has a 400-year cycle, so
1407
+ // to Date.UTC(year + 400, .... ) - 12622780800000 == Date.UTC(year, ...),
1408
+ // where 12622780800000 - number of milliseconds in Gregorian calendar 400 years
1409
+ var year = +match[0];
1410
+ if (0 <= year && year <= 99) {
1411
+ match[0] = year + 400;
1412
+ return NativeDate.UTC.apply(this, match) + offset - 12622780800000;
1413
+ }
1414
+
1415
+ // compute a new UTC date value, accounting for the optional offset
1416
+ return NativeDate.UTC.apply(this, match) + offset;
1417
+ }
1418
+ return NativeDate.parse.apply(this, arguments);
1419
+ };
1420
+
1421
+ return Date;
1422
+ })(Date);
1423
+ }
1424
+
1425
+ //
1426
+ // String
1427
+ // ======
1428
+ //
1429
+
1430
+ // ES5 15.5.4.20
1431
+ // http://es5.github.com/#x15.5.4.20
1432
+ var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
1433
+ "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
1434
+ "\u2029\uFEFF";
1435
+ if (!String.prototype.trim || ws.trim()) {
1436
+ // http://blog.stevenlevithan.com/archives/faster-trim-javascript
1437
+ // http://perfectionkills.com/whitespace-deviations/
1438
+ ws = "[" + ws + "]";
1439
+ var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
1440
+ trimEndRegexp = new RegExp(ws + ws + "*$");
1441
+ String.prototype.trim = function trim() {
1442
+ return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
1443
+ };
1444
+ }
1445
+
1446
+ //
1447
+ // Util
1448
+ // ======
1449
+ //
1450
+
1451
+ // ES5 9.4
1452
+ // http://es5.github.com/#x9.4
1453
+ // http://jsperf.com/to-integer
1454
+ var toInteger = function (n) {
1455
+ n = +n;
1456
+ if (n !== n) // isNaN
1457
+ n = 0;
1458
+ else if (n !== 0 && n !== (1/0) && n !== -(1/0))
1459
+ n = (n > 0 || -1) * Math.floor(Math.abs(n));
1460
+ return n;
1461
+ };
1462
+
1463
+ var prepareString = "a"[0] != "a",
1464
+ // ES5 9.9
1465
+ // http://es5.github.com/#x9.9
1466
+ toObject = function (o) {
1467
+ if (o == null) { // this matches both null and undefined
1468
+ throw new TypeError(); // TODO message
1469
+ }
1470
+ // If the implementation doesn't support by-index access of
1471
+ // string characters (ex. IE < 7), split the string
1472
+ if (prepareString && typeof o == "string" && o) {
1473
+ return o.split("");
1474
+ }
1475
+ return Object(o);
1476
+ };
1477
+ });/* vim:ts=4:sts=4:sw=4:
1478
+ * ***** BEGIN LICENSE BLOCK *****
1479
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
1480
+ *
1481
+ * The contents of this file are subject to the Mozilla Public License Version
1482
+ * 1.1 (the "License"); you may not use this file except in compliance with
1483
+ * the License. You may obtain a copy of the License at
1484
+ * http://www.mozilla.org/MPL/
1485
+ *
1486
+ * Software distributed under the License is distributed on an "AS IS" basis,
1487
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
1488
+ * for the specific language governing rights and limitations under the
1489
+ * License.
1490
+ *
1491
+ * The Original Code is Ajax.org Code Editor (ACE).
1492
+ *
1493
+ * The Initial Developer of the Original Code is
1494
+ * Ajax.org B.V.
1495
+ * Portions created by the Initial Developer are Copyright (C) 2010
1496
+ * the Initial Developer. All Rights Reserved.
1497
+ *
1498
+ * Contributor(s):
1499
+ * Fabian Jakobs <fabian AT ajax DOT org>
1500
+ * Mihai Sucan <mihai AT sucan AT gmail ODT com>
1501
+ * Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
1502
+ *
1503
+ * Alternatively, the contents of this file may be used under the terms of
1504
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
1505
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
1506
+ * in which case the provisions of the GPL or the LGPL are applicable instead
1507
+ * of those above. If you wish to allow use of your version of this file only
1508
+ * under the terms of either the GPL or the LGPL, and not to allow others to
1509
+ * use your version of this file under the terms of the MPL, indicate your
1510
+ * decision by deleting the provisions above and replace them with the notice
1511
+ * and other provisions required by the GPL or the LGPL. If you do not delete
1512
+ * the provisions above, a recipient may use your version of this file under
1513
+ * the terms of any one of the MPL, the GPL or the LGPL.
1514
+ *
1515
+ * ***** END LICENSE BLOCK ***** */
1516
+
1517
+ ace.define('ace/lib/dom', ['require', 'exports', 'module' ], function(require, exports, module) {
1518
+ "use strict";
1519
+
1520
+ var XHTML_NS = "http://www.w3.org/1999/xhtml";
1521
+
1522
+ exports.createElement = function(tag, ns) {
1523
+ return document.createElementNS ?
1524
+ document.createElementNS(ns || XHTML_NS, tag) :
1525
+ document.createElement(tag);
1526
+ };
1527
+
1528
+ exports.setText = function(elem, text) {
1529
+ if (elem.innerText !== undefined) {
1530
+ elem.innerText = text;
1531
+ }
1532
+ if (elem.textContent !== undefined) {
1533
+ elem.textContent = text;
1534
+ }
1535
+ };
1536
+
1537
+ exports.hasCssClass = function(el, name) {
1538
+ var classes = el.className.split(/\s+/g);
1539
+ return classes.indexOf(name) !== -1;
1540
+ };
1541
+
1542
+ /**
1543
+ * Add a CSS class to the list of classes on the given node
1544
+ */
1545
+ exports.addCssClass = function(el, name) {
1546
+ if (!exports.hasCssClass(el, name)) {
1547
+ el.className += " " + name;
1548
+ }
1549
+ };
1550
+
1551
+ /**
1552
+ * Remove a CSS class from the list of classes on the given node
1553
+ */
1554
+ exports.removeCssClass = function(el, name) {
1555
+ var classes = el.className.split(/\s+/g);
1556
+ while (true) {
1557
+ var index = classes.indexOf(name);
1558
+ if (index == -1) {
1559
+ break;
1560
+ }
1561
+ classes.splice(index, 1);
1562
+ }
1563
+ el.className = classes.join(" ");
1564
+ };
1565
+
1566
+ exports.toggleCssClass = function(el, name) {
1567
+ var classes = el.className.split(/\s+/g), add = true;
1568
+ while (true) {
1569
+ var index = classes.indexOf(name);
1570
+ if (index == -1) {
1571
+ break;
1572
+ }
1573
+ add = false;
1574
+ classes.splice(index, 1);
1575
+ }
1576
+ if(add)
1577
+ classes.push(name);
1578
+
1579
+ el.className = classes.join(" ");
1580
+ return add;
1581
+ };
1582
+
1583
+ /**
1584
+ * Add or remove a CSS class from the list of classes on the given node
1585
+ * depending on the value of <tt>include</tt>
1586
+ */
1587
+ exports.setCssClass = function(node, className, include) {
1588
+ if (include) {
1589
+ exports.addCssClass(node, className);
1590
+ } else {
1591
+ exports.removeCssClass(node, className);
1592
+ }
1593
+ };
1594
+
1595
+ exports.hasCssString = function(id, doc) {
1596
+ var index = 0, sheets;
1597
+ doc = doc || document;
1598
+
1599
+ if (doc.createStyleSheet && (sheets = doc.styleSheets)) {
1600
+ while (index < sheets.length)
1601
+ if (sheets[index++].owningElement.id === id) return true;
1602
+ } else if ((sheets = doc.getElementsByTagName("style"))) {
1603
+ while (index < sheets.length)
1604
+ if (sheets[index++].id === id) return true;
1605
+ }
1606
+
1607
+ return false;
1608
+ };
1609
+
1610
+ exports.importCssString = function importCssString(cssText, id, doc) {
1611
+ doc = doc || document;
1612
+ // If style is already imported return immediately.
1613
+ if (id && exports.hasCssString(id, doc))
1614
+ return null;
1615
+
1616
+ var style;
1617
+
1618
+ if (doc.createStyleSheet) {
1619
+ style = doc.createStyleSheet();
1620
+ style.cssText = cssText;
1621
+ if (id)
1622
+ style.owningElement.id = id;
1623
+ } else {
1624
+ style = doc.createElementNS
1625
+ ? doc.createElementNS(XHTML_NS, "style")
1626
+ : doc.createElement("style");
1627
+
1628
+ style.appendChild(doc.createTextNode(cssText));
1629
+ if (id)
1630
+ style.id = id;
1631
+
1632
+ var head = doc.getElementsByTagName("head")[0] || doc.documentElement;
1633
+ head.appendChild(style);
1634
+ }
1635
+ };
1636
+
1637
+ exports.importCssStylsheet = function(uri, doc) {
1638
+ if (doc.createStyleSheet) {
1639
+ doc.createStyleSheet(uri);
1640
+ } else {
1641
+ var link = exports.createElement('link');
1642
+ link.rel = 'stylesheet';
1643
+ link.href = uri;
1644
+
1645
+ var head = doc.getElementsByTagName("head")[0] || doc.documentElement;
1646
+ head.appendChild(link);
1647
+ }
1648
+ };
1649
+
1650
+ exports.getInnerWidth = function(element) {
1651
+ return (
1652
+ parseInt(exports.computedStyle(element, "paddingLeft"), 10) +
1653
+ parseInt(exports.computedStyle(element, "paddingRight"), 10) +
1654
+ element.clientWidth
1655
+ );
1656
+ };
1657
+
1658
+ exports.getInnerHeight = function(element) {
1659
+ return (
1660
+ parseInt(exports.computedStyle(element, "paddingTop"), 10) +
1661
+ parseInt(exports.computedStyle(element, "paddingBottom"), 10) +
1662
+ element.clientHeight
1663
+ );
1664
+ };
1665
+
1666
+ if (window.pageYOffset !== undefined) {
1667
+ exports.getPageScrollTop = function() {
1668
+ return window.pageYOffset;
1669
+ };
1670
+
1671
+ exports.getPageScrollLeft = function() {
1672
+ return window.pageXOffset;
1673
+ };
1674
+ }
1675
+ else {
1676
+ exports.getPageScrollTop = function() {
1677
+ return document.body.scrollTop;
1678
+ };
1679
+
1680
+ exports.getPageScrollLeft = function() {
1681
+ return document.body.scrollLeft;
1682
+ };
1683
+ }
1684
+
1685
+ if (window.getComputedStyle)
1686
+ exports.computedStyle = function(element, style) {
1687
+ if (style)
1688
+ return (window.getComputedStyle(element, "") || {})[style] || "";
1689
+ return window.getComputedStyle(element, "") || {};
1690
+ };
1691
+ else
1692
+ exports.computedStyle = function(element, style) {
1693
+ if (style)
1694
+ return element.currentStyle[style];
1695
+ return element.currentStyle;
1696
+ };
1697
+
1698
+ exports.scrollbarWidth = function(document) {
1699
+
1700
+ var inner = exports.createElement("p");
1701
+ inner.style.width = "100%";
1702
+ inner.style.minWidth = "0px";
1703
+ inner.style.height = "200px";
1704
+
1705
+ var outer = exports.createElement("div");
1706
+ var style = outer.style;
1707
+
1708
+ style.position = "absolute";
1709
+ style.left = "-10000px";
1710
+ style.overflow = "hidden";
1711
+ style.width = "200px";
1712
+ style.minWidth = "0px";
1713
+ style.height = "150px";
1714
+
1715
+ outer.appendChild(inner);
1716
+
1717
+ var body = document.body || document.documentElement;
1718
+ body.appendChild(outer);
1719
+
1720
+ var noScrollbar = inner.offsetWidth;
1721
+
1722
+ style.overflow = "scroll";
1723
+ var withScrollbar = inner.offsetWidth;
1724
+
1725
+ if (noScrollbar == withScrollbar) {
1726
+ withScrollbar = outer.clientWidth;
1727
+ }
1728
+
1729
+ body.removeChild(outer);
1730
+
1731
+ return noScrollbar-withScrollbar;
1732
+ };
1733
+
1734
+ /**
1735
+ * Optimized set innerHTML. This is faster than plain innerHTML if the element
1736
+ * already contains a lot of child elements.
1737
+ *
1738
+ * See http://blog.stevenlevithan.com/archives/faster-than-innerhtml for details
1739
+ */
1740
+ exports.setInnerHtml = function(el, innerHtml) {
1741
+ var element = el.cloneNode(false);//document.createElement("div");
1742
+ element.innerHTML = innerHtml;
1743
+ el.parentNode.replaceChild(element, el);
1744
+ return element;
1745
+ };
1746
+
1747
+ exports.setInnerText = function(el, innerText) {
1748
+ var document = el.ownerDocument;
1749
+ if (document.body && "textContent" in document.body)
1750
+ el.textContent = innerText;
1751
+ else
1752
+ el.innerText = innerText;
1753
+
1754
+ };
1755
+
1756
+ exports.getInnerText = function(el) {
1757
+ var document = el.ownerDocument;
1758
+ if (document.body && "textContent" in document.body)
1759
+ return el.textContent;
1760
+ else
1761
+ return el.innerText || el.textContent || "";
1762
+ };
1763
+
1764
+ exports.getParentWindow = function(document) {
1765
+ return document.defaultView || document.parentWindow;
1766
+ };
1767
+
1768
+ });/* ***** BEGIN LICENSE BLOCK *****
1769
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
1770
+ *
1771
+ * The contents of this file are subject to the Mozilla Public License Version
1772
+ * 1.1 (the "License"); you may not use this file except in compliance with
1773
+ * the License. You may obtain a copy of the License at
1774
+ * http://www.mozilla.org/MPL/
1775
+ *
1776
+ * Software distributed under the License is distributed on an "AS IS" basis,
1777
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
1778
+ * for the specific language governing rights and limitations under the
1779
+ * License.
1780
+ *
1781
+ * The Original Code is Ajax.org Code Editor (ACE).
1782
+ *
1783
+ * The Initial Developer of the Original Code is
1784
+ * Ajax.org B.V.
1785
+ * Portions created by the Initial Developer are Copyright (C) 2010
1786
+ * the Initial Developer. All Rights Reserved.
1787
+ *
1788
+ * Contributor(s):
1789
+ * Fabian Jakobs <fabian AT ajax DOT org>
1790
+ *
1791
+ * Alternatively, the contents of this file may be used under the terms of
1792
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
1793
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
1794
+ * in which case the provisions of the GPL or the LGPL are applicable instead
1795
+ * of those above. If you wish to allow use of your version of this file only
1796
+ * under the terms of either the GPL or the LGPL, and not to allow others to
1797
+ * use your version of this file under the terms of the MPL, indicate your
1798
+ * decision by deleting the provisions above and replace them with the notice
1799
+ * and other provisions required by the GPL or the LGPL. If you do not delete
1800
+ * the provisions above, a recipient may use your version of this file under
1801
+ * the terms of any one of the MPL, the GPL or the LGPL.
1802
+ *
1803
+ * ***** END LICENSE BLOCK ***** */
1804
+
1805
+ ace.define('ace/lib/event', ['require', 'exports', 'module' , 'ace/lib/keys', 'ace/lib/useragent', 'ace/lib/dom'], function(require, exports, module) {
1806
+ "use strict";
1807
+
1808
+ var keys = require("./keys");
1809
+ var useragent = require("./useragent");
1810
+ var dom = require("./dom");
1811
+
1812
+ exports.addListener = function(elem, type, callback) {
1813
+ if (elem.addEventListener) {
1814
+ return elem.addEventListener(type, callback, false);
1815
+ }
1816
+ if (elem.attachEvent) {
1817
+ var wrapper = function() {
1818
+ callback(window.event);
1819
+ };
1820
+ callback._wrapper = wrapper;
1821
+ elem.attachEvent("on" + type, wrapper);
1822
+ }
1823
+ };
1824
+
1825
+ exports.removeListener = function(elem, type, callback) {
1826
+ if (elem.removeEventListener) {
1827
+ return elem.removeEventListener(type, callback, false);
1828
+ }
1829
+ if (elem.detachEvent) {
1830
+ elem.detachEvent("on" + type, callback._wrapper || callback);
1831
+ }
1832
+ };
1833
+
1834
+ /**
1835
+ * Prevents propagation and clobbers the default action of the passed event
1836
+ */
1837
+ exports.stopEvent = function(e) {
1838
+ exports.stopPropagation(e);
1839
+ exports.preventDefault(e);
1840
+ return false;
1841
+ };
1842
+
1843
+ exports.stopPropagation = function(e) {
1844
+ if (e.stopPropagation)
1845
+ e.stopPropagation();
1846
+ else
1847
+ e.cancelBubble = true;
1848
+ };
1849
+
1850
+ exports.preventDefault = function(e) {
1851
+ if (e.preventDefault)
1852
+ e.preventDefault();
1853
+ else
1854
+ e.returnValue = false;
1855
+ };
1856
+
1857
+ exports.getDocumentX = function(e) {
1858
+ if (e.clientX) {
1859
+ return e.clientX + dom.getPageScrollLeft();
1860
+ } else {
1861
+ return e.pageX;
1862
+ }
1863
+ };
1864
+
1865
+ exports.getDocumentY = function(e) {
1866
+ if (e.clientY) {
1867
+ return e.clientY + dom.getPageScrollTop();
1868
+ } else {
1869
+ return e.pageY;
1870
+ }
1871
+ };
1872
+
1873
+ /**
1874
+ * @return {Number} 0 for left button, 1 for middle button, 2 for right button
1875
+ */
1876
+ exports.getButton = function(e) {
1877
+ if (e.type == "dblclick")
1878
+ return 0;
1879
+ else if (e.type == "contextmenu")
1880
+ return 2;
1881
+
1882
+ // DOM Event
1883
+ if (e.preventDefault) {
1884
+ return e.button;
1885
+ }
1886
+ // old IE
1887
+ else {
1888
+ return {1:0, 2:2, 4:1}[e.button];
1889
+ }
1890
+ };
1891
+
1892
+ if (document.documentElement.setCapture) {
1893
+ exports.capture = function(el, eventHandler, releaseCaptureHandler) {
1894
+ function onMouseMove(e) {
1895
+ eventHandler(e);
1896
+ return exports.stopPropagation(e);
1897
+ }
1898
+
1899
+ var called = false;
1900
+ function onReleaseCapture(e) {
1901
+ eventHandler(e);
1902
+
1903
+ if (!called) {
1904
+ called = true;
1905
+ releaseCaptureHandler(e);
1906
+ }
1907
+
1908
+ exports.removeListener(el, "mousemove", eventHandler);
1909
+ exports.removeListener(el, "mouseup", onReleaseCapture);
1910
+ exports.removeListener(el, "losecapture", onReleaseCapture);
1911
+
1912
+ el.releaseCapture();
1913
+ }
1914
+
1915
+ exports.addListener(el, "mousemove", eventHandler);
1916
+ exports.addListener(el, "mouseup", onReleaseCapture);
1917
+ exports.addListener(el, "losecapture", onReleaseCapture);
1918
+ el.setCapture();
1919
+ };
1920
+ }
1921
+ else {
1922
+ exports.capture = function(el, eventHandler, releaseCaptureHandler) {
1923
+ function onMouseMove(e) {
1924
+ eventHandler(e);
1925
+ e.stopPropagation();
1926
+ }
1927
+
1928
+ function onMouseUp(e) {
1929
+ eventHandler && eventHandler(e);
1930
+ releaseCaptureHandler && releaseCaptureHandler(e);
1931
+
1932
+ document.removeEventListener("mousemove", onMouseMove, true);
1933
+ document.removeEventListener("mouseup", onMouseUp, true);
1934
+
1935
+ e.stopPropagation();
1936
+ }
1937
+
1938
+ document.addEventListener("mousemove", onMouseMove, true);
1939
+ document.addEventListener("mouseup", onMouseUp, true);
1940
+ };
1941
+ }
1942
+
1943
+ exports.addMouseWheelListener = function(el, callback) {
1944
+ var factor = 8;
1945
+ var listener = function(e) {
1946
+ if (e.wheelDelta !== undefined) {
1947
+ if (e.wheelDeltaX !== undefined) {
1948
+ e.wheelX = -e.wheelDeltaX / factor;
1949
+ e.wheelY = -e.wheelDeltaY / factor;
1950
+ } else {
1951
+ e.wheelX = 0;
1952
+ e.wheelY = -e.wheelDelta / factor;
1953
+ }
1954
+ }
1955
+ else {
1956
+ if (e.axis && e.axis == e.HORIZONTAL_AXIS) {
1957
+ e.wheelX = (e.detail || 0) * 5;
1958
+ e.wheelY = 0;
1959
+ } else {
1960
+ e.wheelX = 0;
1961
+ e.wheelY = (e.detail || 0) * 5;
1962
+ }
1963
+ }
1964
+ callback(e);
1965
+ };
1966
+ exports.addListener(el, "DOMMouseScroll", listener);
1967
+ exports.addListener(el, "mousewheel", listener);
1968
+ };
1969
+
1970
+ exports.addMultiMouseDownListener = function(el, button, count, timeout, callback) {
1971
+ var clicks = 0;
1972
+ var startX, startY;
1973
+
1974
+ var listener = function(e) {
1975
+ clicks += 1;
1976
+ if (clicks == 1) {
1977
+ startX = e.clientX;
1978
+ startY = e.clientY;
1979
+
1980
+ setTimeout(function() {
1981
+ clicks = 0;
1982
+ }, timeout || 600);
1983
+ }
1984
+
1985
+ var isButton = exports.getButton(e) == button;
1986
+ if (!isButton || Math.abs(e.clientX - startX) > 5 || Math.abs(e.clientY - startY) > 5)
1987
+ clicks = 0;
1988
+
1989
+ if (clicks == count) {
1990
+ clicks = 0;
1991
+ callback(e);
1992
+ }
1993
+
1994
+ if (isButton)
1995
+ return exports.preventDefault(e);
1996
+ };
1997
+
1998
+ exports.addListener(el, "mousedown", listener);
1999
+ useragent.isOldIE && exports.addListener(el, "dblclick", listener);
2000
+ };
2001
+
2002
+ function normalizeCommandKeys(callback, e, keyCode) {
2003
+ var hashId = 0;
2004
+ if (useragent.isOpera && useragent.isMac) {
2005
+ hashId = 0 | (e.metaKey ? 1 : 0) | (e.altKey ? 2 : 0)
2006
+ | (e.shiftKey ? 4 : 0) | (e.ctrlKey ? 8 : 0);
2007
+ } else {
2008
+ hashId = 0 | (e.ctrlKey ? 1 : 0) | (e.altKey ? 2 : 0)
2009
+ | (e.shiftKey ? 4 : 0) | (e.metaKey ? 8 : 0);
2010
+ }
2011
+
2012
+ if (keyCode in keys.MODIFIER_KEYS) {
2013
+ switch (keys.MODIFIER_KEYS[keyCode]) {
2014
+ case "Alt":
2015
+ hashId = 2;
2016
+ break;
2017
+ case "Shift":
2018
+ hashId = 4;
2019
+ break;
2020
+ case "Ctrl":
2021
+ hashId = 1;
2022
+ break;
2023
+ default:
2024
+ hashId = 8;
2025
+ break;
2026
+ }
2027
+ keyCode = 0;
2028
+ }
2029
+
2030
+ if (hashId & 8 && (keyCode == 91 || keyCode == 93)) {
2031
+ keyCode = 0;
2032
+ }
2033
+
2034
+ // If there is no hashID and the keyCode is not a function key, then
2035
+ // we don't call the callback as we don't handle a command key here
2036
+ // (it's a normal key/character input).
2037
+ if (!hashId && !(keyCode in keys.FUNCTION_KEYS) && !(keyCode in keys.PRINTABLE_KEYS)) {
2038
+ return false;
2039
+ }
2040
+ return callback(e, hashId, keyCode);
2041
+ }
2042
+
2043
+ exports.addCommandKeyListener = function(el, callback) {
2044
+ var addListener = exports.addListener;
2045
+ if (useragent.isOldGecko || useragent.isOpera) {
2046
+ // Old versions of Gecko aka. Firefox < 4.0 didn't repeat the keydown
2047
+ // event if the user pressed the key for a longer time. Instead, the
2048
+ // keydown event was fired once and later on only the keypress event.
2049
+ // To emulate the 'right' keydown behavior, the keyCode of the initial
2050
+ // keyDown event is stored and in the following keypress events the
2051
+ // stores keyCode is used to emulate a keyDown event.
2052
+ var lastKeyDownKeyCode = null;
2053
+ addListener(el, "keydown", function(e) {
2054
+ lastKeyDownKeyCode = e.keyCode;
2055
+ });
2056
+ addListener(el, "keypress", function(e) {
2057
+ return normalizeCommandKeys(callback, e, lastKeyDownKeyCode);
2058
+ });
2059
+ } else {
2060
+ var lastDown = null;
2061
+
2062
+ addListener(el, "keydown", function(e) {
2063
+ lastDown = e.keyIdentifier || e.keyCode;
2064
+ return normalizeCommandKeys(callback, e, e.keyCode);
2065
+ });
2066
+ }
2067
+ };
2068
+
2069
+ if (window.postMessage) {
2070
+ var postMessageId = 1;
2071
+ exports.nextTick = function(callback, win) {
2072
+ win = win || window;
2073
+ var messageName = "zero-timeout-message-" + postMessageId;
2074
+ exports.addListener(win, "message", function listener(e) {
2075
+ if (e.data == messageName) {
2076
+ exports.stopPropagation(e);
2077
+ exports.removeListener(win, "message", listener);
2078
+ callback();
2079
+ }
2080
+ });
2081
+ win.postMessage(messageName, "*");
2082
+ };
2083
+ }
2084
+ else {
2085
+ exports.nextTick = function(callback, win) {
2086
+ win = win || window;
2087
+ window.setTimeout(callback, 0);
2088
+ };
2089
+ }
2090
+
2091
+ });
2092
+ /*! @license
2093
+ ==========================================================================
2094
+ SproutCore -- JavaScript Application Framework
2095
+ copyright 2006-2009, Sprout Systems Inc., Apple Inc. and contributors.
2096
+
2097
+ Permission is hereby granted, free of charge, to any person obtaining a
2098
+ copy of this software and associated documentation files (the "Software"),
2099
+ to deal in the Software without restriction, including without limitation
2100
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
2101
+ and/or sell copies of the Software, and to permit persons to whom the
2102
+ Software is furnished to do so, subject to the following conditions:
2103
+
2104
+ The above copyright notice and this permission notice shall be included in
2105
+ all copies or substantial portions of the Software.
2106
+
2107
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2108
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2109
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2110
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2111
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2112
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2113
+ DEALINGS IN THE SOFTWARE.
2114
+
2115
+ SproutCore and the SproutCore logo are trademarks of Sprout Systems, Inc.
2116
+
2117
+ For more information about SproutCore, visit http://www.sproutcore.com
2118
+
2119
+
2120
+ ==========================================================================
2121
+ @license */
2122
+
2123
+ // Most of the following code is taken from SproutCore with a few changes.
2124
+
2125
+ ace.define('ace/lib/keys', ['require', 'exports', 'module' , 'ace/lib/oop'], function(require, exports, module) {
2126
+ "use strict";
2127
+
2128
+ var oop = require("./oop");
2129
+
2130
+ /**
2131
+ * Helper functions and hashes for key handling.
2132
+ */
2133
+ var Keys = (function() {
2134
+ var ret = {
2135
+ MODIFIER_KEYS: {
2136
+ 16: 'Shift', 17: 'Ctrl', 18: 'Alt', 224: 'Meta'
2137
+ },
2138
+
2139
+ KEY_MODS: {
2140
+ "ctrl": 1, "alt": 2, "option" : 2,
2141
+ "shift": 4, "meta": 8, "command": 8
2142
+ },
2143
+
2144
+ FUNCTION_KEYS : {
2145
+ 8 : "Backspace",
2146
+ 9 : "Tab",
2147
+ 13 : "Return",
2148
+ 19 : "Pause",
2149
+ 27 : "Esc",
2150
+ 32 : "Space",
2151
+ 33 : "PageUp",
2152
+ 34 : "PageDown",
2153
+ 35 : "End",
2154
+ 36 : "Home",
2155
+ 37 : "Left",
2156
+ 38 : "Up",
2157
+ 39 : "Right",
2158
+ 40 : "Down",
2159
+ 44 : "Print",
2160
+ 45 : "Insert",
2161
+ 46 : "Delete",
2162
+ 96 : "Numpad0",
2163
+ 97 : "Numpad1",
2164
+ 98 : "Numpad2",
2165
+ 99 : "Numpad3",
2166
+ 100: "Numpad4",
2167
+ 101: "Numpad5",
2168
+ 102: "Numpad6",
2169
+ 103: "Numpad7",
2170
+ 104: "Numpad8",
2171
+ 105: "Numpad9",
2172
+ 112: "F1",
2173
+ 113: "F2",
2174
+ 114: "F3",
2175
+ 115: "F4",
2176
+ 116: "F5",
2177
+ 117: "F6",
2178
+ 118: "F7",
2179
+ 119: "F8",
2180
+ 120: "F9",
2181
+ 121: "F10",
2182
+ 122: "F11",
2183
+ 123: "F12",
2184
+ 144: "Numlock",
2185
+ 145: "Scrolllock"
2186
+ },
2187
+
2188
+ PRINTABLE_KEYS: {
2189
+ 32: ' ', 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5',
2190
+ 54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a',
2191
+ 66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h',
2192
+ 73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o',
2193
+ 80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v',
2194
+ 87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.',
2195
+ 188: ',', 190: '.', 191: '/', 192: '`', 219: '[', 220: '\\',
2196
+ 221: ']', 222: '\"'
2197
+ }
2198
+ };
2199
+
2200
+ // A reverse map of FUNCTION_KEYS
2201
+ for (var i in ret.FUNCTION_KEYS) {
2202
+ var name = ret.FUNCTION_KEYS[i].toUpperCase();
2203
+ ret[name] = parseInt(i, 10);
2204
+ }
2205
+
2206
+ // Add the MODIFIER_KEYS, FUNCTION_KEYS and PRINTABLE_KEYS to the KEY
2207
+ // variables as well.
2208
+ oop.mixin(ret, ret.MODIFIER_KEYS);
2209
+ oop.mixin(ret, ret.PRINTABLE_KEYS);
2210
+ oop.mixin(ret, ret.FUNCTION_KEYS);
2211
+
2212
+ return ret;
2213
+ })();
2214
+ oop.mixin(exports, Keys);
2215
+
2216
+ exports.keyCodeToString = function(keyCode) {
2217
+ return (Keys[keyCode] || String.fromCharCode(keyCode)).toLowerCase();
2218
+ }
2219
+
2220
+ });/* ***** BEGIN LICENSE BLOCK *****
2221
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
2222
+ *
2223
+ * The contents of this file are subject to the Mozilla Public License Version
2224
+ * 1.1 (the "License"); you may not use this file except in compliance with
2225
+ * the License. You may obtain a copy of the License at
2226
+ * http://www.mozilla.org/MPL/
2227
+ *
2228
+ * Software distributed under the License is distributed on an "AS IS" basis,
2229
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
2230
+ * for the specific language governing rights and limitations under the
2231
+ * License.
2232
+ *
2233
+ * The Original Code is Ajax.org Code Editor (ACE).
2234
+ *
2235
+ * The Initial Developer of the Original Code is
2236
+ * Ajax.org B.V.
2237
+ * Portions created by the Initial Developer are Copyright (C) 2010
2238
+ * the Initial Developer. All Rights Reserved.
2239
+ *
2240
+ * Contributor(s):
2241
+ * Fabian Jakobs <fabian AT ajax DOT org>
2242
+ *
2243
+ * Alternatively, the contents of this file may be used under the terms of
2244
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
2245
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
2246
+ * in which case the provisions of the GPL or the LGPL are applicable instead
2247
+ * of those above. If you wish to allow use of your version of this file only
2248
+ * under the terms of either the GPL or the LGPL, and not to allow others to
2249
+ * use your version of this file under the terms of the MPL, indicate your
2250
+ * decision by deleting the provisions above and replace them with the notice
2251
+ * and other provisions required by the GPL or the LGPL. If you do not delete
2252
+ * the provisions above, a recipient may use your version of this file under
2253
+ * the terms of any one of the MPL, the GPL or the LGPL.
2254
+ *
2255
+ * ***** END LICENSE BLOCK ***** */
2256
+
2257
+ ace.define('ace/lib/oop', ['require', 'exports', 'module' ], function(require, exports, module) {
2258
+ "use strict";
2259
+
2260
+ exports.inherits = (function() {
2261
+ var tempCtor = function() {};
2262
+ return function(ctor, superCtor) {
2263
+ tempCtor.prototype = superCtor.prototype;
2264
+ ctor.super_ = superCtor.prototype;
2265
+ ctor.prototype = new tempCtor();
2266
+ ctor.prototype.constructor = ctor;
2267
+ };
2268
+ }());
2269
+
2270
+ exports.mixin = function(obj, mixin) {
2271
+ for (var key in mixin) {
2272
+ obj[key] = mixin[key];
2273
+ }
2274
+ };
2275
+
2276
+ exports.implement = function(proto, mixin) {
2277
+ exports.mixin(proto, mixin);
2278
+ };
2279
+
2280
+ });
2281
+ /* ***** BEGIN LICENSE BLOCK *****
2282
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
2283
+ *
2284
+ * The contents of this file are subject to the Mozilla Public License Version
2285
+ * 1.1 (the "License"); you may not use this file except in compliance with
2286
+ * the License. You may obtain a copy of the License at
2287
+ * http://www.mozilla.org/MPL/
2288
+ *
2289
+ * Software distributed under the License is distributed on an "AS IS" basis,
2290
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
2291
+ * for the specific language governing rights and limitations under the
2292
+ * License.
2293
+ *
2294
+ * The Original Code is Ajax.org Code Editor (ACE).
2295
+ *
2296
+ * The Initial Developer of the Original Code is
2297
+ * Ajax.org B.V.
2298
+ * Portions created by the Initial Developer are Copyright (C) 2010
2299
+ * the Initial Developer. All Rights Reserved.
2300
+ *
2301
+ * Contributor(s):
2302
+ * Fabian Jakobs <fabian AT ajax DOT org>
2303
+ *
2304
+ * Alternatively, the contents of this file may be used under the terms of
2305
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
2306
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
2307
+ * in which case the provisions of the GPL or the LGPL are applicable instead
2308
+ * of those above. If you wish to allow use of your version of this file only
2309
+ * under the terms of either the GPL or the LGPL, and not to allow others to
2310
+ * use your version of this file under the terms of the MPL, indicate your
2311
+ * decision by deleting the provisions above and replace them with the notice
2312
+ * and other provisions required by the GPL or the LGPL. If you do not delete
2313
+ * the provisions above, a recipient may use your version of this file under
2314
+ * the terms of any one of the MPL, the GPL or the LGPL.
2315
+ *
2316
+ * ***** END LICENSE BLOCK ***** */
2317
+
2318
+ ace.define('ace/lib/useragent', ['require', 'exports', 'module' ], function(require, exports, module) {
2319
+ "use strict";
2320
+
2321
+ var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase();
2322
+ var ua = navigator.userAgent;
2323
+
2324
+ /** Is the user using a browser that identifies itself as Windows */
2325
+ exports.isWin = (os == "win");
2326
+
2327
+ /** Is the user using a browser that identifies itself as Mac OS */
2328
+ exports.isMac = (os == "mac");
2329
+
2330
+ /** Is the user using a browser that identifies itself as Linux */
2331
+ exports.isLinux = (os == "linux");
2332
+
2333
+ exports.isIE =
2334
+ navigator.appName == "Microsoft Internet Explorer"
2335
+ && parseFloat(navigator.userAgent.match(/MSIE ([0-9]+[\.0-9]+)/)[1]);
2336
+
2337
+ exports.isOldIE = exports.isIE && exports.isIE < 9;
2338
+
2339
+ /** Is this Firefox or related? */
2340
+ exports.isGecko = exports.isMozilla = window.controllers && window.navigator.product === "Gecko";
2341
+
2342
+ /** oldGecko == rev < 2.0 **/
2343
+ exports.isOldGecko = exports.isGecko && parseInt((navigator.userAgent.match(/rv\:(\d+)/)||[])[1], 10) < 4;
2344
+
2345
+ /** Is this Opera */
2346
+ exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]";
2347
+
2348
+ /** Is the user using a browser that identifies itself as WebKit */
2349
+ exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined;
2350
+
2351
+ exports.isChrome = parseFloat(ua.split(" Chrome/")[1]) || undefined;
2352
+
2353
+ exports.isAIR = ua.indexOf("AdobeAIR") >= 0;
2354
+
2355
+ exports.isIPad = ua.indexOf("iPad") >= 0;
2356
+
2357
+ exports.isTouchPad = ua.indexOf("TouchPad") >= 0;
2358
+
2359
+ /**
2360
+ * I hate doing this, but we need some way to determine if the user is on a Mac
2361
+ * The reason is that users have different expectations of their key combinations.
2362
+ *
2363
+ * Take copy as an example, Mac people expect to use CMD or APPLE + C
2364
+ * Windows folks expect to use CTRL + C
2365
+ */
2366
+ exports.OS = {
2367
+ LINUX: "LINUX",
2368
+ MAC: "MAC",
2369
+ WINDOWS: "WINDOWS"
2370
+ };
2371
+
2372
+ /**
2373
+ * Return an exports.OS constant
2374
+ */
2375
+ exports.getOS = function() {
2376
+ if (exports.isMac) {
2377
+ return exports.OS.MAC;
2378
+ } else if (exports.isLinux) {
2379
+ return exports.OS.LINUX;
2380
+ } else {
2381
+ return exports.OS.WINDOWS;
2382
+ }
2383
+ };
2384
+
2385
+ });
2386
+ /* vim:ts=4:sts=4:sw=4:
2387
+ * ***** BEGIN LICENSE BLOCK *****
2388
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
2389
+ *
2390
+ * The contents of this file are subject to the Mozilla Public License Version
2391
+ * 1.1 (the "License"); you may not use this file except in compliance with
2392
+ * the License. You may obtain a copy of the License at
2393
+ * http://www.mozilla.org/MPL/
2394
+ *
2395
+ * Software distributed under the License is distributed on an "AS IS" basis,
2396
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
2397
+ * for the specific language governing rights and limitations under the
2398
+ * License.
2399
+ *
2400
+ * The Original Code is Ajax.org Code Editor (ACE).
2401
+ *
2402
+ * The Initial Developer of the Original Code is
2403
+ * Ajax.org B.V.
2404
+ * Portions created by the Initial Developer are Copyright (C) 2010
2405
+ * the Initial Developer. All Rights Reserved.
2406
+ *
2407
+ * Contributor(s):
2408
+ * Fabian Jakobs <fabian AT ajax DOT org>
2409
+ * Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
2410
+ * Julian Viereck <julian.viereck@gmail.com>
2411
+ *
2412
+ * Alternatively, the contents of this file may be used under the terms of
2413
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
2414
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
2415
+ * in which case the provisions of the GPL or the LGPL are applicable instead
2416
+ * of those above. If you wish to allow use of your version of this file only
2417
+ * under the terms of either the GPL or the LGPL, and not to allow others to
2418
+ * use your version of this file under the terms of the MPL, indicate your
2419
+ * decision by deleting the provisions above and replace them with the notice
2420
+ * and other provisions required by the GPL or the LGPL. If you do not delete
2421
+ * the provisions above, a recipient may use your version of this file under
2422
+ * the terms of any one of the MPL, the GPL or the LGPL.
2423
+ *
2424
+ * ***** END LICENSE BLOCK ***** */
2425
+
2426
+ ace.define('ace/editor', ['require', 'exports', 'module' , 'ace/lib/fixoldbrowsers', 'ace/lib/oop', 'ace/lib/lang', 'ace/lib/useragent', 'ace/keyboard/textinput', 'ace/mouse/mouse_handler', 'ace/mouse/fold_handler', 'ace/keyboard/keybinding', 'ace/edit_session', 'ace/search', 'ace/range', 'ace/lib/event_emitter', 'ace/commands/command_manager', 'ace/commands/default_commands'], function(require, exports, module) {
2427
+ "use strict";
2428
+
2429
+ require("./lib/fixoldbrowsers");
2430
+
2431
+ var oop = require("./lib/oop");
2432
+ var lang = require("./lib/lang");
2433
+ var useragent = require("./lib/useragent");
2434
+ var TextInput = require("./keyboard/textinput").TextInput;
2435
+ var MouseHandler = require("./mouse/mouse_handler").MouseHandler;
2436
+ var FoldHandler = require("./mouse/fold_handler").FoldHandler;
2437
+ //var TouchHandler = require("./touch_handler").TouchHandler;
2438
+ var KeyBinding = require("./keyboard/keybinding").KeyBinding;
2439
+ var EditSession = require("./edit_session").EditSession;
2440
+ var Search = require("./search").Search;
2441
+ var Range = require("./range").Range;
2442
+ var EventEmitter = require("./lib/event_emitter").EventEmitter;
2443
+ var CommandManager = require("./commands/command_manager").CommandManager;
2444
+ var defaultCommands = require("./commands/default_commands").commands;
2445
+
2446
+ var Editor = function(renderer, session) {
2447
+ var container = renderer.getContainerElement();
2448
+ this.container = container;
2449
+ this.renderer = renderer;
2450
+
2451
+ this.textInput = new TextInput(renderer.getTextAreaContainer(), this);
2452
+ this.keyBinding = new KeyBinding(this);
2453
+
2454
+ // TODO detect touch event support
2455
+ if (useragent.isIPad) {
2456
+ //this.$mouseHandler = new TouchHandler(this);
2457
+ } else {
2458
+ this.$mouseHandler = new MouseHandler(this);
2459
+ new FoldHandler(this);
2460
+ }
2461
+
2462
+ this.$blockScrolling = 0;
2463
+ this.$search = new Search().set({
2464
+ wrap: true
2465
+ });
2466
+
2467
+ this.commands = new CommandManager(useragent.isMac ? "mac" : "win", defaultCommands);
2468
+ this.setSession(session || new EditSession(""));
2469
+ };
2470
+
2471
+ (function(){
2472
+
2473
+ oop.implement(this, EventEmitter);
2474
+
2475
+ this.setKeyboardHandler = function(keyboardHandler) {
2476
+ this.keyBinding.setKeyboardHandler(keyboardHandler);
2477
+ };
2478
+
2479
+ this.getKeyboardHandler = function() {
2480
+ return this.keyBinding.getKeyboardHandler();
2481
+ };
2482
+
2483
+ this.setSession = function(session) {
2484
+ if (this.session == session)
2485
+ return;
2486
+
2487
+ if (this.session) {
2488
+ var oldSession = this.session;
2489
+ this.session.removeEventListener("change", this.$onDocumentChange);
2490
+ this.session.removeEventListener("changeMode", this.$onChangeMode);
2491
+ this.session.removeEventListener("tokenizerUpdate", this.$onTokenizerUpdate);
2492
+ this.session.removeEventListener("changeTabSize", this.$onChangeTabSize);
2493
+ this.session.removeEventListener("changeWrapLimit", this.$onChangeWrapLimit);
2494
+ this.session.removeEventListener("changeWrapMode", this.$onChangeWrapMode);
2495
+ this.session.removeEventListener("onChangeFold", this.$onChangeFold);
2496
+ this.session.removeEventListener("changeFrontMarker", this.$onChangeFrontMarker);
2497
+ this.session.removeEventListener("changeBackMarker", this.$onChangeBackMarker);
2498
+ this.session.removeEventListener("changeBreakpoint", this.$onChangeBreakpoint);
2499
+ this.session.removeEventListener("changeAnnotation", this.$onChangeAnnotation);
2500
+ this.session.removeEventListener("changeOverwrite", this.$onCursorChange);
2501
+ this.session.removeEventListener("changeScrollTop", this.$onScrollTopChange);
2502
+ this.session.removeEventListener("changeLeftTop", this.$onScrollLeftChange);
2503
+
2504
+ var selection = this.session.getSelection();
2505
+ selection.removeEventListener("changeCursor", this.$onCursorChange);
2506
+ selection.removeEventListener("changeSelection", this.$onSelectionChange);
2507
+ }
2508
+
2509
+ this.session = session;
2510
+
2511
+ this.$onDocumentChange = this.onDocumentChange.bind(this);
2512
+ session.addEventListener("change", this.$onDocumentChange);
2513
+ this.renderer.setSession(session);
2514
+
2515
+ this.$onChangeMode = this.onChangeMode.bind(this);
2516
+ session.addEventListener("changeMode", this.$onChangeMode);
2517
+
2518
+ this.$onTokenizerUpdate = this.onTokenizerUpdate.bind(this);
2519
+ session.addEventListener("tokenizerUpdate", this.$onTokenizerUpdate);
2520
+
2521
+ this.$onChangeTabSize = this.renderer.updateText.bind(this.renderer);
2522
+ session.addEventListener("changeTabSize", this.$onChangeTabSize);
2523
+
2524
+ this.$onChangeWrapLimit = this.onChangeWrapLimit.bind(this);
2525
+ session.addEventListener("changeWrapLimit", this.$onChangeWrapLimit);
2526
+
2527
+ this.$onChangeWrapMode = this.onChangeWrapMode.bind(this);
2528
+ session.addEventListener("changeWrapMode", this.$onChangeWrapMode);
2529
+
2530
+ this.$onChangeFold = this.onChangeFold.bind(this);
2531
+ session.addEventListener("changeFold", this.$onChangeFold);
2532
+
2533
+ this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this);
2534
+ this.session.addEventListener("changeFrontMarker", this.$onChangeFrontMarker);
2535
+
2536
+ this.$onChangeBackMarker = this.onChangeBackMarker.bind(this);
2537
+ this.session.addEventListener("changeBackMarker", this.$onChangeBackMarker);
2538
+
2539
+ this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this);
2540
+ this.session.addEventListener("changeBreakpoint", this.$onChangeBreakpoint);
2541
+
2542
+ this.$onChangeAnnotation = this.onChangeAnnotation.bind(this);
2543
+ this.session.addEventListener("changeAnnotation", this.$onChangeAnnotation);
2544
+
2545
+ this.$onCursorChange = this.onCursorChange.bind(this);
2546
+ this.session.addEventListener("changeOverwrite", this.$onCursorChange);
2547
+
2548
+ this.$onScrollTopChange = this.onScrollTopChange.bind(this);
2549
+ this.session.addEventListener("changeScrollTop", this.$onScrollTopChange);
2550
+
2551
+ this.$onScrollLeftChange = this.onScrollLeftChange.bind(this);
2552
+ this.session.addEventListener("changeScrollLeft", this.$onScrollLeftChange);
2553
+
2554
+ this.selection = session.getSelection();
2555
+ this.selection.addEventListener("changeCursor", this.$onCursorChange);
2556
+
2557
+ this.$onSelectionChange = this.onSelectionChange.bind(this);
2558
+ this.selection.addEventListener("changeSelection", this.$onSelectionChange);
2559
+
2560
+ this.onChangeMode();
2561
+
2562
+ this.$blockScrolling += 1;
2563
+ this.onCursorChange();
2564
+ this.$blockScrolling -= 1;
2565
+
2566
+ this.onScrollTopChange();
2567
+ this.onScrollLeftChange();
2568
+ this.onSelectionChange();
2569
+ this.onChangeFrontMarker();
2570
+ this.onChangeBackMarker();
2571
+ this.onChangeBreakpoint();
2572
+ this.onChangeAnnotation();
2573
+ this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
2574
+ this.renderer.updateFull();
2575
+
2576
+ this._emit("changeSession", {
2577
+ session: session,
2578
+ oldSession: oldSession
2579
+ });
2580
+ };
2581
+
2582
+ this.getSession = function() {
2583
+ return this.session;
2584
+ };
2585
+
2586
+ this.getSelection = function() {
2587
+ return this.selection;
2588
+ };
2589
+
2590
+ this.resize = function() {
2591
+ this.renderer.onResize();
2592
+ };
2593
+
2594
+ this.setTheme = function(theme) {
2595
+ this.renderer.setTheme(theme);
2596
+ };
2597
+
2598
+ this.getTheme = function() {
2599
+ return this.renderer.getTheme();
2600
+ };
2601
+
2602
+ this.setStyle = function(style) {
2603
+ this.renderer.setStyle(style);
2604
+ };
2605
+
2606
+ this.unsetStyle = function(style) {
2607
+ this.renderer.unsetStyle(style);
2608
+ };
2609
+
2610
+ this.setFontSize = function(size) {
2611
+ this.container.style.fontSize = size;
2612
+ this.renderer.updateFontSize();
2613
+ };
2614
+
2615
+ this.$highlightBrackets = function() {
2616
+ if (this.session.$bracketHighlight) {
2617
+ this.session.removeMarker(this.session.$bracketHighlight);
2618
+ this.session.$bracketHighlight = null;
2619
+ }
2620
+
2621
+ if (this.$highlightPending) {
2622
+ return;
2623
+ }
2624
+
2625
+ // perform highlight async to not block the browser during navigation
2626
+ var self = this;
2627
+ this.$highlightPending = true;
2628
+ setTimeout(function() {
2629
+ self.$highlightPending = false;
2630
+
2631
+ var pos = self.session.findMatchingBracket(self.getCursorPosition());
2632
+ if (pos) {
2633
+ var range = new Range(pos.row, pos.column, pos.row, pos.column+1);
2634
+ self.session.$bracketHighlight = self.session.addMarker(range, "ace_bracket", "text");
2635
+ }
2636
+ }, 10);
2637
+ };
2638
+
2639
+ this.focus = function() {
2640
+ // Safari needs the timeout
2641
+ // iOS and Firefox need it called immediately
2642
+ // to be on the save side we do both
2643
+ var _self = this;
2644
+ setTimeout(function() {
2645
+ _self.textInput.focus();
2646
+ });
2647
+ this.textInput.focus();
2648
+ };
2649
+
2650
+ this.isFocused = function() {
2651
+ return this.textInput.isFocused();
2652
+ };
2653
+
2654
+ this.blur = function() {
2655
+ this.textInput.blur();
2656
+ };
2657
+
2658
+ this.onFocus = function() {
2659
+ this.renderer.showCursor();
2660
+ this.renderer.visualizeFocus();
2661
+ this._emit("focus");
2662
+ };
2663
+
2664
+ this.onBlur = function() {
2665
+ this.renderer.hideCursor();
2666
+ this.renderer.visualizeBlur();
2667
+ this._emit("blur");
2668
+ };
2669
+
2670
+ this.onDocumentChange = function(e) {
2671
+ var delta = e.data;
2672
+ var range = delta.range;
2673
+ var lastRow;
2674
+
2675
+ if (range.start.row == range.end.row && delta.action != "insertLines" && delta.action != "removeLines")
2676
+ lastRow = range.end.row;
2677
+ else
2678
+ lastRow = Infinity;
2679
+ this.renderer.updateLines(range.start.row, lastRow);
2680
+
2681
+ this._emit("change", e);
2682
+
2683
+ // update cursor because tab characters can influence the cursor position
2684
+ this.onCursorChange();
2685
+ };
2686
+
2687
+ this.onTokenizerUpdate = function(e) {
2688
+ var rows = e.data;
2689
+ this.renderer.updateLines(rows.first, rows.last);
2690
+ };
2691
+
2692
+ this.onScrollTopChange = function() {
2693
+ this.renderer.scrollToY(this.session.getScrollTop());
2694
+ };
2695
+
2696
+ this.onScrollLeftChange = function() {
2697
+ this.renderer.scrollToX(this.session.getScrollLeft());
2698
+ };
2699
+
2700
+ this.onCursorChange = function() {
2701
+ this.renderer.updateCursor();
2702
+
2703
+ if (!this.$blockScrolling) {
2704
+ var selection = this.getSelection();
2705
+ if (selection.isEmpty())
2706
+ this.renderer.scrollCursorIntoView(selection.getCursor());
2707
+ else
2708
+ this.renderer.scrollSelectionIntoView(selection.getSelectionLead(), selection.getSelectionAnchor());
2709
+ }
2710
+
2711
+ // move text input over the cursor
2712
+ // this is required for iOS and IME
2713
+ this.renderer.moveTextAreaToCursor(this.textInput.getElement());
2714
+
2715
+ this.$highlightBrackets();
2716
+ this.$updateHighlightActiveLine();
2717
+ };
2718
+
2719
+ this.$updateHighlightActiveLine = function() {
2720
+ var session = this.getSession();
2721
+
2722
+ if (session.$highlightLineMarker) {
2723
+ session.removeMarker(session.$highlightLineMarker);
2724
+ }
2725
+ session.$highlightLineMarker = null;
2726
+
2727
+ if (this.getHighlightActiveLine() && (this.getSelectionStyle() != "line" || !this.selection.isMultiLine())) {
2728
+ var cursor = this.getCursorPosition(),
2729
+ foldLine = this.session.getFoldLine(cursor.row);
2730
+ var range;
2731
+ if (foldLine) {
2732
+ range = new Range(foldLine.start.row, 0, foldLine.end.row + 1, 0);
2733
+ } else {
2734
+ range = new Range(cursor.row, 0, cursor.row+1, 0);
2735
+ }
2736
+ session.$highlightLineMarker = session.addMarker(range, "ace_active_line", "background");
2737
+ }
2738
+ };
2739
+
2740
+ this.onSelectionChange = function(e) {
2741
+ var session = this.getSession();
2742
+
2743
+ if (session.$selectionMarker) {
2744
+ session.removeMarker(session.$selectionMarker);
2745
+ }
2746
+ session.$selectionMarker = null;
2747
+
2748
+ if (!this.selection.isEmpty()) {
2749
+ var range = this.selection.getRange();
2750
+ var style = this.getSelectionStyle();
2751
+ session.$selectionMarker = session.addMarker(range, "ace_selection", style);
2752
+ } else {
2753
+ this.$updateHighlightActiveLine();
2754
+ }
2755
+
2756
+ if (this.$highlightSelectedWord)
2757
+ this.session.getMode().highlightSelection(this);
2758
+ };
2759
+
2760
+ this.onChangeFrontMarker = function() {
2761
+ this.renderer.updateFrontMarkers();
2762
+ };
2763
+
2764
+ this.onChangeBackMarker = function() {
2765
+ this.renderer.updateBackMarkers();
2766
+ };
2767
+
2768
+ this.onChangeBreakpoint = function() {
2769
+ this.renderer.setBreakpoints(this.session.getBreakpoints());
2770
+ };
2771
+
2772
+ this.onChangeAnnotation = function() {
2773
+ this.renderer.setAnnotations(this.session.getAnnotations());
2774
+ };
2775
+
2776
+ this.onChangeMode = function() {
2777
+ this.renderer.updateText();
2778
+ };
2779
+
2780
+ this.onChangeWrapLimit = function() {
2781
+ this.renderer.updateFull();
2782
+ };
2783
+
2784
+ this.onChangeWrapMode = function() {
2785
+ this.renderer.onResize(true);
2786
+ };
2787
+
2788
+ this.onChangeFold = function() {
2789
+ // Update the active line marker as due to folding changes the current
2790
+ // line range on the screen might have changed.
2791
+ this.$updateHighlightActiveLine();
2792
+ // TODO: This might be too much updating. Okay for now.
2793
+ this.renderer.updateFull();
2794
+ };
2795
+
2796
+ this.getCopyText = function() {
2797
+ var text = "";
2798
+ if (!this.selection.isEmpty())
2799
+ text = this.session.getTextRange(this.getSelectionRange());
2800
+
2801
+ this._emit("copy", text);
2802
+ return text;
2803
+ };
2804
+
2805
+ this.onCut = function() {
2806
+ if (this.$readOnly)
2807
+ return;
2808
+
2809
+ var range = this.getSelectionRange();
2810
+ this._emit("cut", range);
2811
+
2812
+ if (!this.selection.isEmpty()) {
2813
+ this.session.remove(range);
2814
+ this.clearSelection();
2815
+ }
2816
+ };
2817
+
2818
+ this.insert = function(text) {
2819
+ var session = this.session;
2820
+ var mode = session.getMode();
2821
+
2822
+ var cursor = this.getCursorPosition();
2823
+
2824
+ if (this.getBehavioursEnabled()) {
2825
+ // Get a transform if the current mode wants one.
2826
+ var transform = mode.transformAction(session.getState(cursor.row), 'insertion', this, session, text);
2827
+ if (transform)
2828
+ text = transform.text;
2829
+ }
2830
+
2831
+ text = text.replace("\t", this.session.getTabString());
2832
+
2833
+ // remove selected text
2834
+ if (!this.selection.isEmpty()) {
2835
+ cursor = this.session.remove(this.getSelectionRange());
2836
+ this.clearSelection();
2837
+ }
2838
+ else if (this.session.getOverwrite()) {
2839
+ var range = new Range.fromPoints(cursor, cursor);
2840
+ range.end.column += text.length;
2841
+ this.session.remove(range);
2842
+ }
2843
+
2844
+ this.clearSelection();
2845
+
2846
+ var start = cursor.column;
2847
+ var lineState = session.getState(cursor.row);
2848
+ var shouldOutdent = mode.checkOutdent(lineState, session.getLine(cursor.row), text);
2849
+ var line = session.getLine(cursor.row);
2850
+ var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString());
2851
+ var end = session.insert(cursor, text);
2852
+
2853
+ if (transform && transform.selection) {
2854
+ if (transform.selection.length == 2) { // Transform relative to the current column
2855
+ this.selection.setSelectionRange(
2856
+ new Range(cursor.row, start + transform.selection[0],
2857
+ cursor.row, start + transform.selection[1]));
2858
+ } else { // Transform relative to the current row.
2859
+ this.selection.setSelectionRange(
2860
+ new Range(cursor.row + transform.selection[0],
2861
+ transform.selection[1],
2862
+ cursor.row + transform.selection[2],
2863
+ transform.selection[3]));
2864
+ }
2865
+ }
2866
+
2867
+ var lineState = session.getState(cursor.row);
2868
+
2869
+ // TODO disabled multiline auto indent
2870
+ // possibly doing the indent before inserting the text
2871
+ // if (cursor.row !== end.row) {
2872
+ if (session.getDocument().isNewLine(text)) {
2873
+ this.moveCursorTo(cursor.row+1, 0);
2874
+
2875
+ var size = session.getTabSize();
2876
+ var minIndent = Number.MAX_VALUE;
2877
+
2878
+ for (var row = cursor.row + 1; row <= end.row; ++row) {
2879
+ var indent = 0;
2880
+
2881
+ line = session.getLine(row);
2882
+ for (var i = 0; i < line.length; ++i)
2883
+ if (line.charAt(i) == '\t')
2884
+ indent += size;
2885
+ else if (line.charAt(i) == ' ')
2886
+ indent += 1;
2887
+ else
2888
+ break;
2889
+ if (/[^\s]/.test(line))
2890
+ minIndent = Math.min(indent, minIndent);
2891
+ }
2892
+
2893
+ for (var row = cursor.row + 1; row <= end.row; ++row) {
2894
+ var outdent = minIndent;
2895
+
2896
+ line = session.getLine(row);
2897
+ for (var i = 0; i < line.length && outdent > 0; ++i)
2898
+ if (line.charAt(i) == '\t')
2899
+ outdent -= size;
2900
+ else if (line.charAt(i) == ' ')
2901
+ outdent -= 1;
2902
+ session.remove(new Range(row, 0, row, i));
2903
+ }
2904
+ session.indentRows(cursor.row + 1, end.row, lineIndent);
2905
+ }
2906
+ if (shouldOutdent)
2907
+ mode.autoOutdent(lineState, session, cursor.row);
2908
+ };
2909
+
2910
+ this.onTextInput = function(text, pasted) {
2911
+ if (pasted)
2912
+ this._emit("paste", text);
2913
+
2914
+ this.keyBinding.onTextInput(text, pasted);
2915
+ };
2916
+
2917
+ this.onCommandKey = function(e, hashId, keyCode) {
2918
+ this.keyBinding.onCommandKey(e, hashId, keyCode);
2919
+ };
2920
+
2921
+ this.setOverwrite = function(overwrite) {
2922
+ this.session.setOverwrite(overwrite);
2923
+ };
2924
+
2925
+ this.getOverwrite = function() {
2926
+ return this.session.getOverwrite();
2927
+ };
2928
+
2929
+ this.toggleOverwrite = function() {
2930
+ this.session.toggleOverwrite();
2931
+ };
2932
+
2933
+ this.setScrollSpeed = function(speed) {
2934
+ this.$mouseHandler.setScrollSpeed(speed);
2935
+ };
2936
+
2937
+ this.getScrollSpeed = function() {
2938
+ return this.$mouseHandler.getScrollSpeed();
2939
+ };
2940
+
2941
+ this.setDragDelay = function(dragDelay) {
2942
+ this.$mouseHandler.setDragDelay(dragDelay);
2943
+ };
2944
+
2945
+ this.getDragDelay = function() {
2946
+ return this.$mouseHandler.getDragDelay();
2947
+ };
2948
+
2949
+ this.$selectionStyle = "line";
2950
+ this.setSelectionStyle = function(style) {
2951
+ if (this.$selectionStyle == style) return;
2952
+
2953
+ this.$selectionStyle = style;
2954
+ this.onSelectionChange();
2955
+ this._emit("changeSelectionStyle", {data: style});
2956
+ };
2957
+
2958
+ this.getSelectionStyle = function() {
2959
+ return this.$selectionStyle;
2960
+ };
2961
+
2962
+ this.$highlightActiveLine = true;
2963
+ this.setHighlightActiveLine = function(shouldHighlight) {
2964
+ if (this.$highlightActiveLine == shouldHighlight) return;
2965
+
2966
+ this.$highlightActiveLine = shouldHighlight;
2967
+ this.$updateHighlightActiveLine();
2968
+ };
2969
+
2970
+ this.getHighlightActiveLine = function() {
2971
+ return this.$highlightActiveLine;
2972
+ };
2973
+
2974
+ this.$highlightSelectedWord = true;
2975
+ this.setHighlightSelectedWord = function(shouldHighlight) {
2976
+ if (this.$highlightSelectedWord == shouldHighlight)
2977
+ return;
2978
+
2979
+ this.$highlightSelectedWord = shouldHighlight;
2980
+ if (shouldHighlight)
2981
+ this.session.getMode().highlightSelection(this);
2982
+ else
2983
+ this.session.getMode().clearSelectionHighlight(this);
2984
+ };
2985
+
2986
+ this.getHighlightSelectedWord = function() {
2987
+ return this.$highlightSelectedWord;
2988
+ };
2989
+
2990
+ this.setShowInvisibles = function(showInvisibles) {
2991
+ if (this.getShowInvisibles() == showInvisibles)
2992
+ return;
2993
+
2994
+ this.renderer.setShowInvisibles(showInvisibles);
2995
+ };
2996
+
2997
+ this.getShowInvisibles = function() {
2998
+ return this.renderer.getShowInvisibles();
2999
+ };
3000
+
3001
+ this.setShowPrintMargin = function(showPrintMargin) {
3002
+ this.renderer.setShowPrintMargin(showPrintMargin);
3003
+ };
3004
+
3005
+ this.getShowPrintMargin = function() {
3006
+ return this.renderer.getShowPrintMargin();
3007
+ };
3008
+
3009
+ this.setPrintMarginColumn = function(showPrintMargin) {
3010
+ this.renderer.setPrintMarginColumn(showPrintMargin);
3011
+ };
3012
+
3013
+ this.getPrintMarginColumn = function() {
3014
+ return this.renderer.getPrintMarginColumn();
3015
+ };
3016
+
3017
+ this.$readOnly = false;
3018
+ this.setReadOnly = function(readOnly) {
3019
+ this.$readOnly = readOnly;
3020
+ };
3021
+
3022
+ this.getReadOnly = function() {
3023
+ return this.$readOnly;
3024
+ };
3025
+
3026
+ this.$modeBehaviours = true;
3027
+ this.setBehavioursEnabled = function (enabled) {
3028
+ this.$modeBehaviours = enabled;
3029
+ };
3030
+
3031
+ this.getBehavioursEnabled = function () {
3032
+ return this.$modeBehaviours;
3033
+ };
3034
+
3035
+ this.setShowFoldWidgets = function(show) {
3036
+ var gutter = this.renderer.$gutterLayer;
3037
+ if (gutter.getShowFoldWidgets() == show)
3038
+ return;
3039
+
3040
+ this.renderer.$gutterLayer.setShowFoldWidgets(show);
3041
+ this.$showFoldWidgets = show;
3042
+ this.renderer.updateFull();
3043
+ };
3044
+
3045
+ this.getShowFoldWidgets = function() {
3046
+ return this.renderer.$gutterLayer.getShowFoldWidgets();
3047
+ };
3048
+
3049
+ this.remove = function(dir) {
3050
+ if (this.selection.isEmpty()){
3051
+ if(dir == "left")
3052
+ this.selection.selectLeft();
3053
+ else
3054
+ this.selection.selectRight();
3055
+ }
3056
+
3057
+ var range = this.getSelectionRange();
3058
+ if (this.getBehavioursEnabled()) {
3059
+ var session = this.session;
3060
+ var state = session.getState(range.start.row);
3061
+ var new_range = session.getMode().transformAction(state, 'deletion', this, session, range);
3062
+ if (new_range)
3063
+ range = new_range;
3064
+ }
3065
+
3066
+ this.session.remove(range);
3067
+ this.clearSelection();
3068
+ };
3069
+
3070
+ this.removeWordRight = function() {
3071
+ if (this.selection.isEmpty())
3072
+ this.selection.selectWordRight();
3073
+
3074
+ this.session.remove(this.getSelectionRange());
3075
+ this.clearSelection();
3076
+ };
3077
+
3078
+ this.removeWordLeft = function() {
3079
+ if (this.selection.isEmpty())
3080
+ this.selection.selectWordLeft();
3081
+
3082
+ this.session.remove(this.getSelectionRange());
3083
+ this.clearSelection();
3084
+ };
3085
+
3086
+ this.removeToLineStart = function() {
3087
+ if (this.selection.isEmpty())
3088
+ this.selection.selectLineStart();
3089
+
3090
+ this.session.remove(this.getSelectionRange());
3091
+ this.clearSelection();
3092
+ };
3093
+
3094
+ this.removeToLineEnd = function() {
3095
+ if (this.selection.isEmpty())
3096
+ this.selection.selectLineEnd();
3097
+
3098
+ var range = this.getSelectionRange();
3099
+ if (range.start.column == range.end.column && range.start.row == range.end.row) {
3100
+ range.end.column = 0;
3101
+ range.end.row++;
3102
+ }
3103
+
3104
+ this.session.remove(range);
3105
+ this.clearSelection();
3106
+ };
3107
+
3108
+ this.splitLine = function() {
3109
+ if (!this.selection.isEmpty()) {
3110
+ this.session.remove(this.getSelectionRange());
3111
+ this.clearSelection();
3112
+ }
3113
+
3114
+ var cursor = this.getCursorPosition();
3115
+ this.insert("\n");
3116
+ this.moveCursorToPosition(cursor);
3117
+ };
3118
+
3119
+ this.transposeLetters = function() {
3120
+ if (!this.selection.isEmpty()) {
3121
+ return;
3122
+ }
3123
+
3124
+ var cursor = this.getCursorPosition();
3125
+ var column = cursor.column;
3126
+ if (column === 0)
3127
+ return;
3128
+
3129
+ var line = this.session.getLine(cursor.row);
3130
+ var swap, range;
3131
+ if (column < line.length) {
3132
+ swap = line.charAt(column) + line.charAt(column-1);
3133
+ range = new Range(cursor.row, column-1, cursor.row, column+1);
3134
+ }
3135
+ else {
3136
+ swap = line.charAt(column-1) + line.charAt(column-2);
3137
+ range = new Range(cursor.row, column-2, cursor.row, column);
3138
+ }
3139
+ this.session.replace(range, swap);
3140
+ };
3141
+
3142
+ this.toLowerCase = function() {
3143
+ var originalRange = this.getSelectionRange();
3144
+ if (this.selection.isEmpty()) {
3145
+ this.selection.selectWord();
3146
+ }
3147
+
3148
+ var range = this.getSelectionRange();
3149
+ var text = this.session.getTextRange(range);
3150
+ this.session.replace(range, text.toLowerCase());
3151
+ this.selection.setSelectionRange(originalRange);
3152
+ };
3153
+
3154
+ this.toUpperCase = function() {
3155
+ var originalRange = this.getSelectionRange();
3156
+ if (this.selection.isEmpty()) {
3157
+ this.selection.selectWord();
3158
+ }
3159
+
3160
+ var range = this.getSelectionRange();
3161
+ var text = this.session.getTextRange(range);
3162
+ this.session.replace(range, text.toUpperCase());
3163
+ this.selection.setSelectionRange(originalRange);
3164
+ };
3165
+
3166
+ this.indent = function() {
3167
+ var session = this.session;
3168
+ var range = this.getSelectionRange();
3169
+
3170
+ if (range.start.row < range.end.row || range.start.column < range.end.column) {
3171
+ var rows = this.$getSelectedRows();
3172
+ session.indentRows(rows.first, rows.last, "\t");
3173
+ } else {
3174
+ var indentString;
3175
+
3176
+ if (this.session.getUseSoftTabs()) {
3177
+ var size = session.getTabSize(),
3178
+ position = this.getCursorPosition(),
3179
+ column = session.documentToScreenColumn(position.row, position.column),
3180
+ count = (size - column % size);
3181
+
3182
+ indentString = lang.stringRepeat(" ", count);
3183
+ } else
3184
+ indentString = "\t";
3185
+ return this.insert(indentString);
3186
+ }
3187
+ };
3188
+
3189
+ this.blockOutdent = function() {
3190
+ var selection = this.session.getSelection();
3191
+ this.session.outdentRows(selection.getRange());
3192
+ };
3193
+
3194
+ this.toggleCommentLines = function() {
3195
+ var state = this.session.getState(this.getCursorPosition().row);
3196
+ var rows = this.$getSelectedRows();
3197
+ this.session.getMode().toggleCommentLines(state, this.session, rows.first, rows.last);
3198
+ };
3199
+
3200
+ this.removeLines = function() {
3201
+ var rows = this.$getSelectedRows();
3202
+ var range;
3203
+ if (rows.first === 0 || rows.last+1 < this.session.getLength())
3204
+ range = new Range(rows.first, 0, rows.last+1, 0);
3205
+ else
3206
+ range = new Range(
3207
+ rows.first-1, this.session.getLine(rows.first-1).length,
3208
+ rows.last, this.session.getLine(rows.last).length
3209
+ );
3210
+ this.session.remove(range);
3211
+ this.clearSelection();
3212
+ };
3213
+
3214
+ this.moveLinesDown = function() {
3215
+ this.$moveLines(function(firstRow, lastRow) {
3216
+ return this.session.moveLinesDown(firstRow, lastRow);
3217
+ });
3218
+ };
3219
+
3220
+ this.moveLinesUp = function() {
3221
+ this.$moveLines(function(firstRow, lastRow) {
3222
+ return this.session.moveLinesUp(firstRow, lastRow);
3223
+ });
3224
+ };
3225
+
3226
+ this.moveText = function(range, toPosition) {
3227
+ if (this.$readOnly)
3228
+ return null;
3229
+
3230
+ return this.session.moveText(range, toPosition);
3231
+ };
3232
+
3233
+ this.copyLinesUp = function() {
3234
+ this.$moveLines(function(firstRow, lastRow) {
3235
+ this.session.duplicateLines(firstRow, lastRow);
3236
+ return 0;
3237
+ });
3238
+ };
3239
+
3240
+ this.copyLinesDown = function() {
3241
+ this.$moveLines(function(firstRow, lastRow) {
3242
+ return this.session.duplicateLines(firstRow, lastRow);
3243
+ });
3244
+ };
3245
+
3246
+
3247
+ this.$moveLines = function(mover) {
3248
+ var rows = this.$getSelectedRows();
3249
+ var selection = this.selection;
3250
+ if (!selection.isMultiLine()) {
3251
+ var range = selection.getRange();
3252
+ var reverse = selection.isBackwards();
3253
+ }
3254
+
3255
+ var linesMoved = mover.call(this, rows.first, rows.last);
3256
+
3257
+ if (range) {
3258
+ range.start.row += linesMoved;
3259
+ range.end.row += linesMoved;
3260
+ selection.setSelectionRange(range, reverse);
3261
+ }
3262
+ else {
3263
+ selection.setSelectionAnchor(rows.last+linesMoved+1, 0);
3264
+ selection.$moveSelection(function() {
3265
+ selection.moveCursorTo(rows.first+linesMoved, 0);
3266
+ });
3267
+ }
3268
+ };
3269
+
3270
+ this.$getSelectedRows = function() {
3271
+ var range = this.getSelectionRange().collapseRows();
3272
+
3273
+ return {
3274
+ first: range.start.row,
3275
+ last: range.end.row
3276
+ };
3277
+ };
3278
+
3279
+ this.onCompositionStart = function(text) {
3280
+ this.renderer.showComposition(this.getCursorPosition());
3281
+ };
3282
+
3283
+ this.onCompositionUpdate = function(text) {
3284
+ this.renderer.setCompositionText(text);
3285
+ };
3286
+
3287
+ this.onCompositionEnd = function() {
3288
+ this.renderer.hideComposition();
3289
+ };
3290
+
3291
+ this.getFirstVisibleRow = function() {
3292
+ return this.renderer.getFirstVisibleRow();
3293
+ };
3294
+
3295
+ this.getLastVisibleRow = function() {
3296
+ return this.renderer.getLastVisibleRow();
3297
+ };
3298
+
3299
+ this.isRowVisible = function(row) {
3300
+ return (row >= this.getFirstVisibleRow() && row <= this.getLastVisibleRow());
3301
+ };
3302
+
3303
+ this.isRowFullyVisible = function(row) {
3304
+ return (row >= this.renderer.getFirstFullyVisibleRow() && row <= this.renderer.getLastFullyVisibleRow());
3305
+ };
3306
+
3307
+ this.$getVisibleRowCount = function() {
3308
+ return this.renderer.getScrollBottomRow() - this.renderer.getScrollTopRow() + 1;
3309
+ };
3310
+
3311
+ this.$getPageDownRow = function() {
3312
+ return this.renderer.getScrollBottomRow();
3313
+ };
3314
+
3315
+ this.$getPageUpRow = function() {
3316
+ var firstRow = this.renderer.getScrollTopRow();
3317
+ var lastRow = this.renderer.getScrollBottomRow();
3318
+
3319
+ return firstRow - (lastRow - firstRow);
3320
+ };
3321
+
3322
+ this.selectPageDown = function() {
3323
+ var row = this.$getPageDownRow() + Math.floor(this.$getVisibleRowCount() / 2);
3324
+
3325
+ this.scrollPageDown();
3326
+
3327
+ var selection = this.getSelection();
3328
+ var leadScreenPos = this.session.documentToScreenPosition(selection.getSelectionLead());
3329
+ var dest = this.session.screenToDocumentPosition(row, leadScreenPos.column);
3330
+ selection.selectTo(dest.row, dest.column);
3331
+ };
3332
+
3333
+ this.selectPageUp = function() {
3334
+ var visibleRows = this.renderer.getScrollTopRow() - this.renderer.getScrollBottomRow();
3335
+ var row = this.$getPageUpRow() + Math.round(visibleRows / 2);
3336
+
3337
+ this.scrollPageUp();
3338
+
3339
+ var selection = this.getSelection();
3340
+ var leadScreenPos = this.session.documentToScreenPosition(selection.getSelectionLead());
3341
+ var dest = this.session.screenToDocumentPosition(row, leadScreenPos.column);
3342
+ selection.selectTo(dest.row, dest.column);
3343
+ };
3344
+
3345
+ this.gotoPageDown = function() {
3346
+ var row = this.$getPageDownRow();
3347
+ var column = this.getCursorPositionScreen().column;
3348
+
3349
+ this.scrollToRow(row);
3350
+ this.getSelection().moveCursorToScreen(row, column);
3351
+ };
3352
+
3353
+ this.gotoPageUp = function() {
3354
+ var row = this.$getPageUpRow();
3355
+ var column = this.getCursorPositionScreen().column;
3356
+
3357
+ this.scrollToRow(row);
3358
+ this.getSelection().moveCursorToScreen(row, column);
3359
+ };
3360
+
3361
+ this.scrollPageDown = function() {
3362
+ this.scrollToRow(this.$getPageDownRow());
3363
+ };
3364
+
3365
+ this.scrollPageUp = function() {
3366
+ this.renderer.scrollToRow(this.$getPageUpRow());
3367
+ };
3368
+
3369
+ this.scrollToRow = function(row) {
3370
+ this.renderer.scrollToRow(row);
3371
+ };
3372
+
3373
+ this.scrollToLine = function(line, center) {
3374
+ this.renderer.scrollToLine(line, center);
3375
+ };
3376
+
3377
+ this.centerSelection = function() {
3378
+ var range = this.getSelectionRange();
3379
+ var line = Math.floor(range.start.row + (range.end.row - range.start.row) / 2);
3380
+ this.renderer.scrollToLine(line, true);
3381
+ };
3382
+
3383
+ this.getCursorPosition = function() {
3384
+ return this.selection.getCursor();
3385
+ };
3386
+
3387
+ this.getCursorPositionScreen = function() {
3388
+ return this.session.documentToScreenPosition(this.getCursorPosition());
3389
+ };
3390
+
3391
+ this.getSelectionRange = function() {
3392
+ return this.selection.getRange();
3393
+ };
3394
+
3395
+
3396
+ this.selectAll = function() {
3397
+ this.$blockScrolling += 1;
3398
+ this.selection.selectAll();
3399
+ this.$blockScrolling -= 1;
3400
+ };
3401
+
3402
+ this.clearSelection = function() {
3403
+ this.selection.clearSelection();
3404
+ };
3405
+
3406
+ this.moveCursorTo = function(row, column) {
3407
+ this.selection.moveCursorTo(row, column);
3408
+ };
3409
+
3410
+ this.moveCursorToPosition = function(pos) {
3411
+ this.selection.moveCursorToPosition(pos);
3412
+ };
3413
+
3414
+ this.jumpToMatching = function() {
3415
+ var cursor = this.getCursorPosition();
3416
+ var pos = this.session.findMatchingBracket(cursor);
3417
+ if (!pos) {
3418
+ cursor.column += 1;
3419
+ pos = this.session.findMatchingBracket(cursor);
3420
+ }
3421
+ if (!pos) {
3422
+ cursor.column -= 2;
3423
+ pos = this.session.findMatchingBracket(cursor);
3424
+ }
3425
+
3426
+ if (pos) {
3427
+ this.clearSelection();
3428
+ this.moveCursorTo(pos.row, pos.column);
3429
+ }
3430
+ };
3431
+
3432
+ this.gotoLine = function(lineNumber, column) {
3433
+ this.selection.clearSelection();
3434
+ this.session.unfold({row: lineNumber - 1, column: column || 0});
3435
+
3436
+ this.$blockScrolling += 1;
3437
+ this.moveCursorTo(lineNumber-1, column || 0);
3438
+ this.$blockScrolling -= 1;
3439
+ if (!this.isRowFullyVisible(this.getCursorPosition().row))
3440
+ this.scrollToLine(lineNumber, true);
3441
+ };
3442
+
3443
+ this.navigateTo = function(row, column) {
3444
+ this.clearSelection();
3445
+ this.moveCursorTo(row, column);
3446
+ };
3447
+
3448
+ this.navigateUp = function(times) {
3449
+ this.selection.clearSelection();
3450
+ times = times || 1;
3451
+ this.selection.moveCursorBy(-times, 0);
3452
+ };
3453
+
3454
+ this.navigateDown = function(times) {
3455
+ this.selection.clearSelection();
3456
+ times = times || 1;
3457
+ this.selection.moveCursorBy(times, 0);
3458
+ };
3459
+
3460
+ this.navigateLeft = function(times) {
3461
+ if (!this.selection.isEmpty()) {
3462
+ var selectionStart = this.getSelectionRange().start;
3463
+ this.moveCursorToPosition(selectionStart);
3464
+ }
3465
+ else {
3466
+ times = times || 1;
3467
+ while (times--) {
3468
+ this.selection.moveCursorLeft();
3469
+ }
3470
+ }
3471
+ this.clearSelection();
3472
+ };
3473
+
3474
+ this.navigateRight = function(times) {
3475
+ if (!this.selection.isEmpty()) {
3476
+ var selectionEnd = this.getSelectionRange().end;
3477
+ this.moveCursorToPosition(selectionEnd);
3478
+ }
3479
+ else {
3480
+ times = times || 1;
3481
+ while (times--) {
3482
+ this.selection.moveCursorRight();
3483
+ }
3484
+ }
3485
+ this.clearSelection();
3486
+ };
3487
+
3488
+ this.navigateLineStart = function() {
3489
+ this.selection.moveCursorLineStart();
3490
+ this.clearSelection();
3491
+ };
3492
+
3493
+ this.navigateLineEnd = function() {
3494
+ this.selection.moveCursorLineEnd();
3495
+ this.clearSelection();
3496
+ };
3497
+
3498
+ this.navigateFileEnd = function() {
3499
+ this.selection.moveCursorFileEnd();
3500
+ this.clearSelection();
3501
+ };
3502
+
3503
+ this.navigateFileStart = function() {
3504
+ this.selection.moveCursorFileStart();
3505
+ this.clearSelection();
3506
+ };
3507
+
3508
+ this.navigateWordRight = function() {
3509
+ this.selection.moveCursorWordRight();
3510
+ this.clearSelection();
3511
+ };
3512
+
3513
+ this.navigateWordLeft = function() {
3514
+ this.selection.moveCursorWordLeft();
3515
+ this.clearSelection();
3516
+ };
3517
+
3518
+ this.replace = function(replacement, options) {
3519
+ if (options)
3520
+ this.$search.set(options);
3521
+
3522
+ var range = this.$search.find(this.session);
3523
+ if (!range)
3524
+ return;
3525
+
3526
+ this.$tryReplace(range, replacement);
3527
+ if (range !== null)
3528
+ this.selection.setSelectionRange(range);
3529
+ };
3530
+
3531
+ this.replaceAll = function(replacement, options) {
3532
+ if (options) {
3533
+ this.$search.set(options);
3534
+ }
3535
+
3536
+ var ranges = this.$search.findAll(this.session);
3537
+ if (!ranges.length)
3538
+ return;
3539
+
3540
+ var selection = this.getSelectionRange();
3541
+ this.clearSelection();
3542
+ this.selection.moveCursorTo(0, 0);
3543
+
3544
+ this.$blockScrolling += 1;
3545
+ for (var i = ranges.length - 1; i >= 0; --i)
3546
+ this.$tryReplace(ranges[i], replacement);
3547
+
3548
+ this.selection.setSelectionRange(selection);
3549
+ this.$blockScrolling -= 1;
3550
+ };
3551
+
3552
+ this.$tryReplace = function(range, replacement) {
3553
+ var input = this.session.getTextRange(range);
3554
+ replacement = this.$search.replace(input, replacement);
3555
+ if (replacement !== null) {
3556
+ range.end = this.session.replace(range, replacement);
3557
+ return range;
3558
+ } else {
3559
+ return null;
3560
+ }
3561
+ };
3562
+
3563
+ this.getLastSearchOptions = function() {
3564
+ return this.$search.getOptions();
3565
+ };
3566
+
3567
+ this.find = function(needle, options) {
3568
+ this.clearSelection();
3569
+ options = options || {};
3570
+ options.needle = needle;
3571
+ this.$search.set(options);
3572
+ this.$find();
3573
+ };
3574
+
3575
+ this.findNext = function(options) {
3576
+ options = options || {};
3577
+ if (typeof options.backwards == "undefined")
3578
+ options.backwards = false;
3579
+ this.$search.set(options);
3580
+ this.$find();
3581
+ };
3582
+
3583
+ this.findPrevious = function(options) {
3584
+ options = options || {};
3585
+ if (typeof options.backwards == "undefined")
3586
+ options.backwards = true;
3587
+ this.$search.set(options);
3588
+ this.$find();
3589
+ };
3590
+
3591
+ this.$find = function(backwards) {
3592
+ if (!this.selection.isEmpty())
3593
+ this.$search.set({needle: this.session.getTextRange(this.getSelectionRange())});
3594
+
3595
+ if (typeof backwards != "undefined")
3596
+ this.$search.set({backwards: backwards});
3597
+
3598
+ var range = this.$search.find(this.session);
3599
+ if (range) {
3600
+ this.session.unfold(range);
3601
+ this.selection.setSelectionRange(range); // this scrolls selection into view
3602
+ }
3603
+ };
3604
+
3605
+ this.undo = function() {
3606
+ this.session.getUndoManager().undo();
3607
+ };
3608
+
3609
+ this.redo = function() {
3610
+ this.session.getUndoManager().redo();
3611
+ };
3612
+
3613
+ this.destroy = function() {
3614
+ this.renderer.destroy();
3615
+ };
3616
+
3617
+ }).call(Editor.prototype);
3618
+
3619
+
3620
+ exports.Editor = Editor;
3621
+ });/* ***** BEGIN LICENSE BLOCK *****
3622
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3623
+ *
3624
+ * The contents of this file are subject to the Mozilla Public License Version
3625
+ * 1.1 (the "License"); you may not use this file except in compliance with
3626
+ * the License. You may obtain a copy of the License at
3627
+ * http://www.mozilla.org/MPL/
3628
+ *
3629
+ * Software distributed under the License is distributed on an "AS IS" basis,
3630
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
3631
+ * for the specific language governing rights and limitations under the
3632
+ * License.
3633
+ *
3634
+ * The Original Code is Ajax.org Code Editor (ACE).
3635
+ *
3636
+ * The Initial Developer of the Original Code is
3637
+ * Ajax.org B.V.
3638
+ * Portions created by the Initial Developer are Copyright (C) 2010
3639
+ * the Initial Developer. All Rights Reserved.
3640
+ *
3641
+ * Contributor(s):
3642
+ * Fabian Jakobs <fabian AT ajax DOT org>
3643
+ *
3644
+ * Alternatively, the contents of this file may be used under the terms of
3645
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
3646
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
3647
+ * in which case the provisions of the GPL or the LGPL are applicable instead
3648
+ * of those above. If you wish to allow use of your version of this file only
3649
+ * under the terms of either the GPL or the LGPL, and not to allow others to
3650
+ * use your version of this file under the terms of the MPL, indicate your
3651
+ * decision by deleting the provisions above and replace them with the notice
3652
+ * and other provisions required by the GPL or the LGPL. If you do not delete
3653
+ * the provisions above, a recipient may use your version of this file under
3654
+ * the terms of any one of the MPL, the GPL or the LGPL.
3655
+ *
3656
+ * ***** END LICENSE BLOCK ***** */
3657
+
3658
+ ace.define('ace/lib/lang', ['require', 'exports', 'module' ], function(require, exports, module) {
3659
+ "use strict";
3660
+
3661
+ exports.stringReverse = function(string) {
3662
+ return string.split("").reverse().join("");
3663
+ };
3664
+
3665
+ exports.stringRepeat = function (string, count) {
3666
+ return new Array(count + 1).join(string);
3667
+ };
3668
+
3669
+ var trimBeginRegexp = /^\s\s*/;
3670
+ var trimEndRegexp = /\s\s*$/;
3671
+
3672
+ exports.stringTrimLeft = function (string) {
3673
+ return string.replace(trimBeginRegexp, '');
3674
+ };
3675
+
3676
+ exports.stringTrimRight = function (string) {
3677
+ return string.replace(trimEndRegexp, '');
3678
+ };
3679
+
3680
+ exports.copyObject = function(obj) {
3681
+ var copy = {};
3682
+ for (var key in obj) {
3683
+ copy[key] = obj[key];
3684
+ }
3685
+ return copy;
3686
+ };
3687
+
3688
+ exports.copyArray = function(array){
3689
+ var copy = [];
3690
+ for (var i=0, l=array.length; i<l; i++) {
3691
+ if (array[i] && typeof array[i] == "object")
3692
+ copy[i] = this.copyObject( array[i] );
3693
+ else
3694
+ copy[i] = array[i];
3695
+ }
3696
+ return copy;
3697
+ };
3698
+
3699
+ exports.deepCopy = function (obj) {
3700
+ if (typeof obj != "object") {
3701
+ return obj;
3702
+ }
3703
+
3704
+ var copy = obj.constructor();
3705
+ for (var key in obj) {
3706
+ if (typeof obj[key] == "object") {
3707
+ copy[key] = this.deepCopy(obj[key]);
3708
+ } else {
3709
+ copy[key] = obj[key];
3710
+ }
3711
+ }
3712
+ return copy;
3713
+ };
3714
+
3715
+ exports.arrayToMap = function(arr) {
3716
+ var map = {};
3717
+ for (var i=0; i<arr.length; i++) {
3718
+ map[arr[i]] = 1;
3719
+ }
3720
+ return map;
3721
+
3722
+ };
3723
+
3724
+ /**
3725
+ * splice out of 'array' anything that === 'value'
3726
+ */
3727
+ exports.arrayRemove = function(array, value) {
3728
+ for (var i = 0; i <= array.length; i++) {
3729
+ if (value === array[i]) {
3730
+ array.splice(i, 1);
3731
+ }
3732
+ }
3733
+ };
3734
+
3735
+ exports.escapeRegExp = function(str) {
3736
+ return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
3737
+ };
3738
+
3739
+ exports.deferredCall = function(fcn) {
3740
+
3741
+ var timer = null;
3742
+ var callback = function() {
3743
+ timer = null;
3744
+ fcn();
3745
+ };
3746
+
3747
+ var deferred = function(timeout) {
3748
+ deferred.cancel();
3749
+ timer = setTimeout(callback, timeout || 0);
3750
+ return deferred;
3751
+ };
3752
+
3753
+ deferred.schedule = deferred;
3754
+
3755
+ deferred.call = function() {
3756
+ this.cancel();
3757
+ fcn();
3758
+ return deferred;
3759
+ };
3760
+
3761
+ deferred.cancel = function() {
3762
+ clearTimeout(timer);
3763
+ timer = null;
3764
+ return deferred;
3765
+ };
3766
+
3767
+ return deferred;
3768
+ };
3769
+
3770
+ });
3771
+ /* vim:ts=4:sts=4:sw=4:
3772
+ * ***** BEGIN LICENSE BLOCK *****
3773
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3774
+ *
3775
+ * The contents of this file are subject to the Mozilla Public License Version
3776
+ * 1.1 (the "License"); you may not use this file except in compliance with
3777
+ * the License. You may obtain a copy of the License at
3778
+ * http://www.mozilla.org/MPL/
3779
+ *
3780
+ * Software distributed under the License is distributed on an "AS IS" basis,
3781
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
3782
+ * for the specific language governing rights and limitations under the
3783
+ * License.
3784
+ *
3785
+ * The Original Code is Ajax.org Code Editor (ACE).
3786
+ *
3787
+ * The Initial Developer of the Original Code is
3788
+ * Ajax.org B.V.
3789
+ * Portions created by the Initial Developer are Copyright (C) 2010
3790
+ * the Initial Developer. All Rights Reserved.
3791
+ *
3792
+ * Contributor(s):
3793
+ * Fabian Jakobs <fabian AT ajax DOT org>
3794
+ * Mihai Sucan <mihai DOT sucan AT gmail DOT com>
3795
+ *
3796
+ * Alternatively, the contents of this file may be used under the terms of
3797
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
3798
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
3799
+ * in which case the provisions of the GPL or the LGPL are applicable instead
3800
+ * of those above. If you wish to allow use of your version of this file only
3801
+ * under the terms of either the GPL or the LGPL, and not to allow others to
3802
+ * use your version of this file under the terms of the MPL, indicate your
3803
+ * decision by deleting the provisions above and replace them with the notice
3804
+ * and other provisions required by the GPL or the LGPL. If you do not delete
3805
+ * the provisions above, a recipient may use your version of this file under
3806
+ * the terms of any one of the MPL, the GPL or the LGPL.
3807
+ *
3808
+ * ***** END LICENSE BLOCK ***** */
3809
+
3810
+ ace.define('ace/keyboard/textinput', ['require', 'exports', 'module' , 'ace/lib/event', 'ace/lib/useragent', 'ace/lib/dom'], function(require, exports, module) {
3811
+ "use strict";
3812
+
3813
+ var event = require("../lib/event");
3814
+ var useragent = require("../lib/useragent");
3815
+ var dom = require("../lib/dom");
3816
+
3817
+ var TextInput = function(parentNode, host) {
3818
+
3819
+ var text = dom.createElement("textarea");
3820
+ if (useragent.isTouchPad)
3821
+ text.setAttribute("x-palm-disable-auto-cap", true);
3822
+
3823
+ text.style.left = "-10000px";
3824
+ text.style.position = "fixed";
3825
+ parentNode.insertBefore(text, parentNode.firstChild);
3826
+
3827
+ var PLACEHOLDER = String.fromCharCode(0);
3828
+ sendText();
3829
+
3830
+ var inCompostion = false;
3831
+ var copied = false;
3832
+ var pasted = false;
3833
+ var tempStyle = '';
3834
+
3835
+ function select() {
3836
+ try {
3837
+ text.select();
3838
+ } catch (e) {}
3839
+ }
3840
+
3841
+ function sendText(valueToSend) {
3842
+ if (!copied) {
3843
+ var value = valueToSend || text.value;
3844
+ if (value) {
3845
+ if (value.charCodeAt(value.length-1) == PLACEHOLDER.charCodeAt(0)) {
3846
+ value = value.slice(0, -1);
3847
+ if (value)
3848
+ host.onTextInput(value, pasted);
3849
+ }
3850
+ else {
3851
+ host.onTextInput(value, pasted);
3852
+ }
3853
+
3854
+ // If editor is no longer focused we quit immediately, since
3855
+ // it means that something else is in charge now.
3856
+ if (!isFocused())
3857
+ return false;
3858
+ }
3859
+ }
3860
+
3861
+ copied = false;
3862
+ pasted = false;
3863
+
3864
+ // Safari doesn't fire copy events if no text is selected
3865
+ text.value = PLACEHOLDER;
3866
+ select();
3867
+ }
3868
+
3869
+ var onTextInput = function(e) {
3870
+ setTimeout(function () {
3871
+ if (!inCompostion)
3872
+ sendText(e.data);
3873
+ }, 0);
3874
+ };
3875
+
3876
+ var onPropertyChange = function(e) {
3877
+ if (useragent.isOldIE && text.value.charCodeAt(0) > 128) return;
3878
+ setTimeout(function() {
3879
+ if (!inCompostion)
3880
+ sendText();
3881
+ }, 0);
3882
+ };
3883
+
3884
+ var onCompositionStart = function(e) {
3885
+ inCompostion = true;
3886
+ host.onCompositionStart();
3887
+ if (!useragent.isGecko) setTimeout(onCompositionUpdate, 0);
3888
+ };
3889
+
3890
+ var onCompositionUpdate = function() {
3891
+ if (!inCompostion) return;
3892
+ host.onCompositionUpdate(text.value);
3893
+ };
3894
+
3895
+ var onCompositionEnd = function(e) {
3896
+ inCompostion = false;
3897
+ host.onCompositionEnd();
3898
+ };
3899
+
3900
+ var onCopy = function(e) {
3901
+ copied = true;
3902
+ var copyText = host.getCopyText();
3903
+ if(copyText)
3904
+ text.value = copyText;
3905
+ else
3906
+ e.preventDefault();
3907
+ select();
3908
+ setTimeout(function () {
3909
+ sendText();
3910
+ }, 0);
3911
+ };
3912
+
3913
+ var onCut = function(e) {
3914
+ copied = true;
3915
+ var copyText = host.getCopyText();
3916
+ if(copyText) {
3917
+ text.value = copyText;
3918
+ host.onCut();
3919
+ } else
3920
+ e.preventDefault();
3921
+ select();
3922
+ setTimeout(function () {
3923
+ sendText();
3924
+ }, 0);
3925
+ };
3926
+
3927
+ event.addCommandKeyListener(text, host.onCommandKey.bind(host));
3928
+ if (useragent.isOldIE) {
3929
+ var keytable = { 13:1, 27:1 };
3930
+ event.addListener(text, "keyup", function (e) {
3931
+ if (inCompostion && (!text.value || keytable[e.keyCode]))
3932
+ setTimeout(onCompositionEnd, 0);
3933
+ if ((text.value.charCodeAt(0)|0) < 129) {
3934
+ return;
3935
+ }
3936
+ inCompostion ? onCompositionUpdate() : onCompositionStart();
3937
+ });
3938
+ }
3939
+
3940
+ if ("onpropertychange" in text && !("oninput" in text))
3941
+ event.addListener(text, "propertychange", onPropertyChange);
3942
+ else
3943
+ event.addListener(text, "input", onTextInput);
3944
+
3945
+ event.addListener(text, "paste", function(e) {
3946
+ // Mark that the next input text comes from past.
3947
+ pasted = true;
3948
+ // Some browsers support the event.clipboardData API. Use this to get
3949
+ // the pasted content which increases speed if pasting a lot of lines.
3950
+ if (e.clipboardData && e.clipboardData.getData) {
3951
+ sendText(e.clipboardData.getData("text/plain"));
3952
+ e.preventDefault();
3953
+ }
3954
+ else {
3955
+ // If a browser doesn't support any of the things above, use the regular
3956
+ // method to detect the pasted input.
3957
+ onPropertyChange();
3958
+ }
3959
+ });
3960
+
3961
+ if ("onbeforecopy" in text && typeof clipboardData !== "undefined") {
3962
+ event.addListener(text, "beforecopy", function(e) {
3963
+ var copyText = host.getCopyText();
3964
+ if (copyText)
3965
+ clipboardData.setData("Text", copyText);
3966
+ else
3967
+ e.preventDefault();
3968
+ });
3969
+ event.addListener(parentNode, "keydown", function(e) {
3970
+ if (e.ctrlKey && e.keyCode == 88) {
3971
+ var copyText = host.getCopyText();
3972
+ if (copyText) {
3973
+ clipboardData.setData("Text", copyText);
3974
+ host.onCut();
3975
+ }
3976
+ event.preventDefault(e);
3977
+ }
3978
+ });
3979
+ }
3980
+ else {
3981
+ event.addListener(text, "copy", onCopy);
3982
+ event.addListener(text, "cut", onCut);
3983
+ }
3984
+
3985
+ event.addListener(text, "compositionstart", onCompositionStart);
3986
+ if (useragent.isGecko) {
3987
+ event.addListener(text, "text", onCompositionUpdate);
3988
+ }
3989
+ if (useragent.isWebKit) {
3990
+ event.addListener(text, "keyup", onCompositionUpdate);
3991
+ }
3992
+ event.addListener(text, "compositionend", onCompositionEnd);
3993
+
3994
+ event.addListener(text, "blur", function() {
3995
+ host.onBlur();
3996
+ });
3997
+
3998
+ event.addListener(text, "focus", function() {
3999
+ host.onFocus();
4000
+ select();
4001
+ });
4002
+
4003
+ this.focus = function() {
4004
+ host.onFocus();
4005
+ select();
4006
+ text.focus();
4007
+ };
4008
+
4009
+ this.blur = function() {
4010
+ text.blur();
4011
+ };
4012
+
4013
+ function isFocused() {
4014
+ return document.activeElement === text;
4015
+ }
4016
+ this.isFocused = isFocused;
4017
+
4018
+ this.getElement = function() {
4019
+ return text;
4020
+ };
4021
+
4022
+ this.onContextMenu = function(mousePos, isEmpty){
4023
+ if (mousePos) {
4024
+ if (!tempStyle)
4025
+ tempStyle = text.style.cssText;
4026
+
4027
+ text.style.cssText =
4028
+ 'position:fixed; z-index:1000;' +
4029
+ 'left:' + (mousePos.x - 2) + 'px; top:' + (mousePos.y - 2) + 'px;';
4030
+
4031
+ }
4032
+ if (isEmpty)
4033
+ text.value='';
4034
+ };
4035
+
4036
+ this.onContextMenuClose = function(){
4037
+ setTimeout(function () {
4038
+ if (tempStyle) {
4039
+ text.style.cssText = tempStyle;
4040
+ tempStyle = '';
4041
+ }
4042
+ sendText();
4043
+ }, 0);
4044
+ };
4045
+ };
4046
+
4047
+ exports.TextInput = TextInput;
4048
+ });
4049
+ /* vim:ts=4:sts=4:sw=4:
4050
+ * ***** BEGIN LICENSE BLOCK *****
4051
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4052
+ *
4053
+ * The contents of this file are subject to the Mozilla Public License Version
4054
+ * 1.1 (the "License"); you may not use this file except in compliance with
4055
+ * the License. You may obtain a copy of the License at
4056
+ * http://www.mozilla.org/MPL/
4057
+ *
4058
+ * Software distributed under the License is distributed on an "AS IS" basis,
4059
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
4060
+ * for the specific language governing rights and limitations under the
4061
+ * License.
4062
+ *
4063
+ * The Original Code is Ajax.org Code Editor (ACE).
4064
+ *
4065
+ * The Initial Developer of the Original Code is
4066
+ * Ajax.org B.V.
4067
+ * Portions created by the Initial Developer are Copyright (C) 2010
4068
+ * the Initial Developer. All Rights Reserved.
4069
+ *
4070
+ * Contributor(s):
4071
+ * Fabian Jakobs <fabian AT ajax DOT org>
4072
+ * Mihai Sucan <mihai DOT sucan AT gmail DOT com>
4073
+ *
4074
+ * Alternatively, the contents of this file may be used under the terms of
4075
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
4076
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
4077
+ * in which case the provisions of the GPL or the LGPL are applicable instead
4078
+ * of those above. If you wish to allow use of your version of this file only
4079
+ * under the terms of either the GPL or the LGPL, and not to allow others to
4080
+ * use your version of this file under the terms of the MPL, indicate your
4081
+ * decision by deleting the provisions above and replace them with the notice
4082
+ * and other provisions required by the GPL or the LGPL. If you do not delete
4083
+ * the provisions above, a recipient may use your version of this file under
4084
+ * the terms of any one of the MPL, the GPL or the LGPL.
4085
+ *
4086
+ * ***** END LICENSE BLOCK ***** */
4087
+
4088
+ ace.define('ace/mouse/mouse_handler', ['require', 'exports', 'module' , 'ace/lib/event', 'ace/mouse/default_handlers', 'ace/mouse/default_gutter_handler', 'ace/mouse/mouse_event'], function(require, exports, module) {
4089
+ "use strict";
4090
+
4091
+ var event = require("../lib/event");
4092
+ var DefaultHandlers = require("./default_handlers").DefaultHandlers;
4093
+ var DefaultGutterHandler = require("./default_gutter_handler").GutterHandler;
4094
+ var MouseEvent = require("./mouse_event").MouseEvent;
4095
+
4096
+ var MouseHandler = function(editor) {
4097
+ this.editor = editor;
4098
+
4099
+ new DefaultHandlers(editor);
4100
+ new DefaultGutterHandler(editor);
4101
+
4102
+ event.addListener(editor.container, "mousedown", function(e) {
4103
+ editor.focus();
4104
+ return event.preventDefault(e);
4105
+ });
4106
+ event.addListener(editor.container, "selectstart", function(e) {
4107
+ return event.preventDefault(e);
4108
+ });
4109
+
4110
+ var mouseTarget = editor.renderer.getMouseEventTarget();
4111
+ event.addListener(mouseTarget, "mousedown", this.onMouseEvent.bind(this, "mousedown"));
4112
+ event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click"));
4113
+ event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this, "mousemove"));
4114
+ event.addMultiMouseDownListener(mouseTarget, 0, 2, 500, this.onMouseEvent.bind(this, "dblclick"));
4115
+ event.addMultiMouseDownListener(mouseTarget, 0, 3, 600, this.onMouseEvent.bind(this, "tripleclick"));
4116
+ event.addMultiMouseDownListener(mouseTarget, 0, 4, 600, this.onMouseEvent.bind(this, "quadclick"));
4117
+ event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel"));
4118
+
4119
+ var gutterEl = editor.renderer.$gutter;
4120
+ event.addListener(gutterEl, "mousedown", this.onMouseEvent.bind(this, "guttermousedown"));
4121
+ event.addListener(gutterEl, "click", this.onMouseEvent.bind(this, "gutterclick"));
4122
+ event.addListener(gutterEl, "dblclick", this.onMouseEvent.bind(this, "gutterdblclick"));
4123
+ event.addListener(gutterEl, "mousemove", this.onMouseMove.bind(this, "gutter"));
4124
+ };
4125
+
4126
+ (function() {
4127
+
4128
+ this.$scrollSpeed = 1;
4129
+ this.setScrollSpeed = function(speed) {
4130
+ this.$scrollSpeed = speed;
4131
+ };
4132
+
4133
+ this.getScrollSpeed = function() {
4134
+ return this.$scrollSpeed;
4135
+ };
4136
+
4137
+ this.onMouseEvent = function(name, e) {
4138
+ this.editor._emit(name, new MouseEvent(e, this.editor));
4139
+ };
4140
+
4141
+ this.$dragDelay = 250;
4142
+ this.setDragDelay = function(dragDelay) {
4143
+ this.$dragDelay = dragDelay;
4144
+ };
4145
+
4146
+ this.getDragDelay = function() {
4147
+ return this.$dragDelay;
4148
+ };
4149
+
4150
+ this.onMouseMove = function(name, e) {
4151
+ // optimization, because mousemove doesn't have a default handler.
4152
+ var listeners = this.editor._eventRegistry && this.editor._eventRegistry.mousemove;
4153
+ if (!listeners || !listeners.length)
4154
+ return;
4155
+
4156
+ this.editor._emit(name, new MouseEvent(e, this.editor));
4157
+ };
4158
+
4159
+ this.onMouseWheel = function(name, e) {
4160
+ var mouseEvent = new MouseEvent(e, this.editor);
4161
+ mouseEvent.speed = this.$scrollSpeed * 2;
4162
+ mouseEvent.wheelX = e.wheelX;
4163
+ mouseEvent.wheelY = e.wheelY;
4164
+
4165
+ this.editor._emit(name, mouseEvent);
4166
+ };
4167
+
4168
+ }).call(MouseHandler.prototype);
4169
+
4170
+ exports.MouseHandler = MouseHandler;
4171
+ });
4172
+ /* vim:ts=4:sts=4:sw=4:
4173
+ * ***** BEGIN LICENSE BLOCK *****
4174
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4175
+ *
4176
+ * The contents of this file are subject to the Mozilla Public License Version
4177
+ * 1.1 (the "License"); you may not use this file except in compliance with
4178
+ * the License. You may obtain a copy of the License at
4179
+ * http://www.mozilla.org/MPL/
4180
+ *
4181
+ * Software distributed under the License is distributed on an "AS IS" basis,
4182
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
4183
+ * for the specific language governing rights and limitations under the
4184
+ * License.
4185
+ *
4186
+ * The Original Code is Ajax.org Code Editor (ACE).
4187
+ *
4188
+ * The Initial Developer of the Original Code is
4189
+ * Ajax.org B.V.
4190
+ * Portions created by the Initial Developer are Copyright (C) 2010
4191
+ * the Initial Developer. All Rights Reserved.
4192
+ *
4193
+ * Contributor(s):
4194
+ * Fabian Jakobs <fabian AT ajax DOT org>
4195
+ * Mike de Boer <mike AT ajax DOT org>
4196
+ *
4197
+ * Alternatively, the contents of this file may be used under the terms of
4198
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
4199
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
4200
+ * in which case the provisions of the GPL or the LGPL are applicable instead
4201
+ * of those above. If you wish to allow use of your version of this file only
4202
+ * under the terms of either the GPL or the LGPL, and not to allow others to
4203
+ * use your version of this file under the terms of the MPL, indicate your
4204
+ * decision by deleting the provisions above and replace them with the notice
4205
+ * and other provisions required by the GPL or the LGPL. If you do not delete
4206
+ * the provisions above, a recipient may use your version of this file under
4207
+ * the terms of any one of the MPL, the GPL or the LGPL.
4208
+ *
4209
+ * ***** END LICENSE BLOCK ***** */
4210
+
4211
+ ace.define('ace/mouse/default_handlers', ['require', 'exports', 'module' , 'ace/lib/event', 'ace/lib/dom', 'ace/lib/browser_focus'], function(require, exports, module) {
4212
+ "use strict";
4213
+
4214
+ var event = require("../lib/event");
4215
+ var dom = require("../lib/dom");
4216
+ var BrowserFocus = require("../lib/browser_focus").BrowserFocus;
4217
+
4218
+ var STATE_UNKNOWN = 0;
4219
+ var STATE_SELECT = 1;
4220
+ var STATE_DRAG = 2;
4221
+
4222
+ var DRAG_OFFSET = 5; // pixels
4223
+
4224
+ function DefaultHandlers(editor) {
4225
+ this.editor = editor;
4226
+ this.$clickSelection = null;
4227
+ this.browserFocus = new BrowserFocus();
4228
+
4229
+ editor.setDefaultHandler("mousedown", this.onMouseDown.bind(this));
4230
+ editor.setDefaultHandler("dblclick", this.onDoubleClick.bind(this));
4231
+ editor.setDefaultHandler("tripleclick", this.onTripleClick.bind(this));
4232
+ editor.setDefaultHandler("quadclick", this.onQuadClick.bind(this));
4233
+ editor.setDefaultHandler("mousewheel", this.onScroll.bind(this));
4234
+ }
4235
+
4236
+ (function() {
4237
+
4238
+ this.onMouseDown = function(ev) {
4239
+ var inSelection = ev.inSelection();
4240
+ var pageX = ev.pageX;
4241
+ var pageY = ev.pageY;
4242
+ var pos = ev.getDocumentPosition();
4243
+ var editor = this.editor;
4244
+ var _self = this;
4245
+
4246
+ var selectionRange = editor.getSelectionRange();
4247
+ var selectionEmpty = selectionRange.isEmpty();
4248
+ var state = STATE_UNKNOWN;
4249
+
4250
+ // if this click caused the editor to be focused should not clear the
4251
+ // selection
4252
+ if (
4253
+ inSelection && (
4254
+ !this.browserFocus.isFocused()
4255
+ || new Date().getTime() - this.browserFocus.lastFocus < 20
4256
+ || !editor.isFocused()
4257
+ )
4258
+ ) {
4259
+ editor.focus();
4260
+ return;
4261
+ }
4262
+
4263
+ var button = ev.getButton();
4264
+ if (button !== 0) {
4265
+ if (selectionEmpty) {
4266
+ editor.moveCursorToPosition(pos);
4267
+ }
4268
+ if (button == 2) {
4269
+ editor.textInput.onContextMenu({x: ev.clientX, y: ev.clientY}, selectionEmpty);
4270
+ event.capture(editor.container, function(){}, editor.textInput.onContextMenuClose);
4271
+ }
4272
+ return;
4273
+ }
4274
+
4275
+ if (!inSelection) {
4276
+ // Directly pick STATE_SELECT, since the user is not clicking inside
4277
+ // a selection.
4278
+ onStartSelect(pos);
4279
+ }
4280
+
4281
+ var mousePageX = pageX, mousePageY = pageY;
4282
+ var mousedownTime = (new Date()).getTime();
4283
+ var dragCursor, dragRange, dragSelectionMarker;
4284
+
4285
+ var onMouseSelection = function(e) {
4286
+ mousePageX = event.getDocumentX(e);
4287
+ mousePageY = event.getDocumentY(e);
4288
+ };
4289
+
4290
+ var onMouseSelectionEnd = function(e) {
4291
+ clearInterval(timerId);
4292
+ if (state == STATE_UNKNOWN)
4293
+ onStartSelect(pos);
4294
+ else if (state == STATE_DRAG)
4295
+ onMouseDragSelectionEnd(e);
4296
+
4297
+ _self.$clickSelection = null;
4298
+ state = STATE_UNKNOWN;
4299
+ };
4300
+
4301
+ var onMouseDragSelectionEnd = function(e) {
4302
+ dom.removeCssClass(editor.container, "ace_dragging");
4303
+ editor.session.removeMarker(dragSelectionMarker);
4304
+
4305
+ if (!editor.$mouseHandler.$clickSelection) {
4306
+ if (!dragCursor) {
4307
+ editor.moveCursorToPosition(pos);
4308
+ editor.selection.clearSelection(pos.row, pos.column);
4309
+ }
4310
+ }
4311
+
4312
+ if (!dragCursor)
4313
+ return;
4314
+
4315
+ if (dragRange.contains(dragCursor.row, dragCursor.column)) {
4316
+ dragCursor = null;
4317
+ return;
4318
+ }
4319
+
4320
+ editor.clearSelection();
4321
+ if (e && (e.ctrlKey || e.altKey)) {
4322
+ var session = editor.session;
4323
+ var newRange = session.insert(dragCursor, session.getTextRange(dragRange));
4324
+ } else {
4325
+ var newRange = editor.moveText(dragRange, dragCursor);
4326
+ }
4327
+ if (!newRange) {
4328
+ dragCursor = null;
4329
+ return;
4330
+ }
4331
+
4332
+ editor.selection.setSelectionRange(newRange);
4333
+ };
4334
+
4335
+ var onSelectionInterval = function() {
4336
+ if (state == STATE_UNKNOWN) {
4337
+ var distance = calcDistance(pageX, pageY, mousePageX, mousePageY);
4338
+ var time = (new Date()).getTime();
4339
+
4340
+ if (distance > DRAG_OFFSET) {
4341
+ state = STATE_SELECT;
4342
+ var cursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
4343
+ cursor.row = Math.max(0, Math.min(cursor.row, editor.session.getLength()-1));
4344
+ onStartSelect(cursor);
4345
+ }
4346
+ else if ((time - mousedownTime) > editor.getDragDelay()) {
4347
+ state = STATE_DRAG;
4348
+ dragRange = editor.getSelectionRange();
4349
+ var style = editor.getSelectionStyle();
4350
+ dragSelectionMarker = editor.session.addMarker(dragRange, "ace_selection", style);
4351
+ editor.clearSelection();
4352
+ dom.addCssClass(editor.container, "ace_dragging");
4353
+ }
4354
+
4355
+ }
4356
+
4357
+ if (state == STATE_DRAG)
4358
+ onDragSelectionInterval();
4359
+ else if (state == STATE_SELECT)
4360
+ onUpdateSelectionInterval();
4361
+ };
4362
+
4363
+ function onStartSelect(pos) {
4364
+ if (ev.getShiftKey()) {
4365
+ editor.selection.selectToPosition(pos);
4366
+ }
4367
+ else {
4368
+ if (!_self.$clickSelection) {
4369
+ editor.moveCursorToPosition(pos);
4370
+ editor.selection.clearSelection(pos.row, pos.column);
4371
+ }
4372
+ }
4373
+ state = STATE_SELECT;
4374
+ }
4375
+
4376
+ var onUpdateSelectionInterval = function() {
4377
+ var anchor;
4378
+ var cursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
4379
+ cursor.row = Math.max(0, Math.min(cursor.row, editor.session.getLength()-1));
4380
+
4381
+ if (_self.$clickSelection) {
4382
+ if (_self.$clickSelection.contains(cursor.row, cursor.column)) {
4383
+ editor.selection.setSelectionRange(_self.$clickSelection);
4384
+ }
4385
+ else {
4386
+ if (_self.$clickSelection.compare(cursor.row, cursor.column) == -1) {
4387
+ anchor = _self.$clickSelection.end;
4388
+ }
4389
+ else {
4390
+ anchor = _self.$clickSelection.start;
4391
+ }
4392
+ editor.selection.setSelectionAnchor(anchor.row, anchor.column);
4393
+ editor.selection.selectToPosition(cursor);
4394
+ }
4395
+ }
4396
+ else {
4397
+ editor.selection.selectToPosition(cursor);
4398
+ }
4399
+
4400
+ editor.renderer.scrollCursorIntoView();
4401
+ };
4402
+
4403
+ var onDragSelectionInterval = function() {
4404
+ dragCursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
4405
+ dragCursor.row = Math.max(0, Math.min(dragCursor.row, editor.session.getLength() - 1));
4406
+
4407
+ editor.moveCursorToPosition(dragCursor);
4408
+ };
4409
+
4410
+ event.capture(editor.container, onMouseSelection, onMouseSelectionEnd);
4411
+ var timerId = setInterval(onSelectionInterval, 20);
4412
+
4413
+ return ev.preventDefault();
4414
+ };
4415
+
4416
+ this.onDoubleClick = function(ev) {
4417
+ var pos = ev.getDocumentPosition();
4418
+ var editor = this.editor;
4419
+
4420
+ editor.moveCursorToPosition(pos);
4421
+ editor.selection.selectWord();
4422
+ this.$clickSelection = editor.getSelectionRange();
4423
+ };
4424
+
4425
+ this.onTripleClick = function(ev) {
4426
+ var pos = ev.getDocumentPosition();
4427
+ var editor = this.editor;
4428
+
4429
+ editor.moveCursorToPosition(pos);
4430
+ editor.selection.selectLine();
4431
+ this.$clickSelection = editor.getSelectionRange();
4432
+ };
4433
+
4434
+ this.onQuadClick = function(ev) {
4435
+ var editor = this.editor;
4436
+
4437
+ editor.selectAll();
4438
+ this.$clickSelection = editor.getSelectionRange();
4439
+ };
4440
+
4441
+ this.onScroll = function(ev) {
4442
+ var editor = this.editor;
4443
+
4444
+ editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
4445
+ if (editor.renderer.isScrollableBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed))
4446
+ return ev.preventDefault();
4447
+ };
4448
+
4449
+ }).call(DefaultHandlers.prototype);
4450
+
4451
+ exports.DefaultHandlers = DefaultHandlers;
4452
+
4453
+ function calcDistance(ax, ay, bx, by) {
4454
+ return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
4455
+ }
4456
+
4457
+ });
4458
+ /* vim:ts=4:sts=4:sw=4:
4459
+ * ***** BEGIN LICENSE BLOCK *****
4460
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4461
+ *
4462
+ * The contents of this file are subject to the Mozilla Public License Version
4463
+ * 1.1 (the "License"); you may not use this file except in compliance with
4464
+ * the License. You may obtain a copy of the License at
4465
+ * http://www.mozilla.org/MPL/
4466
+ *
4467
+ * Software distributed under the License is distributed on an "AS IS" basis,
4468
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
4469
+ * for the specific language governing rights and limitations under the
4470
+ * License.
4471
+ *
4472
+ * The Original Code is Ajax.org Code Editor (ACE).
4473
+ *
4474
+ * The Initial Developer of the Original Code is
4475
+ * Ajax.org B.V.
4476
+ * Portions created by the Initial Developer are Copyright (C) 2010
4477
+ * the Initial Developer. All Rights Reserved.
4478
+ *
4479
+ * Contributor(s):
4480
+ * Fabian Jakobs <fabian AT ajax DOT org>
4481
+ * Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
4482
+ * Julian Viereck <julian.viereck@gmail.com>
4483
+ *
4484
+ * Alternatively, the contents of this file may be used under the terms of
4485
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
4486
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
4487
+ * in which case the provisions of the GPL or the LGPL are applicable instead
4488
+ * of those above. If you wish to allow use of your version of this file only
4489
+ * under the terms of either the GPL or the LGPL, and not to allow others to
4490
+ * use your version of this file under the terms of the MPL, indicate your
4491
+ * decision by deleting the provisions above and replace them with the notice
4492
+ * and other provisions required by the GPL or the LGPL. If you do not delete
4493
+ * the provisions above, a recipient may use your version of this file under
4494
+ * the terms of any one of the MPL, the GPL or the LGPL.
4495
+ *
4496
+ * ***** END LICENSE BLOCK ***** */
4497
+
4498
+ ace.define('ace/lib/browser_focus', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event', 'ace/lib/event_emitter'], function(require, exports, module) {
4499
+ "use strict";
4500
+
4501
+ var oop = require("./oop");
4502
+ var event = require("./event");
4503
+ var EventEmitter = require("./event_emitter").EventEmitter;
4504
+
4505
+ /**
4506
+ * This class keeps track of the focus state of the given window.
4507
+ * Focus changes for example when the user switches a browser tab,
4508
+ * goes to the location bar or switches to another application.
4509
+ */
4510
+ var BrowserFocus = function(win) {
4511
+ win = win || window;
4512
+
4513
+ this.lastFocus = new Date().getTime();
4514
+ this._isFocused = true;
4515
+
4516
+ var _self = this;
4517
+
4518
+ // IE < 9 supports focusin and focusout events
4519
+ if ("onfocusin" in win.document) {
4520
+ event.addListener(win.document, "focusin", function(e) {
4521
+ _self._setFocused(true);
4522
+ });
4523
+
4524
+ event.addListener(win.document, "focusout", function(e) {
4525
+ _self._setFocused(!!e.toElement);
4526
+ });
4527
+ }
4528
+ else {
4529
+ event.addListener(win, "blur", function(e) {
4530
+ _self._setFocused(false);
4531
+ });
4532
+
4533
+ event.addListener(win, "focus", function(e) {
4534
+ _self._setFocused(true);
4535
+ });
4536
+ }
4537
+ };
4538
+
4539
+ (function(){
4540
+
4541
+ oop.implement(this, EventEmitter);
4542
+
4543
+ this.isFocused = function() {
4544
+ return this._isFocused;
4545
+ };
4546
+
4547
+ this._setFocused = function(isFocused) {
4548
+ if (this._isFocused == isFocused)
4549
+ return;
4550
+
4551
+ if (isFocused)
4552
+ this.lastFocus = new Date().getTime();
4553
+
4554
+ this._isFocused = isFocused;
4555
+ this._emit("changeFocus");
4556
+ };
4557
+
4558
+ }).call(BrowserFocus.prototype);
4559
+
4560
+
4561
+ exports.BrowserFocus = BrowserFocus;
4562
+ });
4563
+ /* vim:ts=4:sts=4:sw=4:
4564
+ * ***** BEGIN LICENSE BLOCK *****
4565
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4566
+ *
4567
+ * The contents of this file are subject to the Mozilla Public License Version
4568
+ * 1.1 (the "License"); you may not use this file except in compliance with
4569
+ * the License. You may obtain a copy of the License at
4570
+ * http://www.mozilla.org/MPL/
4571
+ *
4572
+ * Software distributed under the License is distributed on an "AS IS" basis,
4573
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
4574
+ * for the specific language governing rights and limitations under the
4575
+ * License.
4576
+ *
4577
+ * The Original Code is Ajax.org Code Editor (ACE).
4578
+ *
4579
+ * The Initial Developer of the Original Code is
4580
+ * Ajax.org B.V.
4581
+ * Portions created by the Initial Developer are Copyright (C) 2010
4582
+ * the Initial Developer. All Rights Reserved.
4583
+ *
4584
+ * Contributor(s):
4585
+ * Fabian Jakobs <fabian AT ajax DOT org>
4586
+ * Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
4587
+ * Mike de Boer <mike AT ajax DOT org>
4588
+ *
4589
+ * Alternatively, the contents of this file may be used under the terms of
4590
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
4591
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
4592
+ * in which case the provisions of the GPL or the LGPL are applicable instead
4593
+ * of those above. If you wish to allow use of your version of this file only
4594
+ * under the terms of either the GPL or the LGPL, and not to allow others to
4595
+ * use your version of this file under the terms of the MPL, indicate your
4596
+ * decision by deleting the provisions above and replace them with the notice
4597
+ * and other provisions required by the GPL or the LGPL. If you do not delete
4598
+ * the provisions above, a recipient may use your version of this file under
4599
+ * the terms of any one of the MPL, the GPL or the LGPL.
4600
+ *
4601
+ * ***** END LICENSE BLOCK ***** */
4602
+
4603
+ ace.define('ace/lib/event_emitter', ['require', 'exports', 'module' ], function(require, exports, module) {
4604
+ "use strict";
4605
+
4606
+ var EventEmitter = {};
4607
+
4608
+ EventEmitter._emit =
4609
+ EventEmitter._dispatchEvent = function(eventName, e) {
4610
+ this._eventRegistry = this._eventRegistry || {};
4611
+ this._defaultHandlers = this._defaultHandlers || {};
4612
+
4613
+ var listeners = this._eventRegistry[eventName] || [];
4614
+ var defaultHandler = this._defaultHandlers[eventName];
4615
+ if (!listeners.length && !defaultHandler)
4616
+ return;
4617
+
4618
+ e = e || {};
4619
+ e.type = eventName;
4620
+
4621
+ if (!e.stopPropagation) {
4622
+ e.stopPropagation = function() {
4623
+ this.propagationStopped = true;
4624
+ };
4625
+ }
4626
+
4627
+ if (!e.preventDefault) {
4628
+ e.preventDefault = function() {
4629
+ this.defaultPrevented = true;
4630
+ };
4631
+ }
4632
+
4633
+ for (var i=0; i<listeners.length; i++) {
4634
+ listeners[i](e);
4635
+ if (e.propagationStopped)
4636
+ break;
4637
+ }
4638
+
4639
+ if (defaultHandler && !e.defaultPrevented)
4640
+ defaultHandler(e);
4641
+ };
4642
+
4643
+ EventEmitter.setDefaultHandler = function(eventName, callback) {
4644
+ this._defaultHandlers = this._defaultHandlers || {};
4645
+
4646
+ if (this._defaultHandlers[eventName])
4647
+ throw new Error("The default handler for '" + eventName + "' is already set");
4648
+
4649
+ this._defaultHandlers[eventName] = callback;
4650
+ };
4651
+
4652
+ EventEmitter.on =
4653
+ EventEmitter.addEventListener = function(eventName, callback) {
4654
+ this._eventRegistry = this._eventRegistry || {};
4655
+
4656
+ var listeners = this._eventRegistry[eventName];
4657
+ if (!listeners)
4658
+ var listeners = this._eventRegistry[eventName] = [];
4659
+
4660
+ if (listeners.indexOf(callback) == -1)
4661
+ listeners.push(callback);
4662
+ };
4663
+
4664
+ EventEmitter.removeListener =
4665
+ EventEmitter.removeEventListener = function(eventName, callback) {
4666
+ this._eventRegistry = this._eventRegistry || {};
4667
+
4668
+ var listeners = this._eventRegistry[eventName];
4669
+ if (!listeners)
4670
+ return;
4671
+
4672
+ var index = listeners.indexOf(callback);
4673
+ if (index !== -1)
4674
+ listeners.splice(index, 1);
4675
+ };
4676
+
4677
+ EventEmitter.removeAllListeners = function(eventName) {
4678
+ if (this._eventRegistry) this._eventRegistry[eventName] = [];
4679
+ };
4680
+
4681
+ exports.EventEmitter = EventEmitter;
4682
+
4683
+ });/* vim:ts=4:sts=4:sw=4:
4684
+ * ***** BEGIN LICENSE BLOCK *****
4685
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4686
+ *
4687
+ * The contents of this file are subject to the Mozilla Public License Version
4688
+ * 1.1 (the "License"); you may not use this file except in compliance with
4689
+ * the License. You may obtain a copy of the License at
4690
+ * http://www.mozilla.org/MPL/
4691
+ *
4692
+ * Software distributed under the License is distributed on an "AS IS" basis,
4693
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
4694
+ * for the specific language governing rights and limitations under the
4695
+ * License.
4696
+ *
4697
+ * The Original Code is Ajax.org Code Editor (ACE).
4698
+ *
4699
+ * The Initial Developer of the Original Code is
4700
+ * Ajax.org B.V.
4701
+ * Portions created by the Initial Developer are Copyright (C) 2010
4702
+ * the Initial Developer. All Rights Reserved.
4703
+ *
4704
+ * Contributor(s):
4705
+ * Fabian Jakobs <fabian AT ajax DOT org>
4706
+ *
4707
+ * Alternatively, the contents of this file may be used under the terms of
4708
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
4709
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
4710
+ * in which case the provisions of the GPL or the LGPL are applicable instead
4711
+ * of those above. If you wish to allow use of your version of this file only
4712
+ * under the terms of either the GPL or the LGPL, and not to allow others to
4713
+ * use your version of this file under the terms of the MPL, indicate your
4714
+ * decision by deleting the provisions above and replace them with the notice
4715
+ * and other provisions required by the GPL or the LGPL. If you do not delete
4716
+ * the provisions above, a recipient may use your version of this file under
4717
+ * the terms of any one of the MPL, the GPL or the LGPL.
4718
+ *
4719
+ * ***** END LICENSE BLOCK ***** */
4720
+
4721
+ ace.define('ace/mouse/default_gutter_handler', ['require', 'exports', 'module' ], function(require, exports, module) {
4722
+ "use strict";
4723
+
4724
+ function GutterHandler(editor) {
4725
+ editor.setDefaultHandler("gutterclick", function(e) {
4726
+ var row = e.getDocumentPosition().row;
4727
+ var selection = editor.session.selection;
4728
+
4729
+ selection.moveCursorTo(row, 0);
4730
+ selection.selectLine();
4731
+ });
4732
+ }
4733
+
4734
+ exports.GutterHandler = GutterHandler;
4735
+
4736
+ });/* vim:ts=4:sts=4:sw=4:
4737
+ * ***** BEGIN LICENSE BLOCK *****
4738
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4739
+ *
4740
+ * The contents of this file are subject to the Mozilla Public License Version
4741
+ * 1.1 (the "License"); you may not use this file except in compliance with
4742
+ * the License. You may obtain a copy of the License at
4743
+ * http://www.mozilla.org/MPL/
4744
+ *
4745
+ * Software distributed under the License is distributed on an "AS IS" basis,
4746
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
4747
+ * for the specific language governing rights and limitations under the
4748
+ * License.
4749
+ *
4750
+ * The Original Code is Ajax.org Code Editor (ACE).
4751
+ *
4752
+ * The Initial Developer of the Original Code is
4753
+ * Ajax.org B.V.
4754
+ * Portions created by the Initial Developer are Copyright (C) 2010
4755
+ * the Initial Developer. All Rights Reserved.
4756
+ *
4757
+ * Contributor(s):
4758
+ * Fabian Jakobs <fabian AT ajax DOT org>
4759
+ *
4760
+ * Alternatively, the contents of this file may be used under the terms of
4761
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
4762
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
4763
+ * in which case the provisions of the GPL or the LGPL are applicable instead
4764
+ * of those above. If you wish to allow use of your version of this file only
4765
+ * under the terms of either the GPL or the LGPL, and not to allow others to
4766
+ * use your version of this file under the terms of the MPL, indicate your
4767
+ * decision by deleting the provisions above and replace them with the notice
4768
+ * and other provisions required by the GPL or the LGPL. If you do not delete
4769
+ * the provisions above, a recipient may use your version of this file under
4770
+ * the terms of any one of the MPL, the GPL or the LGPL.
4771
+ *
4772
+ * ***** END LICENSE BLOCK ***** */
4773
+
4774
+ ace.define('ace/mouse/mouse_event', ['require', 'exports', 'module' , 'ace/lib/event'], function(require, exports, module) {
4775
+ "use strict";
4776
+
4777
+ var event = require("../lib/event");
4778
+
4779
+ /**
4780
+ * Custom Ace mouse event
4781
+ */
4782
+ var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
4783
+ this.domEvent = domEvent;
4784
+ this.editor = editor;
4785
+
4786
+ this.pageX = event.getDocumentX(domEvent);
4787
+ this.pageY = event.getDocumentY(domEvent);
4788
+
4789
+ this.clientX = domEvent.clientX;
4790
+ this.clientY = domEvent.clientY;
4791
+
4792
+ this.$pos = null;
4793
+ this.$inSelection = null;
4794
+
4795
+ this.propagationStopped = false;
4796
+ this.defaultPrevented = false;
4797
+ };
4798
+
4799
+ (function() {
4800
+
4801
+ this.stopPropagation = function() {
4802
+ event.stopPropagation(this.domEvent);
4803
+ this.propagationStopped = true;
4804
+ };
4805
+
4806
+ this.preventDefault = function() {
4807
+ event.preventDefault(this.domEvent);
4808
+ this.defaultPrevented = true;
4809
+ };
4810
+
4811
+ this.stop = function() {
4812
+ this.stopPropagation();
4813
+ this.preventDefault();
4814
+ };
4815
+
4816
+ /**
4817
+ * Get the document position below the mouse cursor
4818
+ *
4819
+ * @return {Object} 'row' and 'column' of the document position
4820
+ */
4821
+ this.getDocumentPosition = function() {
4822
+ if (this.$pos)
4823
+ return this.$pos;
4824
+
4825
+ var pageX = event.getDocumentX(this.domEvent);
4826
+ var pageY = event.getDocumentY(this.domEvent);
4827
+ this.$pos = this.editor.renderer.screenToTextCoordinates(pageX, pageY);
4828
+ this.$pos.row = Math.max(0, Math.min(this.$pos.row, this.editor.session.getLength()-1));
4829
+ return this.$pos;
4830
+ };
4831
+
4832
+ /**
4833
+ * Check if the mouse cursor is inside of the text selection
4834
+ *
4835
+ * @return {Boolean} whether the mouse cursor is inside of the selection
4836
+ */
4837
+ this.inSelection = function() {
4838
+ if (this.$inSelection !== null)
4839
+ return this.$inSelection;
4840
+
4841
+ var editor = this.editor;
4842
+
4843
+ if (editor.getReadOnly()) {
4844
+ this.$inSelection = false;
4845
+ }
4846
+ else {
4847
+ var selectionRange = editor.getSelectionRange();
4848
+ if (selectionRange.isEmpty())
4849
+ this.$inSelection = false;
4850
+ else {
4851
+ var pos = this.getDocumentPosition();
4852
+ this.$inSelection = selectionRange.contains(pos.row, pos.column);
4853
+ }
4854
+ }
4855
+ return this.$inSelection;
4856
+ };
4857
+
4858
+ /**
4859
+ * Get the clicked mouse button
4860
+ *
4861
+ * @return {Number} 0 for left button, 1 for middle button, 2 for right button
4862
+ */
4863
+ this.getButton = function() {
4864
+ return event.getButton(this.domEvent);
4865
+ };
4866
+
4867
+ /**
4868
+ * @return {Boolean} whether the shift key was pressed when the event was emitted
4869
+ */
4870
+ this.getShiftKey = function() {
4871
+ return this.domEvent.shiftKey;
4872
+ };
4873
+
4874
+ this.getAccelKey = function() {
4875
+ return this.domEvent.ctrlKey || this.domEvent.metaKey ;
4876
+ };
4877
+
4878
+ }).call(MouseEvent.prototype);
4879
+
4880
+ });
4881
+ /* vim:ts=4:sts=4:sw=4:
4882
+ * ***** BEGIN LICENSE BLOCK *****
4883
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4884
+ *
4885
+ * The contents of this file are subject to the Mozilla Public License Version
4886
+ * 1.1 (the "License"); you may not use this file except in compliance with
4887
+ * the License. You may obtain a copy of the License at
4888
+ * http://www.mozilla.org/MPL/
4889
+ *
4890
+ * Software distributed under the License is distributed on an "AS IS" basis,
4891
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
4892
+ * for the specific language governing rights and limitations under the
4893
+ * License.
4894
+ *
4895
+ * The Original Code is Ajax.org Code Editor (ACE).
4896
+ *
4897
+ * The Initial Developer of the Original Code is
4898
+ * Ajax.org B.V.
4899
+ * Portions created by the Initial Developer are Copyright (C) 2010
4900
+ * the Initial Developer. All Rights Reserved.
4901
+ *
4902
+ * Contributor(s):
4903
+ * Fabian Jakobs <fabian AT ajax DOT org>
4904
+ *
4905
+ * Alternatively, the contents of this file may be used under the terms of
4906
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
4907
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
4908
+ * in which case the provisions of the GPL or the LGPL are applicable instead
4909
+ * of those above. If you wish to allow use of your version of this file only
4910
+ * under the terms of either the GPL or the LGPL, and not to allow others to
4911
+ * use your version of this file under the terms of the MPL, indicate your
4912
+ * decision by deleting the provisions above and replace them with the notice
4913
+ * and other provisions required by the GPL or the LGPL. If you do not delete
4914
+ * the provisions above, a recipient may use your version of this file under
4915
+ * the terms of any one of the MPL, the GPL or the LGPL.
4916
+ *
4917
+ * ***** END LICENSE BLOCK ***** */
4918
+
4919
+ ace.define('ace/mouse/fold_handler', ['require', 'exports', 'module' ], function(require, exports, module) {
4920
+ "use strict";
4921
+
4922
+ function FoldHandler(editor) {
4923
+
4924
+ editor.on("click", function(e) {
4925
+ var position = e.getDocumentPosition();
4926
+ var session = editor.session;
4927
+
4928
+ // If the user dclicked on a fold, then expand it.
4929
+ var fold = session.getFoldAt(position.row, position.column, 1);
4930
+ if (fold) {
4931
+ if (e.getAccelKey())
4932
+ session.removeFold(fold);
4933
+ else
4934
+ session.expandFold(fold);
4935
+
4936
+ e.stop();
4937
+ }
4938
+ });
4939
+
4940
+ editor.on("gutterclick", function(e) {
4941
+ if (e.domEvent.target.className.indexOf("ace_fold-widget") != -1) {
4942
+ var row = e.getDocumentPosition().row;
4943
+ editor.session.onFoldWidgetClick(row, e.domEvent);
4944
+ e.stop();
4945
+ }
4946
+ });
4947
+ }
4948
+
4949
+ exports.FoldHandler = FoldHandler;
4950
+
4951
+ });/* ***** BEGIN LICENSE BLOCK *****
4952
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4953
+ *
4954
+ * The contents of this file are subject to the Mozilla Public License Version
4955
+ * 1.1 (the "License"); you may not use this file except in compliance with
4956
+ * the License. You may obtain a copy of the License at
4957
+ * http://www.mozilla.org/MPL/
4958
+ *
4959
+ * Software distributed under the License is distributed on an "AS IS" basis,
4960
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
4961
+ * for the specific language governing rights and limitations under the
4962
+ * License.
4963
+ *
4964
+ * The Original Code is Ajax.org Code Editor (ACE).
4965
+ *
4966
+ * The Initial Developer of the Original Code is
4967
+ * Ajax.org B.V.
4968
+ * Portions created by the Initial Developer are Copyright (C) 2010
4969
+ * the Initial Developer. All Rights Reserved.
4970
+ *
4971
+ * Contributor(s):
4972
+ * Fabian Jakobs <fabian AT ajax DOT org>
4973
+ * Julian Viereck <julian.viereck@gmail.com>
4974
+ * Harutyun Amirjanyan <amirjanyan@gmail.com>
4975
+ *
4976
+ * Alternatively, the contents of this file may be used under the terms of
4977
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
4978
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
4979
+ * in which case the provisions of the GPL or the LGPL are applicable instead
4980
+ * of those above. If you wish to allow use of your version of this file only
4981
+ * under the terms of either the GPL or the LGPL, and not to allow others to
4982
+ * use your version of this file under the terms of the MPL, indicate your
4983
+ * decision by deleting the provisions above and replace them with the notice
4984
+ * and other provisions required by the GPL or the LGPL. If you do not delete
4985
+ * the provisions above, a recipient may use your version of this file under
4986
+ * the terms of any one of the MPL, the GPL or the LGPL.
4987
+ *
4988
+ * ***** END LICENSE BLOCK ***** */
4989
+
4990
+ ace.define('ace/keyboard/keybinding', ['require', 'exports', 'module' , 'ace/lib/keys', 'ace/lib/event', 'ace/commands/default_commands'], function(require, exports, module) {
4991
+ "use strict";
4992
+
4993
+ var keyUtil = require("../lib/keys");
4994
+ var event = require("../lib/event");
4995
+ require("../commands/default_commands");
4996
+
4997
+ var KeyBinding = function(editor) {
4998
+ this.$editor = editor;
4999
+ this.$data = { };
5000
+ this.$handlers = [this];
5001
+ };
5002
+
5003
+ (function() {
5004
+ this.setKeyboardHandler = function(keyboardHandler) {
5005
+ if (this.$handlers[this.$handlers.length - 1] == keyboardHandler)
5006
+ return;
5007
+ this.$data = { };
5008
+ this.$handlers = keyboardHandler ? [this, keyboardHandler] : [this];
5009
+ };
5010
+
5011
+ this.addKeyboardHandler = function(keyboardHandler) {
5012
+ this.removeKeyboardHandler(keyboardHandler);
5013
+ this.$handlers.push(keyboardHandler);
5014
+ };
5015
+
5016
+ this.removeKeyboardHandler = function(keyboardHandler) {
5017
+ var i = this.$handlers.indexOf(keyboardHandler);
5018
+ if (i == -1)
5019
+ return false;
5020
+ this.$handlers.splice(i, 1);
5021
+ return true;
5022
+ };
5023
+
5024
+ this.getKeyboardHandler = function() {
5025
+ return this.$handlers[this.$handlers.length - 1];
5026
+ };
5027
+
5028
+ this.$callKeyboardHandlers = function (hashId, keyString, keyCode, e) {
5029
+ var toExecute;
5030
+ for (var i = this.$handlers.length; i--;) {
5031
+ toExecute = this.$handlers[i].handleKeyboard(
5032
+ this.$data, hashId, keyString, keyCode, e
5033
+ );
5034
+ if (toExecute && toExecute.command)
5035
+ break;
5036
+ }
5037
+
5038
+ if (!toExecute || !toExecute.command)
5039
+ return false;
5040
+
5041
+ var success = false;
5042
+ var commands = this.$editor.commands;
5043
+
5044
+ // allow keyboardHandler to consume keys
5045
+ if (toExecute.command != "null")
5046
+ success = commands.exec(toExecute.command, this.$editor, toExecute.args);
5047
+ else
5048
+ success = true;
5049
+
5050
+ if (success && e)
5051
+ event.stopEvent(e);
5052
+
5053
+ return success;
5054
+ };
5055
+
5056
+ this.handleKeyboard = function(data, hashId, keyString) {
5057
+ return {
5058
+ command: this.$editor.commands.findKeyCommand(hashId, keyString)
5059
+ };
5060
+ };
5061
+
5062
+ this.onCommandKey = function(e, hashId, keyCode) {
5063
+ var keyString = keyUtil.keyCodeToString(keyCode);
5064
+ this.$callKeyboardHandlers(hashId, keyString, keyCode, e);
5065
+ };
5066
+
5067
+ this.onTextInput = function(text, pasted) {
5068
+ var success = false;
5069
+ if (!pasted && text.length == 1)
5070
+ success = this.$callKeyboardHandlers(0, text);
5071
+ if (!success)
5072
+ this.$editor.commands.exec("insertstring", this.$editor, text);
5073
+ };
5074
+
5075
+ }).call(KeyBinding.prototype);
5076
+
5077
+ exports.KeyBinding = KeyBinding;
5078
+ });
5079
+ /* vim:ts=4:sts=4:sw=4:
5080
+ * ***** BEGIN LICENSE BLOCK *****
5081
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5082
+ *
5083
+ * The contents of this file are subject to the Mozilla Public License Version
5084
+ * 1.1 (the "License"); you may not use this file except in compliance with
5085
+ * the License. You may obtain a copy of the License at
5086
+ * http://www.mozilla.org/MPL/
5087
+ *
5088
+ * Software distributed under the License is distributed on an "AS IS" basis,
5089
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
5090
+ * for the specific language governing rights and limitations under the
5091
+ * License.
5092
+ *
5093
+ * The Original Code is Ajax.org Code Editor (ACE).
5094
+ *
5095
+ * The Initial Developer of the Original Code is
5096
+ * Ajax.org B.V.
5097
+ * Portions created by the Initial Developer are Copyright (C) 2010
5098
+ * the Initial Developer. All Rights Reserved.
5099
+ *
5100
+ * Contributor(s):
5101
+ * Fabian Jakobs <fabian AT ajax DOT org>
5102
+ * Julian Viereck <julian.viereck@gmail.com>
5103
+ * Mihai Sucan <mihai.sucan@gmail.com>
5104
+ *
5105
+ * Alternatively, the contents of this file may be used under the terms of
5106
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
5107
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
5108
+ * in which case the provisions of the GPL or the LGPL are applicable instead
5109
+ * of those above. If you wish to allow use of your version of this file only
5110
+ * under the terms of either the GPL or the LGPL, and not to allow others to
5111
+ * use your version of this file under the terms of the MPL, indicate your
5112
+ * decision by deleting the provisions above and replace them with the notice
5113
+ * and other provisions required by the GPL or the LGPL. If you do not delete
5114
+ * the provisions above, a recipient may use your version of this file under
5115
+ * the terms of any one of the MPL, the GPL or the LGPL.
5116
+ *
5117
+ * ***** END LICENSE BLOCK ***** */
5118
+
5119
+ ace.define('ace/commands/default_commands', ['require', 'exports', 'module' , 'ace/lib/lang'], function(require, exports, module) {
5120
+ "use strict";
5121
+
5122
+ var lang = require("../lib/lang");
5123
+
5124
+ function bindKey(win, mac) {
5125
+ return {
5126
+ win: win,
5127
+ mac: mac
5128
+ };
5129
+ }
5130
+
5131
+ exports.commands = [{
5132
+ name: "selectall",
5133
+ bindKey: bindKey("Ctrl-A", "Command-A"),
5134
+ exec: function(editor) { editor.selectAll(); },
5135
+ readOnly: true
5136
+ }, {
5137
+ name: "centerselection",
5138
+ bindKey: bindKey(null, "Ctrl-L"),
5139
+ exec: function(editor) { editor.centerSelection(); },
5140
+ readOnly: true
5141
+ }, {
5142
+ name: "gotoline",
5143
+ bindKey: bindKey("Ctrl-L", "Command-L"),
5144
+ exec: function(editor) {
5145
+ var line = parseInt(prompt("Enter line number:"), 10);
5146
+ if (!isNaN(line)) {
5147
+ editor.gotoLine(line);
5148
+ }
5149
+ },
5150
+ readOnly: true
5151
+ }, {
5152
+ name: "fold",
5153
+ bindKey: bindKey("Alt-L", "Alt-L"),
5154
+ exec: function(editor) { editor.session.toggleFold(false); },
5155
+ readOnly: true
5156
+ }, {
5157
+ name: "unfold",
5158
+ bindKey: bindKey("Alt-Shift-L", "Alt-Shift-L"),
5159
+ exec: function(editor) { editor.session.toggleFold(true); },
5160
+ readOnly: true
5161
+ }, {
5162
+ name: "foldall",
5163
+ bindKey: bindKey("Alt-0", "Alt-0"),
5164
+ exec: function(editor) { editor.session.foldAll(); },
5165
+ readOnly: true
5166
+ }, {
5167
+ name: "unfoldall",
5168
+ bindKey: bindKey("Alt-Shift-0", "Alt-Shift-0"),
5169
+ exec: function(editor) { editor.session.unfold(); },
5170
+ readOnly: true
5171
+ }, {
5172
+ name: "findnext",
5173
+ bindKey: bindKey("Ctrl-K", "Command-G"),
5174
+ exec: function(editor) { editor.findNext(); },
5175
+ readOnly: true
5176
+ }, {
5177
+ name: "findprevious",
5178
+ bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
5179
+ exec: function(editor) { editor.findPrevious(); },
5180
+ readOnly: true
5181
+ }, {
5182
+ name: "find",
5183
+ bindKey: bindKey("Ctrl-F", "Command-F"),
5184
+ exec: function(editor) {
5185
+ var needle = prompt("Find:", editor.getCopyText());
5186
+ editor.find(needle);
5187
+ },
5188
+ readOnly: true
5189
+ }, {
5190
+ name: "overwrite",
5191
+ bindKey: bindKey("Insert", "Insert"),
5192
+ exec: function(editor) { editor.toggleOverwrite(); },
5193
+ readOnly: true
5194
+ }, {
5195
+ name: "selecttostart",
5196
+ bindKey: bindKey("Ctrl-Shift-Home|Alt-Shift-Up", "Command-Shift-Up"),
5197
+ exec: function(editor) { editor.getSelection().selectFileStart(); },
5198
+ readOnly: true
5199
+ }, {
5200
+ name: "gotostart",
5201
+ bindKey: bindKey("Ctrl-Home|Ctrl-Up", "Command-Home|Command-Up"),
5202
+ exec: function(editor) { editor.navigateFileStart(); },
5203
+ readOnly: true
5204
+ }, {
5205
+ name: "selectup",
5206
+ bindKey: bindKey("Shift-Up", "Shift-Up"),
5207
+ exec: function(editor) { editor.getSelection().selectUp(); },
5208
+ readOnly: true
5209
+ }, {
5210
+ name: "golineup",
5211
+ bindKey: bindKey("Up", "Up|Ctrl-P"),
5212
+ exec: function(editor, args) { editor.navigateUp(args.times); },
5213
+ readOnly: true
5214
+ }, {
5215
+ name: "selecttoend",
5216
+ bindKey: bindKey("Ctrl-Shift-End|Alt-Shift-Down", "Command-Shift-Down"),
5217
+ exec: function(editor) { editor.getSelection().selectFileEnd(); },
5218
+ readOnly: true
5219
+ }, {
5220
+ name: "gotoend",
5221
+ bindKey: bindKey("Ctrl-End|Ctrl-Down", "Command-End|Command-Down"),
5222
+ exec: function(editor) { editor.navigateFileEnd(); },
5223
+ readOnly: true
5224
+ }, {
5225
+ name: "selectdown",
5226
+ bindKey: bindKey("Shift-Down", "Shift-Down"),
5227
+ exec: function(editor) { editor.getSelection().selectDown(); },
5228
+ readOnly: true
5229
+ }, {
5230
+ name: "golinedown",
5231
+ bindKey: bindKey("Down", "Down|Ctrl-N"),
5232
+ exec: function(editor, args) { editor.navigateDown(args.times); },
5233
+ readOnly: true
5234
+ }, {
5235
+ name: "selectwordleft",
5236
+ bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"),
5237
+ exec: function(editor) { editor.getSelection().selectWordLeft(); },
5238
+ readOnly: true
5239
+ }, {
5240
+ name: "gotowordleft",
5241
+ bindKey: bindKey("Ctrl-Left", "Option-Left"),
5242
+ exec: function(editor) { editor.navigateWordLeft(); },
5243
+ readOnly: true
5244
+ }, {
5245
+ name: "selecttolinestart",
5246
+ bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"),
5247
+ exec: function(editor) { editor.getSelection().selectLineStart(); },
5248
+ readOnly: true
5249
+ }, {
5250
+ name: "gotolinestart",
5251
+ bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"),
5252
+ exec: function(editor) { editor.navigateLineStart(); },
5253
+ readOnly: true
5254
+ }, {
5255
+ name: "selectleft",
5256
+ bindKey: bindKey("Shift-Left", "Shift-Left"),
5257
+ exec: function(editor) { editor.getSelection().selectLeft(); },
5258
+ readOnly: true
5259
+ }, {
5260
+ name: "gotoleft",
5261
+ bindKey: bindKey("Left", "Left|Ctrl-B"),
5262
+ exec: function(editor, args) { editor.navigateLeft(args.times); },
5263
+ readOnly: true
5264
+ }, {
5265
+ name: "selectwordright",
5266
+ bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"),
5267
+ exec: function(editor) { editor.getSelection().selectWordRight(); },
5268
+ readOnly: true
5269
+ }, {
5270
+ name: "gotowordright",
5271
+ bindKey: bindKey("Ctrl-Right", "Option-Right"),
5272
+ exec: function(editor) { editor.navigateWordRight(); },
5273
+ readOnly: true
5274
+ }, {
5275
+ name: "selecttolineend",
5276
+ bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"),
5277
+ exec: function(editor) { editor.getSelection().selectLineEnd(); },
5278
+ readOnly: true
5279
+ }, {
5280
+ name: "gotolineend",
5281
+ bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"),
5282
+ exec: function(editor) { editor.navigateLineEnd(); },
5283
+ readOnly: true
5284
+ }, {
5285
+ name: "selectright",
5286
+ bindKey: bindKey("Shift-Right", "Shift-Right"),
5287
+ exec: function(editor) { editor.getSelection().selectRight(); },
5288
+ readOnly: true
5289
+ }, {
5290
+ name: "gotoright",
5291
+ bindKey: bindKey("Right", "Right|Ctrl-F"),
5292
+ exec: function(editor, args) { editor.navigateRight(args.times); },
5293
+ readOnly: true
5294
+ }, {
5295
+ name: "selectpagedown",
5296
+ bindKey: bindKey("Shift-PageDown", "Shift-PageDown"),
5297
+ exec: function(editor) { editor.selectPageDown(); },
5298
+ readOnly: true
5299
+ }, {
5300
+ name: "pagedown",
5301
+ bindKey: bindKey(null, "PageDown"),
5302
+ exec: function(editor) { editor.scrollPageDown(); },
5303
+ readOnly: true
5304
+ }, {
5305
+ name: "gotopagedown",
5306
+ bindKey: bindKey("PageDown", "Option-PageDown|Ctrl-V"),
5307
+ exec: function(editor) { editor.gotoPageDown(); },
5308
+ readOnly: true
5309
+ }, {
5310
+ name: "selectpageup",
5311
+ bindKey: bindKey("Shift-PageUp", "Shift-PageUp"),
5312
+ exec: function(editor) { editor.selectPageUp(); },
5313
+ readOnly: true
5314
+ }, {
5315
+ name: "pageup",
5316
+ bindKey: bindKey(null, "PageUp"),
5317
+ exec: function(editor) { editor.scrollPageUp(); },
5318
+ readOnly: true
5319
+ }, {
5320
+ name: "gotopageup",
5321
+ bindKey: bindKey("PageUp", "Option-PageUp"),
5322
+ exec: function(editor) { editor.gotoPageUp(); },
5323
+ readOnly: true
5324
+ }, {
5325
+ name: "selectlinestart",
5326
+ bindKey: bindKey("Shift-Home", "Shift-Home"),
5327
+ exec: function(editor) { editor.getSelection().selectLineStart(); },
5328
+ readOnly: true
5329
+ }, {
5330
+ name: "selectlineend",
5331
+ bindKey: bindKey("Shift-End", "Shift-End"),
5332
+ exec: function(editor) { editor.getSelection().selectLineEnd(); },
5333
+ readOnly: true
5334
+ }, {
5335
+ name: "togglerecording",
5336
+ bindKey: bindKey("Ctrl-Alt-E", "Command-Option-E"),
5337
+ exec: function(editor) { editor.commands.toggleRecording(); },
5338
+ readOnly: true
5339
+ }, {
5340
+ name: "replaymacro",
5341
+ bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"),
5342
+ exec: function(editor) { editor.commands.replay(editor); },
5343
+ readOnly: true
5344
+ }, {
5345
+ name: "jumptomatching",
5346
+ bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
5347
+ exec: function(editor) { editor.jumpToMatching(); },
5348
+ readOnly: true
5349
+ },
5350
+
5351
+ // commands disabled in readOnly mode
5352
+ {
5353
+ name: "removeline",
5354
+ bindKey: bindKey("Ctrl-D", "Command-D"),
5355
+ exec: function(editor) { editor.removeLines(); }
5356
+ }, {
5357
+ name: "togglecomment",
5358
+ bindKey: bindKey("Ctrl-7", "Command-7"),
5359
+ exec: function(editor) { editor.toggleCommentLines(); }
5360
+ }, {
5361
+ name: "replace",
5362
+ bindKey: bindKey("Ctrl-R", "Command-Option-F"),
5363
+ exec: function(editor) {
5364
+ var needle = prompt("Find:", editor.getCopyText());
5365
+ if (!needle)
5366
+ return;
5367
+ var replacement = prompt("Replacement:");
5368
+ if (!replacement)
5369
+ return;
5370
+ editor.replace(replacement, {needle: needle});
5371
+ }
5372
+ }, {
5373
+ name: "replaceall",
5374
+ bindKey: bindKey("Ctrl-Shift-R", "Command-Shift-Option-F"),
5375
+ exec: function(editor) {
5376
+ var needle = prompt("Find:");
5377
+ if (!needle)
5378
+ return;
5379
+ var replacement = prompt("Replacement:");
5380
+ if (!replacement)
5381
+ return;
5382
+ editor.replaceAll(replacement, {needle: needle});
5383
+ }
5384
+ }, {
5385
+ name: "undo",
5386
+ bindKey: bindKey("Ctrl-Z", "Command-Z"),
5387
+ exec: function(editor) { editor.undo(); }
5388
+ }, {
5389
+ name: "redo",
5390
+ bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"),
5391
+ exec: function(editor) { editor.redo(); }
5392
+ }, {
5393
+ name: "copylinesup",
5394
+ bindKey: bindKey("Ctrl-Alt-Up", "Command-Option-Up"),
5395
+ exec: function(editor) { editor.copyLinesUp(); }
5396
+ }, {
5397
+ name: "movelinesup",
5398
+ bindKey: bindKey("Alt-Up", "Option-Up"),
5399
+ exec: function(editor) { editor.moveLinesUp(); }
5400
+ }, {
5401
+ name: "copylinesdown",
5402
+ bindKey: bindKey("Ctrl-Alt-Down", "Command-Option-Down"),
5403
+ exec: function(editor) { editor.copyLinesDown(); }
5404
+ }, {
5405
+ name: "movelinesdown",
5406
+ bindKey: bindKey("Alt-Down", "Option-Down"),
5407
+ exec: function(editor) { editor.moveLinesDown(); }
5408
+ }, {
5409
+ name: "del",
5410
+ bindKey: bindKey("Delete", "Delete|Ctrl-D"),
5411
+ exec: function(editor) { editor.remove("right"); }
5412
+ }, {
5413
+ name: "backspace",
5414
+ bindKey: bindKey(
5415
+ "Command-Backspace|Option-Backspace|Shift-Backspace|Backspace",
5416
+ "Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H"
5417
+ ),
5418
+ exec: function(editor) { editor.remove("left"); }
5419
+ }, {
5420
+ name: "removetolinestart",
5421
+ bindKey: bindKey("Alt-Backspace", "Command-Backspace"),
5422
+ exec: function(editor) { editor.removeToLineStart(); }
5423
+ }, {
5424
+ name: "removetolineend",
5425
+ bindKey: bindKey("Alt-Delete", "Ctrl-K"),
5426
+ exec: function(editor) { editor.removeToLineEnd(); }
5427
+ }, {
5428
+ name: "removewordleft",
5429
+ bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"),
5430
+ exec: function(editor) { editor.removeWordLeft(); }
5431
+ }, {
5432
+ name: "removewordright",
5433
+ bindKey: bindKey("Ctrl-Delete", "Alt-Delete"),
5434
+ exec: function(editor) { editor.removeWordRight(); }
5435
+ }, {
5436
+ name: "outdent",
5437
+ bindKey: bindKey("Shift-Tab", "Shift-Tab"),
5438
+ exec: function(editor) { editor.blockOutdent(); }
5439
+ }, {
5440
+ name: "indent",
5441
+ bindKey: bindKey("Tab", "Tab"),
5442
+ exec: function(editor) { editor.indent(); }
5443
+ }, {
5444
+ name: "insertstring",
5445
+ exec: function(editor, str) { editor.insert(str); }
5446
+ }, {
5447
+ name: "inserttext",
5448
+ exec: function(editor, args) {
5449
+ editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
5450
+ }
5451
+ }, {
5452
+ name: "splitline",
5453
+ bindKey: bindKey(null, "Ctrl-O"),
5454
+ exec: function(editor) { editor.splitLine(); }
5455
+ }, {
5456
+ name: "transposeletters",
5457
+ bindKey: bindKey("Ctrl-T", "Ctrl-T"),
5458
+ exec: function(editor) { editor.transposeLetters(); }
5459
+ }, {
5460
+ name: "touppercase",
5461
+ bindKey: bindKey("Ctrl-U", "Ctrl-U"),
5462
+ exec: function(editor) { editor.toUpperCase(); }
5463
+ }, {
5464
+ name: "tolowercase",
5465
+ bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"),
5466
+ exec: function(editor) { editor.toLowerCase(); }
5467
+ }];
5468
+
5469
+ });
5470
+ /* vim:ts=4:sts=4:sw=4:
5471
+ * ***** BEGIN LICENSE BLOCK *****
5472
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5473
+ *
5474
+ * The contents of this file are subject to the Mozilla Public License Version
5475
+ * 1.1 (the "License"); you may not use this file except in compliance with
5476
+ * the License. You may obtain a copy of the License at
5477
+ * http://www.mozilla.org/MPL/
5478
+ *
5479
+ * Software distributed under the License is distributed on an "AS IS" basis,
5480
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
5481
+ * for the specific language governing rights and limitations under the
5482
+ * License.
5483
+ *
5484
+ * The Original Code is Ajax.org Code Editor (ACE).
5485
+ *
5486
+ * The Initial Developer of the Original Code is
5487
+ * Ajax.org B.V.
5488
+ * Portions created by the Initial Developer are Copyright (C) 2010
5489
+ * the Initial Developer. All Rights Reserved.
5490
+ *
5491
+ * Contributor(s):
5492
+ * Fabian Jakobs <fabian AT ajax DOT org>
5493
+ * Mihai Sucan <mihai DOT sucan AT gmail DOT com>
5494
+ * Julian Viereck <julian DOT viereck AT gmail DOT com>
5495
+ *
5496
+ * Alternatively, the contents of this file may be used under the terms of
5497
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
5498
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
5499
+ * in which case the provisions of the GPL or the LGPL are applicable instead
5500
+ * of those above. If you wish to allow use of your version of this file only
5501
+ * under the terms of either the GPL or the LGPL, and not to allow others to
5502
+ * use your version of this file under the terms of the MPL, indicate your
5503
+ * decision by deleting the provisions above and replace them with the notice
5504
+ * and other provisions required by the GPL or the LGPL. If you do not delete
5505
+ * the provisions above, a recipient may use your version of this file under
5506
+ * the terms of any one of the MPL, the GPL or the LGPL.
5507
+ *
5508
+ * ***** END LICENSE BLOCK ***** */
5509
+
5510
+ ace.define('ace/edit_session', ['require', 'exports', 'module' , 'ace/config', 'ace/lib/oop', 'ace/lib/lang', 'ace/lib/net', 'ace/lib/event_emitter', 'ace/selection', 'ace/mode/text', 'ace/range', 'ace/document', 'ace/background_tokenizer', 'ace/edit_session/folding', 'ace/edit_session/bracket_match'], function(require, exports, module) {
5511
+ "use strict";
5512
+
5513
+ var config = require("./config");
5514
+ var oop = require("./lib/oop");
5515
+ var lang = require("./lib/lang");
5516
+ var net = require("./lib/net");
5517
+ var EventEmitter = require("./lib/event_emitter").EventEmitter;
5518
+ var Selection = require("./selection").Selection;
5519
+ var TextMode = require("./mode/text").Mode;
5520
+ var Range = require("./range").Range;
5521
+ var Document = require("./document").Document;
5522
+ var BackgroundTokenizer = require("./background_tokenizer").BackgroundTokenizer;
5523
+
5524
+ var EditSession = function(text, mode) {
5525
+ this.$modified = true;
5526
+ this.$breakpoints = [];
5527
+ this.$frontMarkers = {};
5528
+ this.$backMarkers = {};
5529
+ this.$markerId = 1;
5530
+ this.$rowCache = [];
5531
+ this.$wrapData = [];
5532
+ this.$foldData = [];
5533
+ this.$undoSelect = true;
5534
+ this.$foldData.toString = function() {
5535
+ var str = "";
5536
+ this.forEach(function(foldLine) {
5537
+ str += "\n" + foldLine.toString();
5538
+ });
5539
+ return str;
5540
+ }
5541
+
5542
+ if (text instanceof Document) {
5543
+ this.setDocument(text);
5544
+ } else {
5545
+ this.setDocument(new Document(text));
5546
+ }
5547
+
5548
+ this.selection = new Selection(this);
5549
+ if (mode)
5550
+ this.setMode(mode);
5551
+ else
5552
+ this.setMode(new TextMode());
5553
+ };
5554
+
5555
+
5556
+ (function() {
5557
+
5558
+ oop.implement(this, EventEmitter);
5559
+
5560
+ this.setDocument = function(doc) {
5561
+ if (this.doc)
5562
+ throw new Error("Document is already set");
5563
+
5564
+ this.doc = doc;
5565
+ doc.on("change", this.onChange.bind(this));
5566
+ this.on("changeFold", this.onChangeFold.bind(this));
5567
+
5568
+ if (this.bgTokenizer) {
5569
+ this.bgTokenizer.setDocument(this.getDocument());
5570
+ this.bgTokenizer.start(0);
5571
+ }
5572
+ };
5573
+
5574
+ this.getDocument = function() {
5575
+ return this.doc;
5576
+ };
5577
+
5578
+ this.$resetRowCache = function(row) {
5579
+ if (row == 0) {
5580
+ this.$rowCache = [];
5581
+ return;
5582
+ }
5583
+ var rowCache = this.$rowCache;
5584
+ for (var i = 0; i < rowCache.length; i++) {
5585
+ if (rowCache[i].docRow >= row) {
5586
+ rowCache.splice(i, rowCache.length);
5587
+ return;
5588
+ }
5589
+ }
5590
+ };
5591
+
5592
+ this.onChangeFold = function(e) {
5593
+ var fold = e.data;
5594
+ this.$resetRowCache(fold.start.row);
5595
+ };
5596
+
5597
+ this.onChange = function(e) {
5598
+ var delta = e.data;
5599
+ this.$modified = true;
5600
+
5601
+ this.$resetRowCache(delta.range.start.row);
5602
+
5603
+ var removedFolds = this.$updateInternalDataOnChange(e);
5604
+ if (!this.$fromUndo && this.$undoManager && !delta.ignore) {
5605
+ this.$deltasDoc.push(delta);
5606
+ if (removedFolds && removedFolds.length != 0) {
5607
+ this.$deltasFold.push({
5608
+ action: "removeFolds",
5609
+ folds: removedFolds
5610
+ });
5611
+ }
5612
+
5613
+ this.$informUndoManager.schedule();
5614
+ }
5615
+
5616
+ this.bgTokenizer.start(delta.range.start.row);
5617
+ this._emit("change", e);
5618
+ };
5619
+
5620
+ this.setValue = function(text) {
5621
+ this.doc.setValue(text);
5622
+ this.selection.moveCursorTo(0, 0);
5623
+ this.selection.clearSelection();
5624
+
5625
+ this.$resetRowCache(0);
5626
+ this.$deltas = [];
5627
+ this.$deltasDoc = [];
5628
+ this.$deltasFold = [];
5629
+ this.getUndoManager().reset();
5630
+ };
5631
+
5632
+ this.getValue =
5633
+ this.toString = function() {
5634
+ return this.doc.getValue();
5635
+ };
5636
+
5637
+ this.getSelection = function() {
5638
+ return this.selection;
5639
+ };
5640
+
5641
+ this.getState = function(row) {
5642
+ return this.bgTokenizer.getState(row);
5643
+ };
5644
+
5645
+ this.getTokens = function(firstRow, lastRow) {
5646
+ return this.bgTokenizer.getTokens(firstRow, lastRow);
5647
+ };
5648
+
5649
+ this.getTokenAt = function(row, column) {
5650
+ var tokens = this.bgTokenizer.getTokens(row, row)[0].tokens;
5651
+ var token, c = 0;
5652
+ if (column == null) {
5653
+ i = tokens.length - 1;
5654
+ c = this.getLine(row).length;
5655
+ } else {
5656
+ for (var i = 0; i < tokens.length; i++) {
5657
+ c += tokens[i].value.length;
5658
+ if (c >= column)
5659
+ break;
5660
+ }
5661
+ }
5662
+ token = tokens[i];
5663
+ if (!token)
5664
+ return null;
5665
+ token.index = i;
5666
+ token.start = c - token.value.length;
5667
+ return token;
5668
+ };
5669
+
5670
+ this.setUndoManager = function(undoManager) {
5671
+ this.$undoManager = undoManager;
5672
+ this.$resetRowCache(0);
5673
+ this.$deltas = [];
5674
+ this.$deltasDoc = [];
5675
+ this.$deltasFold = [];
5676
+
5677
+ if (this.$informUndoManager)
5678
+ this.$informUndoManager.cancel();
5679
+
5680
+ if (undoManager) {
5681
+ var self = this;
5682
+ this.$syncInformUndoManager = function() {
5683
+ self.$informUndoManager.cancel();
5684
+
5685
+ if (self.$deltasFold.length) {
5686
+ self.$deltas.push({
5687
+ group: "fold",
5688
+ deltas: self.$deltasFold
5689
+ });
5690
+ self.$deltasFold = [];
5691
+ }
5692
+
5693
+ if (self.$deltasDoc.length) {
5694
+ self.$deltas.push({
5695
+ group: "doc",
5696
+ deltas: self.$deltasDoc
5697
+ });
5698
+ self.$deltasDoc = [];
5699
+ }
5700
+
5701
+ if (self.$deltas.length > 0) {
5702
+ undoManager.execute({
5703
+ action: "aceupdate",
5704
+ args: [self.$deltas, self]
5705
+ });
5706
+ }
5707
+
5708
+ self.$deltas = [];
5709
+ }
5710
+ this.$informUndoManager =
5711
+ lang.deferredCall(this.$syncInformUndoManager);
5712
+ }
5713
+ };
5714
+
5715
+ this.$defaultUndoManager = {
5716
+ undo: function() {},
5717
+ redo: function() {},
5718
+ reset: function() {}
5719
+ };
5720
+
5721
+ this.getUndoManager = function() {
5722
+ return this.$undoManager || this.$defaultUndoManager;
5723
+ },
5724
+
5725
+ this.getTabString = function() {
5726
+ if (this.getUseSoftTabs()) {
5727
+ return lang.stringRepeat(" ", this.getTabSize());
5728
+ } else {
5729
+ return "\t";
5730
+ }
5731
+ };
5732
+
5733
+ this.$useSoftTabs = true;
5734
+ this.setUseSoftTabs = function(useSoftTabs) {
5735
+ if (this.$useSoftTabs === useSoftTabs) return;
5736
+
5737
+ this.$useSoftTabs = useSoftTabs;
5738
+ };
5739
+
5740
+ this.getUseSoftTabs = function() {
5741
+ return this.$useSoftTabs;
5742
+ };
5743
+
5744
+ this.$tabSize = 4;
5745
+ this.setTabSize = function(tabSize) {
5746
+ if (isNaN(tabSize) || this.$tabSize === tabSize) return;
5747
+
5748
+ this.$modified = true;
5749
+ this.$tabSize = tabSize;
5750
+ this._emit("changeTabSize");
5751
+ };
5752
+
5753
+ this.getTabSize = function() {
5754
+ return this.$tabSize;
5755
+ };
5756
+
5757
+ this.isTabStop = function(position) {
5758
+ return this.$useSoftTabs && (position.column % this.$tabSize == 0);
5759
+ };
5760
+
5761
+ this.$overwrite = false;
5762
+ this.setOverwrite = function(overwrite) {
5763
+ if (this.$overwrite == overwrite) return;
5764
+
5765
+ this.$overwrite = overwrite;
5766
+ this._emit("changeOverwrite");
5767
+ };
5768
+
5769
+ this.getOverwrite = function() {
5770
+ return this.$overwrite;
5771
+ };
5772
+
5773
+ this.toggleOverwrite = function() {
5774
+ this.setOverwrite(!this.$overwrite);
5775
+ };
5776
+
5777
+ this.getBreakpoints = function() {
5778
+ return this.$breakpoints;
5779
+ };
5780
+
5781
+ this.setBreakpoints = function(rows) {
5782
+ this.$breakpoints = [];
5783
+ for (var i=0; i<rows.length; i++) {
5784
+ this.$breakpoints[rows[i]] = true;
5785
+ }
5786
+ this._emit("changeBreakpoint", {});
5787
+ };
5788
+
5789
+ this.clearBreakpoints = function() {
5790
+ this.$breakpoints = [];
5791
+ this._emit("changeBreakpoint", {});
5792
+ };
5793
+
5794
+ this.setBreakpoint = function(row) {
5795
+ this.$breakpoints[row] = true;
5796
+ this._emit("changeBreakpoint", {});
5797
+ };
5798
+
5799
+ this.clearBreakpoint = function(row) {
5800
+ delete this.$breakpoints[row];
5801
+ this._emit("changeBreakpoint", {});
5802
+ };
5803
+
5804
+ this.getBreakpoints = function() {
5805
+ return this.$breakpoints;
5806
+ };
5807
+
5808
+ this.addMarker = function(range, clazz, type, inFront) {
5809
+ var id = this.$markerId++;
5810
+
5811
+ var marker = {
5812
+ range : range,
5813
+ type : type || "line",
5814
+ renderer: typeof type == "function" ? type : null,
5815
+ clazz : clazz,
5816
+ inFront: !!inFront
5817
+ }
5818
+
5819
+ if (inFront) {
5820
+ this.$frontMarkers[id] = marker;
5821
+ this._emit("changeFrontMarker")
5822
+ } else {
5823
+ this.$backMarkers[id] = marker;
5824
+ this._emit("changeBackMarker")
5825
+ }
5826
+
5827
+ return id;
5828
+ };
5829
+
5830
+ this.removeMarker = function(markerId) {
5831
+ var marker = this.$frontMarkers[markerId] || this.$backMarkers[markerId];
5832
+ if (!marker)
5833
+ return;
5834
+
5835
+ var markers = marker.inFront ? this.$frontMarkers : this.$backMarkers;
5836
+ if (marker) {
5837
+ delete (markers[markerId]);
5838
+ this._emit(marker.inFront ? "changeFrontMarker" : "changeBackMarker");
5839
+ }
5840
+ };
5841
+
5842
+ this.getMarkers = function(inFront) {
5843
+ return inFront ? this.$frontMarkers : this.$backMarkers;
5844
+ };
5845
+
5846
+ /**
5847
+ * Error:
5848
+ * {
5849
+ * row: 12,
5850
+ * column: 2, //can be undefined
5851
+ * text: "Missing argument",
5852
+ * type: "error" // or "warning" or "info"
5853
+ * }
5854
+ */
5855
+ this.setAnnotations = function(annotations) {
5856
+ this.$annotations = {};
5857
+ for (var i=0; i<annotations.length; i++) {
5858
+ var annotation = annotations[i];
5859
+ var row = annotation.row;
5860
+ if (this.$annotations[row])
5861
+ this.$annotations[row].push(annotation);
5862
+ else
5863
+ this.$annotations[row] = [annotation];
5864
+ }
5865
+ this._emit("changeAnnotation", {});
5866
+ };
5867
+
5868
+ this.getAnnotations = function() {
5869
+ return this.$annotations || {};
5870
+ };
5871
+
5872
+ this.clearAnnotations = function() {
5873
+ this.$annotations = {};
5874
+ this._emit("changeAnnotation", {});
5875
+ };
5876
+
5877
+ this.$detectNewLine = function(text) {
5878
+ var match = text.match(/^.*?(\r?\n)/m);
5879
+ if (match) {
5880
+ this.$autoNewLine = match[1];
5881
+ } else {
5882
+ this.$autoNewLine = "\n";
5883
+ }
5884
+ };
5885
+
5886
+ this.getWordRange = function(row, column) {
5887
+ var line = this.getLine(row);
5888
+
5889
+ var inToken = false;
5890
+ if (column > 0) {
5891
+ inToken = !!line.charAt(column - 1).match(this.tokenRe);
5892
+ }
5893
+
5894
+ if (!inToken) {
5895
+ inToken = !!line.charAt(column).match(this.tokenRe);
5896
+ }
5897
+
5898
+ var re = inToken ? this.tokenRe : this.nonTokenRe;
5899
+
5900
+ var start = column;
5901
+ if (start > 0) {
5902
+ do {
5903
+ start--;
5904
+ }
5905
+ while (start >= 0 && line.charAt(start).match(re));
5906
+ start++;
5907
+ }
5908
+
5909
+ var end = column;
5910
+ while (end < line.length && line.charAt(end).match(re)) {
5911
+ end++;
5912
+ }
5913
+
5914
+ return new Range(row, start, row, end);
5915
+ };
5916
+
5917
+ // Gets the range of a word including its right whitespace
5918
+ this.getAWordRange = function(row, column) {
5919
+ var wordRange = this.getWordRange(row, column);
5920
+ var line = this.getLine(wordRange.end.row);
5921
+
5922
+ while (line.charAt(wordRange.end.column).match(/[ \t]/)) {
5923
+ wordRange.end.column += 1;
5924
+ }
5925
+ return wordRange;
5926
+ };
5927
+
5928
+ this.setNewLineMode = function(newLineMode) {
5929
+ this.doc.setNewLineMode(newLineMode);
5930
+ };
5931
+
5932
+ this.getNewLineMode = function() {
5933
+ return this.doc.getNewLineMode();
5934
+ };
5935
+
5936
+ this.$useWorker = true;
5937
+ this.setUseWorker = function(useWorker) {
5938
+ if (this.$useWorker == useWorker)
5939
+ return;
5940
+
5941
+ this.$useWorker = useWorker;
5942
+
5943
+ this.$stopWorker();
5944
+ if (useWorker)
5945
+ this.$startWorker();
5946
+ };
5947
+
5948
+ this.getUseWorker = function() {
5949
+ return this.$useWorker;
5950
+ };
5951
+
5952
+ this.onReloadTokenizer = function(e) {
5953
+ var rows = e.data;
5954
+ this.bgTokenizer.start(rows.first);
5955
+ this._emit("tokenizerUpdate", e);
5956
+ };
5957
+
5958
+ this.$modes = {};
5959
+ this._loadMode = function(mode, callback) {
5960
+ if (this.$modes[mode])
5961
+ return callback(this.$modes[mode]);
5962
+
5963
+ var _self = this;
5964
+ var module;
5965
+ try {
5966
+ module = require(mode);
5967
+ } catch (e) {};
5968
+ if (module)
5969
+ return done(module);
5970
+
5971
+ fetch(function() {
5972
+ require([mode], done);
5973
+ });
5974
+
5975
+ function done(module) {
5976
+ if (_self.$modes[mode])
5977
+ return callback(_self.$modes[mode]);
5978
+
5979
+ _self.$modes[mode] = new module.Mode();
5980
+ _self._emit("loadmode", {
5981
+ name: mode,
5982
+ mode: _self.$modes[mode]
5983
+ });
5984
+ callback(_self.$modes[mode]);
5985
+ }
5986
+
5987
+ function fetch(callback) {
5988
+ if (!config.get("packaged"))
5989
+ return callback();
5990
+
5991
+ var base = mode.split("/").pop();
5992
+ var filename = config.get("modePath") + "/mode-" + base + config.get("suffix");
5993
+ net.loadScript(filename, callback);
5994
+ }
5995
+ };
5996
+
5997
+ this.$mode = null;
5998
+ this.$origMode = null;
5999
+ this.setMode = function(mode) {
6000
+ this.$origMode = mode;
6001
+
6002
+ // load on demand
6003
+ if (typeof mode === "string") {
6004
+ var _self = this;
6005
+ this._loadMode(mode, function(module) {
6006
+ if (_self.$origMode !== mode)
6007
+ return;
6008
+
6009
+ _self.setMode(module);
6010
+ });
6011
+ return;
6012
+ }
6013
+
6014
+ if (this.$mode === mode) return;
6015
+ this.$mode = mode;
6016
+
6017
+
6018
+ this.$stopWorker();
6019
+
6020
+ if (this.$useWorker)
6021
+ this.$startWorker();
6022
+
6023
+ var tokenizer = mode.getTokenizer();
6024
+
6025
+ if(tokenizer.addEventListener !== undefined) {
6026
+ var onReloadTokenizer = this.onReloadTokenizer.bind(this);
6027
+ tokenizer.addEventListener("update", onReloadTokenizer);
6028
+ }
6029
+
6030
+ if (!this.bgTokenizer) {
6031
+ this.bgTokenizer = new BackgroundTokenizer(tokenizer);
6032
+ var _self = this;
6033
+ this.bgTokenizer.addEventListener("update", function(e) {
6034
+ _self._emit("tokenizerUpdate", e);
6035
+ });
6036
+ } else {
6037
+ this.bgTokenizer.setTokenizer(tokenizer);
6038
+ }
6039
+
6040
+ this.bgTokenizer.setDocument(this.getDocument());
6041
+ this.bgTokenizer.start(0);
6042
+
6043
+ this.tokenRe = mode.tokenRe;
6044
+ this.nonTokenRe = mode.nonTokenRe;
6045
+
6046
+ this.$setFolding(mode.foldingRules);
6047
+
6048
+ this._emit("changeMode");
6049
+ };
6050
+
6051
+ this.$stopWorker = function() {
6052
+ if (this.$worker)
6053
+ this.$worker.terminate();
6054
+
6055
+ this.$worker = null;
6056
+ };
6057
+
6058
+ this.$startWorker = function() {
6059
+ if (typeof Worker !== "undefined" && !require.noWorker) {
6060
+ try {
6061
+ this.$worker = this.$mode.createWorker(this);
6062
+ } catch (e) {
6063
+ console.log("Could not load worker");
6064
+ console.log(e);
6065
+ this.$worker = null;
6066
+ }
6067
+ }
6068
+ else
6069
+ this.$worker = null;
6070
+ };
6071
+
6072
+ this.getMode = function() {
6073
+ return this.$mode;
6074
+ };
6075
+
6076
+ this.$scrollTop = 0;
6077
+ this.setScrollTop = function(scrollTop) {
6078
+ scrollTop = Math.round(Math.max(0, scrollTop));
6079
+ if (this.$scrollTop === scrollTop)
6080
+ return;
6081
+
6082
+ this.$scrollTop = scrollTop;
6083
+ this._emit("changeScrollTop", scrollTop);
6084
+ };
6085
+
6086
+ this.getScrollTop = function() {
6087
+ return this.$scrollTop;
6088
+ };
6089
+
6090
+ this.$scrollLeft = 0;
6091
+ this.setScrollLeft = function(scrollLeft) {
6092
+ scrollLeft = Math.round(Math.max(0, scrollLeft));
6093
+ if (this.$scrollLeft === scrollLeft)
6094
+ return;
6095
+
6096
+ this.$scrollLeft = scrollLeft;
6097
+ this._emit("changeScrollLeft", scrollLeft);
6098
+ };
6099
+
6100
+ this.getScrollLeft = function() {
6101
+ return this.$scrollLeft;
6102
+ };
6103
+
6104
+ this.getWidth = function() {
6105
+ this.$computeWidth();
6106
+ return this.width;
6107
+ };
6108
+
6109
+ this.getScreenWidth = function() {
6110
+ this.$computeWidth();
6111
+ return this.screenWidth;
6112
+ };
6113
+
6114
+ this.$computeWidth = function(force) {
6115
+ if (this.$modified || force) {
6116
+ this.$modified = false;
6117
+
6118
+ var lines = this.doc.getAllLines();
6119
+ var longestLine = 0;
6120
+ var longestScreenLine = 0;
6121
+
6122
+ for ( var i = 0; i < lines.length; i++) {
6123
+ var foldLine = this.getFoldLine(i),
6124
+ line, len;
6125
+
6126
+ line = lines[i];
6127
+ if (foldLine) {
6128
+ var end = foldLine.range.end;
6129
+ line = this.getFoldDisplayLine(foldLine);
6130
+ // Continue after the foldLine.end.row. All the lines in
6131
+ // between are folded.
6132
+ i = end.row;
6133
+ }
6134
+ len = line.length;
6135
+ longestLine = Math.max(longestLine, len);
6136
+ if (!this.$useWrapMode) {
6137
+ longestScreenLine = Math.max(
6138
+ longestScreenLine,
6139
+ this.$getStringScreenWidth(line)[0]
6140
+ );
6141
+ }
6142
+ }
6143
+ this.width = longestLine;
6144
+
6145
+ if (this.$useWrapMode) {
6146
+ this.screenWidth = this.$wrapLimit;
6147
+ } else {
6148
+ this.screenWidth = longestScreenLine;
6149
+ }
6150
+ }
6151
+ };
6152
+
6153
+ /**
6154
+ * Get a verbatim copy of the given line as it is in the document
6155
+ */
6156
+ this.getLine = function(row) {
6157
+ return this.doc.getLine(row);
6158
+ };
6159
+
6160
+ this.getLines = function(firstRow, lastRow) {
6161
+ return this.doc.getLines(firstRow, lastRow);
6162
+ };
6163
+
6164
+ this.getLength = function() {
6165
+ return this.doc.getLength();
6166
+ };
6167
+
6168
+ this.getTextRange = function(range) {
6169
+ return this.doc.getTextRange(range);
6170
+ };
6171
+
6172
+ this.insert = function(position, text) {
6173
+ return this.doc.insert(position, text);
6174
+ };
6175
+
6176
+ this.remove = function(range) {
6177
+ return this.doc.remove(range);
6178
+ };
6179
+
6180
+ this.undoChanges = function(deltas, dontSelect) {
6181
+ if (!deltas.length)
6182
+ return;
6183
+
6184
+ this.$fromUndo = true;
6185
+ var lastUndoRange = null;
6186
+ for (var i = deltas.length - 1; i != -1; i--) {
6187
+ var delta = deltas[i];
6188
+ if (delta.group == "doc") {
6189
+ this.doc.revertDeltas(delta.deltas);
6190
+ lastUndoRange =
6191
+ this.$getUndoSelection(delta.deltas, true, lastUndoRange);
6192
+ } else {
6193
+ delta.deltas.forEach(function(foldDelta) {
6194
+ this.addFolds(foldDelta.folds);
6195
+ }, this);
6196
+ }
6197
+ }
6198
+ this.$fromUndo = false;
6199
+ lastUndoRange &&
6200
+ this.$undoSelect &&
6201
+ !dontSelect &&
6202
+ this.selection.setSelectionRange(lastUndoRange);
6203
+ return lastUndoRange;
6204
+ };
6205
+
6206
+ this.redoChanges = function(deltas, dontSelect) {
6207
+ if (!deltas.length)
6208
+ return;
6209
+
6210
+ this.$fromUndo = true;
6211
+ var lastUndoRange = null;
6212
+ for (var i = 0; i < deltas.length; i++) {
6213
+ var delta = deltas[i];
6214
+ if (delta.group == "doc") {
6215
+ this.doc.applyDeltas(delta.deltas);
6216
+ lastUndoRange =
6217
+ this.$getUndoSelection(delta.deltas, false, lastUndoRange);
6218
+ }
6219
+ }
6220
+ this.$fromUndo = false;
6221
+ lastUndoRange &&
6222
+ this.$undoSelect &&
6223
+ !dontSelect &&
6224
+ this.selection.setSelectionRange(lastUndoRange);
6225
+ return lastUndoRange;
6226
+ };
6227
+
6228
+ this.setUndoSelect = function(enable) {
6229
+ this.$undoSelect = enable;
6230
+ };
6231
+
6232
+ this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
6233
+ function isInsert(delta) {
6234
+ var insert =
6235
+ delta.action == "insertText" || delta.action == "insertLines";
6236
+ return isUndo ? !insert : insert;
6237
+ }
6238
+
6239
+ var delta = deltas[0];
6240
+ var range, point;
6241
+ var lastDeltaIsInsert = false;
6242
+ if (isInsert(delta)) {
6243
+ range = delta.range.clone();
6244
+ lastDeltaIsInsert = true;
6245
+ } else {
6246
+ range = Range.fromPoints(delta.range.start, delta.range.start);
6247
+ lastDeltaIsInsert = false;
6248
+ }
6249
+
6250
+ for (var i = 1; i < deltas.length; i++) {
6251
+ delta = deltas[i];
6252
+ if (isInsert(delta)) {
6253
+ point = delta.range.start;
6254
+ if (range.compare(point.row, point.column) == -1) {
6255
+ range.setStart(delta.range.start);
6256
+ }
6257
+ point = delta.range.end;
6258
+ if (range.compare(point.row, point.column) == 1) {
6259
+ range.setEnd(delta.range.end);
6260
+ }
6261
+ lastDeltaIsInsert = true;
6262
+ } else {
6263
+ point = delta.range.start;
6264
+ if (range.compare(point.row, point.column) == -1) {
6265
+ range =
6266
+ Range.fromPoints(delta.range.start, delta.range.start);
6267
+ }
6268
+ lastDeltaIsInsert = false;
6269
+ }
6270
+ }
6271
+
6272
+ // Check if this range and the last undo range has something in common.
6273
+ // If true, merge the ranges.
6274
+ if (lastUndoRange != null) {
6275
+ var cmp = lastUndoRange.compareRange(range);
6276
+ if (cmp == 1) {
6277
+ range.setStart(lastUndoRange.start);
6278
+ } else if (cmp == -1) {
6279
+ range.setEnd(lastUndoRange.end);
6280
+ }
6281
+ }
6282
+
6283
+ return range;
6284
+ },
6285
+
6286
+ this.replace = function(range, text) {
6287
+ return this.doc.replace(range, text);
6288
+ };
6289
+
6290
+ /**
6291
+ * Move a range of text from the given range to the given position.
6292
+ *
6293
+ * @param fromRange {Range} The range of text you want moved within the
6294
+ * document.
6295
+ * @param toPosition {Object} The location (row and column) where you want
6296
+ * to move the text to.
6297
+ * @return {Range} The new range where the text was moved to.
6298
+ */
6299
+ this.moveText = function(fromRange, toPosition) {
6300
+ var text = this.getTextRange(fromRange);
6301
+ this.remove(fromRange);
6302
+
6303
+ var toRow = toPosition.row;
6304
+ var toColumn = toPosition.column;
6305
+
6306
+ // Make sure to update the insert location, when text is removed in
6307
+ // front of the chosen point of insertion.
6308
+ if (!fromRange.isMultiLine() && fromRange.start.row == toRow &&
6309
+ fromRange.end.column < toColumn)
6310
+ toColumn -= text.length;
6311
+
6312
+ if (fromRange.isMultiLine() && fromRange.end.row < toRow) {
6313
+ var lines = this.doc.$split(text);
6314
+ toRow -= lines.length - 1;
6315
+ }
6316
+
6317
+ var endRow = toRow + fromRange.end.row - fromRange.start.row;
6318
+ var endColumn = fromRange.isMultiLine() ?
6319
+ fromRange.end.column :
6320
+ toColumn + fromRange.end.column - fromRange.start.column;
6321
+
6322
+ var toRange = new Range(toRow, toColumn, endRow, endColumn);
6323
+
6324
+ this.insert(toRange.start, text);
6325
+
6326
+ return toRange;
6327
+ };
6328
+
6329
+ this.indentRows = function(startRow, endRow, indentString) {
6330
+ indentString = indentString.replace(/\t/g, this.getTabString());
6331
+ for (var row=startRow; row<=endRow; row++)
6332
+ this.insert({row: row, column:0}, indentString);
6333
+ };
6334
+
6335
+ this.outdentRows = function (range) {
6336
+ var rowRange = range.collapseRows();
6337
+ var deleteRange = new Range(0, 0, 0, 0);
6338
+ var size = this.getTabSize();
6339
+
6340
+ for (var i = rowRange.start.row; i <= rowRange.end.row; ++i) {
6341
+ var line = this.getLine(i);
6342
+
6343
+ deleteRange.start.row = i;
6344
+ deleteRange.end.row = i;
6345
+ for (var j = 0; j < size; ++j)
6346
+ if (line.charAt(j) != ' ')
6347
+ break;
6348
+ if (j < size && line.charAt(j) == '\t') {
6349
+ deleteRange.start.column = j;
6350
+ deleteRange.end.column = j + 1;
6351
+ } else {
6352
+ deleteRange.start.column = 0;
6353
+ deleteRange.end.column = j;
6354
+ }
6355
+ this.remove(deleteRange);
6356
+ }
6357
+ };
6358
+
6359
+ this.moveLinesUp = function(firstRow, lastRow) {
6360
+ if (firstRow <= 0) return 0;
6361
+
6362
+ var removed = this.doc.removeLines(firstRow, lastRow);
6363
+ this.doc.insertLines(firstRow - 1, removed);
6364
+ return -1;
6365
+ };
6366
+
6367
+ this.moveLinesDown = function(firstRow, lastRow) {
6368
+ if (lastRow >= this.doc.getLength()-1) return 0;
6369
+
6370
+ var removed = this.doc.removeLines(firstRow, lastRow);
6371
+ this.doc.insertLines(firstRow+1, removed);
6372
+ return 1;
6373
+ };
6374
+
6375
+ this.duplicateLines = function(firstRow, lastRow) {
6376
+ var firstRow = this.$clipRowToDocument(firstRow);
6377
+ var lastRow = this.$clipRowToDocument(lastRow);
6378
+
6379
+ var lines = this.getLines(firstRow, lastRow);
6380
+ this.doc.insertLines(firstRow, lines);
6381
+
6382
+ var addedRows = lastRow - firstRow + 1;
6383
+ return addedRows;
6384
+ };
6385
+
6386
+ this.$clipRowToDocument = function(row) {
6387
+ return Math.max(0, Math.min(row, this.doc.getLength()-1));
6388
+ };
6389
+
6390
+ this.$clipColumnToRow = function(row, column) {
6391
+ if (column < 0)
6392
+ return 0;
6393
+ return Math.min(this.doc.getLine(row).length, column);
6394
+ };
6395
+
6396
+ this.$clipPositionToDocument = function(row, column) {
6397
+ column = Math.max(0, column);
6398
+
6399
+ if (row < 0) {
6400
+ row = 0;
6401
+ column = 0;
6402
+ } else {
6403
+ var len = this.doc.getLength();
6404
+ if (row >= len) {
6405
+ row = len - 1;
6406
+ column = this.doc.getLine(len-1).length;
6407
+ } else {
6408
+ column = Math.min(this.doc.getLine(row).length, column);
6409
+ }
6410
+ }
6411
+
6412
+ return {
6413
+ row: row,
6414
+ column: column
6415
+ };
6416
+ };
6417
+
6418
+ this.$clipRangeToDocument = function(range) {
6419
+ if (range.start.row < 0) {
6420
+ range.start.row = 0;
6421
+ range.start.column = 0
6422
+ } else {
6423
+ range.start.column = this.$clipColumnToRow(
6424
+ range.start.row,
6425
+ range.start.column
6426
+ );
6427
+ }
6428
+
6429
+ var len = this.doc.getLength() - 1;
6430
+ if (range.end.row > len) {
6431
+ range.end.row = len;
6432
+ range.end.column = this.doc.getLine(len).length;
6433
+ } else {
6434
+ range.end.column = this.$clipColumnToRow(
6435
+ range.end.row,
6436
+ range.end.column
6437
+ );
6438
+ }
6439
+ return range;
6440
+ };
6441
+
6442
+ // WRAPMODE
6443
+ this.$wrapLimit = 80;
6444
+ this.$useWrapMode = false;
6445
+ this.$wrapLimitRange = {
6446
+ min : null,
6447
+ max : null
6448
+ };
6449
+
6450
+ this.setUseWrapMode = function(useWrapMode) {
6451
+ if (useWrapMode != this.$useWrapMode) {
6452
+ this.$useWrapMode = useWrapMode;
6453
+ this.$modified = true;
6454
+ this.$resetRowCache(0);
6455
+
6456
+ // If wrapMode is activaed, the wrapData array has to be initialized.
6457
+ if (useWrapMode) {
6458
+ var len = this.getLength();
6459
+ this.$wrapData = [];
6460
+ for (var i = 0; i < len; i++) {
6461
+ this.$wrapData.push([]);
6462
+ }
6463
+ this.$updateWrapData(0, len - 1);
6464
+ }
6465
+
6466
+ this._emit("changeWrapMode");
6467
+ }
6468
+ };
6469
+
6470
+ this.getUseWrapMode = function() {
6471
+ return this.$useWrapMode;
6472
+ };
6473
+
6474
+ // Allow the wrap limit to move freely between min and max. Either
6475
+ // parameter can be null to allow the wrap limit to be unconstrained
6476
+ // in that direction. Or set both parameters to the same number to pin
6477
+ // the limit to that value.
6478
+ this.setWrapLimitRange = function(min, max) {
6479
+ if (this.$wrapLimitRange.min !== min || this.$wrapLimitRange.max !== max) {
6480
+ this.$wrapLimitRange.min = min;
6481
+ this.$wrapLimitRange.max = max;
6482
+ this.$modified = true;
6483
+ // This will force a recalculation of the wrap limit
6484
+ this._emit("changeWrapMode");
6485
+ }
6486
+ };
6487
+
6488
+ // This should generally only be called by the renderer when a resize
6489
+ // is detected.
6490
+ this.adjustWrapLimit = function(desiredLimit) {
6491
+ var wrapLimit = this.$constrainWrapLimit(desiredLimit);
6492
+ if (wrapLimit != this.$wrapLimit && wrapLimit > 0) {
6493
+ this.$wrapLimit = wrapLimit;
6494
+ this.$modified = true;
6495
+ if (this.$useWrapMode) {
6496
+ this.$updateWrapData(0, this.getLength() - 1);
6497
+ this.$resetRowCache(0)
6498
+ this._emit("changeWrapLimit");
6499
+ }
6500
+ return true;
6501
+ }
6502
+ return false;
6503
+ };
6504
+
6505
+ this.$constrainWrapLimit = function(wrapLimit) {
6506
+ var min = this.$wrapLimitRange.min;
6507
+ if (min)
6508
+ wrapLimit = Math.max(min, wrapLimit);
6509
+
6510
+ var max = this.$wrapLimitRange.max;
6511
+ if (max)
6512
+ wrapLimit = Math.min(max, wrapLimit);
6513
+
6514
+ // What would a limit of 0 even mean?
6515
+ return Math.max(1, wrapLimit);
6516
+ };
6517
+
6518
+ this.getWrapLimit = function() {
6519
+ return this.$wrapLimit;
6520
+ };
6521
+
6522
+ this.getWrapLimitRange = function() {
6523
+ // Avoid unexpected mutation by returning a copy
6524
+ return {
6525
+ min : this.$wrapLimitRange.min,
6526
+ max : this.$wrapLimitRange.max
6527
+ };
6528
+ };
6529
+
6530
+ this.$updateInternalDataOnChange = function(e) {
6531
+ var useWrapMode = this.$useWrapMode;
6532
+ var len;
6533
+ var action = e.data.action;
6534
+ var firstRow = e.data.range.start.row;
6535
+ var lastRow = e.data.range.end.row;
6536
+ var start = e.data.range.start;
6537
+ var end = e.data.range.end;
6538
+ var removedFolds = null;
6539
+
6540
+ if (action.indexOf("Lines") != -1) {
6541
+ if (action == "insertLines") {
6542
+ lastRow = firstRow + (e.data.lines.length);
6543
+ } else {
6544
+ lastRow = firstRow;
6545
+ }
6546
+ len = e.data.lines ? e.data.lines.length : lastRow - firstRow;
6547
+ } else {
6548
+ len = lastRow - firstRow;
6549
+ }
6550
+
6551
+ if (len != 0) {
6552
+ if (action.indexOf("remove") != -1) {
6553
+ useWrapMode && this.$wrapData.splice(firstRow, len);
6554
+
6555
+ var foldLines = this.$foldData;
6556
+ removedFolds = this.getFoldsInRange(e.data.range);
6557
+ this.removeFolds(removedFolds);
6558
+
6559
+ var foldLine = this.getFoldLine(end.row);
6560
+ var idx = 0;
6561
+ if (foldLine) {
6562
+ foldLine.addRemoveChars(end.row, end.column, start.column - end.column);
6563
+ foldLine.shiftRow(-len);
6564
+
6565
+ var foldLineBefore = this.getFoldLine(firstRow);
6566
+ if (foldLineBefore && foldLineBefore !== foldLine) {
6567
+ foldLineBefore.merge(foldLine);
6568
+ foldLine = foldLineBefore;
6569
+ }
6570
+ idx = foldLines.indexOf(foldLine) + 1;
6571
+ }
6572
+
6573
+ for (idx; idx < foldLines.length; idx++) {
6574
+ var foldLine = foldLines[idx];
6575
+ if (foldLine.start.row >= end.row) {
6576
+ foldLine.shiftRow(-len);
6577
+ }
6578
+ }
6579
+
6580
+ lastRow = firstRow;
6581
+ } else {
6582
+ var args;
6583
+ if (useWrapMode) {
6584
+ args = [firstRow, 0];
6585
+ for (var i = 0; i < len; i++) args.push([]);
6586
+ this.$wrapData.splice.apply(this.$wrapData, args);
6587
+ }
6588
+
6589
+ // If some new line is added inside of a foldLine, then split
6590
+ // the fold line up.
6591
+ var foldLines = this.$foldData;
6592
+ var foldLine = this.getFoldLine(firstRow);
6593
+ var idx = 0;
6594
+ if (foldLine) {
6595
+ var cmp = foldLine.range.compareInside(start.row, start.column)
6596
+ // Inside of the foldLine range. Need to split stuff up.
6597
+ if (cmp == 0) {
6598
+ foldLine = foldLine.split(start.row, start.column);
6599
+ foldLine.shiftRow(len);
6600
+ foldLine.addRemoveChars(
6601
+ lastRow, 0, end.column - start.column);
6602
+ } else
6603
+ // Infront of the foldLine but same row. Need to shift column.
6604
+ if (cmp == -1) {
6605
+ foldLine.addRemoveChars(firstRow, 0, end.column - start.column);
6606
+ foldLine.shiftRow(len);
6607
+ }
6608
+ // Nothing to do if the insert is after the foldLine.
6609
+ idx = foldLines.indexOf(foldLine) + 1;
6610
+ }
6611
+
6612
+ for (idx; idx < foldLines.length; idx++) {
6613
+ var foldLine = foldLines[idx];
6614
+ if (foldLine.start.row >= firstRow) {
6615
+ foldLine.shiftRow(len);
6616
+ }
6617
+ }
6618
+ }
6619
+ } else {
6620
+ // Realign folds. E.g. if you add some new chars before a fold, the
6621
+ // fold should "move" to the right.
6622
+ len = Math.abs(e.data.range.start.column - e.data.range.end.column);
6623
+ if (action.indexOf("remove") != -1) {
6624
+ // Get all the folds in the change range and remove them.
6625
+ removedFolds = this.getFoldsInRange(e.data.range);
6626
+ this.removeFolds(removedFolds);
6627
+
6628
+ len = -len;
6629
+ }
6630
+ var foldLine = this.getFoldLine(firstRow);
6631
+ if (foldLine) {
6632
+ foldLine.addRemoveChars(firstRow, start.column, len);
6633
+ }
6634
+ }
6635
+
6636
+ if (useWrapMode && this.$wrapData.length != this.doc.getLength()) {
6637
+ console.error("doc.getLength() and $wrapData.length have to be the same!");
6638
+ }
6639
+
6640
+ useWrapMode && this.$updateWrapData(firstRow, lastRow);
6641
+
6642
+ return removedFolds;
6643
+ };
6644
+
6645
+ this.$updateWrapData = function(firstRow, lastRow) {
6646
+ var lines = this.doc.getAllLines();
6647
+ var tabSize = this.getTabSize();
6648
+ var wrapData = this.$wrapData;
6649
+ var wrapLimit = this.$wrapLimit;
6650
+ var tokens;
6651
+ var foldLine;
6652
+
6653
+ var row = firstRow;
6654
+ lastRow = Math.min(lastRow, lines.length - 1);
6655
+ while (row <= lastRow) {
6656
+ foldLine = this.getFoldLine(row, foldLine);
6657
+ if (!foldLine) {
6658
+ tokens = this.$getDisplayTokens(lang.stringTrimRight(lines[row]));
6659
+ wrapData[row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
6660
+ row ++;
6661
+ } else {
6662
+ tokens = [];
6663
+ foldLine.walk(
6664
+ function(placeholder, row, column, lastColumn) {
6665
+ var walkTokens;
6666
+ if (placeholder) {
6667
+ walkTokens = this.$getDisplayTokens(
6668
+ placeholder, tokens.length);
6669
+ walkTokens[0] = PLACEHOLDER_START;
6670
+ for (var i = 1; i < walkTokens.length; i++) {
6671
+ walkTokens[i] = PLACEHOLDER_BODY;
6672
+ }
6673
+ } else {
6674
+ walkTokens = this.$getDisplayTokens(
6675
+ lines[row].substring(lastColumn, column),
6676
+ tokens.length);
6677
+ }
6678
+ tokens = tokens.concat(walkTokens);
6679
+ }.bind(this),
6680
+ foldLine.end.row,
6681
+ lines[foldLine.end.row].length + 1
6682
+ );
6683
+ // Remove spaces/tabs from the back of the token array.
6684
+ while (tokens.length != 0 && tokens[tokens.length - 1] >= SPACE)
6685
+ tokens.pop();
6686
+
6687
+ wrapData[foldLine.start.row]
6688
+ = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
6689
+ row = foldLine.end.row + 1;
6690
+ }
6691
+ }
6692
+ };
6693
+
6694
+ // "Tokens"
6695
+ var CHAR = 1,
6696
+ CHAR_EXT = 2,
6697
+ PLACEHOLDER_START = 3,
6698
+ PLACEHOLDER_BODY = 4,
6699
+ PUNCTUATION = 9,
6700
+ SPACE = 10,
6701
+ TAB = 11,
6702
+ TAB_SPACE = 12;
6703
+
6704
+ this.$computeWrapSplits = function(tokens, wrapLimit) {
6705
+ if (tokens.length == 0) {
6706
+ return [];
6707
+ }
6708
+
6709
+ var splits = [];
6710
+ var displayLength = tokens.length;
6711
+ var lastSplit = 0, lastDocSplit = 0;
6712
+
6713
+ function addSplit(screenPos) {
6714
+ var displayed = tokens.slice(lastSplit, screenPos);
6715
+
6716
+ // The document size is the current size - the extra width for tabs
6717
+ // and multipleWidth characters.
6718
+ var len = displayed.length;
6719
+ displayed.join("").
6720
+ // Get all the TAB_SPACEs.
6721
+ replace(/12/g, function() {
6722
+ len -= 1;
6723
+ }).
6724
+ // Get all the CHAR_EXT/multipleWidth characters.
6725
+ replace(/2/g, function() {
6726
+ len -= 1;
6727
+ });
6728
+
6729
+ lastDocSplit += len;
6730
+ splits.push(lastDocSplit);
6731
+ lastSplit = screenPos;
6732
+ }
6733
+
6734
+ while (displayLength - lastSplit > wrapLimit) {
6735
+ // This is, where the split should be.
6736
+ var split = lastSplit + wrapLimit;
6737
+
6738
+ // If there is a space or tab at this split position, then making
6739
+ // a split is simple.
6740
+ if (tokens[split] >= SPACE) {
6741
+ // Include all following spaces + tabs in this split as well.
6742
+ while (tokens[split] >= SPACE) {
6743
+ split ++;
6744
+ }
6745
+ addSplit(split);
6746
+ continue;
6747
+ }
6748
+
6749
+ // === ELSE ===
6750
+ // Check if split is inside of a placeholder. Placeholder are
6751
+ // not splitable. Therefore, seek the beginning of the placeholder
6752
+ // and try to place the split beofre the placeholder's start.
6753
+ if (tokens[split] == PLACEHOLDER_START
6754
+ || tokens[split] == PLACEHOLDER_BODY)
6755
+ {
6756
+ // Seek the start of the placeholder and do the split
6757
+ // before the placeholder. By definition there always
6758
+ // a PLACEHOLDER_START between split and lastSplit.
6759
+ for (split; split != lastSplit - 1; split--) {
6760
+ if (tokens[split] == PLACEHOLDER_START) {
6761
+ // split++; << No incremental here as we want to
6762
+ // have the position before the Placeholder.
6763
+ break;
6764
+ }
6765
+ }
6766
+
6767
+ // If the PLACEHOLDER_START is not the index of the
6768
+ // last split, then we can do the split
6769
+ if (split > lastSplit) {
6770
+ addSplit(split);
6771
+ continue;
6772
+ }
6773
+
6774
+ // If the PLACEHOLDER_START IS the index of the last
6775
+ // split, then we have to place the split after the
6776
+ // placeholder. So, let's seek for the end of the placeholder.
6777
+ split = lastSplit + wrapLimit;
6778
+ for (split; split < tokens.length; split++) {
6779
+ if (tokens[split] != PLACEHOLDER_BODY)
6780
+ {
6781
+ break;
6782
+ }
6783
+ }
6784
+
6785
+ // If spilt == tokens.length, then the placeholder is the last
6786
+ // thing in the line and adding a new split doesn't make sense.
6787
+ if (split == tokens.length) {
6788
+ break; // Breaks the while-loop.
6789
+ }
6790
+
6791
+ // Finally, add the split...
6792
+ addSplit(split);
6793
+ continue;
6794
+ }
6795
+
6796
+ // === ELSE ===
6797
+ // Search for the first non space/tab/placeholder/punctuation token backwards.
6798
+ var minSplit = Math.max(split - 10, lastSplit - 1);
6799
+ while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
6800
+ split --;
6801
+ }
6802
+ while (split > minSplit && tokens[split] == PUNCTUATION) {
6803
+ split --;
6804
+ }
6805
+ // If we found one, then add the split.
6806
+ if (split > minSplit) {
6807
+ addSplit(++split);
6808
+ continue;
6809
+ }
6810
+
6811
+ // === ELSE ===
6812
+ split = lastSplit + wrapLimit;
6813
+ // The split is inside of a CHAR or CHAR_EXT token and no space
6814
+ // around -> force a split.
6815
+ addSplit(split);
6816
+ }
6817
+ return splits;
6818
+ }
6819
+
6820
+ /**
6821
+ * @param
6822
+ * offset: The offset in screenColumn at which position str starts.
6823
+ * Important for calculating the realTabSize.
6824
+ */
6825
+ this.$getDisplayTokens = function(str, offset) {
6826
+ var arr = [];
6827
+ var tabSize;
6828
+ offset = offset || 0;
6829
+
6830
+ for (var i = 0; i < str.length; i++) {
6831
+ var c = str.charCodeAt(i);
6832
+ // Tab
6833
+ if (c == 9) {
6834
+ tabSize = this.getScreenTabSize(arr.length + offset);
6835
+ arr.push(TAB);
6836
+ for (var n = 1; n < tabSize; n++) {
6837
+ arr.push(TAB_SPACE);
6838
+ }
6839
+ }
6840
+ // Space
6841
+ else if (c == 32) {
6842
+ arr.push(SPACE);
6843
+ } else if((c > 39 && c < 48) || (c > 57 && c < 64)) {
6844
+ arr.push(PUNCTUATION);
6845
+ }
6846
+ // full width characters
6847
+ else if (c >= 0x1100 && isFullWidth(c)) {
6848
+ arr.push(CHAR, CHAR_EXT);
6849
+ } else {
6850
+ arr.push(CHAR);
6851
+ }
6852
+ }
6853
+ return arr;
6854
+ }
6855
+
6856
+ /**
6857
+ * Calculates the width of the a string on the screen while assuming that
6858
+ * the string starts at the first column on the screen.
6859
+ *
6860
+ * @param string str String to calculate the screen width of
6861
+ * @return array
6862
+ * [0]: number of columns for str on screen.
6863
+ * [1]: docColumn position that was read until (useful with screenColumn)
6864
+ */
6865
+ this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) {
6866
+ if (maxScreenColumn == 0) {
6867
+ return [0, 0];
6868
+ }
6869
+ if (maxScreenColumn == null) {
6870
+ maxScreenColumn = screenColumn +
6871
+ str.length * Math.max(this.getTabSize(), 2);
6872
+ }
6873
+ screenColumn = screenColumn || 0;
6874
+
6875
+ var c, column;
6876
+ for (column = 0; column < str.length; column++) {
6877
+ c = str.charCodeAt(column);
6878
+ // tab
6879
+ if (c == 9) {
6880
+ screenColumn += this.getScreenTabSize(screenColumn);
6881
+ }
6882
+ // full width characters
6883
+ else if (c >= 0x1100 && isFullWidth(c)) {
6884
+ screenColumn += 2;
6885
+ } else {
6886
+ screenColumn += 1;
6887
+ }
6888
+ if (screenColumn > maxScreenColumn) {
6889
+ break
6890
+ }
6891
+ }
6892
+
6893
+ return [screenColumn, column];
6894
+ }
6895
+
6896
+ /**
6897
+ * Returns the number of rows required to render this row on the screen
6898
+ */
6899
+ this.getRowLength = function(row) {
6900
+ if (!this.$useWrapMode || !this.$wrapData[row]) {
6901
+ return 1;
6902
+ } else {
6903
+ return this.$wrapData[row].length + 1;
6904
+ }
6905
+ }
6906
+
6907
+ /**
6908
+ * Returns the height in pixels required to render this row on the screen
6909
+ **/
6910
+ this.getRowHeight = function(config, row) {
6911
+ return this.getRowLength(row) * config.lineHeight;
6912
+ }
6913
+
6914
+ this.getScreenLastRowColumn = function(screenRow) {
6915
+ //return this.screenToDocumentColumn(screenRow, Number.MAX_VALUE / 10)
6916
+ return this.documentToScreenColumn(screenRow, this.doc.getLine(screenRow).length);
6917
+ };
6918
+
6919
+ this.getDocumentLastRowColumn = function(docRow, docColumn) {
6920
+ var screenRow = this.documentToScreenRow(docRow, docColumn);
6921
+ return this.getScreenLastRowColumn(screenRow);
6922
+ };
6923
+
6924
+ this.getDocumentLastRowColumnPosition = function(docRow, docColumn) {
6925
+ var screenRow = this.documentToScreenRow(docRow, docColumn);
6926
+ return this.screenToDocumentPosition(screenRow, Number.MAX_VALUE / 10);
6927
+ };
6928
+
6929
+ this.getRowSplitData = function(row) {
6930
+ if (!this.$useWrapMode) {
6931
+ return undefined;
6932
+ } else {
6933
+ return this.$wrapData[row];
6934
+ }
6935
+ };
6936
+
6937
+ /**
6938
+ * Returns the width of a tab character at screenColumn.
6939
+ */
6940
+ this.getScreenTabSize = function(screenColumn) {
6941
+ return this.$tabSize - screenColumn % this.$tabSize;
6942
+ };
6943
+
6944
+ this.screenToDocumentRow = function(screenRow, screenColumn) {
6945
+ return this.screenToDocumentPosition(screenRow, screenColumn).row;
6946
+ };
6947
+
6948
+ this.screenToDocumentColumn = function(screenRow, screenColumn) {
6949
+ return this.screenToDocumentPosition(screenRow, screenColumn).column;
6950
+ };
6951
+
6952
+ this.screenToDocumentPosition = function(screenRow, screenColumn) {
6953
+ if (screenRow < 0) {
6954
+ return {
6955
+ row: 0,
6956
+ column: 0
6957
+ }
6958
+ }
6959
+
6960
+ var line;
6961
+ var docRow = 0;
6962
+ var docColumn = 0;
6963
+ var column;
6964
+ var row = 0;
6965
+ var rowLength = 0;
6966
+
6967
+ var rowCache = this.$rowCache;
6968
+ for (var i = 0; i < rowCache.length; i++) {
6969
+ if (rowCache[i].screenRow < screenRow) {
6970
+ row = rowCache[i].screenRow;
6971
+ docRow = rowCache[i].docRow;
6972
+ }
6973
+ else {
6974
+ break;
6975
+ }
6976
+ }
6977
+ var doCache = !rowCache.length || i == rowCache.length;
6978
+
6979
+ var maxRow = this.getLength() - 1;
6980
+ var foldLine = this.getNextFoldLine(docRow);
6981
+ var foldStart = foldLine ? foldLine.start.row : Infinity;
6982
+
6983
+ while (row <= screenRow) {
6984
+ rowLength = this.getRowLength(docRow);
6985
+ if (row + rowLength - 1 >= screenRow || docRow >= maxRow) {
6986
+ break;
6987
+ } else {
6988
+ row += rowLength;
6989
+ docRow++;
6990
+ if (docRow > foldStart) {
6991
+ docRow = foldLine.end.row+1;
6992
+ foldLine = this.getNextFoldLine(docRow, foldLine);
6993
+ foldStart = foldLine ? foldLine.start.row : Infinity;
6994
+ }
6995
+ }
6996
+ if (doCache) {
6997
+ rowCache.push({
6998
+ docRow: docRow,
6999
+ screenRow: row
7000
+ });
7001
+ }
7002
+ }
7003
+
7004
+ if (foldLine && foldLine.start.row <= docRow) {
7005
+ line = this.getFoldDisplayLine(foldLine);
7006
+ docRow = foldLine.start.row;
7007
+ } else if (row + rowLength <= screenRow || docRow > maxRow) {
7008
+ // clip at the end of the document
7009
+ return {
7010
+ row: maxRow,
7011
+ column: this.getLine(maxRow).length
7012
+ }
7013
+ } else {
7014
+ line = this.getLine(docRow);
7015
+ foldLine = null;
7016
+ }
7017
+
7018
+ if (this.$useWrapMode) {
7019
+ var splits = this.$wrapData[docRow];
7020
+ if (splits) {
7021
+ column = splits[screenRow - row];
7022
+ if(screenRow > row && splits.length) {
7023
+ docColumn = splits[screenRow - row - 1] || splits[splits.length - 1];
7024
+ line = line.substring(docColumn);
7025
+ }
7026
+ }
7027
+ }
7028
+
7029
+ docColumn += this.$getStringScreenWidth(line, screenColumn)[1];
7030
+
7031
+ // Need to do some clamping action here.
7032
+ if (this.$useWrapMode) {
7033
+ if (docColumn >= column) {
7034
+ // We remove one character at the end such that the docColumn
7035
+ // position returned is not associated to the next row on the
7036
+ // screen.
7037
+ docColumn = column - 1;
7038
+ }
7039
+ } else {
7040
+ docColumn = Math.min(docColumn, line.length);
7041
+ }
7042
+
7043
+ if (foldLine) {
7044
+ return foldLine.idxToPosition(docColumn);
7045
+ }
7046
+
7047
+ return {
7048
+ row: docRow,
7049
+ column: docColumn
7050
+ }
7051
+ };
7052
+
7053
+ this.documentToScreenPosition = function(docRow, docColumn) {
7054
+ // Normalize the passed in arguments.
7055
+ if (typeof docColumn === "undefined")
7056
+ var pos = this.$clipPositionToDocument(docRow.row, docRow.column);
7057
+ else
7058
+ pos = this.$clipPositionToDocument(docRow, docColumn);
7059
+
7060
+ docRow = pos.row;
7061
+ docColumn = pos.column;
7062
+
7063
+ var wrapData;
7064
+ // Special case in wrapMode if the doc is at the end of the document.
7065
+ if (this.$useWrapMode) {
7066
+ wrapData = this.$wrapData;
7067
+ if (docRow > wrapData.length - 1) {
7068
+ return {
7069
+ row: this.getScreenLength(),
7070
+ column: wrapData.length == 0
7071
+ ? 0
7072
+ : (wrapData[wrapData.length - 1].length - 1)
7073
+ };
7074
+ }
7075
+ }
7076
+
7077
+ var screenRow = 0;
7078
+ var foldStartRow = null;
7079
+ var fold = null;
7080
+
7081
+ // Clamp the docRow position in case it's inside of a folded block.
7082
+ fold = this.getFoldAt(docRow, docColumn, 1);
7083
+ if (fold) {
7084
+ docRow = fold.start.row;
7085
+ docColumn = fold.start.column;
7086
+ }
7087
+
7088
+ var rowEnd, row = 0;
7089
+ var rowCache = this.$rowCache;
7090
+
7091
+ for (var i = 0; i < rowCache.length; i++) {
7092
+ if (rowCache[i].docRow < docRow) {
7093
+ screenRow = rowCache[i].screenRow;
7094
+ row = rowCache[i].docRow;
7095
+ } else {
7096
+ break;
7097
+ }
7098
+ }
7099
+ var doCache = !rowCache.length || i == rowCache.length;
7100
+
7101
+ var foldLine = this.getNextFoldLine(row);
7102
+ var foldStart = foldLine ?foldLine.start.row :Infinity;
7103
+
7104
+ while (row < docRow) {
7105
+ if (row >= foldStart) {
7106
+ rowEnd = foldLine.end.row + 1;
7107
+ if (rowEnd > docRow)
7108
+ break;
7109
+ foldLine = this.getNextFoldLine(rowEnd, foldLine);
7110
+ foldStart = foldLine ?foldLine.start.row :Infinity;
7111
+ }
7112
+ else {
7113
+ rowEnd = row + 1;
7114
+ }
7115
+
7116
+ screenRow += this.getRowLength(row);
7117
+ row = rowEnd;
7118
+
7119
+ if (doCache) {
7120
+ rowCache.push({
7121
+ docRow: row,
7122
+ screenRow: screenRow
7123
+ });
7124
+ }
7125
+ }
7126
+
7127
+ // Calculate the text line that is displayed in docRow on the screen.
7128
+ var textLine = "";
7129
+ // Check if the final row we want to reach is inside of a fold.
7130
+ if (foldLine && row >= foldStart) {
7131
+ textLine = this.getFoldDisplayLine(foldLine, docRow, docColumn);
7132
+ foldStartRow = foldLine.start.row;
7133
+ } else {
7134
+ textLine = this.getLine(docRow).substring(0, docColumn);
7135
+ foldStartRow = docRow;
7136
+ }
7137
+ // Clamp textLine if in wrapMode.
7138
+ if (this.$useWrapMode) {
7139
+ var wrapRow = wrapData[foldStartRow];
7140
+ var screenRowOffset = 0;
7141
+ while (textLine.length >= wrapRow[screenRowOffset]) {
7142
+ screenRow ++;
7143
+ screenRowOffset++;
7144
+ }
7145
+ textLine = textLine.substring(
7146
+ wrapRow[screenRowOffset - 1] || 0, textLine.length
7147
+ );
7148
+ }
7149
+
7150
+ return {
7151
+ row: screenRow,
7152
+ column: this.$getStringScreenWidth(textLine)[0]
7153
+ };
7154
+ };
7155
+
7156
+ this.documentToScreenColumn = function(row, docColumn) {
7157
+ return this.documentToScreenPosition(row, docColumn).column;
7158
+ };
7159
+
7160
+ this.documentToScreenRow = function(docRow, docColumn) {
7161
+ return this.documentToScreenPosition(docRow, docColumn).row;
7162
+ };
7163
+
7164
+ this.getScreenLength = function() {
7165
+ var screenRows = 0;
7166
+ var fold = null;
7167
+ if (!this.$useWrapMode) {
7168
+ screenRows = this.getLength();
7169
+
7170
+ // Remove the folded lines again.
7171
+ var foldData = this.$foldData;
7172
+ for (var i = 0; i < foldData.length; i++) {
7173
+ fold = foldData[i];
7174
+ screenRows -= fold.end.row - fold.start.row;
7175
+ }
7176
+ } else {
7177
+ var lastRow = this.$wrapData.length;
7178
+ var row = 0, i = 0;
7179
+ var fold = this.$foldData[i++];
7180
+ var foldStart = fold ? fold.start.row :Infinity;
7181
+
7182
+ while (row < lastRow) {
7183
+ screenRows += this.$wrapData[row].length + 1;
7184
+ row ++;
7185
+ if (row > foldStart) {
7186
+ row = fold.end.row+1;
7187
+ fold = this.$foldData[i++];
7188
+ foldStart = fold ?fold.start.row :Infinity;
7189
+ }
7190
+ }
7191
+ }
7192
+
7193
+ return screenRows;
7194
+ }
7195
+
7196
+ // For every keystroke this gets called once per char in the whole doc!!
7197
+ // Wouldn't hurt to make it a bit faster for c >= 0x1100
7198
+ function isFullWidth(c) {
7199
+ if (c < 0x1100)
7200
+ return false;
7201
+ return c >= 0x1100 && c <= 0x115F ||
7202
+ c >= 0x11A3 && c <= 0x11A7 ||
7203
+ c >= 0x11FA && c <= 0x11FF ||
7204
+ c >= 0x2329 && c <= 0x232A ||
7205
+ c >= 0x2E80 && c <= 0x2E99 ||
7206
+ c >= 0x2E9B && c <= 0x2EF3 ||
7207
+ c >= 0x2F00 && c <= 0x2FD5 ||
7208
+ c >= 0x2FF0 && c <= 0x2FFB ||
7209
+ c >= 0x3000 && c <= 0x303E ||
7210
+ c >= 0x3041 && c <= 0x3096 ||
7211
+ c >= 0x3099 && c <= 0x30FF ||
7212
+ c >= 0x3105 && c <= 0x312D ||
7213
+ c >= 0x3131 && c <= 0x318E ||
7214
+ c >= 0x3190 && c <= 0x31BA ||
7215
+ c >= 0x31C0 && c <= 0x31E3 ||
7216
+ c >= 0x31F0 && c <= 0x321E ||
7217
+ c >= 0x3220 && c <= 0x3247 ||
7218
+ c >= 0x3250 && c <= 0x32FE ||
7219
+ c >= 0x3300 && c <= 0x4DBF ||
7220
+ c >= 0x4E00 && c <= 0xA48C ||
7221
+ c >= 0xA490 && c <= 0xA4C6 ||
7222
+ c >= 0xA960 && c <= 0xA97C ||
7223
+ c >= 0xAC00 && c <= 0xD7A3 ||
7224
+ c >= 0xD7B0 && c <= 0xD7C6 ||
7225
+ c >= 0xD7CB && c <= 0xD7FB ||
7226
+ c >= 0xF900 && c <= 0xFAFF ||
7227
+ c >= 0xFE10 && c <= 0xFE19 ||
7228
+ c >= 0xFE30 && c <= 0xFE52 ||
7229
+ c >= 0xFE54 && c <= 0xFE66 ||
7230
+ c >= 0xFE68 && c <= 0xFE6B ||
7231
+ c >= 0xFF01 && c <= 0xFF60 ||
7232
+ c >= 0xFFE0 && c <= 0xFFE6;
7233
+ };
7234
+
7235
+ }).call(EditSession.prototype);
7236
+
7237
+ require("./edit_session/folding").Folding.call(EditSession.prototype);
7238
+ require("./edit_session/bracket_match").BracketMatch.call(EditSession.prototype);
7239
+
7240
+ exports.EditSession = EditSession;
7241
+ });
7242
+ /* vim:ts=4:sts=4:sw=4:
7243
+ * ***** BEGIN LICENSE BLOCK *****
7244
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
7245
+ *
7246
+ * The contents of this file are subject to the Mozilla Public License Version
7247
+ * 1.1 (the "License"); you may not use this file except in compliance with
7248
+ * the License. You may obtain a copy of the License at
7249
+ * http://www.mozilla.org/MPL/
7250
+ *
7251
+ * Software distributed under the License is distributed on an "AS IS" basis,
7252
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7253
+ * for the specific language governing rights and limitations under the
7254
+ * License.
7255
+ *
7256
+ * The Original Code is Ajax.org Code Editor (ACE).
7257
+ *
7258
+ * The Initial Developer of the Original Code is
7259
+ * Ajax.org B.V.
7260
+ * Portions created by the Initial Developer are Copyright (C) 2010
7261
+ * the Initial Developer. All Rights Reserved.
7262
+ *
7263
+ * Contributor(s):
7264
+ * Fabian Jakobs <fabian AT ajax DOT org>
7265
+ *
7266
+ * Alternatively, the contents of this file may be used under the terms of
7267
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
7268
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
7269
+ * in which case the provisions of the GPL or the LGPL are applicable instead
7270
+ * of those above. If you wish to allow use of your version of this file only
7271
+ * under the terms of either the GPL or the LGPL, and not to allow others to
7272
+ * use your version of this file under the terms of the MPL, indicate your
7273
+ * decision by deleting the provisions above and replace them with the notice
7274
+ * and other provisions required by the GPL or the LGPL. If you do not delete
7275
+ * the provisions above, a recipient may use your version of this file under
7276
+ * the terms of any one of the MPL, the GPL or the LGPL.
7277
+ *
7278
+ * ***** END LICENSE BLOCK ***** */
7279
+
7280
+ ace.define('ace/config', ['require', 'exports', 'module' , 'ace/lib/lang'], function(require, exports, module) {
7281
+ "no use strict";
7282
+
7283
+ var lang = require("./lib/lang");
7284
+
7285
+ var global = (function() {
7286
+ return this;
7287
+ })();
7288
+
7289
+ var options = {
7290
+ packaged: false,
7291
+ workerPath: "",
7292
+ modePath: "",
7293
+ themePath: "",
7294
+ suffix: ".js"
7295
+ };
7296
+
7297
+ exports.get = function(key) {
7298
+ if (!options.hasOwnProperty(key))
7299
+ throw new Error("Unknown confik key: " + key);
7300
+
7301
+ return options[key];
7302
+ };
7303
+
7304
+ exports.set = function(key, value) {
7305
+ if (!options.hasOwnProperty(key))
7306
+ throw new Error("Unknown confik key: " + key);
7307
+
7308
+ options[key] = value;
7309
+ };
7310
+
7311
+ exports.all = function() {
7312
+ return lang.copyObject(options);
7313
+ };
7314
+
7315
+ exports.init = function() {
7316
+ options.packaged = require.packaged || module.packaged || (global.define && define.packaged);
7317
+
7318
+ if (!global.document)
7319
+ return "";
7320
+
7321
+ var scriptOptions = {};
7322
+ var scriptUrl = "";
7323
+ var suffix;
7324
+
7325
+ var scripts = document.getElementsByTagName("script");
7326
+ for (var i=0; i<scripts.length; i++) {
7327
+ var script = scripts[i];
7328
+
7329
+ var src = script.src || script.getAttribute("src");
7330
+ if (!src) {
7331
+ continue;
7332
+ }
7333
+
7334
+ var attributes = script.attributes;
7335
+ for (var j=0, l=attributes.length; j < l; j++) {
7336
+ var attr = attributes[j];
7337
+ if (attr.name.indexOf("data-ace-") === 0) {
7338
+ scriptOptions[deHyphenate(attr.name.replace(/^data-ace-/, ""))] = attr.value;
7339
+ }
7340
+ }
7341
+
7342
+ var m = src.match(/^(?:(.*\/)ace\.js|(.*\/)ace((-uncompressed)?(-noconflict)?\.js))(?:\?|$)/);
7343
+ if (m) {
7344
+ scriptUrl = m[1] || m[2];
7345
+ suffix = m[3];
7346
+ }
7347
+ }
7348
+
7349
+ if (scriptUrl) {
7350
+ scriptOptions.base = scriptOptions.base || scriptUrl;
7351
+ scriptOptions.packaged = true;
7352
+ }
7353
+
7354
+ scriptOptions.suffix = scriptOptions.suffix || suffix;
7355
+ scriptOptions.workerPath = scriptOptions.workerPath || scriptOptions.base;
7356
+ scriptOptions.modePath = scriptOptions.modePath || scriptOptions.base;
7357
+ scriptOptions.themePath = scriptOptions.themePath || scriptOptions.base;
7358
+ delete scriptOptions.base;
7359
+
7360
+ for (var key in scriptOptions)
7361
+ if (typeof scriptOptions[key] !== "undefined")
7362
+ exports.set(key, scriptOptions[key]);
7363
+ };
7364
+
7365
+ function deHyphenate(str) {
7366
+ return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); });
7367
+ }
7368
+
7369
+ });/**
7370
+ * based on code from:
7371
+ *
7372
+ * @license RequireJS text 0.25.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
7373
+ * Available via the MIT or new BSD license.
7374
+ * see: http://github.com/jrburke/requirejs for details
7375
+ */
7376
+ ace.define('ace/lib/net', ['require', 'exports', 'module' ], function(require, exports, module) {
7377
+ "use strict";
7378
+
7379
+ exports.get = function (url, callback) {
7380
+ var xhr = exports.createXhr();
7381
+ xhr.open('GET', url, true);
7382
+ xhr.onreadystatechange = function (evt) {
7383
+ //Do not explicitly handle errors, those should be
7384
+ //visible via console output in the browser.
7385
+ if (xhr.readyState === 4) {
7386
+ callback(xhr.responseText);
7387
+ }
7388
+ };
7389
+ xhr.send(null);
7390
+ };
7391
+
7392
+ var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
7393
+
7394
+ exports.createXhr = function() {
7395
+ //Would love to dump the ActiveX crap in here. Need IE 6 to die first.
7396
+ var xhr, i, progId;
7397
+ if (typeof XMLHttpRequest !== "undefined") {
7398
+ return new XMLHttpRequest();
7399
+ } else {
7400
+ for (i = 0; i < 3; i++) {
7401
+ progId = progIds[i];
7402
+ try {
7403
+ xhr = new ActiveXObject(progId);
7404
+ } catch (e) {}
7405
+
7406
+ if (xhr) {
7407
+ progIds = [progId]; // so faster next time
7408
+ break;
7409
+ }
7410
+ }
7411
+ }
7412
+
7413
+ if (!xhr) {
7414
+ throw new Error("createXhr(): XMLHttpRequest not available");
7415
+ }
7416
+
7417
+ return xhr;
7418
+ };
7419
+
7420
+ exports.loadScript = function(path, callback) {
7421
+ var head = document.getElementsByTagName('head')[0];
7422
+ var s = document.createElement('script');
7423
+
7424
+ s.src = path;
7425
+ head.appendChild(s);
7426
+
7427
+ s.onload = callback;
7428
+ };
7429
+
7430
+ });/* ***** BEGIN LICENSE BLOCK *****
7431
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
7432
+ *
7433
+ * The contents of this file are subject to the Mozilla Public License Version
7434
+ * 1.1 (the "License"); you may not use this file except in compliance with
7435
+ * the License. You may obtain a copy of the License at
7436
+ * http://www.mozilla.org/MPL/
7437
+ *
7438
+ * Software distributed under the License is distributed on an "AS IS" basis,
7439
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7440
+ * for the specific language governing rights and limitations under the
7441
+ * License.
7442
+ *
7443
+ * The Original Code is Ajax.org Code Editor (ACE).
7444
+ *
7445
+ * The Initial Developer of the Original Code is
7446
+ * Ajax.org B.V.
7447
+ * Portions created by the Initial Developer are Copyright (C) 2010
7448
+ * the Initial Developer. All Rights Reserved.
7449
+ *
7450
+ * Contributor(s):
7451
+ * Fabian Jakobs <fabian AT ajax DOT org>
7452
+ * Julian Viereck <julian.viereck@gmail.com>
7453
+ *
7454
+ * Alternatively, the contents of this file may be used under the terms of
7455
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
7456
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
7457
+ * in which case the provisions of the GPL or the LGPL are applicable instead
7458
+ * of those above. If you wish to allow use of your version of this file only
7459
+ * under the terms of either the GPL or the LGPL, and not to allow others to
7460
+ * use your version of this file under the terms of the MPL, indicate your
7461
+ * decision by deleting the provisions above and replace them with the notice
7462
+ * and other provisions required by the GPL or the LGPL. If you do not delete
7463
+ * the provisions above, a recipient may use your version of this file under
7464
+ * the terms of any one of the MPL, the GPL or the LGPL.
7465
+ *
7466
+ * ***** END LICENSE BLOCK ***** */
7467
+
7468
+ ace.define('ace/selection', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/lib/event_emitter', 'ace/range'], function(require, exports, module) {
7469
+ "use strict";
7470
+
7471
+ var oop = require("./lib/oop");
7472
+ var lang = require("./lib/lang");
7473
+ var EventEmitter = require("./lib/event_emitter").EventEmitter;
7474
+ var Range = require("./range").Range;
7475
+
7476
+ /**
7477
+ * Keeps cursor position and the text selection of an edit session.
7478
+ *
7479
+ * The row/columns used in the selection are in document coordinates
7480
+ * representing ths coordinates as thez appear in the document
7481
+ * before applying soft wrap and folding.
7482
+ */
7483
+ var Selection = function(session) {
7484
+ this.session = session;
7485
+ this.doc = session.getDocument();
7486
+
7487
+ this.clearSelection();
7488
+ this.selectionLead = this.doc.createAnchor(0, 0);
7489
+ this.selectionAnchor = this.doc.createAnchor(0, 0);
7490
+
7491
+ var _self = this;
7492
+ this.selectionLead.on("change", function(e) {
7493
+ _self._emit("changeCursor");
7494
+ if (!_self.$isEmpty)
7495
+ _self._emit("changeSelection");
7496
+ if (!_self.$preventUpdateDesiredColumnOnChange && e.old.column != e.value.column)
7497
+ _self.$updateDesiredColumn();
7498
+ });
7499
+
7500
+ this.selectionAnchor.on("change", function() {
7501
+ if (!_self.$isEmpty)
7502
+ _self._emit("changeSelection");
7503
+ });
7504
+ };
7505
+
7506
+ (function() {
7507
+
7508
+ oop.implement(this, EventEmitter);
7509
+
7510
+ this.isEmpty = function() {
7511
+ return (this.$isEmpty || (
7512
+ this.selectionAnchor.row == this.selectionLead.row &&
7513
+ this.selectionAnchor.column == this.selectionLead.column
7514
+ ));
7515
+ };
7516
+
7517
+ this.isMultiLine = function() {
7518
+ if (this.isEmpty()) {
7519
+ return false;
7520
+ }
7521
+
7522
+ return this.getRange().isMultiLine();
7523
+ };
7524
+
7525
+ this.getCursor = function() {
7526
+ return this.selectionLead.getPosition();
7527
+ };
7528
+
7529
+ this.setSelectionAnchor = function(row, column) {
7530
+ this.selectionAnchor.setPosition(row, column);
7531
+
7532
+ if (this.$isEmpty) {
7533
+ this.$isEmpty = false;
7534
+ this._emit("changeSelection");
7535
+ }
7536
+ };
7537
+
7538
+ this.getSelectionAnchor = function() {
7539
+ if (this.$isEmpty)
7540
+ return this.getSelectionLead()
7541
+ else
7542
+ return this.selectionAnchor.getPosition();
7543
+ };
7544
+
7545
+ this.getSelectionLead = function() {
7546
+ return this.selectionLead.getPosition();
7547
+ };
7548
+
7549
+ this.shiftSelection = function(columns) {
7550
+ if (this.$isEmpty) {
7551
+ this.moveCursorTo(this.selectionLead.row, this.selectionLead.column + columns);
7552
+ return;
7553
+ };
7554
+
7555
+ var anchor = this.getSelectionAnchor();
7556
+ var lead = this.getSelectionLead();
7557
+
7558
+ var isBackwards = this.isBackwards();
7559
+
7560
+ if (!isBackwards || anchor.column !== 0)
7561
+ this.setSelectionAnchor(anchor.row, anchor.column + columns);
7562
+
7563
+ if (isBackwards || lead.column !== 0) {
7564
+ this.$moveSelection(function() {
7565
+ this.moveCursorTo(lead.row, lead.column + columns);
7566
+ });
7567
+ }
7568
+ };
7569
+
7570
+ this.isBackwards = function() {
7571
+ var anchor = this.selectionAnchor;
7572
+ var lead = this.selectionLead;
7573
+ return (anchor.row > lead.row || (anchor.row == lead.row && anchor.column > lead.column));
7574
+ };
7575
+
7576
+ this.getRange = function() {
7577
+ var anchor = this.selectionAnchor;
7578
+ var lead = this.selectionLead;
7579
+
7580
+ if (this.isEmpty())
7581
+ return Range.fromPoints(lead, lead);
7582
+
7583
+ if (this.isBackwards()) {
7584
+ return Range.fromPoints(lead, anchor);
7585
+ }
7586
+ else {
7587
+ return Range.fromPoints(anchor, lead);
7588
+ }
7589
+ };
7590
+
7591
+ this.clearSelection = function() {
7592
+ if (!this.$isEmpty) {
7593
+ this.$isEmpty = true;
7594
+ this._emit("changeSelection");
7595
+ }
7596
+ };
7597
+
7598
+ this.selectAll = function() {
7599
+ var lastRow = this.doc.getLength() - 1;
7600
+ this.setSelectionAnchor(lastRow, this.doc.getLine(lastRow).length);
7601
+ this.moveCursorTo(0, 0);
7602
+ };
7603
+
7604
+ this.setSelectionRange = function(range, reverse) {
7605
+ if (reverse) {
7606
+ this.setSelectionAnchor(range.end.row, range.end.column);
7607
+ this.selectTo(range.start.row, range.start.column);
7608
+ } else {
7609
+ this.setSelectionAnchor(range.start.row, range.start.column);
7610
+ this.selectTo(range.end.row, range.end.column);
7611
+ }
7612
+ this.$updateDesiredColumn();
7613
+ };
7614
+
7615
+ this.$updateDesiredColumn = function() {
7616
+ var cursor = this.getCursor();
7617
+ this.$desiredColumn = this.session.documentToScreenColumn(cursor.row, cursor.column);
7618
+ };
7619
+
7620
+ this.$moveSelection = function(mover) {
7621
+ var lead = this.selectionLead;
7622
+ if (this.$isEmpty)
7623
+ this.setSelectionAnchor(lead.row, lead.column);
7624
+
7625
+ mover.call(this);
7626
+ };
7627
+
7628
+ this.selectTo = function(row, column) {
7629
+ this.$moveSelection(function() {
7630
+ this.moveCursorTo(row, column);
7631
+ });
7632
+ };
7633
+
7634
+ this.selectToPosition = function(pos) {
7635
+ this.$moveSelection(function() {
7636
+ this.moveCursorToPosition(pos);
7637
+ });
7638
+ };
7639
+
7640
+ this.selectUp = function() {
7641
+ this.$moveSelection(this.moveCursorUp);
7642
+ };
7643
+
7644
+ this.selectDown = function() {
7645
+ this.$moveSelection(this.moveCursorDown);
7646
+ };
7647
+
7648
+ this.selectRight = function() {
7649
+ this.$moveSelection(this.moveCursorRight);
7650
+ };
7651
+
7652
+ this.selectLeft = function() {
7653
+ this.$moveSelection(this.moveCursorLeft);
7654
+ };
7655
+
7656
+ this.selectLineStart = function() {
7657
+ this.$moveSelection(this.moveCursorLineStart);
7658
+ };
7659
+
7660
+ this.selectLineEnd = function() {
7661
+ this.$moveSelection(this.moveCursorLineEnd);
7662
+ };
7663
+
7664
+ this.selectFileEnd = function() {
7665
+ this.$moveSelection(this.moveCursorFileEnd);
7666
+ };
7667
+
7668
+ this.selectFileStart = function() {
7669
+ this.$moveSelection(this.moveCursorFileStart);
7670
+ };
7671
+
7672
+ this.selectWordRight = function() {
7673
+ this.$moveSelection(this.moveCursorWordRight);
7674
+ };
7675
+
7676
+ this.selectWordLeft = function() {
7677
+ this.$moveSelection(this.moveCursorWordLeft);
7678
+ };
7679
+
7680
+ this.selectWord = function() {
7681
+ var cursor = this.getCursor();
7682
+ var range = this.session.getWordRange(cursor.row, cursor.column);
7683
+ this.setSelectionRange(range);
7684
+ };
7685
+
7686
+ // Selects a word including its right whitespace
7687
+ this.selectAWord = function() {
7688
+ var cursor = this.getCursor();
7689
+ var range = this.session.getAWordRange(cursor.row, cursor.column);
7690
+ this.setSelectionRange(range);
7691
+ };
7692
+
7693
+ this.selectLine = function() {
7694
+ var rowStart = this.selectionLead.row;
7695
+ var rowEnd;
7696
+
7697
+ var foldLine = this.session.getFoldLine(rowStart);
7698
+ if (foldLine) {
7699
+ rowStart = foldLine.start.row;
7700
+ rowEnd = foldLine.end.row;
7701
+ } else {
7702
+ rowEnd = rowStart;
7703
+ }
7704
+ this.setSelectionAnchor(rowStart, 0);
7705
+ this.$moveSelection(function() {
7706
+ this.moveCursorTo(rowEnd + 1, 0);
7707
+ });
7708
+ };
7709
+
7710
+ this.moveCursorUp = function() {
7711
+ this.moveCursorBy(-1, 0);
7712
+ };
7713
+
7714
+ this.moveCursorDown = function() {
7715
+ this.moveCursorBy(1, 0);
7716
+ };
7717
+
7718
+ this.moveCursorLeft = function() {
7719
+ var cursor = this.selectionLead.getPosition(),
7720
+ fold;
7721
+
7722
+ if (fold = this.session.getFoldAt(cursor.row, cursor.column, -1)) {
7723
+ this.moveCursorTo(fold.start.row, fold.start.column);
7724
+ } else if (cursor.column == 0) {
7725
+ // cursor is a line (start
7726
+ if (cursor.row > 0) {
7727
+ this.moveCursorTo(cursor.row - 1, this.doc.getLine(cursor.row - 1).length);
7728
+ }
7729
+ }
7730
+ else {
7731
+ var tabSize = this.session.getTabSize();
7732
+ if (this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(cursor.column-tabSize, cursor.column).split(" ").length-1 == tabSize)
7733
+ this.moveCursorBy(0, -tabSize);
7734
+ else
7735
+ this.moveCursorBy(0, -1);
7736
+ }
7737
+ };
7738
+
7739
+ this.moveCursorRight = function() {
7740
+ var cursor = this.selectionLead.getPosition(),
7741
+ fold;
7742
+ if (fold = this.session.getFoldAt(cursor.row, cursor.column, 1)) {
7743
+ this.moveCursorTo(fold.end.row, fold.end.column);
7744
+ }
7745
+ else if (this.selectionLead.column == this.doc.getLine(this.selectionLead.row).length) {
7746
+ if (this.selectionLead.row < this.doc.getLength() - 1) {
7747
+ this.moveCursorTo(this.selectionLead.row + 1, 0);
7748
+ }
7749
+ }
7750
+ else {
7751
+ var tabSize = this.session.getTabSize();
7752
+ var cursor = this.selectionLead;
7753
+ if (this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(cursor.column, cursor.column+tabSize).split(" ").length-1 == tabSize)
7754
+ this.moveCursorBy(0, tabSize);
7755
+ else
7756
+ this.moveCursorBy(0, 1);
7757
+ }
7758
+ };
7759
+
7760
+ this.moveCursorLineStart = function() {
7761
+ var row = this.selectionLead.row;
7762
+ var column = this.selectionLead.column;
7763
+ var screenRow = this.session.documentToScreenRow(row, column);
7764
+
7765
+ // Determ the doc-position of the first character at the screen line.
7766
+ var firstColumnPosition = this.session.screenToDocumentPosition(screenRow, 0);
7767
+
7768
+ // Determ the line
7769
+ var beforeCursor = this.session.getDisplayLine(
7770
+ row, null,
7771
+ firstColumnPosition.row, firstColumnPosition.column
7772
+ );
7773
+
7774
+ var leadingSpace = beforeCursor.match(/^\s*/);
7775
+ if (leadingSpace[0].length == column) {
7776
+ this.moveCursorTo(
7777
+ firstColumnPosition.row, firstColumnPosition.column
7778
+ );
7779
+ }
7780
+ else {
7781
+ this.moveCursorTo(
7782
+ firstColumnPosition.row,
7783
+ firstColumnPosition.column + leadingSpace[0].length
7784
+ );
7785
+ }
7786
+ };
7787
+
7788
+ this.moveCursorLineEnd = function() {
7789
+ var lead = this.selectionLead;
7790
+ var lastRowColumnPosition =
7791
+ this.session.getDocumentLastRowColumnPosition(lead.row, lead.column);
7792
+ this.moveCursorTo(
7793
+ lastRowColumnPosition.row,
7794
+ lastRowColumnPosition.column
7795
+ );
7796
+ };
7797
+
7798
+ this.moveCursorFileEnd = function() {
7799
+ var row = this.doc.getLength() - 1;
7800
+ var column = this.doc.getLine(row).length;
7801
+ this.moveCursorTo(row, column);
7802
+ };
7803
+
7804
+ this.moveCursorFileStart = function() {
7805
+ this.moveCursorTo(0, 0);
7806
+ };
7807
+
7808
+ this.moveCursorWordRight = function() {
7809
+ var row = this.selectionLead.row;
7810
+ var column = this.selectionLead.column;
7811
+ var line = this.doc.getLine(row);
7812
+ var rightOfCursor = line.substring(column);
7813
+
7814
+ var match;
7815
+ this.session.nonTokenRe.lastIndex = 0;
7816
+ this.session.tokenRe.lastIndex = 0;
7817
+
7818
+ // skip folds
7819
+ var fold = this.session.getFoldAt(row, column, 1);
7820
+ if (fold) {
7821
+ this.moveCursorTo(fold.end.row, fold.end.column);
7822
+ return;
7823
+ }
7824
+
7825
+ // first skip space
7826
+ if (match = this.session.nonTokenRe.exec(rightOfCursor)) {
7827
+ column += this.session.nonTokenRe.lastIndex;
7828
+ this.session.nonTokenRe.lastIndex = 0;
7829
+ rightOfCursor = line.substring(column);
7830
+ }
7831
+
7832
+ // if at line end proceed with next line
7833
+ if (column >= line.length) {
7834
+ this.moveCursorTo(row, line.length);
7835
+ this.moveCursorRight();
7836
+ if (row < this.doc.getLength() - 1)
7837
+ this.moveCursorWordRight();
7838
+ return;
7839
+ }
7840
+
7841
+ // advance to the end of the next token
7842
+ if (match = this.session.tokenRe.exec(rightOfCursor)) {
7843
+ column += this.session.tokenRe.lastIndex;
7844
+ this.session.tokenRe.lastIndex = 0;
7845
+ }
7846
+
7847
+ this.moveCursorTo(row, column);
7848
+ };
7849
+
7850
+ this.moveCursorWordLeft = function() {
7851
+ var row = this.selectionLead.row;
7852
+ var column = this.selectionLead.column;
7853
+
7854
+ // skip folds
7855
+ var fold;
7856
+ if (fold = this.session.getFoldAt(row, column, -1)) {
7857
+ this.moveCursorTo(fold.start.row, fold.start.column);
7858
+ return;
7859
+ }
7860
+
7861
+ var str = this.session.getFoldStringAt(row, column, -1);
7862
+ if (str == null) {
7863
+ str = this.doc.getLine(row).substring(0, column)
7864
+ }
7865
+
7866
+ var leftOfCursor = lang.stringReverse(str);
7867
+ var match;
7868
+ this.session.nonTokenRe.lastIndex = 0;
7869
+ this.session.tokenRe.lastIndex = 0;
7870
+
7871
+ // skip whitespace
7872
+ if (match = this.session.nonTokenRe.exec(leftOfCursor)) {
7873
+ column -= this.session.nonTokenRe.lastIndex;
7874
+ leftOfCursor = leftOfCursor.slice(this.session.nonTokenRe.lastIndex);
7875
+ this.session.nonTokenRe.lastIndex = 0;
7876
+ }
7877
+
7878
+ // if at begin of the line proceed in line above
7879
+ if (column <= 0) {
7880
+ this.moveCursorTo(row, 0);
7881
+ this.moveCursorLeft();
7882
+ if (row > 0)
7883
+ this.moveCursorWordLeft();
7884
+ return;
7885
+ }
7886
+
7887
+ // move to the begin of the word
7888
+ if (match = this.session.tokenRe.exec(leftOfCursor)) {
7889
+ column -= this.session.tokenRe.lastIndex;
7890
+ this.session.tokenRe.lastIndex = 0;
7891
+ }
7892
+
7893
+ this.moveCursorTo(row, column);
7894
+ };
7895
+
7896
+ this.moveCursorBy = function(rows, chars) {
7897
+ var screenPos = this.session.documentToScreenPosition(
7898
+ this.selectionLead.row,
7899
+ this.selectionLead.column
7900
+ );
7901
+
7902
+ var screenCol = (chars === 0 && this.$desiredColumn) || screenPos.column;
7903
+ var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenCol);
7904
+
7905
+ // move the cursor and update the desired column
7906
+ this.moveCursorTo(docPos.row, docPos.column + chars, chars === 0);
7907
+ };
7908
+
7909
+ this.moveCursorToPosition = function(position) {
7910
+ this.moveCursorTo(position.row, position.column);
7911
+ };
7912
+
7913
+ this.moveCursorTo = function(row, column, preventUpdateDesiredColumn) {
7914
+ // Ensure the row/column is not inside of a fold.
7915
+ var fold = this.session.getFoldAt(row, column, 1);
7916
+ if (fold) {
7917
+ row = fold.start.row;
7918
+ column = fold.start.column;
7919
+ }
7920
+
7921
+ this.$preventUpdateDesiredColumnOnChange = true;
7922
+ this.selectionLead.setPosition(row, column);
7923
+ this.$preventUpdateDesiredColumnOnChange = false;
7924
+
7925
+ if (!preventUpdateDesiredColumn)
7926
+ this.$updateDesiredColumn(this.selectionLead.column);
7927
+ };
7928
+
7929
+ this.moveCursorToScreen = function(row, column, preventUpdateDesiredColumn) {
7930
+ var pos = this.session.screenToDocumentPosition(row, column);
7931
+ row = pos.row;
7932
+ column = pos.column;
7933
+ this.moveCursorTo(row, column, preventUpdateDesiredColumn);
7934
+ };
7935
+
7936
+ }).call(Selection.prototype);
7937
+
7938
+ exports.Selection = Selection;
7939
+ });
7940
+ /* ***** BEGIN LICENSE BLOCK *****
7941
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
7942
+ *
7943
+ * The contents of this file are subject to the Mozilla Public License Version
7944
+ * 1.1 (the "License"); you may not use this file except in compliance with
7945
+ * the License. You may obtain a copy of the License at
7946
+ * http://www.mozilla.org/MPL/
7947
+ *
7948
+ * Software distributed under the License is distributed on an "AS IS" basis,
7949
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7950
+ * for the specific language governing rights and limitations under the
7951
+ * License.
7952
+ *
7953
+ * The Original Code is Ajax.org Code Editor (ACE).
7954
+ *
7955
+ * The Initial Developer of the Original Code is
7956
+ * Ajax.org B.V.
7957
+ * Portions created by the Initial Developer are Copyright (C) 2010
7958
+ * the Initial Developer. All Rights Reserved.
7959
+ *
7960
+ * Contributor(s):
7961
+ * Fabian Jakobs <fabian AT ajax DOT org>
7962
+ *
7963
+ * Alternatively, the contents of this file may be used under the terms of
7964
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
7965
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
7966
+ * in which case the provisions of the GPL or the LGPL are applicable instead
7967
+ * of those above. If you wish to allow use of your version of this file only
7968
+ * under the terms of either the GPL or the LGPL, and not to allow others to
7969
+ * use your version of this file under the terms of the MPL, indicate your
7970
+ * decision by deleting the provisions above and replace them with the notice
7971
+ * and other provisions required by the GPL or the LGPL. If you do not delete
7972
+ * the provisions above, a recipient may use your version of this file under
7973
+ * the terms of any one of the MPL, the GPL or the LGPL.
7974
+ *
7975
+ * ***** END LICENSE BLOCK ***** */
7976
+
7977
+ ace.define('ace/range', ['require', 'exports', 'module' ], function(require, exports, module) {
7978
+ "use strict";
7979
+
7980
+ var Range = function(startRow, startColumn, endRow, endColumn) {
7981
+ this.start = {
7982
+ row: startRow,
7983
+ column: startColumn
7984
+ };
7985
+
7986
+ this.end = {
7987
+ row: endRow,
7988
+ column: endColumn
7989
+ };
7990
+ };
7991
+
7992
+ (function() {
7993
+ this.isEequal = function(range) {
7994
+ return this.start.row == range.start.row &&
7995
+ this.end.row == range.end.row &&
7996
+ this.start.column == range.start.column &&
7997
+ this.end.column == range.end.column
7998
+ };
7999
+
8000
+ this.toString = function() {
8001
+ return ("Range: [" + this.start.row + "/" + this.start.column +
8002
+ "] -> [" + this.end.row + "/" + this.end.column + "]");
8003
+ };
8004
+
8005
+ this.contains = function(row, column) {
8006
+ return this.compare(row, column) == 0;
8007
+ };
8008
+
8009
+ /**
8010
+ * Compares this range (A) with another range (B), where B is the passed in
8011
+ * range.
8012
+ *
8013
+ * Return values:
8014
+ * -2: (B) is infront of (A) and doesn't intersect with (A)
8015
+ * -1: (B) begins before (A) but ends inside of (A)
8016
+ * 0: (B) is completly inside of (A) OR (A) is complety inside of (B)
8017
+ * +1: (B) begins inside of (A) but ends outside of (A)
8018
+ * +2: (B) is after (A) and doesn't intersect with (A)
8019
+ *
8020
+ * 42: FTW state: (B) ends in (A) but starts outside of (A)
8021
+ */
8022
+ this.compareRange = function(range) {
8023
+ var cmp,
8024
+ end = range.end,
8025
+ start = range.start;
8026
+
8027
+ cmp = this.compare(end.row, end.column);
8028
+ if (cmp == 1) {
8029
+ cmp = this.compare(start.row, start.column);
8030
+ if (cmp == 1) {
8031
+ return 2;
8032
+ } else if (cmp == 0) {
8033
+ return 1;
8034
+ } else {
8035
+ return 0;
8036
+ }
8037
+ } else if (cmp == -1) {
8038
+ return -2;
8039
+ } else {
8040
+ cmp = this.compare(start.row, start.column);
8041
+ if (cmp == -1) {
8042
+ return -1;
8043
+ } else if (cmp == 1) {
8044
+ return 42;
8045
+ } else {
8046
+ return 0;
8047
+ }
8048
+ }
8049
+ }
8050
+
8051
+ this.comparePoint = function(p) {
8052
+ return this.compare(p.row, p.column);
8053
+ }
8054
+
8055
+ this.containsRange = function(range) {
8056
+ return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
8057
+ }
8058
+
8059
+ this.isEnd = function(row, column) {
8060
+ return this.end.row == row && this.end.column == column;
8061
+ }
8062
+
8063
+ this.isStart = function(row, column) {
8064
+ return this.start.row == row && this.start.column == column;
8065
+ }
8066
+
8067
+ this.setStart = function(row, column) {
8068
+ if (typeof row == "object") {
8069
+ this.start.column = row.column;
8070
+ this.start.row = row.row;
8071
+ } else {
8072
+ this.start.row = row;
8073
+ this.start.column = column;
8074
+ }
8075
+ }
8076
+
8077
+ this.setEnd = function(row, column) {
8078
+ if (typeof row == "object") {
8079
+ this.end.column = row.column;
8080
+ this.end.row = row.row;
8081
+ } else {
8082
+ this.end.row = row;
8083
+ this.end.column = column;
8084
+ }
8085
+ }
8086
+
8087
+ this.inside = function(row, column) {
8088
+ if (this.compare(row, column) == 0) {
8089
+ if (this.isEnd(row, column) || this.isStart(row, column)) {
8090
+ return false;
8091
+ } else {
8092
+ return true;
8093
+ }
8094
+ }
8095
+ return false;
8096
+ }
8097
+
8098
+ this.insideStart = function(row, column) {
8099
+ if (this.compare(row, column) == 0) {
8100
+ if (this.isEnd(row, column)) {
8101
+ return false;
8102
+ } else {
8103
+ return true;
8104
+ }
8105
+ }
8106
+ return false;
8107
+ }
8108
+
8109
+ this.insideEnd = function(row, column) {
8110
+ if (this.compare(row, column) == 0) {
8111
+ if (this.isStart(row, column)) {
8112
+ return false;
8113
+ } else {
8114
+ return true;
8115
+ }
8116
+ }
8117
+ return false;
8118
+ }
8119
+
8120
+ this.compare = function(row, column) {
8121
+ if (!this.isMultiLine()) {
8122
+ if (row === this.start.row) {
8123
+ return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
8124
+ };
8125
+ }
8126
+
8127
+ if (row < this.start.row)
8128
+ return -1;
8129
+
8130
+ if (row > this.end.row)
8131
+ return 1;
8132
+
8133
+ if (this.start.row === row)
8134
+ return column >= this.start.column ? 0 : -1;
8135
+
8136
+ if (this.end.row === row)
8137
+ return column <= this.end.column ? 0 : 1;
8138
+
8139
+ return 0;
8140
+ };
8141
+
8142
+ /**
8143
+ * Like .compare(), but if isStart is true, return -1;
8144
+ */
8145
+ this.compareStart = function(row, column) {
8146
+ if (this.start.row == row && this.start.column == column) {
8147
+ return -1;
8148
+ } else {
8149
+ return this.compare(row, column);
8150
+ }
8151
+ }
8152
+
8153
+ /**
8154
+ * Like .compare(), but if isEnd is true, return 1;
8155
+ */
8156
+ this.compareEnd = function(row, column) {
8157
+ if (this.end.row == row && this.end.column == column) {
8158
+ return 1;
8159
+ } else {
8160
+ return this.compare(row, column);
8161
+ }
8162
+ }
8163
+
8164
+ this.compareInside = function(row, column) {
8165
+ if (this.end.row == row && this.end.column == column) {
8166
+ return 1;
8167
+ } else if (this.start.row == row && this.start.column == column) {
8168
+ return -1;
8169
+ } else {
8170
+ return this.compare(row, column);
8171
+ }
8172
+ }
8173
+
8174
+ this.clipRows = function(firstRow, lastRow) {
8175
+ if (this.end.row > lastRow) {
8176
+ var end = {
8177
+ row: lastRow+1,
8178
+ column: 0
8179
+ };
8180
+ }
8181
+
8182
+ if (this.start.row > lastRow) {
8183
+ var start = {
8184
+ row: lastRow+1,
8185
+ column: 0
8186
+ };
8187
+ }
8188
+
8189
+ if (this.start.row < firstRow) {
8190
+ var start = {
8191
+ row: firstRow,
8192
+ column: 0
8193
+ };
8194
+ }
8195
+
8196
+ if (this.end.row < firstRow) {
8197
+ var end = {
8198
+ row: firstRow,
8199
+ column: 0
8200
+ };
8201
+ }
8202
+ return Range.fromPoints(start || this.start, end || this.end);
8203
+ };
8204
+
8205
+ this.extend = function(row, column) {
8206
+ var cmp = this.compare(row, column);
8207
+
8208
+ if (cmp == 0)
8209
+ return this;
8210
+ else if (cmp == -1)
8211
+ var start = {row: row, column: column};
8212
+ else
8213
+ var end = {row: row, column: column};
8214
+
8215
+ return Range.fromPoints(start || this.start, end || this.end);
8216
+ };
8217
+
8218
+ this.isEmpty = function() {
8219
+ return (this.start.row == this.end.row && this.start.column == this.end.column);
8220
+ };
8221
+
8222
+ this.isMultiLine = function() {
8223
+ return (this.start.row !== this.end.row);
8224
+ };
8225
+
8226
+ this.clone = function() {
8227
+ return Range.fromPoints(this.start, this.end);
8228
+ };
8229
+
8230
+ this.collapseRows = function() {
8231
+ if (this.end.column == 0)
8232
+ return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0)
8233
+ else
8234
+ return new Range(this.start.row, 0, this.end.row, 0)
8235
+ };
8236
+
8237
+ this.toScreenRange = function(session) {
8238
+ var screenPosStart =
8239
+ session.documentToScreenPosition(this.start);
8240
+ var screenPosEnd =
8241
+ session.documentToScreenPosition(this.end);
8242
+
8243
+ return new Range(
8244
+ screenPosStart.row, screenPosStart.column,
8245
+ screenPosEnd.row, screenPosEnd.column
8246
+ );
8247
+ };
8248
+
8249
+ }).call(Range.prototype);
8250
+
8251
+
8252
+ Range.fromPoints = function(start, end) {
8253
+ return new Range(start.row, start.column, end.row, end.column);
8254
+ };
8255
+
8256
+ exports.Range = Range;
8257
+ });
8258
+ /* vim:ts=4:sts=4:sw=4:
8259
+ * ***** BEGIN LICENSE BLOCK *****
8260
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
8261
+ *
8262
+ * The contents of this file are subject to the Mozilla Public License Version
8263
+ * 1.1 (the "License"); you may not use this file except in compliance with
8264
+ * the License. You may obtain a copy of the License at
8265
+ * http://www.mozilla.org/MPL/
8266
+ *
8267
+ * Software distributed under the License is distributed on an "AS IS" basis,
8268
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8269
+ * for the specific language governing rights and limitations under the
8270
+ * License.
8271
+ *
8272
+ * The Original Code is Ajax.org Code Editor (ACE).
8273
+ *
8274
+ * The Initial Developer of the Original Code is
8275
+ * Ajax.org B.V.
8276
+ * Portions created by the Initial Developer are Copyright (C) 2010
8277
+ * the Initial Developer. All Rights Reserved.
8278
+ *
8279
+ * Contributor(s):
8280
+ * Fabian Jakobs <fabian AT ajax DOT org>
8281
+ * Mihai Sucan <mihai DOT sucan AT gmail DOT com>
8282
+ * Chris Spencer <chris.ag.spencer AT googlemail DOT com>
8283
+ *
8284
+ * Alternatively, the contents of this file may be used under the terms of
8285
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
8286
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
8287
+ * in which case the provisions of the GPL or the LGPL are applicable instead
8288
+ * of those above. If you wish to allow use of your version of this file only
8289
+ * under the terms of either the GPL or the LGPL, and not to allow others to
8290
+ * use your version of this file under the terms of the MPL, indicate your
8291
+ * decision by deleting the provisions above and replace them with the notice
8292
+ * and other provisions required by the GPL or the LGPL. If you do not delete
8293
+ * the provisions above, a recipient may use your version of this file under
8294
+ * the terms of any one of the MPL, the GPL or the LGPL.
8295
+ *
8296
+ * ***** END LICENSE BLOCK ***** */
8297
+
8298
+ ace.define('ace/mode/text', ['require', 'exports', 'module' , 'ace/tokenizer', 'ace/mode/text_highlight_rules', 'ace/mode/behaviour', 'ace/unicode'], function(require, exports, module) {
8299
+ "use strict";
8300
+
8301
+ var Tokenizer = require("../tokenizer").Tokenizer;
8302
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
8303
+ var Behaviour = require("./behaviour").Behaviour;
8304
+ var unicode = require("../unicode");
8305
+
8306
+ var Mode = function() {
8307
+ this.$tokenizer = new Tokenizer(new TextHighlightRules().getRules());
8308
+ this.$behaviour = new Behaviour();
8309
+ };
8310
+
8311
+ (function() {
8312
+
8313
+ this.tokenRe = new RegExp("^["
8314
+ + unicode.packages.L
8315
+ + unicode.packages.Mn + unicode.packages.Mc
8316
+ + unicode.packages.Nd
8317
+ + unicode.packages.Pc + "\\$_]+", "g"
8318
+ );
8319
+
8320
+ this.nonTokenRe = new RegExp("^(?:[^"
8321
+ + unicode.packages.L
8322
+ + unicode.packages.Mn + unicode.packages.Mc
8323
+ + unicode.packages.Nd
8324
+ + unicode.packages.Pc + "\\$_]|\s])+", "g"
8325
+ );
8326
+
8327
+ this.getTokenizer = function() {
8328
+ return this.$tokenizer;
8329
+ };
8330
+
8331
+ this.toggleCommentLines = function(state, doc, startRow, endRow) {
8332
+ };
8333
+
8334
+ this.getNextLineIndent = function(state, line, tab) {
8335
+ return "";
8336
+ };
8337
+
8338
+ this.checkOutdent = function(state, line, input) {
8339
+ return false;
8340
+ };
8341
+
8342
+ this.autoOutdent = function(state, doc, row) {
8343
+ };
8344
+
8345
+ this.$getIndent = function(line) {
8346
+ var match = line.match(/^(\s+)/);
8347
+ if (match) {
8348
+ return match[1];
8349
+ }
8350
+
8351
+ return "";
8352
+ };
8353
+
8354
+ this.createWorker = function(session) {
8355
+ return null;
8356
+ };
8357
+
8358
+ this.highlightSelection = function(editor) {
8359
+ var session = editor.session;
8360
+ if (!session.$selectionOccurrences)
8361
+ session.$selectionOccurrences = [];
8362
+
8363
+ if (session.$selectionOccurrences.length)
8364
+ this.clearSelectionHighlight(editor);
8365
+
8366
+ var selection = editor.getSelectionRange();
8367
+ if (selection.isEmpty() || selection.isMultiLine())
8368
+ return;
8369
+
8370
+ var startOuter = selection.start.column - 1;
8371
+ var endOuter = selection.end.column + 1;
8372
+ var line = session.getLine(selection.start.row);
8373
+ var lineCols = line.length;
8374
+ var needle = line.substring(Math.max(startOuter, 0),
8375
+ Math.min(endOuter, lineCols));
8376
+
8377
+ // Make sure the outer characters are not part of the word.
8378
+ if ((startOuter >= 0 && /^[\w\d]/.test(needle)) ||
8379
+ (endOuter <= lineCols && /[\w\d]$/.test(needle)))
8380
+ return;
8381
+
8382
+ needle = line.substring(selection.start.column, selection.end.column);
8383
+ if (!/^[\w\d]+$/.test(needle))
8384
+ return;
8385
+
8386
+ var cursor = editor.getCursorPosition();
8387
+
8388
+ var newOptions = {
8389
+ wrap: true,
8390
+ wholeWord: true,
8391
+ caseSensitive: true,
8392
+ needle: needle
8393
+ };
8394
+
8395
+ var currentOptions = editor.$search.getOptions();
8396
+ editor.$search.set(newOptions);
8397
+
8398
+ var ranges = editor.$search.findAll(session);
8399
+ ranges.forEach(function(range) {
8400
+ if (!range.contains(cursor.row, cursor.column)) {
8401
+ var marker = session.addMarker(range, "ace_selected_word", "text");
8402
+ session.$selectionOccurrences.push(marker);
8403
+ }
8404
+ });
8405
+
8406
+ editor.$search.set(currentOptions);
8407
+ };
8408
+
8409
+ this.clearSelectionHighlight = function(editor) {
8410
+ if (!editor.session.$selectionOccurrences)
8411
+ return;
8412
+
8413
+ editor.session.$selectionOccurrences.forEach(function(marker) {
8414
+ editor.session.removeMarker(marker);
8415
+ });
8416
+
8417
+ editor.session.$selectionOccurrences = [];
8418
+ };
8419
+
8420
+ this.createModeDelegates = function (mapping) {
8421
+ if (!this.$embeds) {
8422
+ return;
8423
+ }
8424
+ this.$modes = {};
8425
+ for (var i = 0; i < this.$embeds.length; i++) {
8426
+ if (mapping[this.$embeds[i]]) {
8427
+ this.$modes[this.$embeds[i]] = new mapping[this.$embeds[i]]();
8428
+ }
8429
+ }
8430
+
8431
+ var delegations = ['toggleCommentLines', 'getNextLineIndent', 'checkOutdent', 'autoOutdent', 'transformAction'];
8432
+
8433
+ for (var i = 0; i < delegations.length; i++) {
8434
+ (function(scope) {
8435
+ var functionName = delegations[i];
8436
+ var defaultHandler = scope[functionName];
8437
+ scope[delegations[i]] = function() {
8438
+ return this.$delegator(functionName, arguments, defaultHandler);
8439
+ }
8440
+ } (this));
8441
+ }
8442
+ }
8443
+
8444
+ this.$delegator = function(method, args, defaultHandler) {
8445
+ var state = args[0];
8446
+
8447
+ for (var i = 0; i < this.$embeds.length; i++) {
8448
+ if (!this.$modes[this.$embeds[i]]) continue;
8449
+
8450
+ var split = state.split(this.$embeds[i]);
8451
+ if (!split[0] && split[1]) {
8452
+ args[0] = split[1];
8453
+ var mode = this.$modes[this.$embeds[i]];
8454
+ return mode[method].apply(mode, args);
8455
+ }
8456
+ }
8457
+ var ret = defaultHandler.apply(this, args);
8458
+ return defaultHandler ? ret : undefined;
8459
+ };
8460
+
8461
+ this.transformAction = function(state, action, editor, session, param) {
8462
+ if (this.$behaviour) {
8463
+ var behaviours = this.$behaviour.getBehaviours();
8464
+ for (var key in behaviours) {
8465
+ if (behaviours[key][action]) {
8466
+ var ret = behaviours[key][action].apply(this, arguments);
8467
+ if (ret) {
8468
+ return ret;
8469
+ }
8470
+ }
8471
+ }
8472
+ }
8473
+ }
8474
+
8475
+ }).call(Mode.prototype);
8476
+
8477
+ exports.Mode = Mode;
8478
+ });
8479
+ /* ***** BEGIN LICENSE BLOCK *****
8480
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
8481
+ *
8482
+ * The contents of this file are subject to the Mozilla Public License Version
8483
+ * 1.1 (the "License"); you may not use this file except in compliance with
8484
+ * the License. You may obtain a copy of the License at
8485
+ * http://www.mozilla.org/MPL/
8486
+ *
8487
+ * Software distributed under the License is distributed on an "AS IS" basis,
8488
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8489
+ * for the specific language governing rights and limitations under the
8490
+ * License.
8491
+ *
8492
+ * The Original Code is Ajax.org Code Editor (ACE).
8493
+ *
8494
+ * The Initial Developer of the Original Code is
8495
+ * Ajax.org B.V.
8496
+ * Portions created by the Initial Developer are Copyright (C) 2010
8497
+ * the Initial Developer. All Rights Reserved.
8498
+ *
8499
+ * Contributor(s):
8500
+ * Fabian Jakobs <fabian AT ajax DOT org>
8501
+ *
8502
+ * Alternatively, the contents of this file may be used under the terms of
8503
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
8504
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
8505
+ * in which case the provisions of the GPL or the LGPL are applicable instead
8506
+ * of those above. If you wish to allow use of your version of this file only
8507
+ * under the terms of either the GPL or the LGPL, and not to allow others to
8508
+ * use your version of this file under the terms of the MPL, indicate your
8509
+ * decision by deleting the provisions above and replace them with the notice
8510
+ * and other provisions required by the GPL or the LGPL. If you do not delete
8511
+ * the provisions above, a recipient may use your version of this file under
8512
+ * the terms of any one of the MPL, the GPL or the LGPL.
8513
+ *
8514
+ * ***** END LICENSE BLOCK ***** */
8515
+
8516
+ ace.define('ace/tokenizer', ['require', 'exports', 'module' ], function(require, exports, module) {
8517
+ "use strict";
8518
+
8519
+ var Tokenizer = function(rules, flag) {
8520
+ flag = flag ? "g" + flag : "g";
8521
+ this.rules = rules;
8522
+
8523
+ this.regExps = {};
8524
+ this.matchMappings = {};
8525
+ for ( var key in this.rules) {
8526
+ var rule = this.rules[key];
8527
+ var state = rule;
8528
+ var ruleRegExps = [];
8529
+ var matchTotal = 0;
8530
+ var mapping = this.matchMappings[key] = {};
8531
+
8532
+ for ( var i = 0; i < state.length; i++) {
8533
+
8534
+ if (state[i].regex instanceof RegExp)
8535
+ state[i].regex = state[i].regex.toString().slice(1, -1);
8536
+
8537
+ // Count number of matching groups. 2 extra groups from the full match
8538
+ // And the catch-all on the end (used to force a match);
8539
+ var matchcount = new RegExp("(?:(" + state[i].regex + ")|(.))").exec("a").length - 2;
8540
+
8541
+ // Replace any backreferences and offset appropriately.
8542
+ var adjustedregex = state[i].regex.replace(/\\([0-9]+)/g, function (match, digit) {
8543
+ return "\\" + (parseInt(digit, 10) + matchTotal + 1);
8544
+ });
8545
+
8546
+ if (matchcount > 1 && state[i].token.length !== matchcount-1)
8547
+ throw new Error("Matching groups and length of the token array don't match in rule #" + i + " of state " + key);
8548
+
8549
+ mapping[matchTotal] = {
8550
+ rule: i,
8551
+ len: matchcount
8552
+ };
8553
+ matchTotal += matchcount;
8554
+
8555
+ ruleRegExps.push(adjustedregex);
8556
+ }
8557
+
8558
+ this.regExps[key] = new RegExp("(?:(" + ruleRegExps.join(")|(") + ")|(.))", flag);
8559
+ }
8560
+ };
8561
+
8562
+ (function() {
8563
+
8564
+ this.getLineTokens = function(line, startState) {
8565
+ var currentState = startState;
8566
+ var state = this.rules[currentState];
8567
+ var mapping = this.matchMappings[currentState];
8568
+ var re = this.regExps[currentState];
8569
+ re.lastIndex = 0;
8570
+
8571
+ var match, tokens = [];
8572
+
8573
+ var lastIndex = 0;
8574
+
8575
+ var token = {
8576
+ type: null,
8577
+ value: ""
8578
+ };
8579
+
8580
+ while (match = re.exec(line)) {
8581
+ var type = "text";
8582
+ var rule = null;
8583
+ var value = [match[0]];
8584
+
8585
+ for (var i = 0; i < match.length-2; i++) {
8586
+ if (match[i + 1] === undefined)
8587
+ continue;
8588
+
8589
+ rule = state[mapping[i].rule];
8590
+
8591
+ if (mapping[i].len > 1)
8592
+ value = match.slice(i+2, i+1+mapping[i].len);
8593
+
8594
+ // compute token type
8595
+ if (typeof rule.token == "function")
8596
+ type = rule.token.apply(this, value);
8597
+ else
8598
+ type = rule.token;
8599
+
8600
+ var next = rule.next;
8601
+ if (next && next !== currentState) {
8602
+ currentState = next;
8603
+ state = this.rules[currentState];
8604
+ mapping = this.matchMappings[currentState];
8605
+ lastIndex = re.lastIndex;
8606
+
8607
+ re = this.regExps[currentState];
8608
+ re.lastIndex = lastIndex;
8609
+ }
8610
+ break;
8611
+ }
8612
+
8613
+ if (value[0]) {
8614
+ if (typeof type == "string") {
8615
+ value = [value.join("")];
8616
+ type = [type];
8617
+ }
8618
+ for (var i = 0; i < value.length; i++) {
8619
+ if (!value[i])
8620
+ continue;
8621
+
8622
+ if ((!rule || rule.merge || type[i] === "text") && token.type === type[i]) {
8623
+ token.value += value[i];
8624
+ } else {
8625
+ if (token.type)
8626
+ tokens.push(token);
8627
+
8628
+ token = {
8629
+ type: type[i],
8630
+ value: value[i]
8631
+ };
8632
+ }
8633
+ }
8634
+ }
8635
+
8636
+ if (lastIndex == line.length)
8637
+ break;
8638
+
8639
+ lastIndex = re.lastIndex;
8640
+ }
8641
+
8642
+ if (token.type)
8643
+ tokens.push(token);
8644
+
8645
+ return {
8646
+ tokens : tokens,
8647
+ state : currentState
8648
+ };
8649
+ };
8650
+
8651
+ }).call(Tokenizer.prototype);
8652
+
8653
+ exports.Tokenizer = Tokenizer;
8654
+ });
8655
+ /* ***** BEGIN LICENSE BLOCK *****
8656
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
8657
+ *
8658
+ * The contents of this file are subject to the Mozilla Public License Version
8659
+ * 1.1 (the "License"); you may not use this file except in compliance with
8660
+ * the License. You may obtain a copy of the License at
8661
+ * http://www.mozilla.org/MPL/
8662
+ *
8663
+ * Software distributed under the License is distributed on an "AS IS" basis,
8664
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8665
+ * for the specific language governing rights and limitations under the
8666
+ * License.
8667
+ *
8668
+ * The Original Code is Ajax.org Code Editor (ACE).
8669
+ *
8670
+ * The Initial Developer of the Original Code is
8671
+ * Ajax.org B.V.
8672
+ * Portions created by the Initial Developer are Copyright (C) 2010
8673
+ * the Initial Developer. All Rights Reserved.
8674
+ *
8675
+ * Contributor(s):
8676
+ * Fabian Jakobs <fabian AT ajax DOT org>
8677
+ *
8678
+ * Alternatively, the contents of this file may be used under the terms of
8679
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
8680
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
8681
+ * in which case the provisions of the GPL or the LGPL are applicable instead
8682
+ * of those above. If you wish to allow use of your version of this file only
8683
+ * under the terms of either the GPL or the LGPL, and not to allow others to
8684
+ * use your version of this file under the terms of the MPL, indicate your
8685
+ * decision by deleting the provisions above and replace them with the notice
8686
+ * and other provisions required by the GPL or the LGPL. If you do not delete
8687
+ * the provisions above, a recipient may use your version of this file under
8688
+ * the terms of any one of the MPL, the GPL or the LGPL.
8689
+ *
8690
+ * ***** END LICENSE BLOCK ***** */
8691
+
8692
+ ace.define('ace/mode/text_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/lang'], function(require, exports, module) {
8693
+ "use strict";
8694
+
8695
+ var lang = require("../lib/lang");
8696
+
8697
+ var TextHighlightRules = function() {
8698
+
8699
+ // regexp must not have capturing parentheses
8700
+ // regexps are ordered -> the first match is used
8701
+
8702
+ this.$rules = {
8703
+ "start" : [{
8704
+ token : "empty_line",
8705
+ regex : '^$'
8706
+ }, {
8707
+ token : "text",
8708
+ regex : ".+"
8709
+ }]
8710
+ };
8711
+ };
8712
+
8713
+ (function() {
8714
+
8715
+ this.addRules = function(rules, prefix) {
8716
+ for (var key in rules) {
8717
+ var state = rules[key];
8718
+ for (var i=0; i<state.length; i++) {
8719
+ var rule = state[i];
8720
+ if (rule.next) {
8721
+ rule.next = prefix + rule.next;
8722
+ } else {
8723
+ rule.next = prefix + key;
8724
+ }
8725
+ }
8726
+ this.$rules[prefix + key] = state;
8727
+ }
8728
+ };
8729
+
8730
+ this.getRules = function() {
8731
+ return this.$rules;
8732
+ };
8733
+
8734
+ this.embedRules = function (HighlightRules, prefix, escapeRules, states) {
8735
+ var embedRules = new HighlightRules().getRules();
8736
+ if (states) {
8737
+ for (var i = 0; i < states.length; i++) {
8738
+ states[i] = prefix + states[i];
8739
+ }
8740
+ } else {
8741
+ states = [];
8742
+ for (var key in embedRules) {
8743
+ states.push(prefix + key);
8744
+ }
8745
+ }
8746
+ this.addRules(embedRules, prefix);
8747
+
8748
+ for (var i = 0; i < states.length; i++) {
8749
+ Array.prototype.unshift.apply(this.$rules[states[i]], lang.deepCopy(escapeRules));
8750
+ }
8751
+
8752
+ if (!this.$embeds) {
8753
+ this.$embeds = [];
8754
+ }
8755
+ this.$embeds.push(prefix);
8756
+ }
8757
+
8758
+ this.getEmbeds = function() {
8759
+ return this.$embeds;
8760
+ }
8761
+
8762
+ }).call(TextHighlightRules.prototype);
8763
+
8764
+ exports.TextHighlightRules = TextHighlightRules;
8765
+ });
8766
+ /* vim:ts=4:sts=4:sw=4:
8767
+ * ***** BEGIN LICENSE BLOCK *****
8768
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
8769
+ *
8770
+ * The contents of this file are subject to the Mozilla Public License Version
8771
+ * 1.1 (the "License"); you may not use this file except in compliance with
8772
+ * the License. You may obtain a copy of the License at
8773
+ * http://www.mozilla.org/MPL/
8774
+ *
8775
+ * Software distributed under the License is distributed on an "AS IS" basis,
8776
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8777
+ * for the specific language governing rights and limitations under the
8778
+ * License.
8779
+ *
8780
+ * The Original Code is Ajax.org Code Editor (ACE).
8781
+ *
8782
+ * The Initial Developer of the Original Code is
8783
+ * Ajax.org B.V.
8784
+ * Portions created by the Initial Developer are Copyright (C) 2010
8785
+ * the Initial Developer. All Rights Reserved.
8786
+ *
8787
+ * Contributor(s):
8788
+ * Chris Spencer <chris.ag.spencer AT googlemail DOT com>
8789
+ *
8790
+ * Alternatively, the contents of this file may be used under the terms of
8791
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
8792
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
8793
+ * in which case the provisions of the GPL or the LGPL are applicable instead
8794
+ * of those above. If you wish to allow use of your version of this file only
8795
+ * under the terms of either the GPL or the LGPL, and not to allow others to
8796
+ * use your version of this file under the terms of the MPL, indicate your
8797
+ * decision by deleting the provisions above and replace them with the notice
8798
+ * and other provisions required by the GPL or the LGPL. If you do not delete
8799
+ * the provisions above, a recipient may use your version of this file under
8800
+ * the terms of any one of the MPL, the GPL or the LGPL.
8801
+ *
8802
+ * ***** END LICENSE BLOCK ***** */
8803
+
8804
+ ace.define('ace/mode/behaviour', ['require', 'exports', 'module' ], function(require, exports, module) {
8805
+ "use strict";
8806
+
8807
+ var Behaviour = function() {
8808
+ this.$behaviours = {};
8809
+ };
8810
+
8811
+ (function () {
8812
+
8813
+ this.add = function (name, action, callback) {
8814
+ switch (undefined) {
8815
+ case this.$behaviours:
8816
+ this.$behaviours = {};
8817
+ case this.$behaviours[name]:
8818
+ this.$behaviours[name] = {};
8819
+ }
8820
+ this.$behaviours[name][action] = callback;
8821
+ }
8822
+
8823
+ this.addBehaviours = function (behaviours) {
8824
+ for (var key in behaviours) {
8825
+ for (var action in behaviours[key]) {
8826
+ this.add(key, action, behaviours[key][action]);
8827
+ }
8828
+ }
8829
+ }
8830
+
8831
+ this.remove = function (name) {
8832
+ if (this.$behaviours && this.$behaviours[name]) {
8833
+ delete this.$behaviours[name];
8834
+ }
8835
+ }
8836
+
8837
+ this.inherit = function (mode, filter) {
8838
+ if (typeof mode === "function") {
8839
+ var behaviours = new mode().getBehaviours(filter);
8840
+ } else {
8841
+ var behaviours = mode.getBehaviours(filter);
8842
+ }
8843
+ this.addBehaviours(behaviours);
8844
+ }
8845
+
8846
+ this.getBehaviours = function (filter) {
8847
+ if (!filter) {
8848
+ return this.$behaviours;
8849
+ } else {
8850
+ var ret = {}
8851
+ for (var i = 0; i < filter.length; i++) {
8852
+ if (this.$behaviours[filter[i]]) {
8853
+ ret[filter[i]] = this.$behaviours[filter[i]];
8854
+ }
8855
+ }
8856
+ return ret;
8857
+ }
8858
+ }
8859
+
8860
+ }).call(Behaviour.prototype);
8861
+
8862
+ exports.Behaviour = Behaviour;
8863
+ });ace.define('ace/unicode', ['require', 'exports', 'module' ], function(require, exports, module) {
8864
+ "use strict";
8865
+
8866
+ /*
8867
+ XRegExp Unicode plugin pack: Categories 1.0
8868
+ (c) 2010 Steven Levithan
8869
+ MIT License
8870
+ <http://xregexp.com>
8871
+ Uses the Unicode 5.2 character database
8872
+
8873
+ This package for the XRegExp Unicode plugin enables the following Unicode categories (aka properties):
8874
+
8875
+ L - Letter (the top-level Letter category is included in the Unicode plugin base script)
8876
+ Ll - Lowercase letter
8877
+ Lu - Uppercase letter
8878
+ Lt - Titlecase letter
8879
+ Lm - Modifier letter
8880
+ Lo - Letter without case
8881
+ M - Mark
8882
+ Mn - Non-spacing mark
8883
+ Mc - Spacing combining mark
8884
+ Me - Enclosing mark
8885
+ N - Number
8886
+ Nd - Decimal digit
8887
+ Nl - Letter number
8888
+ No - Other number
8889
+ P - Punctuation
8890
+ Pd - Dash punctuation
8891
+ Ps - Open punctuation
8892
+ Pe - Close punctuation
8893
+ Pi - Initial punctuation
8894
+ Pf - Final punctuation
8895
+ Pc - Connector punctuation
8896
+ Po - Other punctuation
8897
+ S - Symbol
8898
+ Sm - Math symbol
8899
+ Sc - Currency symbol
8900
+ Sk - Modifier symbol
8901
+ So - Other symbol
8902
+ Z - Separator
8903
+ Zs - Space separator
8904
+ Zl - Line separator
8905
+ Zp - Paragraph separator
8906
+ C - Other
8907
+ Cc - Control
8908
+ Cf - Format
8909
+ Co - Private use
8910
+ Cs - Surrogate
8911
+ Cn - Unassigned
8912
+
8913
+ Example usage:
8914
+
8915
+ \p{N}
8916
+ \p{Cn}
8917
+ */
8918
+
8919
+
8920
+ // will be populated by addUnicodePackage
8921
+ exports.packages = {};
8922
+
8923
+ addUnicodePackage({
8924
+ L: "0041-005A0061-007A00AA00B500BA00C0-00D600D8-00F600F8-02C102C6-02D102E0-02E402EC02EE0370-037403760377037A-037D03860388-038A038C038E-03A103A3-03F503F7-0481048A-05250531-055605590561-058705D0-05EA05F0-05F20621-064A066E066F0671-06D306D506E506E606EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA07F407F507FA0800-0815081A082408280904-0939093D09500958-0961097109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E460E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EC60EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10A0-10C510D0-10FA10FC1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317D717DC1820-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541AA71B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C7D1CE9-1CEC1CEE-1CF11D00-1DBF1E00-1F151F18-1F1D1F20-1F451F48-1F4D1F50-1F571F591F5B1F5D1F5F-1F7D1F80-1FB41FB6-1FBC1FBE1FC2-1FC41FC6-1FCC1FD0-1FD31FD6-1FDB1FE0-1FEC1FF2-1FF41FF6-1FFC2071207F2090-209421022107210A-211321152119-211D212421262128212A-212D212F-2139213C-213F2145-2149214E218321842C00-2C2E2C30-2C5E2C60-2CE42CEB-2CEE2D00-2D252D30-2D652D6F2D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE2E2F300530063031-3035303B303C3041-3096309D-309F30A1-30FA30FC-30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A48CA4D0-A4FDA500-A60CA610-A61FA62AA62BA640-A65FA662-A66EA67F-A697A6A0-A6E5A717-A71FA722-A788A78BA78CA7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2A9CFAA00-AA28AA40-AA42AA44-AA4BAA60-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADB-AADDABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB00-FB06FB13-FB17FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF21-FF3AFF41-FF5AFF66-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC",
8925
+ Ll: "0061-007A00AA00B500BA00DF-00F600F8-00FF01010103010501070109010B010D010F01110113011501170119011B011D011F01210123012501270129012B012D012F01310133013501370138013A013C013E014001420144014601480149014B014D014F01510153015501570159015B015D015F01610163016501670169016B016D016F0171017301750177017A017C017E-0180018301850188018C018D019201950199-019B019E01A101A301A501A801AA01AB01AD01B001B401B601B901BA01BD-01BF01C601C901CC01CE01D001D201D401D601D801DA01DC01DD01DF01E101E301E501E701E901EB01ED01EF01F001F301F501F901FB01FD01FF02010203020502070209020B020D020F02110213021502170219021B021D021F02210223022502270229022B022D022F02310233-0239023C023F0240024202470249024B024D024F-02930295-02AF037103730377037B-037D039003AC-03CE03D003D103D5-03D703D903DB03DD03DF03E103E303E503E703E903EB03ED03EF-03F303F503F803FB03FC0430-045F04610463046504670469046B046D046F04710473047504770479047B047D047F0481048B048D048F04910493049504970499049B049D049F04A104A304A504A704A904AB04AD04AF04B104B304B504B704B904BB04BD04BF04C204C404C604C804CA04CC04CE04CF04D104D304D504D704D904DB04DD04DF04E104E304E504E704E904EB04ED04EF04F104F304F504F704F904FB04FD04FF05010503050505070509050B050D050F05110513051505170519051B051D051F0521052305250561-05871D00-1D2B1D62-1D771D79-1D9A1E011E031E051E071E091E0B1E0D1E0F1E111E131E151E171E191E1B1E1D1E1F1E211E231E251E271E291E2B1E2D1E2F1E311E331E351E371E391E3B1E3D1E3F1E411E431E451E471E491E4B1E4D1E4F1E511E531E551E571E591E5B1E5D1E5F1E611E631E651E671E691E6B1E6D1E6F1E711E731E751E771E791E7B1E7D1E7F1E811E831E851E871E891E8B1E8D1E8F1E911E931E95-1E9D1E9F1EA11EA31EA51EA71EA91EAB1EAD1EAF1EB11EB31EB51EB71EB91EBB1EBD1EBF1EC11EC31EC51EC71EC91ECB1ECD1ECF1ED11ED31ED51ED71ED91EDB1EDD1EDF1EE11EE31EE51EE71EE91EEB1EED1EEF1EF11EF31EF51EF71EF91EFB1EFD1EFF-1F071F10-1F151F20-1F271F30-1F371F40-1F451F50-1F571F60-1F671F70-1F7D1F80-1F871F90-1F971FA0-1FA71FB0-1FB41FB61FB71FBE1FC2-1FC41FC61FC71FD0-1FD31FD61FD71FE0-1FE71FF2-1FF41FF61FF7210A210E210F2113212F21342139213C213D2146-2149214E21842C30-2C5E2C612C652C662C682C6A2C6C2C712C732C742C76-2C7C2C812C832C852C872C892C8B2C8D2C8F2C912C932C952C972C992C9B2C9D2C9F2CA12CA32CA52CA72CA92CAB2CAD2CAF2CB12CB32CB52CB72CB92CBB2CBD2CBF2CC12CC32CC52CC72CC92CCB2CCD2CCF2CD12CD32CD52CD72CD92CDB2CDD2CDF2CE12CE32CE42CEC2CEE2D00-2D25A641A643A645A647A649A64BA64DA64FA651A653A655A657A659A65BA65DA65FA663A665A667A669A66BA66DA681A683A685A687A689A68BA68DA68FA691A693A695A697A723A725A727A729A72BA72DA72F-A731A733A735A737A739A73BA73DA73FA741A743A745A747A749A74BA74DA74FA751A753A755A757A759A75BA75DA75FA761A763A765A767A769A76BA76DA76FA771-A778A77AA77CA77FA781A783A785A787A78CFB00-FB06FB13-FB17FF41-FF5A",
8926
+ Lu: "0041-005A00C0-00D600D8-00DE01000102010401060108010A010C010E01100112011401160118011A011C011E01200122012401260128012A012C012E01300132013401360139013B013D013F0141014301450147014A014C014E01500152015401560158015A015C015E01600162016401660168016A016C016E017001720174017601780179017B017D018101820184018601870189-018B018E-0191019301940196-0198019C019D019F01A001A201A401A601A701A901AC01AE01AF01B1-01B301B501B701B801BC01C401C701CA01CD01CF01D101D301D501D701D901DB01DE01E001E201E401E601E801EA01EC01EE01F101F401F6-01F801FA01FC01FE02000202020402060208020A020C020E02100212021402160218021A021C021E02200222022402260228022A022C022E02300232023A023B023D023E02410243-02460248024A024C024E03700372037603860388-038A038C038E038F0391-03A103A3-03AB03CF03D2-03D403D803DA03DC03DE03E003E203E403E603E803EA03EC03EE03F403F703F903FA03FD-042F04600462046404660468046A046C046E04700472047404760478047A047C047E0480048A048C048E04900492049404960498049A049C049E04A004A204A404A604A804AA04AC04AE04B004B204B404B604B804BA04BC04BE04C004C104C304C504C704C904CB04CD04D004D204D404D604D804DA04DC04DE04E004E204E404E604E804EA04EC04EE04F004F204F404F604F804FA04FC04FE05000502050405060508050A050C050E05100512051405160518051A051C051E0520052205240531-055610A0-10C51E001E021E041E061E081E0A1E0C1E0E1E101E121E141E161E181E1A1E1C1E1E1E201E221E241E261E281E2A1E2C1E2E1E301E321E341E361E381E3A1E3C1E3E1E401E421E441E461E481E4A1E4C1E4E1E501E521E541E561E581E5A1E5C1E5E1E601E621E641E661E681E6A1E6C1E6E1E701E721E741E761E781E7A1E7C1E7E1E801E821E841E861E881E8A1E8C1E8E1E901E921E941E9E1EA01EA21EA41EA61EA81EAA1EAC1EAE1EB01EB21EB41EB61EB81EBA1EBC1EBE1EC01EC21EC41EC61EC81ECA1ECC1ECE1ED01ED21ED41ED61ED81EDA1EDC1EDE1EE01EE21EE41EE61EE81EEA1EEC1EEE1EF01EF21EF41EF61EF81EFA1EFC1EFE1F08-1F0F1F18-1F1D1F28-1F2F1F38-1F3F1F48-1F4D1F591F5B1F5D1F5F1F68-1F6F1FB8-1FBB1FC8-1FCB1FD8-1FDB1FE8-1FEC1FF8-1FFB21022107210B-210D2110-211221152119-211D212421262128212A-212D2130-2133213E213F214521832C00-2C2E2C602C62-2C642C672C692C6B2C6D-2C702C722C752C7E-2C802C822C842C862C882C8A2C8C2C8E2C902C922C942C962C982C9A2C9C2C9E2CA02CA22CA42CA62CA82CAA2CAC2CAE2CB02CB22CB42CB62CB82CBA2CBC2CBE2CC02CC22CC42CC62CC82CCA2CCC2CCE2CD02CD22CD42CD62CD82CDA2CDC2CDE2CE02CE22CEB2CEDA640A642A644A646A648A64AA64CA64EA650A652A654A656A658A65AA65CA65EA662A664A666A668A66AA66CA680A682A684A686A688A68AA68CA68EA690A692A694A696A722A724A726A728A72AA72CA72EA732A734A736A738A73AA73CA73EA740A742A744A746A748A74AA74CA74EA750A752A754A756A758A75AA75CA75EA760A762A764A766A768A76AA76CA76EA779A77BA77DA77EA780A782A784A786A78BFF21-FF3A",
8927
+ Lt: "01C501C801CB01F21F88-1F8F1F98-1F9F1FA8-1FAF1FBC1FCC1FFC",
8928
+ Lm: "02B0-02C102C6-02D102E0-02E402EC02EE0374037A0559064006E506E607F407F507FA081A0824082809710E460EC610FC17D718431AA71C78-1C7D1D2C-1D611D781D9B-1DBF2071207F2090-20942C7D2D6F2E2F30053031-3035303B309D309E30FC-30FEA015A4F8-A4FDA60CA67FA717-A71FA770A788A9CFAA70AADDFF70FF9EFF9F",
8929
+ Lo: "01BB01C0-01C3029405D0-05EA05F0-05F20621-063F0641-064A066E066F0671-06D306D506EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA0800-08150904-0939093D09500958-096109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E450E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10D0-10FA1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317DC1820-18421844-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C771CE9-1CEC1CEE-1CF12135-21382D30-2D652D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE3006303C3041-3096309F30A1-30FA30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A014A016-A48CA4D0-A4F7A500-A60BA610-A61FA62AA62BA66EA6A0-A6E5A7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2AA00-AA28AA40-AA42AA44-AA4BAA60-AA6FAA71-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADBAADCABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF66-FF6FFF71-FF9DFFA0-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC",
8930
+ M: "0300-036F0483-04890591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DE-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0903093C093E-094E0951-0955096209630981-098309BC09BE-09C409C709C809CB-09CD09D709E209E30A01-0A030A3C0A3E-0A420A470A480A4B-0A4D0A510A700A710A750A81-0A830ABC0ABE-0AC50AC7-0AC90ACB-0ACD0AE20AE30B01-0B030B3C0B3E-0B440B470B480B4B-0B4D0B560B570B620B630B820BBE-0BC20BC6-0BC80BCA-0BCD0BD70C01-0C030C3E-0C440C46-0C480C4A-0C4D0C550C560C620C630C820C830CBC0CBE-0CC40CC6-0CC80CCA-0CCD0CD50CD60CE20CE30D020D030D3E-0D440D46-0D480D4A-0D4D0D570D620D630D820D830DCA0DCF-0DD40DD60DD8-0DDF0DF20DF30E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F3E0F3F0F71-0F840F860F870F90-0F970F99-0FBC0FC6102B-103E1056-1059105E-10601062-10641067-106D1071-10741082-108D108F109A-109D135F1712-17141732-1734175217531772177317B6-17D317DD180B-180D18A91920-192B1930-193B19B0-19C019C819C91A17-1A1B1A55-1A5E1A60-1A7C1A7F1B00-1B041B34-1B441B6B-1B731B80-1B821BA1-1BAA1C24-1C371CD0-1CD21CD4-1CE81CED1CF21DC0-1DE61DFD-1DFF20D0-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66F-A672A67CA67DA6F0A6F1A802A806A80BA823-A827A880A881A8B4-A8C4A8E0-A8F1A926-A92DA947-A953A980-A983A9B3-A9C0AA29-AA36AA43AA4CAA4DAA7BAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE3-ABEAABECABEDFB1EFE00-FE0FFE20-FE26",
8931
+ Mn: "0300-036F0483-04870591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DF-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0902093C0941-0948094D0951-095509620963098109BC09C1-09C409CD09E209E30A010A020A3C0A410A420A470A480A4B-0A4D0A510A700A710A750A810A820ABC0AC1-0AC50AC70AC80ACD0AE20AE30B010B3C0B3F0B41-0B440B4D0B560B620B630B820BC00BCD0C3E-0C400C46-0C480C4A-0C4D0C550C560C620C630CBC0CBF0CC60CCC0CCD0CE20CE30D41-0D440D4D0D620D630DCA0DD2-0DD40DD60E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F71-0F7E0F80-0F840F860F870F90-0F970F99-0FBC0FC6102D-10301032-10371039103A103D103E10581059105E-10601071-1074108210851086108D109D135F1712-17141732-1734175217531772177317B7-17BD17C617C9-17D317DD180B-180D18A91920-19221927192819321939-193B1A171A181A561A58-1A5E1A601A621A65-1A6C1A73-1A7C1A7F1B00-1B031B341B36-1B3A1B3C1B421B6B-1B731B801B811BA2-1BA51BA81BA91C2C-1C331C361C371CD0-1CD21CD4-1CE01CE2-1CE81CED1DC0-1DE61DFD-1DFF20D0-20DC20E120E5-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66FA67CA67DA6F0A6F1A802A806A80BA825A826A8C4A8E0-A8F1A926-A92DA947-A951A980-A982A9B3A9B6-A9B9A9BCAA29-AA2EAA31AA32AA35AA36AA43AA4CAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE5ABE8ABEDFB1EFE00-FE0FFE20-FE26",
8932
+ Mc: "0903093E-09400949-094C094E0982098309BE-09C009C709C809CB09CC09D70A030A3E-0A400A830ABE-0AC00AC90ACB0ACC0B020B030B3E0B400B470B480B4B0B4C0B570BBE0BBF0BC10BC20BC6-0BC80BCA-0BCC0BD70C01-0C030C41-0C440C820C830CBE0CC0-0CC40CC70CC80CCA0CCB0CD50CD60D020D030D3E-0D400D46-0D480D4A-0D4C0D570D820D830DCF-0DD10DD8-0DDF0DF20DF30F3E0F3F0F7F102B102C10311038103B103C105610571062-10641067-106D108310841087-108C108F109A-109C17B617BE-17C517C717C81923-19261929-192B193019311933-193819B0-19C019C819C91A19-1A1B1A551A571A611A631A641A6D-1A721B041B351B3B1B3D-1B411B431B441B821BA11BA61BA71BAA1C24-1C2B1C341C351CE11CF2A823A824A827A880A881A8B4-A8C3A952A953A983A9B4A9B5A9BAA9BBA9BD-A9C0AA2FAA30AA33AA34AA4DAA7BABE3ABE4ABE6ABE7ABE9ABEAABEC",
8933
+ Me: "0488048906DE20DD-20E020E2-20E4A670-A672",
8934
+ N: "0030-003900B200B300B900BC-00BE0660-066906F0-06F907C0-07C90966-096F09E6-09EF09F4-09F90A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BF20C66-0C6F0C78-0C7E0CE6-0CEF0D66-0D750E50-0E590ED0-0ED90F20-0F331040-10491090-10991369-137C16EE-16F017E0-17E917F0-17F91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C5920702074-20792080-20892150-21822185-21892460-249B24EA-24FF2776-27932CFD30073021-30293038-303A3192-31953220-32293251-325F3280-328932B1-32BFA620-A629A6E6-A6EFA830-A835A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19",
8935
+ Nd: "0030-00390660-066906F0-06F907C0-07C90966-096F09E6-09EF0A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BEF0C66-0C6F0CE6-0CEF0D66-0D6F0E50-0E590ED0-0ED90F20-0F291040-10491090-109917E0-17E91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C59A620-A629A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19",
8936
+ Nl: "16EE-16F02160-21822185-218830073021-30293038-303AA6E6-A6EF",
8937
+ No: "00B200B300B900BC-00BE09F4-09F90BF0-0BF20C78-0C7E0D70-0D750F2A-0F331369-137C17F0-17F920702074-20792080-20892150-215F21892460-249B24EA-24FF2776-27932CFD3192-31953220-32293251-325F3280-328932B1-32BFA830-A835",
8938
+ P: "0021-00230025-002A002C-002F003A003B003F0040005B-005D005F007B007D00A100AB00B700BB00BF037E0387055A-055F0589058A05BE05C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F3A-0F3D0F850FD0-0FD4104A-104F10FB1361-13681400166D166E169B169C16EB-16ED1735173617D4-17D617D8-17DA1800-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD32010-20272030-20432045-20512053-205E207D207E208D208E2329232A2768-277527C527C627E6-27EF2983-299829D8-29DB29FC29FD2CF9-2CFC2CFE2CFF2E00-2E2E2E302E313001-30033008-30113014-301F3030303D30A030FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFD3EFD3FFE10-FE19FE30-FE52FE54-FE61FE63FE68FE6AFE6BFF01-FF03FF05-FF0AFF0C-FF0FFF1AFF1BFF1FFF20FF3B-FF3DFF3FFF5BFF5DFF5F-FF65",
8939
+ Pd: "002D058A05BE140018062010-20152E172E1A301C303030A0FE31FE32FE58FE63FF0D",
8940
+ Ps: "0028005B007B0F3A0F3C169B201A201E2045207D208D23292768276A276C276E27702772277427C527E627E827EA27EC27EE2983298529872989298B298D298F299129932995299729D829DA29FC2E222E242E262E283008300A300C300E3010301430163018301A301DFD3EFE17FE35FE37FE39FE3BFE3DFE3FFE41FE43FE47FE59FE5BFE5DFF08FF3BFF5BFF5FFF62",
8941
+ Pe: "0029005D007D0F3B0F3D169C2046207E208E232A2769276B276D276F27712773277527C627E727E927EB27ED27EF298429862988298A298C298E2990299229942996299829D929DB29FD2E232E252E272E293009300B300D300F3011301530173019301B301E301FFD3FFE18FE36FE38FE3AFE3CFE3EFE40FE42FE44FE48FE5AFE5CFE5EFF09FF3DFF5DFF60FF63",
8942
+ Pi: "00AB2018201B201C201F20392E022E042E092E0C2E1C2E20",
8943
+ Pf: "00BB2019201D203A2E032E052E0A2E0D2E1D2E21",
8944
+ Pc: "005F203F20402054FE33FE34FE4D-FE4FFF3F",
8945
+ Po: "0021-00230025-0027002A002C002E002F003A003B003F0040005C00A100B700BF037E0387055A-055F058905C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F850FD0-0FD4104A-104F10FB1361-1368166D166E16EB-16ED1735173617D4-17D617D8-17DA1800-18051807-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD3201620172020-20272030-2038203B-203E2041-20432047-205120532055-205E2CF9-2CFC2CFE2CFF2E002E012E06-2E082E0B2E0E-2E162E182E192E1B2E1E2E1F2E2A-2E2E2E302E313001-3003303D30FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFE10-FE16FE19FE30FE45FE46FE49-FE4CFE50-FE52FE54-FE57FE5F-FE61FE68FE6AFE6BFF01-FF03FF05-FF07FF0AFF0CFF0EFF0FFF1AFF1BFF1FFF20FF3CFF61FF64FF65",
8946
+ S: "0024002B003C-003E005E0060007C007E00A2-00A900AC00AE-00B100B400B600B800D700F702C2-02C502D2-02DF02E5-02EB02ED02EF-02FF03750384038503F604820606-0608060B060E060F06E906FD06FE07F609F209F309FA09FB0AF10B700BF3-0BFA0C7F0CF10CF20D790E3F0F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-139917DB194019E0-19FF1B61-1B6A1B74-1B7C1FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE20442052207A-207C208A-208C20A0-20B8210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B2140-2144214A-214D214F2190-2328232B-23E82400-24262440-244A249C-24E92500-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE27C0-27C427C7-27CA27CC27D0-27E527F0-29822999-29D729DC-29FB29FE-2B4C2B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F309B309C319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A700-A716A720A721A789A78AA828-A82BA836-A839AA77-AA79FB29FDFCFDFDFE62FE64-FE66FE69FF04FF0BFF1C-FF1EFF3EFF40FF5CFF5EFFE0-FFE6FFE8-FFEEFFFCFFFD",
8947
+ Sm: "002B003C-003E007C007E00AC00B100D700F703F60606-060820442052207A-207C208A-208C2140-2144214B2190-2194219A219B21A021A321A621AE21CE21CF21D221D421F4-22FF2308-230B23202321237C239B-23B323DC-23E125B725C125F8-25FF266F27C0-27C427C7-27CA27CC27D0-27E527F0-27FF2900-29822999-29D729DC-29FB29FE-2AFF2B30-2B442B47-2B4CFB29FE62FE64-FE66FF0BFF1C-FF1EFF5CFF5EFFE2FFE9-FFEC",
8948
+ Sc: "002400A2-00A5060B09F209F309FB0AF10BF90E3F17DB20A0-20B8A838FDFCFE69FF04FFE0FFE1FFE5FFE6",
8949
+ Sk: "005E006000A800AF00B400B802C2-02C502D2-02DF02E5-02EB02ED02EF-02FF0375038403851FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE309B309CA700-A716A720A721A789A78AFF3EFF40FFE3",
8950
+ So: "00A600A700A900AE00B000B60482060E060F06E906FD06FE07F609FA0B700BF3-0BF80BFA0C7F0CF10CF20D790F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-1399194019E0-19FF1B61-1B6A1B74-1B7C210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B214A214C214D214F2195-2199219C-219F21A121A221A421A521A7-21AD21AF-21CD21D021D121D321D5-21F32300-2307230C-231F2322-2328232B-237B237D-239A23B4-23DB23E2-23E82400-24262440-244A249C-24E92500-25B625B8-25C025C2-25F72600-266E2670-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE2800-28FF2B00-2B2F2B452B462B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A828-A82BA836A837A839AA77-AA79FDFDFFE4FFE8FFEDFFEEFFFCFFFD",
8951
+ Z: "002000A01680180E2000-200A20282029202F205F3000",
8952
+ Zs: "002000A01680180E2000-200A202F205F3000",
8953
+ Zl: "2028",
8954
+ Zp: "2029",
8955
+ C: "0000-001F007F-009F00AD03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-0605061C061D0620065F06DD070E070F074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17B417B517DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF200B-200F202A-202E2060-206F20722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-F8FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFD-FF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFFBFFFEFFFF",
8956
+ Cc: "0000-001F007F-009F",
8957
+ Cf: "00AD0600-060306DD070F17B417B5200B-200F202A-202E2060-2064206A-206FFEFFFFF9-FFFB",
8958
+ Co: "E000-F8FF",
8959
+ Cs: "D800-DFFF",
8960
+ Cn: "03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-05FF06040605061C061D0620065F070E074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF2065-206920722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-D7FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFDFEFEFF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFF8FFFEFFFF"
8961
+ });
8962
+
8963
+ function addUnicodePackage (pack) {
8964
+ var codePoint = /\w{4}/g;
8965
+ for (var name in pack)
8966
+ exports.packages[name] = pack[name].replace(codePoint, "\\u$&");
8967
+ };
8968
+
8969
+ });/* ***** BEGIN LICENSE BLOCK *****
8970
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
8971
+ *
8972
+ * The contents of this file are subject to the Mozilla Public License Version
8973
+ * 1.1 (the "License"); you may not use this file except in compliance with
8974
+ * the License. You may obtain a copy of the License at
8975
+ * http://www.mozilla.org/MPL/
8976
+ *
8977
+ * Software distributed under the License is distributed on an "AS IS" basis,
8978
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8979
+ * for the specific language governing rights and limitations under the
8980
+ * License.
8981
+ *
8982
+ * The Original Code is Ajax.org Code Editor (ACE).
8983
+ *
8984
+ * The Initial Developer of the Original Code is
8985
+ * Ajax.org B.V.
8986
+ * Portions created by the Initial Developer are Copyright (C) 2010
8987
+ * the Initial Developer. All Rights Reserved.
8988
+ *
8989
+ * Contributor(s):
8990
+ * Fabian Jakobs <fabian AT ajax DOT org>
8991
+ *
8992
+ * Alternatively, the contents of this file may be used under the terms of
8993
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
8994
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
8995
+ * in which case the provisions of the GPL or the LGPL are applicable instead
8996
+ * of those above. If you wish to allow use of your version of this file only
8997
+ * under the terms of either the GPL or the LGPL, and not to allow others to
8998
+ * use your version of this file under the terms of the MPL, indicate your
8999
+ * decision by deleting the provisions above and replace them with the notice
9000
+ * and other provisions required by the GPL or the LGPL. If you do not delete
9001
+ * the provisions above, a recipient may use your version of this file under
9002
+ * the terms of any one of the MPL, the GPL or the LGPL.
9003
+ *
9004
+ * ***** END LICENSE BLOCK ***** */
9005
+
9006
+ ace.define('ace/document', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter', 'ace/range', 'ace/anchor'], function(require, exports, module) {
9007
+ "use strict";
9008
+
9009
+ var oop = require("./lib/oop");
9010
+ var EventEmitter = require("./lib/event_emitter").EventEmitter;
9011
+ var Range = require("./range").Range;
9012
+ var Anchor = require("./anchor").Anchor;
9013
+
9014
+ var Document = function(text) {
9015
+ this.$lines = [];
9016
+
9017
+ if (Array.isArray(text)) {
9018
+ this.insertLines(0, text);
9019
+ }
9020
+ // There has to be one line at least in the document. If you pass an empty
9021
+ // string to the insert function, nothing will happen. Workaround.
9022
+ else if (text.length == 0) {
9023
+ this.$lines = [""];
9024
+ } else {
9025
+ this.insert({row: 0, column:0}, text);
9026
+ }
9027
+ };
9028
+
9029
+ (function() {
9030
+
9031
+ oop.implement(this, EventEmitter);
9032
+
9033
+ this.setValue = function(text) {
9034
+ var len = this.getLength();
9035
+ this.remove(new Range(0, 0, len, this.getLine(len-1).length));
9036
+ this.insert({row: 0, column:0}, text);
9037
+ };
9038
+
9039
+ this.getValue = function() {
9040
+ return this.getAllLines().join(this.getNewLineCharacter());
9041
+ };
9042
+
9043
+ this.createAnchor = function(row, column) {
9044
+ return new Anchor(this, row, column);
9045
+ };
9046
+
9047
+ // check for IE split bug
9048
+ if ("aaa".split(/a/).length == 0)
9049
+ this.$split = function(text) {
9050
+ return text.replace(/\r\n|\r/g, "\n").split("\n");
9051
+ }
9052
+ else
9053
+ this.$split = function(text) {
9054
+ return text.split(/\r\n|\r|\n/);
9055
+ };
9056
+
9057
+
9058
+ this.$detectNewLine = function(text) {
9059
+ var match = text.match(/^.*?(\r\n|\r|\n)/m);
9060
+ if (match) {
9061
+ this.$autoNewLine = match[1];
9062
+ } else {
9063
+ this.$autoNewLine = "\n";
9064
+ }
9065
+ };
9066
+
9067
+ this.getNewLineCharacter = function() {
9068
+ switch (this.$newLineMode) {
9069
+ case "windows":
9070
+ return "\r\n";
9071
+
9072
+ case "unix":
9073
+ return "\n";
9074
+
9075
+ case "auto":
9076
+ return this.$autoNewLine;
9077
+ }
9078
+ };
9079
+
9080
+ this.$autoNewLine = "\n";
9081
+ this.$newLineMode = "auto";
9082
+ this.setNewLineMode = function(newLineMode) {
9083
+ if (this.$newLineMode === newLineMode)
9084
+ return;
9085
+
9086
+ this.$newLineMode = newLineMode;
9087
+ };
9088
+
9089
+ this.getNewLineMode = function() {
9090
+ return this.$newLineMode;
9091
+ };
9092
+
9093
+ this.isNewLine = function(text) {
9094
+ return (text == "\r\n" || text == "\r" || text == "\n");
9095
+ };
9096
+
9097
+ /**
9098
+ * Get a verbatim copy of the given line as it is in the document
9099
+ */
9100
+ this.getLine = function(row) {
9101
+ return this.$lines[row] || "";
9102
+ };
9103
+
9104
+ this.getLines = function(firstRow, lastRow) {
9105
+ return this.$lines.slice(firstRow, lastRow + 1);
9106
+ };
9107
+
9108
+ /**
9109
+ * Returns all lines in the document as string array. Warning: The caller
9110
+ * should not modify this array!
9111
+ */
9112
+ this.getAllLines = function() {
9113
+ return this.getLines(0, this.getLength());
9114
+ };
9115
+
9116
+ this.getLength = function() {
9117
+ return this.$lines.length;
9118
+ };
9119
+
9120
+ this.getTextRange = function(range) {
9121
+ if (range.start.row == range.end.row) {
9122
+ return this.$lines[range.start.row].substring(range.start.column,
9123
+ range.end.column);
9124
+ }
9125
+ else {
9126
+ var lines = [];
9127
+ lines.push(this.$lines[range.start.row].substring(range.start.column));
9128
+ lines.push.apply(lines, this.getLines(range.start.row+1, range.end.row-1));
9129
+ lines.push(this.$lines[range.end.row].substring(0, range.end.column));
9130
+ return lines.join(this.getNewLineCharacter());
9131
+ }
9132
+ };
9133
+
9134
+ this.$clipPosition = function(position) {
9135
+ var length = this.getLength();
9136
+ if (position.row >= length) {
9137
+ position.row = Math.max(0, length - 1);
9138
+ position.column = this.getLine(length-1).length;
9139
+ }
9140
+ return position;
9141
+ };
9142
+
9143
+ this.insert = function(position, text) {
9144
+ if (!text || text.length === 0)
9145
+ return position;
9146
+
9147
+ position = this.$clipPosition(position);
9148
+
9149
+ // only detect new lines if the document has no line break yet
9150
+ if (this.getLength() <= 1)
9151
+ this.$detectNewLine(text);
9152
+
9153
+ var lines = this.$split(text);
9154
+ var firstLine = lines.splice(0, 1)[0];
9155
+ var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0];
9156
+
9157
+ position = this.insertInLine(position, firstLine);
9158
+ if (lastLine !== null) {
9159
+ position = this.insertNewLine(position); // terminate first line
9160
+ position = this.insertLines(position.row, lines);
9161
+ position = this.insertInLine(position, lastLine || "");
9162
+ }
9163
+ return position;
9164
+ };
9165
+
9166
+ this.insertLines = function(row, lines) {
9167
+ if (lines.length == 0)
9168
+ return {row: row, column: 0};
9169
+
9170
+ var args = [row, 0];
9171
+ args.push.apply(args, lines);
9172
+ this.$lines.splice.apply(this.$lines, args);
9173
+
9174
+ var range = new Range(row, 0, row + lines.length, 0);
9175
+ var delta = {
9176
+ action: "insertLines",
9177
+ range: range,
9178
+ lines: lines
9179
+ };
9180
+ this._emit("change", { data: delta });
9181
+ return range.end;
9182
+ };
9183
+
9184
+ this.insertNewLine = function(position) {
9185
+ position = this.$clipPosition(position);
9186
+ var line = this.$lines[position.row] || "";
9187
+
9188
+ this.$lines[position.row] = line.substring(0, position.column);
9189
+ this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length));
9190
+
9191
+ var end = {
9192
+ row : position.row + 1,
9193
+ column : 0
9194
+ };
9195
+
9196
+ var delta = {
9197
+ action: "insertText",
9198
+ range: Range.fromPoints(position, end),
9199
+ text: this.getNewLineCharacter()
9200
+ };
9201
+ this._emit("change", { data: delta });
9202
+
9203
+ return end;
9204
+ };
9205
+
9206
+ this.insertInLine = function(position, text) {
9207
+ if (text.length == 0)
9208
+ return position;
9209
+
9210
+ var line = this.$lines[position.row] || "";
9211
+
9212
+ this.$lines[position.row] = line.substring(0, position.column) + text
9213
+ + line.substring(position.column);
9214
+
9215
+ var end = {
9216
+ row : position.row,
9217
+ column : position.column + text.length
9218
+ };
9219
+
9220
+ var delta = {
9221
+ action: "insertText",
9222
+ range: Range.fromPoints(position, end),
9223
+ text: text
9224
+ };
9225
+ this._emit("change", { data: delta });
9226
+
9227
+ return end;
9228
+ };
9229
+
9230
+ this.remove = function(range) {
9231
+ // clip to document
9232
+ range.start = this.$clipPosition(range.start);
9233
+ range.end = this.$clipPosition(range.end);
9234
+
9235
+ if (range.isEmpty())
9236
+ return range.start;
9237
+
9238
+ var firstRow = range.start.row;
9239
+ var lastRow = range.end.row;
9240
+
9241
+ if (range.isMultiLine()) {
9242
+ var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1;
9243
+ var lastFullRow = lastRow - 1;
9244
+
9245
+ if (range.end.column > 0)
9246
+ this.removeInLine(lastRow, 0, range.end.column);
9247
+
9248
+ if (lastFullRow >= firstFullRow)
9249
+ this.removeLines(firstFullRow, lastFullRow);
9250
+
9251
+ if (firstFullRow != firstRow) {
9252
+ this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length);
9253
+ this.removeNewLine(range.start.row);
9254
+ }
9255
+ }
9256
+ else {
9257
+ this.removeInLine(firstRow, range.start.column, range.end.column);
9258
+ }
9259
+ return range.start;
9260
+ };
9261
+
9262
+ this.removeInLine = function(row, startColumn, endColumn) {
9263
+ if (startColumn == endColumn)
9264
+ return;
9265
+
9266
+ var range = new Range(row, startColumn, row, endColumn);
9267
+ var line = this.getLine(row);
9268
+ var removed = line.substring(startColumn, endColumn);
9269
+ var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length);
9270
+ this.$lines.splice(row, 1, newLine);
9271
+
9272
+ var delta = {
9273
+ action: "removeText",
9274
+ range: range,
9275
+ text: removed
9276
+ };
9277
+ this._emit("change", { data: delta });
9278
+ return range.start;
9279
+ };
9280
+
9281
+ /**
9282
+ * Removes a range of full lines
9283
+ *
9284
+ * @param firstRow {Integer} The first row to be removed
9285
+ * @param lastRow {Integer} The last row to be removed
9286
+ * @return {String[]} The removed lines
9287
+ */
9288
+ this.removeLines = function(firstRow, lastRow) {
9289
+ var range = new Range(firstRow, 0, lastRow + 1, 0);
9290
+ var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1);
9291
+
9292
+ var delta = {
9293
+ action: "removeLines",
9294
+ range: range,
9295
+ nl: this.getNewLineCharacter(),
9296
+ lines: removed
9297
+ };
9298
+ this._emit("change", { data: delta });
9299
+ return removed;
9300
+ };
9301
+
9302
+ this.removeNewLine = function(row) {
9303
+ var firstLine = this.getLine(row);
9304
+ var secondLine = this.getLine(row+1);
9305
+
9306
+ var range = new Range(row, firstLine.length, row+1, 0);
9307
+ var line = firstLine + secondLine;
9308
+
9309
+ this.$lines.splice(row, 2, line);
9310
+
9311
+ var delta = {
9312
+ action: "removeText",
9313
+ range: range,
9314
+ text: this.getNewLineCharacter()
9315
+ };
9316
+ this._emit("change", { data: delta });
9317
+ };
9318
+
9319
+ this.replace = function(range, text) {
9320
+ if (text.length == 0 && range.isEmpty())
9321
+ return range.start;
9322
+
9323
+ // Shortcut: If the text we want to insert is the same as it is already
9324
+ // in the document, we don't have to replace anything.
9325
+ if (text == this.getTextRange(range))
9326
+ return range.end;
9327
+
9328
+ this.remove(range);
9329
+ if (text) {
9330
+ var end = this.insert(range.start, text);
9331
+ }
9332
+ else {
9333
+ end = range.start;
9334
+ }
9335
+
9336
+ return end;
9337
+ };
9338
+
9339
+ this.applyDeltas = function(deltas) {
9340
+ for (var i=0; i<deltas.length; i++) {
9341
+ var delta = deltas[i];
9342
+ var range = Range.fromPoints(delta.range.start, delta.range.end);
9343
+
9344
+ if (delta.action == "insertLines")
9345
+ this.insertLines(range.start.row, delta.lines);
9346
+ else if (delta.action == "insertText")
9347
+ this.insert(range.start, delta.text);
9348
+ else if (delta.action == "removeLines")
9349
+ this.removeLines(range.start.row, range.end.row - 1);
9350
+ else if (delta.action == "removeText")
9351
+ this.remove(range);
9352
+ }
9353
+ };
9354
+
9355
+ this.revertDeltas = function(deltas) {
9356
+ for (var i=deltas.length-1; i>=0; i--) {
9357
+ var delta = deltas[i];
9358
+
9359
+ var range = Range.fromPoints(delta.range.start, delta.range.end);
9360
+
9361
+ if (delta.action == "insertLines")
9362
+ this.removeLines(range.start.row, range.end.row - 1);
9363
+ else if (delta.action == "insertText")
9364
+ this.remove(range);
9365
+ else if (delta.action == "removeLines")
9366
+ this.insertLines(range.start.row, delta.lines);
9367
+ else if (delta.action == "removeText")
9368
+ this.insert(range.start, delta.text);
9369
+ }
9370
+ };
9371
+
9372
+ }).call(Document.prototype);
9373
+
9374
+ exports.Document = Document;
9375
+ });
9376
+ /* ***** BEGIN LICENSE BLOCK *****
9377
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
9378
+ *
9379
+ * The contents of this file are subject to the Mozilla Public License Version
9380
+ * 1.1 (the "License"); you may not use this file except in compliance with
9381
+ * the License. You may obtain a copy of the License at
9382
+ * http://www.mozilla.org/MPL/
9383
+ *
9384
+ * Software distributed under the License is distributed on an "AS IS" basis,
9385
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9386
+ * for the specific language governing rights and limitations under the
9387
+ * License.
9388
+ *
9389
+ * The Original Code is Ajax.org Code Editor (ACE).
9390
+ *
9391
+ * The Initial Developer of the Original Code is
9392
+ * Ajax.org B.V.
9393
+ * Portions created by the Initial Developer are Copyright (C) 2010
9394
+ * the Initial Developer. All Rights Reserved.
9395
+ *
9396
+ * Contributor(s):
9397
+ * Fabian Jakobs <fabian AT ajax DOT org>
9398
+ *
9399
+ * Alternatively, the contents of this file may be used under the terms of
9400
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
9401
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
9402
+ * in which case the provisions of the GPL or the LGPL are applicable instead
9403
+ * of those above. If you wish to allow use of your version of this file only
9404
+ * under the terms of either the GPL or the LGPL, and not to allow others to
9405
+ * use your version of this file under the terms of the MPL, indicate your
9406
+ * decision by deleting the provisions above and replace them with the notice
9407
+ * and other provisions required by the GPL or the LGPL. If you do not delete
9408
+ * the provisions above, a recipient may use your version of this file under
9409
+ * the terms of any one of the MPL, the GPL or the LGPL.
9410
+ *
9411
+ * ***** END LICENSE BLOCK ***** */
9412
+
9413
+ ace.define('ace/anchor', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) {
9414
+ "use strict";
9415
+
9416
+ var oop = require("./lib/oop");
9417
+ var EventEmitter = require("./lib/event_emitter").EventEmitter;
9418
+
9419
+ /**
9420
+ * An Anchor is a floating pointer in the document. Whenever text is inserted or
9421
+ * deleted before the cursor, the position of the cursor is updated
9422
+ */
9423
+ var Anchor = exports.Anchor = function(doc, row, column) {
9424
+ this.document = doc;
9425
+
9426
+ if (typeof column == "undefined")
9427
+ this.setPosition(row.row, row.column);
9428
+ else
9429
+ this.setPosition(row, column);
9430
+
9431
+ this.$onChange = this.onChange.bind(this);
9432
+ doc.on("change", this.$onChange);
9433
+ };
9434
+
9435
+ (function() {
9436
+
9437
+ oop.implement(this, EventEmitter);
9438
+
9439
+ this.getPosition = function() {
9440
+ return this.$clipPositionToDocument(this.row, this.column);
9441
+ };
9442
+
9443
+ this.getDocument = function() {
9444
+ return this.document;
9445
+ };
9446
+
9447
+ this.onChange = function(e) {
9448
+ var delta = e.data;
9449
+ var range = delta.range;
9450
+
9451
+ if (range.start.row == range.end.row && range.start.row != this.row)
9452
+ return;
9453
+
9454
+ if (range.start.row > this.row)
9455
+ return;
9456
+
9457
+ if (range.start.row == this.row && range.start.column > this.column)
9458
+ return;
9459
+
9460
+ var row = this.row;
9461
+ var column = this.column;
9462
+
9463
+ if (delta.action === "insertText") {
9464
+ if (range.start.row === row && range.start.column <= column) {
9465
+ if (range.start.row === range.end.row) {
9466
+ column += range.end.column - range.start.column;
9467
+ }
9468
+ else {
9469
+ column -= range.start.column;
9470
+ row += range.end.row - range.start.row;
9471
+ }
9472
+ }
9473
+ else if (range.start.row !== range.end.row && range.start.row < row) {
9474
+ row += range.end.row - range.start.row;
9475
+ }
9476
+ } else if (delta.action === "insertLines") {
9477
+ if (range.start.row <= row) {
9478
+ row += range.end.row - range.start.row;
9479
+ }
9480
+ }
9481
+ else if (delta.action == "removeText") {
9482
+ if (range.start.row == row && range.start.column < column) {
9483
+ if (range.end.column >= column)
9484
+ column = range.start.column;
9485
+ else
9486
+ column = Math.max(0, column - (range.end.column - range.start.column));
9487
+
9488
+ } else if (range.start.row !== range.end.row && range.start.row < row) {
9489
+ if (range.end.row == row) {
9490
+ column = Math.max(0, column - range.end.column) + range.start.column;
9491
+ }
9492
+ row -= (range.end.row - range.start.row);
9493
+ }
9494
+ else if (range.end.row == row) {
9495
+ row -= range.end.row - range.start.row;
9496
+ column = Math.max(0, column - range.end.column) + range.start.column;
9497
+ }
9498
+ } else if (delta.action == "removeLines") {
9499
+ if (range.start.row <= row) {
9500
+ if (range.end.row <= row)
9501
+ row -= range.end.row - range.start.row;
9502
+ else {
9503
+ row = range.start.row;
9504
+ column = 0;
9505
+ }
9506
+ }
9507
+ }
9508
+
9509
+ this.setPosition(row, column, true);
9510
+ };
9511
+
9512
+ this.setPosition = function(row, column, noClip) {
9513
+ var pos;
9514
+ if (noClip) {
9515
+ pos = {
9516
+ row: row,
9517
+ column: column
9518
+ };
9519
+ }
9520
+ else {
9521
+ pos = this.$clipPositionToDocument(row, column);
9522
+ }
9523
+
9524
+ if (this.row == pos.row && this.column == pos.column)
9525
+ return;
9526
+
9527
+ var old = {
9528
+ row: this.row,
9529
+ column: this.column
9530
+ };
9531
+
9532
+ this.row = pos.row;
9533
+ this.column = pos.column;
9534
+ this._emit("change", {
9535
+ old: old,
9536
+ value: pos
9537
+ });
9538
+ };
9539
+
9540
+ this.detach = function() {
9541
+ this.document.removeEventListener("change", this.$onChange);
9542
+ };
9543
+
9544
+ this.$clipPositionToDocument = function(row, column) {
9545
+ var pos = {};
9546
+
9547
+ if (row >= this.document.getLength()) {
9548
+ pos.row = Math.max(0, this.document.getLength() - 1);
9549
+ pos.column = this.document.getLine(pos.row).length;
9550
+ }
9551
+ else if (row < 0) {
9552
+ pos.row = 0;
9553
+ pos.column = 0;
9554
+ }
9555
+ else {
9556
+ pos.row = row;
9557
+ pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
9558
+ }
9559
+
9560
+ if (column < 0)
9561
+ pos.column = 0;
9562
+
9563
+ return pos;
9564
+ };
9565
+
9566
+ }).call(Anchor.prototype);
9567
+
9568
+ });
9569
+ /* ***** BEGIN LICENSE BLOCK *****
9570
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
9571
+ *
9572
+ * The contents of this file are subject to the Mozilla Public License Version
9573
+ * 1.1 (the "License"); you may not use this file except in compliance with
9574
+ * the License. You may obtain a copy of the License at
9575
+ * http://www.mozilla.org/MPL/
9576
+ *
9577
+ * Software distributed under the License is distributed on an "AS IS" basis,
9578
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9579
+ * for the specific language governing rights and limitations under the
9580
+ * License.
9581
+ *
9582
+ * The Original Code is Ajax.org Code Editor (ACE).
9583
+ *
9584
+ * The Initial Developer of the Original Code is
9585
+ * Ajax.org B.V.
9586
+ * Portions created by the Initial Developer are Copyright (C) 2010
9587
+ * the Initial Developer. All Rights Reserved.
9588
+ *
9589
+ * Contributor(s):
9590
+ * Fabian Jakobs <fabian AT ajax DOT org>
9591
+ *
9592
+ * Alternatively, the contents of this file may be used under the terms of
9593
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
9594
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
9595
+ * in which case the provisions of the GPL or the LGPL are applicable instead
9596
+ * of those above. If you wish to allow use of your version of this file only
9597
+ * under the terms of either the GPL or the LGPL, and not to allow others to
9598
+ * use your version of this file under the terms of the MPL, indicate your
9599
+ * decision by deleting the provisions above and replace them with the notice
9600
+ * and other provisions required by the GPL or the LGPL. If you do not delete
9601
+ * the provisions above, a recipient may use your version of this file under
9602
+ * the terms of any one of the MPL, the GPL or the LGPL.
9603
+ *
9604
+ * ***** END LICENSE BLOCK ***** */
9605
+
9606
+ ace.define('ace/background_tokenizer', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) {
9607
+ "use strict";
9608
+
9609
+ var oop = require("./lib/oop");
9610
+ var EventEmitter = require("./lib/event_emitter").EventEmitter;
9611
+
9612
+ var BackgroundTokenizer = function(tokenizer, editor) {
9613
+ this.running = false;
9614
+ this.lines = [];
9615
+ this.currentLine = 0;
9616
+ this.tokenizer = tokenizer;
9617
+
9618
+ var self = this;
9619
+
9620
+ this.$worker = function() {
9621
+ if (!self.running) { return; }
9622
+
9623
+ var workerStart = new Date();
9624
+ var startLine = self.currentLine;
9625
+ var doc = self.doc;
9626
+
9627
+ var processedLines = 0;
9628
+
9629
+ var len = doc.getLength();
9630
+ while (self.currentLine < len) {
9631
+ self.lines[self.currentLine] = self.$tokenizeRows(self.currentLine, self.currentLine)[0];
9632
+ self.currentLine++;
9633
+
9634
+ // only check every 5 lines
9635
+ processedLines += 1;
9636
+ if ((processedLines % 5 == 0) && (new Date() - workerStart) > 20) {
9637
+ self.fireUpdateEvent(startLine, self.currentLine-1);
9638
+ self.running = setTimeout(self.$worker, 20);
9639
+ return;
9640
+ }
9641
+ }
9642
+
9643
+ self.running = false;
9644
+
9645
+ self.fireUpdateEvent(startLine, len - 1);
9646
+ };
9647
+ };
9648
+
9649
+ (function(){
9650
+
9651
+ oop.implement(this, EventEmitter);
9652
+
9653
+ this.setTokenizer = function(tokenizer) {
9654
+ this.tokenizer = tokenizer;
9655
+ this.lines = [];
9656
+
9657
+ this.start(0);
9658
+ };
9659
+
9660
+ this.setDocument = function(doc) {
9661
+ this.doc = doc;
9662
+ this.lines = [];
9663
+
9664
+ this.stop();
9665
+ };
9666
+
9667
+ this.fireUpdateEvent = function(firstRow, lastRow) {
9668
+ var data = {
9669
+ first: firstRow,
9670
+ last: lastRow
9671
+ };
9672
+ this._emit("update", {data: data});
9673
+ };
9674
+
9675
+ this.start = function(startRow) {
9676
+ this.currentLine = Math.min(startRow || 0, this.currentLine,
9677
+ this.doc.getLength());
9678
+
9679
+ // remove all cached items below this line
9680
+ this.lines.splice(this.currentLine, this.lines.length);
9681
+
9682
+ this.stop();
9683
+ // pretty long delay to prevent the tokenizer from interfering with the user
9684
+ this.running = setTimeout(this.$worker, 700);
9685
+ };
9686
+
9687
+ this.stop = function() {
9688
+ if (this.running)
9689
+ clearTimeout(this.running);
9690
+ this.running = false;
9691
+ };
9692
+
9693
+ this.getTokens = function(firstRow, lastRow) {
9694
+ return this.$tokenizeRows(firstRow, lastRow);
9695
+ };
9696
+
9697
+ this.getState = function(row) {
9698
+ return this.$tokenizeRows(row, row)[0].state;
9699
+ };
9700
+
9701
+ this.$tokenizeRows = function(firstRow, lastRow) {
9702
+ if (!this.doc || isNaN(firstRow) || isNaN(lastRow))
9703
+ return [{'state':'start','tokens':[]}];
9704
+
9705
+ var rows = [];
9706
+
9707
+ // determine start state
9708
+ var state = "start";
9709
+ var doCache = false;
9710
+ if (firstRow > 0 && this.lines[firstRow - 1]) {
9711
+ state = this.lines[firstRow - 1].state;
9712
+ doCache = true;
9713
+ } else if (firstRow == 0) {
9714
+ state = "start";
9715
+ doCache = true;
9716
+ } else if (this.lines.length > 0) {
9717
+ // Guess that we haven't changed state.
9718
+ state = this.lines[this.lines.length-1].state;
9719
+ }
9720
+
9721
+ var lines = this.doc.getLines(firstRow, lastRow);
9722
+ for (var row=firstRow; row<=lastRow; row++) {
9723
+ if (!this.lines[row]) {
9724
+ var tokens = this.tokenizer.getLineTokens(lines[row-firstRow] || "", state);
9725
+ var state = tokens.state;
9726
+ rows.push(tokens);
9727
+
9728
+ if (doCache) {
9729
+ this.lines[row] = tokens;
9730
+ }
9731
+ }
9732
+ else {
9733
+ var tokens = this.lines[row];
9734
+ state = tokens.state;
9735
+ rows.push(tokens);
9736
+ }
9737
+ }
9738
+ return rows;
9739
+ };
9740
+
9741
+ }).call(BackgroundTokenizer.prototype);
9742
+
9743
+ exports.BackgroundTokenizer = BackgroundTokenizer;
9744
+ });
9745
+ /* vim:ts=4:sts=4:sw=4:
9746
+ * ***** BEGIN LICENSE BLOCK *****
9747
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
9748
+ *
9749
+ * The contents of this file are subject to the Mozilla Public License Version
9750
+ * 1.1 (the "License"); you may not use this file except in compliance with
9751
+ * the License. You may obtain a copy of the License at
9752
+ * http://www.mozilla.org/MPL/
9753
+ *
9754
+ * Software distributed under the License is distributed on an "AS IS" basis,
9755
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
9756
+ * for the specific language governing rights and limitations under the
9757
+ * License.
9758
+ *
9759
+ * The Original Code is Ajax.org Code Editor (ACE).
9760
+ *
9761
+ * The Initial Developer of the Original Code is
9762
+ * Ajax.org B.V.
9763
+ * Portions created by the Initial Developer are Copyright (C) 2010
9764
+ * the Initial Developer. All Rights Reserved.
9765
+ *
9766
+ * Contributor(s):
9767
+ * Julian Viereck <julian DOT viereck AT gmail DOT com>
9768
+ *
9769
+ * Alternatively, the contents of this file may be used under the terms of
9770
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
9771
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
9772
+ * in which case the provisions of the GPL or the LGPL are applicable instead
9773
+ * of those above. If you wish to allow use of your version of this file only
9774
+ * under the terms of either the GPL or the LGPL, and not to allow others to
9775
+ * use your version of this file under the terms of the MPL, indicate your
9776
+ * decision by deleting the provisions above and replace them with the notice
9777
+ * and other provisions required by the GPL or the LGPL. If you do not delete
9778
+ * the provisions above, a recipient may use your version of this file under
9779
+ * the terms of any one of the MPL, the GPL or the LGPL.
9780
+ *
9781
+ * ***** END LICENSE BLOCK ***** */
9782
+
9783
+ ace.define('ace/edit_session/folding', ['require', 'exports', 'module' , 'ace/range', 'ace/edit_session/fold_line', 'ace/edit_session/fold', 'ace/token_iterator'], function(require, exports, module) {
9784
+ "use strict";
9785
+
9786
+ var Range = require("../range").Range;
9787
+ var FoldLine = require("./fold_line").FoldLine;
9788
+ var Fold = require("./fold").Fold;
9789
+ var TokenIterator = require("../token_iterator").TokenIterator;
9790
+
9791
+ function Folding() {
9792
+ /**
9793
+ * Looks up a fold at a given row/column. Possible values for side:
9794
+ * -1: ignore a fold if fold.start = row/column
9795
+ * +1: ignore a fold if fold.end = row/column
9796
+ */
9797
+ this.getFoldAt = function(row, column, side) {
9798
+ var foldLine = this.getFoldLine(row);
9799
+ if (!foldLine)
9800
+ return null;
9801
+
9802
+ var folds = foldLine.folds;
9803
+ for (var i = 0; i < folds.length; i++) {
9804
+ var fold = folds[i];
9805
+ if (fold.range.contains(row, column)) {
9806
+ if (side == 1 && fold.range.isEnd(row, column)) {
9807
+ continue;
9808
+ } else if (side == -1 && fold.range.isStart(row, column)) {
9809
+ continue;
9810
+ }
9811
+ return fold;
9812
+ }
9813
+ }
9814
+ };
9815
+
9816
+ /**
9817
+ * Returns all folds in the given range. Note, that this will return folds
9818
+ *
9819
+ */
9820
+ this.getFoldsInRange = function(range) {
9821
+ range = range.clone();
9822
+ var start = range.start;
9823
+ var end = range.end;
9824
+ var foldLines = this.$foldData;
9825
+ var foundFolds = [];
9826
+
9827
+ start.column += 1;
9828
+ end.column -= 1;
9829
+
9830
+ for (var i = 0; i < foldLines.length; i++) {
9831
+ var cmp = foldLines[i].range.compareRange(range);
9832
+ if (cmp == 2) {
9833
+ // Range is before foldLine. No intersection. This means,
9834
+ // there might be other foldLines that intersect.
9835
+ continue;
9836
+ }
9837
+ else if (cmp == -2) {
9838
+ // Range is after foldLine. There can't be any other foldLines then,
9839
+ // so let's give up.
9840
+ break;
9841
+ }
9842
+
9843
+ var folds = foldLines[i].folds;
9844
+ for (var j = 0; j < folds.length; j++) {
9845
+ var fold = folds[j];
9846
+ cmp = fold.range.compareRange(range);
9847
+ if (cmp == -2) {
9848
+ break;
9849
+ } else if (cmp == 2) {
9850
+ continue;
9851
+ } else
9852
+ // WTF-state: Can happen due to -1/+1 to start/end column.
9853
+ if (cmp == 42) {
9854
+ break;
9855
+ }
9856
+ foundFolds.push(fold);
9857
+ }
9858
+ }
9859
+ return foundFolds;
9860
+ };
9861
+
9862
+ /**
9863
+ * Returns all folds in the document
9864
+ */
9865
+ this.getAllFolds = function() {
9866
+ var folds = [];
9867
+ var foldLines = this.$foldData;
9868
+
9869
+ function addFold(fold) {
9870
+ folds.push(fold);
9871
+ if (!fold.subFolds)
9872
+ return;
9873
+
9874
+ for (var i = 0; i < fold.subFolds.length; i++)
9875
+ addFold(fold.subFolds[i]);
9876
+ }
9877
+
9878
+ for (var i = 0; i < foldLines.length; i++)
9879
+ for (var j = 0; j < foldLines[i].folds.length; j++)
9880
+ addFold(foldLines[i].folds[j]);
9881
+
9882
+ return folds;
9883
+ };
9884
+
9885
+ /**
9886
+ * Returns the string between folds at the given position.
9887
+ * E.g.
9888
+ * foo<fold>b|ar<fold>wolrd -> "bar"
9889
+ * foo<fold>bar<fold>wol|rd -> "world"
9890
+ * foo<fold>bar<fo|ld>wolrd -> <null>
9891
+ *
9892
+ * where | means the position of row/column
9893
+ *
9894
+ * The trim option determs if the return string should be trimed according
9895
+ * to the "side" passed with the trim value:
9896
+ *
9897
+ * E.g.
9898
+ * foo<fold>b|ar<fold>wolrd -trim=-1> "b"
9899
+ * foo<fold>bar<fold>wol|rd -trim=+1> "rld"
9900
+ * fo|o<fold>bar<fold>wolrd -trim=00> "foo"
9901
+ */
9902
+ this.getFoldStringAt = function(row, column, trim, foldLine) {
9903
+ foldLine = foldLine || this.getFoldLine(row);
9904
+ if (!foldLine)
9905
+ return null;
9906
+
9907
+ var lastFold = {
9908
+ end: { column: 0 }
9909
+ };
9910
+ // TODO: Refactor to use getNextFoldTo function.
9911
+ var str, fold;
9912
+ for (var i = 0; i < foldLine.folds.length; i++) {
9913
+ fold = foldLine.folds[i];
9914
+ var cmp = fold.range.compareEnd(row, column);
9915
+ if (cmp == -1) {
9916
+ str = this
9917
+ .getLine(fold.start.row)
9918
+ .substring(lastFold.end.column, fold.start.column);
9919
+ break;
9920
+ }
9921
+ else if (cmp === 0) {
9922
+ return null;
9923
+ }
9924
+ lastFold = fold;
9925
+ }
9926
+ if (!str)
9927
+ str = this.getLine(fold.start.row).substring(lastFold.end.column);
9928
+
9929
+ if (trim == -1)
9930
+ return str.substring(0, column - lastFold.end.column);
9931
+ else if (trim == 1)
9932
+ return str.substring(column - lastFold.end.column);
9933
+ else
9934
+ return str;
9935
+ };
9936
+
9937
+ this.getFoldLine = function(docRow, startFoldLine) {
9938
+ var foldData = this.$foldData;
9939
+ var i = 0;
9940
+ if (startFoldLine)
9941
+ i = foldData.indexOf(startFoldLine);
9942
+ if (i == -1)
9943
+ i = 0;
9944
+ for (i; i < foldData.length; i++) {
9945
+ var foldLine = foldData[i];
9946
+ if (foldLine.start.row <= docRow && foldLine.end.row >= docRow) {
9947
+ return foldLine;
9948
+ } else if (foldLine.end.row > docRow) {
9949
+ return null;
9950
+ }
9951
+ }
9952
+ return null;
9953
+ };
9954
+
9955
+ // returns the fold which starts after or contains docRow
9956
+ this.getNextFoldLine = function(docRow, startFoldLine) {
9957
+ var foldData = this.$foldData;
9958
+ var i = 0;
9959
+ if (startFoldLine)
9960
+ i = foldData.indexOf(startFoldLine);
9961
+ if (i == -1)
9962
+ i = 0;
9963
+ for (i; i < foldData.length; i++) {
9964
+ var foldLine = foldData[i];
9965
+ if (foldLine.end.row >= docRow) {
9966
+ return foldLine;
9967
+ }
9968
+ }
9969
+ return null;
9970
+ };
9971
+
9972
+ this.getFoldedRowCount = function(first, last) {
9973
+ var foldData = this.$foldData, rowCount = last-first+1;
9974
+ for (var i = 0; i < foldData.length; i++) {
9975
+ var foldLine = foldData[i],
9976
+ end = foldLine.end.row,
9977
+ start = foldLine.start.row;
9978
+ if (end >= last) {
9979
+ if(start < last) {
9980
+ if(start >= first)
9981
+ rowCount -= last-start;
9982
+ else
9983
+ rowCount = 0;//in one fold
9984
+ }
9985
+ break;
9986
+ } else if(end >= first){
9987
+ if (start >= first) //fold inside range
9988
+ rowCount -= end-start;
9989
+ else
9990
+ rowCount -= end-first+1;
9991
+ }
9992
+ }
9993
+ return rowCount;
9994
+ };
9995
+
9996
+ this.$addFoldLine = function(foldLine) {
9997
+ this.$foldData.push(foldLine);
9998
+ this.$foldData.sort(function(a, b) {
9999
+ return a.start.row - b.start.row;
10000
+ });
10001
+ return foldLine;
10002
+ };
10003
+
10004
+ /**
10005
+ * Adds a new fold.
10006
+ *
10007
+ * @returns
10008
+ * The new created Fold object or an existing fold object in case the
10009
+ * passed in range fits an existing fold exactly.
10010
+ */
10011
+ this.addFold = function(placeholder, range) {
10012
+ var foldData = this.$foldData;
10013
+ var added = false;
10014
+ var fold;
10015
+
10016
+ if (placeholder instanceof Fold)
10017
+ fold = placeholder;
10018
+ else
10019
+ fold = new Fold(range, placeholder);
10020
+
10021
+ this.$clipRangeToDocument(fold.range);
10022
+
10023
+ var startRow = fold.start.row;
10024
+ var startColumn = fold.start.column;
10025
+ var endRow = fold.end.row;
10026
+ var endColumn = fold.end.column;
10027
+
10028
+ // --- Some checking ---
10029
+ if (fold.placeholder.length < 2)
10030
+ throw "Placeholder has to be at least 2 characters";
10031
+
10032
+ if (startRow == endRow && endColumn - startColumn < 2)
10033
+ throw "The range has to be at least 2 characters width";
10034
+
10035
+ var startFold = this.getFoldAt(startRow, startColumn, 1);
10036
+ var endFold = this.getFoldAt(endRow, endColumn, -1);
10037
+ if (startFold && endFold == startFold)
10038
+ return startFold.addSubFold(fold);
10039
+
10040
+ if (
10041
+ (startFold && !startFold.range.isStart(startRow, startColumn))
10042
+ || (endFold && !endFold.range.isEnd(endRow, endColumn))
10043
+ ) {
10044
+ throw "A fold can't intersect already existing fold" + fold.range + startFold.range;
10045
+ }
10046
+
10047
+ // Check if there are folds in the range we create the new fold for.
10048
+ var folds = this.getFoldsInRange(fold.range);
10049
+ if (folds.length > 0) {
10050
+ // Remove the folds from fold data.
10051
+ this.removeFolds(folds);
10052
+ // Add the removed folds as subfolds on the new fold.
10053
+ fold.subFolds = folds;
10054
+ }
10055
+
10056
+ for (var i = 0; i < foldData.length; i++) {
10057
+ var foldLine = foldData[i];
10058
+ if (endRow == foldLine.start.row) {
10059
+ foldLine.addFold(fold);
10060
+ added = true;
10061
+ break;
10062
+ }
10063
+ else if (startRow == foldLine.end.row) {
10064
+ foldLine.addFold(fold);
10065
+ added = true;
10066
+ if (!fold.sameRow) {
10067
+ // Check if we might have to merge two FoldLines.
10068
+ var foldLineNext = foldData[i + 1];
10069
+ if (foldLineNext && foldLineNext.start.row == endRow) {
10070
+ // We need to merge!
10071
+ foldLine.merge(foldLineNext);
10072
+ break;
10073
+ }
10074
+ }
10075
+ break;
10076
+ }
10077
+ else if (endRow <= foldLine.start.row) {
10078
+ break;
10079
+ }
10080
+ }
10081
+
10082
+ if (!added)
10083
+ foldLine = this.$addFoldLine(new FoldLine(this.$foldData, fold));
10084
+
10085
+ if (this.$useWrapMode)
10086
+ this.$updateWrapData(foldLine.start.row, foldLine.start.row);
10087
+
10088
+ // Notify that fold data has changed.
10089
+ this.$modified = true;
10090
+ this._emit("changeFold", { data: fold });
10091
+
10092
+ return fold;
10093
+ };
10094
+
10095
+ this.addFolds = function(folds) {
10096
+ folds.forEach(function(fold) {
10097
+ this.addFold(fold);
10098
+ }, this);
10099
+ };
10100
+
10101
+ this.removeFold = function(fold) {
10102
+ var foldLine = fold.foldLine;
10103
+ var startRow = foldLine.start.row;
10104
+ var endRow = foldLine.end.row;
10105
+
10106
+ var foldLines = this.$foldData;
10107
+ var folds = foldLine.folds;
10108
+ // Simple case where there is only one fold in the FoldLine such that
10109
+ // the entire fold line can get removed directly.
10110
+ if (folds.length == 1) {
10111
+ foldLines.splice(foldLines.indexOf(foldLine), 1);
10112
+ } else
10113
+ // If the fold is the last fold of the foldLine, just remove it.
10114
+ if (foldLine.range.isEnd(fold.end.row, fold.end.column)) {
10115
+ folds.pop();
10116
+ foldLine.end.row = folds[folds.length - 1].end.row;
10117
+ foldLine.end.column = folds[folds.length - 1].end.column;
10118
+ } else
10119
+ // If the fold is the first fold of the foldLine, just remove it.
10120
+ if (foldLine.range.isStart(fold.start.row, fold.start.column)) {
10121
+ folds.shift();
10122
+ foldLine.start.row = folds[0].start.row;
10123
+ foldLine.start.column = folds[0].start.column;
10124
+ } else
10125
+ // We know there are more then 2 folds and the fold is not at the edge.
10126
+ // This means, the fold is somewhere in between.
10127
+ //
10128
+ // If the fold is in one row, we just can remove it.
10129
+ if (fold.sameRow) {
10130
+ folds.splice(folds.indexOf(fold), 1);
10131
+ } else
10132
+ // The fold goes over more then one row. This means remvoing this fold
10133
+ // will cause the fold line to get splitted up. newFoldLine is the second part
10134
+ {
10135
+ var newFoldLine = foldLine.split(fold.start.row, fold.start.column);
10136
+ folds = newFoldLine.folds;
10137
+ folds.shift();
10138
+ newFoldLine.start.row = folds[0].start.row;
10139
+ newFoldLine.start.column = folds[0].start.column;
10140
+ }
10141
+
10142
+ if (this.$useWrapMode) {
10143
+ this.$updateWrapData(startRow, endRow);
10144
+ }
10145
+
10146
+ // Notify that fold data has changed.
10147
+ this.$modified = true;
10148
+ this._emit("changeFold", { data: fold });
10149
+ };
10150
+
10151
+ this.removeFolds = function(folds) {
10152
+ // We need to clone the folds array passed in as it might be the folds
10153
+ // array of a fold line and as we call this.removeFold(fold), folds
10154
+ // are removed from folds and changes the current index.
10155
+ var cloneFolds = [];
10156
+ for (var i = 0; i < folds.length; i++) {
10157
+ cloneFolds.push(folds[i]);
10158
+ }
10159
+
10160
+ cloneFolds.forEach(function(fold) {
10161
+ this.removeFold(fold);
10162
+ }, this);
10163
+ this.$modified = true;
10164
+ };
10165
+
10166
+ this.expandFold = function(fold) {
10167
+ this.removeFold(fold);
10168
+ fold.subFolds.forEach(function(fold) {
10169
+ this.addFold(fold);
10170
+ }, this);
10171
+ fold.subFolds = [];
10172
+ };
10173
+
10174
+ this.expandFolds = function(folds) {
10175
+ folds.forEach(function(fold) {
10176
+ this.expandFold(fold);
10177
+ }, this);
10178
+ };
10179
+
10180
+ this.unfold = function(location, expandInner) {
10181
+ var range, folds;
10182
+ if (location == null)
10183
+ range = new Range(0, 0, this.getLength(), 0);
10184
+ else if (typeof location == "number")
10185
+ range = new Range(location, 0, location, this.getLine(location).length);
10186
+ else if ("row" in location)
10187
+ range = Range.fromPoints(location, location);
10188
+ else
10189
+ range = location;
10190
+
10191
+ folds = this.getFoldsInRange(range);
10192
+ if (expandInner) {
10193
+ this.removeFolds(folds);
10194
+ } else {
10195
+ // TODO: might need to remove and add folds in one go instead of using
10196
+ // expandFolds several times.
10197
+ while (folds.length) {
10198
+ this.expandFolds(folds);
10199
+ folds = this.getFoldsInRange(range);
10200
+ }
10201
+ }
10202
+ };
10203
+
10204
+ /**
10205
+ * Checks if a given documentRow is folded. This is true if there are some
10206
+ * folded parts such that some parts of the line is still visible.
10207
+ **/
10208
+ this.isRowFolded = function(docRow, startFoldRow) {
10209
+ return !!this.getFoldLine(docRow, startFoldRow);
10210
+ };
10211
+
10212
+ this.getRowFoldEnd = function(docRow, startFoldRow) {
10213
+ var foldLine = this.getFoldLine(docRow, startFoldRow);
10214
+ return (foldLine
10215
+ ? foldLine.end.row
10216
+ : docRow);
10217
+ };
10218
+
10219
+ this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) {
10220
+ if (startRow == null) {
10221
+ startRow = foldLine.start.row;
10222
+ startColumn = 0;
10223
+ }
10224
+
10225
+ if (endRow == null) {
10226
+ endRow = foldLine.end.row;
10227
+ endColumn = this.getLine(endRow).length;
10228
+ }
10229
+
10230
+ // Build the textline using the FoldLine walker.
10231
+ var doc = this.doc;
10232
+ var textLine = "";
10233
+
10234
+ foldLine.walk(function(placeholder, row, column, lastColumn) {
10235
+ if (row < startRow) {
10236
+ return;
10237
+ } else if (row == startRow) {
10238
+ if (column < startColumn) {
10239
+ return;
10240
+ }
10241
+ lastColumn = Math.max(startColumn, lastColumn);
10242
+ }
10243
+ if (placeholder) {
10244
+ textLine += placeholder;
10245
+ } else {
10246
+ textLine += doc.getLine(row).substring(lastColumn, column);
10247
+ }
10248
+ }.bind(this), endRow, endColumn);
10249
+ return textLine;
10250
+ };
10251
+
10252
+ this.getDisplayLine = function(row, endColumn, startRow, startColumn) {
10253
+ var foldLine = this.getFoldLine(row);
10254
+
10255
+ if (!foldLine) {
10256
+ var line;
10257
+ line = this.doc.getLine(row);
10258
+ return line.substring(startColumn || 0, endColumn || line.length);
10259
+ } else {
10260
+ return this.getFoldDisplayLine(
10261
+ foldLine, row, endColumn, startRow, startColumn);
10262
+ }
10263
+ };
10264
+
10265
+ this.$cloneFoldData = function() {
10266
+ var fd = [];
10267
+ fd = this.$foldData.map(function(foldLine) {
10268
+ var folds = foldLine.folds.map(function(fold) {
10269
+ return fold.clone();
10270
+ });
10271
+ return new FoldLine(fd, folds);
10272
+ });
10273
+
10274
+ return fd;
10275
+ };
10276
+
10277
+ this.toggleFold = function(tryToUnfold) {
10278
+ var selection = this.selection;
10279
+ var range = selection.getRange();
10280
+ var fold;
10281
+ var bracketPos;
10282
+
10283
+ if (range.isEmpty()) {
10284
+ var cursor = range.start;
10285
+ fold = this.getFoldAt(cursor.row, cursor.column);
10286
+
10287
+ if (fold) {
10288
+ this.expandFold(fold);
10289
+ return;
10290
+ }
10291
+ else if (bracketPos = this.findMatchingBracket(cursor)) {
10292
+ if (range.comparePoint(bracketPos) == 1) {
10293
+ range.end = bracketPos;
10294
+ }
10295
+ else {
10296
+ range.start = bracketPos;
10297
+ range.start.column++;
10298
+ range.end.column--;
10299
+ }
10300
+ }
10301
+ else if (bracketPos = this.findMatchingBracket({row: cursor.row, column: cursor.column + 1})) {
10302
+ if (range.comparePoint(bracketPos) == 1)
10303
+ range.end = bracketPos;
10304
+ else
10305
+ range.start = bracketPos;
10306
+
10307
+ range.start.column++;
10308
+ }
10309
+ else {
10310
+ range = this.getCommentFoldRange(cursor.row, cursor.column) || range;
10311
+ }
10312
+ } else {
10313
+ var folds = this.getFoldsInRange(range);
10314
+ if (tryToUnfold && folds.length) {
10315
+ this.expandFolds(folds);
10316
+ return;
10317
+ }
10318
+ else if (folds.length == 1 ) {
10319
+ fold = folds[0];
10320
+ }
10321
+ }
10322
+
10323
+ if (!fold)
10324
+ fold = this.getFoldAt(range.start.row, range.start.column);
10325
+
10326
+ if (fold && fold.range.toString() == range.toString()) {
10327
+ this.expandFold(fold);
10328
+ return;
10329
+ }
10330
+
10331
+ var placeholder = "...";
10332
+ if (!range.isMultiLine()) {
10333
+ placeholder = this.getTextRange(range);
10334
+ if(placeholder.length < 4)
10335
+ return;
10336
+ placeholder = placeholder.trim().substring(0, 2) + "..";
10337
+ }
10338
+
10339
+ this.addFold(placeholder, range);
10340
+ };
10341
+
10342
+ this.getCommentFoldRange = function(row, column) {
10343
+ var iterator = new TokenIterator(this, row, column);
10344
+ var token = iterator.getCurrentToken();
10345
+ if (token && /^comment|string/.test(token.type)) {
10346
+ var range = new Range();
10347
+ var re = new RegExp(token.type.replace(/\..*/, "\\."));
10348
+ do {
10349
+ token = iterator.stepBackward();
10350
+ } while(token && re.test(token.type));
10351
+
10352
+ iterator.stepForward();
10353
+ range.start.row = iterator.getCurrentTokenRow();
10354
+ range.start.column = iterator.getCurrentTokenColumn() + 2;
10355
+
10356
+ iterator = new TokenIterator(this, row, column);
10357
+
10358
+ do {
10359
+ token = iterator.stepForward();
10360
+ } while(token && re.test(token.type));
10361
+
10362
+ token = iterator.stepBackward();
10363
+
10364
+ range.end.row = iterator.getCurrentTokenRow();
10365
+ range.end.column = iterator.getCurrentTokenColumn() + token.value.length;
10366
+ return range;
10367
+ }
10368
+ };
10369
+
10370
+ this.foldAll = function(startRow, endRow) {
10371
+ var foldWidgets = this.foldWidgets;
10372
+ endRow = endRow || this.getLength();
10373
+ for (var row = startRow || 0; row < endRow; row++) {
10374
+ if (foldWidgets[row] == null)
10375
+ foldWidgets[row] = this.getFoldWidget(row);
10376
+ if (foldWidgets[row] != "start")
10377
+ continue;
10378
+
10379
+ var range = this.getFoldWidgetRange(row);
10380
+ // sometimes range can be incompatible with existing fold
10381
+ // wouldn't it be better for addFold to return null istead of throwing?
10382
+ if (range && range.end.row < endRow) try {
10383
+ this.addFold("...", range);
10384
+ } catch(e) {}
10385
+ }
10386
+ };
10387
+
10388
+ this.$foldStyles = {
10389
+ "manual": 1,
10390
+ "markbegin": 1,
10391
+ "markbeginend": 1
10392
+ };
10393
+ this.$foldStyle = "markbegin";
10394
+ this.setFoldStyle = function(style) {
10395
+ if (!this.$foldStyles[style])
10396
+ throw new Error("invalid fold style: " + style + "[" + Object.keys(this.$foldStyles).join(", ") + "]");
10397
+
10398
+ if (this.$foldStyle == style)
10399
+ return;
10400
+
10401
+ this.$foldStyle = style;
10402
+
10403
+ if (style == "manual")
10404
+ this.unfold();
10405
+
10406
+ // reset folding
10407
+ var mode = this.$foldMode;
10408
+ this.$setFolding(null);
10409
+ this.$setFolding(mode);
10410
+ };
10411
+
10412
+ // structured folding
10413
+ this.$setFolding = function(foldMode) {
10414
+ if (this.$foldMode == foldMode)
10415
+ return;
10416
+
10417
+ this.$foldMode = foldMode;
10418
+
10419
+ this.removeListener('change', this.$updateFoldWidgets);
10420
+ this._emit("changeAnnotation");
10421
+
10422
+ if (!foldMode || this.$foldStyle == "manual") {
10423
+ this.foldWidgets = null;
10424
+ return;
10425
+ }
10426
+
10427
+ this.foldWidgets = [];
10428
+ this.getFoldWidget = foldMode.getFoldWidget.bind(foldMode, this, this.$foldStyle);
10429
+ this.getFoldWidgetRange = foldMode.getFoldWidgetRange.bind(foldMode, this, this.$foldStyle);
10430
+
10431
+ this.$updateFoldWidgets = this.updateFoldWidgets.bind(this);
10432
+ this.on('change', this.$updateFoldWidgets);
10433
+
10434
+ };
10435
+
10436
+ this.onFoldWidgetClick = function(row, e) {
10437
+ var type = this.getFoldWidget(row);
10438
+ var line = this.getLine(row);
10439
+ var onlySubfolds = e.shiftKey;
10440
+ var addSubfolds = onlySubfolds || e.ctrlKey || e.altKey || e.metaKey;
10441
+ var fold;
10442
+
10443
+ if (type == "end")
10444
+ fold = this.getFoldAt(row, 0, -1);
10445
+ else
10446
+ fold = this.getFoldAt(row, line.length, 1);
10447
+
10448
+ if (fold) {
10449
+ if (addSubfolds)
10450
+ this.removeFold(fold);
10451
+ else
10452
+ this.expandFold(fold);
10453
+ return;
10454
+ }
10455
+
10456
+ var range = this.getFoldWidgetRange(row);
10457
+ if (range) {
10458
+ // sometimes singleline folds can be missed by the code above
10459
+ if (!range.isMultiLine()) {
10460
+ fold = this.getFoldAt(range.start.row, range.start.column, 1);
10461
+ if (fold && range.isEequal(fold.range)) {
10462
+ this.removeFold(fold);
10463
+ return;
10464
+ }
10465
+ }
10466
+
10467
+ if (!onlySubfolds)
10468
+ this.addFold("...", range);
10469
+
10470
+ if (addSubfolds)
10471
+ this.foldAll(range.start.row + 1, range.end.row);
10472
+ } else {
10473
+ if (addSubfolds)
10474
+ this.foldAll(row + 1, this.getLength());
10475
+ e.target.className += " invalid"
10476
+ }
10477
+ };
10478
+
10479
+ this.updateFoldWidgets = function(e) {
10480
+ var delta = e.data;
10481
+ var range = delta.range;
10482
+ var firstRow = range.start.row;
10483
+ var len = range.end.row - firstRow;
10484
+
10485
+ if (len === 0) {
10486
+ this.foldWidgets[firstRow] = null;
10487
+ } else if (delta.action == "removeText" || delta.action == "removeLines") {
10488
+ this.foldWidgets.splice(firstRow, len + 1, null);
10489
+ } else {
10490
+ var args = Array(len + 1);
10491
+ args.unshift(firstRow, 1);
10492
+ this.foldWidgets.splice.apply(this.foldWidgets, args);
10493
+ }
10494
+ };
10495
+
10496
+ }
10497
+
10498
+ exports.Folding = Folding;
10499
+
10500
+ });
10501
+ /* vim:ts=4:sts=4:sw=4:
10502
+ * ***** BEGIN LICENSE BLOCK *****
10503
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
10504
+ *
10505
+ * The contents of this file are subject to the Mozilla Public License Version
10506
+ * 1.1 (the "License"); you may not use this file except in compliance with
10507
+ * the License. You may obtain a copy of the License at
10508
+ * http://www.mozilla.org/MPL/
10509
+ *
10510
+ * Software distributed under the License is distributed on an "AS IS" basis,
10511
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
10512
+ * for the specific language governing rights and limitations under the
10513
+ * License.
10514
+ *
10515
+ * The Original Code is Ajax.org Code Editor (ACE).
10516
+ *
10517
+ * The Initial Developer of the Original Code is
10518
+ * Ajax.org B.V.
10519
+ * Portions created by the Initial Developer are Copyright (C) 2010
10520
+ * the Initial Developer. All Rights Reserved.
10521
+ *
10522
+ * Contributor(s):
10523
+ * Julian Viereck <julian DOT viereck AT gmail DOT com>
10524
+ *
10525
+ * Alternatively, the contents of this file may be used under the terms of
10526
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
10527
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
10528
+ * in which case the provisions of the GPL or the LGPL are applicable instead
10529
+ * of those above. If you wish to allow use of your version of this file only
10530
+ * under the terms of either the GPL or the LGPL, and not to allow others to
10531
+ * use your version of this file under the terms of the MPL, indicate your
10532
+ * decision by deleting the provisions above and replace them with the notice
10533
+ * and other provisions required by the GPL or the LGPL. If you do not delete
10534
+ * the provisions above, a recipient may use your version of this file under
10535
+ * the terms of any one of the MPL, the GPL or the LGPL.
10536
+ *
10537
+ * ***** END LICENSE BLOCK ***** */
10538
+
10539
+ ace.define('ace/edit_session/fold_line', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
10540
+ "use strict";
10541
+
10542
+ var Range = require("../range").Range;
10543
+
10544
+ /**
10545
+ * If an array is passed in, the folds are expected to be sorted already.
10546
+ */
10547
+ function FoldLine(foldData, folds) {
10548
+ this.foldData = foldData;
10549
+ if (Array.isArray(folds)) {
10550
+ this.folds = folds;
10551
+ } else {
10552
+ folds = this.folds = [ folds ];
10553
+ }
10554
+
10555
+ var last = folds[folds.length - 1]
10556
+ this.range = new Range(folds[0].start.row, folds[0].start.column,
10557
+ last.end.row, last.end.column);
10558
+ this.start = this.range.start;
10559
+ this.end = this.range.end;
10560
+
10561
+ this.folds.forEach(function(fold) {
10562
+ fold.setFoldLine(this);
10563
+ }, this);
10564
+ }
10565
+
10566
+ (function() {
10567
+ /**
10568
+ * Note: This doesn't update wrapData!
10569
+ */
10570
+ this.shiftRow = function(shift) {
10571
+ this.start.row += shift;
10572
+ this.end.row += shift;
10573
+ this.folds.forEach(function(fold) {
10574
+ fold.start.row += shift;
10575
+ fold.end.row += shift;
10576
+ });
10577
+ }
10578
+
10579
+ this.addFold = function(fold) {
10580
+ if (fold.sameRow) {
10581
+ if (fold.start.row < this.startRow || fold.endRow > this.endRow) {
10582
+ throw "Can't add a fold to this FoldLine as it has no connection";
10583
+ }
10584
+ this.folds.push(fold);
10585
+ this.folds.sort(function(a, b) {
10586
+ return -a.range.compareEnd(b.start.row, b.start.column);
10587
+ });
10588
+ if (this.range.compareEnd(fold.start.row, fold.start.column) > 0) {
10589
+ this.end.row = fold.end.row;
10590
+ this.end.column = fold.end.column;
10591
+ } else if (this.range.compareStart(fold.end.row, fold.end.column) < 0) {
10592
+ this.start.row = fold.start.row;
10593
+ this.start.column = fold.start.column;
10594
+ }
10595
+ } else if (fold.start.row == this.end.row) {
10596
+ this.folds.push(fold);
10597
+ this.end.row = fold.end.row;
10598
+ this.end.column = fold.end.column;
10599
+ } else if (fold.end.row == this.start.row) {
10600
+ this.folds.unshift(fold);
10601
+ this.start.row = fold.start.row;
10602
+ this.start.column = fold.start.column;
10603
+ } else {
10604
+ throw "Trying to add fold to FoldRow that doesn't have a matching row";
10605
+ }
10606
+ fold.foldLine = this;
10607
+ }
10608
+
10609
+ this.containsRow = function(row) {
10610
+ return row >= this.start.row && row <= this.end.row;
10611
+ }
10612
+
10613
+ this.walk = function(callback, endRow, endColumn) {
10614
+ var lastEnd = 0,
10615
+ folds = this.folds,
10616
+ fold,
10617
+ comp, stop, isNewRow = true;
10618
+
10619
+ if (endRow == null) {
10620
+ endRow = this.end.row;
10621
+ endColumn = this.end.column;
10622
+ }
10623
+
10624
+ for (var i = 0; i < folds.length; i++) {
10625
+ fold = folds[i];
10626
+
10627
+ comp = fold.range.compareStart(endRow, endColumn);
10628
+ // This fold is after the endRow/Column.
10629
+ if (comp == -1) {
10630
+ callback(null, endRow, endColumn, lastEnd, isNewRow);
10631
+ return;
10632
+ }
10633
+
10634
+ stop = callback(null, fold.start.row, fold.start.column, lastEnd, isNewRow);
10635
+ stop = !stop && callback(fold.placeholder, fold.start.row, fold.start.column, lastEnd);
10636
+
10637
+ // If the user requested to stop the walk or endRow/endColumn is
10638
+ // inside of this fold (comp == 0), then end here.
10639
+ if (stop || comp == 0) {
10640
+ return;
10641
+ }
10642
+
10643
+ // Note the new lastEnd might not be on the same line. However,
10644
+ // it's the callback's job to recognize this.
10645
+ isNewRow = !fold.sameRow;
10646
+ lastEnd = fold.end.column;
10647
+ }
10648
+ callback(null, endRow, endColumn, lastEnd, isNewRow);
10649
+ }
10650
+
10651
+ this.getNextFoldTo = function(row, column) {
10652
+ var fold, cmp;
10653
+ for (var i = 0; i < this.folds.length; i++) {
10654
+ fold = this.folds[i];
10655
+ cmp = fold.range.compareEnd(row, column);
10656
+ if (cmp == -1) {
10657
+ return {
10658
+ fold: fold,
10659
+ kind: "after"
10660
+ };
10661
+ } else if (cmp == 0) {
10662
+ return {
10663
+ fold: fold,
10664
+ kind: "inside"
10665
+ }
10666
+ }
10667
+ }
10668
+ return null;
10669
+ }
10670
+
10671
+ this.addRemoveChars = function(row, column, len) {
10672
+ var ret = this.getNextFoldTo(row, column),
10673
+ fold, folds;
10674
+ if (ret) {
10675
+ fold = ret.fold;
10676
+ if (ret.kind == "inside"
10677
+ && fold.start.column != column
10678
+ && fold.start.row != row)
10679
+ {
10680
+ throw "Moving characters inside of a fold should never be reached";
10681
+ } else if (fold.start.row == row) {
10682
+ folds = this.folds;
10683
+ var i = folds.indexOf(fold);
10684
+ if (i == 0) {
10685
+ this.start.column += len;
10686
+ }
10687
+ for (i; i < folds.length; i++) {
10688
+ fold = folds[i];
10689
+ fold.start.column += len;
10690
+ if (!fold.sameRow) {
10691
+ return;
10692
+ }
10693
+ fold.end.column += len;
10694
+ }
10695
+ this.end.column += len;
10696
+ }
10697
+ }
10698
+ }
10699
+
10700
+ this.split = function(row, column) {
10701
+ var fold = this.getNextFoldTo(row, column).fold,
10702
+ folds = this.folds;
10703
+ var foldData = this.foldData;
10704
+
10705
+ if (!fold) {
10706
+ return null;
10707
+ }
10708
+ var i = folds.indexOf(fold);
10709
+ var foldBefore = folds[i - 1];
10710
+ this.end.row = foldBefore.end.row;
10711
+ this.end.column = foldBefore.end.column;
10712
+
10713
+ // Remove the folds after row/column and create a new FoldLine
10714
+ // containing these removed folds.
10715
+ folds = folds.splice(i, folds.length - i);
10716
+
10717
+ var newFoldLine = new FoldLine(foldData, folds);
10718
+ foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine);
10719
+ return newFoldLine;
10720
+ }
10721
+
10722
+ this.merge = function(foldLineNext) {
10723
+ var folds = foldLineNext.folds;
10724
+ for (var i = 0; i < folds.length; i++) {
10725
+ this.addFold(folds[i]);
10726
+ }
10727
+ // Remove the foldLineNext - no longer needed, as
10728
+ // it's merged now with foldLineNext.
10729
+ var foldData = this.foldData;
10730
+ foldData.splice(foldData.indexOf(foldLineNext), 1);
10731
+ }
10732
+
10733
+ this.toString = function() {
10734
+ var ret = [this.range.toString() + ": [" ];
10735
+
10736
+ this.folds.forEach(function(fold) {
10737
+ ret.push(" " + fold.toString());
10738
+ });
10739
+ ret.push("]")
10740
+ return ret.join("\n");
10741
+ }
10742
+
10743
+ this.idxToPosition = function(idx) {
10744
+ var lastFoldEndColumn = 0;
10745
+ var fold;
10746
+
10747
+ for (var i = 0; i < this.folds.length; i++) {
10748
+ var fold = this.folds[i];
10749
+
10750
+ idx -= fold.start.column - lastFoldEndColumn;
10751
+ if (idx < 0) {
10752
+ return {
10753
+ row: fold.start.row,
10754
+ column: fold.start.column + idx
10755
+ };
10756
+ }
10757
+
10758
+ idx -= fold.placeholder.length;
10759
+ if (idx < 0) {
10760
+ return fold.start;
10761
+ }
10762
+
10763
+ lastFoldEndColumn = fold.end.column;
10764
+ }
10765
+
10766
+ return {
10767
+ row: this.end.row,
10768
+ column: this.end.column + idx
10769
+ };
10770
+ }
10771
+ }).call(FoldLine.prototype);
10772
+
10773
+ exports.FoldLine = FoldLine;
10774
+ });/* vim:ts=4:sts=4:sw=4:
10775
+ * ***** BEGIN LICENSE BLOCK *****
10776
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
10777
+ *
10778
+ * The contents of this file are subject to the Mozilla Public License Version
10779
+ * 1.1 (the "License"); you may not use this file except in compliance with
10780
+ * the License. You may obtain a copy of the License at
10781
+ * http://www.mozilla.org/MPL/
10782
+ *
10783
+ * Software distributed under the License is distributed on an "AS IS" basis,
10784
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
10785
+ * for the specific language governing rights and limitations under the
10786
+ * License.
10787
+ *
10788
+ * The Original Code is Ajax.org Code Editor (ACE).
10789
+ *
10790
+ * The Initial Developer of the Original Code is
10791
+ * Ajax.org B.V.
10792
+ * Portions created by the Initial Developer are Copyright (C) 2010
10793
+ * the Initial Developer. All Rights Reserved.
10794
+ *
10795
+ * Contributor(s):
10796
+ * Julian Viereck <julian DOT viereck AT gmail DOT com>
10797
+ *
10798
+ * Alternatively, the contents of this file may be used under the terms of
10799
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
10800
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
10801
+ * in which case the provisions of the GPL or the LGPL are applicable instead
10802
+ * of those above. If you wish to allow use of your version of this file only
10803
+ * under the terms of either the GPL or the LGPL, and not to allow others to
10804
+ * use your version of this file under the terms of the MPL, indicate your
10805
+ * decision by deleting the provisions above and replace them with the notice
10806
+ * and other provisions required by the GPL or the LGPL. If you do not delete
10807
+ * the provisions above, a recipient may use your version of this file under
10808
+ * the terms of any one of the MPL, the GPL or the LGPL.
10809
+ *
10810
+ * ***** END LICENSE BLOCK ***** */
10811
+
10812
+ ace.define('ace/edit_session/fold', ['require', 'exports', 'module' ], function(require, exports, module) {
10813
+ "use strict";
10814
+
10815
+ /**
10816
+ * Simple fold-data struct.
10817
+ **/
10818
+ var Fold = exports.Fold = function(range, placeholder) {
10819
+ this.foldLine = null;
10820
+ this.placeholder = placeholder;
10821
+ this.range = range;
10822
+ this.start = range.start;
10823
+ this.end = range.end;
10824
+
10825
+ this.sameRow = range.start.row == range.end.row;
10826
+ this.subFolds = [];
10827
+ };
10828
+
10829
+ (function() {
10830
+
10831
+ this.toString = function() {
10832
+ return '"' + this.placeholder + '" ' + this.range.toString();
10833
+ };
10834
+
10835
+ this.setFoldLine = function(foldLine) {
10836
+ this.foldLine = foldLine;
10837
+ this.subFolds.forEach(function(fold) {
10838
+ fold.setFoldLine(foldLine);
10839
+ });
10840
+ };
10841
+
10842
+ this.clone = function() {
10843
+ var range = this.range.clone();
10844
+ var fold = new Fold(range, this.placeholder);
10845
+ this.subFolds.forEach(function(subFold) {
10846
+ fold.subFolds.push(subFold.clone());
10847
+ });
10848
+ return fold;
10849
+ };
10850
+
10851
+ this.addSubFold = function(fold) {
10852
+ if (this.range.isEequal(fold))
10853
+ return this;
10854
+
10855
+ if (!this.range.containsRange(fold))
10856
+ throw "A fold can't intersect already existing fold" + fold.range + this.range;
10857
+
10858
+ var row = fold.range.start.row, column = fold.range.start.column;
10859
+ for (var i = 0, cmp = -1; i < this.subFolds.length; i++) {
10860
+ cmp = this.subFolds[i].range.compare(row, column);
10861
+ if (cmp != 1)
10862
+ break;
10863
+ }
10864
+ var afterStart = this.subFolds[i];
10865
+
10866
+ if (cmp == 0)
10867
+ return afterStart.addSubFold(fold)
10868
+
10869
+ // cmp == -1
10870
+ var row = fold.range.end.row, column = fold.range.end.column;
10871
+ for (var j = i, cmp = -1; j < this.subFolds.length; j++) {
10872
+ cmp = this.subFolds[j].range.compare(row, column);
10873
+ if (cmp != 1)
10874
+ break;
10875
+ }
10876
+ var afterEnd = this.subFolds[j];
10877
+
10878
+ if (cmp == 0)
10879
+ throw "A fold can't intersect already existing fold" + fold.range + this.range;
10880
+
10881
+ var consumedFolds = this.subFolds.splice(i, j - i, fold)
10882
+ fold.setFoldLine(this.foldLine);
10883
+
10884
+ return fold;
10885
+ }
10886
+
10887
+ }).call(Fold.prototype);
10888
+
10889
+ });/* vim:ts=4:sts=4:sw=4:
10890
+ * ***** BEGIN LICENSE BLOCK *****
10891
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
10892
+ *
10893
+ * The contents of this file are subject to the Mozilla Public License Version
10894
+ * 1.1 (the "License"); you may not use this file except in compliance with
10895
+ * the License. You may obtain a copy of the License at
10896
+ * http://www.mozilla.org/MPL/
10897
+ *
10898
+ * Software distributed under the License is distributed on an "AS IS" basis,
10899
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
10900
+ * for the specific language governing rights and limitations under the
10901
+ * License.
10902
+ *
10903
+ * The Original Code is Ajax.org Code Editor (ACE).
10904
+ *
10905
+ * The Initial Developer of the Original Code is
10906
+ * Ajax.org B.V.
10907
+ * Portions created by the Initial Developer are Copyright (C) 2010
10908
+ * the Initial Developer. All Rights Reserved.
10909
+ *
10910
+ * Contributor(s):
10911
+ * Fabian Jakobs <fabian AT ajax DOT org>
10912
+ *
10913
+ * Alternatively, the contents of this file may be used under the terms of
10914
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
10915
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
10916
+ * in which case the provisions of the GPL or the LGPL are applicable instead
10917
+ * of those above. If you wish to allow use of your version of this file only
10918
+ * under the terms of either the GPL or the LGPL, and not to allow others to
10919
+ * use your version of this file under the terms of the MPL, indicate your
10920
+ * decision by deleting the provisions above and replace them with the notice
10921
+ * and other provisions required by the GPL or the LGPL. If you do not delete
10922
+ * the provisions above, a recipient may use your version of this file under
10923
+ * the terms of any one of the MPL, the GPL or the LGPL.
10924
+ *
10925
+ * ***** END LICENSE BLOCK ***** */
10926
+
10927
+ ace.define('ace/token_iterator', ['require', 'exports', 'module' ], function(require, exports, module) {
10928
+ "use strict";
10929
+
10930
+ var TokenIterator = function(session, initialRow, initialColumn) {
10931
+ this.$session = session;
10932
+ this.$row = initialRow;
10933
+ this.$rowTokens = session.getTokens(initialRow, initialRow)[0].tokens;
10934
+
10935
+ var token = session.getTokenAt(initialRow, initialColumn);
10936
+ this.$tokenIndex = token ? token.index : -1;
10937
+ };
10938
+
10939
+ (function() {
10940
+
10941
+ this.stepBackward = function() {
10942
+ this.$tokenIndex -= 1;
10943
+
10944
+ while (this.$tokenIndex < 0) {
10945
+ this.$row -= 1;
10946
+ if (this.$row < 0) {
10947
+ this.$row = 0;
10948
+ return null;
10949
+ }
10950
+
10951
+ this.$rowTokens = this.$session.getTokens(this.$row, this.$row)[0].tokens;
10952
+ this.$tokenIndex = this.$rowTokens.length - 1;
10953
+ }
10954
+
10955
+ return this.$rowTokens[this.$tokenIndex];
10956
+ };
10957
+
10958
+ this.stepForward = function() {
10959
+ var rowCount = this.$session.getLength();
10960
+ this.$tokenIndex += 1;
10961
+
10962
+ while (this.$tokenIndex >= this.$rowTokens.length) {
10963
+ this.$row += 1;
10964
+ if (this.$row >= rowCount) {
10965
+ this.$row = rowCount - 1;
10966
+ return null;
10967
+ }
10968
+
10969
+ this.$rowTokens = this.$session.getTokens(this.$row, this.$row)[0].tokens;
10970
+ this.$tokenIndex = 0;
10971
+ }
10972
+
10973
+ return this.$rowTokens[this.$tokenIndex];
10974
+ };
10975
+
10976
+ this.getCurrentToken = function () {
10977
+ return this.$rowTokens[this.$tokenIndex];
10978
+ };
10979
+
10980
+ this.getCurrentTokenRow = function () {
10981
+ return this.$row;
10982
+ };
10983
+
10984
+ this.getCurrentTokenColumn = function() {
10985
+ var rowTokens = this.$rowTokens;
10986
+ var tokenIndex = this.$tokenIndex;
10987
+
10988
+ // If a column was cached by EditSession.getTokenAt, then use it
10989
+ var column = rowTokens[tokenIndex].start;
10990
+ if (column !== undefined)
10991
+ return column;
10992
+
10993
+ column = 0;
10994
+ while (tokenIndex > 0) {
10995
+ tokenIndex -= 1;
10996
+ column += rowTokens[tokenIndex].value.length;
10997
+ }
10998
+
10999
+ return column;
11000
+ };
11001
+
11002
+ }).call(TokenIterator.prototype);
11003
+
11004
+ exports.TokenIterator = TokenIterator;
11005
+ });
11006
+ /* vim:ts=4:sts=4:sw=4:
11007
+ * ***** BEGIN LICENSE BLOCK *****
11008
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
11009
+ *
11010
+ * The contents of this file are subject to the Mozilla Public License Version
11011
+ * 1.1 (the "License"); you may not use this file except in compliance with
11012
+ * the License. You may obtain a copy of the License at
11013
+ * http://www.mozilla.org/MPL/
11014
+ *
11015
+ * Software distributed under the License is distributed on an "AS IS" basis,
11016
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11017
+ * for the specific language governing rights and limitations under the
11018
+ * License.
11019
+ *
11020
+ * The Original Code is Ajax.org Code Editor (ACE).
11021
+ *
11022
+ * The Initial Developer of the Original Code is
11023
+ * Ajax.org B.V.
11024
+ * Portions created by the Initial Developer are Copyright (C) 2010
11025
+ * the Initial Developer. All Rights Reserved.
11026
+ *
11027
+ * Contributor(s):
11028
+ * Fabian Jakobs <fabian AT ajax DOT org>
11029
+ *
11030
+ * Alternatively, the contents of this file may be used under the terms of
11031
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
11032
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
11033
+ * in which case the provisions of the GPL or the LGPL are applicable instead
11034
+ * of those above. If you wish to allow use of your version of this file only
11035
+ * under the terms of either the GPL or the LGPL, and not to allow others to
11036
+ * use your version of this file under the terms of the MPL, indicate your
11037
+ * decision by deleting the provisions above and replace them with the notice
11038
+ * and other provisions required by the GPL or the LGPL. If you do not delete
11039
+ * the provisions above, a recipient may use your version of this file under
11040
+ * the terms of any one of the MPL, the GPL or the LGPL.
11041
+ *
11042
+ * ***** END LICENSE BLOCK ***** */
11043
+
11044
+ ace.define('ace/edit_session/bracket_match', ['require', 'exports', 'module' , 'ace/token_iterator'], function(require, exports, module) {
11045
+ "use strict";
11046
+
11047
+ var TokenIterator = require("../token_iterator").TokenIterator;
11048
+
11049
+ function BracketMatch() {
11050
+
11051
+ this.findMatchingBracket = function(position) {
11052
+ if (position.column == 0) return null;
11053
+
11054
+ var charBeforeCursor = this.getLine(position.row).charAt(position.column-1);
11055
+ if (charBeforeCursor == "") return null;
11056
+
11057
+ var match = charBeforeCursor.match(/([\(\[\{])|([\)\]\}])/);
11058
+ if (!match) {
11059
+ return null;
11060
+ }
11061
+
11062
+ if (match[1]) {
11063
+ return this.$findClosingBracket(match[1], position);
11064
+ } else {
11065
+ return this.$findOpeningBracket(match[2], position);
11066
+ }
11067
+ };
11068
+
11069
+ this.$brackets = {
11070
+ ")": "(",
11071
+ "(": ")",
11072
+ "]": "[",
11073
+ "[": "]",
11074
+ "{": "}",
11075
+ "}": "{"
11076
+ };
11077
+
11078
+ this.$findOpeningBracket = function(bracket, position) {
11079
+ var openBracket = this.$brackets[bracket];
11080
+ var depth = 1;
11081
+
11082
+ var iterator = new TokenIterator(this, position.row, position.column);
11083
+ var token = iterator.getCurrentToken();
11084
+ if (!token) return null;
11085
+
11086
+ // token.type contains a period-delimited list of token identifiers
11087
+ // (e.g.: "constant.numeric" or "paren.lparen"). Create a pattern that
11088
+ // matches any token containing the same identifiers or a subset. In
11089
+ // addition, if token.type includes "rparen", then also match "lparen".
11090
+ // So if type.token is "paren.rparen", then typeRe will match "lparen.paren".
11091
+ var typeRe = new RegExp("(\\.?" +
11092
+ token.type.replace(".", "|").replace("rparen", "lparen|rparen") + ")+");
11093
+
11094
+ // Start searching in token, just before the character at position.column
11095
+ var valueIndex = position.column - iterator.getCurrentTokenColumn() - 2;
11096
+ var value = token.value;
11097
+
11098
+ while (true) {
11099
+
11100
+ while (valueIndex >= 0) {
11101
+ var chr = value.charAt(valueIndex);
11102
+ if (chr == openBracket) {
11103
+ depth -= 1;
11104
+ if (depth == 0) {
11105
+ return {row: iterator.getCurrentTokenRow(),
11106
+ column: valueIndex + iterator.getCurrentTokenColumn()};
11107
+ }
11108
+ }
11109
+ else if (chr == bracket) {
11110
+ depth += 1;
11111
+ }
11112
+ valueIndex -= 1;
11113
+ }
11114
+
11115
+ // Scan backward through the document, looking for the next token
11116
+ // whose type matches typeRe
11117
+ do {
11118
+ token = iterator.stepBackward();
11119
+ } while (token && !typeRe.test(token.type));
11120
+
11121
+ if (token == null)
11122
+ break;
11123
+
11124
+ value = token.value;
11125
+ valueIndex = value.length - 1;
11126
+ }
11127
+
11128
+ return null;
11129
+ };
11130
+
11131
+ this.$findClosingBracket = function(bracket, position) {
11132
+ var closingBracket = this.$brackets[bracket];
11133
+ var depth = 1;
11134
+
11135
+ var iterator = new TokenIterator(this, position.row, position.column);
11136
+ var token = iterator.getCurrentToken();
11137
+ if (!token) return null;
11138
+
11139
+ // token.type contains a period-delimited list of token identifiers
11140
+ // (e.g.: "constant.numeric" or "paren.lparen"). Create a pattern that
11141
+ // matches any token containing the same identifiers or a subset. In
11142
+ // addition, if token.type includes "lparen", then also match "rparen".
11143
+ // So if type.token is "lparen.paren", then typeRe will match "paren.rparen".
11144
+ var typeRe = new RegExp("(\\.?" +
11145
+ token.type.replace(".", "|").replace("lparen", "lparen|rparen") + ")+");
11146
+
11147
+ // Start searching in token, after the character at position.column
11148
+ var valueIndex = position.column - iterator.getCurrentTokenColumn();
11149
+
11150
+ while (true) {
11151
+
11152
+ var value = token.value;
11153
+ var valueLength = value.length;
11154
+ while (valueIndex < valueLength) {
11155
+ var chr = value.charAt(valueIndex);
11156
+ if (chr == closingBracket) {
11157
+ depth -= 1;
11158
+ if (depth == 0) {
11159
+ return {row: iterator.getCurrentTokenRow(),
11160
+ column: valueIndex + iterator.getCurrentTokenColumn()};
11161
+ }
11162
+ }
11163
+ else if (chr == bracket) {
11164
+ depth += 1;
11165
+ }
11166
+ valueIndex += 1;
11167
+ }
11168
+
11169
+ // Scan forward through the document, looking for the next token
11170
+ // whose type matches typeRe
11171
+ do {
11172
+ token = iterator.stepForward();
11173
+ } while (token && !typeRe.test(token.type));
11174
+
11175
+ if (token == null)
11176
+ break;
11177
+
11178
+ valueIndex = 0;
11179
+ }
11180
+
11181
+ return null;
11182
+ };
11183
+ }
11184
+ exports.BracketMatch = BracketMatch;
11185
+
11186
+ });
11187
+ /* vim:ts=4:sts=4:sw=4:
11188
+ * ***** BEGIN LICENSE BLOCK *****
11189
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
11190
+ *
11191
+ * The contents of this file are subject to the Mozilla Public License Version
11192
+ * 1.1 (the "License"); you may not use this file except in compliance with
11193
+ * the License. You may obtain a copy of the License at
11194
+ * http://www.mozilla.org/MPL/
11195
+ *
11196
+ * Software distributed under the License is distributed on an "AS IS" basis,
11197
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11198
+ * for the specific language governing rights and limitations under the
11199
+ * License.
11200
+ *
11201
+ * The Original Code is Ajax.org Code Editor (ACE).
11202
+ *
11203
+ * The Initial Developer of the Original Code is
11204
+ * Ajax.org B.V.
11205
+ * Portions created by the Initial Developer are Copyright (C) 2010
11206
+ * the Initial Developer. All Rights Reserved.
11207
+ *
11208
+ * Contributor(s):
11209
+ * Fabian Jakobs <fabian AT ajax DOT org>
11210
+ * Mihai Sucan <mihai DOT sucan AT gmail DOT com>
11211
+ *
11212
+ * Alternatively, the contents of this file may be used under the terms of
11213
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
11214
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
11215
+ * in which case the provisions of the GPL or the LGPL are applicable instead
11216
+ * of those above. If you wish to allow use of your version of this file only
11217
+ * under the terms of either the GPL or the LGPL, and not to allow others to
11218
+ * use your version of this file under the terms of the MPL, indicate your
11219
+ * decision by deleting the provisions above and replace them with the notice
11220
+ * and other provisions required by the GPL or the LGPL. If you do not delete
11221
+ * the provisions above, a recipient may use your version of this file under
11222
+ * the terms of any one of the MPL, the GPL or the LGPL.
11223
+ *
11224
+ * ***** END LICENSE BLOCK ***** */
11225
+
11226
+ ace.define('ace/search', ['require', 'exports', 'module' , 'ace/lib/lang', 'ace/lib/oop', 'ace/range'], function(require, exports, module) {
11227
+ "use strict";
11228
+
11229
+ var lang = require("./lib/lang");
11230
+ var oop = require("./lib/oop");
11231
+ var Range = require("./range").Range;
11232
+
11233
+ var Search = function() {
11234
+ this.$options = {
11235
+ needle: "",
11236
+ backwards: false,
11237
+ wrap: false,
11238
+ caseSensitive: false,
11239
+ wholeWord: false,
11240
+ scope: Search.ALL,
11241
+ regExp: false
11242
+ };
11243
+ };
11244
+
11245
+ Search.ALL = 1;
11246
+ Search.SELECTION = 2;
11247
+
11248
+ (function() {
11249
+
11250
+ this.set = function(options) {
11251
+ oop.mixin(this.$options, options);
11252
+ return this;
11253
+ };
11254
+
11255
+ this.getOptions = function() {
11256
+ return lang.copyObject(this.$options);
11257
+ };
11258
+
11259
+ this.find = function(session) {
11260
+ if (!this.$options.needle)
11261
+ return null;
11262
+
11263
+ if (this.$options.backwards) {
11264
+ var iterator = this.$backwardMatchIterator(session);
11265
+ } else {
11266
+ iterator = this.$forwardMatchIterator(session);
11267
+ }
11268
+
11269
+ var firstRange = null;
11270
+ iterator.forEach(function(range) {
11271
+ firstRange = range;
11272
+ return true;
11273
+ });
11274
+
11275
+ return firstRange;
11276
+ };
11277
+
11278
+ this.findAll = function(session) {
11279
+ var options = this.$options;
11280
+ if (!options.needle)
11281
+ return [];
11282
+
11283
+ if (options.backwards) {
11284
+ var iterator = this.$backwardMatchIterator(session);
11285
+ } else {
11286
+ iterator = this.$forwardMatchIterator(session);
11287
+ }
11288
+
11289
+ var ignoreCursor = !options.start && options.wrap && options.scope == Search.ALL;
11290
+ if (ignoreCursor)
11291
+ options.start = {row: 0, column: 0};
11292
+
11293
+ var ranges = [];
11294
+ iterator.forEach(function(range) {
11295
+ ranges.push(range);
11296
+ });
11297
+
11298
+ if (ignoreCursor)
11299
+ options.start = null;
11300
+
11301
+ return ranges;
11302
+ };
11303
+
11304
+ this.replace = function(input, replacement) {
11305
+ var re = this.$assembleRegExp();
11306
+ var match = re.exec(input);
11307
+ if (match && match[0].length == input.length) {
11308
+ if (this.$options.regExp) {
11309
+ return input.replace(re, replacement);
11310
+ } else {
11311
+ return replacement;
11312
+ }
11313
+ } else {
11314
+ return null;
11315
+ }
11316
+ };
11317
+
11318
+ this.$forwardMatchIterator = function(session) {
11319
+ var re = this.$assembleRegExp();
11320
+ var self = this;
11321
+
11322
+ return {
11323
+ forEach: function(callback) {
11324
+ self.$forwardLineIterator(session).forEach(function(line, startIndex, row) {
11325
+ if (startIndex) {
11326
+ line = line.substring(startIndex);
11327
+ }
11328
+
11329
+ var matches = [];
11330
+
11331
+ line.replace(re, function(str) {
11332
+ var offset = arguments[arguments.length-2];
11333
+ matches.push({
11334
+ str: str,
11335
+ offset: startIndex + offset
11336
+ });
11337
+ return str;
11338
+ });
11339
+
11340
+ for (var i=0; i<matches.length; i++) {
11341
+ var match = matches[i];
11342
+ var range = self.$rangeFromMatch(row, match.offset, match.str.length);
11343
+ if (callback(range))
11344
+ return true;
11345
+ }
11346
+
11347
+ });
11348
+ }
11349
+ };
11350
+ };
11351
+
11352
+ this.$backwardMatchIterator = function(session) {
11353
+ var re = this.$assembleRegExp();
11354
+ var self = this;
11355
+
11356
+ return {
11357
+ forEach: function(callback) {
11358
+ self.$backwardLineIterator(session).forEach(function(line, startIndex, row) {
11359
+ if (startIndex) {
11360
+ line = line.substring(startIndex);
11361
+ }
11362
+
11363
+ var matches = [];
11364
+
11365
+ line.replace(re, function(str, offset) {
11366
+ matches.push({
11367
+ str: str,
11368
+ offset: startIndex + offset
11369
+ });
11370
+ return str;
11371
+ });
11372
+
11373
+ for (var i=matches.length-1; i>= 0; i--) {
11374
+ var match = matches[i];
11375
+ var range = self.$rangeFromMatch(row, match.offset, match.str.length);
11376
+ if (callback(range))
11377
+ return true;
11378
+ }
11379
+ });
11380
+ }
11381
+ };
11382
+ };
11383
+
11384
+ this.$rangeFromMatch = function(row, column, length) {
11385
+ return new Range(row, column, row, column+length);
11386
+ };
11387
+
11388
+ this.$assembleRegExp = function() {
11389
+ if (this.$options.regExp) {
11390
+ var needle = this.$options.needle;
11391
+ } else {
11392
+ needle = lang.escapeRegExp(this.$options.needle);
11393
+ }
11394
+
11395
+ if (this.$options.wholeWord) {
11396
+ needle = "\\b" + needle + "\\b";
11397
+ }
11398
+
11399
+ var modifier = "g";
11400
+ if (!this.$options.caseSensitive) {
11401
+ modifier += "i";
11402
+ }
11403
+
11404
+ var re = new RegExp(needle, modifier);
11405
+ return re;
11406
+ };
11407
+
11408
+ this.$forwardLineIterator = function(session) {
11409
+ var searchSelection = this.$options.scope == Search.SELECTION;
11410
+
11411
+ var range = this.$options.range || session.getSelection().getRange();
11412
+ var start = this.$options.start || range[searchSelection ? "start" : "end"];
11413
+
11414
+ var firstRow = searchSelection ? range.start.row : 0;
11415
+ var firstColumn = searchSelection ? range.start.column : 0;
11416
+ var lastRow = searchSelection ? range.end.row : session.getLength() - 1;
11417
+
11418
+ var wrap = this.$options.wrap;
11419
+ var inWrap = false;
11420
+
11421
+ function getLine(row) {
11422
+ var line = session.getLine(row);
11423
+ if (searchSelection && row == range.end.row) {
11424
+ line = line.substring(0, range.end.column);
11425
+ }
11426
+ if (inWrap && row == start.row) {
11427
+ line = line.substring(0, start.column);
11428
+ }
11429
+ return line;
11430
+ }
11431
+
11432
+ return {
11433
+ forEach: function(callback) {
11434
+ var row = start.row;
11435
+
11436
+ var line = getLine(row);
11437
+ var startIndex = start.column;
11438
+
11439
+ var stop = false;
11440
+ inWrap = false;
11441
+
11442
+ while (!callback(line, startIndex, row)) {
11443
+
11444
+ if (stop) {
11445
+ return;
11446
+ }
11447
+
11448
+ row++;
11449
+ startIndex = 0;
11450
+
11451
+ if (row > lastRow) {
11452
+ if (wrap) {
11453
+ row = firstRow;
11454
+ startIndex = firstColumn;
11455
+ inWrap = true;
11456
+ } else {
11457
+ return;
11458
+ }
11459
+ }
11460
+
11461
+ if (row == start.row)
11462
+ stop = true;
11463
+
11464
+ line = getLine(row);
11465
+ }
11466
+ }
11467
+ };
11468
+ };
11469
+
11470
+ this.$backwardLineIterator = function(session) {
11471
+ var searchSelection = this.$options.scope == Search.SELECTION;
11472
+
11473
+ var range = this.$options.range || session.getSelection().getRange();
11474
+ var start = this.$options.start || range[searchSelection ? "end" : "start"];
11475
+
11476
+ var firstRow = searchSelection ? range.start.row : 0;
11477
+ var firstColumn = searchSelection ? range.start.column : 0;
11478
+ var lastRow = searchSelection ? range.end.row : session.getLength() - 1;
11479
+
11480
+ var wrap = this.$options.wrap;
11481
+
11482
+ return {
11483
+ forEach : function(callback) {
11484
+ var row = start.row;
11485
+
11486
+ var line = session.getLine(row).substring(0, start.column);
11487
+ var startIndex = 0;
11488
+ var stop = false;
11489
+ var inWrap = false;
11490
+
11491
+ while (!callback(line, startIndex, row)) {
11492
+
11493
+ if (stop)
11494
+ return;
11495
+
11496
+ row--;
11497
+ startIndex = 0;
11498
+
11499
+ if (row < firstRow) {
11500
+ if (wrap) {
11501
+ row = lastRow;
11502
+ inWrap = true;
11503
+ } else {
11504
+ return;
11505
+ }
11506
+ }
11507
+
11508
+ if (row == start.row)
11509
+ stop = true;
11510
+
11511
+ line = session.getLine(row);
11512
+ if (searchSelection) {
11513
+ if (row == firstRow)
11514
+ startIndex = firstColumn;
11515
+ else if (row == lastRow)
11516
+ line = line.substring(0, range.end.column);
11517
+ }
11518
+
11519
+ if (inWrap && row == start.row)
11520
+ startIndex = start.column;
11521
+ }
11522
+ }
11523
+ };
11524
+ };
11525
+
11526
+ }).call(Search.prototype);
11527
+
11528
+ exports.Search = Search;
11529
+ });
11530
+ ace.define('ace/commands/command_manager', ['require', 'exports', 'module' , 'ace/lib/keys'], function(require, exports, module) {
11531
+ "use strict";
11532
+
11533
+ var keyUtil = require("../lib/keys");
11534
+
11535
+ var CommandManager = function(platform, commands) {
11536
+ if (typeof platform !== "string")
11537
+ throw new TypeError("'platform' argument must be either 'mac' or 'win'");
11538
+
11539
+ this.platform = platform;
11540
+ this.commands = {};
11541
+ this.commmandKeyBinding = {};
11542
+
11543
+ if (commands)
11544
+ commands.forEach(this.addCommand, this);
11545
+ };
11546
+
11547
+ (function() {
11548
+
11549
+ this.addCommand = function(command) {
11550
+ if (this.commands[command.name])
11551
+ this.removeCommand(command);
11552
+
11553
+ this.commands[command.name] = command;
11554
+
11555
+ if (command.bindKey) {
11556
+ this._buildKeyHash(command);
11557
+ }
11558
+ };
11559
+
11560
+ this.removeCommand = function(command) {
11561
+ var name = (typeof command === 'string' ? command : command.name);
11562
+ command = this.commands[name];
11563
+ delete this.commands[name];
11564
+
11565
+ // exaustive search is brute force but since removeCommand is
11566
+ // not a performance critical operation this should be OK
11567
+ var ckb = this.commmandKeyBinding;
11568
+ for (var hashId in ckb) {
11569
+ for (var key in ckb[hashId]) {
11570
+ if (ckb[hashId][key] == command)
11571
+ delete ckb[hashId][key];
11572
+ }
11573
+ }
11574
+ };
11575
+
11576
+ this.addCommands = function(commands) {
11577
+ Object.keys(commands).forEach(function(name) {
11578
+ var command = commands[name];
11579
+ if (typeof command === "string")
11580
+ return this.bindKey(command, name);
11581
+
11582
+ if (typeof command === "function")
11583
+ command = { exec: command };
11584
+
11585
+ if (!command.name)
11586
+ command.name = name;
11587
+
11588
+ this.addCommand(command);
11589
+ }, this);
11590
+ };
11591
+
11592
+ this.removeCommands = function(commands) {
11593
+ Object.keys(commands).forEach(function(name) {
11594
+ this.removeCommand(commands[name]);
11595
+ }, this);
11596
+ };
11597
+
11598
+ this.bindKey = function(key, command) {
11599
+ if(!key)
11600
+ return;
11601
+
11602
+ var ckb = this.commmandKeyBinding;
11603
+ key.split("|").forEach(function(keyPart) {
11604
+ var binding = parseKeys(keyPart, command);
11605
+ var hashId = binding.hashId;
11606
+ (ckb[hashId] || (ckb[hashId] = {}))[binding.key] = command;
11607
+ });
11608
+ };
11609
+
11610
+ this.bindKeys = function(keyList) {
11611
+ Object.keys(keyList).forEach(function(key) {
11612
+ this.bindKey(key, keyList[key]);
11613
+ }, this);
11614
+ };
11615
+
11616
+ this._buildKeyHash = function(command) {
11617
+ var binding = command.bindKey;
11618
+ if (!binding)
11619
+ return;
11620
+
11621
+ var key = typeof binding == "string" ? binding: binding[this.platform];
11622
+ this.bindKey(key, command);
11623
+ };
11624
+
11625
+ function parseKeys(keys, val, ret) {
11626
+ var key;
11627
+ var hashId = 0;
11628
+ var parts = splitSafe(keys);
11629
+
11630
+ for (var i=0, l = parts.length; i < l; i++) {
11631
+ if (keyUtil.KEY_MODS[parts[i]])
11632
+ hashId = hashId | keyUtil.KEY_MODS[parts[i]];
11633
+ else
11634
+ key = parts[i] || "-"; //when empty, the splitSafe removed a '-'
11635
+ }
11636
+
11637
+ return {
11638
+ key: key,
11639
+ hashId: hashId
11640
+ };
11641
+ }
11642
+
11643
+ function splitSafe(s) {
11644
+ return (s.toLowerCase()
11645
+ .trim()
11646
+ .split(new RegExp("[\\s ]*\\-[\\s ]*", "g"), 999));
11647
+ }
11648
+
11649
+ this.findKeyCommand = function findKeyCommand(hashId, textOrKey) {
11650
+ // Convert keyCode to the string representation.
11651
+ if (typeof textOrKey == "number") {
11652
+ textOrKey = keyUtil.keyCodeToString(textOrKey);
11653
+ }
11654
+
11655
+ var ckbr = this.commmandKeyBinding;
11656
+ return ckbr[hashId] && ckbr[hashId][textOrKey.toLowerCase()];
11657
+ };
11658
+
11659
+ this.exec = function(command, editor, args) {
11660
+ if (typeof command === 'string')
11661
+ command = this.commands[command];
11662
+
11663
+ if (!command)
11664
+ return false;
11665
+
11666
+ if (editor && editor.$readOnly && !command.readOnly)
11667
+ return false;
11668
+
11669
+ command.exec(editor, args || {});
11670
+ return true;
11671
+ };
11672
+
11673
+ this.toggleRecording = function() {
11674
+ if (this.$inReplay)
11675
+ return;
11676
+ if (this.recording) {
11677
+ this.macro.pop();
11678
+ this.exec = this.normal_exec;
11679
+
11680
+ if (!this.macro.length)
11681
+ this.macro = this.oldMacro;
11682
+
11683
+ return this.recording = false;
11684
+ }
11685
+ this.oldMacro = this.macro;
11686
+ this.macro = [];
11687
+ this.normal_exec = this.exec;
11688
+ this.exec = function(command, editor, args) {
11689
+ this.macro.push([command, args]);
11690
+ return this.normal_exec(command, editor, args);
11691
+ };
11692
+ return this.recording = true;
11693
+ };
11694
+
11695
+ this.replay = function(editor) {
11696
+ if (this.$inReplay || !this.macro)
11697
+ return;
11698
+
11699
+ if (this.recording)
11700
+ return this.toggleRecording();
11701
+
11702
+ try {
11703
+ this.$inReplay = true;
11704
+ this.macro.forEach(function(x) {
11705
+ if (typeof x == "string")
11706
+ this.exec(x, editor);
11707
+ else
11708
+ this.exec(x[0], editor, x[1]);
11709
+ }, this);
11710
+ } finally {
11711
+ this.$inReplay = false;
11712
+ }
11713
+ };
11714
+
11715
+ this.trimMacro = function(m) {
11716
+ return m.map(function(x){
11717
+ if (typeof x[0] != "string")
11718
+ x[0] = x[0].name;
11719
+ if (!x[1])
11720
+ x = x[0];
11721
+ return x;
11722
+ });
11723
+ };
11724
+
11725
+ }).call(CommandManager.prototype);
11726
+
11727
+ exports.CommandManager = CommandManager;
11728
+
11729
+ });
11730
+ /* vim:ts=4:sts=4:sw=4:
11731
+ * ***** BEGIN LICENSE BLOCK *****
11732
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
11733
+ *
11734
+ * The contents of this file are subject to the Mozilla Public License Version
11735
+ * 1.1 (the "License"); you may not use this file except in compliance with
11736
+ * the License. You may obtain a copy of the License at
11737
+ * http://www.mozilla.org/MPL/
11738
+ *
11739
+ * Software distributed under the License is distributed on an "AS IS" basis,
11740
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11741
+ * for the specific language governing rights and limitations under the
11742
+ * License.
11743
+ *
11744
+ * The Original Code is Ajax.org Code Editor (ACE).
11745
+ *
11746
+ * The Initial Developer of the Original Code is
11747
+ * Ajax.org B.V.
11748
+ * Portions created by the Initial Developer are Copyright (C) 2010
11749
+ * the Initial Developer. All Rights Reserved.
11750
+ *
11751
+ * Contributor(s):
11752
+ * Fabian Jakobs <fabian AT ajax DOT org>
11753
+ * Mihai Sucan <mihai DOT sucan AT gmail DOT com>
11754
+ *
11755
+ * Alternatively, the contents of this file may be used under the terms of
11756
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
11757
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
11758
+ * in which case the provisions of the GPL or the LGPL are applicable instead
11759
+ * of those above. If you wish to allow use of your version of this file only
11760
+ * under the terms of either the GPL or the LGPL, and not to allow others to
11761
+ * use your version of this file under the terms of the MPL, indicate your
11762
+ * decision by deleting the provisions above and replace them with the notice
11763
+ * and other provisions required by the GPL or the LGPL. If you do not delete
11764
+ * the provisions above, a recipient may use your version of this file under
11765
+ * the terms of any one of the MPL, the GPL or the LGPL.
11766
+ *
11767
+ * ***** END LICENSE BLOCK ***** */
11768
+
11769
+ ace.define('ace/undomanager', ['require', 'exports', 'module' ], function(require, exports, module) {
11770
+ "use strict";
11771
+
11772
+ var UndoManager = function() {
11773
+ this.reset();
11774
+ };
11775
+
11776
+ (function() {
11777
+
11778
+ this.execute = function(options) {
11779
+ var deltas = options.args[0];
11780
+ this.$doc = options.args[1];
11781
+ this.$undoStack.push(deltas);
11782
+ this.$redoStack = [];
11783
+ };
11784
+
11785
+ this.undo = function(dontSelect) {
11786
+ var deltas = this.$undoStack.pop();
11787
+ var undoSelectionRange = null;
11788
+ if (deltas) {
11789
+ undoSelectionRange =
11790
+ this.$doc.undoChanges(deltas, dontSelect);
11791
+ this.$redoStack.push(deltas);
11792
+ }
11793
+ return undoSelectionRange;
11794
+ };
11795
+
11796
+ this.redo = function(dontSelect) {
11797
+ var deltas = this.$redoStack.pop();
11798
+ var redoSelectionRange = null;
11799
+ if (deltas) {
11800
+ redoSelectionRange =
11801
+ this.$doc.redoChanges(deltas, dontSelect);
11802
+ this.$undoStack.push(deltas);
11803
+ }
11804
+ return redoSelectionRange;
11805
+ };
11806
+
11807
+ this.reset = function() {
11808
+ this.$undoStack = [];
11809
+ this.$redoStack = [];
11810
+ };
11811
+
11812
+ this.hasUndo = function() {
11813
+ return this.$undoStack.length > 0;
11814
+ };
11815
+
11816
+ this.hasRedo = function() {
11817
+ return this.$redoStack.length > 0;
11818
+ };
11819
+
11820
+ }).call(UndoManager.prototype);
11821
+
11822
+ exports.UndoManager = UndoManager;
11823
+ });
11824
+ /* vim:ts=4:sts=4:sw=4:
11825
+ * ***** BEGIN LICENSE BLOCK *****
11826
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
11827
+ *
11828
+ * The contents of this file are subject to the Mozilla Public License Version
11829
+ * 1.1 (the "License"); you may not use this file except in compliance with
11830
+ * the License. You may obtain a copy of the License at
11831
+ * http://www.mozilla.org/MPL/
11832
+ *
11833
+ * Software distributed under the License is distributed on an "AS IS" basis,
11834
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11835
+ * for the specific language governing rights and limitations under the
11836
+ * License.
11837
+ *
11838
+ * The Original Code is Ajax.org Code Editor (ACE).
11839
+ *
11840
+ * The Initial Developer of the Original Code is
11841
+ * Ajax.org B.V.
11842
+ * Portions created by the Initial Developer are Copyright (C) 2010
11843
+ * the Initial Developer. All Rights Reserved.
11844
+ *
11845
+ * Contributor(s):
11846
+ * Fabian Jakobs <fabian@ajax.org>
11847
+ * Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
11848
+ * Julian Viereck <julian.viereck@gmail.com>
11849
+ *
11850
+ * Alternatively, the contents of this file may be used under the terms of
11851
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
11852
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
11853
+ * in which case the provisions of the GPL or the LGPL are applicable instead
11854
+ * of those above. If you wish to allow use of your version of this file only
11855
+ * under the terms of either the GPL or the LGPL, and not to allow others to
11856
+ * use your version of this file under the terms of the MPL, indicate your
11857
+ * decision by deleting the provisions above and replace them with the notice
11858
+ * and other provisions required by the GPL or the LGPL. If you do not delete
11859
+ * the provisions above, a recipient may use your version of this file under
11860
+ * the terms of any one of the MPL, the GPL or the LGPL.
11861
+ *
11862
+ * ***** END LICENSE BLOCK ***** */
11863
+
11864
+ ace.define('ace/virtual_renderer', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/dom', 'ace/lib/event', 'ace/lib/useragent', 'ace/config', 'ace/lib/net', 'ace/layer/gutter', 'ace/layer/marker', 'ace/layer/text', 'ace/layer/cursor', 'ace/scrollbar', 'ace/renderloop', 'ace/lib/event_emitter', 'text!ace/css/editor.css'], function(require, exports, module) {
11865
+ "use strict";
11866
+
11867
+ var oop = require("./lib/oop");
11868
+ var dom = require("./lib/dom");
11869
+ var event = require("./lib/event");
11870
+ var useragent = require("./lib/useragent");
11871
+ var config = require("./config");
11872
+ var net = require("./lib/net");
11873
+ var GutterLayer = require("./layer/gutter").Gutter;
11874
+ var MarkerLayer = require("./layer/marker").Marker;
11875
+ var TextLayer = require("./layer/text").Text;
11876
+ var CursorLayer = require("./layer/cursor").Cursor;
11877
+ var ScrollBar = require("./scrollbar").ScrollBar;
11878
+ var RenderLoop = require("./renderloop").RenderLoop;
11879
+ var EventEmitter = require("./lib/event_emitter").EventEmitter;
11880
+ var editorCss = require("text!./css/editor.css");
11881
+
11882
+ dom.importCssString(editorCss, "ace_editor");
11883
+
11884
+ var VirtualRenderer = function(container, theme) {
11885
+ var _self = this;
11886
+
11887
+ this.container = container;
11888
+
11889
+ // TODO: this breaks rendering in Cloud9 with multiple ace instances
11890
+ // // Imports CSS once per DOM document ('ace_editor' serves as an identifier).
11891
+ // dom.importCssString(editorCss, "ace_editor", container.ownerDocument);
11892
+
11893
+ dom.addCssClass(container, "ace_editor");
11894
+
11895
+ this.setTheme(theme);
11896
+
11897
+ this.$gutter = dom.createElement("div");
11898
+ this.$gutter.className = "ace_gutter";
11899
+ this.container.appendChild(this.$gutter);
11900
+
11901
+ this.scroller = dom.createElement("div");
11902
+ this.scroller.className = "ace_scroller";
11903
+ this.container.appendChild(this.scroller);
11904
+
11905
+ this.content = dom.createElement("div");
11906
+ this.content.className = "ace_content";
11907
+ this.scroller.appendChild(this.content);
11908
+
11909
+ this.$gutterLayer = new GutterLayer(this.$gutter);
11910
+ this.$gutterLayer.on("changeGutterWidth", this.onResize.bind(this, true));
11911
+
11912
+ this.$markerBack = new MarkerLayer(this.content);
11913
+
11914
+ var textLayer = this.$textLayer = new TextLayer(this.content);
11915
+ this.canvas = textLayer.element;
11916
+
11917
+ this.$markerFront = new MarkerLayer(this.content);
11918
+
11919
+ this.characterWidth = textLayer.getCharacterWidth();
11920
+ this.lineHeight = textLayer.getLineHeight();
11921
+
11922
+ this.$cursorLayer = new CursorLayer(this.content);
11923
+ this.$cursorPadding = 8;
11924
+
11925
+ // Indicates whether the horizontal scrollbar is visible
11926
+ this.$horizScroll = true;
11927
+ this.$horizScrollAlwaysVisible = true;
11928
+
11929
+ this.scrollBar = new ScrollBar(container);
11930
+ this.scrollBar.addEventListener("scroll", function(e) {
11931
+ _self.session.setScrollTop(e.data);
11932
+ });
11933
+
11934
+ this.scrollTop = 0;
11935
+ this.scrollLeft = 0;
11936
+
11937
+ event.addListener(this.scroller, "scroll", function() {
11938
+ var scrollLeft = _self.scroller.scrollLeft;
11939
+ _self.scrollLeft = scrollLeft;
11940
+ _self.session.setScrollLeft(scrollLeft);
11941
+ });
11942
+
11943
+ this.cursorPos = {
11944
+ row : 0,
11945
+ column : 0
11946
+ };
11947
+
11948
+ this.$textLayer.addEventListener("changeCharacterSize", function() {
11949
+ _self.characterWidth = textLayer.getCharacterWidth();
11950
+ _self.lineHeight = textLayer.getLineHeight();
11951
+ _self.$updatePrintMargin();
11952
+ _self.onResize(true);
11953
+
11954
+ _self.$loop.schedule(_self.CHANGE_FULL);
11955
+ });
11956
+
11957
+ this.$size = {
11958
+ width: 0,
11959
+ height: 0,
11960
+ scrollerHeight: 0,
11961
+ scrollerWidth: 0
11962
+ };
11963
+
11964
+ this.layerConfig = {
11965
+ width : 1,
11966
+ padding : 0,
11967
+ firstRow : 0,
11968
+ firstRowScreen: 0,
11969
+ lastRow : 0,
11970
+ lineHeight : 1,
11971
+ characterWidth : 1,
11972
+ minHeight : 1,
11973
+ maxHeight : 1,
11974
+ offset : 0,
11975
+ height : 1
11976
+ };
11977
+
11978
+ this.$loop = new RenderLoop(
11979
+ this.$renderChanges.bind(this),
11980
+ this.container.ownerDocument.defaultView
11981
+ );
11982
+ this.$loop.schedule(this.CHANGE_FULL);
11983
+
11984
+ this.setPadding(4);
11985
+ this.$updatePrintMargin();
11986
+ };
11987
+
11988
+ (function() {
11989
+ this.showGutter = true;
11990
+
11991
+ this.CHANGE_CURSOR = 1;
11992
+ this.CHANGE_MARKER = 2;
11993
+ this.CHANGE_GUTTER = 4;
11994
+ this.CHANGE_SCROLL = 8;
11995
+ this.CHANGE_LINES = 16;
11996
+ this.CHANGE_TEXT = 32;
11997
+ this.CHANGE_SIZE = 64;
11998
+ this.CHANGE_MARKER_BACK = 128;
11999
+ this.CHANGE_MARKER_FRONT = 256;
12000
+ this.CHANGE_FULL = 512;
12001
+ this.CHANGE_H_SCROLL = 1024;
12002
+
12003
+ oop.implement(this, EventEmitter);
12004
+
12005
+ this.setSession = function(session) {
12006
+ this.session = session;
12007
+ this.$cursorLayer.setSession(session);
12008
+ this.$markerBack.setSession(session);
12009
+ this.$markerFront.setSession(session);
12010
+ this.$gutterLayer.setSession(session);
12011
+ this.$textLayer.setSession(session);
12012
+ this.$loop.schedule(this.CHANGE_FULL);
12013
+ };
12014
+
12015
+ /**
12016
+ * Triggers partial update of the text layer
12017
+ */
12018
+ this.updateLines = function(firstRow, lastRow) {
12019
+ if (lastRow === undefined)
12020
+ lastRow = Infinity;
12021
+
12022
+ if (!this.$changedLines) {
12023
+ this.$changedLines = {
12024
+ firstRow: firstRow,
12025
+ lastRow: lastRow
12026
+ };
12027
+ }
12028
+ else {
12029
+ if (this.$changedLines.firstRow > firstRow)
12030
+ this.$changedLines.firstRow = firstRow;
12031
+
12032
+ if (this.$changedLines.lastRow < lastRow)
12033
+ this.$changedLines.lastRow = lastRow;
12034
+ }
12035
+
12036
+ this.$loop.schedule(this.CHANGE_LINES);
12037
+ };
12038
+
12039
+ /**
12040
+ * Triggers full update of the text layer
12041
+ */
12042
+ this.updateText = function() {
12043
+ this.$loop.schedule(this.CHANGE_TEXT);
12044
+ };
12045
+
12046
+ /**
12047
+ * Triggers a full update of all layers
12048
+ */
12049
+ this.updateFull = function() {
12050
+ this.$loop.schedule(this.CHANGE_FULL);
12051
+ };
12052
+
12053
+ this.updateFontSize = function() {
12054
+ this.$textLayer.checkForSizeChanges();
12055
+ };
12056
+
12057
+ /**
12058
+ * Triggers resize of the editor
12059
+ */
12060
+ this.onResize = function(force) {
12061
+ var changes = this.CHANGE_SIZE;
12062
+ var size = this.$size;
12063
+
12064
+ var height = dom.getInnerHeight(this.container);
12065
+ if (force || size.height != height) {
12066
+ size.height = height;
12067
+
12068
+ this.scroller.style.height = height + "px";
12069
+ size.scrollerHeight = this.scroller.clientHeight;
12070
+ this.scrollBar.setHeight(size.scrollerHeight);
12071
+
12072
+ if (this.session) {
12073
+ this.session.setScrollTop(this.getScrollTop());
12074
+ changes = changes | this.CHANGE_FULL;
12075
+ }
12076
+ }
12077
+
12078
+ var width = dom.getInnerWidth(this.container);
12079
+ if (force || size.width != width) {
12080
+ size.width = width;
12081
+
12082
+ var gutterWidth = this.showGutter ? this.$gutter.offsetWidth : 0;
12083
+ this.scroller.style.left = gutterWidth + "px";
12084
+ size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBar.getWidth());
12085
+ this.scroller.style.width = size.scrollerWidth + "px";
12086
+
12087
+ if (this.session.getUseWrapMode() && this.adjustWrapLimit() || force)
12088
+ changes = changes | this.CHANGE_FULL;
12089
+ }
12090
+
12091
+ this.$loop.schedule(changes);
12092
+ };
12093
+
12094
+ this.adjustWrapLimit = function() {
12095
+ var availableWidth = this.$size.scrollerWidth - this.$padding * 2;
12096
+ var limit = Math.floor(availableWidth / this.characterWidth);
12097
+ return this.session.adjustWrapLimit(limit);
12098
+ };
12099
+
12100
+ this.setShowInvisibles = function(showInvisibles) {
12101
+ if (this.$textLayer.setShowInvisibles(showInvisibles))
12102
+ this.$loop.schedule(this.CHANGE_TEXT);
12103
+ };
12104
+
12105
+ this.getShowInvisibles = function() {
12106
+ return this.$textLayer.showInvisibles;
12107
+ };
12108
+
12109
+ this.$showPrintMargin = true;
12110
+ this.setShowPrintMargin = function(showPrintMargin) {
12111
+ this.$showPrintMargin = showPrintMargin;
12112
+ this.$updatePrintMargin();
12113
+ };
12114
+
12115
+ this.getShowPrintMargin = function() {
12116
+ return this.$showPrintMargin;
12117
+ };
12118
+
12119
+ this.$printMarginColumn = 80;
12120
+ this.setPrintMarginColumn = function(showPrintMargin) {
12121
+ this.$printMarginColumn = showPrintMargin;
12122
+ this.$updatePrintMargin();
12123
+ };
12124
+
12125
+ this.getPrintMarginColumn = function() {
12126
+ return this.$printMarginColumn;
12127
+ };
12128
+
12129
+ this.getShowGutter = function(){
12130
+ return this.showGutter;
12131
+ };
12132
+
12133
+ this.setShowGutter = function(show){
12134
+ if(this.showGutter === show)
12135
+ return;
12136
+ this.$gutter.style.display = show ? "block" : "none";
12137
+ this.showGutter = show;
12138
+ this.onResize(true);
12139
+ };
12140
+
12141
+ this.$updatePrintMargin = function() {
12142
+ var containerEl;
12143
+
12144
+ if (!this.$showPrintMargin && !this.$printMarginEl)
12145
+ return;
12146
+
12147
+ if (!this.$printMarginEl) {
12148
+ containerEl = dom.createElement("div");
12149
+ containerEl.className = "ace_print_margin_layer";
12150
+ this.$printMarginEl = dom.createElement("div");
12151
+ this.$printMarginEl.className = "ace_print_margin";
12152
+ containerEl.appendChild(this.$printMarginEl);
12153
+ this.content.insertBefore(containerEl, this.$textLayer.element);
12154
+ }
12155
+
12156
+ var style = this.$printMarginEl.style;
12157
+ style.left = ((this.characterWidth * this.$printMarginColumn) + this.$padding) + "px";
12158
+ style.visibility = this.$showPrintMargin ? "visible" : "hidden";
12159
+ };
12160
+
12161
+ this.getContainerElement = function() {
12162
+ return this.container;
12163
+ };
12164
+
12165
+ this.getMouseEventTarget = function() {
12166
+ return this.content;
12167
+ };
12168
+
12169
+ this.getTextAreaContainer = function() {
12170
+ return this.container;
12171
+ };
12172
+
12173
+ this.moveTextAreaToCursor = function(textarea) {
12174
+ // in IE the native cursor always shines through
12175
+ // this persists in IE9
12176
+ if (useragent.isIE)
12177
+ return;
12178
+
12179
+ if (this.layerConfig.lastRow === 0)
12180
+ return;
12181
+
12182
+ var pos = this.$cursorLayer.getPixelPosition();
12183
+ if (!pos)
12184
+ return;
12185
+
12186
+ var bounds = this.content.getBoundingClientRect();
12187
+ var offset = this.layerConfig.offset;
12188
+
12189
+ textarea.style.left = (bounds.left + pos.left) + "px";
12190
+ textarea.style.top = (bounds.top + pos.top - this.scrollTop + offset) + "px";
12191
+ };
12192
+
12193
+ this.getFirstVisibleRow = function() {
12194
+ return this.layerConfig.firstRow;
12195
+ };
12196
+
12197
+ this.getFirstFullyVisibleRow = function() {
12198
+ return this.layerConfig.firstRow + (this.layerConfig.offset === 0 ? 0 : 1);
12199
+ };
12200
+
12201
+ this.getLastFullyVisibleRow = function() {
12202
+ var flint = Math.floor((this.layerConfig.height + this.layerConfig.offset) / this.layerConfig.lineHeight);
12203
+ return this.layerConfig.firstRow - 1 + flint;
12204
+ };
12205
+
12206
+ this.getLastVisibleRow = function() {
12207
+ return this.layerConfig.lastRow;
12208
+ };
12209
+
12210
+ this.$padding = null;
12211
+ this.setPadding = function(padding) {
12212
+ this.$padding = padding;
12213
+ this.$textLayer.setPadding(padding);
12214
+ this.$cursorLayer.setPadding(padding);
12215
+ this.$markerFront.setPadding(padding);
12216
+ this.$markerBack.setPadding(padding);
12217
+ this.$loop.schedule(this.CHANGE_FULL);
12218
+ this.$updatePrintMargin();
12219
+ };
12220
+
12221
+ this.getHScrollBarAlwaysVisible = function() {
12222
+ return this.$horizScrollAlwaysVisible;
12223
+ };
12224
+
12225
+ this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
12226
+ if (this.$horizScrollAlwaysVisible != alwaysVisible) {
12227
+ this.$horizScrollAlwaysVisible = alwaysVisible;
12228
+ if (!this.$horizScrollAlwaysVisible || !this.$horizScroll)
12229
+ this.$loop.schedule(this.CHANGE_SCROLL);
12230
+ }
12231
+ };
12232
+
12233
+ this.$updateScrollBar = function() {
12234
+ this.scrollBar.setInnerHeight(this.layerConfig.maxHeight);
12235
+ this.scrollBar.setScrollTop(this.scrollTop);
12236
+ };
12237
+
12238
+ this.$renderChanges = function(changes) {
12239
+ if (!changes || !this.session || !this.container.offsetWidth)
12240
+ return;
12241
+
12242
+ // text, scrolling and resize changes can cause the view port size to change
12243
+ if (changes & this.CHANGE_FULL ||
12244
+ changes & this.CHANGE_SIZE ||
12245
+ changes & this.CHANGE_TEXT ||
12246
+ changes & this.CHANGE_LINES ||
12247
+ changes & this.CHANGE_SCROLL
12248
+ )
12249
+ this.$computeLayerConfig();
12250
+
12251
+ // horizontal scrolling
12252
+ if (changes & this.CHANGE_H_SCROLL) {
12253
+ this.scroller.scrollLeft = this.scrollLeft;
12254
+
12255
+ // read the value after writing it since the value might get clipped
12256
+ var scrollLeft = this.scroller.scrollLeft;
12257
+ this.scrollLeft = scrollLeft;
12258
+ this.session.setScrollLeft(scrollLeft);
12259
+ }
12260
+
12261
+ // full
12262
+ if (changes & this.CHANGE_FULL) {
12263
+ this.$textLayer.checkForSizeChanges();
12264
+ // update scrollbar first to not lose scroll position when gutter calls resize
12265
+ this.$updateScrollBar();
12266
+ this.$textLayer.update(this.layerConfig);
12267
+ if (this.showGutter)
12268
+ this.$gutterLayer.update(this.layerConfig);
12269
+ this.$markerBack.update(this.layerConfig);
12270
+ this.$markerFront.update(this.layerConfig);
12271
+ this.$cursorLayer.update(this.layerConfig);
12272
+ return;
12273
+ }
12274
+
12275
+ // scrolling
12276
+ if (changes & this.CHANGE_SCROLL) {
12277
+ this.$updateScrollBar();
12278
+ if (changes & this.CHANGE_TEXT || changes & this.CHANGE_LINES)
12279
+ this.$textLayer.update(this.layerConfig);
12280
+ else
12281
+ this.$textLayer.scrollLines(this.layerConfig);
12282
+
12283
+ if (this.showGutter)
12284
+ this.$gutterLayer.update(this.layerConfig);
12285
+ this.$markerBack.update(this.layerConfig);
12286
+ this.$markerFront.update(this.layerConfig);
12287
+ this.$cursorLayer.update(this.layerConfig);
12288
+ return;
12289
+ }
12290
+
12291
+ if (changes & this.CHANGE_TEXT) {
12292
+ this.$textLayer.update(this.layerConfig);
12293
+ if (this.showGutter)
12294
+ this.$gutterLayer.update(this.layerConfig);
12295
+ }
12296
+ else if (changes & this.CHANGE_LINES) {
12297
+ if (this.$updateLines()) {
12298
+ this.$updateScrollBar();
12299
+ if (this.showGutter)
12300
+ this.$gutterLayer.update(this.layerConfig);
12301
+ }
12302
+ } else if (changes & this.CHANGE_GUTTER) {
12303
+ if (this.showGutter)
12304
+ this.$gutterLayer.update(this.layerConfig);
12305
+ }
12306
+
12307
+ if (changes & this.CHANGE_CURSOR)
12308
+ this.$cursorLayer.update(this.layerConfig);
12309
+
12310
+ if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) {
12311
+ this.$markerFront.update(this.layerConfig);
12312
+ }
12313
+
12314
+ if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_BACK)) {
12315
+ this.$markerBack.update(this.layerConfig);
12316
+ }
12317
+
12318
+ if (changes & this.CHANGE_SIZE)
12319
+ this.$updateScrollBar();
12320
+ };
12321
+
12322
+ this.$computeLayerConfig = function() {
12323
+ var session = this.session;
12324
+
12325
+ var offset = this.scrollTop % this.lineHeight;
12326
+ var minHeight = this.$size.scrollerHeight + this.lineHeight;
12327
+
12328
+ var longestLine = this.$getLongestLine();
12329
+
12330
+ var horizScroll = this.$horizScrollAlwaysVisible || this.$size.scrollerWidth - longestLine < 0;
12331
+ var horizScrollChanged = this.$horizScroll !== horizScroll;
12332
+ this.$horizScroll = horizScroll;
12333
+ if (horizScrollChanged) {
12334
+ this.scroller.style.overflowX = horizScroll ? "scroll" : "hidden";
12335
+ // when we hide scrollbar scroll event isn't emited
12336
+ // leaving session with wrong scrollLeft value
12337
+ if (!horizScroll)
12338
+ this.session.setScrollLeft(0);
12339
+ }
12340
+ var maxHeight = this.session.getScreenLength() * this.lineHeight;
12341
+ this.session.setScrollTop(Math.max(0, Math.min(this.scrollTop, maxHeight - this.$size.scrollerHeight)));
12342
+
12343
+ var lineCount = Math.ceil(minHeight / this.lineHeight) - 1;
12344
+ var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight));
12345
+ var lastRow = firstRow + lineCount;
12346
+
12347
+ // Map lines on the screen to lines in the document.
12348
+ var firstRowScreen, firstRowHeight;
12349
+ var lineHeight = { lineHeight: this.lineHeight };
12350
+ firstRow = session.screenToDocumentRow(firstRow, 0);
12351
+
12352
+ // Check if firstRow is inside of a foldLine. If true, then use the first
12353
+ // row of the foldLine.
12354
+ var foldLine = session.getFoldLine(firstRow);
12355
+ if (foldLine) {
12356
+ firstRow = foldLine.start.row;
12357
+ }
12358
+
12359
+ firstRowScreen = session.documentToScreenRow(firstRow, 0);
12360
+ firstRowHeight = session.getRowHeight(lineHeight, firstRow);
12361
+
12362
+ lastRow = Math.min(session.screenToDocumentRow(lastRow, 0), session.getLength() - 1);
12363
+ minHeight = this.$size.scrollerHeight + session.getRowHeight(lineHeight, lastRow)+
12364
+ firstRowHeight;
12365
+
12366
+ offset = this.scrollTop - firstRowScreen * this.lineHeight;
12367
+
12368
+ this.layerConfig = {
12369
+ width : longestLine,
12370
+ padding : this.$padding,
12371
+ firstRow : firstRow,
12372
+ firstRowScreen: firstRowScreen,
12373
+ lastRow : lastRow,
12374
+ lineHeight : this.lineHeight,
12375
+ characterWidth : this.characterWidth,
12376
+ minHeight : minHeight,
12377
+ maxHeight : maxHeight,
12378
+ offset : offset,
12379
+ height : this.$size.scrollerHeight
12380
+ };
12381
+
12382
+ // For debugging.
12383
+ // console.log(JSON.stringify(this.layerConfig));
12384
+
12385
+ this.$gutterLayer.element.style.marginTop = (-offset) + "px";
12386
+ this.content.style.marginTop = (-offset) + "px";
12387
+ this.content.style.width = longestLine + 2 * this.$padding + "px";
12388
+ this.content.style.height = minHeight + "px";
12389
+
12390
+ // Horizontal scrollbar visibility may have changed, which changes
12391
+ // the client height of the scroller
12392
+ if (horizScrollChanged)
12393
+ this.onResize(true);
12394
+ };
12395
+
12396
+ this.$updateLines = function() {
12397
+ var firstRow = this.$changedLines.firstRow;
12398
+ var lastRow = this.$changedLines.lastRow;
12399
+ this.$changedLines = null;
12400
+
12401
+ var layerConfig = this.layerConfig;
12402
+
12403
+ // if the update changes the width of the document do a full redraw
12404
+ if (layerConfig.width != this.$getLongestLine())
12405
+ return this.$textLayer.update(layerConfig);
12406
+
12407
+ if (firstRow > layerConfig.lastRow + 1) { return; }
12408
+ if (lastRow < layerConfig.firstRow) { return; }
12409
+
12410
+ // if the last row is unknown -> redraw everything
12411
+ if (lastRow === Infinity) {
12412
+ if (this.showGutter)
12413
+ this.$gutterLayer.update(layerConfig);
12414
+ this.$textLayer.update(layerConfig);
12415
+ return;
12416
+ }
12417
+
12418
+ // else update only the changed rows
12419
+ this.$textLayer.updateLines(layerConfig, firstRow, lastRow);
12420
+ return true;
12421
+ };
12422
+
12423
+ this.$getLongestLine = function() {
12424
+ var charCount = this.session.getScreenWidth();
12425
+ if (this.$textLayer.showInvisibles)
12426
+ charCount += 1;
12427
+
12428
+ return Math.max(this.$size.scrollerWidth - 2 * this.$padding, Math.round(charCount * this.characterWidth));
12429
+ };
12430
+
12431
+ this.updateFrontMarkers = function() {
12432
+ this.$markerFront.setMarkers(this.session.getMarkers(true));
12433
+ this.$loop.schedule(this.CHANGE_MARKER_FRONT);
12434
+ };
12435
+
12436
+ this.updateBackMarkers = function() {
12437
+ this.$markerBack.setMarkers(this.session.getMarkers());
12438
+ this.$loop.schedule(this.CHANGE_MARKER_BACK);
12439
+ };
12440
+
12441
+ this.addGutterDecoration = function(row, className){
12442
+ this.$gutterLayer.addGutterDecoration(row, className);
12443
+ this.$loop.schedule(this.CHANGE_GUTTER);
12444
+ };
12445
+
12446
+ this.removeGutterDecoration = function(row, className){
12447
+ this.$gutterLayer.removeGutterDecoration(row, className);
12448
+ this.$loop.schedule(this.CHANGE_GUTTER);
12449
+ };
12450
+
12451
+ this.setBreakpoints = function(rows) {
12452
+ this.$gutterLayer.setBreakpoints(rows);
12453
+ this.$loop.schedule(this.CHANGE_GUTTER);
12454
+ };
12455
+
12456
+ this.setAnnotations = function(annotations) {
12457
+ this.$gutterLayer.setAnnotations(annotations);
12458
+ this.$loop.schedule(this.CHANGE_GUTTER);
12459
+ };
12460
+
12461
+ this.updateCursor = function() {
12462
+ this.$loop.schedule(this.CHANGE_CURSOR);
12463
+ };
12464
+
12465
+ this.hideCursor = function() {
12466
+ this.$cursorLayer.hideCursor();
12467
+ };
12468
+
12469
+ this.showCursor = function() {
12470
+ this.$cursorLayer.showCursor();
12471
+ };
12472
+
12473
+ this.scrollSelectionIntoView = function(anchor, lead) {
12474
+ // first scroll anchor into view then scroll lead into view
12475
+ this.scrollCursorIntoView(anchor);
12476
+ this.scrollCursorIntoView(lead);
12477
+ };
12478
+
12479
+ this.scrollCursorIntoView = function(cursor) {
12480
+ // the editor is not visible
12481
+ if (this.$size.scrollerHeight === 0)
12482
+ return;
12483
+
12484
+ var pos = this.$cursorLayer.getPixelPosition(cursor);
12485
+
12486
+ var left = pos.left;
12487
+ var top = pos.top;
12488
+
12489
+ if (this.scrollTop > top) {
12490
+ this.session.setScrollTop(top);
12491
+ }
12492
+
12493
+ if (this.scrollTop + this.$size.scrollerHeight < top + this.lineHeight) {
12494
+ this.session.setScrollTop(top + this.lineHeight - this.$size.scrollerHeight);
12495
+ }
12496
+
12497
+ var scrollLeft = this.scrollLeft;
12498
+
12499
+ if (scrollLeft > left) {
12500
+ if (left < this.$padding + 2 * this.layerConfig.characterWidth)
12501
+ left = 0;
12502
+ this.session.setScrollLeft(left);
12503
+ }
12504
+
12505
+ if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
12506
+ this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
12507
+ }
12508
+ };
12509
+
12510
+ this.getScrollTop = function() {
12511
+ return this.session.getScrollTop();
12512
+ };
12513
+
12514
+ this.getScrollLeft = function() {
12515
+ return this.session.getScrollLeft();
12516
+ };
12517
+
12518
+ this.getScrollTopRow = function() {
12519
+ return this.scrollTop / this.lineHeight;
12520
+ };
12521
+
12522
+ this.getScrollBottomRow = function() {
12523
+ return Math.max(0, Math.floor((this.scrollTop + this.$size.scrollerHeight) / this.lineHeight) - 1);
12524
+ };
12525
+
12526
+ this.scrollToRow = function(row) {
12527
+ this.session.setScrollTop(row * this.lineHeight);
12528
+ };
12529
+
12530
+ this.scrollToLine = function(line, center) {
12531
+ var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
12532
+ var offset = pos.top;
12533
+ if (center)
12534
+ offset -= this.$size.scrollerHeight / 2;
12535
+
12536
+ this.session.setScrollTop(offset);
12537
+ };
12538
+
12539
+ this.scrollToY = function(scrollTop) {
12540
+ // after calling scrollBar.setScrollTop
12541
+ // scrollbar sends us event with same scrollTop. ignore it
12542
+ if (this.scrollTop !== scrollTop) {
12543
+ this.$loop.schedule(this.CHANGE_SCROLL);
12544
+ this.scrollTop = scrollTop;
12545
+ }
12546
+ };
12547
+
12548
+ this.scrollToX = function(scrollLeft) {
12549
+ if (scrollLeft <= this.$padding)
12550
+ scrollLeft = 0;
12551
+
12552
+ if (this.scrollLeft !== scrollLeft)
12553
+ this.scrollLeft = scrollLeft;
12554
+ this.$loop.schedule(this.CHANGE_H_SCROLL);
12555
+ };
12556
+
12557
+ this.scrollBy = function(deltaX, deltaY) {
12558
+ deltaY && this.session.setScrollTop(this.session.getScrollTop() + deltaY);
12559
+ deltaX && this.session.setScrollLeft(this.session.getScrollLeft() + deltaX);
12560
+ };
12561
+
12562
+ this.isScrollableBy = function(deltaX, deltaY) {
12563
+ if (deltaY < 0 && this.session.getScrollTop() > 0)
12564
+ return true;
12565
+ if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight < this.layerConfig.maxHeight)
12566
+ return true;
12567
+ // todo: handle horizontal scrolling
12568
+ };
12569
+
12570
+ this.screenToTextCoordinates = function(pageX, pageY) {
12571
+ var canvasPos = this.scroller.getBoundingClientRect();
12572
+
12573
+ var col = Math.round(
12574
+ (pageX + this.scrollLeft - canvasPos.left - this.$padding - dom.getPageScrollLeft()) / this.characterWidth
12575
+ );
12576
+ var row = Math.floor(
12577
+ (pageY + this.scrollTop - canvasPos.top - dom.getPageScrollTop()) / this.lineHeight
12578
+ );
12579
+
12580
+ return this.session.screenToDocumentPosition(row, Math.max(col, 0));
12581
+ };
12582
+
12583
+ this.textToScreenCoordinates = function(row, column) {
12584
+ var canvasPos = this.scroller.getBoundingClientRect();
12585
+ var pos = this.session.documentToScreenPosition(row, column);
12586
+
12587
+ var x = this.$padding + Math.round(pos.column * this.characterWidth);
12588
+ var y = pos.row * this.lineHeight;
12589
+
12590
+ return {
12591
+ pageX: canvasPos.left + x - this.scrollLeft,
12592
+ pageY: canvasPos.top + y - this.scrollTop
12593
+ };
12594
+ };
12595
+
12596
+ this.visualizeFocus = function() {
12597
+ dom.addCssClass(this.container, "ace_focus");
12598
+ };
12599
+
12600
+ this.visualizeBlur = function() {
12601
+ dom.removeCssClass(this.container, "ace_focus");
12602
+ };
12603
+
12604
+ this.showComposition = function(position) {
12605
+ if (!this.$composition) {
12606
+ this.$composition = dom.createElement("div");
12607
+ this.$composition.className = "ace_composition";
12608
+ this.content.appendChild(this.$composition);
12609
+ }
12610
+
12611
+ this.$composition.innerHTML = "&#160;";
12612
+
12613
+ var pos = this.$cursorLayer.getPixelPosition();
12614
+ var style = this.$composition.style;
12615
+ style.top = pos.top + "px";
12616
+ style.left = (pos.left + this.$padding) + "px";
12617
+ style.height = this.lineHeight + "px";
12618
+
12619
+ this.hideCursor();
12620
+ };
12621
+
12622
+ this.setCompositionText = function(text) {
12623
+ dom.setInnerText(this.$composition, text);
12624
+ };
12625
+
12626
+ this.hideComposition = function() {
12627
+ this.showCursor();
12628
+
12629
+ if (!this.$composition)
12630
+ return;
12631
+
12632
+ var style = this.$composition.style;
12633
+ style.top = "-10000px";
12634
+ style.left = "-10000px";
12635
+ };
12636
+
12637
+ this._loadTheme = function(name, callback) {
12638
+ if (!config.get("packaged"))
12639
+ return callback();
12640
+
12641
+ var base = name.split("/").pop();
12642
+ var filename = config.get("themePath") + "/theme-" + base + config.get("suffix");
12643
+ net.loadScript(filename, callback);
12644
+ };
12645
+
12646
+ this.setTheme = function(theme) {
12647
+ var _self = this;
12648
+
12649
+ this.$themeValue = theme;
12650
+ if (!theme || typeof theme == "string") {
12651
+ var moduleName = theme || "ace/theme/textmate";
12652
+
12653
+ var module;
12654
+ try {
12655
+ module = require(moduleName);
12656
+ } catch (e) {};
12657
+ if (module)
12658
+ return afterLoad(module);
12659
+
12660
+ _self._loadTheme(moduleName, function() {
12661
+ require([theme], function(module) {
12662
+ if (_self.$themeValue !== theme)
12663
+ return;
12664
+
12665
+ afterLoad(module);
12666
+ });
12667
+ });
12668
+ } else {
12669
+ afterLoad(theme);
12670
+ }
12671
+
12672
+ function afterLoad(theme) {
12673
+ dom.importCssString(
12674
+ theme.cssText,
12675
+ theme.cssClass,
12676
+ _self.container.ownerDocument
12677
+ );
12678
+
12679
+ if (_self.$theme)
12680
+ dom.removeCssClass(_self.container, _self.$theme);
12681
+
12682
+ _self.$theme = theme ? theme.cssClass : null;
12683
+
12684
+ if (_self.$theme)
12685
+ dom.addCssClass(_self.container, _self.$theme);
12686
+
12687
+ if (theme && theme.isDark)
12688
+ dom.addCssClass(_self.container, "ace_dark");
12689
+ else
12690
+ dom.removeCssClass(_self.container, "ace_dark");
12691
+
12692
+ // force re-measure of the gutter width
12693
+ if (_self.$size) {
12694
+ _self.$size.width = 0;
12695
+ _self.onResize();
12696
+ }
12697
+ }
12698
+ };
12699
+
12700
+ this.getTheme = function() {
12701
+ return this.$themeValue;
12702
+ };
12703
+
12704
+ // Methods allows to add / remove CSS classnames to the editor element.
12705
+ // This feature can be used by plug-ins to provide a visual indication of
12706
+ // a certain mode that editor is in.
12707
+
12708
+ this.setStyle = function setStyle(style) {
12709
+ dom.addCssClass(this.container, style);
12710
+ };
12711
+
12712
+ this.unsetStyle = function unsetStyle(style) {
12713
+ dom.removeCssClass(this.container, style);
12714
+ };
12715
+
12716
+ this.destroy = function() {
12717
+ this.$textLayer.destroy();
12718
+ this.$cursorLayer.destroy();
12719
+ };
12720
+
12721
+ }).call(VirtualRenderer.prototype);
12722
+
12723
+ exports.VirtualRenderer = VirtualRenderer;
12724
+ });
12725
+ /* vim:ts=4:sts=4:sw=4:
12726
+ * ***** BEGIN LICENSE BLOCK *****
12727
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
12728
+ *
12729
+ * The contents of this file are subject to the Mozilla Public License Version
12730
+ * 1.1 (the "License"); you may not use this file except in compliance with
12731
+ * the License. You may obtain a copy of the License at
12732
+ * http://www.mozilla.org/MPL/
12733
+ *
12734
+ * Software distributed under the License is distributed on an "AS IS" basis,
12735
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12736
+ * for the specific language governing rights and limitations under the
12737
+ * License.
12738
+ *
12739
+ * The Original Code is Ajax.org Code Editor (ACE).
12740
+ *
12741
+ * The Initial Developer of the Original Code is
12742
+ * Ajax.org B.V.
12743
+ * Portions created by the Initial Developer are Copyright (C) 2010
12744
+ * the Initial Developer. All Rights Reserved.
12745
+ *
12746
+ * Contributor(s):
12747
+ * Fabian Jakobs <fabian AT ajax DOT org>
12748
+ * Julian Viereck <julian DOT viereck AT gmail DOT com>
12749
+ *
12750
+ * Alternatively, the contents of this file may be used under the terms of
12751
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
12752
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
12753
+ * in which case the provisions of the GPL or the LGPL are applicable instead
12754
+ * of those above. If you wish to allow use of your version of this file only
12755
+ * under the terms of either the GPL or the LGPL, and not to allow others to
12756
+ * use your version of this file under the terms of the MPL, indicate your
12757
+ * decision by deleting the provisions above and replace them with the notice
12758
+ * and other provisions required by the GPL or the LGPL. If you do not delete
12759
+ * the provisions above, a recipient may use your version of this file under
12760
+ * the terms of any one of the MPL, the GPL or the LGPL.
12761
+ *
12762
+ * ***** END LICENSE BLOCK ***** */
12763
+
12764
+ ace.define('ace/layer/gutter', ['require', 'exports', 'module' , 'ace/lib/dom', 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) {
12765
+ "use strict";
12766
+
12767
+ var dom = require("../lib/dom");
12768
+ var oop = require("../lib/oop");
12769
+ var EventEmitter = require("../lib/event_emitter").EventEmitter;
12770
+
12771
+ var Gutter = function(parentEl) {
12772
+ this.element = dom.createElement("div");
12773
+ this.element.className = "ace_layer ace_gutter-layer";
12774
+ parentEl.appendChild(this.element);
12775
+ this.setShowFoldWidgets(this.$showFoldWidgets);
12776
+
12777
+ this.gutterWidth = 0;
12778
+
12779
+ this.$breakpoints = [];
12780
+ this.$annotations = [];
12781
+ this.$decorations = [];
12782
+ };
12783
+
12784
+ (function() {
12785
+
12786
+ oop.implement(this, EventEmitter);
12787
+
12788
+ this.setSession = function(session) {
12789
+ this.session = session;
12790
+ };
12791
+
12792
+ this.addGutterDecoration = function(row, className){
12793
+ if (!this.$decorations[row])
12794
+ this.$decorations[row] = "";
12795
+ this.$decorations[row] += " ace_" + className;
12796
+ };
12797
+
12798
+ this.removeGutterDecoration = function(row, className){
12799
+ this.$decorations[row] = this.$decorations[row].replace(" ace_" + className, "");
12800
+ };
12801
+
12802
+ this.setBreakpoints = function(rows) {
12803
+ this.$breakpoints = rows.concat();
12804
+ };
12805
+
12806
+ this.setAnnotations = function(annotations) {
12807
+ // iterate over sparse array
12808
+ this.$annotations = [];
12809
+ for (var row in annotations) if (annotations.hasOwnProperty(row)) {
12810
+ var rowAnnotations = annotations[row];
12811
+ if (!rowAnnotations)
12812
+ continue;
12813
+
12814
+ var rowInfo = this.$annotations[row] = {
12815
+ text: []
12816
+ };
12817
+ for (var i=0; i<rowAnnotations.length; i++) {
12818
+ var annotation = rowAnnotations[i];
12819
+ var annoText = annotation.text.replace(/"/g, "&quot;").replace(/'/g, "&#8217;").replace(/</, "&lt;");
12820
+ if (rowInfo.text.indexOf(annoText) === -1)
12821
+ rowInfo.text.push(annoText);
12822
+ var type = annotation.type;
12823
+ if (type == "error")
12824
+ rowInfo.className = "ace_error";
12825
+ else if (type == "warning" && rowInfo.className != "ace_error")
12826
+ rowInfo.className = "ace_warning";
12827
+ else if (type == "info" && (!rowInfo.className))
12828
+ rowInfo.className = "ace_info";
12829
+ }
12830
+ }
12831
+ };
12832
+
12833
+ this.update = function(config) {
12834
+ this.$config = config;
12835
+
12836
+ var emptyAnno = {className: "", text: []};
12837
+ var html = [];
12838
+ var i = config.firstRow;
12839
+ var lastRow = config.lastRow;
12840
+ var fold = this.session.getNextFoldLine(i);
12841
+ var foldStart = fold ? fold.start.row : Infinity;
12842
+ var foldWidgets = this.$showFoldWidgets && this.session.foldWidgets;
12843
+
12844
+ while (true) {
12845
+ if(i > foldStart) {
12846
+ i = fold.end.row + 1;
12847
+ fold = this.session.getNextFoldLine(i, fold);
12848
+ foldStart = fold ?fold.start.row :Infinity;
12849
+ }
12850
+ if(i > lastRow)
12851
+ break;
12852
+
12853
+ var annotation = this.$annotations[i] || emptyAnno;
12854
+ html.push("<div class='ace_gutter-cell",
12855
+ this.$decorations[i] || "",
12856
+ this.$breakpoints[i] ? " ace_breakpoint " : " ",
12857
+ annotation.className,
12858
+ "' title='", annotation.text.join("\n"),
12859
+ "' style='height:", config.lineHeight, "px;'>", (i+1));
12860
+
12861
+ if (foldWidgets) {
12862
+ var c = foldWidgets[i];
12863
+ // check if cached value is invalidated and we need to recompute
12864
+ if (c == null)
12865
+ c = foldWidgets[i] = this.session.getFoldWidget(i);
12866
+ if (c)
12867
+ html.push(
12868
+ "<span class='ace_fold-widget ", c,
12869
+ c == "start" && i == foldStart && i < fold.end.row ? " closed" : " open",
12870
+ "'></span>"
12871
+ );
12872
+ }
12873
+
12874
+ var wrappedRowLength = this.session.getRowLength(i) - 1;
12875
+ while (wrappedRowLength--) {
12876
+ html.push("</div><div class='ace_gutter-cell' style='height:", config.lineHeight, "px'>\xA6");
12877
+ }
12878
+
12879
+ html.push("</div>");
12880
+
12881
+ i++;
12882
+ }
12883
+ this.element = dom.setInnerHtml(this.element, html.join(""));
12884
+ this.element.style.height = config.minHeight + "px";
12885
+
12886
+ var gutterWidth = this.element.offsetWidth;
12887
+ if (gutterWidth !== this.gutterWidth) {
12888
+ this.gutterWidth = gutterWidth;
12889
+ this._emit("changeGutterWidth", gutterWidth);
12890
+ }
12891
+ };
12892
+
12893
+ this.$showFoldWidgets = true;
12894
+ this.setShowFoldWidgets = function(show) {
12895
+ if (show)
12896
+ dom.addCssClass(this.element, "ace_folding-enabled");
12897
+ else
12898
+ dom.removeCssClass(this.element, "ace_folding-enabled");
12899
+
12900
+ this.$showFoldWidgets = show;
12901
+ };
12902
+
12903
+ this.getShowFoldWidgets = function() {
12904
+ return this.$showFoldWidgets;
12905
+ };
12906
+
12907
+ }).call(Gutter.prototype);
12908
+
12909
+ exports.Gutter = Gutter;
12910
+
12911
+ });
12912
+ /* vim:ts=4:sts=4:sw=4:
12913
+ * ***** BEGIN LICENSE BLOCK *****
12914
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
12915
+ *
12916
+ * The contents of this file are subject to the Mozilla Public License Version
12917
+ * 1.1 (the "License"); you may not use this file except in compliance with
12918
+ * the License. You may obtain a copy of the License at
12919
+ * http://www.mozilla.org/MPL/
12920
+ *
12921
+ * Software distributed under the License is distributed on an "AS IS" basis,
12922
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12923
+ * for the specific language governing rights and limitations under the
12924
+ * License.
12925
+ *
12926
+ * The Original Code is Ajax.org Code Editor (ACE).
12927
+ *
12928
+ * The Initial Developer of the Original Code is
12929
+ * Ajax.org B.V.
12930
+ * Portions created by the Initial Developer are Copyright (C) 2010
12931
+ * the Initial Developer. All Rights Reserved.
12932
+ *
12933
+ * Contributor(s):
12934
+ * Fabian Jakobs <fabian AT ajax DOT org>
12935
+ * Julian Viereck <julian.viereck@gmail.com>
12936
+ *
12937
+ * Alternatively, the contents of this file may be used under the terms of
12938
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
12939
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
12940
+ * in which case the provisions of the GPL or the LGPL are applicable instead
12941
+ * of those above. If you wish to allow use of your version of this file only
12942
+ * under the terms of either the GPL or the LGPL, and not to allow others to
12943
+ * use your version of this file under the terms of the MPL, indicate your
12944
+ * decision by deleting the provisions above and replace them with the notice
12945
+ * and other provisions required by the GPL or the LGPL. If you do not delete
12946
+ * the provisions above, a recipient may use your version of this file under
12947
+ * the terms of any one of the MPL, the GPL or the LGPL.
12948
+ *
12949
+ * ***** END LICENSE BLOCK ***** */
12950
+
12951
+ ace.define('ace/layer/marker', ['require', 'exports', 'module' , 'ace/range', 'ace/lib/dom'], function(require, exports, module) {
12952
+ "use strict";
12953
+
12954
+ var Range = require("../range").Range;
12955
+ var dom = require("../lib/dom");
12956
+
12957
+ var Marker = function(parentEl) {
12958
+ this.element = dom.createElement("div");
12959
+ this.element.className = "ace_layer ace_marker-layer";
12960
+ parentEl.appendChild(this.element);
12961
+ };
12962
+
12963
+ (function() {
12964
+
12965
+ this.$padding = 0;
12966
+
12967
+ this.setPadding = function(padding) {
12968
+ this.$padding = padding;
12969
+ };
12970
+ this.setSession = function(session) {
12971
+ this.session = session;
12972
+ };
12973
+
12974
+ this.setMarkers = function(markers) {
12975
+ this.markers = markers;
12976
+ };
12977
+
12978
+ this.update = function(config) {
12979
+ var config = config || this.config;
12980
+ if (!config)
12981
+ return;
12982
+
12983
+ this.config = config;
12984
+
12985
+
12986
+ var html = [];
12987
+ for ( var key in this.markers) {
12988
+ var marker = this.markers[key];
12989
+
12990
+ var range = marker.range.clipRows(config.firstRow, config.lastRow);
12991
+ if (range.isEmpty()) continue;
12992
+
12993
+ range = range.toScreenRange(this.session);
12994
+ if (marker.renderer) {
12995
+ var top = this.$getTop(range.start.row, config);
12996
+ var left = Math.round(
12997
+ this.$padding + range.start.column * config.characterWidth
12998
+ );
12999
+ marker.renderer(html, range, left, top, config);
13000
+ }
13001
+ else if (range.isMultiLine()) {
13002
+ if (marker.type == "text") {
13003
+ this.drawTextMarker(html, range, marker.clazz, config);
13004
+ } else {
13005
+ this.drawMultiLineMarker(
13006
+ html, range, marker.clazz, config,
13007
+ marker.type
13008
+ );
13009
+ }
13010
+ }
13011
+ else {
13012
+ this.drawSingleLineMarker(
13013
+ html, range, marker.clazz, config,
13014
+ null, marker.type
13015
+ );
13016
+ }
13017
+ }
13018
+ this.element = dom.setInnerHtml(this.element, html.join(""));
13019
+ };
13020
+
13021
+ this.$getTop = function(row, layerConfig) {
13022
+ return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight;
13023
+ };
13024
+
13025
+ /**
13026
+ * Draws a marker, which spans a range of text in a single line
13027
+ */
13028
+ this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig) {
13029
+ // selection start
13030
+ var row = range.start.row;
13031
+
13032
+ var lineRange = new Range(
13033
+ row, range.start.column,
13034
+ row, this.session.getScreenLastRowColumn(row)
13035
+ );
13036
+ this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 1, "text");
13037
+
13038
+ // selection end
13039
+ row = range.end.row;
13040
+ lineRange = new Range(row, 0, row, range.end.column);
13041
+ this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 0, "text");
13042
+
13043
+ for (row = range.start.row + 1; row < range.end.row; row++) {
13044
+ lineRange.start.row = row;
13045
+ lineRange.end.row = row;
13046
+ lineRange.end.column = this.session.getScreenLastRowColumn(row);
13047
+ this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 1, "text");
13048
+ }
13049
+ };
13050
+
13051
+ /**
13052
+ * Draws a multi line marker, where lines span the full width
13053
+ */
13054
+ this.drawMultiLineMarker = function(stringBuilder, range, clazz, layerConfig, type) {
13055
+ var padding = type === "background" ? 0 : this.$padding;
13056
+ var layerWidth = layerConfig.width + 2 * this.$padding - padding;
13057
+ // from selection start to the end of the line
13058
+ var height = layerConfig.lineHeight;
13059
+ var width = Math.round(layerWidth - (range.start.column * layerConfig.characterWidth));
13060
+ var top = this.$getTop(range.start.row, layerConfig);
13061
+ var left = Math.round(
13062
+ padding + range.start.column * layerConfig.characterWidth
13063
+ );
13064
+
13065
+ stringBuilder.push(
13066
+ "<div class='", clazz, "' style='",
13067
+ "height:", height, "px;",
13068
+ "width:", width, "px;",
13069
+ "top:", top, "px;",
13070
+ "left:", left, "px;'></div>"
13071
+ );
13072
+
13073
+ // from start of the last line to the selection end
13074
+ top = this.$getTop(range.end.row, layerConfig);
13075
+ width = Math.round(range.end.column * layerConfig.characterWidth);
13076
+
13077
+ stringBuilder.push(
13078
+ "<div class='", clazz, "' style='",
13079
+ "height:", height, "px;",
13080
+ "width:", width, "px;",
13081
+ "top:", top, "px;",
13082
+ "left:", padding, "px;'></div>"
13083
+ );
13084
+
13085
+ // all the complete lines
13086
+ height = (range.end.row - range.start.row - 1) * layerConfig.lineHeight;
13087
+ if (height < 0)
13088
+ return;
13089
+ top = this.$getTop(range.start.row + 1, layerConfig);
13090
+
13091
+ stringBuilder.push(
13092
+ "<div class='", clazz, "' style='",
13093
+ "height:", height, "px;",
13094
+ "width:", layerWidth, "px;",
13095
+ "top:", top, "px;",
13096
+ "left:", padding, "px;'></div>"
13097
+ );
13098
+ };
13099
+
13100
+ /**
13101
+ * Draws a marker which covers one single full line
13102
+ */
13103
+ this.drawSingleLineMarker = function(stringBuilder, range, clazz, layerConfig, extraLength, type) {
13104
+ var padding = type === "background" ? 0 : this.$padding;
13105
+ var height = layerConfig.lineHeight;
13106
+
13107
+ if (type === "background")
13108
+ var width = layerConfig.width;
13109
+ else
13110
+ width = Math.round((range.end.column + (extraLength || 0) - range.start.column) * layerConfig.characterWidth);
13111
+
13112
+ var top = this.$getTop(range.start.row, layerConfig);
13113
+ var left = Math.round(
13114
+ padding + range.start.column * layerConfig.characterWidth
13115
+ );
13116
+
13117
+ stringBuilder.push(
13118
+ "<div class='", clazz, "' style='",
13119
+ "height:", height, "px;",
13120
+ "width:", width, "px;",
13121
+ "top:", top, "px;",
13122
+ "left:", left,"px;'></div>"
13123
+ );
13124
+ };
13125
+
13126
+ }).call(Marker.prototype);
13127
+
13128
+ exports.Marker = Marker;
13129
+
13130
+ });
13131
+ /* vim:ts=4:sts=4:sw=4:
13132
+ * ***** BEGIN LICENSE BLOCK *****
13133
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
13134
+ *
13135
+ * The contents of this file are subject to the Mozilla Public License Version
13136
+ * 1.1 (the "License"); you may not use this file except in compliance with
13137
+ * the License. You may obtain a copy of the License at
13138
+ * http://www.mozilla.org/MPL/
13139
+ *
13140
+ * Software distributed under the License is distributed on an "AS IS" basis,
13141
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13142
+ * for the specific language governing rights and limitations under the
13143
+ * License.
13144
+ *
13145
+ * The Original Code is Ajax.org Code Editor (ACE).
13146
+ *
13147
+ * The Initial Developer of the Original Code is
13148
+ * Ajax.org B.V.
13149
+ * Portions created by the Initial Developer are Copyright (C) 2010
13150
+ * the Initial Developer. All Rights Reserved.
13151
+ *
13152
+ * Contributor(s):
13153
+ * Fabian Jakobs <fabian AT ajax DOT org>
13154
+ * Julian Viereck <julian DOT viereck AT gmail DOT com>
13155
+ * Mihai Sucan <mihai.sucan@gmail.com>
13156
+ * Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
13157
+ *
13158
+ * Alternatively, the contents of this file may be used under the terms of
13159
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
13160
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
13161
+ * in which case the provisions of the GPL or the LGPL are applicable instead
13162
+ * of those above. If you wish to allow use of your version of this file only
13163
+ * under the terms of either the GPL or the LGPL, and not to allow others to
13164
+ * use your version of this file under the terms of the MPL, indicate your
13165
+ * decision by deleting the provisions above and replace them with the notice
13166
+ * and other provisions required by the GPL or the LGPL. If you do not delete
13167
+ * the provisions above, a recipient may use your version of this file under
13168
+ * the terms of any one of the MPL, the GPL or the LGPL.
13169
+ *
13170
+ * ***** END LICENSE BLOCK ***** */
13171
+
13172
+ ace.define('ace/layer/text', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/dom', 'ace/lib/lang', 'ace/lib/useragent', 'ace/lib/event_emitter'], function(require, exports, module) {
13173
+ "use strict";
13174
+
13175
+ var oop = require("../lib/oop");
13176
+ var dom = require("../lib/dom");
13177
+ var lang = require("../lib/lang");
13178
+ var useragent = require("../lib/useragent");
13179
+ var EventEmitter = require("../lib/event_emitter").EventEmitter;
13180
+
13181
+ var Text = function(parentEl) {
13182
+ this.element = dom.createElement("div");
13183
+ this.element.className = "ace_layer ace_text-layer";
13184
+ parentEl.appendChild(this.element);
13185
+
13186
+ this.$characterSize = this.$measureSizes() || {width: 0, height: 0};
13187
+ this.$pollSizeChanges();
13188
+ };
13189
+
13190
+ (function() {
13191
+
13192
+ oop.implement(this, EventEmitter);
13193
+
13194
+ this.EOF_CHAR = "\xB6"; //"&para;";
13195
+ this.EOL_CHAR = "\xAC"; //"&not;";
13196
+ this.TAB_CHAR = "\u2192"; //"&rarr;";
13197
+ this.SPACE_CHAR = "\xB7"; //"&middot;";
13198
+ this.$padding = 0;
13199
+
13200
+ this.setPadding = function(padding) {
13201
+ this.$padding = padding;
13202
+ this.element.style.padding = "0 " + padding + "px";
13203
+ };
13204
+
13205
+ this.getLineHeight = function() {
13206
+ return this.$characterSize.height || 1;
13207
+ };
13208
+
13209
+ this.getCharacterWidth = function() {
13210
+ return this.$characterSize.width || 1;
13211
+ };
13212
+
13213
+ this.checkForSizeChanges = function() {
13214
+ var size = this.$measureSizes();
13215
+ if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
13216
+ this.$characterSize = size;
13217
+ this._emit("changeCharacterSize", {data: size});
13218
+ }
13219
+ };
13220
+
13221
+ this.$pollSizeChanges = function() {
13222
+ var self = this;
13223
+ this.$pollSizeChangesTimer = setInterval(function() {
13224
+ self.checkForSizeChanges();
13225
+ }, 500);
13226
+ };
13227
+
13228
+ this.$fontStyles = {
13229
+ fontFamily : 1,
13230
+ fontSize : 1,
13231
+ fontWeight : 1,
13232
+ fontStyle : 1,
13233
+ lineHeight : 1
13234
+ };
13235
+
13236
+ this.$measureSizes = function() {
13237
+ var n = 1000;
13238
+ if (!this.$measureNode) {
13239
+ var measureNode = this.$measureNode = dom.createElement("div");
13240
+ var style = measureNode.style;
13241
+
13242
+ style.width = style.height = "auto";
13243
+ style.left = style.top = (-n * 40) + "px";
13244
+
13245
+ style.visibility = "hidden";
13246
+ style.position = "absolute";
13247
+ style.overflow = "visible";
13248
+ style.whiteSpace = "nowrap";
13249
+
13250
+ // in FF 3.6 monospace fonts can have a fixed sub pixel width.
13251
+ // that's why we have to measure many characters
13252
+ // Note: characterWidth can be a float!
13253
+ measureNode.innerHTML = lang.stringRepeat("Xy", n);
13254
+
13255
+ if (this.element.ownerDocument.body) {
13256
+ this.element.ownerDocument.body.appendChild(measureNode);
13257
+ } else {
13258
+ var container = this.element.parentNode;
13259
+ while (!dom.hasCssClass(container, "ace_editor"))
13260
+ container = container.parentNode;
13261
+ container.appendChild(measureNode);
13262
+ }
13263
+
13264
+ }
13265
+
13266
+ // Size and width can be null if the editor is not visible or
13267
+ // detached from the document
13268
+ if (!this.element.offsetWidth)
13269
+ return null;
13270
+
13271
+ var style = this.$measureNode.style;
13272
+ var computedStyle = dom.computedStyle(this.element);
13273
+ for (var prop in this.$fontStyles)
13274
+ style[prop] = computedStyle[prop];
13275
+
13276
+ var size = {
13277
+ height: this.$measureNode.offsetHeight,
13278
+ width: this.$measureNode.offsetWidth / (n * 2)
13279
+ };
13280
+
13281
+ // Size and width can be null if the editor is not visible or
13282
+ // detached from the document
13283
+ if (size.width == 0 && size.height == 0)
13284
+ return null;
13285
+
13286
+ return size;
13287
+ };
13288
+
13289
+ this.setSession = function(session) {
13290
+ this.session = session;
13291
+ };
13292
+
13293
+ this.showInvisibles = false;
13294
+ this.setShowInvisibles = function(showInvisibles) {
13295
+ if (this.showInvisibles == showInvisibles)
13296
+ return false;
13297
+
13298
+ this.showInvisibles = showInvisibles;
13299
+ return true;
13300
+ };
13301
+
13302
+ this.$tabStrings = [];
13303
+ this.$computeTabString = function() {
13304
+ var tabSize = this.session.getTabSize();
13305
+ var tabStr = this.$tabStrings = [0];
13306
+ for (var i = 1; i < tabSize + 1; i++) {
13307
+ if (this.showInvisibles) {
13308
+ tabStr.push("<span class='ace_invisible'>"
13309
+ + this.TAB_CHAR
13310
+ + new Array(i).join("&#160;")
13311
+ + "</span>");
13312
+ } else {
13313
+ tabStr.push(new Array(i+1).join("&#160;"));
13314
+ }
13315
+ }
13316
+
13317
+ };
13318
+
13319
+ this.updateLines = function(config, firstRow, lastRow) {
13320
+ this.$computeTabString();
13321
+ // Due to wrap line changes there can be new lines if e.g.
13322
+ // the line to updated wrapped in the meantime.
13323
+ if (this.config.lastRow != config.lastRow ||
13324
+ this.config.firstRow != config.firstRow) {
13325
+ this.scrollLines(config);
13326
+ }
13327
+ this.config = config;
13328
+
13329
+ var first = Math.max(firstRow, config.firstRow);
13330
+ var last = Math.min(lastRow, config.lastRow);
13331
+
13332
+ var lineElements = this.element.childNodes;
13333
+ var lineElementsIdx = 0;
13334
+
13335
+ for (var row = config.firstRow; row < first; row++) {
13336
+ var foldLine = this.session.getFoldLine(row);
13337
+ if (foldLine) {
13338
+ if (foldLine.containsRow(first)) {
13339
+ first = foldLine.start.row;
13340
+ break;
13341
+ } else {
13342
+ row = foldLine.end.row;
13343
+ }
13344
+ }
13345
+ lineElementsIdx ++;
13346
+ }
13347
+
13348
+ for (var i=first; i<=last; i++) {
13349
+ var lineElement = lineElements[lineElementsIdx++];
13350
+ if (!lineElement)
13351
+ continue;
13352
+
13353
+ var html = [];
13354
+ var tokens = this.session.getTokens(i, i);
13355
+ this.$renderLine(html, i, tokens[0].tokens, !this.$useLineGroups());
13356
+ lineElement = dom.setInnerHtml(lineElement, html.join(""));
13357
+
13358
+ i = this.session.getRowFoldEnd(i);
13359
+ }
13360
+ };
13361
+
13362
+ this.scrollLines = function(config) {
13363
+ this.$computeTabString();
13364
+ var oldConfig = this.config;
13365
+ this.config = config;
13366
+
13367
+ if (!oldConfig || oldConfig.lastRow < config.firstRow)
13368
+ return this.update(config);
13369
+
13370
+ if (config.lastRow < oldConfig.firstRow)
13371
+ return this.update(config);
13372
+
13373
+ var el = this.element;
13374
+ if (oldConfig.firstRow < config.firstRow)
13375
+ for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--)
13376
+ el.removeChild(el.firstChild);
13377
+
13378
+ if (oldConfig.lastRow > config.lastRow)
13379
+ for (var row=this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row>0; row--)
13380
+ el.removeChild(el.lastChild);
13381
+
13382
+ if (config.firstRow < oldConfig.firstRow) {
13383
+ var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1);
13384
+ if (el.firstChild)
13385
+ el.insertBefore(fragment, el.firstChild);
13386
+ else
13387
+ el.appendChild(fragment);
13388
+ }
13389
+
13390
+ if (config.lastRow > oldConfig.lastRow) {
13391
+ var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow);
13392
+ el.appendChild(fragment);
13393
+ }
13394
+ };
13395
+
13396
+ this.$renderLinesFragment = function(config, firstRow, lastRow) {
13397
+ var fragment = this.element.ownerDocument.createDocumentFragment(),
13398
+ row = firstRow,
13399
+ fold = this.session.getNextFoldLine(row),
13400
+ foldStart = fold ?fold.start.row :Infinity;
13401
+
13402
+ while (true) {
13403
+ if (row > foldStart) {
13404
+ row = fold.end.row+1;
13405
+ fold = this.session.getNextFoldLine(row, fold);
13406
+ foldStart = fold ?fold.start.row :Infinity;
13407
+ }
13408
+ if (row > lastRow)
13409
+ break;
13410
+
13411
+ var container = dom.createElement("div");
13412
+
13413
+ var html = [];
13414
+ // Get the tokens per line as there might be some lines in between
13415
+ // beeing folded.
13416
+ // OPTIMIZE: If there is a long block of unfolded lines, just make
13417
+ // this call once for that big block of unfolded lines.
13418
+ var tokens = this.session.getTokens(row, row);
13419
+ if (tokens.length == 1)
13420
+ this.$renderLine(html, row, tokens[0].tokens, false);
13421
+
13422
+ // don't use setInnerHtml since we are working with an empty DIV
13423
+ container.innerHTML = html.join("");
13424
+ if (this.$useLineGroups()) {
13425
+ container.className = 'ace_line_group';
13426
+ fragment.appendChild(container);
13427
+ } else {
13428
+ var lines = container.childNodes
13429
+ while(lines.length)
13430
+ fragment.appendChild(lines[0]);
13431
+ }
13432
+
13433
+ row++;
13434
+ }
13435
+ return fragment;
13436
+ };
13437
+
13438
+ this.update = function(config) {
13439
+ this.$computeTabString();
13440
+ this.config = config;
13441
+
13442
+ var html = [];
13443
+ var firstRow = config.firstRow, lastRow = config.lastRow;
13444
+
13445
+ var row = firstRow,
13446
+ fold = this.session.getNextFoldLine(row),
13447
+ foldStart = fold ?fold.start.row :Infinity;
13448
+
13449
+ while (true) {
13450
+ if (row > foldStart) {
13451
+ row = fold.end.row+1;
13452
+ fold = this.session.getNextFoldLine(row, fold);
13453
+ foldStart = fold ?fold.start.row :Infinity;
13454
+ }
13455
+ if (row > lastRow)
13456
+ break;
13457
+
13458
+ if (this.$useLineGroups())
13459
+ html.push("<div class='ace_line_group'>")
13460
+
13461
+ // Get the tokens per line as there might be some lines in between
13462
+ // beeing folded.
13463
+ // OPTIMIZE: If there is a long block of unfolded lines, just make
13464
+ // this call once for that big block of unfolded lines.
13465
+ var tokens = this.session.getTokens(row, row);
13466
+ if (tokens.length == 1)
13467
+ this.$renderLine(html, row, tokens[0].tokens, false);
13468
+
13469
+ if (this.$useLineGroups())
13470
+ html.push("</div>"); // end the line group
13471
+
13472
+ row++;
13473
+ }
13474
+ this.element = dom.setInnerHtml(this.element, html.join(""));
13475
+ };
13476
+
13477
+ this.$textToken = {
13478
+ "text": true,
13479
+ "rparen": true,
13480
+ "lparen": true
13481
+ };
13482
+
13483
+ this.$renderToken = function(stringBuilder, screenColumn, token, value) {
13484
+ var self = this;
13485
+ var replaceReg = /\t|&|<|( +)|([\v\f \u00a0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000])|[\u1100-\u115F]|[\u11A3-\u11A7]|[\u11FA-\u11FF]|[\u2329-\u232A]|[\u2E80-\u2E99]|[\u2E9B-\u2EF3]|[\u2F00-\u2FD5]|[\u2FF0-\u2FFB]|[\u3000-\u303E]|[\u3041-\u3096]|[\u3099-\u30FF]|[\u3105-\u312D]|[\u3131-\u318E]|[\u3190-\u31BA]|[\u31C0-\u31E3]|[\u31F0-\u321E]|[\u3220-\u3247]|[\u3250-\u32FE]|[\u3300-\u4DBF]|[\u4E00-\uA48C]|[\uA490-\uA4C6]|[\uA960-\uA97C]|[\uAC00-\uD7A3]|[\uD7B0-\uD7C6]|[\uD7CB-\uD7FB]|[\uF900-\uFAFF]|[\uFE10-\uFE19]|[\uFE30-\uFE52]|[\uFE54-\uFE66]|[\uFE68-\uFE6B]|[\uFF01-\uFF60]|[\uFFE0-\uFFE6]/g;
13486
+ var replaceFunc = function(c, a, b, tabIdx, idx4) {
13487
+ if (c.charCodeAt(0) == 32) {
13488
+ return new Array(c.length+1).join("&#160;");
13489
+ } else if (c == "\t") {
13490
+ var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx);
13491
+ screenColumn += tabSize - 1;
13492
+ return self.$tabStrings[tabSize];
13493
+ } else if (c == "&") {
13494
+ if (useragent.isOldGecko)
13495
+ return "&";
13496
+ else
13497
+ return "&amp;";
13498
+ } else if (c == "<") {
13499
+ return "&lt;";
13500
+ } else if (c == "\u3000") {
13501
+ // U+3000 is both invisible AND full-width, so must be handled uniquely
13502
+ var classToUse = self.showInvisibles ? "ace_cjk ace_invisible" : "ace_cjk";
13503
+ var space = self.showInvisibles ? self.SPACE_CHAR : "";
13504
+ screenColumn += 1;
13505
+ return "<span class='" + classToUse + "' style='width:" +
13506
+ (self.config.characterWidth * 2) +
13507
+ "px'>" + space + "</span>";
13508
+ } else if (c.match(/[\v\f \u00a0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000]/)) {
13509
+ if (self.showInvisibles) {
13510
+ var space = new Array(c.length+1).join(self.SPACE_CHAR);
13511
+ return "<span class='ace_invisible'>" + space + "</span>";
13512
+ } else {
13513
+ return "&#160;";
13514
+ }
13515
+ } else {
13516
+ screenColumn += 1;
13517
+ return "<span class='ace_cjk' style='width:" +
13518
+ (self.config.characterWidth * 2) +
13519
+ "px'>" + c + "</span>";
13520
+ }
13521
+ };
13522
+
13523
+ var output = value.replace(replaceReg, replaceFunc);
13524
+
13525
+ if (!this.$textToken[token.type]) {
13526
+ var classes = "ace_" + token.type.replace(/\./g, " ace_");
13527
+ var style = "";
13528
+ if (token.type == "fold")
13529
+ style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' ";
13530
+ stringBuilder.push("<span class='", classes, "'", style, ">", output, "</span>");
13531
+ }
13532
+ else {
13533
+ stringBuilder.push(output);
13534
+ }
13535
+ return screenColumn + value.length;
13536
+ };
13537
+
13538
+ this.$renderLineCore = function(stringBuilder, lastRow, tokens, splits, onlyContents) {
13539
+ var chars = 0;
13540
+ var split = 0;
13541
+ var splitChars;
13542
+ var screenColumn = 0;
13543
+ var self = this;
13544
+
13545
+ if (!splits || splits.length == 0)
13546
+ splitChars = Number.MAX_VALUE;
13547
+ else
13548
+ splitChars = splits[0];
13549
+
13550
+ if (!onlyContents) {
13551
+ stringBuilder.push("<div class='ace_line' style='height:",
13552
+ this.config.lineHeight, "px",
13553
+ "'>"
13554
+ );
13555
+ }
13556
+
13557
+ for (var i = 0; i < tokens.length; i++) {
13558
+ var token = tokens[i];
13559
+ var value = token.value;
13560
+
13561
+ if (chars + value.length < splitChars) {
13562
+ screenColumn = self.$renderToken(
13563
+ stringBuilder, screenColumn, token, value
13564
+ );
13565
+ chars += value.length;
13566
+ }
13567
+ else {
13568
+ while (chars + value.length >= splitChars) {
13569
+ screenColumn = self.$renderToken(
13570
+ stringBuilder, screenColumn,
13571
+ token, value.substring(0, splitChars - chars)
13572
+ );
13573
+ value = value.substring(splitChars - chars);
13574
+ chars = splitChars;
13575
+
13576
+ if (!onlyContents) {
13577
+ stringBuilder.push("</div>",
13578
+ "<div class='ace_line' style='height:",
13579
+ this.config.lineHeight, "px",
13580
+ "'>"
13581
+ );
13582
+ }
13583
+
13584
+ split ++;
13585
+ screenColumn = 0;
13586
+ splitChars = splits[split] || Number.MAX_VALUE;
13587
+ }
13588
+ if (value.length != 0) {
13589
+ chars += value.length;
13590
+ screenColumn = self.$renderToken(
13591
+ stringBuilder, screenColumn, token, value
13592
+ );
13593
+ }
13594
+ }
13595
+ }
13596
+
13597
+ if (this.showInvisibles) {
13598
+ if (lastRow !== this.session.getLength() - 1)
13599
+ stringBuilder.push("<span class='ace_invisible'>" + this.EOL_CHAR + "</span>");
13600
+ else
13601
+ stringBuilder.push("<span class='ace_invisible'>" + this.EOF_CHAR + "</span>");
13602
+ }
13603
+ if (!onlyContents)
13604
+ stringBuilder.push("</div>");
13605
+ };
13606
+
13607
+ this.$renderLine = function(stringBuilder, row, tokens, onlyContents) {
13608
+ // Check if the line to render is folded or not. If not, things are
13609
+ // simple, otherwise, we need to fake some things...
13610
+ if (!this.session.isRowFolded(row)) {
13611
+ var splits = this.session.getRowSplitData(row);
13612
+ this.$renderLineCore(stringBuilder, row, tokens, splits, onlyContents);
13613
+ } else {
13614
+ this.$renderFoldLine(stringBuilder, row, tokens, onlyContents);
13615
+ }
13616
+ };
13617
+
13618
+ this.$renderFoldLine = function(stringBuilder, row, tokens, onlyContents) {
13619
+ var session = this.session,
13620
+ foldLine = session.getFoldLine(row),
13621
+ renderTokens = [];
13622
+
13623
+ function addTokens(tokens, from, to) {
13624
+ var idx = 0, col = 0;
13625
+ while ((col + tokens[idx].value.length) < from) {
13626
+ col += tokens[idx].value.length;
13627
+ idx++;
13628
+
13629
+ if (idx == tokens.length) {
13630
+ return;
13631
+ }
13632
+ }
13633
+ if (col != from) {
13634
+ var value = tokens[idx].value.substring(from - col);
13635
+ // Check if the token value is longer then the from...to spacing.
13636
+ if (value.length > (to - from)) {
13637
+ value = value.substring(0, to - from);
13638
+ }
13639
+
13640
+ renderTokens.push({
13641
+ type: tokens[idx].type,
13642
+ value: value
13643
+ });
13644
+
13645
+ col = from + value.length;
13646
+ idx += 1;
13647
+ }
13648
+
13649
+ while (col < to) {
13650
+ var value = tokens[idx].value;
13651
+ if (value.length + col > to) {
13652
+ value = value.substring(0, to - col);
13653
+ }
13654
+ renderTokens.push({
13655
+ type: tokens[idx].type,
13656
+ value: value
13657
+ });
13658
+ col += value.length;
13659
+ idx += 1;
13660
+ }
13661
+ }
13662
+
13663
+ foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) {
13664
+ if (placeholder) {
13665
+ renderTokens.push({
13666
+ type: "fold",
13667
+ value: placeholder
13668
+ });
13669
+ } else {
13670
+ if (isNewRow) {
13671
+ tokens = this.session.getTokens(row, row)[0].tokens;
13672
+ }
13673
+ if (tokens.length != 0) {
13674
+ addTokens(tokens, lastColumn, column);
13675
+ }
13676
+ }
13677
+ }.bind(this), foldLine.end.row, this.session.getLine(foldLine.end.row).length);
13678
+
13679
+ // TODO: Build a fake splits array!
13680
+ var splits = this.session.$useWrapMode?this.session.$wrapData[row]:null;
13681
+ this.$renderLineCore(stringBuilder, row, renderTokens, splits, onlyContents);
13682
+ };
13683
+
13684
+ this.$useLineGroups = function() {
13685
+ // For the updateLines function to work correctly, it's important that the
13686
+ // child nodes of this.element correspond on a 1-to-1 basis to rows in the
13687
+ // document (as distinct from lines on the screen). For sessions that are
13688
+ // wrapped, this means we need to add a layer to the node hierarchy (tagged
13689
+ // with the class name ace_line_group).
13690
+ return this.session.getUseWrapMode();
13691
+ };
13692
+
13693
+ this.destroy = function() {
13694
+ clearInterval(this.$pollSizeChangesTimer);
13695
+ if (this.$measureNode)
13696
+ this.$measureNode.parentNode.removeChild(this.$measureNode);
13697
+ delete this.$measureNode;
13698
+ };
13699
+
13700
+ }).call(Text.prototype);
13701
+
13702
+ exports.Text = Text;
13703
+
13704
+ });
13705
+ /* vim:ts=4:sts=4:sw=4:
13706
+ * ***** BEGIN LICENSE BLOCK *****
13707
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
13708
+ *
13709
+ * The contents of this file are subject to the Mozilla Public License Version
13710
+ * 1.1 (the "License"); you may not use this file except in compliance with
13711
+ * the License. You may obtain a copy of the License at
13712
+ * http://www.mozilla.org/MPL/
13713
+ *
13714
+ * Software distributed under the License is distributed on an "AS IS" basis,
13715
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13716
+ * for the specific language governing rights and limitations under the
13717
+ * License.
13718
+ *
13719
+ * The Original Code is Ajax.org Code Editor (ACE).
13720
+ *
13721
+ * The Initial Developer of the Original Code is
13722
+ * Ajax.org B.V.
13723
+ * Portions created by the Initial Developer are Copyright (C) 2010
13724
+ * the Initial Developer. All Rights Reserved.
13725
+ *
13726
+ * Contributor(s):
13727
+ * Fabian Jakobs <fabian AT ajax DOT org>
13728
+ * Julian Viereck <julian.viereck@gmail.com>
13729
+ *
13730
+ * Alternatively, the contents of this file may be used under the terms of
13731
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
13732
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
13733
+ * in which case the provisions of the GPL or the LGPL are applicable instead
13734
+ * of those above. If you wish to allow use of your version of this file only
13735
+ * under the terms of either the GPL or the LGPL, and not to allow others to
13736
+ * use your version of this file under the terms of the MPL, indicate your
13737
+ * decision by deleting the provisions above and replace them with the notice
13738
+ * and other provisions required by the GPL or the LGPL. If you do not delete
13739
+ * the provisions above, a recipient may use your version of this file under
13740
+ * the terms of any one of the MPL, the GPL or the LGPL.
13741
+ *
13742
+ * ***** END LICENSE BLOCK ***** */
13743
+
13744
+ ace.define('ace/layer/cursor', ['require', 'exports', 'module' , 'ace/lib/dom'], function(require, exports, module) {
13745
+ "use strict";
13746
+
13747
+ var dom = require("../lib/dom");
13748
+
13749
+ var Cursor = function(parentEl) {
13750
+ this.element = dom.createElement("div");
13751
+ this.element.className = "ace_layer ace_cursor-layer";
13752
+ parentEl.appendChild(this.element);
13753
+
13754
+ this.cursor = dom.createElement("div");
13755
+ this.cursor.className = "ace_cursor ace_hidden";
13756
+ this.element.appendChild(this.cursor);
13757
+
13758
+ this.isVisible = false;
13759
+ };
13760
+
13761
+ (function() {
13762
+
13763
+ this.$padding = 0;
13764
+ this.setPadding = function(padding) {
13765
+ this.$padding = padding;
13766
+ };
13767
+
13768
+ this.setSession = function(session) {
13769
+ this.session = session;
13770
+ };
13771
+
13772
+ this.hideCursor = function() {
13773
+ this.isVisible = false;
13774
+ dom.addCssClass(this.cursor, "ace_hidden");
13775
+ clearInterval(this.blinkId);
13776
+ };
13777
+
13778
+ this.showCursor = function() {
13779
+ this.isVisible = true;
13780
+ dom.removeCssClass(this.cursor, "ace_hidden");
13781
+ this.cursor.style.visibility = "visible";
13782
+ this.restartTimer();
13783
+ };
13784
+
13785
+ this.restartTimer = function() {
13786
+ clearInterval(this.blinkId);
13787
+ if (!this.isVisible) {
13788
+ return;
13789
+ }
13790
+
13791
+ var cursor = this.cursor;
13792
+ this.blinkId = setInterval(function() {
13793
+ cursor.style.visibility = "hidden";
13794
+ setTimeout(function() {
13795
+ cursor.style.visibility = "visible";
13796
+ }, 400);
13797
+ }, 1000);
13798
+ };
13799
+
13800
+ this.getPixelPosition = function(position, onScreen) {
13801
+ if (!this.config || !this.session) {
13802
+ return {
13803
+ left : 0,
13804
+ top : 0
13805
+ };
13806
+ }
13807
+
13808
+ if (!position)
13809
+ position = this.session.selection.getCursor();
13810
+ var pos = this.session.documentToScreenPosition(position);
13811
+ var cursorLeft = Math.round(this.$padding +
13812
+ pos.column * this.config.characterWidth);
13813
+ var cursorTop = (pos.row - (onScreen ? this.config.firstRowScreen : 0)) *
13814
+ this.config.lineHeight;
13815
+
13816
+ return {
13817
+ left : cursorLeft,
13818
+ top : cursorTop
13819
+ };
13820
+ };
13821
+
13822
+ this.update = function(config) {
13823
+ this.config = config;
13824
+
13825
+ this.pixelPos = this.getPixelPosition(null, true);
13826
+
13827
+ this.cursor.style.left = this.pixelPos.left + "px";
13828
+ this.cursor.style.top = this.pixelPos.top + "px";
13829
+ this.cursor.style.width = config.characterWidth + "px";
13830
+ this.cursor.style.height = config.lineHeight + "px";
13831
+
13832
+ var overwrite = this.session.getOverwrite()
13833
+ if (overwrite != this.overwrite) {
13834
+ this.overwrite = overwrite;
13835
+ if (overwrite)
13836
+ dom.addCssClass(this.cursor, "ace_overwrite");
13837
+ else
13838
+ dom.removeCssClass(this.cursor, "ace_overwrite");
13839
+ }
13840
+
13841
+ this.restartTimer();
13842
+ };
13843
+
13844
+ this.destroy = function() {
13845
+ clearInterval(this.blinkId);
13846
+ }
13847
+
13848
+ }).call(Cursor.prototype);
13849
+
13850
+ exports.Cursor = Cursor;
13851
+
13852
+ });
13853
+ /* ***** BEGIN LICENSE BLOCK *****
13854
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
13855
+ *
13856
+ * The contents of this file are subject to the Mozilla Public License Version
13857
+ * 1.1 (the "License"); you may not use this file except in compliance with
13858
+ * the License. You may obtain a copy of the License at
13859
+ * http://www.mozilla.org/MPL/
13860
+ *
13861
+ * Software distributed under the License is distributed on an "AS IS" basis,
13862
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13863
+ * for the specific language governing rights and limitations under the
13864
+ * License.
13865
+ *
13866
+ * The Original Code is Ajax.org Code Editor (ACE).
13867
+ *
13868
+ * The Initial Developer of the Original Code is
13869
+ * Ajax.org B.V.
13870
+ * Portions created by the Initial Developer are Copyright (C) 2010
13871
+ * the Initial Developer. All Rights Reserved.
13872
+ *
13873
+ * Contributor(s):
13874
+ * Fabian Jakobs <fabian AT ajax DOT org>
13875
+ * Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
13876
+ *
13877
+ * Alternatively, the contents of this file may be used under the terms of
13878
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
13879
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
13880
+ * in which case the provisions of the GPL or the LGPL are applicable instead
13881
+ * of those above. If you wish to allow use of your version of this file only
13882
+ * under the terms of either the GPL or the LGPL, and not to allow others to
13883
+ * use your version of this file under the terms of the MPL, indicate your
13884
+ * decision by deleting the provisions above and replace them with the notice
13885
+ * and other provisions required by the GPL or the LGPL. If you do not delete
13886
+ * the provisions above, a recipient may use your version of this file under
13887
+ * the terms of any one of the MPL, the GPL or the LGPL.
13888
+ *
13889
+ * ***** END LICENSE BLOCK ***** */
13890
+
13891
+ ace.define('ace/scrollbar', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/dom', 'ace/lib/event', 'ace/lib/event_emitter'], function(require, exports, module) {
13892
+ "use strict";
13893
+
13894
+ var oop = require("./lib/oop");
13895
+ var dom = require("./lib/dom");
13896
+ var event = require("./lib/event");
13897
+ var EventEmitter = require("./lib/event_emitter").EventEmitter;
13898
+
13899
+ var ScrollBar = function(parent) {
13900
+ this.element = dom.createElement("div");
13901
+ this.element.className = "ace_sb";
13902
+
13903
+ this.inner = dom.createElement("div");
13904
+ this.element.appendChild(this.inner);
13905
+
13906
+ parent.appendChild(this.element);
13907
+
13908
+ // in OSX lion the scrollbars appear to have no width. In this case resize
13909
+ // the to show the scrollbar but still pretend that the scrollbar has a width
13910
+ // of 0px
13911
+ // in Firefox 6+ scrollbar is hidden if element has the same width as scrollbar
13912
+ // make element a little bit wider to retain scrollbar when page is zoomed
13913
+ this.width = dom.scrollbarWidth(parent.ownerDocument);
13914
+ this.element.style.width = (this.width || 15) + 5 + "px";
13915
+
13916
+ event.addListener(this.element, "scroll", this.onScroll.bind(this));
13917
+ };
13918
+
13919
+ (function() {
13920
+ oop.implement(this, EventEmitter);
13921
+
13922
+ this.onScroll = function() {
13923
+ this._emit("scroll", {data: this.element.scrollTop});
13924
+ };
13925
+
13926
+ this.getWidth = function() {
13927
+ return this.width;
13928
+ };
13929
+
13930
+ this.setHeight = function(height) {
13931
+ this.element.style.height = height + "px";
13932
+ };
13933
+
13934
+ this.setInnerHeight = function(height) {
13935
+ this.inner.style.height = height + "px";
13936
+ };
13937
+
13938
+ this.setScrollTop = function(scrollTop) {
13939
+ this.element.scrollTop = scrollTop;
13940
+ };
13941
+
13942
+ }).call(ScrollBar.prototype);
13943
+
13944
+ exports.ScrollBar = ScrollBar;
13945
+ });
13946
+ /* ***** BEGIN LICENSE BLOCK *****
13947
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
13948
+ *
13949
+ * The contents of this file are subject to the Mozilla Public License Version
13950
+ * 1.1 (the "License"); you may not use this file except in compliance with
13951
+ * the License. You may obtain a copy of the License at
13952
+ * http://www.mozilla.org/MPL/
13953
+ *
13954
+ * Software distributed under the License is distributed on an "AS IS" basis,
13955
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13956
+ * for the specific language governing rights and limitations under the
13957
+ * License.
13958
+ *
13959
+ * The Original Code is Ajax.org Code Editor (ACE).
13960
+ *
13961
+ * The Initial Developer of the Original Code is
13962
+ * Ajax.org B.V.
13963
+ * Portions created by the Initial Developer are Copyright (C) 2010
13964
+ * the Initial Developer. All Rights Reserved.
13965
+ *
13966
+ * Contributor(s):
13967
+ * Fabian Jakobs <fabian AT ajax DOT org>
13968
+ * Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
13969
+ *
13970
+ * Alternatively, the contents of this file may be used under the terms of
13971
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
13972
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
13973
+ * in which case the provisions of the GPL or the LGPL are applicable instead
13974
+ * of those above. If you wish to allow use of your version of this file only
13975
+ * under the terms of either the GPL or the LGPL, and not to allow others to
13976
+ * use your version of this file under the terms of the MPL, indicate your
13977
+ * decision by deleting the provisions above and replace them with the notice
13978
+ * and other provisions required by the GPL or the LGPL. If you do not delete
13979
+ * the provisions above, a recipient may use your version of this file under
13980
+ * the terms of any one of the MPL, the GPL or the LGPL.
13981
+ *
13982
+ * ***** END LICENSE BLOCK ***** */
13983
+
13984
+ ace.define('ace/renderloop', ['require', 'exports', 'module' , 'ace/lib/event'], function(require, exports, module) {
13985
+ "use strict";
13986
+
13987
+ var event = require("./lib/event");
13988
+
13989
+ var RenderLoop = function(onRender, win) {
13990
+ this.onRender = onRender;
13991
+ this.pending = false;
13992
+ this.changes = 0;
13993
+ this.window = win || window;
13994
+ };
13995
+
13996
+ (function() {
13997
+
13998
+ this.schedule = function(change) {
13999
+ //this.onRender(change);
14000
+ //return;
14001
+ this.changes = this.changes | change;
14002
+ if (!this.pending) {
14003
+ this.pending = true;
14004
+ var _self = this;
14005
+ event.nextTick(function() {
14006
+ _self.pending = false;
14007
+ var changes;
14008
+ while (changes = _self.changes) {
14009
+ _self.changes = 0;
14010
+ _self.onRender(changes);
14011
+ }
14012
+ }, this.window);
14013
+ }
14014
+ };
14015
+
14016
+ }).call(RenderLoop.prototype);
14017
+
14018
+ exports.RenderLoop = RenderLoop;
14019
+ });
14020
+ ace.define("text!ace/css/editor.css", [], "@import url(//fonts.googleapis.com/css?family=Droid+Sans+Mono);\n" +
14021
+ "\n" +
14022
+ "\n" +
14023
+ ".ace_editor {\n" +
14024
+ " position: absolute;\n" +
14025
+ " overflow: hidden;\n" +
14026
+ " font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Droid Sans Mono', 'Consolas', monospace;\n" +
14027
+ " font-size: 12px;\n" +
14028
+ "}\n" +
14029
+ "\n" +
14030
+ ".ace_scroller {\n" +
14031
+ " position: absolute;\n" +
14032
+ " overflow-x: scroll;\n" +
14033
+ " overflow-y: hidden;\n" +
14034
+ "}\n" +
14035
+ "\n" +
14036
+ ".ace_content {\n" +
14037
+ " position: absolute;\n" +
14038
+ " box-sizing: border-box;\n" +
14039
+ " -moz-box-sizing: border-box;\n" +
14040
+ " -webkit-box-sizing: border-box;\n" +
14041
+ " cursor: text;\n" +
14042
+ "}\n" +
14043
+ "\n" +
14044
+ ".ace_composition {\n" +
14045
+ " position: absolute;\n" +
14046
+ " background: #555;\n" +
14047
+ " color: #DDD;\n" +
14048
+ " z-index: 4;\n" +
14049
+ "}\n" +
14050
+ "\n" +
14051
+ ".ace_gutter {\n" +
14052
+ " position: absolute;\n" +
14053
+ " overflow : hidden;\n" +
14054
+ " height: 100%;\n" +
14055
+ " width: auto;\n" +
14056
+ " cursor: default;\n" +
14057
+ "}\n" +
14058
+ "\n" +
14059
+ ".ace_gutter-cell {\n" +
14060
+ " padding-left: 19px;\n" +
14061
+ " padding-right: 6px;\n" +
14062
+ "}\n" +
14063
+ "\n" +
14064
+ ".ace_gutter-cell.ace_error {\n" +
14065
+ " background-image: url(\"data:image/gif,GIF89a%10%00%10%00%D5%00%00%F5or%F5%87%88%F5nr%F4ns%EBmq%F5z%7F%DDJT%DEKS%DFOW%F1Yc%F2ah%CE(7%CE)8%D18E%DD%40M%F2KZ%EBU%60%F4%60m%DCir%C8%16(%C8%19*%CE%255%F1%3FR%F1%3FS%E6%AB%B5%CA%5DI%CEn%5E%F7%A2%9A%C9G%3E%E0a%5B%F7%89%85%F5yy%F6%82%80%ED%82%80%FF%BF%BF%E3%C4%C4%FF%FF%FF%FF%FF%FF%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00!%F9%04%01%00%00%25%00%2C%00%00%00%00%10%00%10%00%00%06p%C0%92pH%2C%1A%8F%C8%D2H%93%E1d4%23%E4%88%D3%09mB%1DN%B48%F5%90%40%60%92G%5B%94%20%3E%22%D2%87%24%FA%20%24%C5%06A%00%20%B1%07%02B%A38%89X.v%17%82%11%13q%10%0Fi%24%0F%8B%10%7BD%12%0Ei%09%92%09%0EpD%18%15%24%0A%9Ci%05%0C%18F%18%0B%07%04%01%04%06%A0H%18%12%0D%14%0D%12%A1I%B3%B4%B5IA%00%3B\");\n" +
14066
+ " background-repeat: no-repeat;\n" +
14067
+ " background-position: 2px center;\n" +
14068
+ "}\n" +
14069
+ "\n" +
14070
+ ".ace_gutter-cell.ace_warning {\n" +
14071
+ " background-image: url(\"data:image/gif,GIF89a%10%00%10%00%D5%00%00%FF%DBr%FF%DE%81%FF%E2%8D%FF%E2%8F%FF%E4%96%FF%E3%97%FF%E5%9D%FF%E6%9E%FF%EE%C1%FF%C8Z%FF%CDk%FF%D0s%FF%D4%81%FF%D5%82%FF%D5%83%FF%DC%97%FF%DE%9D%FF%E7%B8%FF%CCl%7BQ%13%80U%15%82W%16%81U%16%89%5B%18%87%5B%18%8C%5E%1A%94d%1D%C5%83-%C9%87%2F%C6%84.%C6%85.%CD%8B2%C9%871%CB%8A3%CD%8B5%DC%98%3F%DF%9BB%E0%9CC%E1%A5U%CB%871%CF%8B5%D1%8D6%DB%97%40%DF%9AB%DD%99B%E3%B0p%E7%CC%AE%FF%FF%FF%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00!%F9%04%01%00%00%2F%00%2C%00%00%00%00%10%00%10%00%00%06a%C0%97pH%2C%1A%8FH%A1%ABTr%25%87%2B%04%82%F4%7C%B9X%91%08%CB%99%1C!%26%13%84*iJ9(%15G%CA%84%14%01%1A%97%0C%03%80%3A%9A%3E%81%84%3E%11%08%B1%8B%20%02%12%0F%18%1A%0F%0A%03'F%1C%04%0B%10%16%18%10%0B%05%1CF%1D-%06%07%9A%9A-%1EG%1B%A0%A1%A0U%A4%A5%A6BA%00%3B\");\n" +
14072
+ " background-repeat: no-repeat;\n" +
14073
+ " background-position: 2px center;\n" +
14074
+ "}\n" +
14075
+ "\n" +
14076
+ ".ace_gutter-cell.ace_info {\n" +
14077
+ " background-image: url(\"data:image/gif;base64,R0lGODlhEAAQAMQAAAAAAEFBQVJSUl5eXmRkZGtra39/f4WFhYmJiZGRkaampry8vMPDw8zMzNXV1dzc3OTk5Orq6vDw8P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABQALAAAAAAQABAAAAUuICWOZGmeaBml5XGwFCQSBGyXRSAwtqQIiRuiwIM5BoYVbEFIyGCQoeJGrVptIQA7\");\n" +
14078
+ " background-repeat: no-repeat;\n" +
14079
+ " background-position: 2px center;\n" +
14080
+ "}\n" +
14081
+ "\n" +
14082
+ ".ace_editor .ace_sb {\n" +
14083
+ " position: absolute;\n" +
14084
+ " overflow-x: hidden;\n" +
14085
+ " overflow-y: scroll;\n" +
14086
+ " right: 0;\n" +
14087
+ "}\n" +
14088
+ "\n" +
14089
+ ".ace_editor .ace_sb div {\n" +
14090
+ " position: absolute;\n" +
14091
+ " width: 1px;\n" +
14092
+ " left: 0;\n" +
14093
+ "}\n" +
14094
+ "\n" +
14095
+ ".ace_editor .ace_print_margin_layer {\n" +
14096
+ " z-index: 0;\n" +
14097
+ " position: absolute;\n" +
14098
+ " overflow: hidden;\n" +
14099
+ " margin: 0;\n" +
14100
+ " left: 0;\n" +
14101
+ " height: 100%;\n" +
14102
+ " width: 100%;\n" +
14103
+ "}\n" +
14104
+ "\n" +
14105
+ ".ace_editor .ace_print_margin {\n" +
14106
+ " position: absolute;\n" +
14107
+ " height: 100%;\n" +
14108
+ "}\n" +
14109
+ "\n" +
14110
+ ".ace_editor textarea {\n" +
14111
+ " position: fixed;\n" +
14112
+ " z-index: 0;\n" +
14113
+ " width: 10px;\n" +
14114
+ " height: 30px;\n" +
14115
+ " opacity: 0;\n" +
14116
+ " background: transparent;\n" +
14117
+ " appearance: none;\n" +
14118
+ " -moz-appearance: none;\n" +
14119
+ " border: none;\n" +
14120
+ " resize: none;\n" +
14121
+ " outline: none;\n" +
14122
+ " overflow: hidden;\n" +
14123
+ "}\n" +
14124
+ "\n" +
14125
+ ".ace_layer {\n" +
14126
+ " z-index: 1;\n" +
14127
+ " position: absolute;\n" +
14128
+ " overflow: hidden;\n" +
14129
+ " white-space: nowrap;\n" +
14130
+ " height: 100%;\n" +
14131
+ " width: 100%;\n" +
14132
+ " box-sizing: border-box;\n" +
14133
+ " -moz-box-sizing: border-box;\n" +
14134
+ " -webkit-box-sizing: border-box;\n" +
14135
+ " /* setting pointer-events: auto; on node under the mouse, which changes\n" +
14136
+ " during scroll, will break mouse wheel scrolling in Safari */\n" +
14137
+ " pointer-events: none;\n" +
14138
+ "}\n" +
14139
+ "\n" +
14140
+ ".ace_gutter .ace_layer {\n" +
14141
+ " position: relative;\n" +
14142
+ " min-width: 40px;\n" +
14143
+ " text-align: right;\n" +
14144
+ " pointer-events: auto;\n" +
14145
+ "}\n" +
14146
+ "\n" +
14147
+ ".ace_text-layer {\n" +
14148
+ " color: black;\n" +
14149
+ "}\n" +
14150
+ "\n" +
14151
+ ".ace_cjk {\n" +
14152
+ " display: inline-block;\n" +
14153
+ " text-align: center;\n" +
14154
+ "}\n" +
14155
+ "\n" +
14156
+ ".ace_cursor-layer {\n" +
14157
+ " z-index: 4;\n" +
14158
+ "}\n" +
14159
+ "\n" +
14160
+ ".ace_cursor {\n" +
14161
+ " z-index: 4;\n" +
14162
+ " position: absolute;\n" +
14163
+ "}\n" +
14164
+ "\n" +
14165
+ ".ace_cursor.ace_hidden {\n" +
14166
+ " opacity: 0.2;\n" +
14167
+ "}\n" +
14168
+ "\n" +
14169
+ ".ace_line {\n" +
14170
+ " white-space: nowrap;\n" +
14171
+ "}\n" +
14172
+ "\n" +
14173
+ ".ace_marker-layer .ace_step {\n" +
14174
+ " position: absolute;\n" +
14175
+ " z-index: 3;\n" +
14176
+ "}\n" +
14177
+ "\n" +
14178
+ ".ace_marker-layer .ace_selection {\n" +
14179
+ " position: absolute;\n" +
14180
+ " z-index: 4;\n" +
14181
+ "}\n" +
14182
+ "\n" +
14183
+ ".ace_marker-layer .ace_bracket {\n" +
14184
+ " position: absolute;\n" +
14185
+ " z-index: 5;\n" +
14186
+ "}\n" +
14187
+ "\n" +
14188
+ ".ace_marker-layer .ace_active_line {\n" +
14189
+ " position: absolute;\n" +
14190
+ " z-index: 2;\n" +
14191
+ "}\n" +
14192
+ "\n" +
14193
+ ".ace_marker-layer .ace_selected_word {\n" +
14194
+ " position: absolute;\n" +
14195
+ " z-index: 6;\n" +
14196
+ " box-sizing: border-box;\n" +
14197
+ " -moz-box-sizing: border-box;\n" +
14198
+ " -webkit-box-sizing: border-box;\n" +
14199
+ "}\n" +
14200
+ "\n" +
14201
+ ".ace_line .ace_fold {\n" +
14202
+ " box-sizing: border-box;\n" +
14203
+ " -moz-box-sizing: border-box;\n" +
14204
+ " -webkit-box-sizing: border-box;\n" +
14205
+ " \n" +
14206
+ " display: inline-block;\n" +
14207
+ " height: 11px;\n" +
14208
+ " margin-top: -2px;\n" +
14209
+ " vertical-align: middle;\n" +
14210
+ "\n" +
14211
+ " background-image: \n" +
14212
+ " url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%11%00%00%00%09%08%06%00%00%00%D4%E8%C7%0C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%00%B5IDAT(%15%A5%91%3D%0E%02!%10%85ac%E1%05%D6%CE%D6%C6%CE%D2%E8%ED%CD%DE%C0%C6%D6N.%E0V%F8%3D%9Ca%891XH%C2%BE%D9y%3F%90!%E6%9C%C3%BFk%E5%011%C6-%F5%C8N%04%DF%BD%FF%89%DFt%83DN%60%3E%F3%AB%A0%DE%1A%5Dg%BE%10Q%97%1B%40%9C%A8o%10%8F%5E%828%B4%1B%60%87%F6%02%26%85%1Ch%1E%C1%2B%5Bk%FF%86%EE%B7j%09%9A%DA%9B%ACe%A3%F9%EC%DA!9%B4%D5%A6%81%86%86%98%CC%3C%5B%40%FA%81%B3%E9%CB%23%94%C16Azo%05%D4%E1%C1%95a%3B%8A'%A0%E8%CC%17%22%85%1D%BA%00%A2%FA%DC%0A%94%D1%D1%8D%8B%3A%84%17B%C7%60%1A%25Z%FC%8D%00%00%00%00IEND%AEB%60%82\"),\n" +
14213
+ " url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%007%08%06%00%00%00%C4%DD%80C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%00%3AIDAT8%11c%FC%FF%FF%7F%18%03%1A%60%01%F2%3F%A0%891%80%04%FF%11-%F8%17%9BJ%E2%05%B1ZD%81v%26t%E7%80%F8%A3%82h%A12%1A%20%A3%01%02%0F%01%BA%25%06%00%19%C0%0D%AEF%D5%3ES%00%00%00%00IEND%AEB%60%82\");\n" +
14214
+ " background-repeat: no-repeat, repeat-x;\n" +
14215
+ " background-position: center center, top left;\n" +
14216
+ " color: transparent;\n" +
14217
+ "\n" +
14218
+ " border: 1px solid black;\n" +
14219
+ " -moz-border-radius: 2px;\n" +
14220
+ " -webkit-border-radius: 2px;\n" +
14221
+ " border-radius: 2px;\n" +
14222
+ " \n" +
14223
+ " cursor: pointer;\n" +
14224
+ " pointer-events: auto;\n" +
14225
+ "}\n" +
14226
+ "\n" +
14227
+ ".ace_dark .ace_fold {\n" +
14228
+ "}\n" +
14229
+ "\n" +
14230
+ ".ace_fold:hover{\n" +
14231
+ " background-image: \n" +
14232
+ " url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%11%00%00%00%09%08%06%00%00%00%D4%E8%C7%0C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%00%B5IDAT(%15%A5%91%3D%0E%02!%10%85ac%E1%05%D6%CE%D6%C6%CE%D2%E8%ED%CD%DE%C0%C6%D6N.%E0V%F8%3D%9Ca%891XH%C2%BE%D9y%3F%90!%E6%9C%C3%BFk%E5%011%C6-%F5%C8N%04%DF%BD%FF%89%DFt%83DN%60%3E%F3%AB%A0%DE%1A%5Dg%BE%10Q%97%1B%40%9C%A8o%10%8F%5E%828%B4%1B%60%87%F6%02%26%85%1Ch%1E%C1%2B%5Bk%FF%86%EE%B7j%09%9A%DA%9B%ACe%A3%F9%EC%DA!9%B4%D5%A6%81%86%86%98%CC%3C%5B%40%FA%81%B3%E9%CB%23%94%C16Azo%05%D4%E1%C1%95a%3B%8A'%A0%E8%CC%17%22%85%1D%BA%00%A2%FA%DC%0A%94%D1%D1%8D%8B%3A%84%17B%C7%60%1A%25Z%FC%8D%00%00%00%00IEND%AEB%60%82\"),\n" +
14233
+ " url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%007%08%06%00%00%00%C4%DD%80C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%003IDAT8%11c%FC%FF%FF%7F%3E%03%1A%60%01%F2%3F%A3%891%80%04%FFQ%26%F8w%C0%B43%A1%DB%0C%E2%8F%0A%A2%85%CAh%80%8C%06%08%3C%04%E8%96%18%00%A3S%0D%CD%CF%D8%C1%9D%00%00%00%00IEND%AEB%60%82\");\n" +
14234
+ " background-repeat: no-repeat, repeat-x;\n" +
14235
+ " background-position: center center, top left;\n" +
14236
+ "}\n" +
14237
+ "\n" +
14238
+ ".ace_dragging .ace_content {\n" +
14239
+ " cursor: move;\n" +
14240
+ "}\n" +
14241
+ "\n" +
14242
+ ".ace_folding-enabled > .ace_gutter-cell {\n" +
14243
+ " padding-right: 13px;\n" +
14244
+ "}\n" +
14245
+ "\n" +
14246
+ ".ace_fold-widget {\n" +
14247
+ " box-sizing: border-box;\n" +
14248
+ " -moz-box-sizing: border-box;\n" +
14249
+ " -webkit-box-sizing: border-box;\n" +
14250
+ "\n" +
14251
+ " margin: 0 -12px 1px 1px;\n" +
14252
+ " display: inline-block;\n" +
14253
+ " height: 14px;\n" +
14254
+ " width: 11px;\n" +
14255
+ " vertical-align: text-bottom;\n" +
14256
+ " \n" +
14257
+ " background-image: url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%00%05%08%06%00%00%00%8Do%26%E5%00%00%004IDATx%DAe%8A%B1%0D%000%0C%C2%F2%2CK%96%BC%D0%8F9%81%88H%E9%D0%0E%96%C0%10%92%3E%02%80%5E%82%E4%A9*-%EEsw%C8%CC%11%EE%96w%D8%DC%E9*Eh%0C%151(%00%00%00%00IEND%AEB%60%82\");\n" +
14258
+ " background-repeat: no-repeat;\n" +
14259
+ " background-position: center 5px;\n" +
14260
+ "\n" +
14261
+ " border-radius: 3px;\n" +
14262
+ "}\n" +
14263
+ "\n" +
14264
+ ".ace_fold-widget.end {\n" +
14265
+ " background-image: url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%00%05%08%06%00%00%00%8Do%26%E5%00%00%004IDATx%DAm%C7%C1%09%000%08C%D1%8C%ECE%C8E(%8E%EC%02)%1EZJ%F1%C1'%04%07I%E1%E5%EE%CAL%F5%A2%99%99%22%E2%D6%1FU%B5%FE0%D9x%A7%26Wz5%0E%D5%00%00%00%00IEND%AEB%60%82\");\n" +
14266
+ "}\n" +
14267
+ "\n" +
14268
+ ".ace_fold-widget.closed {\n" +
14269
+ " background-image: url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%03%00%00%00%06%08%06%00%00%00%06%E5%24%0C%00%00%009IDATx%DA5%CA%C1%09%000%08%03%C0%AC*(%3E%04%C1%0D%BA%B1%23%A4Uh%E0%20%81%C0%CC%F8%82%81%AA%A2%AArGfr%88%08%11%11%1C%DD%7D%E0%EE%5B%F6%F6%CB%B8%05Q%2F%E9tai%D9%00%00%00%00IEND%AEB%60%82\");\n" +
14270
+ "}\n" +
14271
+ "\n" +
14272
+ ".ace_fold-widget:hover {\n" +
14273
+ " border: 1px solid rgba(0, 0, 0, 0.3);\n" +
14274
+ " background-color: rgba(255, 255, 255, 0.2);\n" +
14275
+ " -moz-box-shadow:inset 0 1px 1px rgba(255, 255, 255, 0.7);\n" +
14276
+ " -moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\n" +
14277
+ " -webkit-box-shadow:inset 0 1px 1px rgba(255, 255, 255, 0.7);\n" +
14278
+ " -webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\n" +
14279
+ " box-shadow:inset 0 1px 1px rgba(255, 255, 255, 0.7);\n" +
14280
+ " box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\n" +
14281
+ " background-position: center 4px;\n" +
14282
+ "}\n" +
14283
+ "\n" +
14284
+ ".ace_fold-widget:active {\n" +
14285
+ " border: 1px solid rgba(0, 0, 0, 0.4);\n" +
14286
+ " background-color: rgba(0, 0, 0, 0.05);\n" +
14287
+ " -moz-box-shadow:inset 0 1px 1px rgba(255, 255, 255);\n" +
14288
+ " -moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\n" +
14289
+ " -webkit-box-shadow:inset 0 1px 1px rgba(255, 255, 255);\n" +
14290
+ " -webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\n" +
14291
+ " box-shadow:inset 0 1px 1px rgba(255, 255, 255);\n" +
14292
+ " box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\n" +
14293
+ "}\n" +
14294
+ "\n" +
14295
+ ".ace_fold-widget.invalid {\n" +
14296
+ " background-color: #FFB4B4;\n" +
14297
+ " border-color: #DE5555;\n" +
14298
+ "}\n" +
14299
+ "");
14300
+
14301
+ /* ***** BEGIN LICENSE BLOCK *****
14302
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
14303
+ *
14304
+ * The contents of this file are subject to the Mozilla Public License Version
14305
+ * 1.1 (the "License"); you may not use this file except in compliance with
14306
+ * the License. You may obtain a copy of the License at
14307
+ * http://www.mozilla.org/MPL/
14308
+ *
14309
+ * Software distributed under the License is distributed on an "AS IS" basis,
14310
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14311
+ * for the specific language governing rights and limitations under the
14312
+ * License.
14313
+ *
14314
+ * The Original Code is Ajax.org Code Editor (ACE).
14315
+ *
14316
+ * The Initial Developer of the Original Code is
14317
+ * Ajax.org B.V.
14318
+ * Portions created by the Initial Developer are Copyright (C) 2010
14319
+ * the Initial Developer. All Rights Reserved.
14320
+ *
14321
+ * Contributor(s):
14322
+ * Fabian Jakobs <fabian AT ajax DOT org>
14323
+ *
14324
+ * Alternatively, the contents of this file may be used under the terms of
14325
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
14326
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
14327
+ * in which case the provisions of the GPL or the LGPL are applicable instead
14328
+ * of those above. If you wish to allow use of your version of this file only
14329
+ * under the terms of either the GPL or the LGPL, and not to allow others to
14330
+ * use your version of this file under the terms of the MPL, indicate your
14331
+ * decision by deleting the provisions above and replace them with the notice
14332
+ * and other provisions required by the GPL or the LGPL. If you do not delete
14333
+ * the provisions above, a recipient may use your version of this file under
14334
+ * the terms of any one of the MPL, the GPL or the LGPL.
14335
+ *
14336
+ * ***** END LICENSE BLOCK ***** */
14337
+
14338
+ ace.define('ace/worker/worker_client', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter', 'ace/config'], function(require, exports, module) {
14339
+ "use strict";
14340
+
14341
+ var oop = require("../lib/oop");
14342
+ var EventEmitter = require("../lib/event_emitter").EventEmitter;
14343
+ var config = require("../config");
14344
+
14345
+ var WorkerClient = function(topLevelNamespaces, packagedJs, mod, classname) {
14346
+
14347
+ this.changeListener = this.changeListener.bind(this);
14348
+
14349
+ if (config.get("packaged")) {
14350
+ this.$worker = new Worker(config.get("workerPath") + "/" + packagedJs);
14351
+ }
14352
+ else {
14353
+ var workerUrl = this.$normalizePath(require.nameToUrl("ace/worker/worker", null, "_"));
14354
+ this.$worker = new Worker(workerUrl);
14355
+
14356
+ var tlns = {};
14357
+ for (var i=0; i<topLevelNamespaces.length; i++) {
14358
+ var ns = topLevelNamespaces[i];
14359
+ var path = this.$normalizePath(require.nameToUrl(ns, null, "_").replace(/.js$/, ""));
14360
+
14361
+ tlns[ns] = path;
14362
+ }
14363
+ }
14364
+
14365
+ this.$worker.postMessage({
14366
+ init : true,
14367
+ tlns: tlns,
14368
+ module: mod,
14369
+ classname: classname
14370
+ });
14371
+
14372
+ this.callbackId = 1;
14373
+ this.callbacks = {};
14374
+
14375
+ var _self = this;
14376
+ this.$worker.onerror = function(e) {
14377
+ window.console && console.log && console.log(e);
14378
+ throw e;
14379
+ };
14380
+ this.$worker.onmessage = function(e) {
14381
+ var msg = e.data;
14382
+ switch(msg.type) {
14383
+ case "log":
14384
+ window.console && console.log && console.log(msg.data);
14385
+ break;
14386
+
14387
+ case "event":
14388
+ _self._emit(msg.name, {data: msg.data});
14389
+ break;
14390
+
14391
+ case "call":
14392
+ var callback = _self.callbacks[msg.id];
14393
+ if (callback) {
14394
+ callback(msg.data);
14395
+ delete _self.callbacks[msg.id];
14396
+ }
14397
+ break;
14398
+ }
14399
+ };
14400
+ };
14401
+
14402
+ (function(){
14403
+
14404
+ oop.implement(this, EventEmitter);
14405
+
14406
+ this.$normalizePath = function(path) {
14407
+ path = path.replace(/^[a-z]+:\/\/[^\/]+/, ""); // Remove domain name and rebuild it
14408
+ path = location.protocol + "//" + location.host
14409
+ // paths starting with a slash are relative to the root (host)
14410
+ + (path.charAt(0) == "/" ? "" : location.pathname.replace(/\/[^\/]*$/, ""))
14411
+ + "/" + path.replace(/^[\/]+/, "");
14412
+ return path;
14413
+ };
14414
+
14415
+ this.terminate = function() {
14416
+ this._emit("terminate", {});
14417
+ this.$worker.terminate();
14418
+ this.$worker = null;
14419
+ this.$doc.removeEventListener("change", this.changeListener);
14420
+ this.$doc = null;
14421
+ };
14422
+
14423
+ this.send = function(cmd, args) {
14424
+ this.$worker.postMessage({command: cmd, args: args});
14425
+ };
14426
+
14427
+ this.call = function(cmd, args, callback) {
14428
+ if (callback) {
14429
+ var id = this.callbackId++;
14430
+ this.callbacks[id] = callback;
14431
+ args.push(id);
14432
+ }
14433
+ this.send(cmd, args);
14434
+ };
14435
+
14436
+ this.emit = function(event, data) {
14437
+ try {
14438
+ // firefox refuses to clone objects which have function properties
14439
+ // TODO: cleanup event
14440
+ this.$worker.postMessage({event: event, data: {data: data.data}});
14441
+ }
14442
+ catch(ex) {}
14443
+ };
14444
+
14445
+ this.attachToDocument = function(doc) {
14446
+ if(this.$doc)
14447
+ this.terminate();
14448
+
14449
+ this.$doc = doc;
14450
+ this.call("setValue", [doc.getValue()]);
14451
+ doc.on("change", this.changeListener);
14452
+ };
14453
+
14454
+ this.changeListener = function(e) {
14455
+ e.range = {
14456
+ start: e.data.range.start,
14457
+ end: e.data.range.end
14458
+ };
14459
+ this.emit("change", e);
14460
+ };
14461
+
14462
+ }).call(WorkerClient.prototype);
14463
+
14464
+ exports.WorkerClient = WorkerClient;
14465
+
14466
+ });
14467
+ /* ***** BEGIN LICENSE BLOCK *****
14468
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
14469
+ *
14470
+ * The contents of this file are subject to the Mozilla Public License Version
14471
+ * 1.1 (the "License"); you may not use this file except in compliance with
14472
+ * the License. You may obtain a copy of the License at
14473
+ * http://www.mozilla.org/MPL/
14474
+ *
14475
+ * Software distributed under the License is distributed on an "AS IS" basis,
14476
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14477
+ * for the specific language governing rights and limitations under the
14478
+ * License.
14479
+ *
14480
+ * The Original Code is Mozilla Skywriter.
14481
+ *
14482
+ * The Initial Developer of the Original Code is
14483
+ * Mozilla.
14484
+ * Portions created by the Initial Developer are Copyright (C) 2009
14485
+ * the Initial Developer. All Rights Reserved.
14486
+ *
14487
+ * Contributor(s):
14488
+ * Fabian Jakobs <fabian AT ajax DOT org>
14489
+ * Julian Viereck (julian.viereck@gmail.com)
14490
+ *
14491
+ * Alternatively, the contents of this file may be used under the terms of
14492
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
14493
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
14494
+ * in which case the provisions of the GPL or the LGPL are applicable instead
14495
+ * of those above. If you wish to allow use of your version of this file only
14496
+ * under the terms of either the GPL or the LGPL, and not to allow others to
14497
+ * use your version of this file under the terms of the MPL, indicate your
14498
+ * decision by deleting the provisions above and replace them with the notice
14499
+ * and other provisions required by the GPL or the LGPL. If you do not delete
14500
+ * the provisions above, a recipient may use your version of this file under
14501
+ * the terms of any one of the MPL, the GPL or the LGPL.
14502
+ *
14503
+ * ***** END LICENSE BLOCK ***** */
14504
+
14505
+ ace.define('ace/keyboard/hash_handler', ['require', 'exports', 'module' , 'ace/lib/keys'], function(require, exports, module) {
14506
+ "use strict";
14507
+
14508
+ var keyUtil = require("../lib/keys");
14509
+
14510
+ function HashHandler(config) {
14511
+ this.setConfig(config);
14512
+ }
14513
+
14514
+ (function() {
14515
+ function splitSafe(s, separator, limit, bLowerCase) {
14516
+ return (bLowerCase && s.toLowerCase() || s)
14517
+ .replace(/(?:^\s+|\n|\s+$)/g, "")
14518
+ .split(new RegExp("[\\s ]*" + separator + "[\\s ]*", "g"), limit || 999);
14519
+ }
14520
+
14521
+ function parseKeys(keys, val, ret) {
14522
+ var key,
14523
+ hashId = 0,
14524
+ parts = splitSafe(keys, "\\-", null, true),
14525
+ i = 0,
14526
+ l = parts.length;
14527
+
14528
+ for (; i < l; ++i) {
14529
+ if (keyUtil.KEY_MODS[parts[i]])
14530
+ hashId = hashId | keyUtil.KEY_MODS[parts[i]];
14531
+ else
14532
+ key = parts[i] || "-"; //when empty, the splitSafe removed a '-'
14533
+ }
14534
+
14535
+ (ret[hashId] || (ret[hashId] = {}))[key] = val;
14536
+ return ret;
14537
+ }
14538
+
14539
+ function objectReverse(obj, keySplit) {
14540
+ var i, j, l, key,
14541
+ ret = {};
14542
+ for (i in obj) {
14543
+ key = obj[i];
14544
+ if (keySplit && typeof key == "string") {
14545
+ key = key.split(keySplit);
14546
+ for (j = 0, l = key.length; j < l; ++j)
14547
+ parseKeys.call(this, key[j], i, ret);
14548
+ }
14549
+ else {
14550
+ parseKeys.call(this, key, i, ret);
14551
+ }
14552
+ }
14553
+ return ret;
14554
+ }
14555
+
14556
+ this.setConfig = function(config) {
14557
+ this.$config = config;
14558
+ if (typeof this.$config.reverse == "undefined")
14559
+ this.$config.reverse = objectReverse.call(this, this.$config, "|");
14560
+ };
14561
+
14562
+ /**
14563
+ * This function is called by keyBinding.
14564
+ */
14565
+ this.handleKeyboard = function(data, hashId, textOrKey, keyCode) {
14566
+ // Figure out if a commandKey was pressed or just some text was insert.
14567
+ if (hashId != 0 || keyCode != 0) {
14568
+ return {
14569
+ command: (this.$config.reverse[hashId] || {})[textOrKey]
14570
+ }
14571
+ } else {
14572
+ return {
14573
+ command: "inserttext",
14574
+ args: {
14575
+ text: textOrKey
14576
+ }
14577
+ }
14578
+ }
14579
+ }
14580
+ }).call(HashHandler.prototype)
14581
+
14582
+ exports.HashHandler = HashHandler;
14583
+ });
14584
+ /* ***** BEGIN LICENSE BLOCK *****
14585
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
14586
+ *
14587
+ * The contents of this file are subject to the Mozilla Public License Version
14588
+ * 1.1 (the "License"); you may not use this file except in compliance with
14589
+ * the License. You may obtain a copy of the License at
14590
+ * http://www.mozilla.org/MPL/
14591
+ *
14592
+ * Software distributed under the License is distributed on an "AS IS" basis,
14593
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14594
+ * for the specific language governing rights and limitations under the
14595
+ * License.
14596
+ *
14597
+ * The Original Code is Mozilla Skywriter.
14598
+ *
14599
+ * The Initial Developer of the Original Code is
14600
+ * Mozilla.
14601
+ * Portions created by the Initial Developer are Copyright (C) 2009
14602
+ * the Initial Developer. All Rights Reserved.
14603
+ *
14604
+ * Contributor(s):
14605
+ * Julian Viereck (julian.viereck@gmail.com)
14606
+ *
14607
+ * Alternatively, the contents of this file may be used under the terms of
14608
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
14609
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
14610
+ * in which case the provisions of the GPL or the LGPL are applicable instead
14611
+ * of those above. If you wish to allow use of your version of this file only
14612
+ * under the terms of either the GPL or the LGPL, and not to allow others to
14613
+ * use your version of this file under the terms of the MPL, indicate your
14614
+ * decision by deleting the provisions above and replace them with the notice
14615
+ * and other provisions required by the GPL or the LGPL. If you do not delete
14616
+ * the provisions above, a recipient may use your version of this file under
14617
+ * the terms of any one of the MPL, the GPL or the LGPL.
14618
+ *
14619
+ * ***** END LICENSE BLOCK ***** */
14620
+
14621
+ ace.define('ace/keyboard/state_handler', ['require', 'exports', 'module' ], function(require, exports, module) {
14622
+ "use strict";
14623
+
14624
+ // If you're developing a new keymapping and want to get an idea what's going
14625
+ // on, then enable debugging.
14626
+ var DEBUG = false;
14627
+
14628
+ function StateHandler(keymapping) {
14629
+ this.keymapping = this.$buildKeymappingRegex(keymapping);
14630
+ }
14631
+
14632
+ StateHandler.prototype = {
14633
+ /**
14634
+ * Build the RegExp from the keymapping as RegExp can't stored directly
14635
+ * in the metadata JSON and as the RegExp used to match the keys/buffer
14636
+ * need to be adapted.
14637
+ */
14638
+ $buildKeymappingRegex: function(keymapping) {
14639
+ for (var state in keymapping) {
14640
+ this.$buildBindingsRegex(keymapping[state]);
14641
+ }
14642
+ return keymapping;
14643
+ },
14644
+
14645
+ $buildBindingsRegex: function(bindings) {
14646
+ // Escape a given Regex string.
14647
+ bindings.forEach(function(binding) {
14648
+ if (binding.key) {
14649
+ binding.key = new RegExp('^' + binding.key + '$');
14650
+ } else if (Array.isArray(binding.regex)) {
14651
+ if (!('key' in binding))
14652
+ binding.key = new RegExp('^' + binding.regex[1] + '$');
14653
+ binding.regex = new RegExp(binding.regex.join('') + '$');
14654
+ } else if (binding.regex) {
14655
+ binding.regex = new RegExp(binding.regex + '$');
14656
+ }
14657
+ });
14658
+ },
14659
+
14660
+ $composeBuffer: function(data, hashId, key, e) {
14661
+ // Initialize the data object.
14662
+ if (data.state == null || data.buffer == null) {
14663
+ data.state = "start";
14664
+ data.buffer = "";
14665
+ }
14666
+
14667
+ var keyArray = [];
14668
+ if (hashId & 1) keyArray.push("ctrl");
14669
+ if (hashId & 8) keyArray.push("command");
14670
+ if (hashId & 2) keyArray.push("option");
14671
+ if (hashId & 4) keyArray.push("shift");
14672
+ if (key) keyArray.push(key);
14673
+
14674
+ var symbolicName = keyArray.join("-");
14675
+ var bufferToUse = data.buffer + symbolicName;
14676
+
14677
+ // Don't add the symbolic name to the key buffer if the alt_ key is
14678
+ // part of the symbolic name. If it starts with alt_, this means
14679
+ // that the user hit an alt keycombo and there will be a single,
14680
+ // new character detected after this event, which then will be
14681
+ // added to the buffer (e.g. alt_j will result in ∆).
14682
+ //
14683
+ // We test for 2 and not for & 2 as we only want to exclude the case where
14684
+ // the option key is pressed alone.
14685
+ if (hashId != 2) {
14686
+ data.buffer = bufferToUse;
14687
+ }
14688
+
14689
+ var bufferObj = {
14690
+ bufferToUse: bufferToUse,
14691
+ symbolicName: symbolicName,
14692
+ };
14693
+
14694
+ if (e) {
14695
+ bufferObj.keyIdentifier = e.keyIdentifier
14696
+ }
14697
+
14698
+ return bufferObj;
14699
+ },
14700
+
14701
+ $find: function(data, buffer, symbolicName, hashId, key, keyIdentifier) {
14702
+ // Holds the command to execute and the args if a command matched.
14703
+ var result = {};
14704
+
14705
+ // Loop over all the bindings of the keymap until a match is found.
14706
+ this.keymapping[data.state].some(function(binding) {
14707
+ var match;
14708
+
14709
+ // Check if the key matches.
14710
+ if (binding.key && !binding.key.test(symbolicName)) {
14711
+ return false;
14712
+ }
14713
+
14714
+ // Check if the regex matches.
14715
+ if (binding.regex && !(match = binding.regex.exec(buffer))) {
14716
+ return false;
14717
+ }
14718
+
14719
+ // Check if the match function matches.
14720
+ if (binding.match && !binding.match(buffer, hashId, key, symbolicName, keyIdentifier)) {
14721
+ return false;
14722
+ }
14723
+
14724
+ // Check for disallowed matches.
14725
+ if (binding.disallowMatches) {
14726
+ for (var i = 0; i < binding.disallowMatches.length; i++) {
14727
+ if (!!match[binding.disallowMatches[i]]) {
14728
+ return false;
14729
+ }
14730
+ }
14731
+ }
14732
+
14733
+ // If there is a command to execute, then figure out the
14734
+ // command and the arguments.
14735
+ if (binding.exec) {
14736
+ result.command = binding.exec;
14737
+
14738
+ // Build the arguments.
14739
+ if (binding.params) {
14740
+ var value;
14741
+ result.args = {};
14742
+ binding.params.forEach(function(param) {
14743
+ if (param.match != null && match != null) {
14744
+ value = match[param.match] || param.defaultValue;
14745
+ } else {
14746
+ value = param.defaultValue;
14747
+ }
14748
+
14749
+ if (param.type === 'number') {
14750
+ value = parseInt(value);
14751
+ }
14752
+
14753
+ result.args[param.name] = value;
14754
+ });
14755
+ }
14756
+ data.buffer = "";
14757
+ }
14758
+
14759
+ // Handle the 'then' property.
14760
+ if (binding.then) {
14761
+ data.state = binding.then;
14762
+ data.buffer = "";
14763
+ }
14764
+
14765
+ // If no command is set, then execute the "null" fake command.
14766
+ if (result.command == null) {
14767
+ result.command = "null";
14768
+ }
14769
+
14770
+ if (DEBUG) {
14771
+ console.log("KeyboardStateMapper#find", binding);
14772
+ }
14773
+ return true;
14774
+ });
14775
+
14776
+ if (result.command) {
14777
+ return result;
14778
+ } else {
14779
+ data.buffer = "";
14780
+ return false;
14781
+ }
14782
+ },
14783
+
14784
+ /**
14785
+ * This function is called by keyBinding.
14786
+ */
14787
+ handleKeyboard: function(data, hashId, key, keyCode, e) {
14788
+ // If we pressed any command key but no other key, then ignore the input.
14789
+ // Otherwise "shift-" is added to the buffer, and later on "shift-g"
14790
+ // which results in "shift-shift-g" which doesn't make sense.
14791
+ if (hashId != 0 && (key == "" || key == String.fromCharCode(0))) {
14792
+ return null;
14793
+ }
14794
+
14795
+ // Compute the current value of the keyboard input buffer.
14796
+ var r = this.$composeBuffer(data, hashId, key, e);
14797
+ var buffer = r.bufferToUse;
14798
+ var symbolicName = r.symbolicName;
14799
+ var keyId = r.keyIdentifier;
14800
+
14801
+ r = this.$find(data, buffer, symbolicName, hashId, key, keyId);
14802
+ if (DEBUG) {
14803
+ console.log("KeyboardStateMapper#match", buffer, symbolicName, r);
14804
+ }
14805
+
14806
+ return r;
14807
+ }
14808
+ }
14809
+
14810
+ /**
14811
+ * This is a useful matching function and therefore is defined here so that
14812
+ * users of KeyboardStateMapper can use it.
14813
+ *
14814
+ * @return boolean
14815
+ * If no command key (Command|Option|Shift|Ctrl) is pressed, it
14816
+ * returns true. If the only the Shift key is pressed + a character
14817
+ * true is returned as well. Otherwise, false is returned.
14818
+ * Summing up, the function returns true whenever the user typed
14819
+ * a normal character on the keyboard and no shortcut.
14820
+ */
14821
+ exports.matchCharacterOnly = function(buffer, hashId, key, symbolicName) {
14822
+ // If no command keys are pressed, then catch the input.
14823
+ if (hashId == 0) {
14824
+ return true;
14825
+ }
14826
+ // If only the shift key is pressed and a character key, then
14827
+ // catch that input as well.
14828
+ else if ((hashId == 4) && key.length == 1) {
14829
+ return true;
14830
+ }
14831
+ // Otherwise, we let the input got through.
14832
+ else {
14833
+ return false;
14834
+ }
14835
+ };
14836
+
14837
+ exports.StateHandler = StateHandler;
14838
+ });
14839
+ /* ***** BEGIN LICENSE BLOCK *****
14840
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
14841
+ *
14842
+ * The contents of this file are subject to the Mozilla Public License Version
14843
+ * 1.1 (the "License"); you may not use this file except in compliance with
14844
+ * the License. You may obtain a copy of the License at
14845
+ * http://www.mozilla.org/MPL/
14846
+ *
14847
+ * Software distributed under the License is distributed on an "AS IS" basis,
14848
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14849
+ * for the specific language governing rights and limitations under the
14850
+ * License.
14851
+ *
14852
+ * The Original Code is Ajax.org Code Editor (ACE).
14853
+ *
14854
+ * The Initial Developer of the Original Code is
14855
+ * Ajax.org B.V.
14856
+ * Portions created by the Initial Developer are Copyright (C) 2010
14857
+ * the Initial Developer. All Rights Reserved.
14858
+ *
14859
+ * Contributor(s):
14860
+ * Zef Hemel <zef@c9.io>
14861
+ *
14862
+ * Alternatively, the contents of this file may be used under the terms of
14863
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
14864
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
14865
+ * in which case the provisions of the GPL or the LGPL are applicable instead
14866
+ * of those above. If you wish to allow use of your version of this file only
14867
+ * under the terms of either the GPL or the LGPL, and not to allow others to
14868
+ * use your version of this file under the terms of the MPL, indicate your
14869
+ * decision by deleting the provisions above and replace them with the notice
14870
+ * and other provisions required by the GPL or the LGPL. If you do not delete
14871
+ * the provisions above, a recipient may use your version of this file under
14872
+ * the terms of any one of the MPL, the GPL or the LGPL.
14873
+ *
14874
+ * ***** END LICENSE BLOCK ***** */
14875
+ ace.define('ace/placeholder', ['require', 'exports', 'module' , 'ace/range', 'ace/lib/event_emitter', 'ace/lib/oop'], function(require, exports, module) {
14876
+ "use strict";
14877
+
14878
+ var Range = require('./range').Range;
14879
+ var EventEmitter = require("./lib/event_emitter").EventEmitter;
14880
+ var oop = require("./lib/oop");
14881
+
14882
+ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) {
14883
+ var _self = this;
14884
+ this.length = length;
14885
+ this.session = session;
14886
+ this.doc = session.getDocument();
14887
+ this.mainClass = mainClass;
14888
+ this.othersClass = othersClass;
14889
+ this.$onUpdate = this.onUpdate.bind(this);
14890
+ this.doc.on("change", this.$onUpdate);
14891
+ this.$others = others;
14892
+
14893
+ this.$onCursorChange = function() {
14894
+ setTimeout(function() {
14895
+ _self.onCursorChange();
14896
+ });
14897
+ };
14898
+
14899
+ this.$pos = pos;
14900
+ // Used for reset
14901
+ var undoStack = session.getUndoManager().$undoStack || session.getUndoManager().$undostack || {length: -1};
14902
+ this.$undoStackDepth = undoStack.length;
14903
+ this.setup();
14904
+
14905
+ session.selection.on("changeCursor", this.$onCursorChange);
14906
+ };
14907
+
14908
+ (function() {
14909
+
14910
+ oop.implement(this, EventEmitter);
14911
+
14912
+ this.setup = function() {
14913
+ var _self = this;
14914
+ var doc = this.doc;
14915
+ var session = this.session;
14916
+ var pos = this.$pos;
14917
+
14918
+ this.pos = doc.createAnchor(pos.row, pos.column);
14919
+ this.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column + this.length), this.mainClass, null, false);
14920
+ this.pos.on("change", function(event) {
14921
+ session.removeMarker(_self.markerId);
14922
+ _self.markerId = session.addMarker(new Range(event.value.row, event.value.column, event.value.row, event.value.column+_self.length), _self.mainClass, null, false);
14923
+ });
14924
+ this.others = [];
14925
+ this.$others.forEach(function(other) {
14926
+ var anchor = doc.createAnchor(other.row, other.column);
14927
+ _self.others.push(anchor);
14928
+ });
14929
+ session.setUndoSelect(false);
14930
+ };
14931
+
14932
+ this.showOtherMarkers = function() {
14933
+ if(this.othersActive) return;
14934
+ var session = this.session;
14935
+ var _self = this;
14936
+ this.othersActive = true;
14937
+ this.others.forEach(function(anchor) {
14938
+ anchor.markerId = session.addMarker(new Range(anchor.row, anchor.column, anchor.row, anchor.column+_self.length), _self.othersClass, null, false);
14939
+ anchor.on("change", function(event) {
14940
+ session.removeMarker(anchor.markerId);
14941
+ anchor.markerId = session.addMarker(new Range(event.value.row, event.value.column, event.value.row, event.value.column+_self.length), _self.othersClass, null, false);
14942
+ });
14943
+ });
14944
+ };
14945
+
14946
+ this.hideOtherMarkers = function() {
14947
+ if(!this.othersActive) return;
14948
+ this.othersActive = false;
14949
+ for (var i = 0; i < this.others.length; i++) {
14950
+ this.session.removeMarker(this.others[i].markerId);
14951
+ }
14952
+ };
14953
+
14954
+ this.onUpdate = function(event) {
14955
+ var delta = event.data;
14956
+ var range = delta.range;
14957
+ if(range.start.row !== range.end.row) return;
14958
+ if(range.start.row !== this.pos.row) return;
14959
+ if (this.$updating) return;
14960
+ this.$updating = true;
14961
+ var lengthDiff = delta.action === "insertText" ? range.end.column - range.start.column : range.start.column - range.end.column;
14962
+
14963
+ if(range.start.column >= this.pos.column && range.start.column <= this.pos.column + this.length + 1) {
14964
+ var distanceFromStart = range.start.column - this.pos.column;
14965
+ this.length += lengthDiff;
14966
+ if(!this.session.$fromUndo) {
14967
+ if(delta.action === "insertText") {
14968
+ for (var i = this.others.length - 1; i >= 0; i--) {
14969
+ var otherPos = this.others[i];
14970
+ var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
14971
+ if(otherPos.row === range.start.row && range.start.column < otherPos.column)
14972
+ newPos.column += lengthDiff;
14973
+ this.doc.insert(newPos, delta.text);
14974
+ }
14975
+ } else if(delta.action === "removeText") {
14976
+ for (var i = this.others.length - 1; i >= 0; i--) {
14977
+ var otherPos = this.others[i];
14978
+ var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
14979
+ if(otherPos.row === range.start.row && range.start.column < otherPos.column)
14980
+ newPos.column += lengthDiff;
14981
+ this.doc.remove(new Range(newPos.row, newPos.column, newPos.row, newPos.column - lengthDiff));
14982
+ }
14983
+ }
14984
+ // Special case: insert in beginning
14985
+ if(range.start.column === this.pos.column && delta.action === "insertText") {
14986
+ setTimeout(function() {
14987
+ this.pos.setPosition(this.pos.row, this.pos.column - lengthDiff);
14988
+ for (var i = 0; i < this.others.length; i++) {
14989
+ var other = this.others[i];
14990
+ var newPos = {row: other.row, column: other.column - lengthDiff};
14991
+ if(other.row === range.start.row && range.start.column < other.column)
14992
+ newPos.column += lengthDiff;
14993
+ other.setPosition(newPos.row, newPos.column);
14994
+ }
14995
+ }.bind(this), 0);
14996
+ }
14997
+ else if(range.start.column === this.pos.column && delta.action === "removeText") {
14998
+ setTimeout(function() {
14999
+ for (var i = 0; i < this.others.length; i++) {
15000
+ var other = this.others[i];
15001
+ if(other.row === range.start.row && range.start.column < other.column) {
15002
+ other.setPosition(other.row, other.column - lengthDiff);
15003
+ }
15004
+ }
15005
+ }.bind(this), 0);
15006
+ }
15007
+ }
15008
+ this.pos._emit("change", {value: this.pos});
15009
+ for (var i = 0; i < this.others.length; i++) {
15010
+ this.others[i]._emit("change", {value: this.others[i]});
15011
+ }
15012
+ }
15013
+ this.$updating = false;
15014
+ };
15015
+
15016
+ this.onCursorChange = function(event) {
15017
+ if (this.$updating) return;
15018
+ var pos = this.session.selection.getCursor();
15019
+ if(pos.row === this.pos.row && pos.column >= this.pos.column && pos.column <= this.pos.column + this.length) {
15020
+ this.showOtherMarkers();
15021
+ this._emit("cursorEnter", event);
15022
+ } else {
15023
+ this.hideOtherMarkers();
15024
+ this._emit("cursorLeave", event);
15025
+ }
15026
+ };
15027
+
15028
+ this.detach = function() {
15029
+ this.session.removeMarker(this.markerId);
15030
+ this.hideOtherMarkers();
15031
+ this.doc.removeEventListener("change", this.$onUpdate);
15032
+ this.session.selection.removeEventListener("changeCursor", this.$onCursorChange);
15033
+ this.pos.detach();
15034
+ for (var i = 0; i < this.others.length; i++) {
15035
+ this.others[i].detach();
15036
+ }
15037
+ this.session.setUndoSelect(true);
15038
+ };
15039
+
15040
+ this.cancel = function() {
15041
+ if(this.$undoStackDepth === -1)
15042
+ throw Error("Canceling placeholders only supported with undo manager attached to session.");
15043
+ var undoManager = this.session.getUndoManager();
15044
+ var undosRequired = (undoManager.$undoStack || undoManager.$undostack).length - this.$undoStackDepth;
15045
+ for (var i = 0; i < undosRequired; i++) {
15046
+ undoManager.undo(true);
15047
+ }
15048
+ };
15049
+ }).call(PlaceHolder.prototype);
15050
+
15051
+
15052
+ exports.PlaceHolder = PlaceHolder;
15053
+ });
15054
+ /* ***** BEGIN LICENSE BLOCK *****
15055
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
15056
+ *
15057
+ * The contents of this file are subject to the Mozilla Public License Version
15058
+ * 1.1 (the "License"); you may not use this file except in compliance with
15059
+ * the License. You may obtain a copy of the License at
15060
+ * http://www.mozilla.org/MPL/
15061
+ *
15062
+ * Software distributed under the License is distributed on an "AS IS" basis,
15063
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
15064
+ * for the specific language governing rights and limitations under the
15065
+ * License.
15066
+ *
15067
+ * The Original Code is Ajax.org Code Editor (ACE).
15068
+ *
15069
+ * The Initial Developer of the Original Code is
15070
+ * Ajax.org B.V.
15071
+ * Portions created by the Initial Developer are Copyright (C) 2010
15072
+ * the Initial Developer. All Rights Reserved.
15073
+ *
15074
+ * Contributor(s):
15075
+ * Fabian Jakobs <fabian AT ajax DOT org>
15076
+ *
15077
+ * Alternatively, the contents of this file may be used under the terms of
15078
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
15079
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
15080
+ * in which case the provisions of the GPL or the LGPL are applicable instead
15081
+ * of those above. If you wish to allow use of your version of this file only
15082
+ * under the terms of either the GPL or the LGPL, and not to allow others to
15083
+ * use your version of this file under the terms of the MPL, indicate your
15084
+ * decision by deleting the provisions above and replace them with the notice
15085
+ * and other provisions required by the GPL or the LGPL. If you do not delete
15086
+ * the provisions above, a recipient may use your version of this file under
15087
+ * the terms of any one of the MPL, the GPL or the LGPL.
15088
+ *
15089
+ * ***** END LICENSE BLOCK ***** */
15090
+
15091
+ ace.define('ace/theme/textmate', ['require', 'exports', 'module' , 'ace/lib/dom'], function(require, exports, module) {
15092
+ "use strict";
15093
+
15094
+ exports.isDark = false;
15095
+ exports.cssClass = "ace-tm";
15096
+ exports.cssText = ".ace-tm .ace_editor {\
15097
+ border: 2px solid rgb(159, 159, 159);\
15098
+ }\
15099
+ \
15100
+ .ace-tm .ace_editor.ace_focus {\
15101
+ border: 2px solid #327fbd;\
15102
+ }\
15103
+ \
15104
+ .ace-tm .ace_gutter {\
15105
+ background: #e8e8e8;\
15106
+ color: #333;\
15107
+ }\
15108
+ \
15109
+ .ace-tm .ace_print_margin {\
15110
+ width: 1px;\
15111
+ background: #e8e8e8;\
15112
+ }\
15113
+ \
15114
+ .ace-tm .ace_fold {\
15115
+ background-color: #6B72E6;\
15116
+ }\
15117
+ \
15118
+ .ace-tm .ace_text-layer {\
15119
+ cursor: text;\
15120
+ }\
15121
+ \
15122
+ .ace-tm .ace_cursor {\
15123
+ border-left: 2px solid black;\
15124
+ }\
15125
+ \
15126
+ .ace-tm .ace_cursor.ace_overwrite {\
15127
+ border-left: 0px;\
15128
+ border-bottom: 1px solid black;\
15129
+ }\
15130
+ \
15131
+ .ace-tm .ace_line .ace_invisible {\
15132
+ color: rgb(191, 191, 191);\
15133
+ }\
15134
+ \
15135
+ .ace-tm .ace_line .ace_storage,\
15136
+ .ace-tm .ace_line .ace_keyword {\
15137
+ color: blue;\
15138
+ }\
15139
+ \
15140
+ .ace-tm .ace_line .ace_constant.ace_buildin {\
15141
+ color: rgb(88, 72, 246);\
15142
+ }\
15143
+ \
15144
+ .ace-tm .ace_line .ace_constant.ace_language {\
15145
+ color: rgb(88, 92, 246);\
15146
+ }\
15147
+ \
15148
+ .ace-tm .ace_line .ace_constant.ace_library {\
15149
+ color: rgb(6, 150, 14);\
15150
+ }\
15151
+ \
15152
+ .ace-tm .ace_line .ace_invalid {\
15153
+ background-color: rgb(153, 0, 0);\
15154
+ color: white;\
15155
+ }\
15156
+ \
15157
+ .ace-tm .ace_line .ace_support.ace_function {\
15158
+ color: rgb(60, 76, 114);\
15159
+ }\
15160
+ \
15161
+ .ace-tm .ace_line .ace_support.ace_constant {\
15162
+ color: rgb(6, 150, 14);\
15163
+ }\
15164
+ \
15165
+ .ace-tm .ace_line .ace_support.ace_type,\
15166
+ .ace-tm .ace_line .ace_support.ace_class {\
15167
+ color: rgb(109, 121, 222);\
15168
+ }\
15169
+ \
15170
+ .ace-tm .ace_line .ace_keyword.ace_operator {\
15171
+ color: rgb(104, 118, 135);\
15172
+ }\
15173
+ \
15174
+ .ace-tm .ace_line .ace_string {\
15175
+ color: rgb(3, 106, 7);\
15176
+ }\
15177
+ \
15178
+ .ace-tm .ace_line .ace_comment {\
15179
+ color: rgb(76, 136, 107);\
15180
+ }\
15181
+ \
15182
+ .ace-tm .ace_line .ace_comment.ace_doc {\
15183
+ color: rgb(0, 102, 255);\
15184
+ }\
15185
+ \
15186
+ .ace-tm .ace_line .ace_comment.ace_doc.ace_tag {\
15187
+ color: rgb(128, 159, 191);\
15188
+ }\
15189
+ \
15190
+ .ace-tm .ace_line .ace_constant.ace_numeric {\
15191
+ color: rgb(0, 0, 205);\
15192
+ }\
15193
+ \
15194
+ .ace-tm .ace_line .ace_variable {\
15195
+ color: rgb(49, 132, 149);\
15196
+ }\
15197
+ \
15198
+ .ace-tm .ace_line .ace_xml_pe {\
15199
+ color: rgb(104, 104, 91);\
15200
+ }\
15201
+ \
15202
+ .ace-tm .ace_entity.ace_name.ace_function {\
15203
+ color: #0000A2;\
15204
+ }\
15205
+ \
15206
+ .ace-tm .ace_markup.ace_markupine {\
15207
+ text-decoration:underline;\
15208
+ }\
15209
+ \
15210
+ .ace-tm .ace_markup.ace_heading {\
15211
+ color: rgb(12, 7, 255);\
15212
+ }\
15213
+ \
15214
+ .ace-tm .ace_markup.ace_list {\
15215
+ color:rgb(185, 6, 144);\
15216
+ }\
15217
+ \
15218
+ .ace-tm .ace_marker-layer .ace_selection {\
15219
+ background: rgb(181, 213, 255);\
15220
+ }\
15221
+ \
15222
+ .ace-tm .ace_marker-layer .ace_step {\
15223
+ background: rgb(252, 255, 0);\
15224
+ }\
15225
+ \
15226
+ .ace-tm .ace_marker-layer .ace_stack {\
15227
+ background: rgb(164, 229, 101);\
15228
+ }\
15229
+ \
15230
+ .ace-tm .ace_marker-layer .ace_bracket {\
15231
+ margin: -1px 0 0 -1px;\
15232
+ border: 1px solid rgb(192, 192, 192);\
15233
+ }\
15234
+ \
15235
+ .ace-tm .ace_marker-layer .ace_active_line {\
15236
+ background: rgba(0, 0, 0, 0.07);\
15237
+ }\
15238
+ \
15239
+ .ace-tm .ace_marker-layer .ace_selected_word {\
15240
+ background: rgb(250, 250, 255);\
15241
+ border: 1px solid rgb(200, 200, 250);\
15242
+ }\
15243
+ \
15244
+ .ace-tm .ace_meta.ace_tag {\
15245
+ color:rgb(28, 2, 255);\
15246
+ }\
15247
+ \
15248
+ .ace-tm .ace_string.ace_regex {\
15249
+ color: rgb(255, 0, 0)\
15250
+ }";
15251
+
15252
+ var dom = require("../lib/dom");
15253
+ dom.importCssString(exports.cssText, exports.cssClass);
15254
+ });
15255
+ ;
15256
+ (function() {
15257
+ ace.require(["ace/ace"], function(a) {
15258
+ if (!window.ace)
15259
+ window.ace = {};
15260
+ for (var key in a) if (a.hasOwnProperty(key))
15261
+ ace[key] = a[key];
15262
+ });
15263
+ })();
15264
+
ace-0.2.0/src/ace-uncompressed.js CHANGED
@@ -1,17319 +1,15264 @@
1
- /* ***** BEGIN LICENSE BLOCK *****
2
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3
- *
4
- * The contents of this file are subject to the Mozilla Public License Version
5
- * 1.1 (the "License"); you may not use this file except in compliance with
6
- * the License. You may obtain a copy of the License at
7
- * http://www.mozilla.org/MPL/
8
- *
9
- * Software distributed under the License is distributed on an "AS IS" basis,
10
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
- * for the specific language governing rights and limitations under the
12
- * License.
13
- *
14
- * The Original Code is Ajax.org Code Editor (ACE).
15
- *
16
- * The Initial Developer of the Original Code is
17
- * Ajax.org B.V.
18
- * Portions created by the Initial Developer are Copyright (C) 2010
19
- * the Initial Developer. All Rights Reserved.
20
- *
21
- * Contributor(s):
22
- * Fabian Jakobs <fabian AT ajax DOT org>
23
- *
24
- * Alternatively, the contents of this file may be used under the terms of
25
- * either the GNU General Public License Version 2 or later (the "GPL"), or
26
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
- * in which case the provisions of the GPL or the LGPL are applicable instead
28
- * of those above. If you wish to allow use of your version of this file only
29
- * under the terms of either the GPL or the LGPL, and not to allow others to
30
- * use your version of this file under the terms of the MPL, indicate your
31
- * decision by deleting the provisions above and replace them with the notice
32
- * and other provisions required by the GPL or the LGPL. If you do not delete
33
- * the provisions above, a recipient may use your version of this file under
34
- * the terms of any one of the MPL, the GPL or the LGPL.
35
- *
36
- * ***** END LICENSE BLOCK ***** */
37
-
38
- /**
39
- * Define a module along with a payload
40
- * @param module a name for the payload
41
- * @param payload a function to call with (require, exports, module) params
42
- */
43
-
44
- (function() {
45
-
46
- var global = (function() {
47
- return this;
48
- })();
49
-
50
- // if we find an existing require function use it.
51
- if (global.require && global.define) {
52
- require.packaged = true;
53
- return;
54
- }
55
-
56
- var _define = function(module, deps, payload) {
57
- if (typeof module !== 'string') {
58
- if (_define.original)
59
- _define.original.apply(window, arguments);
60
- else {
61
- console.error('dropping module because define wasn\'t a string.');
62
- console.trace();
63
- }
64
- return;
65
- }
66
-
67
- if (arguments.length == 2)
68
- payload = deps;
69
-
70
- if (!define.modules)
71
- define.modules = {};
72
-
73
- define.modules[module] = payload;
74
- };
75
- if (global.define)
76
- _define.original = global.define;
77
-
78
- global.define = _define;
79
-
80
-
81
- /**
82
- * Get at functionality define()ed using the function above
83
- */
84
- var _require = function(module, callback) {
85
- if (Object.prototype.toString.call(module) === "[object Array]") {
86
- var params = [];
87
- for (var i = 0, l = module.length; i < l; ++i) {
88
- var dep = lookup(module[i]);
89
- if (!dep && _require.original)
90
- return _require.original.apply(window, arguments);
91
- params.push(dep);
92
- }
93
- if (callback) {
94
- callback.apply(null, params);
95
- }
96
- }
97
- else if (typeof module === 'string') {
98
- var payload = lookup(module);
99
- if (!payload && _require.original)
100
- return _require.original.apply(window, arguments);
101
-
102
- if (callback) {
103
- callback();
104
- }
105
-
106
- return payload;
107
- }
108
- else {
109
- if (_require.original)
110
- return _require.original.apply(window, arguments);
111
- }
112
- };
113
-
114
- if (global.require)
115
- _require.original = global.require;
116
-
117
- global.require = _require;
118
- require.packaged = true;
119
-
120
- /**
121
- * Internal function to lookup moduleNames and resolve them by calling the
122
- * definition function if needed.
123
- */
124
- var lookup = function(moduleName) {
125
- var module = define.modules[moduleName];
126
- if (module == null) {
127
- console.error('Missing module: ' + moduleName);
128
- return null;
129
- }
130
-
131
- if (typeof module === 'function') {
132
- var exports = {};
133
- module(require, exports, { id: moduleName, uri: '' });
134
- // cache the resulting module object for next time
135
- define.modules[moduleName] = exports;
136
- return exports;
137
- }
138
-
139
- return module;
140
- };
141
-
142
- })();// vim:set ts=4 sts=4 sw=4 st:
143
- // -- kriskowal Kris Kowal Copyright (C) 2009-2010 MIT License
144
- // -- tlrobinson Tom Robinson Copyright (C) 2009-2010 MIT License (Narwhal Project)
145
- // -- dantman Daniel Friesen Copyright(C) 2010 XXX No License Specified
146
- // -- fschaefer Florian Schäfer Copyright (C) 2010 MIT License
147
- // -- Irakli Gozalishvili Copyright (C) 2010 MIT License
148
-
149
- /*!
150
- Copyright (c) 2009, 280 North Inc. http://280north.com/
151
- MIT License. http://github.com/280north/narwhal/blob/master/README.md
152
- */
153
-
154
- define('pilot/fixoldbrowsers', ['require', 'exports', 'module' ], function(require, exports, module) {
155
-
156
- /**
157
- * Brings an environment as close to ECMAScript 5 compliance
158
- * as is possible with the facilities of erstwhile engines.
159
- *
160
- * ES5 Draft
161
- * http://www.ecma-international.org/publications/files/drafts/tc39-2009-050.pdf
162
- *
163
- * NOTE: this is a draft, and as such, the URL is subject to change. If the
164
- * link is broken, check in the parent directory for the latest TC39 PDF.
165
- * http://www.ecma-international.org/publications/files/drafts/
166
- *
167
- * Previous ES5 Draft
168
- * http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf
169
- * This is a broken link to the previous draft of ES5 on which most of the
170
- * numbered specification references and quotes herein were taken. Updating
171
- * these references and quotes to reflect the new document would be a welcome
172
- * volunteer project.
173
- *
174
- * @module
175
- */
176
-
177
- /*whatsupdoc*/
178
-
179
- //
180
- // Function
181
- // ========
182
- //
183
-
184
- // ES-5 15.3.4.5
185
- // http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf
186
-
187
- if (!Function.prototype.bind) {
188
- var slice = Array.prototype.slice;
189
- Function.prototype.bind = function bind(that) { // .length is 1
190
- // 1. Let Target be the this value.
191
- var target = this;
192
- // 2. If IsCallable(Target) is false, throw a TypeError exception.
193
- // XXX this gets pretty close, for all intents and purposes, letting
194
- // some duck-types slide
195
- if (typeof target.apply !== "function" || typeof target.call !== "function")
196
- return new TypeError();
197
- // 3. Let A be a new (possibly empty) internal list of all of the
198
- // argument values provided after thisArg (arg1, arg2 etc), in order.
199
- var args = slice.call(arguments);
200
- // 4. Let F be a new native ECMAScript object.
201
- // 9. Set the [[Prototype]] internal property of F to the standard
202
- // built-in Function prototype object as specified in 15.3.3.1.
203
- // 10. Set the [[Call]] internal property of F as described in
204
- // 15.3.4.5.1.
205
- // 11. Set the [[Construct]] internal property of F as described in
206
- // 15.3.4.5.2.
207
- // 12. Set the [[HasInstance]] internal property of F as described in
208
- // 15.3.4.5.3.
209
- // 13. The [[Scope]] internal property of F is unused and need not
210
- // exist.
211
- var bound = function bound() {
212
-
213
- if (this instanceof bound) {
214
- // 15.3.4.5.2 [[Construct]]
215
- // When the [[Construct]] internal method of a function object,
216
- // F that was created using the bind function is called with a
217
- // list of arguments ExtraArgs the following steps are taken:
218
- // 1. Let target be the value of F's [[TargetFunction]]
219
- // internal property.
220
- // 2. If target has no [[Construct]] internal method, a
221
- // TypeError exception is thrown.
222
- // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
223
- // property.
224
- // 4. Let args be a new list containing the same values as the
225
- // list boundArgs in the same order followed by the same
226
- // values as the list ExtraArgs in the same order.
227
-
228
- var self = Object.create(target.prototype);
229
- target.apply(self, args.concat(slice.call(arguments)));
230
- return self;
231
-
232
- } else {
233
- // 15.3.4.5.1 [[Call]]
234
- // When the [[Call]] internal method of a function object, F,
235
- // which was created using the bind function is called with a
236
- // this value and a list of arguments ExtraArgs the following
237
- // steps are taken:
238
- // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
239
- // property.
240
- // 2. Let boundThis be the value of F's [[BoundThis]] internal
241
- // property.
242
- // 3. Let target be the value of F's [[TargetFunction]] internal
243
- // property.
244
- // 4. Let args be a new list containing the same values as the list
245
- // boundArgs in the same order followed by the same values as
246
- // the list ExtraArgs in the same order. 5. Return the
247
- // result of calling the [[Call]] internal method of target
248
- // providing boundThis as the this value and providing args
249
- // as the arguments.
250
-
251
- // equiv: target.call(this, ...boundArgs, ...args)
252
- return target.call.apply(
253
- target,
254
- args.concat(slice.call(arguments))
255
- );
256
-
257
- }
258
-
259
- };
260
- bound.length = (
261
- // 14. If the [[Class]] internal property of Target is "Function", then
262
- typeof target === "function" ?
263
- // a. Let L be the length property of Target minus the length of A.
264
- // b. Set the length own property of F to either 0 or L, whichever is larger.
265
- Math.max(target.length - args.length, 0) :
266
- // 15. Else set the length own property of F to 0.
267
- 0
268
- )
269
- // 16. The length own property of F is given attributes as specified in
270
- // 15.3.5.1.
271
- // TODO
272
- // 17. Set the [[Extensible]] internal property of F to true.
273
- // TODO
274
- // 18. Call the [[DefineOwnProperty]] internal method of F with
275
- // arguments "caller", PropertyDescriptor {[[Value]]: null,
276
- // [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]:
277
- // false}, and false.
278
- // TODO
279
- // 19. Call the [[DefineOwnProperty]] internal method of F with
280
- // arguments "arguments", PropertyDescriptor {[[Value]]: null,
281
- // [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]:
282
- // false}, and false.
283
- // TODO
284
- // NOTE Function objects created using Function.prototype.bind do not
285
- // have a prototype property.
286
- // XXX can't delete it in pure-js.
287
- return bound;
288
- };
289
- }
290
-
291
- // Shortcut to an often accessed properties, in order to avoid multiple
292
- // dereference that costs universally.
293
- // _Please note: Shortcuts are defined after `Function.prototype.bind` as we
294
- // us it in defining shortcuts.
295
- var call = Function.prototype.call;
296
- var prototypeOfArray = Array.prototype;
297
- var prototypeOfObject = Object.prototype;
298
- var owns = call.bind(prototypeOfObject.hasOwnProperty);
299
-
300
- var defineGetter, defineSetter, lookupGetter, lookupSetter, supportsAccessors;
301
- // If JS engine supports accessors creating shortcuts.
302
- if ((supportsAccessors = owns(prototypeOfObject, '__defineGetter__'))) {
303
- defineGetter = call.bind(prototypeOfObject.__defineGetter__);
304
- defineSetter = call.bind(prototypeOfObject.__defineSetter__);
305
- lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
306
- lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
307
- }
308
-
309
-
310
- //
311
- // Array
312
- // =====
313
- //
314
-
315
- // ES5 15.4.3.2
316
- if (!Array.isArray) {
317
- Array.isArray = function isArray(obj) {
318
- return Object.prototype.toString.call(obj) === "[object Array]";
319
- };
320
- }
321
-
322
- // ES5 15.4.4.18
323
- if (!Array.prototype.forEach) {
324
- Array.prototype.forEach = function forEach(block, thisObject) {
325
- var len = +this.length;
326
- for (var i = 0; i < len; i++) {
327
- if (i in this) {
328
- block.call(thisObject, this[i], i, this);
329
- }
330
- }
331
- };
332
- }
333
-
334
- // ES5 15.4.4.19
335
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
336
- if (!Array.prototype.map) {
337
- Array.prototype.map = function map(fun /*, thisp*/) {
338
- var len = +this.length;
339
- if (typeof fun !== "function")
340
- throw new TypeError();
341
-
342
- var res = new Array(len);
343
- var thisp = arguments[1];
344
- for (var i = 0; i < len; i++) {
345
- if (i in this)
346
- res[i] = fun.call(thisp, this[i], i, this);
347
- }
348
-
349
- return res;
350
- };
351
- }
352
-
353
- // ES5 15.4.4.20
354
- if (!Array.prototype.filter) {
355
- Array.prototype.filter = function filter(block /*, thisp */) {
356
- var values = [];
357
- var thisp = arguments[1];
358
- for (var i = 0; i < this.length; i++)
359
- if (block.call(thisp, this[i]))
360
- values.push(this[i]);
361
- return values;
362
- };
363
- }
364
-
365
- // ES5 15.4.4.16
366
- if (!Array.prototype.every) {
367
- Array.prototype.every = function every(block /*, thisp */) {
368
- var thisp = arguments[1];
369
- for (var i = 0; i < this.length; i++)
370
- if (!block.call(thisp, this[i]))
371
- return false;
372
- return true;
373
- };
374
- }
375
-
376
- // ES5 15.4.4.17
377
- if (!Array.prototype.some) {
378
- Array.prototype.some = function some(block /*, thisp */) {
379
- var thisp = arguments[1];
380
- for (var i = 0; i < this.length; i++)
381
- if (block.call(thisp, this[i]))
382
- return true;
383
- return false;
384
- };
385
- }
386
-
387
- // ES5 15.4.4.21
388
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
389
- if (!Array.prototype.reduce) {
390
- Array.prototype.reduce = function reduce(fun /*, initial*/) {
391
- var len = +this.length;
392
- if (typeof fun !== "function")
393
- throw new TypeError();
394
-
395
- // no value to return if no initial value and an empty array
396
- if (len === 0 && arguments.length === 1)
397
- throw new TypeError();
398
-
399
- var i = 0;
400
- if (arguments.length >= 2) {
401
- var rv = arguments[1];
402
- } else {
403
- do {
404
- if (i in this) {
405
- rv = this[i++];
406
- break;
407
- }
408
-
409
- // if array contains no values, no initial value to return
410
- if (++i >= len)
411
- throw new TypeError();
412
- } while (true);
413
- }
414
-
415
- for (; i < len; i++) {
416
- if (i in this)
417
- rv = fun.call(null, rv, this[i], i, this);
418
- }
419
-
420
- return rv;
421
- };
422
- }
423
-
424
- // ES5 15.4.4.22
425
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
426
- if (!Array.prototype.reduceRight) {
427
- Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
428
- var len = +this.length;
429
- if (typeof fun !== "function")
430
- throw new TypeError();
431
-
432
- // no value to return if no initial value, empty array
433
- if (len === 0 && arguments.length === 1)
434
- throw new TypeError();
435
-
436
- var i = len - 1;
437
- if (arguments.length >= 2) {
438
- var rv = arguments[1];
439
- } else {
440
- do {
441
- if (i in this) {
442
- rv = this[i--];
443
- break;
444
- }
445
-
446
- // if array contains no values, no initial value to return
447
- if (--i < 0)
448
- throw new TypeError();
449
- } while (true);
450
- }
451
-
452
- for (; i >= 0; i--) {
453
- if (i in this)
454
- rv = fun.call(null, rv, this[i], i, this);
455
- }
456
-
457
- return rv;
458
- };
459
- }
460
-
461
- // ES5 15.4.4.14
462
- if (!Array.prototype.indexOf) {
463
- Array.prototype.indexOf = function indexOf(value /*, fromIndex */ ) {
464
- var length = this.length;
465
- if (!length)
466
- return -1;
467
- var i = arguments[1] || 0;
468
- if (i >= length)
469
- return -1;
470
- if (i < 0)
471
- i += length;
472
- for (; i < length; i++) {
473
- if (!owns(this, i))
474
- continue;
475
- if (value === this[i])
476
- return i;
477
- }
478
- return -1;
479
- };
480
- }
481
-
482
- // ES5 15.4.4.15
483
- if (!Array.prototype.lastIndexOf) {
484
- Array.prototype.lastIndexOf = function lastIndexOf(value /*, fromIndex */) {
485
- var length = this.length;
486
- if (!length)
487
- return -1;
488
- var i = arguments[1] || length;
489
- if (i < 0)
490
- i += length;
491
- i = Math.min(i, length - 1);
492
- for (; i >= 0; i--) {
493
- if (!owns(this, i))
494
- continue;
495
- if (value === this[i])
496
- return i;
497
- }
498
- return -1;
499
- };
500
- }
501
-
502
- //
503
- // Object
504
- // ======
505
- //
506
-
507
- // ES5 15.2.3.2
508
- if (!Object.getPrototypeOf) {
509
- // https://github.com/kriskowal/es5-shim/issues#issue/2
510
- // http://ejohn.org/blog/objectgetprototypeof/
511
- // recommended by fschaefer on github
512
- Object.getPrototypeOf = function getPrototypeOf(object) {
513
- return object.__proto__ || object.constructor.prototype;
514
- // or undefined if not available in this engine
515
- };
516
- }
517
-
518
- // ES5 15.2.3.3
519
- if (!Object.getOwnPropertyDescriptor) {
520
- var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
521
- "non-object: ";
522
- Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
523
- if ((typeof object !== "object" && typeof object !== "function") || object === null)
524
- throw new TypeError(ERR_NON_OBJECT + object);
525
- // If object does not owns property return undefined immediately.
526
- if (!owns(object, property))
527
- return undefined;
528
-
529
- var despriptor, getter, setter;
530
-
531
- // If object has a property then it's for sure both `enumerable` and
532
- // `configurable`.
533
- despriptor = { enumerable: true, configurable: true };
534
-
535
- // If JS engine supports accessor properties then property may be a
536
- // getter or setter.
537
- if (supportsAccessors) {
538
- // Unfortunately `__lookupGetter__` will return a getter even
539
- // if object has own non getter property along with a same named
540
- // inherited getter. To avoid misbehavior we temporary remove
541
- // `__proto__` so that `__lookupGetter__` will return getter only
542
- // if it's owned by an object.
543
- var prototype = object.__proto__;
544
- object.__proto__ = prototypeOfObject;
545
-
546
- var getter = lookupGetter(object, property);
547
- var setter = lookupSetter(object, property);
548
-
549
- // Once we have getter and setter we can put values back.
550
- object.__proto__ = prototype;
551
-
552
- if (getter || setter) {
553
- if (getter) descriptor.get = getter;
554
- if (setter) descriptor.set = setter;
555
-
556
- // If it was accessor property we're done and return here
557
- // in order to avoid adding `value` to the descriptor.
558
- return descriptor;
559
- }
560
- }
561
-
562
- // If we got this far we know that object has an own property that is
563
- // not an accessor so we set it as a value and return descriptor.
564
- descriptor.value = object[property];
565
- return descriptor;
566
- };
567
- }
568
-
569
- // ES5 15.2.3.4
570
- if (!Object.getOwnPropertyNames) {
571
- Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
572
- return Object.keys(object);
573
- };
574
- }
575
-
576
- // ES5 15.2.3.5
577
- if (!Object.create) {
578
- Object.create = function create(prototype, properties) {
579
- var object;
580
- if (prototype === null) {
581
- object = { "__proto__": null };
582
- } else {
583
- if (typeof prototype !== "object")
584
- throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
585
- var Type = function () {};
586
- Type.prototype = prototype;
587
- object = new Type();
588
- // IE has no built-in implementation of `Object.getPrototypeOf`
589
- // neither `__proto__`, but this manually setting `__proto__` will
590
- // guarantee that `Object.getPrototypeOf` will work as expected with
591
- // objects created using `Object.create`
592
- object.__proto__ = prototype;
593
- }
594
- if (typeof properties !== "undefined")
595
- Object.defineProperties(object, properties);
596
- return object;
597
- };
598
- }
599
-
600
- // ES5 15.2.3.6
601
- if (!Object.defineProperty) {
602
- var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
603
- var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
604
- var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
605
- "on this javascript engine";
606
-
607
- Object.defineProperty = function defineProperty(object, property, descriptor) {
608
- if (typeof object !== "object" && typeof object !== "function")
609
- throw new TypeError(ERR_NON_OBJECT_TARGET + object);
610
- if (typeof object !== "object" || object === null)
611
- throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
612
-
613
- // If it's a data property.
614
- if (owns(descriptor, "value")) {
615
- // fail silently if "writable", "enumerable", or "configurable"
616
- // are requested but not supported
617
- /*
618
- // alternate approach:
619
- if ( // can't implement these features; allow false but not true
620
- !(owns(descriptor, "writable") ? descriptor.writable : true) ||
621
- !(owns(descriptor, "enumerable") ? descriptor.enumerable : true) ||
622
- !(owns(descriptor, "configurable") ? descriptor.configurable : true)
623
- )
624
- throw new RangeError(
625
- "This implementation of Object.defineProperty does not " +
626
- "support configurable, enumerable, or writable."
627
- );
628
- */
629
-
630
- if (supportsAccessors && (lookupGetter(object, property) ||
631
- lookupSetter(object, property)))
632
- {
633
- // As accessors are supported only on engines implementing
634
- // `__proto__` we can safely override `__proto__` while defining
635
- // a property to make sure that we don't hit an inherited
636
- // accessor.
637
- var prototype = object.__proto__;
638
- object.__proto__ = prototypeOfObject;
639
- // Deleting a property anyway since getter / setter may be
640
- // defined on object itself.
641
- delete object[property];
642
- object[property] = descriptor.value;
643
- // Setting original `__proto__` back now.
644
- object.prototype;
645
- } else {
646
- object[property] = descriptor.value;
647
- }
648
- } else {
649
- if (!supportsAccessors)
650
- throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
651
- // If we got that far then getters and setters can be defined !!
652
- if (owns(descriptor, "get"))
653
- defineGetter(object, property, descriptor.get);
654
- if (owns(descriptor, "set"))
655
- defineSetter(object, property, descriptor.set);
656
- }
657
-
658
- return object;
659
- };
660
- }
661
-
662
- // ES5 15.2.3.7
663
- if (!Object.defineProperties) {
664
- Object.defineProperties = function defineProperties(object, properties) {
665
- for (var property in properties) {
666
- if (owns(properties, property))
667
- Object.defineProperty(object, property, properties[property]);
668
- }
669
- return object;
670
- };
671
- }
672
-
673
- // ES5 15.2.3.8
674
- if (!Object.seal) {
675
- Object.seal = function seal(object) {
676
- // this is misleading and breaks feature-detection, but
677
- // allows "securable" code to "gracefully" degrade to working
678
- // but insecure code.
679
- return object;
680
- };
681
- }
682
-
683
- // ES5 15.2.3.9
684
- if (!Object.freeze) {
685
- Object.freeze = function freeze(object) {
686
- // this is misleading and breaks feature-detection, but
687
- // allows "securable" code to "gracefully" degrade to working
688
- // but insecure code.
689
- return object;
690
- };
691
- }
692
-
693
- // detect a Rhino bug and patch it
694
- try {
695
- Object.freeze(function () {});
696
- } catch (exception) {
697
- Object.freeze = (function freeze(freezeObject) {
698
- return function freeze(object) {
699
- if (typeof object === "function") {
700
- return object;
701
- } else {
702
- return freezeObject(object);
703
- }
704
- };
705
- })(Object.freeze);
706
- }
707
-
708
- // ES5 15.2.3.10
709
- if (!Object.preventExtensions) {
710
- Object.preventExtensions = function preventExtensions(object) {
711
- // this is misleading and breaks feature-detection, but
712
- // allows "securable" code to "gracefully" degrade to working
713
- // but insecure code.
714
- return object;
715
- };
716
- }
717
-
718
- // ES5 15.2.3.11
719
- if (!Object.isSealed) {
720
- Object.isSealed = function isSealed(object) {
721
- return false;
722
- };
723
- }
724
-
725
- // ES5 15.2.3.12
726
- if (!Object.isFrozen) {
727
- Object.isFrozen = function isFrozen(object) {
728
- return false;
729
- };
730
- }
731
-
732
- // ES5 15.2.3.13
733
- if (!Object.isExtensible) {
734
- Object.isExtensible = function isExtensible(object) {
735
- return true;
736
- };
737
- }
738
-
739
- // ES5 15.2.3.14
740
- // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
741
- if (!Object.keys) {
742
-
743
- var hasDontEnumBug = true,
744
- dontEnums = [
745
- 'toString',
746
- 'toLocaleString',
747
- 'valueOf',
748
- 'hasOwnProperty',
749
- 'isPrototypeOf',
750
- 'propertyIsEnumerable',
751
- 'constructor'
752
- ],
753
- dontEnumsLength = dontEnums.length;
754
-
755
- for (var key in {"toString": null})
756
- hasDontEnumBug = false;
757
-
758
- Object.keys = function keys(object) {
759
-
760
- if (
761
- typeof object !== "object" && typeof object !== "function"
762
- || object === null
763
- )
764
- throw new TypeError("Object.keys called on a non-object");
765
-
766
- var keys = [];
767
- for (var name in object) {
768
- if (owns(object, name)) {
769
- keys.push(name);
770
- }
771
- }
772
-
773
- if (hasDontEnumBug) {
774
- for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
775
- var dontEnum = dontEnums[i];
776
- if (owns(object, dontEnum)) {
777
- keys.push(dontEnum);
778
- }
779
- }
780
- }
781
-
782
- return keys;
783
- };
784
-
785
- }
786
-
787
- //
788
- // Date
789
- // ====
790
- //
791
-
792
- // ES5 15.9.5.43
793
- // Format a Date object as a string according to a subset of the ISO-8601 standard.
794
- // Useful in Atom, among other things.
795
- if (!Date.prototype.toISOString) {
796
- Date.prototype.toISOString = function toISOString() {
797
- return (
798
- this.getUTCFullYear() + "-" +
799
- (this.getUTCMonth() + 1) + "-" +
800
- this.getUTCDate() + "T" +
801
- this.getUTCHours() + ":" +
802
- this.getUTCMinutes() + ":" +
803
- this.getUTCSeconds() + "Z"
804
- );
805
- }
806
- }
807
-
808
- // ES5 15.9.4.4
809
- if (!Date.now) {
810
- Date.now = function now() {
811
- return new Date().getTime();
812
- };
813
- }
814
-
815
- // ES5 15.9.5.44
816
- if (!Date.prototype.toJSON) {
817
- Date.prototype.toJSON = function toJSON(key) {
818
- // This function provides a String representation of a Date object for
819
- // use by JSON.stringify (15.12.3). When the toJSON method is called
820
- // with argument key, the following steps are taken:
821
-
822
- // 1. Let O be the result of calling ToObject, giving it the this
823
- // value as its argument.
824
- // 2. Let tv be ToPrimitive(O, hint Number).
825
- // 3. If tv is a Number and is not finite, return null.
826
- // XXX
827
- // 4. Let toISO be the result of calling the [[Get]] internal method of
828
- // O with argument "toISOString".
829
- // 5. If IsCallable(toISO) is false, throw a TypeError exception.
830
- if (typeof this.toISOString !== "function")
831
- throw new TypeError();
832
- // 6. Return the result of calling the [[Call]] internal method of
833
- // toISO with O as the this value and an empty argument list.
834
- return this.toISOString();
835
-
836
- // NOTE 1 The argument is ignored.
837
-
838
- // NOTE 2 The toJSON function is intentionally generic; it does not
839
- // require that its this value be a Date object. Therefore, it can be
840
- // transferred to other kinds of objects for use as a method. However,
841
- // it does require that any such object have a toISOString method. An
842
- // object is free to use the argument key to filter its
843
- // stringification.
844
- };
845
- }
846
-
847
- // 15.9.4.2 Date.parse (string)
848
- // 15.9.1.15 Date Time String Format
849
- // Date.parse
850
- // based on work shared by Daniel Friesen (dantman)
851
- // http://gist.github.com/303249
852
- if (isNaN(Date.parse("T00:00"))) {
853
- // XXX global assignment won't work in embeddings that use
854
- // an alternate object for the context.
855
- Date = (function(NativeDate) {
856
-
857
- // Date.length === 7
858
- var Date = function(Y, M, D, h, m, s, ms) {
859
- var length = arguments.length;
860
- if (this instanceof NativeDate) {
861
- var date = length === 1 && String(Y) === Y ? // isString(Y)
862
- // We explicitly pass it through parse:
863
- new NativeDate(Date.parse(Y)) :
864
- // We have to manually make calls depending on argument
865
- // length here
866
- length >= 7 ? new NativeDate(Y, M, D, h, m, s, ms) :
867
- length >= 6 ? new NativeDate(Y, M, D, h, m, s) :
868
- length >= 5 ? new NativeDate(Y, M, D, h, m) :
869
- length >= 4 ? new NativeDate(Y, M, D, h) :
870
- length >= 3 ? new NativeDate(Y, M, D) :
871
- length >= 2 ? new NativeDate(Y, M) :
872
- length >= 1 ? new NativeDate(Y) :
873
- new NativeDate();
874
- // Prevent mixups with unfixed Date object
875
- date.constructor = Date;
876
- return date;
877
- }
878
- return NativeDate.apply(this, arguments);
879
- };
880
-
881
- // 15.9.1.15 Date Time String Format
882
- var isoDateExpression = new RegExp("^" +
883
- "(?:" + // optional year-month-day
884
- "(" + // year capture
885
- "(?:[+-]\\d\\d)?" + // 15.9.1.15.1 Extended years
886
- "\\d\\d\\d\\d" + // four-digit year
887
- ")" +
888
- "(?:-" + // optional month-day
889
- "(\\d\\d)" + // month capture
890
- "(?:-" + // optional day
891
- "(\\d\\d)" + // day capture
892
- ")?" +
893
- ")?" +
894
- ")?" +
895
- "(?:T" + // hour:minute:second.subsecond
896
- "(\\d\\d)" + // hour capture
897
- ":(\\d\\d)" + // minute capture
898
- "(?::" + // optional :second.subsecond
899
- "(\\d\\d)" + // second capture
900
- "(?:\\.(\\d\\d\\d))?" + // milisecond capture
901
- ")?" +
902
- ")?" +
903
- "(?:" + // time zone
904
- "Z|" + // UTC capture
905
- "([+-])(\\d\\d):(\\d\\d)" + // timezone offset
906
- // capture sign, hour, minute
907
- ")?" +
908
- "$");
909
-
910
- // Copy any custom methods a 3rd party library may have added
911
- for (var key in NativeDate)
912
- Date[key] = NativeDate[key];
913
-
914
- // Copy "native" methods explicitly; they may be non-enumerable
915
- Date.now = NativeDate.now;
916
- Date.UTC = NativeDate.UTC;
917
- Date.prototype = NativeDate.prototype;
918
- Date.prototype.constructor = Date;
919
-
920
- // Upgrade Date.parse to handle the ISO dates we use
921
- // TODO review specification to ascertain whether it is
922
- // necessary to implement partial ISO date strings.
923
- Date.parse = function parse(string) {
924
- var match = isoDateExpression.exec(string);
925
- if (match) {
926
- match.shift(); // kill match[0], the full match
927
- // recognize times without dates before normalizing the
928
- // numeric values, for later use
929
- var timeOnly = match[0] === undefined;
930
- // parse numerics
931
- for (var i = 0; i < 10; i++) {
932
- // skip + or - for the timezone offset
933
- if (i === 7)
934
- continue;
935
- // Note: parseInt would read 0-prefix numbers as
936
- // octal. Number constructor or unary + work better
937
- // here:
938
- match[i] = +(match[i] || (i < 3 ? 1 : 0));
939
- // match[1] is the month. Months are 0-11 in JavaScript
940
- // Date objects, but 1-12 in ISO notation, so we
941
- // decrement.
942
- if (i === 1)
943
- match[i]--;
944
- }
945
- // if no year-month-date is provided, return a milisecond
946
- // quantity instead of a UTC date number value.
947
- if (timeOnly)
948
- return ((match[3] * 60 + match[4]) * 60 + match[5]) * 1000 + match[6];
949
-
950
- // account for an explicit time zone offset if provided
951
- var offset = (match[8] * 60 + match[9]) * 60 * 1000;
952
- if (match[6] === "-")
953
- offset = -offset;
954
-
955
- return NativeDate.UTC.apply(this, match.slice(0, 7)) + offset;
956
- }
957
- return NativeDate.parse.apply(this, arguments);
958
- };
959
-
960
- return Date;
961
- })(Date);
962
- }
963
-
964
- //
965
- // String
966
- // ======
967
- //
968
-
969
- // ES5 15.5.4.20
970
- if (!String.prototype.trim) {
971
- // http://blog.stevenlevithan.com/archives/faster-trim-javascript
972
- var trimBeginRegexp = /^\s\s*/;
973
- var trimEndRegexp = /\s\s*$/;
974
- String.prototype.trim = function trim() {
975
- return String(this).replace(trimBeginRegexp, '').replace(trimEndRegexp, '');
976
- };
977
- }
978
-
979
- });/* ***** BEGIN LICENSE BLOCK *****
980
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
981
- *
982
- * The contents of this file are subject to the Mozilla Public License Version
983
- * 1.1 (the "License"); you may not use this file except in compliance with
984
- * the License. You may obtain a copy of the License at
985
- * http://www.mozilla.org/MPL/
986
- *
987
- * Software distributed under the License is distributed on an "AS IS" basis,
988
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
989
- * for the specific language governing rights and limitations under the
990
- * License.
991
- *
992
- * The Original Code is Mozilla Skywriter.
993
- *
994
- * The Initial Developer of the Original Code is
995
- * Mozilla.
996
- * Portions created by the Initial Developer are Copyright (C) 2009
997
- * the Initial Developer. All Rights Reserved.
998
- *
999
- * Contributor(s):
1000
- * Kevin Dangoor (kdangoor@mozilla.com)
1001
- *
1002
- * Alternatively, the contents of this file may be used under the terms of
1003
- * either the GNU General Public License Version 2 or later (the "GPL"), or
1004
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
1005
- * in which case the provisions of the GPL or the LGPL are applicable instead
1006
- * of those above. If you wish to allow use of your version of this file only
1007
- * under the terms of either the GPL or the LGPL, and not to allow others to
1008
- * use your version of this file under the terms of the MPL, indicate your
1009
- * decision by deleting the provisions above and replace them with the notice
1010
- * and other provisions required by the GPL or the LGPL. If you do not delete
1011
- * the provisions above, a recipient may use your version of this file under
1012
- * the terms of any one of the MPL, the GPL or the LGPL.
1013
- *
1014
- * ***** END LICENSE BLOCK ***** */
1015
-
1016
- define('ace/ace', ['require', 'exports', 'module' , 'pilot/index', 'pilot/fixoldbrowsers', 'pilot/plugin_manager', 'pilot/dom', 'pilot/event', 'ace/editor', 'ace/edit_session', 'ace/undomanager', 'ace/virtual_renderer', 'ace/theme/textmate', 'pilot/environment'], function(require, exports, module) {
1017
-
1018
- require("pilot/index");
1019
- require("pilot/fixoldbrowsers");
1020
- var catalog = require("pilot/plugin_manager").catalog;
1021
- catalog.registerPlugins([ "pilot/index" ]);
1022
-
1023
- var Dom = require("pilot/dom");
1024
- var Event = require("pilot/event");
1025
-
1026
- var Editor = require("ace/editor").Editor;
1027
- var EditSession = require("ace/edit_session").EditSession;
1028
- var UndoManager = require("ace/undomanager").UndoManager;
1029
- var Renderer = require("ace/virtual_renderer").VirtualRenderer;
1030
-
1031
- exports.edit = function(el) {
1032
- if (typeof(el) == "string") {
1033
- el = document.getElementById(el);
1034
- }
1035
-
1036
- var doc = new EditSession(Dom.getInnerText(el));
1037
- doc.setUndoManager(new UndoManager());
1038
- el.innerHTML = '';
1039
-
1040
- var editor = new Editor(new Renderer(el, require("ace/theme/textmate")));
1041
- editor.setSession(doc);
1042
-
1043
- var env = require("pilot/environment").create();
1044
- catalog.startupPlugins({ env: env }).then(function() {
1045
- env.document = doc;
1046
- env.editor = editor;
1047
- editor.resize();
1048
- Event.addListener(window, "resize", function() {
1049
- editor.resize();
1050
- });
1051
- el.env = env;
1052
- });
1053
- // Store env on editor such that it can be accessed later on from
1054
- // the returned object.
1055
- editor.env = env;
1056
- return editor;
1057
- };
1058
- });/* ***** BEGIN LICENSE BLOCK *****
1059
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
1060
- *
1061
- * The contents of this file are subject to the Mozilla Public License Version
1062
- * 1.1 (the "License"); you may not use this file except in compliance with
1063
- * the License. You may obtain a copy of the License at
1064
- * http://www.mozilla.org/MPL/
1065
- *
1066
- * Software distributed under the License is distributed on an "AS IS" basis,
1067
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
1068
- * for the specific language governing rights and limitations under the
1069
- * License.
1070
- *
1071
- * The Original Code is Mozilla Skywriter.
1072
- *
1073
- * The Initial Developer of the Original Code is
1074
- * Mozilla.
1075
- * Portions created by the Initial Developer are Copyright (C) 2009
1076
- * the Initial Developer. All Rights Reserved.
1077
- *
1078
- * Contributor(s):
1079
- * Kevin Dangoor (kdangoor@mozilla.com)
1080
- *
1081
- * Alternatively, the contents of this file may be used under the terms of
1082
- * either the GNU General Public License Version 2 or later (the "GPL"), or
1083
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
1084
- * in which case the provisions of the GPL or the LGPL are applicable instead
1085
- * of those above. If you wish to allow use of your version of this file only
1086
- * under the terms of either the GPL or the LGPL, and not to allow others to
1087
- * use your version of this file under the terms of the MPL, indicate your
1088
- * decision by deleting the provisions above and replace them with the notice
1089
- * and other provisions required by the GPL or the LGPL. If you do not delete
1090
- * the provisions above, a recipient may use your version of this file under
1091
- * the terms of any one of the MPL, the GPL or the LGPL.
1092
- *
1093
- * ***** END LICENSE BLOCK ***** */
1094
-
1095
- define('pilot/index', ['require', 'exports', 'module' , 'pilot/fixoldbrowsers', 'pilot/types/basic', 'pilot/types/command', 'pilot/types/settings', 'pilot/commands/settings', 'pilot/commands/basic', 'pilot/settings/canon', 'pilot/canon'], function(require, exports, module) {
1096
-
1097
- exports.startup = function(data, reason) {
1098
- require('pilot/fixoldbrowsers');
1099
-
1100
- require('pilot/types/basic').startup(data, reason);
1101
- require('pilot/types/command').startup(data, reason);
1102
- require('pilot/types/settings').startup(data, reason);
1103
- require('pilot/commands/settings').startup(data, reason);
1104
- require('pilot/commands/basic').startup(data, reason);
1105
- // require('pilot/commands/history').startup(data, reason);
1106
- require('pilot/settings/canon').startup(data, reason);
1107
- require('pilot/canon').startup(data, reason);
1108
- };
1109
-
1110
- exports.shutdown = function(data, reason) {
1111
- require('pilot/types/basic').shutdown(data, reason);
1112
- require('pilot/types/command').shutdown(data, reason);
1113
- require('pilot/types/settings').shutdown(data, reason);
1114
- require('pilot/commands/settings').shutdown(data, reason);
1115
- require('pilot/commands/basic').shutdown(data, reason);
1116
- // require('pilot/commands/history').shutdown(data, reason);
1117
- require('pilot/settings/canon').shutdown(data, reason);
1118
- require('pilot/canon').shutdown(data, reason);
1119
- };
1120
-
1121
-
1122
- });
1123
- /* ***** BEGIN LICENSE BLOCK *****
1124
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
1125
- *
1126
- * The contents of this file are subject to the Mozilla Public License Version
1127
- * 1.1 (the "License"); you may not use this file except in compliance with
1128
- * the License. You may obtain a copy of the License at
1129
- * http://www.mozilla.org/MPL/
1130
- *
1131
- * Software distributed under the License is distributed on an "AS IS" basis,
1132
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
1133
- * for the specific language governing rights and limitations under the
1134
- * License.
1135
- *
1136
- * The Original Code is Mozilla Skywriter.
1137
- *
1138
- * The Initial Developer of the Original Code is
1139
- * Mozilla.
1140
- * Portions created by the Initial Developer are Copyright (C) 2009
1141
- * the Initial Developer. All Rights Reserved.
1142
- *
1143
- * Contributor(s):
1144
- * Joe Walker (jwalker@mozilla.com)
1145
- * Kevin Dangoor (kdangoor@mozilla.com)
1146
- *
1147
- * Alternatively, the contents of this file may be used under the terms of
1148
- * either the GNU General Public License Version 2 or later (the "GPL"), or
1149
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
1150
- * in which case the provisions of the GPL or the LGPL are applicable instead
1151
- * of those above. If you wish to allow use of your version of this file only
1152
- * under the terms of either the GPL or the LGPL, and not to allow others to
1153
- * use your version of this file under the terms of the MPL, indicate your
1154
- * decision by deleting the provisions above and replace them with the notice
1155
- * and other provisions required by the GPL or the LGPL. If you do not delete
1156
- * the provisions above, a recipient may use your version of this file under
1157
- * the terms of any one of the MPL, the GPL or the LGPL.
1158
- *
1159
- * ***** END LICENSE BLOCK ***** */
1160
-
1161
- define('pilot/types/basic', ['require', 'exports', 'module' , 'pilot/types'], function(require, exports, module) {
1162
-
1163
- var types = require("pilot/types");
1164
- var Type = types.Type;
1165
- var Conversion = types.Conversion;
1166
- var Status = types.Status;
1167
-
1168
- /**
1169
- * These are the basic types that we accept. They are vaguely based on the
1170
- * Jetpack settings system (https://wiki.mozilla.org/Labs/Jetpack/JEP/24)
1171
- * although clearly more restricted.
1172
- *
1173
- * <p>In addition to these types, Jetpack also accepts range, member, password
1174
- * that we are thinking of adding.
1175
- *
1176
- * <p>This module probably should not be accessed directly, but instead used
1177
- * through types.js
1178
- */
1179
-
1180
- /**
1181
- * 'text' is the default if no type is given.
1182
- */
1183
- var text = new Type();
1184
-
1185
- text.stringify = function(value) {
1186
- return value;
1187
- };
1188
-
1189
- text.parse = function(value) {
1190
- if (typeof value != 'string') {
1191
- throw new Error('non-string passed to text.parse()');
1192
- }
1193
- return new Conversion(value);
1194
- };
1195
-
1196
- text.name = 'text';
1197
-
1198
- /**
1199
- * We don't currently plan to distinguish between integers and floats
1200
- */
1201
- var number = new Type();
1202
-
1203
- number.stringify = function(value) {
1204
- if (!value) {
1205
- return null;
1206
- }
1207
- return '' + value;
1208
- };
1209
-
1210
- number.parse = function(value) {
1211
- if (typeof value != 'string') {
1212
- throw new Error('non-string passed to number.parse()');
1213
- }
1214
-
1215
- if (value.replace(/\s/g, '').length === 0) {
1216
- return new Conversion(null, Status.INCOMPLETE, '');
1217
- }
1218
-
1219
- var reply = new Conversion(parseInt(value, 10));
1220
- if (isNaN(reply.value)) {
1221
- reply.status = Status.INVALID;
1222
- reply.message = 'Can\'t convert "' + value + '" to a number.';
1223
- }
1224
-
1225
- return reply;
1226
- };
1227
-
1228
- number.decrement = function(value) {
1229
- return value - 1;
1230
- };
1231
-
1232
- number.increment = function(value) {
1233
- return value + 1;
1234
- };
1235
-
1236
- number.name = 'number';
1237
-
1238
- /**
1239
- * One of a known set of options
1240
- */
1241
- function SelectionType(typeSpec) {
1242
- if (!Array.isArray(typeSpec.data) && typeof typeSpec.data !== 'function') {
1243
- throw new Error('instances of SelectionType need typeSpec.data to be an array or function that returns an array:' + JSON.stringify(typeSpec));
1244
- }
1245
- Object.keys(typeSpec).forEach(function(key) {
1246
- this[key] = typeSpec[key];
1247
- }, this);
1248
- };
1249
-
1250
- SelectionType.prototype = new Type();
1251
-
1252
- SelectionType.prototype.stringify = function(value) {
1253
- return value;
1254
- };
1255
-
1256
- SelectionType.prototype.parse = function(str) {
1257
- if (typeof str != 'string') {
1258
- throw new Error('non-string passed to parse()');
1259
- }
1260
- if (!this.data) {
1261
- throw new Error('Missing data on selection type extension.');
1262
- }
1263
- var data = (typeof(this.data) === 'function') ? this.data() : this.data;
1264
-
1265
- // The matchedValue could be the boolean value false
1266
- var hasMatched = false;
1267
- var matchedValue;
1268
- var completions = [];
1269
- data.forEach(function(option) {
1270
- if (str == option) {
1271
- matchedValue = this.fromString(option);
1272
- hasMatched = true;
1273
- }
1274
- else if (option.indexOf(str) === 0) {
1275
- completions.push(this.fromString(option));
1276
- }
1277
- }, this);
1278
-
1279
- if (hasMatched) {
1280
- return new Conversion(matchedValue);
1281
- }
1282
- else {
1283
- // This is something of a hack it basically allows us to tell the
1284
- // setting type to forget its last setting hack.
1285
- if (this.noMatch) {
1286
- this.noMatch();
1287
- }
1288
-
1289
- if (completions.length > 0) {
1290
- var msg = 'Possibilities' +
1291
- (str.length === 0 ? '' : ' for \'' + str + '\'');
1292
- return new Conversion(null, Status.INCOMPLETE, msg, completions);
1293
- }
1294
- else {
1295
- var msg = 'Can\'t use \'' + str + '\'.';
1296
- return new Conversion(null, Status.INVALID, msg, completions);
1297
- }
1298
- }
1299
- };
1300
-
1301
- SelectionType.prototype.fromString = function(str) {
1302
- return str;
1303
- };
1304
-
1305
- SelectionType.prototype.decrement = function(value) {
1306
- var data = (typeof this.data === 'function') ? this.data() : this.data;
1307
- var index;
1308
- if (value == null) {
1309
- index = data.length - 1;
1310
- }
1311
- else {
1312
- var name = this.stringify(value);
1313
- var index = data.indexOf(name);
1314
- index = (index === 0 ? data.length - 1 : index - 1);
1315
- }
1316
- return this.fromString(data[index]);
1317
- };
1318
-
1319
- SelectionType.prototype.increment = function(value) {
1320
- var data = (typeof this.data === 'function') ? this.data() : this.data;
1321
- var index;
1322
- if (value == null) {
1323
- index = 0;
1324
- }
1325
- else {
1326
- var name = this.stringify(value);
1327
- var index = data.indexOf(name);
1328
- index = (index === data.length - 1 ? 0 : index + 1);
1329
- }
1330
- return this.fromString(data[index]);
1331
- };
1332
-
1333
- SelectionType.prototype.name = 'selection';
1334
-
1335
- /**
1336
- * SelectionType is a base class for other types
1337
- */
1338
- exports.SelectionType = SelectionType;
1339
-
1340
- /**
1341
- * true/false values
1342
- */
1343
- var bool = new SelectionType({
1344
- name: 'bool',
1345
- data: [ 'true', 'false' ],
1346
- stringify: function(value) {
1347
- return '' + value;
1348
- },
1349
- fromString: function(str) {
1350
- return str === 'true' ? true : false;
1351
- }
1352
- });
1353
-
1354
-
1355
- /**
1356
- * A we don't know right now, but hope to soon.
1357
- */
1358
- function DeferredType(typeSpec) {
1359
- if (typeof typeSpec.defer !== 'function') {
1360
- throw new Error('Instances of DeferredType need typeSpec.defer to be a function that returns a type');
1361
- }
1362
- Object.keys(typeSpec).forEach(function(key) {
1363
- this[key] = typeSpec[key];
1364
- }, this);
1365
- };
1366
-
1367
- DeferredType.prototype = new Type();
1368
-
1369
- DeferredType.prototype.stringify = function(value) {
1370
- return this.defer().stringify(value);
1371
- };
1372
-
1373
- DeferredType.prototype.parse = function(value) {
1374
- return this.defer().parse(value);
1375
- };
1376
-
1377
- DeferredType.prototype.decrement = function(value) {
1378
- var deferred = this.defer();
1379
- return (deferred.decrement ? deferred.decrement(value) : undefined);
1380
- };
1381
-
1382
- DeferredType.prototype.increment = function(value) {
1383
- var deferred = this.defer();
1384
- return (deferred.increment ? deferred.increment(value) : undefined);
1385
- };
1386
-
1387
- DeferredType.prototype.name = 'deferred';
1388
-
1389
- /**
1390
- * DeferredType is a base class for other types
1391
- */
1392
- exports.DeferredType = DeferredType;
1393
-
1394
-
1395
- /**
1396
- * A set of objects of the same type
1397
- */
1398
- function ArrayType(typeSpec) {
1399
- if (typeSpec instanceof Type) {
1400
- this.subtype = typeSpec;
1401
- }
1402
- else if (typeof typeSpec === 'string') {
1403
- this.subtype = types.getType(typeSpec);
1404
- if (this.subtype == null) {
1405
- throw new Error('Unknown array subtype: ' + typeSpec);
1406
- }
1407
- }
1408
- else {
1409
- throw new Error('Can\' handle array subtype');
1410
- }
1411
- };
1412
-
1413
- ArrayType.prototype = new Type();
1414
-
1415
- ArrayType.prototype.stringify = function(values) {
1416
- // TODO: Check for strings with spaces and add quotes
1417
- return values.join(' ');
1418
- };
1419
-
1420
- ArrayType.prototype.parse = function(value) {
1421
- return this.defer().parse(value);
1422
- };
1423
-
1424
- ArrayType.prototype.name = 'array';
1425
-
1426
- /**
1427
- * Registration and de-registration.
1428
- */
1429
- var isStarted = false;
1430
- exports.startup = function() {
1431
- if (isStarted) {
1432
- return;
1433
- }
1434
- isStarted = true;
1435
- types.registerType(text);
1436
- types.registerType(number);
1437
- types.registerType(bool);
1438
- types.registerType(SelectionType);
1439
- types.registerType(DeferredType);
1440
- types.registerType(ArrayType);
1441
- };
1442
-
1443
- exports.shutdown = function() {
1444
- isStarted = false;
1445
- types.unregisterType(text);
1446
- types.unregisterType(number);
1447
- types.unregisterType(bool);
1448
- types.unregisterType(SelectionType);
1449
- types.unregisterType(DeferredType);
1450
- types.unregisterType(ArrayType);
1451
- };
1452
-
1453
-
1454
- });
1455
- /* ***** BEGIN LICENSE BLOCK *****
1456
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
1457
- *
1458
- * The contents of this file are subject to the Mozilla Public License Version
1459
- * 1.1 (the "License"); you may not use this file except in compliance with
1460
- * the License. You may obtain a copy of the License at
1461
- * http://www.mozilla.org/MPL/
1462
- *
1463
- * Software distributed under the License is distributed on an "AS IS" basis,
1464
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
1465
- * for the specific language governing rights and limitations under the
1466
- * License.
1467
- *
1468
- * The Original Code is Skywriter.
1469
- *
1470
- * The Initial Developer of the Original Code is
1471
- * Mozilla.
1472
- * Portions created by the Initial Developer are Copyright (C) 2009
1473
- * the Initial Developer. All Rights Reserved.
1474
- *
1475
- * Contributor(s):
1476
- * Joe Walker (jwalker@mozilla.com)
1477
- *
1478
- * Alternatively, the contents of this file may be used under the terms of
1479
- * either the GNU General Public License Version 2 or later (the "GPL"), or
1480
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
1481
- * in which case the provisions of the GPL or the LGPL are applicable instead
1482
- * of those above. If you wish to allow use of your version of this file only
1483
- * under the terms of either the GPL or the LGPL, and not to allow others to
1484
- * use your version of this file under the terms of the MPL, indicate your
1485
- * decision by deleting the provisions above and replace them with the notice
1486
- * and other provisions required by the GPL or the LGPL. If you do not delete
1487
- * the provisions above, a recipient may use your version of this file under
1488
- * the terms of any one of the MPL, the GPL or the LGPL.
1489
- *
1490
- * ***** END LICENSE BLOCK ***** */
1491
-
1492
- define('pilot/types', ['require', 'exports', 'module' ], function(require, exports, module) {
1493
-
1494
- /**
1495
- * Some types can detect validity, that is to say they can distinguish between
1496
- * valid and invalid values.
1497
- * TODO: Change these constants to be numbers for more performance?
1498
- */
1499
- var Status = {
1500
- /**
1501
- * The conversion process worked without any problem, and the value is
1502
- * valid. There are a number of failure states, so the best way to check
1503
- * for failure is (x !== Status.VALID)
1504
- */
1505
- VALID: {
1506
- toString: function() { return 'VALID'; },
1507
- valueOf: function() { return 0; }
1508
- },
1509
-
1510
- /**
1511
- * A conversion process failed, however it was noted that the string
1512
- * provided to 'parse()' could be VALID by the addition of more characters,
1513
- * so the typing may not be actually incorrect yet, just unfinished.
1514
- * @see Status.INVALID
1515
- */
1516
- INCOMPLETE: {
1517
- toString: function() { return 'INCOMPLETE'; },
1518
- valueOf: function() { return 1; }
1519
- },
1520
-
1521
- /**
1522
- * The conversion process did not work, the value should be null and a
1523
- * reason for failure should have been provided. In addition some completion
1524
- * values may be available.
1525
- * @see Status.INCOMPLETE
1526
- */
1527
- INVALID: {
1528
- toString: function() { return 'INVALID'; },
1529
- valueOf: function() { return 2; }
1530
- },
1531
-
1532
- /**
1533
- * A combined status is the worser of the provided statuses
1534
- */
1535
- combine: function(statuses) {
1536
- var combined = Status.VALID;
1537
- for (var i = 0; i < statuses.length; i++) {
1538
- if (statuses[i].valueOf() > combined.valueOf()) {
1539
- combined = statuses[i];
1540
- }
1541
- }
1542
- return combined;
1543
- }
1544
- };
1545
- exports.Status = Status;
1546
-
1547
- /**
1548
- * The type.parse() method returns a Conversion to inform the user about not
1549
- * only the result of a Conversion but also about what went wrong.
1550
- * We could use an exception, and throw if the conversion failed, but that
1551
- * seems to violate the idea that exceptions should be exceptional. Typos are
1552
- * not. Also in order to store both a status and a message we'd still need
1553
- * some sort of exception type...
1554
- */
1555
- function Conversion(value, status, message, predictions) {
1556
- /**
1557
- * The result of the conversion process. Will be null if status != VALID
1558
- */
1559
- this.value = value;
1560
-
1561
- /**
1562
- * The status of the conversion.
1563
- * @see Status
1564
- */
1565
- this.status = status || Status.VALID;
1566
-
1567
- /**
1568
- * A message to go with the conversion. This could be present for any status
1569
- * including VALID in the case where we want to note a warning for example.
1570
- * I18N: On the one hand this nasty and un-internationalized, however with
1571
- * a command line it is hard to know where to start.
1572
- */
1573
- this.message = message;
1574
-
1575
- /**
1576
- * A array of strings which are the systems best guess at better inputs than
1577
- * the one presented.
1578
- * We generally expect there to be about 7 predictions (to match human list
1579
- * comprehension ability) however it is valid to provide up to about 20,
1580
- * or less. It is the job of the predictor to decide a smart cut-off.
1581
- * For example if there are 4 very good matches and 4 very poor ones,
1582
- * probably only the 4 very good matches should be presented.
1583
- */
1584
- this.predictions = predictions || [];
1585
- }
1586
- exports.Conversion = Conversion;
1587
-
1588
- /**
1589
- * Most of our types are 'static' e.g. there is only one type of 'text', however
1590
- * some types like 'selection' and 'deferred' are customizable. The basic
1591
- * Type type isn't useful, but does provide documentation about what types do.
1592
- */
1593
- function Type() {
1594
- };
1595
- Type.prototype = {
1596
- /**
1597
- * Convert the given <tt>value</tt> to a string representation.
1598
- * Where possible, there should be round-tripping between values and their
1599
- * string representations.
1600
- */
1601
- stringify: function(value) { throw new Error("not implemented"); },
1602
-
1603
- /**
1604
- * Convert the given <tt>str</tt> to an instance of this type.
1605
- * Where possible, there should be round-tripping between values and their
1606
- * string representations.
1607
- * @return Conversion
1608
- */
1609
- parse: function(str) { throw new Error("not implemented"); },
1610
-
1611
- /**
1612
- * The plug-in system, and other things need to know what this type is
1613
- * called. The name alone is not enough to fully specify a type. Types like
1614
- * 'selection' and 'deferred' need extra data, however this function returns
1615
- * only the name, not the extra data.
1616
- * <p>In old bespin, equality was based on the name. This may turn out to be
1617
- * important in Ace too.
1618
- */
1619
- name: undefined,
1620
-
1621
- /**
1622
- * If there is some concept of a higher value, return it,
1623
- * otherwise return undefined.
1624
- */
1625
- increment: function(value) {
1626
- return undefined;
1627
- },
1628
-
1629
- /**
1630
- * If there is some concept of a lower value, return it,
1631
- * otherwise return undefined.
1632
- */
1633
- decrement: function(value) {
1634
- return undefined;
1635
- },
1636
-
1637
- /**
1638
- * There is interesting information (like predictions) in a conversion of
1639
- * nothing, the output of this can sometimes be customized.
1640
- * @return Conversion
1641
- */
1642
- getDefault: function() {
1643
- return this.parse('');
1644
- }
1645
- };
1646
- exports.Type = Type;
1647
-
1648
- /**
1649
- * Private registry of types
1650
- * Invariant: types[name] = type.name
1651
- */
1652
- var types = {};
1653
-
1654
- /**
1655
- * Add a new type to the list available to the system.
1656
- * You can pass 2 things to this function - either an instance of Type, in
1657
- * which case we return this instance when #getType() is called with a 'name'
1658
- * that matches type.name.
1659
- * Also you can pass in a constructor (i.e. function) in which case when
1660
- * #getType() is called with a 'name' that matches Type.prototype.name we will
1661
- * pass the typeSpec into this constructor. See #reconstituteType().
1662
- */
1663
- exports.registerType = function(type) {
1664
- if (typeof type === 'object') {
1665
- if (type instanceof Type) {
1666
- if (!type.name) {
1667
- throw new Error('All registered types must have a name');
1668
- }
1669
- types[type.name] = type;
1670
- }
1671
- else {
1672
- throw new Error('Can\'t registerType using: ' + type);
1673
- }
1674
- }
1675
- else if (typeof type === 'function') {
1676
- if (!type.prototype.name) {
1677
- throw new Error('All registered types must have a name');
1678
- }
1679
- types[type.prototype.name] = type;
1680
- }
1681
- else {
1682
- throw new Error('Unknown type: ' + type);
1683
- }
1684
- };
1685
-
1686
- exports.registerTypes = function registerTypes(types) {
1687
- Object.keys(types).forEach(function (name) {
1688
- var type = types[name];
1689
- type.name = name;
1690
- exports.registerType(type);
1691
- });
1692
- };
1693
-
1694
- /**
1695
- * Remove a type from the list available to the system
1696
- */
1697
- exports.deregisterType = function(type) {
1698
- delete types[type.name];
1699
- };
1700
-
1701
- /**
1702
- * See description of #exports.registerType()
1703
- */
1704
- function reconstituteType(name, typeSpec) {
1705
- if (name.substr(-2) === '[]') { // i.e. endsWith('[]')
1706
- var subtypeName = name.slice(0, -2);
1707
- return new types['array'](subtypeName);
1708
- }
1709
-
1710
- var type = types[name];
1711
- if (typeof type === 'function') {
1712
- type = new type(typeSpec);
1713
- }
1714
- return type;
1715
- }
1716
-
1717
- /**
1718
- * Find a type, previously registered using #registerType()
1719
- */
1720
- exports.getType = function(typeSpec) {
1721
- if (typeof typeSpec === 'string') {
1722
- return reconstituteType(typeSpec);
1723
- }
1724
-
1725
- if (typeof typeSpec === 'object') {
1726
- if (!typeSpec.name) {
1727
- throw new Error('Missing \'name\' member to typeSpec');
1728
- }
1729
- return reconstituteType(typeSpec.name, typeSpec);
1730
- }
1731
-
1732
- throw new Error('Can\'t extract type from ' + typeSpec);
1733
- };
1734
-
1735
-
1736
- });
1737
- /* ***** BEGIN LICENSE BLOCK *****
1738
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
1739
- *
1740
- * The contents of this file are subject to the Mozilla Public License Version
1741
- * 1.1 (the "License"); you may not use this file except in compliance with
1742
- * the License. You may obtain a copy of the License at
1743
- * http://www.mozilla.org/MPL/
1744
- *
1745
- * Software distributed under the License is distributed on an "AS IS" basis,
1746
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
1747
- * for the specific language governing rights and limitations under the
1748
- * License.
1749
- *
1750
- * The Original Code is Mozilla Skywriter.
1751
- *
1752
- * The Initial Developer of the Original Code is
1753
- * Mozilla.
1754
- * Portions created by the Initial Developer are Copyright (C) 2009
1755
- * the Initial Developer. All Rights Reserved.
1756
- *
1757
- * Contributor(s):
1758
- * Joe Walker (jwalker@mozilla.com)
1759
- * Kevin Dangoor (kdangoor@mozilla.com)
1760
- *
1761
- * Alternatively, the contents of this file may be used under the terms of
1762
- * either the GNU General Public License Version 2 or later (the "GPL"), or
1763
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
1764
- * in which case the provisions of the GPL or the LGPL are applicable instead
1765
- * of those above. If you wish to allow use of your version of this file only
1766
- * under the terms of either the GPL or the LGPL, and not to allow others to
1767
- * use your version of this file under the terms of the MPL, indicate your
1768
- * decision by deleting the provisions above and replace them with the notice
1769
- * and other provisions required by the GPL or the LGPL. If you do not delete
1770
- * the provisions above, a recipient may use your version of this file under
1771
- * the terms of any one of the MPL, the GPL or the LGPL.
1772
- *
1773
- * ***** END LICENSE BLOCK ***** */
1774
-
1775
- define('pilot/types/command', ['require', 'exports', 'module' , 'pilot/canon', 'pilot/types/basic', 'pilot/types'], function(require, exports, module) {
1776
-
1777
- var canon = require("pilot/canon");
1778
- var SelectionType = require("pilot/types/basic").SelectionType;
1779
- var types = require("pilot/types");
1780
-
1781
-
1782
- /**
1783
- * Select from the available commands
1784
- */
1785
- var command = new SelectionType({
1786
- name: 'command',
1787
- data: function() {
1788
- return canon.getCommandNames();
1789
- },
1790
- stringify: function(command) {
1791
- return command.name;
1792
- },
1793
- fromString: function(str) {
1794
- return canon.getCommand(str);
1795
- }
1796
- });
1797
-
1798
-
1799
- /**
1800
- * Registration and de-registration.
1801
- */
1802
- exports.startup = function() {
1803
- types.registerType(command);
1804
- };
1805
-
1806
- exports.shutdown = function() {
1807
- types.unregisterType(command);
1808
- };
1809
-
1810
-
1811
- });
1812
- /* ***** BEGIN LICENSE BLOCK *****
1813
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
1814
- *
1815
- * The contents of this file are subject to the Mozilla Public License Version
1816
- * 1.1 (the "License"); you may not use this file except in compliance with
1817
- * the License. You may obtain a copy of the License at
1818
- * http://www.mozilla.org/MPL/
1819
- *
1820
- * Software distributed under the License is distributed on an "AS IS" basis,
1821
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
1822
- * for the specific language governing rights and limitations under the
1823
- * License.
1824
- *
1825
- * The Original Code is Mozilla Skywriter.
1826
- *
1827
- * The Initial Developer of the Original Code is
1828
- * Mozilla.
1829
- * Portions created by the Initial Developer are Copyright (C) 2009
1830
- * the Initial Developer. All Rights Reserved.
1831
- *
1832
- * Contributor(s):
1833
- * Joe Walker (jwalker@mozilla.com)
1834
- *
1835
- * Alternatively, the contents of this file may be used under the terms of
1836
- * either the GNU General Public License Version 2 or later (the "GPL"), or
1837
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
1838
- * in which case the provisions of the GPL or the LGPL are applicable instead
1839
- * of those above. If you wish to allow use of your version of this file only
1840
- * under the terms of either the GPL or the LGPL, and not to allow others to
1841
- * use your version of this file under the terms of the MPL, indicate your
1842
- * decision by deleting the provisions above and replace them with the notice
1843
- * and other provisions required by the GPL or the LGPL. If you do not delete
1844
- * the provisions above, a recipient may use your version of this file under
1845
- * the terms of any one of the MPL, the GPL or the LGPL.
1846
- *
1847
- * ***** END LICENSE BLOCK ***** */
1848
-
1849
- define('pilot/canon', ['require', 'exports', 'module' , 'pilot/console', 'pilot/stacktrace', 'pilot/oop', 'pilot/useragent', 'pilot/keys', 'pilot/event_emitter', 'pilot/typecheck', 'pilot/catalog', 'pilot/types', 'pilot/lang'], function(require, exports, module) {
1850
-
1851
- var console = require('pilot/console');
1852
- var Trace = require('pilot/stacktrace').Trace;
1853
- var oop = require('pilot/oop');
1854
- var useragent = require('pilot/useragent');
1855
- var keyUtil = require('pilot/keys');
1856
- var EventEmitter = require('pilot/event_emitter').EventEmitter;
1857
- var typecheck = require('pilot/typecheck');
1858
- var catalog = require('pilot/catalog');
1859
- var Status = require('pilot/types').Status;
1860
- var types = require('pilot/types');
1861
- var lang = require('pilot/lang');
1862
-
1863
- /*
1864
- // TODO: this doesn't belong here - or maybe anywhere?
1865
- var dimensionsChangedExtensionSpec = {
1866
- name: 'dimensionsChanged',
1867
- description: 'A dimensionsChanged is a way to be notified of ' +
1868
- 'changes to the dimension of Skywriter'
1869
- };
1870
- exports.startup = function(data, reason) {
1871
- catalog.addExtensionSpec(commandExtensionSpec);
1872
- };
1873
- exports.shutdown = function(data, reason) {
1874
- catalog.removeExtensionSpec(commandExtensionSpec);
1875
- };
1876
- */
1877
-
1878
- var commandExtensionSpec = {
1879
- name: 'command',
1880
- description: 'A command is a bit of functionality with optional ' +
1881
- 'typed arguments which can do something small like moving ' +
1882
- 'the cursor around the screen, or large like cloning a ' +
1883
- 'project from VCS.',
1884
- indexOn: 'name'
1885
- };
1886
-
1887
- exports.startup = function(data, reason) {
1888
- // TODO: this is probably all kinds of evil, but we need something working
1889
- catalog.addExtensionSpec(commandExtensionSpec);
1890
- };
1891
-
1892
- exports.shutdown = function(data, reason) {
1893
- catalog.removeExtensionSpec(commandExtensionSpec);
1894
- };
1895
-
1896
- /**
1897
- * Manage a list of commands in the current canon
1898
- */
1899
-
1900
- /**
1901
- * A Command is a discrete action optionally with a set of ways to customize
1902
- * how it happens. This is here for documentation purposes.
1903
- * TODO: Document better
1904
- */
1905
- var thingCommand = {
1906
- name: 'thing',
1907
- description: 'thing is an example command',
1908
- params: [{
1909
- name: 'param1',
1910
- description: 'an example parameter',
1911
- type: 'text',
1912
- defaultValue: null
1913
- }],
1914
- exec: function(env, args, request) {
1915
- thing();
1916
- }
1917
- };
1918
-
1919
- /**
1920
- * A lookup hash of our registered commands
1921
- */
1922
- var commands = {};
1923
-
1924
- /**
1925
- * A lookup has for command key bindings that use a string as sender.
1926
- */
1927
- var commmandKeyBinding = {};
1928
-
1929
- /**
1930
- * Array with command key bindings that use a function to determ the sender.
1931
- */
1932
- var commandKeyBindingFunc = { };
1933
-
1934
- function splitSafe(s, separator, limit, bLowerCase) {
1935
- return (bLowerCase && s.toLowerCase() || s)
1936
- .replace(/(?:^\s+|\n|\s+$)/g, "")
1937
- .split(new RegExp("[\\s ]*" + separator + "[\\s ]*", "g"), limit || 999);
1938
- }
1939
-
1940
- function parseKeys(keys, val, ret) {
1941
- var key,
1942
- hashId = 0,
1943
- parts = splitSafe(keys, "\\-", null, true),
1944
- i = 0,
1945
- l = parts.length;
1946
-
1947
- for (; i < l; ++i) {
1948
- if (keyUtil.KEY_MODS[parts[i]])
1949
- hashId = hashId | keyUtil.KEY_MODS[parts[i]];
1950
- else
1951
- key = parts[i] || "-"; //when empty, the splitSafe removed a '-'
1952
- }
1953
-
1954
- if (ret == null) {
1955
- return {
1956
- key: key,
1957
- hashId: hashId
1958
- }
1959
- } else {
1960
- (ret[hashId] || (ret[hashId] = {}))[key] = val;
1961
- }
1962
- }
1963
-
1964
- var platform = useragent.isMac ? "mac" : "win";
1965
- function buildKeyHash(command) {
1966
- var binding = command.bindKey,
1967
- key = binding[platform],
1968
- ckb = commmandKeyBinding,
1969
- ckbf = commandKeyBindingFunc
1970
-
1971
- if (!binding.sender) {
1972
- throw new Error('All key bindings must have a sender');
1973
- }
1974
- if (!binding.mac && binding.mac !== null) {
1975
- throw new Error('All key bindings must have a mac key binding');
1976
- }
1977
- if (!binding.win && binding.win !== null) {
1978
- throw new Error('All key bindings must have a windows key binding');
1979
- }
1980
- if(!binding[platform]) {
1981
- // No keymapping for this platform.
1982
- return;
1983
- }
1984
- if (typeof binding.sender == 'string') {
1985
- var targets = splitSafe(binding.sender, "\\|", null, true);
1986
- targets.forEach(function(target) {
1987
- if (!ckb[target]) {
1988
- ckb[target] = { };
1989
- }
1990
- key.split("|").forEach(function(keyPart) {
1991
- parseKeys(keyPart, command, ckb[target]);
1992
- });
1993
- });
1994
- } else if (typecheck.isFunction(binding.sender)) {
1995
- var val = {
1996
- command: command,
1997
- sender: binding.sender
1998
- };
1999
-
2000
- keyData = parseKeys(key);
2001
- if (!ckbf[keyData.hashId]) {
2002
- ckbf[keyData.hashId] = { };
2003
- }
2004
- if (!ckbf[keyData.hashId][keyData.key]) {
2005
- ckbf[keyData.hashId][keyData.key] = [ val ];
2006
- } else {
2007
- ckbf[keyData.hashId][keyData.key].push(val);
2008
- }
2009
- } else {
2010
- throw new Error('Key binding must have a sender that is a string or function');
2011
- }
2012
- }
2013
-
2014
- function findKeyCommand(env, sender, hashId, textOrKey) {
2015
- // Convert keyCode to the string representation.
2016
- if (typecheck.isNumber(textOrKey)) {
2017
- textOrKey = keyUtil.keyCodeToString(textOrKey);
2018
- }
2019
-
2020
- // Check bindings with functions as sender first.
2021
- var bindFuncs = (commandKeyBindingFunc[hashId] || {})[textOrKey] || [];
2022
- for (var i = 0; i < bindFuncs.length; i++) {
2023
- if (bindFuncs[i].sender(env, sender, hashId, textOrKey)) {
2024
- return bindFuncs[i].command;
2025
- }
2026
- }
2027
-
2028
- var ckbr = commmandKeyBinding[sender];
2029
- return ckbr && ckbr[hashId] && ckbr[hashId][textOrKey];
2030
- }
2031
-
2032
- function execKeyCommand(env, sender, hashId, textOrKey) {
2033
- var command = findKeyCommand(env, sender, hashId, textOrKey);
2034
- if (command) {
2035
- return exec(command, env, sender, { });
2036
- } else {
2037
- return false;
2038
- }
2039
- }
2040
-
2041
- /**
2042
- * A sorted list of command names, we regularly want them in order, so pre-sort
2043
- */
2044
- var commandNames = [];
2045
-
2046
- /**
2047
- * This registration method isn't like other Ace registration methods because
2048
- * it doesn't return a decorated command because there is no functional
2049
- * decoration to be done.
2050
- * TODO: Are we sure that in the future there will be no such decoration?
2051
- */
2052
- function addCommand(command) {
2053
- if (!command.name) {
2054
- throw new Error('All registered commands must have a name');
2055
- }
2056
- if (command.params == null) {
2057
- command.params = [];
2058
- }
2059
- if (!Array.isArray(command.params)) {
2060
- throw new Error('command.params must be an array in ' + command.name);
2061
- }
2062
- // Replace the type
2063
- command.params.forEach(function(param) {
2064
- if (!param.name) {
2065
- throw new Error('In ' + command.name + ': all params must have a name');
2066
- }
2067
- upgradeType(command.name, param);
2068
- }, this);
2069
- commands[command.name] = command;
2070
-
2071
- if (command.bindKey) {
2072
- buildKeyHash(command);
2073
- }
2074
-
2075
- commandNames.push(command.name);
2076
- commandNames.sort();
2077
- };
2078
-
2079
- function upgradeType(name, param) {
2080
- var lookup = param.type;
2081
- param.type = types.getType(lookup);
2082
- if (param.type == null) {
2083
- throw new Error('In ' + name + '/' + param.name +
2084
- ': can\'t find type for: ' + JSON.stringify(lookup));
2085
- }
2086
- }
2087
-
2088
- function removeCommand(command) {
2089
- var name = (typeof command === 'string' ? command : command.name);
2090
- command = commands[name];
2091
- delete commands[name];
2092
- lang.arrayRemove(commandNames, name);
2093
-
2094
- // exaustive search is a little bit brute force but since removeCommand is
2095
- // not a performance critical operation this should be OK
2096
- var ckb = commmandKeyBinding;
2097
- for (var k1 in ckb) {
2098
- for (var k2 in ckb[k1]) {
2099
- for (var k3 in ckb[k1][k2]) {
2100
- if (ckb[k1][k2][k3] == command)
2101
- delete ckb[k1][k2][k3];
2102
- }
2103
- }
2104
- }
2105
-
2106
- var ckbf = commandKeyBindingFunc;
2107
- for (var k1 in ckbf) {
2108
- for (var k2 in ckbf[k1]) {
2109
- ckbf[k1][k2].forEach(function(cmd, i) {
2110
- if (cmd.command == command) {
2111
- ckbf[k1][k2].splice(i, 1);
2112
- }
2113
- })
2114
- }
2115
- }
2116
- };
2117
-
2118
- function getCommand(name) {
2119
- return commands[name];
2120
- };
2121
-
2122
- function getCommandNames() {
2123
- return commandNames;
2124
- };
2125
-
2126
- /**
2127
- * Default ArgumentProvider that is used if no ArgumentProvider is provided
2128
- * by the command's sender.
2129
- */
2130
- function defaultArgsProvider(request, callback) {
2131
- var args = request.args,
2132
- params = request.command.params;
2133
-
2134
- for (var i = 0; i < params.length; i++) {
2135
- var param = params[i];
2136
-
2137
- // If the parameter is already valid, then don't ask for it anymore.
2138
- if (request.getParamStatus(param) != Status.VALID ||
2139
- // Ask for optional parameters as well.
2140
- param.defaultValue === null)
2141
- {
2142
- var paramPrompt = param.description;
2143
- if (param.defaultValue === null) {
2144
- paramPrompt += " (optional)";
2145
- }
2146
- var value = prompt(paramPrompt, param.defaultValue || "");
2147
- // No value but required -> nope.
2148
- if (!value) {
2149
- callback();
2150
- return;
2151
- } else {
2152
- args[param.name] = value;
2153
- }
2154
- }
2155
- }
2156
- callback();
2157
- }
2158
-
2159
- /**
2160
- * Entry point for keyboard accelerators or anything else that wants to execute
2161
- * a command. A new request object is created and a check performed, if the
2162
- * passed in arguments are VALID/INVALID or INCOMPLETE. If they are INCOMPLETE
2163
- * the ArgumentProvider on the sender is called or otherwise the default
2164
- * ArgumentProvider to get the still required arguments.
2165
- * If they are valid (or valid after the ArgumentProvider is done), the command
2166
- * is executed.
2167
- *
2168
- * @param command Either a command, or the name of one
2169
- * @param env Current environment to execute the command in
2170
- * @param sender String that should be the same as the senderObject stored on
2171
- * the environment in env[sender]
2172
- * @param args Arguments for the command
2173
- * @param typed (Optional)
2174
- */
2175
- function exec(command, env, sender, args, typed) {
2176
- if (typeof command === 'string') {
2177
- command = commands[command];
2178
- }
2179
- if (!command) {
2180
- // TODO: Should we complain more than returning false?
2181
- return false;
2182
- }
2183
-
2184
- var request = new Request({
2185
- sender: sender,
2186
- command: command,
2187
- args: args || {},
2188
- typed: typed
2189
- });
2190
-
2191
- /**
2192
- * Executes the command and ensures request.done is called on the request in
2193
- * case it's not marked to be done already or async.
2194
- */
2195
- function execute() {
2196
- command.exec(env, request.args, request);
2197
-
2198
- // If the request isn't asnync and isn't done, then make it done.
2199
- if (!request.isAsync && !request.isDone) {
2200
- request.done();
2201
- }
2202
- }
2203
-
2204
-
2205
- if (request.getStatus() == Status.INVALID) {
2206
- console.error("Canon.exec: Invalid parameter(s) passed to " +
2207
- command.name);
2208
- return false;
2209
- }
2210
- // If the request isn't complete yet, try to complete it.
2211
- else if (request.getStatus() == Status.INCOMPLETE) {
2212
- // Check if the sender has a ArgsProvider, otherwise use the default
2213
- // build in one.
2214
- var argsProvider;
2215
- var senderObj = env[sender];
2216
- if (!senderObj || !senderObj.getArgsProvider ||
2217
- !(argsProvider = senderObj.getArgsProvider()))
2218
- {
2219
- argsProvider = defaultArgsProvider;
2220
- }
2221
-
2222
- // Ask the paramProvider to complete the request.
2223
- argsProvider(request, function() {
2224
- if (request.getStatus() == Status.VALID) {
2225
- execute();
2226
- }
2227
- });
2228
- return true;
2229
- } else {
2230
- execute();
2231
- return true;
2232
- }
2233
- };
2234
-
2235
- exports.removeCommand = removeCommand;
2236
- exports.addCommand = addCommand;
2237
- exports.getCommand = getCommand;
2238
- exports.getCommandNames = getCommandNames;
2239
- exports.findKeyCommand = findKeyCommand;
2240
- exports.exec = exec;
2241
- exports.execKeyCommand = execKeyCommand;
2242
- exports.upgradeType = upgradeType;
2243
-
2244
-
2245
- /**
2246
- * We publish a 'output' event whenever new command begins output
2247
- * TODO: make this more obvious
2248
- */
2249
- oop.implement(exports, EventEmitter);
2250
-
2251
-
2252
- /**
2253
- * Current requirements are around displaying the command line, and provision
2254
- * of a 'history' command and cursor up|down navigation of history.
2255
- * <p>Future requirements could include:
2256
- * <ul>
2257
- * <li>Multiple command lines
2258
- * <li>The ability to recall key presses (i.e. requests with no output) which
2259
- * will likely be needed for macro recording or similar
2260
- * <li>The ability to store the command history either on the server or in the
2261
- * browser local storage.
2262
- * </ul>
2263
- * <p>The execute() command doesn't really live here, except as part of that
2264
- * last future requirement, and because it doesn't really have anywhere else to
2265
- * live.
2266
- */
2267
-
2268
- /**
2269
- * The array of requests that wish to announce their presence
2270
- */
2271
- var requests = [];
2272
-
2273
- /**
2274
- * How many requests do we store?
2275
- */
2276
- var maxRequestLength = 100;
2277
-
2278
- /**
2279
- * To create an invocation, you need to do something like this (all the ctor
2280
- * args are optional):
2281
- * <pre>
2282
- * var request = new Request({
2283
- * command: command,
2284
- * args: args,
2285
- * typed: typed
2286
- * });
2287
- * </pre>
2288
- * @constructor
2289
- */
2290
- function Request(options) {
2291
- options = options || {};
2292
-
2293
- // Will be used in the keyboard case and the cli case
2294
- this.command = options.command;
2295
-
2296
- // Will be used only in the cli case
2297
- this.args = options.args;
2298
- this.typed = options.typed;
2299
-
2300
- // Have we been initialized?
2301
- this._begunOutput = false;
2302
-
2303
- this.start = new Date();
2304
- this.end = null;
2305
- this.completed = false;
2306
- this.error = false;
2307
- };
2308
-
2309
- oop.implement(Request.prototype, EventEmitter);
2310
-
2311
- /**
2312
- * Return the status of a parameter on the request object.
2313
- */
2314
- Request.prototype.getParamStatus = function(param) {
2315
- var args = this.args || {};
2316
-
2317
- // Check if there is already a value for this parameter.
2318
- if (param.name in args) {
2319
- // If there is no value set and then the value is VALID if it's not
2320
- // required or INCOMPLETE if not set yet.
2321
- if (args[param.name] == null) {
2322
- if (param.defaultValue === null) {
2323
- return Status.VALID;
2324
- } else {
2325
- return Status.INCOMPLETE;
2326
- }
2327
- }
2328
-
2329
- // Check if the parameter value is valid.
2330
- var reply,
2331
- // The passed in value when parsing a type is a string.
2332
- argsValue = args[param.name].toString();
2333
-
2334
- // Type.parse can throw errors.
2335
- try {
2336
- reply = param.type.parse(argsValue);
2337
- } catch (e) {
2338
- return Status.INVALID;
2339
- }
2340
-
2341
- if (reply.status != Status.VALID) {
2342
- return reply.status;
2343
- }
2344
- }
2345
- // Check if the param is marked as required.
2346
- else if (param.defaultValue === undefined) {
2347
- // The parameter is not set on the args object but it's required,
2348
- // which means, things are invalid.
2349
- return Status.INCOMPLETE;
2350
- }
2351
-
2352
- return Status.VALID;
2353
- }
2354
-
2355
- /**
2356
- * Return the status of a parameter name on the request object.
2357
- */
2358
- Request.prototype.getParamNameStatus = function(paramName) {
2359
- var params = this.command.params || [];
2360
-
2361
- for (var i = 0; i < params.length; i++) {
2362
- if (params[i].name == paramName) {
2363
- return this.getParamStatus(params[i]);
2364
- }
2365
- }
2366
-
2367
- throw "Parameter '" + paramName +
2368
- "' not defined on command '" + this.command.name + "'";
2369
- }
2370
-
2371
- /**
2372
- * Checks if all required arguments are set on the request such that it can
2373
- * get executed.
2374
- */
2375
- Request.prototype.getStatus = function() {
2376
- var args = this.args || {},
2377
- params = this.command.params;
2378
-
2379
- // If there are not parameters, then it's valid.
2380
- if (!params || params.length == 0) {
2381
- return Status.VALID;
2382
- }
2383
-
2384
- var status = [];
2385
- for (var i = 0; i < params.length; i++) {
2386
- status.push(this.getParamStatus(params[i]));
2387
- }
2388
-
2389
- return Status.combine(status);
2390
- }
2391
-
2392
- /**
2393
- * Lazy init to register with the history should only be done on output.
2394
- * init() is expensive, and won't be used in the majority of cases
2395
- */
2396
- Request.prototype._beginOutput = function() {
2397
- this._begunOutput = true;
2398
- this.outputs = [];
2399
-
2400
- requests.push(this);
2401
- // This could probably be optimized with some maths, but 99.99% of the
2402
- // time we will only be off by one, and I'm feeling lazy.
2403
- while (requests.length > maxRequestLength) {
2404
- requests.shiftObject();
2405
- }
2406
-
2407
- exports._dispatchEvent('output', { requests: requests, request: this });
2408
- };
2409
-
2410
- /**
2411
- * Sugar for:
2412
- * <pre>request.error = true; request.done(output);</pre>
2413
- */
2414
- Request.prototype.doneWithError = function(content) {
2415
- this.error = true;
2416
- this.done(content);
2417
- };
2418
-
2419
- /**
2420
- * Declares that this function will not be automatically done when
2421
- * the command exits
2422
- */
2423
- Request.prototype.async = function() {
2424
- this.isAsync = true;
2425
- if (!this._begunOutput) {
2426
- this._beginOutput();
2427
- }
2428
- };
2429
-
2430
- /**
2431
- * Complete the currently executing command with successful output.
2432
- * @param output Either DOM node, an SproutCore element or something that
2433
- * can be used in the content of a DIV to create a DOM node.
2434
- */
2435
- Request.prototype.output = function(content) {
2436
- if (!this._begunOutput) {
2437
- this._beginOutput();
2438
- }
2439
-
2440
- if (typeof content !== 'string' && !(content instanceof Node)) {
2441
- content = content.toString();
2442
- }
2443
-
2444
- this.outputs.push(content);
2445
- this.isDone = true;
2446
- this._dispatchEvent('output', {});
2447
-
2448
- return this;
2449
- };
2450
-
2451
- /**
2452
- * All commands that do output must call this to indicate that the command
2453
- * has finished execution.
2454
- */
2455
- Request.prototype.done = function(content) {
2456
- this.completed = true;
2457
- this.end = new Date();
2458
- this.duration = this.end.getTime() - this.start.getTime();
2459
-
2460
- if (content) {
2461
- this.output(content);
2462
- }
2463
-
2464
- // Ensure to finish the request only once.
2465
- if (!this.isDone) {
2466
- this.isDone = true;
2467
- this._dispatchEvent('output', {});
2468
- }
2469
- };
2470
- exports.Request = Request;
2471
-
2472
-
2473
- });
2474
- /* ***** BEGIN LICENSE BLOCK *****
2475
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
2476
- *
2477
- * The contents of this file are subject to the Mozilla Public License Version
2478
- * 1.1 (the "License"); you may not use this file except in compliance with
2479
- * the License. You may obtain a copy of the License at
2480
- * http://www.mozilla.org/MPL/
2481
- *
2482
- * Software distributed under the License is distributed on an "AS IS" basis,
2483
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
2484
- * for the specific language governing rights and limitations under the
2485
- * License.
2486
- *
2487
- * The Original Code is Mozilla Skywriter.
2488
- *
2489
- * The Initial Developer of the Original Code is
2490
- * Mozilla.
2491
- * Portions created by the Initial Developer are Copyright (C) 2009
2492
- * the Initial Developer. All Rights Reserved.
2493
- *
2494
- * Contributor(s):
2495
- * Joe Walker (jwalker@mozilla.com)
2496
- * Patrick Walton (pwalton@mozilla.com)
2497
- * Julian Viereck (jviereck@mozilla.com)
2498
- *
2499
- * Alternatively, the contents of this file may be used under the terms of
2500
- * either the GNU General Public License Version 2 or later (the "GPL"), or
2501
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
2502
- * in which case the provisions of the GPL or the LGPL are applicable instead
2503
- * of those above. If you wish to allow use of your version of this file only
2504
- * under the terms of either the GPL or the LGPL, and not to allow others to
2505
- * use your version of this file under the terms of the MPL, indicate your
2506
- * decision by deleting the provisions above and replace them with the notice
2507
- * and other provisions required by the GPL or the LGPL. If you do not delete
2508
- * the provisions above, a recipient may use your version of this file under
2509
- * the terms of any one of the MPL, the GPL or the LGPL.
2510
- *
2511
- * ***** END LICENSE BLOCK ***** */
2512
- define('pilot/console', ['require', 'exports', 'module' ], function(require, exports, module) {
2513
-
2514
- /**
2515
- * This object represents a "safe console" object that forwards debugging
2516
- * messages appropriately without creating a dependency on Firebug in Firefox.
2517
- */
2518
-
2519
- var noop = function() {};
2520
-
2521
- // These are the functions that are available in Chrome 4/5, Safari 4
2522
- // and Firefox 3.6. Don't add to this list without checking browser support
2523
- var NAMES = [
2524
- "assert", "count", "debug", "dir", "dirxml", "error", "group", "groupEnd",
2525
- "info", "log", "profile", "profileEnd", "time", "timeEnd", "trace", "warn"
2526
- ];
2527
-
2528
- if (typeof(window) === 'undefined') {
2529
- // We're in a web worker. Forward to the main thread so the messages
2530
- // will show up.
2531
- NAMES.forEach(function(name) {
2532
- exports[name] = function() {
2533
- var args = Array.prototype.slice.call(arguments);
2534
- var msg = { op: 'log', method: name, args: args };
2535
- postMessage(JSON.stringify(msg));
2536
- };
2537
- });
2538
- } else {
2539
- // For each of the console functions, copy them if they exist, stub if not
2540
- NAMES.forEach(function(name) {
2541
- if (window.console && window.console[name]) {
2542
- exports[name] = Function.prototype.bind.call(window.console[name], window.console);
2543
- } else {
2544
- exports[name] = noop;
2545
- }
2546
- });
2547
- }
2548
-
2549
- });
2550
- define('pilot/stacktrace', ['require', 'exports', 'module' , 'pilot/useragent', 'pilot/console'], function(require, exports, module) {
2551
-
2552
- var ua = require("pilot/useragent");
2553
- var console = require('pilot/console');
2554
-
2555
- // Changed to suit the specific needs of running within Skywriter
2556
-
2557
- // Domain Public by Eric Wendelin http://eriwen.com/ (2008)
2558
- // Luke Smith http://lucassmith.name/ (2008)
2559
- // Loic Dachary <loic@dachary.org> (2008)
2560
- // Johan Euphrosine <proppy@aminche.com> (2008)
2561
- // Øyvind Sean Kinsey http://kinsey.no/blog
2562
- //
2563
- // Information and discussions
2564
- // http://jspoker.pokersource.info/skin/test-printstacktrace.html
2565
- // http://eriwen.com/javascript/js-stack-trace/
2566
- // http://eriwen.com/javascript/stacktrace-update/
2567
- // http://pastie.org/253058
2568
- // http://browsershots.org/http://jspoker.pokersource.info/skin/test-printstacktrace.html
2569
- //
2570
-
2571
- //
2572
- // guessFunctionNameFromLines comes from firebug
2573
- //
2574
- // Software License Agreement (BSD License)
2575
- //
2576
- // Copyright (c) 2007, Parakey Inc.
2577
- // All rights reserved.
2578
- //
2579
- // Redistribution and use of this software in source and binary forms, with or without modification,
2580
- // are permitted provided that the following conditions are met:
2581
- //
2582
- // * Redistributions of source code must retain the above
2583
- // copyright notice, this list of conditions and the
2584
- // following disclaimer.
2585
- //
2586
- // * Redistributions in binary form must reproduce the above
2587
- // copyright notice, this list of conditions and the
2588
- // following disclaimer in the documentation and/or other
2589
- // materials provided with the distribution.
2590
- //
2591
- // * Neither the name of Parakey Inc. nor the names of its
2592
- // contributors may be used to endorse or promote products
2593
- // derived from this software without specific prior
2594
- // written permission of Parakey Inc.
2595
- //
2596
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
2597
- // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
2598
- // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
2599
- // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2600
- // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2601
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
2602
- // IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
2603
- // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2604
-
2605
-
2606
-
2607
- /**
2608
- * Different browsers create stack traces in different ways.
2609
- * <strike>Feature</strike> Browser detection baby ;).
2610
- */
2611
- var mode = (function() {
2612
-
2613
- // We use SC's browser detection here to avoid the "break on error"
2614
- // functionality provided by Firebug. Firebug tries to do the right
2615
- // thing here and break, but it happens every time you load the page.
2616
- // bug 554105
2617
- if (ua.isGecko) {
2618
- return 'firefox';
2619
- } else if (ua.isOpera) {
2620
- return 'opera';
2621
- } else {
2622
- return 'other';
2623
- }
2624
-
2625
- // SC doesn't do any detection of Chrome at this time.
2626
-
2627
- // this is the original feature detection code that is used as a
2628
- // fallback.
2629
- try {
2630
- (0)();
2631
- } catch (e) {
2632
- if (e.arguments) {
2633
- return 'chrome';
2634
- }
2635
- if (e.stack) {
2636
- return 'firefox';
2637
- }
2638
- if (window.opera && !('stacktrace' in e)) { //Opera 9-
2639
- return 'opera';
2640
- }
2641
- }
2642
- return 'other';
2643
- })();
2644
-
2645
- /**
2646
- *
2647
- */
2648
- function stringifyArguments(args) {
2649
- for (var i = 0; i < args.length; ++i) {
2650
- var argument = args[i];
2651
- if (typeof argument == 'object') {
2652
- args[i] = '#object';
2653
- } else if (typeof argument == 'function') {
2654
- args[i] = '#function';
2655
- } else if (typeof argument == 'string') {
2656
- args[i] = '"' + argument + '"';
2657
- }
2658
- }
2659
- return args.join(',');
2660
- }
2661
-
2662
- /**
2663
- * Extract a stack trace from the format emitted by each browser.
2664
- */
2665
- var decoders = {
2666
- chrome: function(e) {
2667
- var stack = e.stack;
2668
- if (!stack) {
2669
- console.log(e);
2670
- return [];
2671
- }
2672
- return stack.replace(/^.*?\n/, '').
2673
- replace(/^.*?\n/, '').
2674
- replace(/^.*?\n/, '').
2675
- replace(/^[^\(]+?[\n$]/gm, '').
2676
- replace(/^\s+at\s+/gm, '').
2677
- replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@').
2678
- split('\n');
2679
- },
2680
-
2681
- firefox: function(e) {
2682
- var stack = e.stack;
2683
- if (!stack) {
2684
- console.log(e);
2685
- return [];
2686
- }
2687
- // stack = stack.replace(/^.*?\n/, '');
2688
- stack = stack.replace(/(?:\n@:0)?\s+$/m, '');
2689
- stack = stack.replace(/^\(/gm, '{anonymous}(');
2690
- return stack.split('\n');
2691
- },
2692
-
2693
- // Opera 7.x and 8.x only!
2694
- opera: function(e) {
2695
- var lines = e.message.split('\n'), ANON = '{anonymous}',
2696
- lineRE = /Line\s+(\d+).*?script\s+(http\S+)(?:.*?in\s+function\s+(\S+))?/i, i, j, len;
2697
-
2698
- for (i = 4, j = 0, len = lines.length; i < len; i += 2) {
2699
- if (lineRE.test(lines[i])) {
2700
- lines[j++] = (RegExp.$3 ? RegExp.$3 + '()@' + RegExp.$2 + RegExp.$1 : ANON + '()@' + RegExp.$2 + ':' + RegExp.$1) +
2701
- ' -- ' +
2702
- lines[i + 1].replace(/^\s+/, '');
2703
- }
2704
- }
2705
-
2706
- lines.splice(j, lines.length - j);
2707
- return lines;
2708
- },
2709
-
2710
- // Safari, Opera 9+, IE, and others
2711
- other: function(curr) {
2712
- var ANON = '{anonymous}', fnRE = /function\s*([\w\-$]+)?\s*\(/i, stack = [], j = 0, fn, args;
2713
-
2714
- var maxStackSize = 10;
2715
- while (curr && stack.length < maxStackSize) {
2716
- fn = fnRE.test(curr.toString()) ? RegExp.$1 || ANON : ANON;
2717
- args = Array.prototype.slice.call(curr['arguments']);
2718
- stack[j++] = fn + '(' + stringifyArguments(args) + ')';
2719
-
2720
- //Opera bug: if curr.caller does not exist, Opera returns curr (WTF)
2721
- if (curr === curr.caller && window.opera) {
2722
- //TODO: check for same arguments if possible
2723
- break;
2724
- }
2725
- curr = curr.caller;
2726
- }
2727
- return stack;
2728
- }
2729
- };
2730
-
2731
- /**
2732
- *
2733
- */
2734
- function NameGuesser() {
2735
- }
2736
-
2737
- NameGuesser.prototype = {
2738
-
2739
- sourceCache: {},
2740
-
2741
- ajax: function(url) {
2742
- var req = this.createXMLHTTPObject();
2743
- if (!req) {
2744
- return;
2745
- }
2746
- req.open('GET', url, false);
2747
- req.setRequestHeader('User-Agent', 'XMLHTTP/1.0');
2748
- req.send('');
2749
- return req.responseText;
2750
- },
2751
-
2752
- createXMLHTTPObject: function() {
2753
- // Try XHR methods in order and store XHR factory
2754
- var xmlhttp, XMLHttpFactories = [
2755
- function() {
2756
- return new XMLHttpRequest();
2757
- }, function() {
2758
- return new ActiveXObject('Msxml2.XMLHTTP');
2759
- }, function() {
2760
- return new ActiveXObject('Msxml3.XMLHTTP');
2761
- }, function() {
2762
- return new ActiveXObject('Microsoft.XMLHTTP');
2763
- }
2764
- ];
2765
- for (var i = 0; i < XMLHttpFactories.length; i++) {
2766
- try {
2767
- xmlhttp = XMLHttpFactories[i]();
2768
- // Use memoization to cache the factory
2769
- this.createXMLHTTPObject = XMLHttpFactories[i];
2770
- return xmlhttp;
2771
- } catch (e) {}
2772
- }
2773
- },
2774
-
2775
- getSource: function(url) {
2776
- if (!(url in this.sourceCache)) {
2777
- this.sourceCache[url] = this.ajax(url).split('\n');
2778
- }
2779
- return this.sourceCache[url];
2780
- },
2781
-
2782
- guessFunctions: function(stack) {
2783
- for (var i = 0; i < stack.length; ++i) {
2784
- var reStack = /{anonymous}\(.*\)@(\w+:\/\/([-\w\.]+)+(:\d+)?[^:]+):(\d+):?(\d+)?/;
2785
- var frame = stack[i], m = reStack.exec(frame);
2786
- if (m) {
2787
- var file = m[1], lineno = m[4]; //m[7] is character position in Chrome
2788
- if (file && lineno) {
2789
- var functionName = this.guessFunctionName(file, lineno);
2790
- stack[i] = frame.replace('{anonymous}', functionName);
2791
- }
2792
- }
2793
- }
2794
- return stack;
2795
- },
2796
-
2797
- guessFunctionName: function(url, lineNo) {
2798
- try {
2799
- return this.guessFunctionNameFromLines(lineNo, this.getSource(url));
2800
- } catch (e) {
2801
- return 'getSource failed with url: ' + url + ', exception: ' + e.toString();
2802
- }
2803
- },
2804
-
2805
- guessFunctionNameFromLines: function(lineNo, source) {
2806
- var reFunctionArgNames = /function ([^(]*)\(([^)]*)\)/;
2807
- var reGuessFunction = /['"]?([0-9A-Za-z_]+)['"]?\s*[:=]\s*(function|eval|new Function)/;
2808
- // Walk backwards from the first line in the function until we find the line which
2809
- // matches the pattern above, which is the function definition
2810
- var line = '', maxLines = 10;
2811
- for (var i = 0; i < maxLines; ++i) {
2812
- line = source[lineNo - i] + line;
2813
- if (line !== undefined) {
2814
- var m = reGuessFunction.exec(line);
2815
- if (m) {
2816
- return m[1];
2817
- }
2818
- else {
2819
- m = reFunctionArgNames.exec(line);
2820
- }
2821
- if (m && m[1]) {
2822
- return m[1];
2823
- }
2824
- }
2825
- }
2826
- return '(?)';
2827
- }
2828
- };
2829
-
2830
- var guesser = new NameGuesser();
2831
-
2832
- var frameIgnorePatterns = [
2833
- /http:\/\/localhost:4020\/sproutcore.js:/
2834
- ];
2835
-
2836
- exports.ignoreFramesMatching = function(regex) {
2837
- frameIgnorePatterns.push(regex);
2838
- };
2839
-
2840
- /**
2841
- * Create a stack trace from an exception
2842
- * @param ex {Error} The error to create a stacktrace from (optional)
2843
- * @param guess {Boolean} If we should try to resolve the names of anonymous functions
2844
- */
2845
- exports.Trace = function Trace(ex, guess) {
2846
- this._ex = ex;
2847
- this._stack = decoders[mode](ex);
2848
-
2849
- if (guess) {
2850
- this._stack = guesser.guessFunctions(this._stack);
2851
- }
2852
- };
2853
-
2854
- /**
2855
- * Log to the console a number of lines (default all of them)
2856
- * @param lines {number} Maximum number of lines to wrote to console
2857
- */
2858
- exports.Trace.prototype.log = function(lines) {
2859
- if (lines <= 0) {
2860
- // You aren't going to have more lines in your stack trace than this
2861
- // and it still fits in a 32bit integer
2862
- lines = 999999999;
2863
- }
2864
-
2865
- var printed = 0;
2866
- for (var i = 0; i < this._stack.length && printed < lines; i++) {
2867
- var frame = this._stack[i];
2868
- var display = true;
2869
- frameIgnorePatterns.forEach(function(regex) {
2870
- if (regex.test(frame)) {
2871
- display = false;
2872
- }
2873
- });
2874
- if (display) {
2875
- console.debug(frame);
2876
- printed++;
2877
- }
2878
- }
2879
- };
2880
-
2881
- });
2882
- /* ***** BEGIN LICENSE BLOCK *****
2883
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
2884
- *
2885
- * The contents of this file are subject to the Mozilla Public License Version
2886
- * 1.1 (the "License"); you may not use this file except in compliance with
2887
- * the License. You may obtain a copy of the License at
2888
- * http://www.mozilla.org/MPL/
2889
- *
2890
- * Software distributed under the License is distributed on an "AS IS" basis,
2891
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
2892
- * for the specific language governing rights and limitations under the
2893
- * License.
2894
- *
2895
- * The Original Code is Ajax.org Code Editor (ACE).
2896
- *
2897
- * The Initial Developer of the Original Code is
2898
- * Ajax.org B.V.
2899
- * Portions created by the Initial Developer are Copyright (C) 2010
2900
- * the Initial Developer. All Rights Reserved.
2901
- *
2902
- * Contributor(s):
2903
- * Fabian Jakobs <fabian AT ajax DOT org>
2904
- *
2905
- * Alternatively, the contents of this file may be used under the terms of
2906
- * either the GNU General Public License Version 2 or later (the "GPL"), or
2907
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
2908
- * in which case the provisions of the GPL or the LGPL are applicable instead
2909
- * of those above. If you wish to allow use of your version of this file only
2910
- * under the terms of either the GPL or the LGPL, and not to allow others to
2911
- * use your version of this file under the terms of the MPL, indicate your
2912
- * decision by deleting the provisions above and replace them with the notice
2913
- * and other provisions required by the GPL or the LGPL. If you do not delete
2914
- * the provisions above, a recipient may use your version of this file under
2915
- * the terms of any one of the MPL, the GPL or the LGPL.
2916
- *
2917
- * ***** END LICENSE BLOCK ***** */
2918
-
2919
- define('pilot/useragent', ['require', 'exports', 'module' ], function(require, exports, module) {
2920
-
2921
- var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase();
2922
- var ua = navigator.userAgent;
2923
- var av = navigator.appVersion;
2924
-
2925
- /** Is the user using a browser that identifies itself as Windows */
2926
- exports.isWin = (os == "win");
2927
-
2928
- /** Is the user using a browser that identifies itself as Mac OS */
2929
- exports.isMac = (os == "mac");
2930
-
2931
- /** Is the user using a browser that identifies itself as Linux */
2932
- exports.isLinux = (os == "linux");
2933
-
2934
- exports.isIE = ! + "\v1";
2935
-
2936
- /** Is this Firefox or related? */
2937
- exports.isGecko = exports.isMozilla = window.controllers && window.navigator.product === "Gecko";
2938
-
2939
- /** oldGecko == rev < 2.0 **/
2940
- exports.isOldGecko = exports.isGecko && /rv\:1/.test(navigator.userAgent);
2941
-
2942
- /** Is this Opera */
2943
- exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]";
2944
-
2945
- /** Is the user using a browser that identifies itself as WebKit */
2946
- exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined;
2947
-
2948
- exports.isChrome = parseFloat(ua.split(" Chrome/")[1]) || undefined;
2949
-
2950
- exports.isAIR = ua.indexOf("AdobeAIR") >= 0;
2951
-
2952
- exports.isIPad = ua.indexOf("iPad") >= 0;
2953
-
2954
- /**
2955
- * I hate doing this, but we need some way to determine if the user is on a Mac
2956
- * The reason is that users have different expectations of their key combinations.
2957
- *
2958
- * Take copy as an example, Mac people expect to use CMD or APPLE + C
2959
- * Windows folks expect to use CTRL + C
2960
- */
2961
- exports.OS = {
2962
- LINUX: 'LINUX',
2963
- MAC: 'MAC',
2964
- WINDOWS: 'WINDOWS'
2965
- };
2966
-
2967
- /**
2968
- * Return an exports.OS constant
2969
- */
2970
- exports.getOS = function() {
2971
- if (exports.isMac) {
2972
- return exports.OS['MAC'];
2973
- } else if (exports.isLinux) {
2974
- return exports.OS['LINUX'];
2975
- } else {
2976
- return exports.OS['WINDOWS'];
2977
- }
2978
- };
2979
-
2980
- });
2981
- /* ***** BEGIN LICENSE BLOCK *****
2982
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
2983
- *
2984
- * The contents of this file are subject to the Mozilla Public License Version
2985
- * 1.1 (the "License"); you may not use this file except in compliance with
2986
- * the License. You may obtain a copy of the License at
2987
- * http://www.mozilla.org/MPL/
2988
- *
2989
- * Software distributed under the License is distributed on an "AS IS" basis,
2990
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
2991
- * for the specific language governing rights and limitations under the
2992
- * License.
2993
- *
2994
- * The Original Code is Ajax.org Code Editor (ACE).
2995
- *
2996
- * The Initial Developer of the Original Code is
2997
- * Ajax.org B.V.
2998
- * Portions created by the Initial Developer are Copyright (C) 2010
2999
- * the Initial Developer. All Rights Reserved.
3000
- *
3001
- * Contributor(s):
3002
- * Fabian Jakobs <fabian AT ajax DOT org>
3003
- *
3004
- * Alternatively, the contents of this file may be used under the terms of
3005
- * either the GNU General Public License Version 2 or later (the "GPL"), or
3006
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
3007
- * in which case the provisions of the GPL or the LGPL are applicable instead
3008
- * of those above. If you wish to allow use of your version of this file only
3009
- * under the terms of either the GPL or the LGPL, and not to allow others to
3010
- * use your version of this file under the terms of the MPL, indicate your
3011
- * decision by deleting the provisions above and replace them with the notice
3012
- * and other provisions required by the GPL or the LGPL. If you do not delete
3013
- * the provisions above, a recipient may use your version of this file under
3014
- * the terms of any one of the MPL, the GPL or the LGPL.
3015
- *
3016
- * ***** END LICENSE BLOCK ***** */
3017
-
3018
- define('pilot/oop', ['require', 'exports', 'module' ], function(require, exports, module) {
3019
-
3020
- exports.inherits = (function() {
3021
- var tempCtor = function() {};
3022
- return function(ctor, superCtor) {
3023
- tempCtor.prototype = superCtor.prototype;
3024
- ctor.super_ = superCtor.prototype;
3025
- ctor.prototype = new tempCtor();
3026
- ctor.prototype.constructor = ctor;
3027
- }
3028
- }());
3029
-
3030
- exports.mixin = function(obj, mixin) {
3031
- for (var key in mixin) {
3032
- obj[key] = mixin[key];
3033
- }
3034
- };
3035
-
3036
- exports.implement = function(proto, mixin) {
3037
- exports.mixin(proto, mixin);
3038
- };
3039
-
3040
- });
3041
- /*! @license
3042
- ==========================================================================
3043
- SproutCore -- JavaScript Application Framework
3044
- copyright 2006-2009, Sprout Systems Inc., Apple Inc. and contributors.
3045
-
3046
- Permission is hereby granted, free of charge, to any person obtaining a
3047
- copy of this software and associated documentation files (the "Software"),
3048
- to deal in the Software without restriction, including without limitation
3049
- the rights to use, copy, modify, merge, publish, distribute, sublicense,
3050
- and/or sell copies of the Software, and to permit persons to whom the
3051
- Software is furnished to do so, subject to the following conditions:
3052
-
3053
- The above copyright notice and this permission notice shall be included in
3054
- all copies or substantial portions of the Software.
3055
-
3056
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3057
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3058
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3059
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3060
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
3061
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
3062
- DEALINGS IN THE SOFTWARE.
3063
-
3064
- SproutCore and the SproutCore logo are trademarks of Sprout Systems, Inc.
3065
-
3066
- For more information about SproutCore, visit http://www.sproutcore.com
3067
-
3068
-
3069
- ==========================================================================
3070
- @license */
3071
-
3072
- // Most of the following code is taken from SproutCore with a few changes.
3073
-
3074
- define('pilot/keys', ['require', 'exports', 'module' , 'pilot/oop'], function(require, exports, module) {
3075
-
3076
- var oop = require("pilot/oop");
3077
-
3078
- /**
3079
- * Helper functions and hashes for key handling.
3080
- */
3081
- var Keys = (function() {
3082
- var ret = {
3083
- MODIFIER_KEYS: {
3084
- 16: 'Shift', 17: 'Ctrl', 18: 'Alt', 224: 'Meta'
3085
- },
3086
-
3087
- KEY_MODS: {
3088
- "ctrl": 1, "alt": 2, "option" : 2,
3089
- "shift": 4, "meta": 8, "command": 8
3090
- },
3091
-
3092
- FUNCTION_KEYS : {
3093
- 8 : "Backspace",
3094
- 9 : "Tab",
3095
- 13 : "Return",
3096
- 19 : "Pause",
3097
- 27 : "Esc",
3098
- 32 : "Space",
3099
- 33 : "PageUp",
3100
- 34 : "PageDown",
3101
- 35 : "End",
3102
- 36 : "Home",
3103
- 37 : "Left",
3104
- 38 : "Up",
3105
- 39 : "Right",
3106
- 40 : "Down",
3107
- 44 : "Print",
3108
- 45 : "Insert",
3109
- 46 : "Delete",
3110
- 112: "F1",
3111
- 113: "F2",
3112
- 114: "F3",
3113
- 115: "F4",
3114
- 116: "F5",
3115
- 117: "F6",
3116
- 118: "F7",
3117
- 119: "F8",
3118
- 120: "F9",
3119
- 121: "F10",
3120
- 122: "F11",
3121
- 123: "F12",
3122
- 144: "Numlock",
3123
- 145: "Scrolllock"
3124
- },
3125
-
3126
- PRINTABLE_KEYS: {
3127
- 32: ' ', 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5',
3128
- 54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a',
3129
- 66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h',
3130
- 73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o',
3131
- 80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v',
3132
- 87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.',
3133
- 188: ',', 190: '.', 191: '/', 192: '`', 219: '[', 220: '\\',
3134
- 221: ']', 222: '\"'
3135
- }
3136
- };
3137
-
3138
- // A reverse map of FUNCTION_KEYS
3139
- for (i in ret.FUNCTION_KEYS) {
3140
- var name = ret.FUNCTION_KEYS[i].toUpperCase();
3141
- ret[name] = parseInt(i, 10);
3142
- }
3143
-
3144
- // Add the MODIFIER_KEYS, FUNCTION_KEYS and PRINTABLE_KEYS to the KEY
3145
- // variables as well.
3146
- oop.mixin(ret, ret.MODIFIER_KEYS);
3147
- oop.mixin(ret, ret.PRINTABLE_KEYS);
3148
- oop.mixin(ret, ret.FUNCTION_KEYS);
3149
-
3150
- return ret;
3151
- })();
3152
- oop.mixin(exports, Keys);
3153
-
3154
- exports.keyCodeToString = function(keyCode) {
3155
- return (Keys[keyCode] || String.fromCharCode(keyCode)).toLowerCase();
3156
- }
3157
-
3158
- });
3159
- /* vim:ts=4:sts=4:sw=4:
3160
- * ***** BEGIN LICENSE BLOCK *****
3161
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3162
- *
3163
- * The contents of this file are subject to the Mozilla Public License Version
3164
- * 1.1 (the "License"); you may not use this file except in compliance with
3165
- * the License. You may obtain a copy of the License at
3166
- * http://www.mozilla.org/MPL/
3167
- *
3168
- * Software distributed under the License is distributed on an "AS IS" basis,
3169
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
3170
- * for the specific language governing rights and limitations under the
3171
- * License.
3172
- *
3173
- * The Original Code is Ajax.org Code Editor (ACE).
3174
- *
3175
- * The Initial Developer of the Original Code is
3176
- * Ajax.org B.V.
3177
- * Portions created by the Initial Developer are Copyright (C) 2010
3178
- * the Initial Developer. All Rights Reserved.
3179
- *
3180
- * Contributor(s):
3181
- * Fabian Jakobs <fabian AT ajax DOT org>
3182
- * Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
3183
- *
3184
- * Alternatively, the contents of this file may be used under the terms of
3185
- * either the GNU General Public License Version 2 or later (the "GPL"), or
3186
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
3187
- * in which case the provisions of the GPL or the LGPL are applicable instead
3188
- * of those above. If you wish to allow use of your version of this file only
3189
- * under the terms of either the GPL or the LGPL, and not to allow others to
3190
- * use your version of this file under the terms of the MPL, indicate your
3191
- * decision by deleting the provisions above and replace them with the notice
3192
- * and other provisions required by the GPL or the LGPL. If you do not delete
3193
- * the provisions above, a recipient may use your version of this file under
3194
- * the terms of any one of the MPL, the GPL or the LGPL.
3195
- *
3196
- * ***** END LICENSE BLOCK ***** */
3197
-
3198
- define('pilot/event_emitter', ['require', 'exports', 'module' ], function(require, exports, module) {
3199
-
3200
- var EventEmitter = {};
3201
-
3202
- EventEmitter._emit =
3203
- EventEmitter._dispatchEvent = function(eventName, e) {
3204
- this._eventRegistry = this._eventRegistry || {};
3205
-
3206
- var listeners = this._eventRegistry[eventName];
3207
- if (!listeners || !listeners.length) return;
3208
-
3209
- var e = e || {};
3210
- e.type = eventName;
3211
-
3212
- for (var i=0; i<listeners.length; i++) {
3213
- listeners[i](e);
3214
- }
3215
- };
3216
-
3217
- EventEmitter.on =
3218
- EventEmitter.addEventListener = function(eventName, callback) {
3219
- this._eventRegistry = this._eventRegistry || {};
3220
-
3221
- var listeners = this._eventRegistry[eventName];
3222
- if (!listeners) {
3223
- var listeners = this._eventRegistry[eventName] = [];
3224
- }
3225
- if (listeners.indexOf(callback) == -1) {
3226
- listeners.push(callback);
3227
- }
3228
- };
3229
-
3230
- EventEmitter.removeListener =
3231
- EventEmitter.removeEventListener = function(eventName, callback) {
3232
- this._eventRegistry = this._eventRegistry || {};
3233
-
3234
- var listeners = this._eventRegistry[eventName];
3235
- if (!listeners) {
3236
- return;
3237
- }
3238
- var index = listeners.indexOf(callback);
3239
- if (index !== -1) {
3240
- listeners.splice(index, 1);
3241
- }
3242
- };
3243
-
3244
- EventEmitter.removeAllListeners = function(eventName) {
3245
- if (this._eventRegistry) this._eventRegistry[eventName] = [];
3246
- }
3247
-
3248
- exports.EventEmitter = EventEmitter;
3249
-
3250
- });
3251
- /* ***** BEGIN LICENSE BLOCK *****
3252
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3253
- *
3254
- * The contents of this file are subject to the Mozilla Public License Version
3255
- * 1.1 (the "License"); you may not use this file except in compliance with
3256
- * the License. You may obtain a copy of the License at
3257
- * http://www.mozilla.org/MPL/
3258
- *
3259
- * Software distributed under the License is distributed on an "AS IS" basis,
3260
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
3261
- * for the specific language governing rights and limitations under the
3262
- * License.
3263
- *
3264
- * The Original Code is Skywriter.
3265
- *
3266
- * The Initial Developer of the Original Code is
3267
- * Mozilla.
3268
- * Portions created by the Initial Developer are Copyright (C) 2009
3269
- * the Initial Developer. All Rights Reserved.
3270
- *
3271
- * Contributor(s):
3272
- * Joe Walker (jwalker@mozilla.com)
3273
- *
3274
- * Alternatively, the contents of this file may be used under the terms of
3275
- * either the GNU General Public License Version 2 or later (the "GPL"), or
3276
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
3277
- * in which case the provisions of the GPL or the LGPL are applicable instead
3278
- * of those above. If you wish to allow use of your version of this file only
3279
- * under the terms of either the GPL or the LGPL, and not to allow others to
3280
- * use your version of this file under the terms of the MPL, indicate your
3281
- * decision by deleting the provisions above and replace them with the notice
3282
- * and other provisions required by the GPL or the LGPL. If you do not delete
3283
- * the provisions above, a recipient may use your version of this file under
3284
- * the terms of any one of the MPL, the GPL or the LGPL.
3285
- *
3286
- * ***** END LICENSE BLOCK ***** */
3287
-
3288
- define('pilot/typecheck', ['require', 'exports', 'module' ], function(require, exports, module) {
3289
-
3290
- var objectToString = Object.prototype.toString;
3291
-
3292
- /**
3293
- * Return true if it is a String
3294
- */
3295
- exports.isString = function(it) {
3296
- return it && objectToString.call(it) === "[object String]";
3297
- };
3298
-
3299
- /**
3300
- * Returns true if it is a Boolean.
3301
- */
3302
- exports.isBoolean = function(it) {
3303
- return it && objectToString.call(it) === "[object Boolean]";
3304
- };
3305
-
3306
- /**
3307
- * Returns true if it is a Number.
3308
- */
3309
- exports.isNumber = function(it) {
3310
- return it && objectToString.call(it) === "[object Number]" && isFinite(it);
3311
- };
3312
-
3313
- /**
3314
- * Hack copied from dojo.
3315
- */
3316
- exports.isObject = function(it) {
3317
- return it !== undefined &&
3318
- (it === null || typeof it == "object" ||
3319
- Array.isArray(it) || exports.isFunction(it));
3320
- };
3321
-
3322
- /**
3323
- * Is the passed object a function?
3324
- * From dojo.isFunction()
3325
- */
3326
- exports.isFunction = function(it) {
3327
- return it && objectToString.call(it) === "[object Function]";
3328
- };
3329
-
3330
- });/* ***** BEGIN LICENSE BLOCK *****
3331
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3332
- *
3333
- * The contents of this file are subject to the Mozilla Public License Version
3334
- * 1.1 (the "License"); you may not use this file except in compliance with
3335
- * the License. You may obtain a copy of the License at
3336
- * http://www.mozilla.org/MPL/
3337
- *
3338
- * Software distributed under the License is distributed on an "AS IS" basis,
3339
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
3340
- * for the specific language governing rights and limitations under the
3341
- * License.
3342
- *
3343
- * The Original Code is Mozilla Skywriter.
3344
- *
3345
- * The Initial Developer of the Original Code is
3346
- * Mozilla.
3347
- * Portions created by the Initial Developer are Copyright (C) 2009
3348
- * the Initial Developer. All Rights Reserved.
3349
- *
3350
- * Contributor(s):
3351
- * Julian Viereck (jviereck@mozilla.com)
3352
- *
3353
- * Alternatively, the contents of this file may be used under the terms of
3354
- * either the GNU General Public License Version 2 or later (the "GPL"), or
3355
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
3356
- * in which case the provisions of the GPL or the LGPL are applicable instead
3357
- * of those above. If you wish to allow use of your version of this file only
3358
- * under the terms of either the GPL or the LGPL, and not to allow others to
3359
- * use your version of this file under the terms of the MPL, indicate your
3360
- * decision by deleting the provisions above and replace them with the notice
3361
- * and other provisions required by the GPL or the LGPL. If you do not delete
3362
- * the provisions above, a recipient may use your version of this file under
3363
- * the terms of any one of the MPL, the GPL or the LGPL.
3364
- *
3365
- * ***** END LICENSE BLOCK ***** */
3366
-
3367
- define('pilot/catalog', ['require', 'exports', 'module' ], function(require, exports, module) {
3368
-
3369
-
3370
- var extensionSpecs = {};
3371
-
3372
- exports.addExtensionSpec = function(extensionSpec) {
3373
- extensionSpecs[extensionSpec.name] = extensionSpec;
3374
- };
3375
-
3376
- exports.removeExtensionSpec = function(extensionSpec) {
3377
- if (typeof extensionSpec === "string") {
3378
- delete extensionSpecs[extensionSpec];
3379
- }
3380
- else {
3381
- delete extensionSpecs[extensionSpec.name];
3382
- }
3383
- };
3384
-
3385
- exports.getExtensionSpec = function(name) {
3386
- return extensionSpecs[name];
3387
- };
3388
-
3389
- exports.getExtensionSpecs = function() {
3390
- return Object.keys(extensionSpecs);
3391
- };
3392
-
3393
-
3394
- });
3395
- /* ***** BEGIN LICENSE BLOCK *****
3396
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3397
- *
3398
- * The contents of this file are subject to the Mozilla Public License Version
3399
- * 1.1 (the "License"); you may not use this file except in compliance with
3400
- * the License. You may obtain a copy of the License at
3401
- * http://www.mozilla.org/MPL/
3402
- *
3403
- * Software distributed under the License is distributed on an "AS IS" basis,
3404
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
3405
- * for the specific language governing rights and limitations under the
3406
- * License.
3407
- *
3408
- * The Original Code is Ajax.org Code Editor (ACE).
3409
- *
3410
- * The Initial Developer of the Original Code is
3411
- * Ajax.org B.V.
3412
- * Portions created by the Initial Developer are Copyright (C) 2010
3413
- * the Initial Developer. All Rights Reserved.
3414
- *
3415
- * Contributor(s):
3416
- * Fabian Jakobs <fabian AT ajax DOT org>
3417
- *
3418
- * Alternatively, the contents of this file may be used under the terms of
3419
- * either the GNU General Public License Version 2 or later (the "GPL"), or
3420
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
3421
- * in which case the provisions of the GPL or the LGPL are applicable instead
3422
- * of those above. If you wish to allow use of your version of this file only
3423
- * under the terms of either the GPL or the LGPL, and not to allow others to
3424
- * use your version of this file under the terms of the MPL, indicate your
3425
- * decision by deleting the provisions above and replace them with the notice
3426
- * and other provisions required by the GPL or the LGPL. If you do not delete
3427
- * the provisions above, a recipient may use your version of this file under
3428
- * the terms of any one of the MPL, the GPL or the LGPL.
3429
- *
3430
- * ***** END LICENSE BLOCK ***** */
3431
-
3432
- define('pilot/lang', ['require', 'exports', 'module' ], function(require, exports, module) {
3433
-
3434
- exports.stringReverse = function(string) {
3435
- return string.split("").reverse().join("");
3436
- };
3437
-
3438
- exports.stringRepeat = function (string, count) {
3439
- return new Array(count + 1).join(string);
3440
- };
3441
-
3442
- var trimBeginRegexp = /^\s\s*/;
3443
- var trimEndRegexp = /\s\s*$/;
3444
-
3445
- exports.stringTrimLeft = function (string) {
3446
- return string.replace(trimBeginRegexp, '')
3447
- };
3448
-
3449
- exports.stringTrimRight = function (string) {
3450
- return string.replace(trimEndRegexp, '');
3451
- };
3452
-
3453
- exports.copyObject = function(obj) {
3454
- var copy = {};
3455
- for (var key in obj) {
3456
- copy[key] = obj[key];
3457
- }
3458
- return copy;
3459
- };
3460
-
3461
- exports.copyArray = function(array){
3462
- var copy = [];
3463
- for (i=0, l=array.length; i<l; i++) {
3464
- if (array[i] && typeof array[i] == "object")
3465
- copy[i] = this.copyObject( array[i] );
3466
- else
3467
- copy[i] = array[i]
3468
- }
3469
- return copy;
3470
- };
3471
-
3472
- exports.deepCopy = function (obj) {
3473
- if (typeof obj != "object") {
3474
- return obj;
3475
- }
3476
-
3477
- var copy = obj.constructor();
3478
- for (var key in obj) {
3479
- if (typeof obj[key] == "object") {
3480
- copy[key] = this.deepCopy(obj[key]);
3481
- } else {
3482
- copy[key] = obj[key];
3483
- }
3484
- }
3485
- return copy;
3486
- }
3487
-
3488
- exports.arrayToMap = function(arr) {
3489
- var map = {};
3490
- for (var i=0; i<arr.length; i++) {
3491
- map[arr[i]] = 1;
3492
- }
3493
- return map;
3494
-
3495
- };
3496
-
3497
- /**
3498
- * splice out of 'array' anything that === 'value'
3499
- */
3500
- exports.arrayRemove = function(array, value) {
3501
- for (var i = 0; i <= array.length; i++) {
3502
- if (value === array[i]) {
3503
- array.splice(i, 1);
3504
- }
3505
- }
3506
- };
3507
-
3508
- exports.escapeRegExp = function(str) {
3509
- return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
3510
- };
3511
-
3512
- exports.deferredCall = function(fcn) {
3513
-
3514
- var timer = null;
3515
- var callback = function() {
3516
- timer = null;
3517
- fcn();
3518
- };
3519
-
3520
- var deferred = function(timeout) {
3521
- if (!timer) {
3522
- timer = setTimeout(callback, timeout || 0);
3523
- }
3524
- return deferred;
3525
- }
3526
-
3527
- deferred.schedule = deferred;
3528
-
3529
- deferred.call = function() {
3530
- this.cancel();
3531
- fcn();
3532
- return deferred;
3533
- };
3534
-
3535
- deferred.cancel = function() {
3536
- clearTimeout(timer);
3537
- timer = null;
3538
- return deferred;
3539
- };
3540
-
3541
- return deferred;
3542
- };
3543
-
3544
- });
3545
- /* ***** BEGIN LICENSE BLOCK *****
3546
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3547
- *
3548
- * The contents of this file are subject to the Mozilla Public License Version
3549
- * 1.1 (the "License"); you may not use this file except in compliance with
3550
- * the License. You may obtain a copy of the License at
3551
- * http://www.mozilla.org/MPL/
3552
- *
3553
- * Software distributed under the License is distributed on an "AS IS" basis,
3554
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
3555
- * for the specific language governing rights and limitations under the
3556
- * License.
3557
- *
3558
- * The Original Code is Mozilla Skywriter.
3559
- *
3560
- * The Initial Developer of the Original Code is
3561
- * Mozilla.
3562
- * Portions created by the Initial Developer are Copyright (C) 2009
3563
- * the Initial Developer. All Rights Reserved.
3564
- *
3565
- * Contributor(s):
3566
- * Joe Walker (jwalker@mozilla.com)
3567
- * Kevin Dangoor (kdangoor@mozilla.com)
3568
- *
3569
- * Alternatively, the contents of this file may be used under the terms of
3570
- * either the GNU General Public License Version 2 or later (the "GPL"), or
3571
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
3572
- * in which case the provisions of the GPL or the LGPL are applicable instead
3573
- * of those above. If you wish to allow use of your version of this file only
3574
- * under the terms of either the GPL or the LGPL, and not to allow others to
3575
- * use your version of this file under the terms of the MPL, indicate your
3576
- * decision by deleting the provisions above and replace them with the notice
3577
- * and other provisions required by the GPL or the LGPL. If you do not delete
3578
- * the provisions above, a recipient may use your version of this file under
3579
- * the terms of any one of the MPL, the GPL or the LGPL.
3580
- *
3581
- * ***** END LICENSE BLOCK ***** */
3582
-
3583
- define('pilot/types/settings', ['require', 'exports', 'module' , 'pilot/types/basic', 'pilot/types', 'pilot/settings'], function(require, exports, module) {
3584
-
3585
- var SelectionType = require('pilot/types/basic').SelectionType;
3586
- var DeferredType = require('pilot/types/basic').DeferredType;
3587
- var types = require('pilot/types');
3588
- var settings = require('pilot/settings').settings;
3589
-
3590
-
3591
- /**
3592
- * EVIL: This relies on us using settingValue in the same event as setting
3593
- * The alternative is to have some central place where we store the current
3594
- * command line, but this might be a lesser evil for now.
3595
- */
3596
- var lastSetting;
3597
-
3598
- /**
3599
- * Select from the available settings
3600
- */
3601
- var setting = new SelectionType({
3602
- name: 'setting',
3603
- data: function() {
3604
- return env.settings.getSettingNames();
3605
- },
3606
- stringify: function(setting) {
3607
- lastSetting = setting;
3608
- return setting.name;
3609
- },
3610
- fromString: function(str) {
3611
- lastSetting = settings.getSetting(str);
3612
- return lastSetting;
3613
- },
3614
- noMatch: function() {
3615
- lastSetting = null;
3616
- }
3617
- });
3618
-
3619
- /**
3620
- * Something of a hack to allow the set command to give a clearer definition
3621
- * of the type to the command line.
3622
- */
3623
- var settingValue = new DeferredType({
3624
- name: 'settingValue',
3625
- defer: function() {
3626
- if (lastSetting) {
3627
- return lastSetting.type;
3628
- }
3629
- else {
3630
- return types.getType('text');
3631
- }
3632
- },
3633
- /**
3634
- * Promote the current value in any list of predictions, and add it if
3635
- * there are none.
3636
- */
3637
- getDefault: function() {
3638
- var conversion = this.parse('');
3639
- if (lastSetting) {
3640
- var current = lastSetting.get();
3641
- if (conversion.predictions.length === 0) {
3642
- conversion.predictions.push(current);
3643
- }
3644
- else {
3645
- // Remove current from predictions
3646
- var removed = false;
3647
- while (true) {
3648
- var index = conversion.predictions.indexOf(current);
3649
- if (index === -1) {
3650
- break;
3651
- }
3652
- conversion.predictions.splice(index, 1);
3653
- removed = true;
3654
- }
3655
- // If the current value wasn't something we would predict, leave it
3656
- if (removed) {
3657
- conversion.predictions.push(current);
3658
- }
3659
- }
3660
- }
3661
- return conversion;
3662
- }
3663
- });
3664
-
3665
- var env;
3666
-
3667
- /**
3668
- * Registration and de-registration.
3669
- */
3670
- exports.startup = function(data, reason) {
3671
- // TODO: this is probably all kinds of evil, but we need something working
3672
- env = data.env;
3673
- types.registerType(setting);
3674
- types.registerType(settingValue);
3675
- };
3676
-
3677
- exports.shutdown = function(data, reason) {
3678
- types.unregisterType(setting);
3679
- types.unregisterType(settingValue);
3680
- };
3681
-
3682
-
3683
- });
3684
- /* vim:ts=4:sts=4:sw=4:
3685
- * ***** BEGIN LICENSE BLOCK *****
3686
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3687
- *
3688
- * The contents of this file are subject to the Mozilla Public License Version
3689
- * 1.1 (the "License"); you may not use this file except in compliance with
3690
- * the License. You may obtain a copy of the License at
3691
- * http://www.mozilla.org/MPL/
3692
- *
3693
- * Software distributed under the License is distributed on an "AS IS" basis,
3694
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
3695
- * for the specific language governing rights and limitations under the
3696
- * License.
3697
- *
3698
- * The Original Code is Mozilla Skywriter.
3699
- *
3700
- * The Initial Developer of the Original Code is
3701
- * Mozilla.
3702
- * Portions created by the Initial Developer are Copyright (C) 2009
3703
- * the Initial Developer. All Rights Reserved.
3704
- *
3705
- * Contributor(s):
3706
- * Joe Walker (jwalker@mozilla.com)
3707
- * Julian Viereck (jviereck@mozilla.com)
3708
- * Kevin Dangoor (kdangoor@mozilla.com)
3709
- * Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
3710
- *
3711
- * Alternatively, the contents of this file may be used under the terms of
3712
- * either the GNU General Public License Version 2 or later (the "GPL"), or
3713
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
3714
- * in which case the provisions of the GPL or the LGPL are applicable instead
3715
- * of those above. If you wish to allow use of your version of this file only
3716
- * under the terms of either the GPL or the LGPL, and not to allow others to
3717
- * use your version of this file under the terms of the MPL, indicate your
3718
- * decision by deleting the provisions above and replace them with the notice
3719
- * and other provisions required by the GPL or the LGPL. If you do not delete
3720
- * the provisions above, a recipient may use your version of this file under
3721
- * the terms of any one of the MPL, the GPL or the LGPL.
3722
- *
3723
- * ***** END LICENSE BLOCK ***** */
3724
-
3725
- define('pilot/settings', ['require', 'exports', 'module' , 'pilot/console', 'pilot/oop', 'pilot/types', 'pilot/event_emitter', 'pilot/catalog'], function(require, exports, module) {
3726
-
3727
- /**
3728
- * This plug-in manages settings.
3729
- */
3730
-
3731
- var console = require('pilot/console');
3732
- var oop = require('pilot/oop');
3733
- var types = require('pilot/types');
3734
- var EventEmitter = require('pilot/event_emitter').EventEmitter;
3735
- var catalog = require('pilot/catalog');
3736
-
3737
- var settingExtensionSpec = {
3738
- name: 'setting',
3739
- description: 'A setting is something that the application offers as a ' +
3740
- 'way to customize how it works',
3741
- register: 'env.settings.addSetting',
3742
- indexOn: 'name'
3743
- };
3744
-
3745
- exports.startup = function(data, reason) {
3746
- catalog.addExtensionSpec(settingExtensionSpec);
3747
- };
3748
-
3749
- exports.shutdown = function(data, reason) {
3750
- catalog.removeExtensionSpec(settingExtensionSpec);
3751
- };
3752
-
3753
-
3754
- /**
3755
- * Create a new setting.
3756
- * @param settingSpec An object literal that looks like this:
3757
- * {
3758
- * name: 'thing',
3759
- * description: 'Thing is an example setting',
3760
- * type: 'string',
3761
- * defaultValue: 'something'
3762
- * }
3763
- */
3764
- function Setting(settingSpec, settings) {
3765
- this._settings = settings;
3766
-
3767
- Object.keys(settingSpec).forEach(function(key) {
3768
- this[key] = settingSpec[key];
3769
- }, this);
3770
-
3771
- this.type = types.getType(this.type);
3772
- if (this.type == null) {
3773
- throw new Error('In ' + this.name +
3774
- ': can\'t find type for: ' + JSON.stringify(settingSpec.type));
3775
- }
3776
-
3777
- if (!this.name) {
3778
- throw new Error('Setting.name == undefined. Ignoring.', this);
3779
- }
3780
-
3781
- if (!this.defaultValue === undefined) {
3782
- throw new Error('Setting.defaultValue == undefined', this);
3783
- }
3784
-
3785
- if (this.onChange) {
3786
- this.on('change', this.onChange.bind(this))
3787
- }
3788
-
3789
- this.set(this.defaultValue);
3790
- }
3791
- Setting.prototype = {
3792
- get: function() {
3793
- return this.value;
3794
- },
3795
-
3796
- set: function(value) {
3797
- if (this.value === value) {
3798
- return;
3799
- }
3800
-
3801
- this.value = value;
3802
- if (this._settings.persister) {
3803
- this._settings.persister.persistValue(this._settings, this.name, value);
3804
- }
3805
-
3806
- this._dispatchEvent('change', { setting: this, value: value });
3807
- },
3808
-
3809
- /**
3810
- * Reset the value of the <code>key</code> setting to it's default
3811
- */
3812
- resetValue: function() {
3813
- this.set(this.defaultValue);
3814
- },
3815
- toString: function () {
3816
- return this.name;
3817
- }
3818
- };
3819
- oop.implement(Setting.prototype, EventEmitter);
3820
-
3821
-
3822
- /**
3823
- * A base class for all the various methods of storing settings.
3824
- * <p>Usage:
3825
- * <pre>
3826
- * // Create manually, or require 'settings' from the container.
3827
- * // This is the manual version:
3828
- * var settings = plugins.catalog.getObject('settings');
3829
- * // Add a new setting
3830
- * settings.addSetting({ name:'foo', ... });
3831
- * // Display the default value
3832
- * alert(settings.get('foo'));
3833
- * // Alter the value, which also publishes the change etc.
3834
- * settings.set('foo', 'bar');
3835
- * // Reset the value to the default
3836
- * settings.resetValue('foo');
3837
- * </pre>
3838
- * @constructor
3839
- */
3840
- function Settings(persister) {
3841
- // Storage for deactivated values
3842
- this._deactivated = {};
3843
-
3844
- // Storage for the active settings
3845
- this._settings = {};
3846
- // We often want sorted setting names. Cache
3847
- this._settingNames = [];
3848
-
3849
- if (persister) {
3850
- this.setPersister(persister);
3851
- }
3852
- };
3853
-
3854
- Settings.prototype = {
3855
- /**
3856
- * Function to add to the list of available settings.
3857
- * <p>Example usage:
3858
- * <pre>
3859
- * var settings = plugins.catalog.getObject('settings');
3860
- * settings.addSetting({
3861
- * name: 'tabsize', // For use in settings.get('X')
3862
- * type: 'number', // To allow value checking.
3863
- * defaultValue: 4 // Default value for use when none is directly set
3864
- * });
3865
- * </pre>
3866
- * @param {object} settingSpec Object containing name/type/defaultValue members.
3867
- */
3868
- addSetting: function(settingSpec) {
3869
- var setting = new Setting(settingSpec, this);
3870
- this._settings[setting.name] = setting;
3871
- this._settingNames.push(setting.name);
3872
- this._settingNames.sort();
3873
- },
3874
-
3875
- addSettings: function addSettings(settings) {
3876
- Object.keys(settings).forEach(function (name) {
3877
- var setting = settings[name];
3878
- if (!('name' in setting)) setting.name = name;
3879
- this.addSetting(setting);
3880
- }, this);
3881
- },
3882
-
3883
- removeSetting: function(setting) {
3884
- var name = (typeof setting === 'string' ? setting : setting.name);
3885
- setting = this._settings[name];
3886
- delete this._settings[name];
3887
- util.arrayRemove(this._settingNames, name);
3888
- settings.removeAllListeners('change');
3889
- },
3890
-
3891
- removeSettings: function removeSettings(settings) {
3892
- Object.keys(settings).forEach(function(name) {
3893
- var setting = settings[name];
3894
- if (!('name' in setting)) setting.name = name;
3895
- this.removeSettings(setting);
3896
- }, this);
3897
- },
3898
-
3899
- getSettingNames: function() {
3900
- return this._settingNames;
3901
- },
3902
-
3903
- getSetting: function(name) {
3904
- return this._settings[name];
3905
- },
3906
-
3907
- /**
3908
- * A Persister is able to store settings. It is an object that defines
3909
- * two functions:
3910
- * loadInitialValues(settings) and persistValue(settings, key, value).
3911
- */
3912
- setPersister: function(persister) {
3913
- this._persister = persister;
3914
- if (persister) {
3915
- persister.loadInitialValues(this);
3916
- }
3917
- },
3918
-
3919
- resetAll: function() {
3920
- this.getSettingNames().forEach(function(key) {
3921
- this.resetValue(key);
3922
- }, this);
3923
- },
3924
-
3925
- /**
3926
- * Retrieve a list of the known settings and their values
3927
- */
3928
- _list: function() {
3929
- var reply = [];
3930
- this.getSettingNames().forEach(function(setting) {
3931
- reply.push({
3932
- 'key': setting,
3933
- 'value': this.getSetting(setting).get()
3934
- });
3935
- }, this);
3936
- return reply;
3937
- },
3938
-
3939
- /**
3940
- * Prime the local cache with the defaults.
3941
- */
3942
- _loadDefaultValues: function() {
3943
- this._loadFromObject(this._getDefaultValues());
3944
- },
3945
-
3946
- /**
3947
- * Utility to load settings from an object
3948
- */
3949
- _loadFromObject: function(data) {
3950
- // We iterate over data rather than keys so we don't forget values
3951
- // which don't have a setting yet.
3952
- for (var key in data) {
3953
- if (data.hasOwnProperty(key)) {
3954
- var setting = this._settings[key];
3955
- if (setting) {
3956
- var value = setting.type.parse(data[key]);
3957
- this.set(key, value);
3958
- } else {
3959
- this.set(key, data[key]);
3960
- }
3961
- }
3962
- }
3963
- },
3964
-
3965
- /**
3966
- * Utility to grab all the settings and export them into an object
3967
- */
3968
- _saveToObject: function() {
3969
- return this.getSettingNames().map(function(key) {
3970
- return this._settings[key].type.stringify(this.get(key));
3971
- }.bind(this));
3972
- },
3973
-
3974
- /**
3975
- * The default initial settings
3976
- */
3977
- _getDefaultValues: function() {
3978
- return this.getSettingNames().map(function(key) {
3979
- return this._settings[key].spec.defaultValue;
3980
- }.bind(this));
3981
- }
3982
- };
3983
- exports.settings = new Settings();
3984
-
3985
- /**
3986
- * Save the settings in a cookie
3987
- * This code has not been tested since reboot
3988
- * @constructor
3989
- */
3990
- function CookiePersister() {
3991
- };
3992
-
3993
- CookiePersister.prototype = {
3994
- loadInitialValues: function(settings) {
3995
- settings._loadDefaultValues();
3996
- var data = cookie.get('settings');
3997
- settings._loadFromObject(JSON.parse(data));
3998
- },
3999
-
4000
- persistValue: function(settings, key, value) {
4001
- try {
4002
- var stringData = JSON.stringify(settings._saveToObject());
4003
- cookie.set('settings', stringData);
4004
- } catch (ex) {
4005
- console.error('Unable to JSONify the settings! ' + ex);
4006
- return;
4007
- }
4008
- }
4009
- };
4010
-
4011
- exports.CookiePersister = CookiePersister;
4012
-
4013
- });
4014
- /* ***** BEGIN LICENSE BLOCK *****
4015
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4016
- *
4017
- * The contents of this file are subject to the Mozilla Public License Version
4018
- * 1.1 (the "License"); you may not use this file except in compliance with
4019
- * the License. You may obtain a copy of the License at
4020
- * http://www.mozilla.org/MPL/
4021
- *
4022
- * Software distributed under the License is distributed on an "AS IS" basis,
4023
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
4024
- * for the specific language governing rights and limitations under the
4025
- * License.
4026
- *
4027
- * The Original Code is Skywriter.
4028
- *
4029
- * The Initial Developer of the Original Code is
4030
- * Mozilla.
4031
- * Portions created by the Initial Developer are Copyright (C) 2009
4032
- * the Initial Developer. All Rights Reserved.
4033
- *
4034
- * Contributor(s):
4035
- * Skywriter Team (skywriter@mozilla.com)
4036
- *
4037
- * Alternatively, the contents of this file may be used under the terms of
4038
- * either the GNU General Public License Version 2 or later (the "GPL"), or
4039
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
4040
- * in which case the provisions of the GPL or the LGPL are applicable instead
4041
- * of those above. If you wish to allow use of your version of this file only
4042
- * under the terms of either the GPL or the LGPL, and not to allow others to
4043
- * use your version of this file under the terms of the MPL, indicate your
4044
- * decision by deleting the provisions above and replace them with the notice
4045
- * and other provisions required by the GPL or the LGPL. If you do not delete
4046
- * the provisions above, a recipient may use your version of this file under
4047
- * the terms of any one of the MPL, the GPL or the LGPL.
4048
- *
4049
- * ***** END LICENSE BLOCK ***** */
4050
-
4051
- define('pilot/commands/settings', ['require', 'exports', 'module' , 'pilot/canon'], function(require, exports, module) {
4052
-
4053
-
4054
- var setCommandSpec = {
4055
- name: 'set',
4056
- params: [
4057
- {
4058
- name: 'setting',
4059
- type: 'setting',
4060
- description: 'The name of the setting to display or alter',
4061
- defaultValue: null
4062
- },
4063
- {
4064
- name: 'value',
4065
- type: 'settingValue',
4066
- description: 'The new value for the chosen setting',
4067
- defaultValue: null
4068
- }
4069
- ],
4070
- description: 'define and show settings',
4071
- exec: function(env, args, request) {
4072
- var html;
4073
- if (!args.setting) {
4074
- // 'set' by itself lists all the settings
4075
- var names = env.settings.getSettingNames();
4076
- html = '';
4077
- // first sort the settingsList based on the name
4078
- names.sort(function(name1, name2) {
4079
- return name1.localeCompare(name2);
4080
- });
4081
-
4082
- names.forEach(function(name) {
4083
- var setting = env.settings.getSetting(name);
4084
- var url = 'https://wiki.mozilla.org/Labs/Skywriter/Settings#' +
4085
- setting.name;
4086
- html += '<a class="setting" href="' + url +
4087
- '" title="View external documentation on setting: ' +
4088
- setting.name +
4089
- '" target="_blank">' +
4090
- setting.name +
4091
- '</a> = ' +
4092
- setting.value +
4093
- '<br/>';
4094
- });
4095
- } else {
4096
- // set with only a setting, shows the value for that setting
4097
- if (args.value === undefined) {
4098
- html = '<strong>' + setting.name + '</strong> = ' +
4099
- setting.get();
4100
- } else {
4101
- // Actually change the setting
4102
- args.setting.set(args.value);
4103
- html = 'Setting: <strong>' + args.setting.name + '</strong> = ' +
4104
- args.setting.get();
4105
- }
4106
- }
4107
- request.done(html);
4108
- }
4109
- };
4110
-
4111
- var unsetCommandSpec = {
4112
- name: 'unset',
4113
- params: [
4114
- {
4115
- name: 'setting',
4116
- type: 'setting',
4117
- description: 'The name of the setting to return to defaults'
4118
- }
4119
- ],
4120
- description: 'unset a setting entirely',
4121
- exec: function(env, args, request) {
4122
- var setting = env.settings.get(args.setting);
4123
- if (!setting) {
4124
- request.doneWithError('No setting with the name <strong>' +
4125
- args.setting + '</strong>.');
4126
- return;
4127
- }
4128
-
4129
- setting.reset();
4130
- request.done('Reset ' + setting.name + ' to default: ' +
4131
- env.settings.get(args.setting));
4132
- }
4133
- };
4134
-
4135
- var canon = require('pilot/canon');
4136
-
4137
- exports.startup = function(data, reason) {
4138
- canon.addCommand(setCommandSpec);
4139
- canon.addCommand(unsetCommandSpec);
4140
- };
4141
-
4142
- exports.shutdown = function(data, reason) {
4143
- canon.removeCommand(setCommandSpec);
4144
- canon.removeCommand(unsetCommandSpec);
4145
- };
4146
-
4147
-
4148
- });
4149
- /* ***** BEGIN LICENSE BLOCK *****
4150
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4151
- *
4152
- * The contents of this file are subject to the Mozilla Public License Version
4153
- * 1.1 (the "License"); you may not use this file except in compliance with
4154
- * the License. You may obtain a copy of the License at
4155
- * http://www.mozilla.org/MPL/
4156
- *
4157
- * Software distributed under the License is distributed on an "AS IS" basis,
4158
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
4159
- * for the specific language governing rights and limitations under the
4160
- * License.
4161
- *
4162
- * The Original Code is Skywriter.
4163
- *
4164
- * The Initial Developer of the Original Code is
4165
- * Mozilla.
4166
- * Portions created by the Initial Developer are Copyright (C) 2009
4167
- * the Initial Developer. All Rights Reserved.
4168
- *
4169
- * Contributor(s):
4170
- * Skywriter Team (skywriter@mozilla.com)
4171
- *
4172
- * Alternatively, the contents of this file may be used under the terms of
4173
- * either the GNU General Public License Version 2 or later (the "GPL"), or
4174
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
4175
- * in which case the provisions of the GPL or the LGPL are applicable instead
4176
- * of those above. If you wish to allow use of your version of this file only
4177
- * under the terms of either the GPL or the LGPL, and not to allow others to
4178
- * use your version of this file under the terms of the MPL, indicate your
4179
- * decision by deleting the provisions above and replace them with the notice
4180
- * and other provisions required by the GPL or the LGPL. If you do not delete
4181
- * the provisions above, a recipient may use your version of this file under
4182
- * the terms of any one of the MPL, the GPL or the LGPL.
4183
- *
4184
- * ***** END LICENSE BLOCK ***** */
4185
-
4186
- define('pilot/commands/basic', ['require', 'exports', 'module' , 'pilot/typecheck', 'pilot/canon'], function(require, exports, module) {
4187
-
4188
-
4189
- var checks = require("pilot/typecheck");
4190
- var canon = require('pilot/canon');
4191
-
4192
- /**
4193
- * 'help' command
4194
- */
4195
- var helpCommandSpec = {
4196
- name: 'help',
4197
- params: [
4198
- {
4199
- name: 'search',
4200
- type: 'text',
4201
- description: 'Search string to narrow the output.',
4202
- defaultValue: null
4203
- }
4204
- ],
4205
- description: 'Get help on the available commands.',
4206
- exec: function(env, args, request) {
4207
- var output = [];
4208
-
4209
- var command = canon.getCommand(args.search);
4210
- if (command && command.exec) {
4211
- // caught a real command
4212
- output.push(command.description ?
4213
- command.description :
4214
- 'No description for ' + args.search);
4215
- } else {
4216
- var showHidden = false;
4217
-
4218
- if (command) {
4219
- // We must be looking at sub-commands
4220
- output.push('<h2>Sub-Commands of ' + command.name + '</h2>');
4221
- output.push('<p>' + command.description + '</p>');
4222
- }
4223
- else if (args.search) {
4224
- if (args.search == 'hidden') { // sneaky, sneaky.
4225
- args.search = '';
4226
- showHidden = true;
4227
- }
4228
- output.push('<h2>Commands starting with \'' + args.search + '\':</h2>');
4229
- }
4230
- else {
4231
- output.push('<h2>Available Commands:</h2>');
4232
- }
4233
-
4234
- var commandNames = canon.getCommandNames();
4235
- commandNames.sort();
4236
-
4237
- output.push('<table>');
4238
- for (var i = 0; i < commandNames.length; i++) {
4239
- command = canon.getCommand(commandNames[i]);
4240
- if (!showHidden && command.hidden) {
4241
- continue;
4242
- }
4243
- if (command.description === undefined) {
4244
- // Ignore editor actions
4245
- continue;
4246
- }
4247
- if (args.search && command.name.indexOf(args.search) !== 0) {
4248
- // Filtered out by the user
4249
- continue;
4250
- }
4251
- if (!args.search && command.name.indexOf(' ') != -1) {
4252
- // sub command
4253
- continue;
4254
- }
4255
- if (command && command.name == args.search) {
4256
- // sub command, and we've already given that help
4257
- continue;
4258
- }
4259
-
4260
- // todo add back a column with parameter information, perhaps?
4261
-
4262
- output.push('<tr>');
4263
- output.push('<th class="right">' + command.name + '</th>');
4264
- output.push('<td>' + command.description + '</td>');
4265
- output.push('</tr>');
4266
- }
4267
- output.push('</table>');
4268
- }
4269
-
4270
- request.done(output.join(''));
4271
- }
4272
- };
4273
-
4274
- /**
4275
- * 'eval' command
4276
- */
4277
- var evalCommandSpec = {
4278
- name: 'eval',
4279
- params: [
4280
- {
4281
- name: 'javascript',
4282
- type: 'text',
4283
- description: 'The JavaScript to evaluate'
4284
- }
4285
- ],
4286
- description: 'evals given js code and show the result',
4287
- hidden: true,
4288
- exec: function(env, args, request) {
4289
- var result;
4290
- var javascript = args.javascript;
4291
- try {
4292
- result = eval(javascript);
4293
- } catch (e) {
4294
- result = '<b>Error: ' + e.message + '</b>';
4295
- }
4296
-
4297
- var msg = '';
4298
- var type = '';
4299
- var x;
4300
-
4301
- if (checks.isFunction(result)) {
4302
- // converts the function to a well formated string
4303
- msg = (result + '').replace(/\n/g, '<br>').replace(/ /g, '&#160');
4304
- type = 'function';
4305
- } else if (checks.isObject(result)) {
4306
- if (Array.isArray(result)) {
4307
- type = 'array';
4308
- } else {
4309
- type = 'object';
4310
- }
4311
-
4312
- var items = [];
4313
- var value;
4314
-
4315
- for (x in result) {
4316
- if (result.hasOwnProperty(x)) {
4317
- if (checks.isFunction(result[x])) {
4318
- value = '[function]';
4319
- } else if (checks.isObject(result[x])) {
4320
- value = '[object]';
4321
- } else {
4322
- value = result[x];
4323
- }
4324
-
4325
- items.push({name: x, value: value});
4326
- }
4327
- }
4328
-
4329
- items.sort(function(a,b) {
4330
- return (a.name.toLowerCase() < b.name.toLowerCase()) ? -1 : 1;
4331
- });
4332
-
4333
- for (x = 0; x < items.length; x++) {
4334
- msg += '<b>' + items[x].name + '</b>: ' + items[x].value + '<br>';
4335
- }
4336
-
4337
- } else {
4338
- msg = result;
4339
- type = typeof result;
4340
- }
4341
-
4342
- request.done('Result for eval <b>\'' + javascript + '\'</b>' +
4343
- ' (type: '+ type+'): <br><br>'+ msg);
4344
- }
4345
- };
4346
-
4347
- var canon = require('pilot/canon');
4348
-
4349
- exports.startup = function(data, reason) {
4350
- canon.addCommand(helpCommandSpec);
4351
- canon.addCommand(evalCommandSpec);
4352
- };
4353
-
4354
- exports.shutdown = function(data, reason) {
4355
- canon.removeCommand(helpCommandSpec);
4356
- canon.removeCommand(evalCommandSpec);
4357
- };
4358
-
4359
-
4360
- });
4361
- /* ***** BEGIN LICENSE BLOCK *****
4362
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4363
- *
4364
- * The contents of this file are subject to the Mozilla Public License Version
4365
- * 1.1 (the "License"); you may not use this file except in compliance with
4366
- * the License. You may obtain a copy of the License at
4367
- * http://www.mozilla.org/MPL/
4368
- *
4369
- * Software distributed under the License is distributed on an "AS IS" basis,
4370
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
4371
- * for the specific language governing rights and limitations under the
4372
- * License.
4373
- *
4374
- * The Original Code is Mozilla Skywriter.
4375
- *
4376
- * The Initial Developer of the Original Code is
4377
- * Mozilla.
4378
- * Portions created by the Initial Developer are Copyright (C) 2009
4379
- * the Initial Developer. All Rights Reserved.
4380
- *
4381
- * Contributor(s):
4382
- * Joe Walker (jwalker@mozilla.com)
4383
- *
4384
- * Alternatively, the contents of this file may be used under the terms of
4385
- * either the GNU General Public License Version 2 or later (the "GPL"), or
4386
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
4387
- * in which case the provisions of the GPL or the LGPL are applicable instead
4388
- * of those above. If you wish to allow use of your version of this file only
4389
- * under the terms of either the GPL or the LGPL, and not to allow others to
4390
- * use your version of this file under the terms of the MPL, indicate your
4391
- * decision by deleting the provisions above and replace them with the notice
4392
- * and other provisions required by the GPL or the LGPL. If you do not delete
4393
- * the provisions above, a recipient may use your version of this file under
4394
- * the terms of any one of the MPL, the GPL or the LGPL.
4395
- *
4396
- * ***** END LICENSE BLOCK ***** */
4397
-
4398
- define('pilot/settings/canon', ['require', 'exports', 'module' ], function(require, exports, module) {
4399
-
4400
-
4401
- var historyLengthSetting = {
4402
- name: "historyLength",
4403
- description: "How many typed commands do we recall for reference?",
4404
- type: "number",
4405
- defaultValue: 50
4406
- };
4407
-
4408
- exports.startup = function(data, reason) {
4409
- data.env.settings.addSetting(historyLengthSetting);
4410
- };
4411
-
4412
- exports.shutdown = function(data, reason) {
4413
- data.env.settings.removeSetting(historyLengthSetting);
4414
- };
4415
-
4416
-
4417
- });
4418
- /* ***** BEGIN LICENSE BLOCK *****
4419
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4420
- *
4421
- * The contents of this file are subject to the Mozilla Public License Version
4422
- * 1.1 (the "License"); you may not use this file except in compliance with
4423
- * the License. You may obtain a copy of the License at
4424
- * http://www.mozilla.org/MPL/
4425
- *
4426
- * Software distributed under the License is distributed on an "AS IS" basis,
4427
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
4428
- * for the specific language governing rights and limitations under the
4429
- * License.
4430
- *
4431
- * The Original Code is Skywriter.
4432
- *
4433
- * The Initial Developer of the Original Code is
4434
- * Mozilla.
4435
- * Portions created by the Initial Developer are Copyright (C) 2009
4436
- * the Initial Developer. All Rights Reserved.
4437
- *
4438
- * Contributor(s):
4439
- * Kevin Dangoor (kdangoor@mozilla.com)
4440
- *
4441
- * Alternatively, the contents of this file may be used under the terms of
4442
- * either the GNU General Public License Version 2 or later (the "GPL"), or
4443
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
4444
- * in which case the provisions of the GPL or the LGPL are applicable instead
4445
- * of those above. If you wish to allow use of your version of this file only
4446
- * under the terms of either the GPL or the LGPL, and not to allow others to
4447
- * use your version of this file under the terms of the MPL, indicate your
4448
- * decision by deleting the provisions above and replace them with the notice
4449
- * and other provisions required by the GPL or the LGPL. If you do not delete
4450
- * the provisions above, a recipient may use your version of this file under
4451
- * the terms of any one of the MPL, the GPL or the LGPL.
4452
- *
4453
- * ***** END LICENSE BLOCK ***** */
4454
-
4455
- define('pilot/plugin_manager', ['require', 'exports', 'module' , 'pilot/promise'], function(require, exports, module) {
4456
-
4457
- var Promise = require("pilot/promise").Promise;
4458
-
4459
- exports.REASONS = {
4460
- APP_STARTUP: 1,
4461
- APP_SHUTDOWN: 2,
4462
- PLUGIN_ENABLE: 3,
4463
- PLUGIN_DISABLE: 4,
4464
- PLUGIN_INSTALL: 5,
4465
- PLUGIN_UNINSTALL: 6,
4466
- PLUGIN_UPGRADE: 7,
4467
- PLUGIN_DOWNGRADE: 8
4468
- };
4469
-
4470
- exports.Plugin = function(name) {
4471
- this.name = name;
4472
- this.status = this.INSTALLED;
4473
- };
4474
-
4475
- exports.Plugin.prototype = {
4476
- /**
4477
- * constants for the state
4478
- */
4479
- NEW: 0,
4480
- INSTALLED: 1,
4481
- REGISTERED: 2,
4482
- STARTED: 3,
4483
- UNREGISTERED: 4,
4484
- SHUTDOWN: 5,
4485
-
4486
- install: function(data, reason) {
4487
- var pr = new Promise();
4488
- if (this.status > this.NEW) {
4489
- pr.resolve(this);
4490
- return pr;
4491
- }
4492
- require([this.name], function(pluginModule) {
4493
- if (pluginModule.install) {
4494
- pluginModule.install(data, reason);
4495
- }
4496
- this.status = this.INSTALLED;
4497
- pr.resolve(this);
4498
- }.bind(this));
4499
- return pr;
4500
- },
4501
-
4502
- register: function(data, reason) {
4503
- var pr = new Promise();
4504
- if (this.status != this.INSTALLED) {
4505
- pr.resolve(this);
4506
- return pr;
4507
- }
4508
- require([this.name], function(pluginModule) {
4509
- if (pluginModule.register) {
4510
- pluginModule.register(data, reason);
4511
- }
4512
- this.status = this.REGISTERED;
4513
- pr.resolve(this);
4514
- }.bind(this));
4515
- return pr;
4516
- },
4517
-
4518
- startup: function(data, reason) {
4519
- reason = reason || exports.REASONS.APP_STARTUP;
4520
- var pr = new Promise();
4521
- if (this.status != this.REGISTERED) {
4522
- pr.resolve(this);
4523
- return pr;
4524
- }
4525
- require([this.name], function(pluginModule) {
4526
- if (pluginModule.startup) {
4527
- pluginModule.startup(data, reason);
4528
- }
4529
- this.status = this.STARTED;
4530
- pr.resolve(this);
4531
- }.bind(this));
4532
- return pr;
4533
- },
4534
-
4535
- shutdown: function(data, reason) {
4536
- if (this.status != this.STARTED) {
4537
- return;
4538
- }
4539
- pluginModule = require(this.name);
4540
- if (pluginModule.shutdown) {
4541
- pluginModule.shutdown(data, reason);
4542
- }
4543
- }
4544
- };
4545
-
4546
- exports.PluginCatalog = function() {
4547
- this.plugins = {};
4548
- };
4549
-
4550
- exports.PluginCatalog.prototype = {
4551
- registerPlugins: function(pluginList, data, reason) {
4552
- var registrationPromises = [];
4553
- pluginList.forEach(function(pluginName) {
4554
- var plugin = this.plugins[pluginName];
4555
- if (plugin === undefined) {
4556
- plugin = new exports.Plugin(pluginName);
4557
- this.plugins[pluginName] = plugin;
4558
- registrationPromises.push(plugin.register(data, reason));
4559
- }
4560
- }.bind(this));
4561
- return Promise.group(registrationPromises);
4562
- },
4563
-
4564
- startupPlugins: function(data, reason) {
4565
- var startupPromises = [];
4566
- for (var pluginName in this.plugins) {
4567
- var plugin = this.plugins[pluginName];
4568
- startupPromises.push(plugin.startup(data, reason));
4569
- }
4570
- return Promise.group(startupPromises);
4571
- }
4572
- };
4573
-
4574
- exports.catalog = new exports.PluginCatalog();
4575
-
4576
- });
4577
- /* ***** BEGIN LICENSE BLOCK *****
4578
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4579
- *
4580
- * The contents of this file are subject to the Mozilla Public License Version
4581
- * 1.1 (the "License"); you may not use this file except in compliance with
4582
- * the License. You may obtain a copy of the License at
4583
- * http://www.mozilla.org/MPL/
4584
- *
4585
- * Software distributed under the License is distributed on an "AS IS" basis,
4586
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
4587
- * for the specific language governing rights and limitations under the
4588
- * License.
4589
- *
4590
- * The Original Code is Mozilla Skywriter.
4591
- *
4592
- * The Initial Developer of the Original Code is
4593
- * Mozilla.
4594
- * Portions created by the Initial Developer are Copyright (C) 2009
4595
- * the Initial Developer. All Rights Reserved.
4596
- *
4597
- * Contributor(s):
4598
- * Joe Walker (jwalker@mozilla.com)
4599
- *
4600
- * Alternatively, the contents of this file may be used under the terms of
4601
- * either the GNU General Public License Version 2 or later (the "GPL"), or
4602
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
4603
- * in which case the provisions of the GPL or the LGPL are applicable instead
4604
- * of those above. If you wish to allow use of your version of this file only
4605
- * under the terms of either the GPL or the LGPL, and not to allow others to
4606
- * use your version of this file under the terms of the MPL, indicate your
4607
- * decision by deleting the provisions above and replace them with the notice
4608
- * and other provisions required by the GPL or the LGPL. If you do not delete
4609
- * the provisions above, a recipient may use your version of this file under
4610
- * the terms of any one of the MPL, the GPL or the LGPL.
4611
- *
4612
- * ***** END LICENSE BLOCK ***** */
4613
-
4614
- define('pilot/promise', ['require', 'exports', 'module' , 'pilot/console', 'pilot/stacktrace'], function(require, exports, module) {
4615
-
4616
- var console = require("pilot/console");
4617
- var Trace = require('pilot/stacktrace').Trace;
4618
-
4619
- /**
4620
- * A promise can be in one of 2 states.
4621
- * The ERROR and SUCCESS states are terminal, the PENDING state is the only
4622
- * start state.
4623
- */
4624
- var ERROR = -1;
4625
- var PENDING = 0;
4626
- var SUCCESS = 1;
4627
-
4628
- /**
4629
- * We give promises and ID so we can track which are outstanding
4630
- */
4631
- var _nextId = 0;
4632
-
4633
- /**
4634
- * Debugging help if 2 things try to complete the same promise.
4635
- * This can be slow (especially on chrome due to the stack trace unwinding) so
4636
- * we should leave this turned off in normal use.
4637
- */
4638
- var _traceCompletion = false;
4639
-
4640
- /**
4641
- * Outstanding promises. Handy list for debugging only.
4642
- */
4643
- var _outstanding = [];
4644
-
4645
- /**
4646
- * Recently resolved promises. Also for debugging only.
4647
- */
4648
- var _recent = [];
4649
-
4650
- /**
4651
- * Create an unfulfilled promise
4652
- */
4653
- Promise = function () {
4654
- this._status = PENDING;
4655
- this._value = undefined;
4656
- this._onSuccessHandlers = [];
4657
- this._onErrorHandlers = [];
4658
-
4659
- // Debugging help
4660
- this._id = _nextId++;
4661
- //this._createTrace = new Trace(new Error());
4662
- _outstanding[this._id] = this;
4663
- };
4664
-
4665
- /**
4666
- * Yeay for RTTI.
4667
- */
4668
- Promise.prototype.isPromise = true;
4669
-
4670
- /**
4671
- * Have we either been resolve()ed or reject()ed?
4672
- */
4673
- Promise.prototype.isComplete = function() {
4674
- return this._status != PENDING;
4675
- };
4676
-
4677
- /**
4678
- * Have we resolve()ed?
4679
- */
4680
- Promise.prototype.isResolved = function() {
4681
- return this._status == SUCCESS;
4682
- };
4683
-
4684
- /**
4685
- * Have we reject()ed?
4686
- */
4687
- Promise.prototype.isRejected = function() {
4688
- return this._status == ERROR;
4689
- };
4690
-
4691
- /**
4692
- * Take the specified action of fulfillment of a promise, and (optionally)
4693
- * a different action on promise rejection.
4694
- */
4695
- Promise.prototype.then = function(onSuccess, onError) {
4696
- if (typeof onSuccess === 'function') {
4697
- if (this._status === SUCCESS) {
4698
- onSuccess.call(null, this._value);
4699
- } else if (this._status === PENDING) {
4700
- this._onSuccessHandlers.push(onSuccess);
4701
- }
4702
- }
4703
-
4704
- if (typeof onError === 'function') {
4705
- if (this._status === ERROR) {
4706
- onError.call(null, this._value);
4707
- } else if (this._status === PENDING) {
4708
- this._onErrorHandlers.push(onError);
4709
- }
4710
- }
4711
-
4712
- return this;
4713
- };
4714
-
4715
- /**
4716
- * Like then() except that rather than returning <tt>this</tt> we return
4717
- * a promise which
4718
- */
4719
- Promise.prototype.chainPromise = function(onSuccess) {
4720
- var chain = new Promise();
4721
- chain._chainedFrom = this;
4722
- this.then(function(data) {
4723
- try {
4724
- chain.resolve(onSuccess(data));
4725
- } catch (ex) {
4726
- chain.reject(ex);
4727
- }
4728
- }, function(ex) {
4729
- chain.reject(ex);
4730
- });
4731
- return chain;
4732
- };
4733
-
4734
- /**
4735
- * Supply the fulfillment of a promise
4736
- */
4737
- Promise.prototype.resolve = function(data) {
4738
- return this._complete(this._onSuccessHandlers, SUCCESS, data, 'resolve');
4739
- };
4740
-
4741
- /**
4742
- * Renege on a promise
4743
- */
4744
- Promise.prototype.reject = function(data) {
4745
- return this._complete(this._onErrorHandlers, ERROR, data, 'reject');
4746
- };
4747
-
4748
- /**
4749
- * Internal method to be called on resolve() or reject().
4750
- * @private
4751
- */
4752
- Promise.prototype._complete = function(list, status, data, name) {
4753
- // Complain if we've already been completed
4754
- if (this._status != PENDING) {
4755
- console.group('Promise already closed');
4756
- console.error('Attempted ' + name + '() with ', data);
4757
- console.error('Previous status = ', this._status,
4758
- ', previous value = ', this._value);
4759
- console.trace();
4760
-
4761
- if (this._completeTrace) {
4762
- console.error('Trace of previous completion:');
4763
- this._completeTrace.log(5);
4764
- }
4765
- console.groupEnd();
4766
- return this;
4767
- }
4768
-
4769
- if (_traceCompletion) {
4770
- this._completeTrace = new Trace(new Error());
4771
- }
4772
-
4773
- this._status = status;
4774
- this._value = data;
4775
-
4776
- // Call all the handlers, and then delete them
4777
- list.forEach(function(handler) {
4778
- handler.call(null, this._value);
4779
- }, this);
4780
- this._onSuccessHandlers.length = 0;
4781
- this._onErrorHandlers.length = 0;
4782
-
4783
- // Remove the given {promise} from the _outstanding list, and add it to the
4784
- // _recent list, pruning more than 20 recent promises from that list.
4785
- delete _outstanding[this._id];
4786
- _recent.push(this);
4787
- while (_recent.length > 20) {
4788
- _recent.shift();
4789
- }
4790
-
4791
- return this;
4792
- };
4793
-
4794
- /**
4795
- * Takes an array of promises and returns a promise that that is fulfilled once
4796
- * all the promises in the array are fulfilled
4797
- * @param group The array of promises
4798
- * @return the promise that is fulfilled when all the array is fulfilled
4799
- */
4800
- Promise.group = function(promiseList) {
4801
- if (!(promiseList instanceof Array)) {
4802
- promiseList = Array.prototype.slice.call(arguments);
4803
- }
4804
-
4805
- // If the original array has nothing in it, return now to avoid waiting
4806
- if (promiseList.length === 0) {
4807
- return new Promise().resolve([]);
4808
- }
4809
-
4810
- var groupPromise = new Promise();
4811
- var results = [];
4812
- var fulfilled = 0;
4813
-
4814
- var onSuccessFactory = function(index) {
4815
- return function(data) {
4816
- results[index] = data;
4817
- fulfilled++;
4818
- // If the group has already failed, silently drop extra results
4819
- if (groupPromise._status !== ERROR) {
4820
- if (fulfilled === promiseList.length) {
4821
- groupPromise.resolve(results);
4822
- }
4823
- }
4824
- };
4825
- };
4826
-
4827
- promiseList.forEach(function(promise, index) {
4828
- var onSuccess = onSuccessFactory(index);
4829
- var onError = groupPromise.reject.bind(groupPromise);
4830
- promise.then(onSuccess, onError);
4831
- });
4832
-
4833
- return groupPromise;
4834
- };
4835
-
4836
- exports.Promise = Promise;
4837
- exports._outstanding = _outstanding;
4838
- exports._recent = _recent;
4839
-
4840
- });
4841
- /* vim:ts=4:sts=4:sw=4:
4842
- * ***** BEGIN LICENSE BLOCK *****
4843
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4844
- *
4845
- * The contents of this file are subject to the Mozilla Public License Version
4846
- * 1.1 (the "License"); you may not use this file except in compliance with
4847
- * the License. You may obtain a copy of the License at
4848
- * http://www.mozilla.org/MPL/
4849
- *
4850
- * Software distributed under the License is distributed on an "AS IS" basis,
4851
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
4852
- * for the specific language governing rights and limitations under the
4853
- * License.
4854
- *
4855
- * The Original Code is Ajax.org Code Editor (ACE).
4856
- *
4857
- * The Initial Developer of the Original Code is
4858
- * Ajax.org B.V.
4859
- * Portions created by the Initial Developer are Copyright (C) 2010
4860
- * the Initial Developer. All Rights Reserved.
4861
- *
4862
- * Contributor(s):
4863
- * Fabian Jakobs <fabian AT ajax DOT org>
4864
- * Mihai Sucan <mihai AT sucan AT gmail ODT com>
4865
- *
4866
- * Alternatively, the contents of this file may be used under the terms of
4867
- * either the GNU General Public License Version 2 or later (the "GPL"), or
4868
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
4869
- * in which case the provisions of the GPL or the LGPL are applicable instead
4870
- * of those above. If you wish to allow use of your version of this file only
4871
- * under the terms of either the GPL or the LGPL, and not to allow others to
4872
- * use your version of this file under the terms of the MPL, indicate your
4873
- * decision by deleting the provisions above and replace them with the notice
4874
- * and other provisions required by the GPL or the LGPL. If you do not delete
4875
- * the provisions above, a recipient may use your version of this file under
4876
- * the terms of any one of the MPL, the GPL or the LGPL.
4877
- *
4878
- * ***** END LICENSE BLOCK ***** */
4879
-
4880
- define('pilot/dom', ['require', 'exports', 'module' ], function(require, exports, module) {
4881
-
4882
- var XHTML_NS = "http://www.w3.org/1999/xhtml";
4883
-
4884
- exports.createElement = function(tag, ns) {
4885
- return document.createElementNS ?
4886
- document.createElementNS(ns || XHTML_NS, tag) :
4887
- document.createElement(tag);
4888
- };
4889
-
4890
- exports.setText = function(elem, text) {
4891
- if (elem.innerText !== undefined) {
4892
- elem.innerText = text;
4893
- }
4894
- if (elem.textContent !== undefined) {
4895
- elem.textContent = text;
4896
- }
4897
- };
4898
-
4899
- if (!document.documentElement.classList) {
4900
- exports.hasCssClass = function(el, name) {
4901
- var classes = el.className.split(/\s+/g);
4902
- return classes.indexOf(name) !== -1;
4903
- };
4904
-
4905
- /**
4906
- * Add a CSS class to the list of classes on the given node
4907
- */
4908
- exports.addCssClass = function(el, name) {
4909
- if (!exports.hasCssClass(el, name)) {
4910
- el.className += " " + name;
4911
- }
4912
- };
4913
-
4914
- /**
4915
- * Remove a CSS class from the list of classes on the given node
4916
- */
4917
- exports.removeCssClass = function(el, name) {
4918
- var classes = el.className.split(/\s+/g);
4919
- while (true) {
4920
- var index = classes.indexOf(name);
4921
- if (index == -1) {
4922
- break;
4923
- }
4924
- classes.splice(index, 1);
4925
- }
4926
- el.className = classes.join(" ");
4927
- };
4928
-
4929
- exports.toggleCssClass = function(el, name) {
4930
- var classes = el.className.split(/\s+/g), add = true;
4931
- while (true) {
4932
- var index = classes.indexOf(name);
4933
- if (index == -1) {
4934
- break;
4935
- }
4936
- add = false;
4937
- classes.splice(index, 1);
4938
- }
4939
- if(add)
4940
- classes.push(name);
4941
-
4942
- el.className = classes.join(" ");
4943
- return add;
4944
- };
4945
- } else {
4946
- exports.hasCssClass = function(el, name) {
4947
- return el.classList.contains(name);
4948
- };
4949
-
4950
- exports.addCssClass = function(el, name) {
4951
- el.classList.add(name);
4952
- };
4953
-
4954
- exports.removeCssClass = function(el, name) {
4955
- el.classList.remove(name);
4956
- };
4957
-
4958
- exports.toggleCssClass = function(el, name) {
4959
- return el.classList.toggle(name);
4960
- };
4961
- }
4962
-
4963
- /**
4964
- * Add or remove a CSS class from the list of classes on the given node
4965
- * depending on the value of <tt>include</tt>
4966
- */
4967
- exports.setCssClass = function(node, className, include) {
4968
- if (include) {
4969
- exports.addCssClass(node, className);
4970
- } else {
4971
- exports.removeCssClass(node, className);
4972
- }
4973
- };
4974
-
4975
- exports.importCssString = function(cssText, doc){
4976
- doc = doc || document;
4977
-
4978
- if (doc.createStyleSheet) {
4979
- var sheet = doc.createStyleSheet();
4980
- sheet.cssText = cssText;
4981
- }
4982
- else {
4983
- var style = doc.createElementNS ?
4984
- doc.createElementNS(XHTML_NS, "style") :
4985
- doc.createElement("style");
4986
-
4987
- style.appendChild(doc.createTextNode(cssText));
4988
-
4989
- var head = doc.getElementsByTagName("head")[0] || doc.documentElement;
4990
- head.appendChild(style);
4991
- }
4992
- };
4993
-
4994
- exports.getInnerWidth = function(element) {
4995
- return (parseInt(exports.computedStyle(element, "paddingLeft"))
4996
- + parseInt(exports.computedStyle(element, "paddingRight")) + element.clientWidth);
4997
- };
4998
-
4999
- exports.getInnerHeight = function(element) {
5000
- return (parseInt(exports.computedStyle(element, "paddingTop"))
5001
- + parseInt(exports.computedStyle(element, "paddingBottom")) + element.clientHeight);
5002
- };
5003
-
5004
- if (window.pageYOffset !== undefined) {
5005
- exports.getPageScrollTop = function() {
5006
- return window.pageYOffset;
5007
- };
5008
-
5009
- exports.getPageScrollLeft = function() {
5010
- return window.pageXOffset;
5011
- };
5012
- }
5013
- else {
5014
- exports.getPageScrollTop = function() {
5015
- return document.body.scrollTop;
5016
- };
5017
-
5018
- exports.getPageScrollLeft = function() {
5019
- return document.body.scrollLeft;
5020
- };
5021
- }
5022
-
5023
- if (window.getComputedStyle)
5024
- exports.computedStyle = function(element, style) {
5025
- if (style)
5026
- return (window.getComputedStyle(element, "") || {})[style] || "";
5027
- return window.getComputedStyle(element, "") || {}
5028
- };
5029
- else
5030
- exports.computedStyle = function(element, style) {
5031
- if (style)
5032
- return element.currentStyle[style];
5033
- return element.currentStyle
5034
- };
5035
-
5036
- exports.scrollbarWidth = function() {
5037
-
5038
- var inner = exports.createElement("p");
5039
- inner.style.width = "100%";
5040
- inner.style.minWidth = "0px";
5041
- inner.style.height = "200px";
5042
-
5043
- var outer = exports.createElement("div");
5044
- var style = outer.style;
5045
-
5046
- style.position = "absolute";
5047
- style.left = "-10000px";
5048
- style.overflow = "hidden";
5049
- style.width = "200px";
5050
- style.minWidth = "0px";
5051
- style.height = "150px";
5052
-
5053
- outer.appendChild(inner);
5054
-
5055
- var body = document.body || document.documentElement;
5056
- body.appendChild(outer);
5057
-
5058
- var noScrollbar = inner.offsetWidth;
5059
-
5060
- style.overflow = "scroll";
5061
- var withScrollbar = inner.offsetWidth;
5062
-
5063
- if (noScrollbar == withScrollbar) {
5064
- withScrollbar = outer.clientWidth;
5065
- }
5066
-
5067
- body.removeChild(outer);
5068
-
5069
- return noScrollbar-withScrollbar;
5070
- };
5071
-
5072
- /**
5073
- * Optimized set innerHTML. This is faster than plain innerHTML if the element
5074
- * already contains a lot of child elements.
5075
- *
5076
- * See http://blog.stevenlevithan.com/archives/faster-than-innerhtml for details
5077
- */
5078
- exports.setInnerHtml = function(el, innerHtml) {
5079
- var element = el.cloneNode(false);//document.createElement("div");
5080
- element.innerHTML = innerHtml;
5081
- el.parentNode.replaceChild(element, el);
5082
- return element;
5083
- };
5084
-
5085
- exports.setInnerText = function(el, innerText) {
5086
- if (document.body && "textContent" in document.body)
5087
- el.textContent = innerText;
5088
- else
5089
- el.innerText = innerText;
5090
-
5091
- };
5092
-
5093
- exports.getInnerText = function(el) {
5094
- if (document.body && "textContent" in document.body)
5095
- return el.textContent;
5096
- else
5097
- return el.innerText || el.textContent || "";
5098
- };
5099
-
5100
- exports.getParentWindow = function(document) {
5101
- return document.defaultView || document.parentWindow;
5102
- };
5103
-
5104
- exports.getSelectionStart = function(textarea) {
5105
- // TODO IE
5106
- var start;
5107
- try {
5108
- start = textarea.selectionStart || 0;
5109
- } catch (e) {
5110
- start = 0;
5111
- }
5112
- return start;
5113
- };
5114
-
5115
- exports.setSelectionStart = function(textarea, start) {
5116
- // TODO IE
5117
- return textarea.selectionStart = start;
5118
- };
5119
-
5120
- exports.getSelectionEnd = function(textarea) {
5121
- // TODO IE
5122
- var end;
5123
- try {
5124
- end = textarea.selectionEnd || 0;
5125
- } catch (e) {
5126
- end = 0;
5127
- }
5128
- return end;
5129
- };
5130
-
5131
- exports.setSelectionEnd = function(textarea, end) {
5132
- // TODO IE
5133
- return textarea.selectionEnd = end;
5134
- };
5135
-
5136
- });
5137
- /* ***** BEGIN LICENSE BLOCK *****
5138
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5139
- *
5140
- * The contents of this file are subject to the Mozilla Public License Version
5141
- * 1.1 (the "License"); you may not use this file except in compliance with
5142
- * the License. You may obtain a copy of the License at
5143
- * http://www.mozilla.org/MPL/
5144
- *
5145
- * Software distributed under the License is distributed on an "AS IS" basis,
5146
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
5147
- * for the specific language governing rights and limitations under the
5148
- * License.
5149
- *
5150
- * The Original Code is Ajax.org Code Editor (ACE).
5151
- *
5152
- * The Initial Developer of the Original Code is
5153
- * Ajax.org B.V.
5154
- * Portions created by the Initial Developer are Copyright (C) 2010
5155
- * the Initial Developer. All Rights Reserved.
5156
- *
5157
- * Contributor(s):
5158
- * Fabian Jakobs <fabian AT ajax DOT org>
5159
- *
5160
- * Alternatively, the contents of this file may be used under the terms of
5161
- * either the GNU General Public License Version 2 or later (the "GPL"), or
5162
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
5163
- * in which case the provisions of the GPL or the LGPL are applicable instead
5164
- * of those above. If you wish to allow use of your version of this file only
5165
- * under the terms of either the GPL or the LGPL, and not to allow others to
5166
- * use your version of this file under the terms of the MPL, indicate your
5167
- * decision by deleting the provisions above and replace them with the notice
5168
- * and other provisions required by the GPL or the LGPL. If you do not delete
5169
- * the provisions above, a recipient may use your version of this file under
5170
- * the terms of any one of the MPL, the GPL or the LGPL.
5171
- *
5172
- * ***** END LICENSE BLOCK ***** */
5173
-
5174
- define('pilot/event', ['require', 'exports', 'module' , 'pilot/keys', 'pilot/useragent', 'pilot/dom'], function(require, exports, module) {
5175
-
5176
- var keys = require("pilot/keys");
5177
- var useragent = require("pilot/useragent");
5178
- var dom = require("pilot/dom");
5179
-
5180
- exports.addListener = function(elem, type, callback) {
5181
- if (elem.addEventListener) {
5182
- return elem.addEventListener(type, callback, false);
5183
- }
5184
- if (elem.attachEvent) {
5185
- var wrapper = function() {
5186
- callback(window.event);
5187
- };
5188
- callback._wrapper = wrapper;
5189
- elem.attachEvent("on" + type, wrapper);
5190
- }
5191
- };
5192
-
5193
- exports.removeListener = function(elem, type, callback) {
5194
- if (elem.removeEventListener) {
5195
- return elem.removeEventListener(type, callback, false);
5196
- }
5197
- if (elem.detachEvent) {
5198
- elem.detachEvent("on" + type, callback._wrapper || callback);
5199
- }
5200
- };
5201
-
5202
- /**
5203
- * Prevents propagation and clobbers the default action of the passed event
5204
- */
5205
- exports.stopEvent = function(e) {
5206
- exports.stopPropagation(e);
5207
- exports.preventDefault(e);
5208
- return false;
5209
- };
5210
-
5211
- exports.stopPropagation = function(e) {
5212
- if (e.stopPropagation)
5213
- e.stopPropagation();
5214
- else
5215
- e.cancelBubble = true;
5216
- };
5217
-
5218
- exports.preventDefault = function(e) {
5219
- if (e.preventDefault)
5220
- e.preventDefault();
5221
- else
5222
- e.returnValue = false;
5223
- };
5224
-
5225
- exports.getDocumentX = function(e) {
5226
- if (e.clientX) {
5227
- return e.clientX + dom.getPageScrollLeft();
5228
- } else {
5229
- return e.pageX;
5230
- }
5231
- };
5232
-
5233
- exports.getDocumentY = function(e) {
5234
- if (e.clientY) {
5235
- return e.clientY + dom.getPageScrollTop();
5236
- } else {
5237
- return e.pageY;
5238
- }
5239
- };
5240
-
5241
- /**
5242
- * @return {Number} 0 for left button, 1 for middle button, 2 for right button
5243
- */
5244
- exports.getButton = function(e) {
5245
- if (e.type == "dblclick")
5246
- return 0;
5247
- else if (e.type == "contextmenu")
5248
- return 2;
5249
-
5250
- // DOM Event
5251
- if (e.preventDefault) {
5252
- return e.button;
5253
- }
5254
- // old IE
5255
- else {
5256
- return {1:0, 2:2, 4:1}[e.button];
5257
- }
5258
- };
5259
-
5260
- if (document.documentElement.setCapture) {
5261
- exports.capture = function(el, eventHandler, releaseCaptureHandler) {
5262
- function onMouseMove(e) {
5263
- eventHandler(e);
5264
- return exports.stopPropagation(e);
5265
- }
5266
-
5267
- function onReleaseCapture(e) {
5268
- eventHandler && eventHandler(e);
5269
- releaseCaptureHandler && releaseCaptureHandler();
5270
-
5271
- exports.removeListener(el, "mousemove", eventHandler);
5272
- exports.removeListener(el, "mouseup", onReleaseCapture);
5273
- exports.removeListener(el, "losecapture", onReleaseCapture);
5274
-
5275
- el.releaseCapture();
5276
- }
5277
-
5278
- exports.addListener(el, "mousemove", eventHandler);
5279
- exports.addListener(el, "mouseup", onReleaseCapture);
5280
- exports.addListener(el, "losecapture", onReleaseCapture);
5281
- el.setCapture();
5282
- };
5283
- }
5284
- else {
5285
- exports.capture = function(el, eventHandler, releaseCaptureHandler) {
5286
- function onMouseMove(e) {
5287
- eventHandler(e);
5288
- e.stopPropagation();
5289
- }
5290
-
5291
- function onMouseUp(e) {
5292
- eventHandler && eventHandler(e);
5293
- releaseCaptureHandler && releaseCaptureHandler();
5294
-
5295
- document.removeEventListener("mousemove", onMouseMove, true);
5296
- document.removeEventListener("mouseup", onMouseUp, true);
5297
-
5298
- e.stopPropagation();
5299
- }
5300
-
5301
- document.addEventListener("mousemove", onMouseMove, true);
5302
- document.addEventListener("mouseup", onMouseUp, true);
5303
- };
5304
- }
5305
-
5306
- exports.addMouseWheelListener = function(el, callback) {
5307
- var listener = function(e) {
5308
- if (e.wheelDelta !== undefined) {
5309
- if (e.wheelDeltaX !== undefined) {
5310
- e.wheelX = -e.wheelDeltaX / 8;
5311
- e.wheelY = -e.wheelDeltaY / 8;
5312
- } else {
5313
- e.wheelX = 0;
5314
- e.wheelY = -e.wheelDelta / 8;
5315
- }
5316
- }
5317
- else {
5318
- if (e.axis && e.axis == e.HORIZONTAL_AXIS) {
5319
- e.wheelX = (e.detail || 0) * 5;
5320
- e.wheelY = 0;
5321
- } else {
5322
- e.wheelX = 0;
5323
- e.wheelY = (e.detail || 0) * 5;
5324
- }
5325
- }
5326
- callback(e);
5327
- };
5328
- exports.addListener(el, "DOMMouseScroll", listener);
5329
- exports.addListener(el, "mousewheel", listener);
5330
- };
5331
-
5332
- exports.addMultiMouseDownListener = function(el, button, count, timeout, callback) {
5333
- var clicks = 0;
5334
- var startX, startY;
5335
-
5336
- var listener = function(e) {
5337
- clicks += 1;
5338
- if (clicks == 1) {
5339
- startX = e.clientX;
5340
- startY = e.clientY;
5341
-
5342
- setTimeout(function() {
5343
- clicks = 0;
5344
- }, timeout || 600);
5345
- }
5346
-
5347
- var isButton = exports.getButton(e) == button;
5348
- if (!isButton || Math.abs(e.clientX - startX) > 5 || Math.abs(e.clientY - startY) > 5)
5349
- clicks = 0;
5350
-
5351
- if (clicks == count) {
5352
- clicks = 0;
5353
- callback(e);
5354
- }
5355
-
5356
- if (isButton)
5357
- return exports.preventDefault(e);
5358
- };
5359
-
5360
- exports.addListener(el, "mousedown", listener);
5361
- useragent.isIE && exports.addListener(el, "dblclick", listener);
5362
- };
5363
-
5364
- function normalizeCommandKeys(callback, e, keyCode) {
5365
- var hashId = 0;
5366
- if (useragent.isOpera && useragent.isMac) {
5367
- hashId = 0 | (e.metaKey ? 1 : 0) | (e.altKey ? 2 : 0)
5368
- | (e.shiftKey ? 4 : 0) | (e.ctrlKey ? 8 : 0);
5369
- } else {
5370
- hashId = 0 | (e.ctrlKey ? 1 : 0) | (e.altKey ? 2 : 0)
5371
- | (e.shiftKey ? 4 : 0) | (e.metaKey ? 8 : 0);
5372
- }
5373
-
5374
- if (keyCode in keys.MODIFIER_KEYS) {
5375
- switch (keys.MODIFIER_KEYS[keyCode]) {
5376
- case "Alt":
5377
- hashId = 2;
5378
- break;
5379
- case "Shift":
5380
- hashId = 4;
5381
- break
5382
- case "Ctrl":
5383
- hashId = 1;
5384
- break;
5385
- default:
5386
- hashId = 8;
5387
- break;
5388
- }
5389
- keyCode = 0;
5390
- }
5391
-
5392
- if (hashId & 8 && (keyCode == 91 || keyCode == 93)) {
5393
- keyCode = 0;
5394
- }
5395
-
5396
- // If there is no hashID and the keyCode is not a function key, then
5397
- // we don't call the callback as we don't handle a command key here
5398
- // (it's a normal key/character input).
5399
- if (hashId == 0 && !(keyCode in keys.FUNCTION_KEYS)) {
5400
- return false;
5401
- }
5402
-
5403
- return callback(e, hashId, keyCode);
5404
- }
5405
-
5406
- exports.addCommandKeyListener = function(el, callback) {
5407
- var addListener = exports.addListener;
5408
- if (useragent.isOldGecko) {
5409
- // Old versions of Gecko aka. Firefox < 4.0 didn't repeat the keydown
5410
- // event if the user press