Compare commits

...

317 Commits

Author SHA1 Message Date
bootstraponline 091945152f Release 2.4.5 2012-12-10 18:05:38 -07:00
bootstraponline 4838611273 Fix #602 2012-12-07 17:16:25 -07:00
bootstraponline 144f9959c9 Update test #602 2012-12-07 17:02:50 -07:00
bootstraponline 291c6a8fa0 Add test for #602 2012-12-07 16:49:00 -07:00
bootstraponline d5d3581b78 Update gollum.gemspec 2012-12-06 18:17:41 -07:00
bootstraponline 64d90b027c Merge pull request #597 from shanebdavis/master
altered CSS to more closely match github's markdown css
2012-12-03 16:49:37 -08:00
Shane Brinkman-Davis a0e9989734 altered CSS to more closely match github's markdown css.
Main chaings:
Padding between LIs = 0px
Fixed page-width: 920px
H1, H2, H3: Margin-top: 20px; margin-bottom: 10px
2012-12-01 15:48:28 -08:00
bootstraponline b81aa923d6 Fix KCODE warning on 1.9 2012-11-30 23:35:01 -07:00
bootstraponline 610925bc5a Update Ace
https://github.com/ajaxorg/ace/commit/f887e6411222ed49683c477ca571460b99f8e59f
2012-11-30 23:34:55 -07:00
bootstraponline 86eda9bb10 Release 2.4.4 2012-11-30 17:28:53 -07:00
bootstraponline ca06aa9a6f Merge pull request #595 from jtietema/patch-1
Update lib/gollum/frontend/public/gollum/livepreview/js/livepreview.js
2012-11-30 16:11:47 -08:00
Jeroen Tietema ca57d9e83d Update lib/gollum/frontend/public/gollum/livepreview/js/livepreview.js
Adjusted the height of the preview window so that it doesn't flow 
offscreen. (It was impossible to read the last lines...)
2012-11-30 22:20:36 +01:00
bootstraponline 904f975f0c Fix comment 2012-11-30 00:02:24 -07:00
bootstraponline 9b9212cf4c Remove needless conversion
The fix for page.rb resolved UTF-8 in headers.
2012-11-30 00:00:28 -07:00
bootstraponline 404419d1c3 Release 2.4.3 2012-11-29 23:57:15 -07:00
bootstraponline 4ee94a6574 Fix UTF-8 header and add test 2012-11-29 23:47:25 -07:00
bootstraponline f929df0419 Update check_h1 2012-11-29 23:04:40 -07:00
bootstraponline 57587dafbe Fix UTF-8 in headers 2012-11-29 22:05:29 -07:00
bootstraponline 31a95e81b3 Fix test name 2012-11-29 21:36:04 -07:00
bootstraponline 70a4e9551b Improve h1 test 2012-11-29 21:27:45 -07:00
bootstraponline e1a705f975 Fix UTF-8
to_html uses source document encoding by default. Set UTF-8.

Add note about KCODE warning.
2012-11-29 20:05:41 -07:00
bootstraponline 9057ec82d8 Release 2.4.2 2012-11-29 19:49:15 -07:00
bootstraponline 1b53e36666 Fix UTF-8 2012-11-29 16:58:47 -07:00
bootstraponline 10fa5c7bd2 Upgrade to stringex 1.5 2012-11-29 16:50:52 -07:00
bootstraponline 06e72a5a60 Release 2.4.1 2012-11-19 17:22:28 -07:00
bootstraponline 8fa62fc300 @css is set in before 2012-11-19 17:16:53 -07:00
bootstraponline 6c345fc508 Update dependencies 2012-11-19 17:14:52 -07:00
bootstraponline a34eac4ecb Merge pull request #592 from dekimsey/global-custom-css
Fixed custom.css to apply to all views
2012-11-19 16:11:53 -08:00
bootstraponline 10c121e603 Merge pull request #585 from dekimsey/gitcode-embed-any-file
Modified gitcode to allow syntax highlighting of arbitrary files
2012-11-19 16:11:21 -08:00
Daniel Kimsey 2b910167f4 Fixed custom.css to apply to all views 2012-11-19 13:21:39 -05:00
Daniel Kimsey 7d5311a075 Modified gitcode to allow syntax highlighting of arbitrary files 2012-11-19 12:59:45 -05:00
bootstraponline f5581c4b49 Merge pull request #589 from shanebdavis/master
Fix #96
2012-11-18 19:25:05 -08:00
Shane Brinkman-Davis e09f7cd49c Proposed fix for https://github.com/github/gollum/issues/96
(statically hosted content in the images/ folder returns 404s)
(the problem was all content in javascript, css, and images folders was hard-coded to return 404s)
2012-11-18 09:53:27 -08:00
bootstraponline 4dab03b61b Merge pull request #588 from sunnyone/fix_host_option
Pass the value of --host parameter to Rack::Server
2012-11-17 13:04:38 -08:00
Yoichi Imai 2b5e017aa1 Pass the value of --host parameter to Rack::Server 2012-11-17 19:42:28 +09:00
bootstraponline 8b3d944fd2 Fix #586
Place ASCIIDOC test behind ENV var
2012-11-16 19:08:45 -07:00
bootstraponline 2d886fd38a Fix tests #587 2012-11-16 18:13:38 -07:00
bootstraponline 80088832b9 Fix #587
The default behavior prevented linking to header anchors. id_prefix
can still be set to 'wiki-' however it is no longer the default.
2012-11-16 17:45:56 -07:00
bootstraponline be1883f317 Use HTTPS rubygems
Update gemspec
2012-11-16 17:07:38 -07:00
bootstraponline 30119e0c77 Fix tests 2012-11-16 17:03:18 -07:00
bootstraponline c90c3b1544 Support git code syntax in live preview
Add autocrlf values for Windows, Linux, and OS X.
2012-11-16 16:57:39 -07:00
bootstraponline 578386f083 Add dir support to write_page 2012-11-16 16:43:43 -07:00
bootstraponline 3d21ed362e Add history view test 2012-11-14 21:03:24 -07:00
bootstraponline 9cf469b035 Fix ruby bits #574 2012-11-14 00:45:28 -07:00
bootstraponline 462c93ae43 Fix crash #574 2012-11-13 23:12:22 -07:00
bootstraponline bda3b7b24d Fix --user-icons 2012-11-13 22:56:30 -07:00
bootstraponline d861a22cdd Fix line endings 2012-11-13 22:55:57 -07:00
bootstraponline 0de1a182da Validate user_icons 2012-11-13 22:48:37 -07:00
bootstraponline b030554348 Fix default 2012-11-13 22:43:05 -07:00
bootstraponline 858bfa9ccd Merge pull request #574 from dekimsey/local-gravatar-identicons
Extendable user-icons with optional identicon js library.
2012-11-13 21:42:15 -08:00
Daniel Kimsey ee8ec78da7 Add --user-icons option: none, gravatar, and identicon. 2012-11-13 21:17:23 -05:00
bootstraponline c8f684895c Merge pull request #581 from dekimsey/log-opt-author
Changed history date to use authored date instead.
2012-11-13 16:54:14 -08:00
bootstraponline 138a155ba4 Merge pull request #582 from dekimsey/set-focus-buttons
On window popup, focus the first text-field, if any.
2012-11-13 16:53:34 -08:00
Daniel Kimsey ad749bf345 On window popup, focus the first text-field, if any. 2012-11-13 17:25:36 -05:00
Daniel Kimsey ff0d59c16b Changed history date to use authored date instead. 2012-11-13 15:02:55 -05:00
bootstraponline df75d2d60c Release 2.4.0 2012-11-11 15:08:45 -07:00
bootstraponline 2713aabeaf Update gemspec 2012-11-11 15:08:21 -07:00
bootstraponline 796d1b44c2 Update README.md 2012-11-11 14:46:58 -07:00
bootstraponline 470a7b8f52 Fix #579 2012-11-11 14:40:47 -07:00
bootstraponline f699b82a9f Fix #539 2012-11-11 14:18:14 -07:00
bootstraponline 44edb8c7da Merge pull request #576 from roman-zaharenkov/title_control
Page title control
2012-11-11 12:29:37 -08:00
bootstraponline bc4fc0edd9 Fix gitcode test 2012-11-11 13:14:25 -07:00
Roman Zaharenkov 6545fa691b Adjust page header / title generation.
Now page header can be generated by first h1 header from page content. But page title generated by URL is it was before.
2012-11-11 13:22:10 +03:00
Roman Zaharenkov 4954553927 Page title control
Allow to set page title by setting header inside page body. It will use header as title If header is present and page URL otherwise.
2012-11-11 13:20:14 +03:00
bootstraponline 9c50ba9eeb XSLT was never used 2012-11-10 17:02:27 -07:00
bootstraponline 9a67da145a Merge pull request #578 from github/fileview-hover-fix
Fileview hover fix
2012-11-10 15:59:28 -08:00
bootstraponline ca7d82278c Pretty print with nokogiri 2012-11-10 16:34:37 -07:00
bootstraponline f6245c53dd Add .gitattributes 2012-11-10 12:15:20 -07:00
bootstraponline 6888420cc6 Update file_view output 2012-11-10 12:15:19 -07:00
Daniel Kimsey c5631f5b7d Fixed a:hover not highlighting the a block correctly 2012-11-10 12:15:19 -07:00
Daniel Kimsey 34e0b49d72 Refactored the template generator to use new_page method 2012-11-10 12:15:19 -07:00
Daniel Kimsey bd072264ef Line-ending fix for _styles.css 2012-11-10 12:15:19 -07:00
bootstraponline cfb2d24c71 Merge pull request #577 from dekimsey/fix-page-metadata
Renamed page.meta_data => page.metadata
2012-11-09 18:03:12 -08:00
Daniel Kimsey fe0eb72fa3 Renamed page.meta_data to page.metadata for consistency with views 2012-11-09 18:29:49 -05:00
Daniel Kimsey 2783257f06 Added page.meta_data to tests 2012-11-09 18:25:33 -05:00
bootstraponline cc11cb866c Add css note
#572
2012-11-08 18:51:57 -07:00
bootstraponline 6a02643bda Merge pull request #573 from dekimsey/license-guidelines
Added bootstraponline's comment about licensing guidelines
2012-11-08 16:12:40 -08:00
Daniel Kimsey 7f269c8da3 Added bootstraponline's comment about licensing guidelines 2012-11-08 16:46:49 -05:00
bootstraponline ef7f7cebd1 Release 2.3.12 2012-11-07 20:37:50 -07:00
bootstraponline 05c24fd5e3 Fix #570
Fix #571
2012-11-07 20:35:57 -07:00
bootstraponline b08b97bd28 Release 2.3.11 2012-11-07 20:18:43 -07:00
bootstraponline dbb6ce2f71 Fix #570
Error in gollum.js broke new page button.
2012-11-07 20:17:50 -07:00
bootstraponline f66f14b593 Release 2.3.10 2012-11-07 19:47:09 -07:00
bootstraponline 8a52315dee Add base url to custom css 2012-11-07 19:46:27 -07:00
bootstraponline 7c4052906c Add custom css 2012-11-07 19:40:52 -07:00
bootstraponline 3a56f39f6a Fix readme 2012-11-07 19:17:49 -07:00
bootstraponline 6585ca5dd0 Fix space 2012-11-07 19:13:57 -07:00
bootstraponline 792abae07e Release 2.3.9 2012-11-07 19:11:04 -07:00
bootstraponline 74ce648c59 Options.fetch 2012-11-07 19:04:36 -07:00
bootstraponline 2686e96046 Release 2.3.8 2012-11-07 18:50:37 -07:00
bootstraponline 213e2bb432 Add config example 2012-11-07 18:48:07 -07:00
bootstraponline 79bb5c10ab Remove lib.so note 2012-11-07 18:46:36 -07:00
bootstraponline 7ea012d786 Fix code style 2012-11-07 18:45:20 -07:00
bootstraponline 43591f75de Merge pull request #570 from dekimsey/only-alert-on-changes
Only alert on changes
2012-11-07 17:39:30 -08:00
Daniel Kimsey 05d82c0569 Attach unsaved changes warning to trigger only after changes are made 2012-11-07 17:51:36 -05:00
Daniel Kimsey 76c8d3206c Consolidated create and edit page's javascript into the global gollum.js 2012-11-07 17:50:12 -05:00
bootstraponline 00751d05b4 Release 2.3.7 2012-11-06 18:27:05 -07:00
bootstraponline b5be5df11a Fix test name 2012-11-06 18:26:49 -07:00
bootstraponline 7d159273fc Merge pull request #569 from dekimsey/issue-568
Fixed #568, triple tilde without language causes Gollum to crash
2012-11-06 17:11:08 -08:00
Daniel Kimsey 70127922ab Added test for #568 2012-11-06 15:49:47 -05:00
Daniel Kimsey b95df93775 Fixes #568, triple-tilde without language causes crash 2012-11-06 15:39:39 -05:00
bootstraponline dc06edcf5b Add x.y.z 2012-11-05 17:30:01 -07:00
bootstraponline fdc437dcd5 Release 2.3.6 2012-11-05 17:28:51 -07:00
bootstraponline f6873c9612 Merge pull request #566 from dekimsey/deterministic-search
Gollum search results now displayed in a deterministic order
2012-11-05 16:17:40 -08:00
Daniel Kimsey 93754ab32d Sort by filename in addition to count 2012-11-05 18:01:50 -05:00
Daniel Kimsey 5759334635 Gollum search results are displayed in a deterministic order 2012-11-05 17:02:19 -05:00
bootstraponline f2f543b72d Release 2.3.5 2012-10-31 20:14:15 -06:00
bootstraponline 598b052be3 Fix clean
Duplicate slashes must be removed everywhere.
2012-10-31 20:11:23 -06:00
bootstraponline a746062422 Merge pull request #564 from nikitug/patch-1
Update README to new Sequence diagram markup style
2012-10-31 19:09:45 -07:00
Nikita Afanasenko c8868d369f Update README to new Sequence diagram markup style 2012-10-31 18:02:28 +04:00
bootstraponline 52c6e7474c Release 2.3.4 2012-10-28 20:59:06 -06:00
bootstraponline be81f09b0e Update gemspec 2012-10-28 12:43:51 -06:00
bootstraponline 6fa4504e31 Fix #551 2012-10-28 12:37:02 -06:00
bootstraponline 992ba01a12 Fix page file dir 2012-10-28 11:57:25 -06:00
bootstraponline 72c5a74cf1 Update test
The test passes when verified manually using bin/gollum. Without a running server the test
will fail so it has been commented out. If there's an easy way to mock Rack::Server
then the test can be restored.
2012-10-27 23:44:11 -06:00
bootstraponline 919f41a0f1 Fix #559 2012-10-27 23:44:11 -06:00
bootstraponline 785921cb0f Fix toc generation 2012-10-27 21:46:30 -06:00
bootstraponline 8c8cda5e7d Fix comment 2012-10-27 21:05:56 -06:00
bootstraponline 64ef74e7e9 Add preview button to live preview 2012-10-27 20:52:54 -06:00
bootstraponline 776df4e6ee Fix nokogiri rendering
https://github.com/sparklemotion/nokogiri/issues/782
2012-10-27 19:52:26 -06:00
bootstraponline 68465a8651 Set indent and encoding 2012-10-27 18:12:32 -06:00
bootstraponline fa16c8960c Fix #560 2012-10-27 17:58:14 -06:00
bootstraponline 2c57915781 Refactor fileview 2012-10-23 23:27:31 -06:00
bootstraponline d0527f1aeb Release 2.3.3 2012-10-23 22:58:41 -06:00
bootstraponline 75083c5b56 Fix collapse tree 2012-10-23 22:36:17 -06:00
bootstraponline 82526594db Add attr reader for collapse tree 2012-10-23 22:22:56 -06:00
bootstraponline 941d39800c Merge pull request #556 from adiknoth/fileview
Documentation and usability enhancement of recent fileview fix
2012-10-23 21:20:28 -07:00
bootstraponline a1ae2e8bc0 Fix #554 2012-10-23 22:14:45 -06:00
bootstraponline 4af6f366ca Fix show_all /pages 2012-10-23 22:09:27 -06:00
Adrian Knoth c7a9534ed9 Add --collapse-tree command line option 2012-10-23 14:27:15 +02:00
Adrian Knoth 00bcbbf72b File View: Add option to collapse file trees.
For potentially large repositories, starting with a collapsed tree may
be beneficial.
2012-10-23 14:27:12 +02:00
Adrian Knoth ed2254ff9f Add missing documentation for --show-all 2012-10-23 14:22:54 +02:00
bootstraponline b6633f0ecb Release 2.3.2 2012-10-22 19:21:10 -06:00
bootstraponline e08d2d3052 Enable show_all for /pages 2012-10-22 19:10:40 -06:00
bootstraponline fbc0548b43 Add --show-all
--show-all will show all files in file view (not just valid pages). Default is false.
2012-10-22 19:03:21 -06:00
bootstraponline a9807bd1e1 Update math note 2012-10-21 17:22:31 -06:00
bootstraponline 554b80b39d Add MathJax examples 2012-10-21 17:21:24 -06:00
bootstraponline 99e74bf00b Release 2.3.1 2012-10-21 17:16:40 -06:00
bootstraponline f48e923f28 Fix release 2012-10-21 17:15:09 -06:00
bootstraponline 5400b4bfdd Support inline and display math.
$$2^2$$

$2^2$

\\(2^2\\)

[2^2]
2012-10-21 17:15:09 -06:00
bootstraponline f68bebe0f6 Update math note 2012-10-21 16:26:35 -06:00
bootstraponline 4c6019b439 Update math note 2012-10-21 16:23:58 -06:00
bootstraponline 66e08a6b17 Release 2.3.0 2012-10-21 16:19:05 -06:00
bootstraponline 7898db70ed Auto load all MathJax extensions
Fix #549
2012-10-21 16:14:04 -06:00
bootstraponline 7c357116ff Remove TeX
As discussed with @vmg
MathJax is available via a flag for those self hosting gollum
2012-10-18 23:36:05 -06:00
bootstraponline 69ce0eb0d0 Update rake 2012-10-17 21:04:20 -06:00
bootstraponline 4db31a297b Update rake
Jekyll uses rake ~> 0.9
2012-10-17 21:03:29 -06:00
bootstraponline e1fca457e4 Restore gemnasium
Gemnasium fixed the missing pygments.rb issue.

https://github.com/laserlemon/gemnasium-parser/commit/c9b3e43c3021967d5c1bb115e7dd1555e01c6444
2012-10-17 20:54:01 -06:00
bootstraponline 7f8485ce80 Improve system requirements language 2012-10-16 22:31:25 -06:00
bootstraponline 290061fd11 Add system requirements to readme 2012-10-16 22:15:26 -06:00
bootstraponline a507836936 Update dependencies 2012-10-16 21:39:22 -06:00
bootstraponline 6524d20a96 Use pygments.rb 0.3.2 2012-10-16 21:36:37 -06:00
bootstraponline f1c523aa30 Release 2.2.9 2012-10-14 22:26:17 -06:00
bootstraponline 87c08f5613 Escape " in headers 2012-10-14 22:21:00 -06:00
bootstraponline 82913cea20 Improve base path note 2012-10-14 21:42:25 -06:00
bootstraponline 2ad743e4bd Release 2.2.8 2012-10-14 21:28:43 -06:00
bootstraponline fa97b57a96 Define default map as suggested on #460
Base path now sets a default map without having to use an external config.ru.
2012-10-14 20:57:27 -06:00
bootstraponline 1b952b6d56 Release 2.2.7 2012-10-14 17:24:33 -06:00
bootstraponline 90cc512bd1 Fix home loop with page-file-dir #491 2012-10-14 15:45:26 -06:00
bootstraponline b82556c9c0 Fix #460 2012-10-14 15:42:06 -06:00
bootstraponline fbe3b4bb3b Fix #460 2012-10-14 15:23:52 -06:00
bootstraponline 5ffd98ad31 Fix #491 2012-10-14 15:15:55 -06:00
bootstraponline cb9dd4d228 Fix formatting 2012-10-14 14:31:40 -06:00
bootstraponline cd823bf10c Add doc from wiki.rb 2012-10-14 14:31:00 -06:00
bootstraponline 5560ec52c2 Add base_path doc 2012-10-14 14:27:08 -06:00
bootstraponline 065151a77f Add base_path disclaimer 2012-10-14 14:25:27 -06:00
bootstraponline 23454f556c Release 2.2.6 2012-10-14 13:14:08 -06:00
bootstraponline a2b3ddf931 Update tests to XHTML 2012-10-14 13:07:18 -06:00
bootstraponline 44b0d2fcfc Remove old comment 2012-10-14 12:26:23 -06:00
bootstraponline aed4cc590a Fix unicode characters
Fix #547

Update test
2012-10-14 12:21:31 -06:00
bootstraponline 72ee08b5ab Release 2.2.5 2012-10-14 11:21:56 -06:00
bootstraponline 45547624e4 Improve tilde fence support
More than 3 tildes can be used. The code block must end with the same amount of tildes used to open the code block.

Fix #537

http://johnmacfarlane.net/pandoc/README.html#delimited-code-blocks
2012-10-14 11:02:45 -06:00
bootstraponline f928cfa8be Don't ship Lorem ipsum in gem 2012-10-13 20:21:08 -06:00
bootstraponline 988984846a Release 2.2.4 2012-10-13 20:01:57 -06:00
bootstraponline 1149618653 Fix #537 2012-10-13 19:53:41 -06:00
bootstraponline 168a033903 Remove old comment 2012-10-13 14:59:42 -06:00
bootstraponline 6a765c9791 Fix #537 2012-10-13 14:52:28 -06:00
bootstraponline e16ae7b511 Travis is having a bad day
E: There are problems and -y was used without --force-yes
before_install: 'sudo apt-get install -y asciidoc' returned false.
Done. Build script exited with: 1
2012-10-13 14:07:15 -06:00
bootstraponline 174334ea44 Remove comment 2012-10-13 13:58:56 -06:00
bootstraponline dbdf06930d Fix 2012-10-13 13:55:20 -06:00
bootstraponline c93e65ddc3 Merge branch 'master' of github.com:github/gollum 2012-10-13 13:32:19 -06:00
bootstraponline 56101ed264 Fix #535 and add test 2012-10-13 13:32:08 -06:00
bootstraponline 8269c8e574 TOC doesn't require ' 2012-10-13 13:11:31 -06:00
bootstraponline 2246419d1e Fix spacing 2012-10-13 13:09:20 -06:00
bootstraponline 118a0c318b Update comment 2012-10-13 13:06:15 -06:00
bootstraponline 5401cf2910 Fix #542 2012-10-13 13:04:51 -06:00
bootstraponline 432f9b8d2f Add test for #542 2012-10-13 12:57:58 -06:00
bootstraponline 66fc8a2d31 Revert "Fix #542"
This reverts commit 2f3dd3d227.
2012-10-13 12:55:43 -06:00
bootstraponline 2f3dd3d227 Fix #542
Page link may contain duplicate starting forward slashes.
//page points to http://page/ when what we want is
/page pointing to http://localhost:1234/page
2012-10-13 09:53:25 -06:00
bootstraponline c43fd9fa6c Update language comment 2012-10-12 21:19:24 -06:00
bootstraponline 868518e0f5 Bash is Ace mode sh 2012-10-12 20:58:05 -06:00
bootstraponline 039b5cce98 Try to fix Travis
FFI is no longer used in the new pygments.rb.
apt-get update may resolve the asciidoc install failure.
2012-10-12 20:24:31 -06:00
bootstraponline 4a421842d5 https://github.com/travis-ci/travis-ci/issues/725
Modified README to trigger a Travis CI build. It's currently broken.
2012-10-12 20:22:10 -06:00
bootstraponline cfbb124f81 Update README.md 2012-10-12 20:16:43 -06:00
bootstraponline dcb147cde2 Ensure declaredLanguage is lower case 2012-10-10 20:20:33 -06:00
bootstraponline 8d06b5e67e Fix pygments language to Ace mode translation 2012-10-10 20:16:04 -06:00
bootstraponline 4776d0b422 Use rake release in readme 2012-10-10 19:45:42 -06:00
bootstraponline 58bb340c33 Release 2.2.3 2012-10-10 19:43:30 -06:00
bootstraponline ee790a9b7c Add rake bump to readme 2012-10-10 19:38:53 -06:00
bootstraponline ac432aad78 Add bump task to Rakefile 2012-10-10 19:35:04 -06:00
bootstraponline 30207e0a39 Merge pull request #533 from wrs/wrs_syntaxfixes
Two little syntax highlighting fixes
2012-10-10 16:56:37 -07:00
Walter Smith d98547a33c Fix lack of CoffeeScript livepreview
Pygments calls it coffeescript, but Ace calls it coffee.
2012-10-10 14:20:50 -07:00
Walter Smith b7cdeabbf6 Catch all Pygments errors
An unrecognized language was generating a MentosError rather than a
PythonError. Just catch anything that goes wrong in Pygments.
2012-10-10 14:20:50 -07:00
bootstraponline be9907a0cc v2.2.2 2012-10-04 18:17:24 -06:00
bootstraponline 30f42c50a9 Fix #528 2012-10-04 17:18:47 -06:00
bootstraponline 7cba65b138 Gemnasium is not including all deps.
pygments.rb is missing for example. Will restore once Gemnasium has fixed the issue.
2012-10-01 23:50:35 -06:00
bootstraponline f34a78b336 Proc.new instead of lambda. 2012-10-01 23:45:04 -06:00
bootstraponline e1942dda03 Merge pull request #513 from bootstraponline/embed_code
Embed code. #508.
2012-10-01 22:36:25 -07:00
bootstraponline 7142e284fa .call instead of .() for 1.8.7 2012-10-01 23:29:15 -06:00
bootstraponline 3c1c588953 Restore wiki_factory. 2012-10-01 23:23:40 -06:00
bootstraponline 52cc6bae34 Update dependencies. 2012-09-29 13:50:11 -06:00
bootstraponline 955c608115 Update rake. 2012-09-29 13:40:02 -06:00
bootstraponline 2e00cf312c Merge pull request #524 from osener/patch-1
Update org-ruby
2012-09-29 12:17:59 -07:00
Ozan Sener 09bbc144d1 Update org-ruby
Fixes #81
2012-09-29 11:19:09 +03:00
bootstraponline d02b63a434 Fix test. 2012-09-26 00:08:11 -06:00
bootstraponline 9b63c67d8c Try to fix tests. 2012-09-25 23:57:35 -06:00
bootstraponline 05c4bf3374 Add local file support.
Example of absolute path to local file.
```html:/home```

Example of relative path to local file.
```html:home```

1.8.7 string fix. 's'[0..0] instead of 's'[0]

Fix regex.

Add absolute and relative tests.
2012-09-25 23:31:58 -06:00
bootstraponline 424b4d3f4e Remove debug statements. 2012-09-25 23:31:25 -06:00
bootstraponline f9a6187fab Fix undefined method `[]' for nil:NilClass 2012-09-25 23:31:08 -06:00
Henrik d406472882 1.8.7 fixes 2012-09-25 23:29:11 -06:00
Henrik 749b5a5ff8 Adding functionality for fetching code from github
hack for 1.8.7

Don't miss test_markup's relative require

need some food now
2012-09-25 23:29:08 -06:00
bootstraponline 091d5fe750 Update multibyte caracters. 2012-09-25 22:58:07 -06:00
bootstraponline c8894fb465 New pygments.rb works correctly.
The expected output from the tests differs only in newlines.

git diff makes it seem like everything changed. bzr qdiff has a better default diff. git doesn't do per char diffs.

Revert "New pygments has issues."

This reverts commit 2dd41cbfac.
2012-09-25 22:45:57 -06:00
bootstraponline 2dd41cbfac New pygments has issues.
Revert "Update pygments. Solves #225 #490 #517"

This reverts commit c0c77c5ba7.

Revert "Fix pygments.rb tests."

This reverts commit 1f2165e68b.
2012-09-25 21:54:49 -06:00
bootstraponline 1f2165e68b Fix pygments.rb tests. 2012-09-25 21:47:24 -06:00
bootstraponline e9b6bdbdd7 Add dependency status. 2012-09-25 21:38:09 -06:00
bootstraponline c0c77c5ba7 Update pygments. Solves #225 #490 #517 2012-09-25 21:36:37 -06:00
Corey Donohoe 12403172ac Merge pull request #521 from Vanuan/update_nokogiri
Update nokogiri
2012-09-25 12:16:50 -07:00
John Yani 3b41ab8d75 Update nokogiri 2012-09-25 22:04:43 +03:00
bootstraponline 7bcf35f5b1 Fix #517. Thanks @roa 2012-09-23 16:26:48 -06:00
bootstraponline 9a7e1c94c7 Merge pull request #515 from realmacsoftware/master
Populate author details using the session.
2012-09-16 10:32:33 -07:00
Keith Duncan 30c2e675da Test that author details from the session are committed into the repository 2012-09-16 16:49:17 +01:00
Keith Duncan ac405803e8 Add notes on providing author details to the Rack documentation section 2012-09-16 16:25:09 +01:00
Keith Duncan 7dee787a92 Add documentation for where the commit_message parameters are passed and where they're source from 2012-09-16 15:59:49 +01:00
Keith Duncan ae4b1cdeca Add support for author parameters coming in from the session, to be set by rack middleware further up the stack 2012-09-15 21:06:08 +01:00
bootstraponline 572982cbf9 Use a professional right left button. 2012-09-09 21:11:16 -06:00
bootstraponline 74290874f9 Fix #383 test. 2012-09-09 14:05:10 -06:00
bootstraponline 847f08d952 Use block form of gsub to avoid regexp backref interpolation
The content of this commit message is from @kislyuk's comments on the below two issues.

Fix #383
Fix #511

`gsub!(pattern, replacement) interpolates` regexp backreferences
`gsub!(pattern) do block` doesn't

http://stackoverflow.com/questions/2082457/ruby-gsub-problem-when-using-backreference-and-hashes
2012-09-09 12:22:56 -06:00
Neal Pisenti 0bcd616668 fix mathjax option, fixes #509 2012-09-09 11:50:48 -06:00
bootstraponline 9dd701ccc4 Grit is broken. #508 #356 2012-09-04 17:52:56 -06:00
bootstraponline 56a5a7d92b Fix #507 2012-09-04 16:24:16 -06:00
bootstraponline 0cf0fad50e Finish removing MathJax from Live Preview. 2012-09-02 15:27:32 -06:00
bootstraponline 5f9e91656e Fix LaTeX tests. 2012-09-02 15:03:56 -06:00
Vicent Marti a7a2479f85 Release 2.2.1 2012-09-02 22:43:50 +02:00
Vicent Marti a8b230a490 Properly escape TeX data. 2012-09-02 22:27:04 +02:00
bootstraponline 041b01f171 Fix #490 2012-09-01 12:33:08 -06:00
Vicent Marti 1c475f3215 Release 2.2.0 2012-09-01 12:24:17 +02:00
Vicent Marti ab699d94b0 Do not render LaTeX locally
Offload the rendering service to MathTran.org, the free and open-source
LaTeX rendering engine.
2012-09-01 12:23:02 +02:00
bootstraponline 942d32c9b6 Fix uninstall command 2012-08-30 21:36:11 -06:00
bootstraponline 97f15f0b18 Add edit hotkey. #496 2012-08-30 21:07:57 -06:00
bootstraponline ed49358c50 Add h1-3 shortcuts. #496 2012-08-30 20:54:20 -06:00
bootstraponline 85eeecd140 Add save hotkey. 2012-08-30 20:48:44 -06:00
bootstraponline 30fd40fbe5 Fix #498
Ruby 1.8.7 and ri can't deal with <!-- appearing in documentation.
Please upgrade to the latest Ruby if you're able to.
2012-08-30 20:29:53 -06:00
bootstraponline 2ed262cacd v2.1.9 2012-08-30 20:12:28 -06:00
bootstraponline 29a1ef8f8a Skip doc on install 2012-08-30 20:04:20 -06:00
bootstraponline 772d18ee62 Fix uninstall command 2012-08-30 20:00:54 -06:00
bootstraponline dd604d9942 Fix #498 2012-08-30 19:57:20 -06:00
bootstraponline 85abc83427 v2.1.8 2012-08-30 19:41:54 -06:00
bootstraponline 6d8220629c Fix #500 2012-08-30 19:37:57 -06:00
bootstraponline 6ff7ada096 Fix #495 2012-08-30 18:31:35 -03:00
bootstraponline 8575049de5 Update get /data
Remove leading slash from page
Fix edge case with path set to '/'
2012-08-30 11:40:07 -03:00
bootstraponline bb6fb0c253 pathName is undefined when not found instead of 0 2012-08-30 11:18:02 -03:00
bootstraponline eb2ad9f840 Fix path
.key now returns undefined on failure so path can be 0.
If path is undefined then use an empty string.
2012-08-30 11:14:24 -03:00
bootstraponline d0dd23fc11 Fix path 2012-08-30 11:09:44 -03:00
bootstraponline 7ae4acbdb0 Fix #497 #492
Data url now includes path.
2012-08-30 11:03:11 -03:00
bootstraponline 881590ab37 Merge pull request #494 from releu/fix-requiring-uri-encoding-components
Move require "uri_encode_component"
2012-08-28 18:33:18 -07:00
Jan Bernacki 5e479dc5d9 move require 2012-08-28 22:44:09 +04:00
bootstraponline 7db9c2e762 Merge pull request #487 from jm/master
Fix bug with missing variable 'ext'
2012-08-27 11:08:19 -07:00
bootstraponline ce6b0ac095 v2.1.7 2012-08-25 19:21:13 -06:00
bootstraponline 420bb06988 Fix create test. 2012-08-25 18:58:20 -06:00
bootstraponline 20566f8acf Fix #484 2012-08-25 18:54:07 -06:00
bootstraponline 1d5f69704a Clean paths so they start with one slash. 2012-08-25 18:41:13 -06:00
bootstraponline 0da664299e Fix edit. 2012-08-24 13:47:17 -06:00
bootstraponline 6e8fb2b457 Disable exact on edit for now. 2012-08-24 13:38:34 -06:00
bootstraponline d1c72a4ff3 Fix #483 and #481
Exact matching of requested pages

- /page is no longer the same as /a/page
- Deleting /page only deletes /page (before it would delete /a/page instead of /page)
- Edit currently breaks the unit tests if exact matching is enabled
- Fix redirect on create
- Add @giga's checked_dir = '' fix https://github.com/giga/gollum/commit/936958b47324a09c683cb90a2560484b47e09529
- Fix create unit test
2012-08-24 13:35:37 -06:00
bootstraponline 0bf05392e4 Redirect to correct path. #481 2012-08-24 12:26:59 -06:00
bootstraponline 7ecef0c045 Fix #479 2012-08-23 14:11:28 -06:00
bootstraponline 33ca329253 Handle nil slash. 2012-08-23 12:30:08 -06:00
bootstraponline 01fa4770cb Fix page lookup. #473 2012-08-23 12:16:40 -06:00
bootstraponline b76257c49c Restore foward slash. 2012-08-23 11:59:56 -06:00
bootstraponline e2fbf22f38 Fix #473. 2012-08-23 11:51:20 -06:00
bootstraponline 134432d029 v2.1.6 2012-08-23 11:33:00 -06:00
bootstraponline 8d4d6e80b8 Fix #475. 2012-08-23 11:27:40 -06:00
bootstraponline 85e6ef3dca v2.1.5 2012-08-22 19:57:22 -06:00
bootstraponline 60f1467229 Fix encoding for 1.8. 2012-08-22 18:51:41 -06:00
bootstraponline 1757242382 Don't unpack Fixnum. 2012-08-22 17:40:53 -06:00
bootstraponline 55df7bb9c4 Use encodeURIComponent instead of CGI::escape when output is sent to browser. 2012-08-22 17:30:46 -06:00
bootstraponline 686b8acd38 Fix encodeURIComponent on Ruby 1.8.
Replace .ord with .unpack('U')[0]
2012-08-22 17:23:08 -06:00
bootstraponline a5f9df6170 Restore CGI::escape. 2012-08-22 16:57:24 -06:00
bootstraponline 27f61a870a Merge pull request #477 from LuminosoInsight/master
Fix titles created with the "New" button.
2012-08-22 15:54:23 -07:00
bootstraponline a48e8d1c5c New editor style.
Disable MathJax in live preview. Parser isn't MathJax aware.
Performance of MathJax in live preview is not great.
Auto hide editor overflow.
2012-08-22 16:50:57 -06:00
bootstraponline b80f74bccd Remove protocol and host. 2012-08-22 13:32:18 -06:00
bootstraponline 1e768734ef Disable MathJax by default.
GitHub.com doesn't support MathJax. The parser is not MathJax aware which causes problems.

--mathjax enables MathJax.
2012-08-22 13:31:21 -06:00
bootstraponline 11c9cabeb3 Fix edit baseUrl. 2012-08-22 13:21:01 -06:00
bootstraponline 3a14ab92f0 Fix new page when using map '/wiki' in config.ru. 2012-08-22 13:15:18 -06:00
bootstraponline 62d5f52398 Fix anchor for Firefox. 2012-08-22 13:10:11 -06:00
Rob Speer 2b4848566c Fix names created with the 'New' button.
Previously, a page created with the 'New' button would get all of its
spaces turned into the + symbol when submitted, which Gollum would then
convert into "-plus-" in the title. So, for example, a request to create
a page called "Test page" would instead get "test plus page".

This change changes + to - in the parameter received by /create/.
2012-08-22 14:15:20 -04:00
bootstraponline 7c825e877c Remove protocol + host. 2012-08-20 15:51:07 -06:00
bootstraponline 8417c277e6 Fix delete link when using baseUrl. 2012-08-20 15:23:07 -06:00
bootstraponline 9cef423908 Remove default value in new page. 2012-08-19 14:25:02 -06:00
bootstraponline e73c84490e Remove prefix. #470. 2012-08-16 12:01:03 -06:00
bootstraponline 6cfc807db0 Revert still broken in Grit. 2012-08-15 12:22:03 -06:00
bootstraponline be366f8103 v2.1.4 2012-08-15 12:06:12 -06:00
bootstraponline 2d13bd796f Improve #470 fix. 2012-08-15 12:03:48 -06:00
bootstraponline 523f8f80ca Fix #470. 2012-08-15 11:48:17 -06:00
bootstraponline b76fef9143 Update version to 2.1.3 2012-08-13 11:37:56 -06:00
bootstraponline e935af83d5 Update gemspec. 2012-08-13 11:35:15 -06:00
bootstraponline d4e019ef42 Merge pull request #331 from tjh/home-page-link-issue
Redirect from root to /Home, fixes #250
2012-08-09 10:41:31 -07:00
bootstraponline 2e738828c6 Merge pull request #467 from jamesduncombe/pygments_initialize
Added Pygments.start to initialize Pygments on startup, fixes #465
2012-08-09 10:21:59 -07:00
James Duncombe fd7dc93778 Added Pygments.start to initialize Pygments on startup 2012-08-09 09:14:55 +01:00
bootstraponline 3df407d9ee Merge pull request #464 from giga/master
Fix editor when base url is '/'
2012-08-08 10:53:45 -07:00
Jean-Philippe Garcia Ballester 6fbba84725 Revert "Base path is relative."
This reverts commit 69e453ea0b.
2012-08-08 13:49:11 +02:00
Jean-Philippe Garcia Ballester 37d20fa9cc Base url without trailing '/'
This will allow cleaner url in templates and javascripts.
2012-08-08 13:49:09 +02:00
bootstraponline 410cd912ac Fix releasing. 2012-08-06 18:31:36 -06:00
bootstraponline d234bbd861 Test get %r{/(.+?)/([0-9a-f]{40})} do 2012-08-06 18:27:12 -06:00
Jeremy McAnally 3767a11d21 Rename variables to be more clear and fix reference to non-existent 'ext' variable 2012-07-04 12:33:09 -04:00
Tim Harvey 43d2143506 Redirect from root to /Home, fixes #250 2012-05-10 08:55:56 -04:00
473 changed files with 75026 additions and 94476 deletions
+32
View File
@@ -0,0 +1,32 @@
# https://help.github.com/articles/dealing-with-line-endings
#
# For Mac & Linux
# git config --global core.autocrlf input
#
# For windows
# git config --global core.autocrlf true
#
# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto
# Explicitly declare text files we want to always be normalized and converted
# to native line endings on checkout.
*.txt text
*.md text
*.rb text
*.js text
*.html text
*.yml text
*.mustache text
*.css text
Rakefile text
Gemfile text
LICENSE text
COPYRIGHT text
gollum text
.gitattributes text
.gitignore text
# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
+1
View File
@@ -4,3 +4,4 @@ pkg
.bundle
Gemfile.lock
*.gem
*.swp
+3 -2
View File
@@ -4,5 +4,6 @@ rvm:
notifications:
disabled: true
before_install:
- gem uninstall ffi -a
- sudo apt-get install -y asciidoc
- sudo apt-get update
- sudo apt-get install -y --force-yes asciidoc
- ASCIIDOC=1; export ASCIIDOC
+2 -2
View File
@@ -1,4 +1,4 @@
source "http://rubygems.org"
source 'https://rubygems.org'
gemspec
gem "rake", "~> 0.9.2"
gem 'rake', '~> 10.0.2'
+79 -23
View File
@@ -2,6 +2,7 @@ gollum -- A wiki built on top of Git
====================================
[![Build Status](https://secure.travis-ci.org/github/gollum.png?branch=master)](http://travis-ci.org/github/gollum)
[![Dependency Status](https://gemnasium.com/github/gollum.png)](https://gemnasium.com/github/gollum)
## DESCRIPTION
@@ -18,6 +19,11 @@ number of ways depending on your needs. You can edit your wiki locally:
Gollum follows the rules of [Semantic Versioning](http://semver.org/) and uses
[TomDoc](http://tomdoc.org/) for inline documentation.
## SYSTEM REQUIREMENTS
- Python 2.5+ (2.7.3 recommended)
- Ruby 1.8.7+ (1.9.3 recommended)
- Unix like operating system (OS X, Ubuntu, Debian, and more)
- Will not work on Windows (because of [grit](https://github.com/github/grit))
## INSTALLATION
@@ -130,7 +136,13 @@ or JavaScript. These tags will be stripped from the converted HTML. See
`docs/sanitization.md` for more details on what tags and attributes are
allowed.
## TITLES
The first defined `h1` will override the default header on a page. There are two ways to set a page title. The metadata syntax:
`<!-- --- title: New Title -->`
The first `h1` tag can be set to always override the page title, without needing to use the metadata syntax. Start gollum with the `--h1-title` flag.
## BRACKET TAGS
A variety of Gollum tags use a double bracket syntax. For example:
@@ -295,7 +307,7 @@ This is useful for writing about the link syntax in your wiki pages.
Gollum has a special tag to insert a table of contents (new in v2.1)
'[[_TOC_]]
[[_TOC_]]
This tag is case sensitive, use all upper case. The TOC tag can be inserted
into the `_Header`, `_Footer` or `_Sidebar` files too.
@@ -334,27 +346,40 @@ then that whitespace will be ignored (this makes the blocks easier to read in pl
The block must end with three backticks indented at the same level than the opening
backticks.
### GITHUB SYNTAX HIGHLIGHTING
As an extra feature, you can syntax highlight a file from your repository, allowing
you keep some of your sample code in the main repository. The code-snippet is
updated when the wiki is rebuilt. You include github code like this:
```html:github/gollum/master/test/file_view/1_file.txt```
This will make the builder look at the **github user**, in the **gollum project**,
in the **master branch**, at path **test/file_view/1_file.txt**. It will be
rewritten to:
```html
<ol class="tree">
<li class="file"><a href="0">0</a></li>
</ol>
```
Which will be parsed as HTML code during the Pygments run, and thereby coloured
appropriately.
## MATHEMATICAL EQUATIONS
Start gollum with the `--mathjax` flag. Read more about [MathJax](http://docs.mathjax.org/en/latest/index.html) on the web. Gollum uses the `TeX-AMS-MML_HTMLorMML` config with the `autoload-all` extension.
Page files may contain mathematic equations in TeX syntax that will be nicely
typeset into the expected output. A block-style equation is delimited by `\[`
and `\]`. For example:
Inline math:
\[ P(E) = {n \choose k} p^k (1-p)^{ n-k} \]
- $2^2$
- `\\(2^2\\)`
Inline equations are delimited by `\(` and `\)`. These equations will appear
inline with regular text. For example:
Display math:
The Pythagorean theorem is \( a^2 + b^2 = c^2 \).
### INSTALLATION REQUIREMENTS
In order to get the mathematical equations rendering to work, you need the following binaries:
* LaTex, TeTex or MacTex/BasicTeX (pdflatex)
* Netpbm (pnmcrop, pnmpad, pnmscale, ppmtopgm, pnmgamma, pnmtopng)
* Ghostscript (gs)
- $$2^2$$
- [2^2]
## SEQUENCE DIAGRAMS
@@ -362,10 +387,10 @@ You may imbed sequence diagrams into your wiki page (rendered by
[WebSequenceDiagrams](http://www.websequencediagrams.com) by using the
following syntax:
{{{ blue-modern
{{{{{{ blue-modern
alice->bob: Test
bob->alice: Test response
}}}
}}}}}}
You can replace the string "blue-modern" with any supported style.
@@ -392,6 +417,17 @@ By default, internal wiki links are all absolute from the root. To specify a dif
wiki = Gollum::Wiki.new("my-gollum-repo.git", :base_path => "/wiki")
Note that base_path just modifies the links. To map gollum to a non-root location:
- Use the gollum binary: `gollum path/to/wiki --base-path mywiki`
- Define config.ru with `map`. See [#532](https://github.com/github/gollum/issues/532) for an example.
> :base_path - String base path for all Wiki links.
>
> The String base path to prefix to internal links. For example, when set
> to "/wiki", the page "Hobbit" will be linked as "/wiki/Hobbit". Defaults
> to "/".
Get the latest version of the given human or canonical page name:
page = wiki.page('page-name')
@@ -497,9 +533,23 @@ like Rack::Auth, OmniAuth, etc.
Precious::App.set(:wiki_options, {:universal_toc => false})
run Precious::App
## Windows Filename Validation
Your Rack middleware can pass author details to Gollum in a Hash in the session under the 'gollum.author' key.
## WINDOWS FILENAME VALIDATION
Note that filenames on windows must not contain any of the following characters `\ / : * ? " < > |`. See [this support article](http://support.microsoft.com/kb/177506) for details.
## CONFIG FILE
Gollum optionally takes a `--config file`. See [config.rb](https://github.com/github/gollum/blob/master/config.rb) for an example.
## CUSTOM CSS
The `--css` flag will inject `custom.css` from the root of your git repository into each page. `custom.css` must be commited to git or you will get a 302 redirect to the create page. Here's an example of floating the sidebar to the left.
```css
#wiki-rightbar { float: left !important; }
```
## CONTRIBUTE
If you'd like to hack on Gollum, start by forking my repo on GitHub:
@@ -520,14 +570,20 @@ your changes merged back into core is as follows:
1. Send a pull request to the github/gollum project.
## RELEASING
x.y.z
For z releases:
$ rake bump
$ rake release
For x.y releases:
Update VERSION in lib/gollum.rb
$ rake gemspec
$ gem build gollum.gemspec
$ gem push gollum-X.Y.Z.gem
$ rake release
## BUILDING THE GEM FROM MASTER
$ gem uninstall -aix gollum
$ gem uninstall -aIx gollum
$ git clone https://github.com/github/gollum.git
$ cd gollum
gollum$ rake build
gollum$ gem install pkg/gollum*.gem
gollum$ gem install --no-ri --no-rdoc pkg/gollum*.gem
+32 -3
View File
@@ -17,6 +17,27 @@ def version
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
end
# assumes x.y.z all digit version
def next_version
# x.y.z
v = version.split '.'
# bump z
v[-1] = v[-1].to_i + 1
v.join '.'
end
def bump_version
old_file = File.read("lib/#{name}.rb")
old_version_line = old_file[/^\s*VERSION\s*=\s*.*/]
new_version = next_version
# replace first match of old vesion with new version
old_file.sub!(old_version_line, " VERSION = '#{new_version}'")
File.write("lib/#{name}.rb", old_file)
new_version
end
def date
Date.today.to_s
end
@@ -71,7 +92,14 @@ end
#
#############################################################################
desc "Update version number and gemspec"
task :bump do
puts "Updated version to #{bump_version}"
# Execute does not invoke dependencies.
# Manually invoke gemspec then validate.
Rake::Task[:gemspec].execute
Rake::Task[:validate].execute
end
#############################################################################
#
@@ -86,6 +114,7 @@ task :release => :build do
exit!
end
sh "git commit --allow-empty -a -m 'Release #{version}'"
sh "git pull"
sh "git tag v#{version}"
sh "git push origin master"
sh "git push origin v#{version}"
@@ -117,7 +146,7 @@ task :gemspec => :validate do
split("\n").
sort.
reject { |file| file =~ /^\./ }.
reject { |file| file =~ /^(rdoc|pkg)/ }.
reject { |file| file =~ /^(rdoc|pkg|test|Home\.md|\.gitattributes)/ }.
map { |file| " #{file}" }.
join("\n")
@@ -139,4 +168,4 @@ task :validate do
puts "A `VERSION` file at root level violates Gem best practices."
exit!
end
end
end
+48 -3
View File
@@ -45,6 +45,10 @@ opts = OptionParser.new do |opts|
options['irb'] = true
end
opts.on("--css", "Inject custom css. Uses custom.css from root repository") do
wiki_options[:css] = true
end
opts.on("--page-file-dir [PATH]", "Specify the sub directory for all page files (default: repository root).") do |path|
wiki_options[:page_file_dir] = path
end
@@ -65,8 +69,23 @@ opts = OptionParser.new do |opts|
wiki_options[:live_preview] = false
end
opts.on("--no-mathjax", "Disables mathjax.") do
options['mathjax'] = false
opts.on("--mathjax", "Enables mathjax.") do
wiki_options[:mathjax] = true
end
opts.on("--user-icons [SOURCE]", "Set the history user icons. Valid values: gravatar, identicon, none. Default: none.") do |source|
wiki_options[:user_icons] = source
end
opts.on("--show-all", "Shows all files in file view. By default only valid pages are shown.") do
wiki_options[:show_all] = true
end
opts.on("--collapse-tree", "Collapse file view tree. By default, expanded tree is shown.") do
wiki_options[:collapse_tree] = true
end
opts.on("--h1-title", "Sets page title to value of first h1") do
wiki_options[:h1_title] = true
end
end
@@ -141,5 +160,31 @@ else
require cfg
end
Precious::App.run!(options)
base_path = wiki_options[:base_path]
if wiki_options[:base_path].nil?
Precious::App.run!(options)
else
require 'rack'
class MapGollum
def initialize base_path
@mg = Rack::Builder.new do
map '/' do
run Proc.new { [ 302, {'Location'=> "/#{base_path}" }, [] ] }
end
map "/#{base_path}" do
run Precious::App
end
end
end
def call(env)
@mg.call(env)
end
end
# Rack::Handler does not work with Ctrl + C. Use Rack::Server instead.
Rack::Server.new(:app => MapGollum.new(base_path), :Port => options['port'], :Host => options['bind']).start
end
end
+28
View File
@@ -0,0 +1,28 @@
# Example gollum config
# gollum ../wiki --config config.rb
#
# or run from source with
#
# bundle exec bin/gollum ../wiki/ --config config.rb
# Remove const to avoid
# warning: already initialized constant FORMAT_NAMES
#
# only remove if it's defined.
# constant Gollum::Page::FORMAT_NAMES not defined (NameError)
Gollum::Page.send :remove_const, :FORMAT_NAMES if defined? Gollum::Page::FORMAT_NAMES
# limit to one format
Gollum::Page::FORMAT_NAMES = { :markdown => "Markdown" }
=begin
Valid formats are:
{ :markdown => "Markdown",
:textile => "Textile",
:rdoc => "RDoc",
:org => "Org-mode",
:creole => "Creole",
:rest => "reStructuredText",
:asciidoc => "AsciiDoc",
:mediawiki => "MediaWiki",
:pod => "Pod" }
=end
+128 -185
View File
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
s.required_ruby_version = ">= 1.8.7"
s.name = 'gollum'
s.version = '2.1.2'
s.date = '2012-08-06'
s.version = '2.4.5'
s.date = '2012-12-10'
s.rubyforge_project = 'gollum'
s.summary = "A simple, Git-powered wiki."
@@ -23,35 +23,37 @@ Gem::Specification.new do |s|
s.rdoc_options = ["--charset=UTF-8"]
s.extra_rdoc_files = %w[README.md LICENSE]
s.add_dependency('grit', "~> 2.5.0")
s.add_dependency('github-markup', [">= 0.7.0", "< 1.0.0"])
s.add_dependency('github-markdown')
s.add_dependency('pygments.rb', "~> 0.2.0")
s.add_dependency('posix-spawn', "~> 0.3.0")
s.add_dependency('sinatra', "~> 1.0")
s.add_dependency('mustache', [">= 0.11.2", "< 1.0.0"])
s.add_dependency('sanitize', "~> 2.0.0")
s.add_dependency('nokogiri', "~> 1.4")
s.add_dependency('useragent', "~> 0.4.9")
s.add_dependency('stringex', "~> 1.4.0")
s.add_dependency('grit', '~> 2.5.0')
s.add_dependency('github-markup', ['>= 0.7.4', '< 1.0.0'])
s.add_dependency('github-markdown', '~> 0.5.3')
s.add_dependency('pygments.rb', '~> 0.3.2')
s.add_dependency('sinatra', '~> 1.3.3')
s.add_dependency('mustache', ['>= 0.99.4', '< 1.0.0'])
s.add_dependency('sanitize', '~> 2.0.3')
s.add_dependency('nokogiri', '~> 1.5.5')
s.add_dependency('useragent', '~> 0.4.15')
s.add_dependency('stringex', '~> 1.5.1')
s.add_development_dependency('RedCloth')
s.add_development_dependency('mocha')
s.add_development_dependency('org-ruby', '~> 0.7.0')
s.add_development_dependency('shoulda')
s.add_development_dependency('rack-test')
s.add_development_dependency('wikicloth', '~>0.8.0')
s.add_development_dependency('rake', '~> 0.9.2')
s.add_development_dependency('RedCloth', '~> 4.2.9')
s.add_development_dependency('mocha', '~> 0.13.0')
s.add_development_dependency('org-ruby', '~> 0.7.2')
s.add_development_dependency('shoulda', '~> 3.3.2')
s.add_development_dependency('rack-test', '~> 0.6.2')
s.add_development_dependency('wikicloth', '~> 0.8.0')
s.add_development_dependency('rake', '~> 10.0.2')
s.add_development_dependency('pry', '~> 0.9.10')
# required by pry
s.add_development_dependency('rb-readline', '~> 0.4.2')
# = MANIFEST =
s.files = %w[
Gemfile
HISTORY.md
Home.md
LICENSE
README.md
Rakefile
bin/gollum
config.rb
docs/sanitization.md
gollum.gemspec
lib/gollum.rb
@@ -73,6 +75,7 @@ Gem::Specification.new do |s|
lib/gollum/frontend/public/gollum/images/fileview/toggle-small-expand.png
lib/gollum/frontend/public/gollum/images/fileview/toggle-small.png
lib/gollum/frontend/public/gollum/images/icon-sprite.png
lib/gollum/frontend/public/gollum/images/man_24.png
lib/gollum/frontend/public/gollum/images/para.png
lib/gollum/frontend/public/gollum/images/pin-16.png
lib/gollum/frontend/public/gollum/images/pin-20.png
@@ -89,11 +92,13 @@ Gem::Specification.new do |s|
lib/gollum/frontend/public/gollum/javascript/gollum.dialog.js
lib/gollum/frontend/public/gollum/javascript/gollum.js
lib/gollum/frontend/public/gollum/javascript/gollum.placeholder.js
lib/gollum/frontend/public/gollum/javascript/identicon_canvas.js
lib/gollum/frontend/public/gollum/javascript/jquery-1.7.2.min.js
lib/gollum/frontend/public/gollum/javascript/jquery.color.js
lib/gollum/frontend/public/gollum/javascript/mousetrap.min.js
lib/gollum/frontend/public/gollum/livepreview/css/custom.css
lib/gollum/frontend/public/gollum/livepreview/images/cancel_24.png
lib/gollum/frontend/public/gollum/livepreview/images/globe_24.png
lib/gollum/frontend/public/gollum/livepreview/images/lr_24.png
lib/gollum/frontend/public/gollum/livepreview/images/save_24.png
lib/gollum/frontend/public/gollum/livepreview/images/savecomment_24.png
@@ -108,6 +113,7 @@ Gem::Specification.new do |s|
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/commands/default_commands.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/commands/multi_select_commands.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/config.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/config_test.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/css/codefolding-fold-button-states.png
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/css/editor.css
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/css/expand-marker.png
@@ -158,6 +164,55 @@ Gem::Specification.new do |s|
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/oop.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/regexp.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/lib/useragent.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/package.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/test_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/text_javascript.txt
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_c9search.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_c_cpp.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_clojure.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_coffee.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_coldfusion.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_csharp.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_css.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_diff.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_glsl.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_golang.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_groovy.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_haxe.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_html.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_java.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_javascript.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_json.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_jsx.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_latex.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_less.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_liquid.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_lua.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_luapage.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_markdown.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_ocaml.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_perl.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_pgsql.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_php.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_powershell.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_python.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_ruby.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_scad.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_scala.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_scss.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_sh.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_sql.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_svg.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_tcl.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_text.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_textile.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_xml.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_xquery.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/_test/tokens_yaml.json
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/abap.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/abap_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/asciidoc.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/asciidoc_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/behaviour.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/behaviour/cstyle.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/behaviour/html.js
@@ -193,9 +248,12 @@ Gem::Specification.new do |s|
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/css_test.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/css_worker.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/css_worker_test.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/dart.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/dart_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/diff.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/diff_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/doc_comment_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/asciidoc.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/c9search.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/coffee.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/coffee_test.js
@@ -205,24 +263,34 @@ Gem::Specification.new do |s|
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/fold_mode.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/html.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/html_test.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/latex.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/lua.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/markdown.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/mixed.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/pythonic.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/pythonic_test.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/xml.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/xml_test.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/glsl.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/glsl_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/golang.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/golang_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/groovy.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/groovy_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/haml.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/haml_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/haxe.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/haxe_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/html.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/html_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/html_highlight_rules_test.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/html_test.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/jade.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/jade_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/java.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/java_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/javascript.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/javascript/jshint.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/javascript_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/javascript_highlight_rules_test.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/javascript_test.js
@@ -233,6 +301,8 @@ Gem::Specification.new do |s|
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/json_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/json_worker.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/json_worker_test.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/jsp.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/jsp_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/jsx.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/jsx_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/latex.js
@@ -242,14 +312,24 @@ Gem::Specification.new do |s|
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/liquid.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/liquid_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/liquid_highlight_rules_test.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/lisp.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/lisp_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/lua.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/lua_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/luapage.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/luapage_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/lucene.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/lucene_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/lucene_highlight_rules_test.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/makefile.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/makefile_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/markdown.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/markdown_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/markdown_highlight_rules_test.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/matching_brace_outdent.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/matching_parens_outdent.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/objectivec.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/objectivec_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/ocaml.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/ocaml_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/perl.js
@@ -263,6 +343,12 @@ Gem::Specification.new do |s|
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/python.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/python_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/python_test.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/r.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/r_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/rdoc.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/rdoc_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/rhtml.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/rhtml_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/ruby.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/ruby_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/ruby_highlight_rules_test.js
@@ -276,30 +362,31 @@ Gem::Specification.new do |s|
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/sh_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/sql.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/sql_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/stylus.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/stylus_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/svg.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/svg_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/tcl.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/tcl_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/tex.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/tex_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/text.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/text_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/text_test.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/textile.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/textile_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/typescript.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/typescript_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xml.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xml_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xml_highlight_rules_test.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xml_test.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xml_util.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/Position.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/JSONParseTreeHandler.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/Readme.md
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/StringLexer.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/XMLLexer.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/XQDTLexer.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/XQDTParser.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/XQueryLexer.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/XQueryParser.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/XQuerySemanticHighlighter.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/antlr3-all.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/xquery.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery/visitors/SyntaxHighlighter.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery_highlight_rules.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/xquery_worker.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/yaml.js
@@ -314,10 +401,6 @@ Gem::Specification.new do |s|
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mouse/multi_select_handler.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/multi_select.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/multi_select_test.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/narcissus/definitions.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/narcissus/lexer.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/narcissus/options.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/narcissus/parser.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/placeholder.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/placeholder_test.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/range.js
@@ -345,6 +428,8 @@ Gem::Specification.new do |s|
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/test/mockdom.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/test/mockrenderer.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/test/tests.html
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/ambiance.css
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/ambiance.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/chrome.css
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/chrome.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/clouds.css
@@ -397,15 +482,16 @@ Gem::Specification.new do |s|
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/twilight.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/vibrant_ink.css
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/vibrant_ink.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/xcode.css
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/theme/xcode.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/token_iterator.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/token_iterator_test.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/tokenizer.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/tokenizer_dev.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/undomanager.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/unicode.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/virtual_renderer.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/virtual_renderer_test.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/worker/jshint.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/worker/jslint.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/worker/mirror.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/worker/worker.js
lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/worker/worker_client.js
@@ -426,6 +512,7 @@ Gem::Specification.new do |s|
lib/gollum/frontend/public/gollum/livepreview/licenses/retina_display_icon_set/by_sa_3.0_unported_legalcode.txt
lib/gollum/frontend/public/gollum/livepreview/licenses/sizzle/LICENSE.txt
lib/gollum/frontend/public/gollum/livepreview/licenses/sundown/sundown.txt
lib/gollum/frontend/public/gollum/livepreview/licenses/templarian_windowsicons/license.txt
lib/gollum/frontend/public/gollum/livepreview/readme.md
lib/gollum/frontend/templates/compare.mustache
lib/gollum/frontend/templates/create.mustache
@@ -434,6 +521,9 @@ Gem::Specification.new do |s|
lib/gollum/frontend/templates/error.mustache
lib/gollum/frontend/templates/file_view.mustache
lib/gollum/frontend/templates/history.mustache
lib/gollum/frontend/templates/history_authors/gravatar.mustache
lib/gollum/frontend/templates/history_authors/identicon.mustache
lib/gollum/frontend/templates/history_authors/none.mustache
lib/gollum/frontend/templates/layout.mustache
lib/gollum/frontend/templates/page.mustache
lib/gollum/frontend/templates/pages.mustache
@@ -453,165 +543,18 @@ Gem::Specification.new do |s|
lib/gollum/frontend/views/pages.rb
lib/gollum/frontend/views/search.rb
lib/gollum/git_access.rb
lib/gollum/gitcode.rb
lib/gollum/markup.rb
lib/gollum/page.rb
lib/gollum/pagination.rb
lib/gollum/sanitization.rb
lib/gollum/tex.rb
lib/gollum/web_sequence_diagram.rb
lib/gollum/wiki.rb
licenses/css_tree_menu_thecssninja/license.txt
licenses/licenses.txt
licenses/unity_asset_pool/COPYRIGHT
templates/formatting.html
test/examples/empty.git/HEAD
test/examples/empty.git/config
test/examples/empty.git/description
test/examples/empty.git/hooks/applypatch-msg.sample
test/examples/empty.git/hooks/commit-msg.sample
test/examples/empty.git/hooks/post-commit.sample
test/examples/empty.git/hooks/post-receive.sample
test/examples/empty.git/hooks/post-update.sample
test/examples/empty.git/hooks/pre-applypatch.sample
test/examples/empty.git/hooks/pre-commit.sample
test/examples/empty.git/hooks/pre-rebase.sample
test/examples/empty.git/hooks/prepare-commit-msg.sample
test/examples/empty.git/hooks/update.sample
test/examples/empty.git/info/exclude
test/examples/empty.git/objects/info/.gitkeep
test/examples/empty.git/objects/pack/.gitkeep
test/examples/empty.git/refs/heads/.gitkeep
test/examples/lotr.git/COMMIT_EDITMSG
test/examples/lotr.git/HEAD
test/examples/lotr.git/ORIG_HEAD
test/examples/lotr.git/config
test/examples/lotr.git/description
test/examples/lotr.git/index
test/examples/lotr.git/info/exclude
test/examples/lotr.git/logs/HEAD
test/examples/lotr.git/logs/refs/heads/master
test/examples/lotr.git/objects/06/131480411710c92a82fe2d1e76932c70feb2e5
test/examples/lotr.git/objects/0a/de1e2916346d4c1f2fb63b863fd3c16808fe44
test/examples/lotr.git/objects/0d/c9016ca928c78d5421a99a53b379b53929221e
test/examples/lotr.git/objects/0e/d8cbe0a25235bd867e65193c7d837c66b328ef
test/examples/lotr.git/objects/12/629d666c5e3178f82f533f543d61b53dc78c0b
test/examples/lotr.git/objects/1c/79ddc69707f7b164bc2ea58beb5d8965ff6bd0
test/examples/lotr.git/objects/1d/b89ebba7e2c14d93b94ff98cfa3708a4f0d4e3
test/examples/lotr.git/objects/24/49c2681badfd3c189e8ed658dacffe8ba48fe5
test/examples/lotr.git/objects/25/4bdc1ba27d8b8a794538a8522d9a2b56ec2dd9
test/examples/lotr.git/objects/27/680b0fce1abfbc528e7aa53d92645852d52eb6
test/examples/lotr.git/objects/2c/b9156ad383914561a8502fc70f5a1d887e48ad
test/examples/lotr.git/objects/45/3b250f979c7bd6dfb62640c944c982ae6721ee
test/examples/lotr.git/objects/45/f319ee12f2b551b901b22e72602963c366fff1
test/examples/lotr.git/objects/46/a697caf435815bb07bbce947fc2d58be15f087
test/examples/lotr.git/objects/4c/45c2b4e297a726c3d3f66886f35373e48fe1c5
test/examples/lotr.git/objects/4e/023f460ce466e154ca09d8774c79ad5a53fc15
test/examples/lotr.git/objects/5d/cac289a8603188d2c5caf481dcba2985126aaa
test/examples/lotr.git/objects/60/f12f4254f58801b9ee7db7bca5fa8aeefaa56b
test/examples/lotr.git/objects/62/9aa678272b017a4d136d35e77ac94d80b08dc2
test/examples/lotr.git/objects/6e/48abfc56565574859e081ee58eae655d48cf71
test/examples/lotr.git/objects/71/4323c104239440a5c66ab12a67ed07a83c404f
test/examples/lotr.git/objects/7b/60c5a20a501a70f2317fa0ef763e1e2ce22d6b
test/examples/lotr.git/objects/7d/981cd984ad589e3cf00d8122170c6f7d685979
test/examples/lotr.git/objects/84/0ec5b1ba1320e8ec443f28f99566f615d5af10
test/examples/lotr.git/objects/93/6b83ee0dd8837adb82511e40d5e4ebe59bb675
test/examples/lotr.git/objects/94/523d7ae48aeba575099dd12926420d8fd0425d
test/examples/lotr.git/objects/94/9a9cc3119b9c98817f375e976d2bb5e2a42809
test/examples/lotr.git/objects/96/97dc65e095658bbd1b8e8678e08881e86d32f1
test/examples/lotr.git/objects/9b/e95b960ac388d4e7db55f610f828e9c31344e6
test/examples/lotr.git/objects/a3/1ca2a7c352c92531a8b99815d15843b259e814
test/examples/lotr.git/objects/a6/59b3763b822dd97544621fd0beef162ea37b14
test/examples/lotr.git/objects/a8/ad3c09dd842a3517085bfadd37718856dee813
test/examples/lotr.git/objects/aa/b61fe89d56f8614c0a8151da34f939dcedfa68
test/examples/lotr.git/objects/b0/de6e794dfdc7ef3400e894225bfe23308aae5c
test/examples/lotr.git/objects/b1/6b3d9fad9d78e5a669e7f33d94c96da374eccd
test/examples/lotr.git/objects/bc/4b5fc0ce2c2ba3acef6647e4f67256ee45ab60
test/examples/lotr.git/objects/c3/b43e9f08966b088e7a0192e436b7a884542e05
test/examples/lotr.git/objects/c9/6a7645db5d4c76389e77cd103ef3ed77d81e4c
test/examples/lotr.git/objects/ca/7355dc497e9729fbaf0c0e3f424b86afef5614
test/examples/lotr.git/objects/cf/ea406f5f77afc7fb673a43e97721234385b1bd
test/examples/lotr.git/objects/d5/29304506d37f544675244c335d85cab5d29966
test/examples/lotr.git/objects/dc/596d6b2dd89ab05c66f4abd7d5eb706bc17f19
test/examples/lotr.git/objects/ec/da3205bee14520aab5a7bb307392064b938e83
test/examples/lotr.git/objects/f4/84ebb1f40f8eb20d1bcd8d1d71934d2b8ae961
test/examples/lotr.git/objects/fa/e7ef5344202bba4129abdc13060d9297d99465
test/examples/lotr.git/objects/fb/c5dd7d807707b4a0a97c1182fecfef1eced5df
test/examples/lotr.git/objects/fc/3eee516ff72dc9099ba00d4611eb02e5c9e634
test/examples/lotr.git/objects/ff/6f7de62644369380ba73b4e4297c1a2d6f0b66
test/examples/lotr.git/objects/info/packs
test/examples/lotr.git/objects/pack/pack-dcbeaf3f6ff6c5eb08ea2b0a2d83626e8763546b.idx
test/examples/lotr.git/objects/pack/pack-dcbeaf3f6ff6c5eb08ea2b0a2d83626e8763546b.pack
test/examples/lotr.git/packed-refs
test/examples/lotr.git/refs/heads/master
test/examples/lotr.git/refs/remotes/origin/HEAD
test/examples/page_file_dir.git/COMMIT_EDITMSG
test/examples/page_file_dir.git/HEAD
test/examples/page_file_dir.git/config
test/examples/page_file_dir.git/description
test/examples/page_file_dir.git/index
test/examples/page_file_dir.git/info/exclude
test/examples/page_file_dir.git/logs/HEAD
test/examples/page_file_dir.git/logs/refs/heads/master
test/examples/page_file_dir.git/objects/0c/7d27db1f575263efdcab3dc650f4502a2dbcbf
test/examples/page_file_dir.git/objects/22/b404803c966dd92865614d86ff22ca12e50c1e
test/examples/page_file_dir.git/objects/25/7cc5642cb1a054f08cc83f2d943e56fd3ebe99
test/examples/page_file_dir.git/objects/57/16ca5987cbf97d6bb54920bea6adde242d87e6
test/examples/page_file_dir.git/objects/5b/43e14e0a15fb6f08feab1773d1c0991e9f71e2
test/examples/page_file_dir.git/refs/heads/master
test/examples/revert.git/COMMIT_EDITMSG
test/examples/revert.git/HEAD
test/examples/revert.git/config
test/examples/revert.git/description
test/examples/revert.git/index
test/examples/revert.git/info/exclude
test/examples/revert.git/logs/HEAD
test/examples/revert.git/logs/refs/heads/master
test/examples/revert.git/objects/10/2685c42018f802557f05db171f44443e8dacab
test/examples/revert.git/objects/20/2ced67cea93c7b6bd2928aa1daef8d1d55a20d
test/examples/revert.git/objects/41/76394bfa11222363c66ce7e84b5f154095b6d9
test/examples/revert.git/objects/6a/69f92020f5df77af6e8813ff1232493383b708
test/examples/revert.git/objects/8e/83f898e5e16ae400db59dda1017acad540f3aa
test/examples/revert.git/objects/b4/785957bc986dc39c629de9fac9df46972c00fc
test/examples/revert.git/objects/ed/6c9f63b98acf73c25b5ffbb38da557d3682023
test/examples/revert.git/objects/f4/03b791119f8232b7cb0ba455c624ac6435f433
test/examples/revert.git/objects/info/packs
test/examples/revert.git/objects/pack/pack-a561f8437234f74d0bacb9e0eebe52d207f5770d.idx
test/examples/revert.git/objects/pack/pack-a561f8437234f74d0bacb9e0eebe52d207f5770d.pack
test/examples/revert.git/packed-refs
test/examples/revert.git/refs/heads/master
test/examples/revert.git/refs/remotes/origin/HEAD
test/examples/yubiwa.git/HEAD
test/examples/yubiwa.git/config
test/examples/yubiwa.git/description
test/examples/yubiwa.git/info/exclude
test/examples/yubiwa.git/objects/10/fa2ddc4e3b4009d8a453aace10bd6148c1ad00
test/examples/yubiwa.git/objects/52/4b82874327ea7cbf730389964ba7cb3de966de
test/examples/yubiwa.git/objects/58/3fc201cb457fb3f1480f3e1e5999b119633835
test/examples/yubiwa.git/objects/87/bc1dd46ab3d3874d4e898d45dd512cc20a7cc8
test/examples/yubiwa.git/objects/89/64ed1b4e21aa90e831763bbce9034bfda81b70
test/examples/yubiwa.git/objects/9f/f6dd0660da5fba2d3374adb2b84fa653bb538b
test/examples/yubiwa.git/objects/ac/e97abf2b177815a1972d7db22f229f58c83309
test/examples/yubiwa.git/objects/b1/f443863a4816628807fbf86141ebef055dda34
test/examples/yubiwa.git/refs/heads/master
test/file_view/1_file.txt
test/file_view/1_file_1_folder.txt
test/file_view/1_folder.txt
test/file_view/2_files_2_folders.txt
test/file_view/2_files_2_folders_1_root.txt
test/file_view/nested_folders.txt
test/helper.rb
test/test_app.rb
test/test_app_helpers.rb
test/test_committer.rb
test/test_file.rb
test/test_file_view.rb
test/test_git_access.rb
test/test_markup.rb
test/test_page.rb
test/test_page_revert.rb
test/test_pages_view.rb
test/test_unicode.rb
test/test_wiki.rb
templates/helper_wiki.rb
]
# = MANIFEST =
+8 -2
View File
@@ -1,5 +1,7 @@
# ~*~ encoding: utf-8 ~*~
# stdlib
require 'digest/md5'
require 'digest/sha1'
require 'ostruct'
# external
@@ -18,11 +20,15 @@ require File.expand_path('../gollum/file', __FILE__)
require File.expand_path('../gollum/file_view', __FILE__)
require File.expand_path('../gollum/markup', __FILE__)
require File.expand_path('../gollum/sanitization', __FILE__)
require File.expand_path('../gollum/tex', __FILE__)
require File.expand_path('../gollum/web_sequence_diagram', __FILE__)
require File.expand_path('../gollum/frontend/uri_encode_component', __FILE__)
# Set ruby to UTF-8 mode
# This is required for Ruby 1.8.7 which gollum still supports.
$KCODE = 'U' if RUBY_VERSION[2,1] == '8'
module Gollum
VERSION = '2.1.2'
VERSION = '2.4.5'
def self.assets_path
::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
+1
View File
@@ -1,3 +1,4 @@
# ~*~ encoding: utf-8 ~*~
module Gollum
class BlobEntry
# Gets the String SHA for this blob.
+8 -3
View File
@@ -1,3 +1,4 @@
# ~*~ encoding: utf-8 ~*~
module Gollum
# Responsible for handling the commit process for a Wiki. It sets up the
# Git index, provides methods for modifying the tree, and stores callbacks
@@ -100,9 +101,13 @@ module Gollum
tree.blobs.each do |blob|
next if page_path_scheduled_for_deletion?(index.tree, fullpath)
file = blob.name.downcase.sub(/\.\w+$/, '')
file_ext = ::File.extname(blob.name).sub(/^\./, '')
if downpath == file && !(allow_same_ext && file_ext == ext)
existing_file = blob.name.downcase.sub(/\.\w+$/, '')
existing_file_ext = ::File.extname(blob.name).sub(/^\./, '')
new_file_ext = ::File.extname(path).sub(/^\./, '')
if downpath == existing_file && !(allow_same_ext && new_file_ext == existing_file_ext)
raise DuplicatePageError.new(dir, blob.name, path)
end
end
+17
View File
@@ -1,3 +1,4 @@
# ~*~ encoding: utf-8 ~*~
module Gollum
class File
Wiki.file_class = self
@@ -13,6 +14,22 @@ module Gollum
@path = nil
end
# Public: The url path required to reach this page within the repo.
#
# Returns the String url_path
def url_path
path = self.path
path = path.sub(/\/[^\/]+$/, '/') if path.include?('/')
path
end
# Public: The url_path, but CGI escaped.
#
# Returns the String url_path
def escaped_url_path
CGI.escape(self.url_path).gsub('%2F','/')
end
# Public: The on-disk filename of the file.
#
# Returns the String name.
+22 -12
View File
@@ -1,3 +1,4 @@
# ~*~ encoding: utf-8 ~*~
module Gollum
=begin
FileView requires that:
@@ -5,8 +6,13 @@ module Gollum
- Then all the folders are sorted and processed
=end
class FileView
def initialize pages
# common use cases:
# set pages to wiki.pages and show_all to false
# set pages to wiki.pages + wiki.files and show_all to true
def initialize pages, options = {}
@pages = pages
@show_all = options[:show_all] || false
@checked = options[:collapse_tree] ? '' : "checked"
end
def enclose_tree string
@@ -16,7 +22,7 @@ module Gollum
def new_page page
name = page.name
url = url_for_page page
%Q( <li class="file"><a href="#{url}">#{name}</a></li>\n)
%Q( <li class="file"><a href="#{url}"><span class="icon"></span>#{name}</a></li>)
end
def new_folder folder_path
@@ -26,20 +32,26 @@ module Gollum
def new_sub_folder path
<<-HTML
<li>
<label>#{path}</label> <input type="checkbox" checked />
<label>#{path}</label> <input type="checkbox" #{@checked} />
<ol>
HTML
end
def end_folder
<<-HTML
</ol>
</li>
HTML
"</ol></li>\n"
end
def url_for_page page
url = ::File.join(::File.dirname(page.path), page.filename_stripped)
url = ''
if @show_all
# Remove ext for valid pages.
filename = page.filename
filename = Page::valid_page_name?(filename) ? filename.chomp(::File.extname(filename)) : filename
url = ::File.join(::File.dirname(page.path), filename)
else
url = ::File.join(::File.dirname(page.path), page.filename_stripped)
end
url = url[2..-1] if url[0,2] == './'
url
end
@@ -70,13 +82,11 @@ module Gollum
# Handle special case of only one folder.
if (count - folder_start == 1)
page = @pages[ folder_start ]
name = page.name
url = url_for_page page
html += <<-HTML
<li>
<label>#{::File.dirname(page.path)}</label> <input type="checkbox" checked />
<label>#{::File.dirname(page.path)}</label> <input type="checkbox" #{@checked} />
<ol>
<li class="file"><a href="#{url}">#{name}</a></li>
#{new_page page}
</ol>
</li>
HTML
+61 -42
View File
@@ -1,3 +1,4 @@
# ~*~ encoding: utf-8 ~*~
require 'cgi'
require 'sinatra'
require 'gollum'
@@ -9,7 +10,6 @@ require 'gollum/frontend/views/layout'
require 'gollum/frontend/views/editable'
require 'gollum/frontend/views/has_page'
require File.expand_path '../uri_encode_component', __FILE__
require File.expand_path '../helpers', __FILE__
# Fix to_url
@@ -18,8 +18,7 @@ class String
# _Header => header which causes errors
def to_url
return nil if self.nil?
return self if ['_Header', '_Footer', '_Sidebar'].include? self
upstream_to_url
upstream_to_url :exclude => ['_Header', '_Footer', '_Sidebar']
end
end
@@ -82,12 +81,14 @@ module Precious
end
before do
@base_url = url('/', false)
settings.wiki_options.merge!({ :base_path => @base_url }) unless settings.wiki_options.has_key? :base_path
@base_url = url('/', false).chomp('/')
# above will detect base_path when it's used with map in a config.ru
settings.wiki_options.merge!({ :base_path => @base_url })
@css = settings.wiki_options[:css]
end
get '/' do
show_page_or_file('Home')
redirect ::File.join(@base_url, 'Home')
end
# path is set to name if path is nil.
@@ -95,14 +96,15 @@ module Precious
# path must have a trailing slash 'a/b/' or
# extract_path will trim path to 'a'
# name, path, version
def wiki_page( name, path = nil, version = nil)
def wiki_page(name, path = nil, version = nil, exact = true)
path = name if path.nil?
name = extract_name(name)
path = extract_path(path)
path = '/' if exact && path.nil?
wiki = wiki_new
OpenStruct.new(:wiki => wiki, :page => wiki.paged(name, path, version),
OpenStruct.new(:wiki => wiki, :page => wiki.paged(name, path, exact, version),
:name => name, :path => path)
end
@@ -136,19 +138,20 @@ module Precious
mustache :edit
end
else
redirect to("/create/#{CGI.escape(@name)}")
redirect to("/create/#{encodeURIComponent(@name)}")
end
end
post '/edit/*' do
wikip = wiki_page(CGI.unescape(params[:page]), sanitize_empty_params(params[:path]))
path = wikip.path
wiki = wikip.wiki
page = wikip.page
rename = params[:rename].to_url if params[:rename]
name = rename || page.name
committer = Gollum::Committer.new(wiki, commit_message)
commit = {:committer => committer}
path = '/' + clean_url(sanitize_empty_params(params[:path])).to_s
page_name = CGI.unescape(params[:page])
wiki = wiki_new
page = wiki.paged(page_name, path, exact = true)
return if page.nil?
rename = params[:rename].to_url if params[:rename]
name = rename || page.name
committer = Gollum::Committer.new(wiki, commit_message)
commit = {:committer => committer}
update_wiki_page(wiki, page, params[:content], commit, name, params[:format])
update_wiki_page(wiki, page.header, params[:header], commit) if params[:header]
@@ -172,7 +175,7 @@ module Precious
end
get '/create/*' do
wikip = wiki_page(params[:splat].first)
wikip = wiki_page(params[:splat].first.gsub('+', '-'))
@name = wikip.name.to_url
@path = wikip.path
@@ -186,17 +189,18 @@ module Precious
post '/create' do
name = params[:page].to_url
path = sanitize_empty_params(params[:path])
path = sanitize_empty_params(params[:path]) || ''
format = params[:format].intern
# write_page is not directory aware so use wiki_options to emulate dir support.
wiki_options = settings.wiki_options.merge({ :page_file_dir => path })
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
# ensure pages are created in page_file_dir
page_dir = settings.wiki_options[:page_file_dir].to_s
path = clean_url(::File.join(page_dir, path)) unless path.start_with?(page_dir)
wiki = wiki_new
begin
wiki.write_page(name, format, params[:content], commit_message)
page = wiki.page(name)
redirect to("/#{page.escaped_url_path}") unless page.nil?
wiki.write_page(name, format, params[:content], commit_message, path)
redirect to("/#{clean_url(::File.join(path,name))}")
rescue Gollum::DuplicatePageError => e
@message = "Duplicate page: #{e.message}"
mustache :error
@@ -232,6 +236,7 @@ module Precious
@content = @page.formatted_data
@toc_content = wiki.universal_toc ? @page.toc_data : nil
@mathjax = wiki.mathjax
@h1_title = wiki.h1_title
@editable = false
mustache :page
end
@@ -276,16 +281,6 @@ module Precious
mustache :compare
end
get '/_tex.png' do
content_type 'image/png'
formula = Base64.decode64(params[:data])
Gollum::Tex.render_formula(formula)
end
get %r{^/(javascript|css|images)} do
halt 404
end
get %r{/(.+?)/([0-9a-f]{40})} do
file_path = params[:captures][0]
version = params[:captures][1]
@@ -306,7 +301,8 @@ module Precious
get '/search' do
@query = params[:q]
wiki = wiki_new
@results = wiki.search @query
# Sort wiki search results by count (desc) and then by name (asc)
@results = wiki.search(@query).sort{ |a, b| (a[:count] <=> b[:count]).nonzero? || b[:name] <=> a[:name] }.reverse
@name = @query
mustache :search
end
@@ -321,13 +317,21 @@ module Precious
wiki_options = settings.wiki_options.merge({ :page_file_dir => @path })
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
@results = wiki.pages
@results += wiki.files if settings.wiki_options[:show_all]
@ref = wiki.ref
mustache :pages
end
get '/fileview' do
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
@results = Gollum::FileView.new(wiki.pages).render_files
wiki = wiki_new
options = settings.wiki_options
content = wiki.pages
# if showing all files include wiki.files
content += wiki.files if options[:show_all]
# must pass wiki_options to FileView
# --show-all and --collapse-tree can be set.
@results = Gollum::FileView.new(content, options).render_files
@ref = wiki.ref
mustache :file_view, { :layout => false }
end
@@ -338,23 +342,27 @@ module Precious
def show_page_or_file(fullpath)
name = extract_name(fullpath)
path = extract_path(fullpath)
path = extract_path(fullpath) || '/'
wiki = wiki_new
if page = wiki.paged(name, path)
page_dir = settings.wiki_options[:page_file_dir].to_s
path = ::File.join(page_dir, path) unless path.start_with?(page_dir)
if page = wiki.paged(name, path, exact = true)
@page = page
@name = name
@editable = true
@content = page.formatted_data
@toc_content = wiki.universal_toc ? @page.toc_data : nil
@mathjax = wiki.mathjax
@h1_title = wiki.h1_title
mustache :page
elsif file = wiki.file(fullpath)
content_type file.mime_type
file.raw_data
else
page_path = [path, name].compact.join('/')
redirect to("/create/#{CGI.escape(page_path).gsub('%2F','/')}")
redirect to("/create/#{clean_url(encodeURIComponent(page_path))}")
end
end
@@ -367,8 +375,19 @@ module Precious
wiki.update_page(page, name, format, content.to_s, commit)
end
private
# Options parameter to Gollum::Committer#initialize
# :message - The String commit message.
# :name - The String author full name.
# :email - The String email address.
# message is sourced from the incoming request parameters
# author details are sourced from the session, to be populated by rack middleware ahead of us
def commit_message
{ :message => params[:message] }
commit_message = { :message => params[:message] }
author_parameters = session['gollum.author']
commit_message.merge! author_parameters unless author_parameters.nil?
commit_message
end
end
end
+15
View File
@@ -1,3 +1,4 @@
# ~*~ encoding: utf-8 ~*~
module Precious
module Helpers
# Extract the path string that Gollum::Wiki expects
@@ -17,5 +18,19 @@ module Precious
def sanitize_empty_params(param)
[nil,''].include?(param) ? nil : CGI.unescape(param)
end
# Remove all slashes from the start of string.
# Remove all double slashes
def clean_url url
return url if url.nil?
url.gsub('%2F','/').gsub(/^\/+/,'').gsub('//','/')
end
def trim_leading_slash url
return url if url.nil?
url.gsub!('%2F','/')
return '/' + url.gsub(/^\/+/,'') if url[0,1] == '/'
url
end
end
end
+128 -121
View File
@@ -1,121 +1,128 @@
*, html {
font-family: Verdana, Arial, Helvetica, sans-serif;
}
#results a:hover {
background-color: #4c4c4c;
}
#home_button {
position: absolute;
top: 10px;
left: 50%;
}
#home_button .minibutton {
font-size: 1em;
text-align: center;
}
#results {
position: absolute;
top: 60px;
left: 10px;
}
body, form, ul, li, p, h1, h2, h3, h4, h5 {
margin: 0;
padding: 0;
}
body {
background-color: #606061;
color: #ffffff;
margin: 0;
}
img {
border: none;
}
p {
font-size: 1em;
margin: 0 0 1em 0;
}
html { font-size: 100%; /* IE hack */ }
body { font-size: 1em; /* Sets base font size to 16px */ }
table { font-size: 100%; /* IE hack */ }
input, select, textarea, th, td { font-size: 1em; }
/* Prevent wrapping on large file names. */
li.file {
white-space: nowrap;
}
/* CSS Tree menu styles */
ol.tree
{
padding: 0 0 0 30px;
width: 300px;
}
li
{
position: relative;
margin-left: -15px;
list-style: none;
}
li.file
{
margin-left: -1px !important;
height: 1.5em;
}
li.file a
{
background: url(../images/fileview/document.png) 0 0 no-repeat;
color: #fff;
padding-left: 21px;
text-decoration: none;
display: block;
}
li.file a[href *= '.pdf'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li.file a[href *= '.html'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li.file a[href $= '.css'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li.file a[href $= '.js'] { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li input
{
position: absolute;
left: 0;
margin-left: 0;
opacity: 0;
z-index: 2;
cursor: pointer;
height: 1em;
width: 1em;
top: 0;
}
li input + ol
{
background: url(../images/fileview/toggle-small-expand.png) 40px 0 no-repeat;
margin: -1.188em 0 0 -44px; /* 15px */
height: 1.5em;
}
li input + ol > li { display: none; margin-left: -14px !important; padding-left: 1px; }
li label
{
background: url(../images/fileview/folder-horizontal.png) 15px 1px no-repeat;
cursor: pointer;
display: block;
padding-left: 37px;
}
li input:checked + ol
{
background: url(../images/fileview/toggle-small.png) 40px 5px no-repeat;
margin: -1.5em 0 0 -44px; /* 20px */
padding: 1.563em 0 0 80px;
height: auto;
}
li input:checked + ol > li { display: block; margin: 0 0 0.125em; /* 2px */}
li input:checked + ol > li:last-child { margin: 0 0 0.063em; /* 1px */ }
*, html {
font-family: Verdana, Arial, Helvetica, sans-serif;
}
#results a:hover {
background-color: #4c4c4c;
}
#home_button {
position: absolute;
top: 10px;
left: 50%;
}
#home_button .minibutton {
font-size: 1em;
text-align: center;
}
#results {
position: absolute;
top: 60px;
left: 10px;
}
body, form, ul, li, p, h1, h2, h3, h4, h5 {
margin: 0;
padding: 0;
}
body {
background-color: #606061;
color: #ffffff;
margin: 0;
}
img {
border: none;
}
p {
font-size: 1em;
margin: 0 0 1em 0;
}
html { font-size: 100%; /* IE hack */ }
body { font-size: 1em; /* Sets base font size to 16px */ }
table { font-size: 100%; /* IE hack */ }
input, select, textarea, th, td { font-size: 1em; }
/* Prevent wrapping on large file names. */
li.file {
white-space: nowrap;
}
/* CSS Tree menu styles */
ol.tree
{
padding: 0 0 0 30px;
width: 300px;
}
li
{
position: relative;
margin-left: -15px;
list-style: none;
}
li.file
{
margin-left: -1px !important;
height: 1.5em;
}
li.file a
{
color: #fff;
text-decoration: none;
display: inline-block;
}
li.file a span.icon
{
width: 14px;
height: 18px;
background: url(../images/fileview/document.png) 0 0 no-repeat;
display: inline-block;
margin-right: 7px;
vertical-align: text-top;
}
li.file a[href *= '.pdf'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li.file a[href *= '.html'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li.file a[href $= '.css'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li.file a[href $= '.js'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; }
li input
{
position: absolute;
left: 0;
margin-left: 0;
opacity: 0;
z-index: 2;
cursor: pointer;
height: 1em;
width: 1em;
top: 0;
}
li input + ol
{
background: url(../images/fileview/toggle-small-expand.png) 40px 0 no-repeat;
margin: -1.188em 0 0 -44px; /* 15px */
height: 1.5em;
}
li input + ol > li { display: none; margin-left: -14px !important; padding-left: 1px; }
li label
{
background: url(../images/fileview/folder-horizontal.png) 15px 1px no-repeat;
cursor: pointer;
display: block;
padding-left: 37px;
}
li input:checked + ol
{
background: url(../images/fileview/toggle-small.png) 40px 5px no-repeat;
margin: -1.5em 0 0 -44px; /* 20px */
padding: 1.563em 0 0 80px;
height: auto;
}
li input:checked + ol > li { display: block; margin: 0 0 0.125em; /* 2px */}
li input:checked + ol > li:last-child { margin: 0 0 0.063em; /* 1px */ }
@@ -21,7 +21,9 @@ body, html {
#wiki-wrapper {
margin: 0 auto;
overflow: visible;
width: 80%;
width: 920px;
padding-left:20px;
padding-right:20px;
}
a:link {
@@ -97,20 +97,16 @@ a.absent {
.markdown-body h1 {
font-size: 28px;
color: #000;
margin-top: 50px;
margin-bottom: 20px;
margin-top: 20px;
margin-bottom: 10px;
}
.markdown-body h2 {
font-size: 24px;
border-bottom: 1px solid #ccc;
color: #000;
margin-top: 40px;
margin-bottom: 20px;
}
.markdown-body h3 {
font-size: 18px;
margin-top: 30px;
margin-bottom: 15px;
}
.markdown-body h4 {
font-size: 16px;
@@ -127,10 +123,13 @@ a.absent {
.markdown-body ul,
.markdown-body ol,
.markdown-body dl,
.markdown-body li,
.markdown-body table,
.markdown-body pre {
margin: 15px 0;
margin: 0px 0;
margin-bottom: 15px;
}
.markdown-body li {
margin: 0px;
}
.markdown-body hr {
background: transparent url(../images/dirty-shade.png) repeat-x 0 0;
@@ -146,12 +145,9 @@ a.absent {
.markdown-body>h5:first-child,
.markdown-body>h6:first-child {
}
.markdown-body h1+h2{
.markdown-body h1+h2+h3{
margin-top: 30px;
}
.markdown-body h2+h3{
margin-top: 10px;
}
.markdown-body a:first-child h1,
.markdown-body a:first-child h2,
.markdown-body a:first-child h3,
Binary file not shown.

After

Width:  |  Height:  |  Size: 376 B

@@ -196,7 +196,9 @@
LanguageDefinition.getHookFunctionFor("activate")();
}
function hotkey( cmd ) {
function hotkey( e, cmd ) {
e.preventDefault();
var def = LanguageDefinition.getDefinitionFor( cmd );
if ( typeof def == 'object' ) {
FunctionBar.executeAction( def );
@@ -205,8 +207,17 @@
return false;
}
Mousetrap.bind(['command+b', 'ctrl+b'], function(){ hotkey('function-bold'); });
Mousetrap.bind(['command+i', 'ctrl+i'], function(){ hotkey('function-italic'); });
Mousetrap.bind(['command+1', 'ctrl+1'], function( e ){ hotkey( e, 'function-h1' ); });
Mousetrap.bind(['command+2', 'ctrl+2'], function( e ){ hotkey( e, 'function-h2' ); });
Mousetrap.bind(['command+3', 'ctrl+3'], function( e ){ hotkey( e, 'function-h3' ); });
Mousetrap.bind(['command+b', 'ctrl+b'], function( e ){ hotkey( e, 'function-bold' ); });
Mousetrap.bind(['command+i', 'ctrl+i'], function( e ){ hotkey( e, 'function-italic' ); });
Mousetrap.bind(['command+s', 'ctrl+s'], function( e ){
e.preventDefault();
$("#gollum-editor-submit").trigger("click");
return false;
});
} );
} else {
LanguageDefinition._ACTIVE_LANG = name;
@@ -277,7 +288,7 @@
}
// attempt to load the definition for this language
var script_uri = '.' + baseUrl + '/javascript/editor/langs/' + markup_name + '.js';
var script_uri = baseUrl + '/javascript/editor/langs/' + markup_name + '.js';
$.ajax({
url: script_uri,
dataType: 'script',
@@ -233,6 +233,7 @@
$('#gollum-dialog-dialog').animate({ opacity: 1 }, {
duration: 500
});
$($('#gollum-dialog-dialog input[type="text"]').get(0)).focus();
}
});
}
@@ -4,7 +4,7 @@ $(document).ready(function() {
var ok = confirm($(this).data('confirm'));
if ( ok ) {
var loc = window.location;
loc = baseUrl + 'delete' + loc.pathname
loc = baseUrl + '/delete' + loc.pathname.replace(baseUrl,'');
window.location = loc;
}
// Don't navigate on cancel.
@@ -138,10 +138,10 @@ $(document).ready(function() {
var msg = 'Renamed ' + oldName + ' to ' + newName;
jQuery.ajax( {
type: 'POST',
url: baseUrl + 'edit/' + oldName,
url: baseUrl + '/edit/' + oldName,
data: { path: path, rename: newName, page: oldName, message: msg },
success: function() {
window.location = baseUrl + encodeURIComponent(newName);
window.location = baseUrl + '/' + encodeURIComponent(newName);
}
});
}
@@ -154,14 +154,6 @@ $(document).ready(function() {
$('#minibutton-new-page').click(function(e) {
e.preventDefault();
var path = location.pathname;
// ensure there's more than one slash in pathname.
if (path.split('/').length > 2) {
path = path.substr(0, path.lastIndexOf('/') + 1);
} else {
path = '';
}
$.GollumDialog.init({
title: 'Create New Page',
fields: [
@@ -169,7 +161,7 @@ $(document).ready(function() {
id: 'name',
name: 'Page Name',
type: 'text',
defaultValue: path || ''
defaultValue: ''
}
],
OK: function( res ) {
@@ -177,7 +169,7 @@ $(document).ready(function() {
if ( res['name'] ) {
name = res['name'];
}
window.location = baseUrl + encodeURIComponent(name);
window.location = baseUrl + '/' + encodeURIComponent(name);
}
});
});
@@ -220,4 +212,37 @@ $(document).ready(function() {
$('#gollum-revert-form').submit();
});
}
if( $('#wiki-wrapper.edit').length ){
$("#gollum-editor-submit").click( function() { window.onbeforeunload = null; } );
$("#gollum-editor-body").one('change', function(){
window.onbeforeunload = function(){ return "Leaving will discard all edits!" };
});
$.GollumEditor();
}
if( $('#wiki-wrapper.create').length ){
$("#gollum-editor-submit").click( function() { window.onbeforeunload = null; } );
$("#gollum-editor-body").one('change', function(){
window.onbeforeunload = function(){ return "Leaving will not create a new page!" };
});
$.GollumEditor({ NewFile: true, MarkupType: default_markup });
}
if( $('#wiki-history').length ){
var lookup = {};
$('img.identicon').each(function(index, element){
var $item = $(element);
var code = parseInt($item.data('identicon'), 10);
var img_bin = lookup[code];
if( img_bin === undefined ){
var size = 16;
var canvas = $('<canvas width=16 height=16/>').get(0);
render_identicon(canvas, code, 16);
img_bin = canvas.toDataURL("image/png");
lookup[code] = img_bin;
}
$item.attr('src', img_bin);
});
}
});
@@ -0,0 +1,111 @@
/*
Client-side Canvas tag based Identicon rendering code
@author Don Park
@version 0.2
@date January 21th, 2007
*/
var patch0 = new Array( 0, 4, 24, 20 );
var patch1 = new Array( 0, 4, 20 );
var patch2 = new Array( 2, 24, 20 );
var patch3 = new Array( 0, 2, 20, 22 );
var patch4 = new Array( 2, 14, 22, 10 );
var patch5 = new Array( 0, 14, 24, 22 );
var patch6 = new Array( 2, 24, 22, 13, 11, 22, 20 );
var patch7 = new Array( 0, 14, 22 );
var patch8 = new Array( 6, 8, 18, 16 );
var patch9 = new Array( 4, 20, 10, 12, 2 );
var patch10 = new Array( 0, 2, 12, 10 );
var patch11 = new Array( 10, 14, 22 );
var patch12 = new Array( 20, 12, 24 );
var patch13 = new Array( 10, 2, 12 );
var patch14 = new Array( 0, 2, 10 );
var patchTypes = new Array( patch0, patch1, patch2, patch3, patch4,
patch5, patch6, patch7, patch8, patch9, patch10, patch11,
patch12, patch13, patch14, patch0 );
var centerPatchTypes = new Array(0, 4, 8, 15);
function render_identicon_patch(ctx, x, y, size, patch, turn, invert, foreColor, backColor) {
patch %= patchTypes.length;
turn %= 4;
if (patch == 15)
invert = !invert;
var vertices = patchTypes[patch];
var offset = size / 2;
var scale = size / 4;
ctx.save();
// paint background
ctx.fillStyle = invert ? foreColor : backColor;
ctx.fillRect(x, y, size, size);
// build patch path
ctx.translate(x + offset, y + offset);
ctx.rotate(turn * Math.PI / 2);
ctx.beginPath();
ctx.moveTo((vertices[0] % 5 * scale - offset), (Math.floor(vertices[0] / 5) * scale - offset));
for (var i = 1; i < vertices.length; i++)
ctx.lineTo((vertices[i] % 5 * scale - offset), (Math.floor(vertices[i] / 5) * scale - offset));
ctx.closePath();
// offset and rotate coordinate space by patch position (x, y) and
// 'turn' before rendering patch shape
// render rotated patch using fore color (back color if inverted)
ctx.fillStyle = invert ? backColor : foreColor;
ctx.fill();
// restore rotation
ctx.restore();
}
function render_identicon(node, code, size) {
if (!node || !code || !size) return;
var patchSize = size / 3;
var middleType = centerPatchTypes[code & 3];
var middleInvert = ((code >> 2) & 1) != 0;
var cornerType = (code >> 3) & 15;
var cornerInvert = ((code >> 7) & 1) != 0;
var cornerTurn = (code >> 8) & 3;
var sideType = (code >> 10) & 15;
var sideInvert = ((code >> 14) & 1) != 0;
var sideTurn = (code >> 15) & 3;
var blue = (code >> 16) & 31;
var green = (code >> 21) & 31;
var red = (code >> 27) & 31;
var foreColor = "rgb(" + (red << 3) + "," + (green << 3) + "," + (blue << 3) + ")";
var backColor = "rgb(255,255,255)";
var ctx = node.getContext("2d");
// middle patch
render_identicon_patch(ctx, patchSize, patchSize, patchSize, middleType, 0, middleInvert, foreColor, backColor);
// side patchs, starting from top and moving clock-wise
render_identicon_patch(ctx, patchSize, 0, patchSize, sideType, sideTurn++, sideInvert, foreColor, backColor);
render_identicon_patch(ctx, patchSize * 2, patchSize, patchSize, sideType, sideTurn++, sideInvert, foreColor, backColor);
render_identicon_patch(ctx, patchSize, patchSize * 2, patchSize, sideType, sideTurn++, sideInvert, foreColor, backColor);
render_identicon_patch(ctx, 0, patchSize, patchSize, sideType, sideTurn++, sideInvert, foreColor, backColor);
// corner patchs, starting from top left and moving clock-wise
render_identicon_patch(ctx, 0, 0, patchSize, cornerType, cornerTurn++, cornerInvert, foreColor, backColor);
render_identicon_patch(ctx, patchSize * 2, 0, patchSize, cornerType, cornerTurn++, cornerInvert, foreColor, backColor);
render_identicon_patch(ctx, patchSize * 2, patchSize * 2, patchSize, cornerType, cornerTurn++, cornerInvert, foreColor, backColor);
render_identicon_patch(ctx, 0, patchSize * 2, patchSize, cornerType, cornerTurn++, cornerInvert, foreColor, backColor);
}
function render_identicon_canvases(prefix) {
var canvases = document.getElementsByTagName("canvas");
var n = canvases.length;
for (var i = 0; i < n; i++) {
var node = canvases[i];
if (node.title && node.title.indexOf(prefix) == 0) {
if (node.style.display == 'none') node.style.display = "inline";
var code = node.title.substring(prefix.length) * 1;
var size = node.width;
render_identicon(node, code, size);
}
}
}
@@ -2,6 +2,10 @@ body {
overflow: hidden;
}
#editor .ace_sb {
overflow-y: auto !important;
}
#darkness {
visibility: hidden;
position: absolute;
@@ -49,7 +53,7 @@ so editor doesn't display in the background. */
#contentframe {
margin: 0 auto;
overflow: visible;
width: 80%;
width: 90%;
}
#previewframe {
@@ -63,14 +67,35 @@ so editor doesn't display in the background. */
right: 0;
}
.editor_bg {
position: fixed;
top: 0;
margin: 0;
padding: 0;
background: black;
width: 50%;
height: 100%;
z-index: -2;
}
.toolpanel_bg {
position: fixed;
background: #666;
top: 0;
height: 30px;
width: 100%;
padding: 5px 0;
margin: 0;
z-index: -1;
}
/* -- Start from notepag.es -- */
.toolpanel {
position: fixed;
background: #666;
top: 0;
height: 30px;
right: 20px;
width: 80px;
width: 50%;
vertical-align: middle;
padding: 5px 0;
margin: 0;
Binary file not shown.

After

Width:  |  Height:  |  Size: 630 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 757 B

After

Width:  |  Height:  |  Size: 919 B

@@ -11,11 +11,15 @@
<div id='previewframe'><div id='contentframe' class='markdown-body'></div></div>
<!-- tool panel from notepage.es. save & savecomment icons from Retina Display Icon Set. -->
<div id='toolpanel' class='toolpanel edit' style='width: 500px; right: 0px; visibility: hidden;'>
<a id='preview' class='edit'><img src='images/globe_24.png' alt='Preview' title='Preview'></a>
<a id='save' class='edit'><img src='images/save_24.png' alt='Save' title='Save'></a>
<a id='savecomment' class='edit'><img src='images/savecomment_24.png' alt='Save with comment' title='Save with comment'></a>
<a id='toggle' class='edit' href='javascript:void(0)' onclick='jsm.toggleLeftRight();'><img src='images/lr_24.png' alt='Toggle left to right' title='Toggle left to right'></a>
</div>
<div id='editor_bg' class='editor_bg'></div>
<div class='toolpanel_bg'></div>
<div id='commenttoolpanel' class='toolpanel edit' style='width: 500px; right: 0px; '>
<a id='savecommentconfirm' class='edit'><img src='images/savecomment_24.png' alt='Confirm save with comment' title='Confirm save with comment'></a>
<a id='commentcancel' class='edit'><img src='images/cancel_24.png' alt='Cancel save with comment' title='Cancel save with comment'></a>
@@ -36,11 +40,5 @@ var require = {
<script src='js/sundown.js'></script>
<script src='js/md_sundown.js'></script>
<script src='js/livepreview.js'></script>
<script>(function(d,j){
j = d.createElement('script');
j.src = 'https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML';
(d.head || d.getElementsByTagName('head')[0]).appendChild(j);
}(document));
</script>
</body>
</html>
@@ -1,46 +1,37 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Skywriter.
*
* The Initial Developer of the Original Code is
* Mozilla.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Kevin Dangoor (kdangoor@mozilla.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
/**
* class Ace
*
* The main class required to set up an Ace instance in the browser.
*
*
* @class Ace
**/
define(function(require, exports, module) {
@@ -48,8 +39,8 @@ define(function(require, exports, module) {
require("./lib/fixoldbrowsers");
var Dom = require("./lib/dom");
var Event = require("./lib/event");
var dom = require("./lib/dom");
var event = require("./lib/event");
var Editor = require("./editor").Editor;
var EditSession = require("./edit_session").EditSession;
@@ -60,44 +51,57 @@ var MultiSelect = require("./multi_select").MultiSelect;
// The following require()s are for inclusion in the built ace file
require("./worker/worker_client");
require("./keyboard/hash_handler");
require("./keyboard/state_handler");
require("./placeholder");
require("./mode/folding/fold_mode");
exports.config = require("./config");
/**
* Ace.edit(el) -> Editor
* - el (String | DOMElement): Either the id of an element, or the element itself
*
* This method embeds the Ace editor into the DOM, at the element provided by `el`.
*
**/
/**
* Provides access to require in packed noconflict mode
* @param {String} moduleName
* @returns {Object}
*
**/
exports.require = require;
/**
* Embeds the Ace editor into the DOM, at the element provided by `el`.
* @param {String | DOMElement} el Either the id of an element, or the element itself
*
**/
exports.edit = function(el) {
if (typeof(el) == "string") {
el = document.getElementById(el);
var _id = el;
var el = document.getElementById(_id);
if (!el)
throw "ace.edit can't find div #" + _id;
}
if (el.env && el.env.editor instanceof Editor)
return el.env.editor;
var doc = new EditSession(Dom.getInnerText(el));
doc.setUndoManager(new UndoManager());
var doc = exports.createEditSession(dom.getInnerText(el));
el.innerHTML = '';
var editor = new Editor(new Renderer(el, require("./theme/textmate")));
var editor = new Editor(new Renderer(el));
new MultiSelect(editor);
editor.setSession(doc);
var env = {};
env.document = doc;
env.editor = editor;
editor.resize();
Event.addListener(window, "resize", function() {
editor.resize();
});
el.env = env;
// Store env on editor such that it can be accessed later on from
// the returned object.
editor.env = env;
var env = {
document: doc,
editor: editor,
onResize: editor.resize.bind(editor)
};
event.addListener(window, "resize", env.onResize);
el.env = editor.env = env;
return editor;
};
exports.createEditSession = function(text, mode) {
var doc = new EditSession(text, doc);
doc.setUndoManager(new UndoManager());
return doc;
}
exports.EditSession = EditSession;
exports.UndoManager = UndoManager;
});
@@ -1,37 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -42,20 +35,20 @@ var oop = require("./lib/oop");
var EventEmitter = require("./lib/event_emitter").EventEmitter;
/**
* class Anchor
*
* Defines the floating pointer in the document. Whenever text is inserted or deleted before the cursor, the position of the cursor is updated
*
* Defines the floating pointer in the document. Whenever text is inserted or deleted before the cursor, the position of the cursor is updated.
*
* @class Anchor
**/
/**
* new Anchor(doc, row, column)
* - doc (Document): The document to associate with the anchor
* - row (Number): The starting row position
* - column (Number): The starting column position
*
* Creates a new `Anchor` and associates it with a document.
*
* @param {Document} doc The document to associate with the anchor
* @param {Number} row The starting row position
* @param {Number} column The starting column position
*
* @constructor
**/
var Anchor = exports.Anchor = function(doc, row, column) {
@@ -75,10 +68,8 @@ var Anchor = exports.Anchor = function(doc, row, column) {
oop.implement(this, EventEmitter);
/**
* Anchor.getPosition() -> Object
*
* Returns an object identifying the `row` and `column` position of the current anchor.
*
* @returns {Object}
**/
this.getPosition = function() {
@@ -86,10 +77,9 @@ var Anchor = exports.Anchor = function(doc, row, column) {
};
/**
* Anchor.getDocument() -> Document
*
*
* Returns the current document.
*
* @returns {Document}
**/
this.getDocument = function() {
@@ -97,10 +87,17 @@ var Anchor = exports.Anchor = function(doc, row, column) {
};
/**
* Anchor@onChange(e)
* - e (Event): Contains data about the event
* Fires whenever the anchor position changes.
*
* Both of these objects have a `row` and `column` property corresponding to the position.
*
* Events that can trigger this function include [[Anchor.setPosition `setPosition()`]].
*
* @event change
* @param {Object} e An object containing information about the anchor position. It has two properties:
* - `old`: An object describing the old Anchor position
* - `value`: An object describing the new Anchor position
*
* Fires whenever the anchor position changes. Events that can trigger this function include `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`.
*
**/
@@ -170,12 +167,12 @@ var Anchor = exports.Anchor = function(doc, row, column) {
};
/**
* Anchor.setPosition(row, column, noClip)
* - row (Number): The row index to move the anchor to
* - column (Number): The column index to move the anchor to
* - noClip (Boolean): Identifies if you want the position to be clipped
*
* Sets the anchor position to the specified row and column. If `noClip` is `true`, the position is not clipped.
* @param {Number} row The row index to move the anchor to
* @param {Number} column The column index to move the anchor to
* @param {Boolean} noClip Identifies if you want the position to be clipped
*
*
*
**/
@@ -208,8 +205,6 @@ var Anchor = exports.Anchor = function(doc, row, column) {
};
/**
* Anchor.detach()
*
* When called, the `'change'` event listener is removed.
*
**/
@@ -218,15 +213,14 @@ var Anchor = exports.Anchor = function(doc, row, column) {
this.document.removeEventListener("change", this.$onChange);
};
/** internal, hide
* Anchor.clipPositionToDocument(row, column)
* - row (Number): The row index to clip the anchor to
* - column (Number): The column index to clip the anchor to
*
/**
* Clips the anchor position to the specified row and column.
* @param {Number} row The row index to clip the anchor to
* @param {Number} column The column index to clip the anchor to
*
*
*
**/
this.$clipPositionToDocument = function(row, column) {
var pos = {};
@@ -1,37 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -1,37 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -45,20 +38,23 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter;
var MAX_LINE_LENGTH = 5000;
/**
* class BackgroundTokenizer
*
*
* Tokenizes the current [[Document `Document`]] in the background, and caches the tokenized rows for future use. If a certain row is changed, everything below that row is re-tokenized.
* Tokenizes the current [[Document `Document`]] in the background, and caches the tokenized rows for future use.
*
* If a certain row is changed, everything below that row is re-tokenized.
*
* @class BackgroundTokenizer
**/
/**
* new BackgroundTokenizer(tokenizer, editor)
* - tokenizer (Tokenizer): The tokenizer to use
* - editor (Editor): The editor to associate with
*
* Creates a new `BackgroundTokenizer` object.
* @param {Tokenizer} tokenizer The tokenizer to use
* @param {Editor} editor The editor to associate with
*
*
*
*
* @constructor
**/
var BackgroundTokenizer = function(tokenizer, editor) {
@@ -105,11 +101,10 @@ var BackgroundTokenizer = function(tokenizer, editor) {
oop.implement(this, EventEmitter);
/**
* BackgroundTokenizer.setTokenizer(tokenizer)
* - tokenizer (Tokenizer): The new tokenizer to use
*
* Sets a new tokenizer for this object.
*
* @param {Tokenizer} tokenizer The new tokenizer to use
*
**/
this.setTokenizer = function(tokenizer) {
this.tokenizer = tokenizer;
@@ -120,11 +115,8 @@ var BackgroundTokenizer = function(tokenizer, editor) {
};
/**
* BackgroundTokenizer.setDocument(doc)
* - doc (Document): The new document to associate with
*
* Sets a new document to associate with this object.
*
* @param {Document} doc The new document to associate with
**/
this.setDocument = function(doc) {
this.doc = doc;
@@ -134,12 +126,17 @@ var BackgroundTokenizer = function(tokenizer, editor) {
this.stop();
};
/**
* BackgroundTokenizer.fireUpdateEvent(firstRow, lastRow)
* - firstRow (Number): The starting row region
* - lastRow (Number): The final row region
/**
* Fires whenever the background tokeniziers between a range of rows are going to be updated.
*
* @event update
* @param {Object} e An object containing two properties, `first` and `last`, which indicate the rows of the region being updated.
*
**/
/**
* Emits the `'update'` event. `firstRow` and `lastRow` are used to define the boundaries of the region to be updated.
* @param {Number} firstRow The starting row region
* @param {Number} lastRow The final row region
*
**/
this.fireUpdateEvent = function(firstRow, lastRow) {
@@ -151,11 +148,10 @@ var BackgroundTokenizer = function(tokenizer, editor) {
};
/**
* BackgroundTokenizer.start(startRow)
* - startRow (Number): The row to start at
*
* Starts tokenizing at the row indicated.
*
* @param {Number} startRow The row to start at
*
**/
this.start = function(startRow) {
this.currentLine = Math.min(startRow || 0, this.currentLine, this.doc.getLength());
@@ -194,8 +190,6 @@ var BackgroundTokenizer = function(tokenizer, editor) {
};
/**
* BackgroundTokenizer.stop()
*
* Stops tokenizing.
*
**/
@@ -205,12 +199,12 @@ var BackgroundTokenizer = function(tokenizer, editor) {
this.running = false;
};
/** related to: BackgroundTokenizer.$tokenizeRows
* BackgroundTokenizer.getTokens(firstRow, lastRow) -> [Object]
* - firstRow (Number): The row to start at
* - lastRow (Number): The row to finish at
/**
* Gives list of tokens of the row. (tokens are cached)
*
* @param {Number} row The row to get tokens at
*
* Starts tokenizing at the row indicated. Returns a list of objects of the tokenized rows.
*
*
**/
this.getTokens = function(row) {
@@ -218,10 +212,9 @@ var BackgroundTokenizer = function(tokenizer, editor) {
};
/**
* BackgroundTokenizer.getState(row) -> String
* - row (Number): The row to start at
*
* [Returns the state of tokenization at the end of a row.]{: #BackgroundTokenizer.getState}
*
* @param {Number} row The row to get state at
**/
this.getState = function(row) {
if (this.currentLine == row)
@@ -1,37 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Harutyun Amirjanyan <harutyun@c9.io>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -6,26 +6,24 @@ var HashHandler = require("../keyboard/hash_handler").HashHandler;
var EventEmitter = require("../lib/event_emitter").EventEmitter;
/**
* class CommandManager
* @class CommandManager
*
*
**/
/**
* new CommandManager(platform, commands)
* @param {String} platform Identifier for the platform; must be either `'mac'` or `'win'`
* @param {Array} commands A list of commands
*
*
*
*
**/
/**
* new CommandManager(platform, commands)
* - platform (String): Identifier for the platform; must be either `'mac'` or `'win'`
* - commands (Array): A list of commands
*
* TODO
*
*
**/
var CommandManager = function(platform, commands) {
this.platform = platform;
this.commands = {};
this.commands = this.byName = {};
this.commmandKeyBinding = {};
this.addCommands(commands);
@@ -60,9 +58,11 @@ oop.inherits(CommandManager, HashHandler);
return retvalue === false ? false : true;
};
this.toggleRecording = function() {
this.toggleRecording = function(editor) {
if (this.$inReplay)
return;
editor && editor._emit("changeStatus");
if (this.recording) {
this.macro.pop();
this.removeEventListener("exec", this.$addCommandToMacro);
@@ -74,8 +74,8 @@ oop.inherits(CommandManager, HashHandler);
}
if (!this.$addCommandToMacro) {
this.$addCommandToMacro = function(e) {
this.macro.push([e.command, e.args]);
}.bind(this);
this.macro.push([e.command, e.args]);
}.bind(this);
}
this.oldMacro = this.macro;
@@ -89,7 +89,7 @@ oop.inherits(CommandManager, HashHandler);
return;
if (this.recording)
return this.toggleRecording();
return this.toggleRecording(editor);
try {
this.$inReplay = true;
@@ -1,37 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -68,20 +61,20 @@ module.exports = {
},
"test: mac hotkeys": function() {
var command = this.cm.findKeyCommand(keys.KEY_MODS.command, "L");
var command = this.cm.findKeyCommand(keys.KEY_MODS.command, "l");
assert.equal(command, this.command);
var command = this.cm.findKeyCommand(keys.KEY_MODS.ctrl, "L");
var command = this.cm.findKeyCommand(keys.KEY_MODS.ctrl, "l");
assert.equal(command, undefined);
},
"test: win hotkeys": function() {
var cm = new CommandManager("win", [this.command]);
var command = cm.findKeyCommand(keys.KEY_MODS.command, "L");
var command = cm.findKeyCommand(keys.KEY_MODS.command, "l");
assert.equal(command, undefined);
var command = cm.findKeyCommand(keys.KEY_MODS.ctrl, "L");
var command = cm.findKeyCommand(keys.KEY_MODS.ctrl, "l");
assert.equal(command, this.command);
},
@@ -91,7 +84,7 @@ module.exports = {
this.cm.exec("gotoline");
assert.ok(!this.command.called);
var command = this.cm.findKeyCommand(keys.KEY_MODS.command, "L");
var command = this.cm.findKeyCommand(keys.KEY_MODS.command, "l");
assert.equal(command, null);
},
@@ -101,7 +94,7 @@ module.exports = {
this.cm.exec("gotoline");
assert.ok(!this.command.called);
var command = this.cm.findKeyCommand(keys.KEY_MODS.command, "L");
var command = this.cm.findKeyCommand(keys.KEY_MODS.command, "l");
assert.equal(command, null);
},
@@ -121,14 +114,14 @@ module.exports = {
assert.ok(command.called);
assert.ok(!this.command.called);
assert.equal(this.cm.findKeyCommand(keys.KEY_MODS.command, "L"), command);
assert.equal(this.cm.findKeyCommand(keys.KEY_MODS.command, "l"), command);
},
"test: adding commands and recording a macro": function() {
var called = "";
this.cm.addCommands({
togglerecording: function(editor) {
editor.cm.toggleRecording();
editor.cm.toggleRecording(editor);
},
replay: function(editor) {
editor.cm.replay();
@@ -140,9 +133,14 @@ module.exports = {
called += "2";
}
});
var statusUpdateEmitted = false;
this._emit = function() {statusUpdateEmitted = true};
this.cm.exec("togglerecording", this);
assert.ok(this.cm.recording);
assert.ok(statusUpdateEmitted);
this.cm.exec("cm1", this, "-");
this.cm.exec("cm2");
@@ -156,33 +154,41 @@ module.exports = {
},
"test: bindkeys": function() {
var called = "";
this.cm.addCommands({
cm1: function(editor, arg) {
called += "1" + (arg || "");
},
cm2: function(editor) {
called += "2";
}
});
this.cm.bindKeys({
"Ctrl-L|Command-C": "cm1",
"Ctrl-R": "cm2"
});
var command = this.cm.findKeyCommand(keys.KEY_MODS.command, "C");
var command = this.cm.findKeyCommand(keys.KEY_MODS.command, "c");
assert.equal(command, "cm1");
var command = this.cm.findKeyCommand(keys.KEY_MODS.ctrl, "R");
var command = this.cm.findKeyCommand(keys.KEY_MODS.ctrl, "r");
assert.equal(command, "cm2");
this.cm.bindKeys({
"Ctrl-R": null
});
var command = this.cm.findKeyCommand(keys.KEY_MODS.ctrl, "R");
var command = this.cm.findKeyCommand(keys.KEY_MODS.ctrl, "r");
assert.equal(command, null);
},
"test: binding keys without modifiers": function() {
this.cm.bindKeys({
"R": "cm1",
"Shift-r": "cm2",
"Return": "cm4",
"Enter": "cm3"
});
var command = this.cm.findKeyCommand(-1, "r");
assert.equal(command, "cm1");
var command = this.cm.findKeyCommand(-1, "R");
assert.equal(command, "cm2");
var command = this.cm.findKeyCommand(0, "return");
assert.equal(command, "cm3");
}
};
@@ -1,40 +1,30 @@
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Julian Viereck <julian.viereck@gmail.com>
* Mihai Sucan <mihai.sucan@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -117,11 +107,13 @@ exports.commands = [{
name: "selecttostart",
bindKey: bindKey("Ctrl-Shift-Home", "Command-Shift-Up"),
exec: function(editor) { editor.getSelection().selectFileStart(); },
multiSelectAction: "forEach",
readOnly: true
}, {
name: "gotostart",
bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"),
exec: function(editor) { editor.navigateFileStart(); },
multiSelectAction: "forEach",
readOnly: true
}, {
name: "selectup",
@@ -286,7 +278,7 @@ exports.commands = [{
}, {
name: "togglerecording",
bindKey: bindKey("Ctrl-Alt-E", "Command-Option-E"),
exec: function(editor) { editor.commands.toggleRecording(); },
exec: function(editor) { editor.commands.toggleRecording(editor); },
readOnly: true
}, {
name: "replaymacro",
@@ -295,13 +287,13 @@ exports.commands = [{
readOnly: true
}, {
name: "jumptomatching",
bindKey: bindKey("Ctrl-P", "Ctrl-P"),
bindKey: bindKey("Ctrl-P", "Ctrl-Shift-P"),
exec: function(editor) { editor.jumpToMatching(); },
multiSelectAction: "forEach",
readOnly: true
}, {
name: "selecttomatching",
bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
bindKey: bindKey("Ctrl-Shift-P", null),
exec: function(editor) { editor.jumpToMatching(true); },
readOnly: true
},
@@ -329,11 +321,26 @@ exports.commands = [{
bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"),
exec: function(editor) { editor.duplicateSelection(); },
multiSelectAction: "forEach"
}, {
name: "sortlines",
bindKey: bindKey("Ctrl-Alt-S", "Command-Alt-S"),
exec: function(editor) { editor.sortLines(); },
multiSelectAction: "forEach"
}, {
name: "togglecomment",
bindKey: bindKey("Ctrl-/", "Command-/"),
exec: function(editor) { editor.toggleCommentLines(); },
multiSelectAction: "forEach"
}, {
name: "modifyNumberUp",
bindKey: bindKey("Ctrl-Shift-Up", "Alt-Shift-Up"),
exec: function(editor) { editor.modifyNumber(1); },
multiSelectAction: "forEach"
}, {
name: "modifyNumberDown",
bindKey: bindKey("Ctrl-Shift-Down", "Alt-Shift-Down"),
exec: function(editor) { editor.modifyNumber(-1); },
multiSelectAction: "forEach"
}, {
name: "replace",
bindKey: bindKey("Ctrl-R", "Command-Option-F"),
@@ -1,38 +1,30 @@
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Harutyun Amirjanyan <amirjanyan AT gmail DOT com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -82,11 +74,15 @@ exports.defaultCommands = [{
}, {
name: "splitIntoLines",
exec: function(editor) { editor.multiSelect.splitIntoLines(); },
bindKey: {win: "Ctrl-Shift-L", mac: "Ctrl-Shift-L"},
bindKey: {win: "Ctrl-Alt-L", mac: "Ctrl-Alt-L"},
readonly: true
}, {
name: "alignCursors",
exec: function(editor) { editor.alignCursors(); },
bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"}
}];
// commands active in multiselect mode
// commands active only in multiselect mode
exports.multiSelectCommands = [{
name: "singleSelection",
bindKey: "esc",
@@ -1,38 +1,30 @@
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -47,23 +39,25 @@ var global = (function() {
var options = {
packaged: false,
workerPath: "",
modePath: "",
themePath: "",
suffix: ".js"
workerPath: null,
modePath: null,
themePath: null,
basePath: "",
suffix: ".js",
$moduleUrls: {}
};
exports.get = function(key) {
if (!options.hasOwnProperty(key))
throw new Error("Unknown config key: " + key);
return options[key];
};
exports.set = function(key, value) {
if (!options.hasOwnProperty(key))
throw new Error("Unknown config key: " + key);
options[key] = value;
};
@@ -71,6 +65,28 @@ exports.all = function() {
return lang.copyObject(options);
};
exports.moduleUrl = function(name, component) {
if (options.$moduleUrls[name])
return options.$moduleUrls[name];
var parts = name.split("/");
component = component || parts[parts.length - 2] || "";
var base = parts[parts.length - 1].replace(component, "").replace(/(^[\-_])|([\-_]$)/, "");
if (!base && parts.length > 1)
base = parts[parts.length - 2];
var path = options[component + "Path"];
if (path == null)
path = options.basePath;
if (path && path.slice(-1) != "/")
path += "/";
return path + component + "-" + base + this.get("suffix");
};
exports.setModuleUrl = function(name, subst) {
return options.$moduleUrls[name] = subst;
};
exports.init = function() {
options.packaged = require.packaged || module.packaged || (global.define && define.packaged);
@@ -79,16 +95,15 @@ exports.init = function() {
var scriptOptions = {};
var scriptUrl = "";
var scripts = document.getElementsByTagName("script");
for (var i=0; i<scripts.length; i++) {
var script = scripts[i];
var src = script.src || script.getAttribute("src");
if (!src) {
if (!src)
continue;
}
var attributes = script.attributes;
for (var j=0, l=attributes.length; j < l; j++) {
var attr = attributes[j];
@@ -101,17 +116,17 @@ exports.init = function() {
if (m)
scriptUrl = m[1];
}
if (scriptUrl) {
scriptOptions.base = scriptOptions.base || scriptUrl;
scriptOptions.packaged = true;
}
scriptOptions.workerPath = scriptOptions.workerPath || scriptOptions.base;
scriptOptions.modePath = scriptOptions.modePath || scriptOptions.base;
scriptOptions.themePath = scriptOptions.themePath || scriptOptions.base;
delete scriptOptions.base;
for (var key in scriptOptions)
if (typeof scriptOptions[key] !== "undefined")
exports.set(key, scriptOptions[key]);
@@ -0,0 +1,71 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
if (typeof process !== "undefined") {
require("amd-loader");
}
define(function(require, exports, module) {
"use strict";
var config = require("./config");
var assert = require("./test/assertions");
module.exports = {
"test path resolution" : function() {
config.set("packaged", "true");
var url = config.moduleUrl("kr_theme", "theme");
assert.equal(url, "theme-kr.js");
config.set("basePath", "a/b");
url = config.moduleUrl("m/theme", "theme");
assert.equal(url, "a/b/theme-m.js");
url = config.moduleUrl("m/theme", "ext");
assert.equal(url, "a/b/ext-theme.js");
config.set("workerPath", "c/");
url = config.moduleUrl("foo/1", "worker");
assert.equal(url, "c/worker-1.js");
config.setModuleUrl("foo/1", "a/b1.js");
url = config.moduleUrl("foo/1", "theme");
assert.equal(url, "a/b1.js");
assert.equal();
}
};
});
if (typeof module !== "undefined" && module === require.main) {
require("asyncjs").test.testcase(module.exports).exec()
}
@@ -1,7 +1,7 @@
.ace_editor {
position: absolute;
overflow: hidden;
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Droid Sans Mono', 'Consolas', monospace;
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
font-size: 12px;
}
@@ -12,9 +12,9 @@
.ace_content {
position: absolute;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
cursor: text;
}
@@ -27,13 +27,20 @@
z-index: 4;
}
.ace_scroller.horscroll {
.ace_gutter-active-line {
position: absolute;
left: 0;
right: 0;
}
.ace_scroller.ace_scroll-left {
box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;
}
.ace_gutter-cell {
padding-left: 19px;
padding-right: 6px;
background-repeat: no-repeat;
}
.ace_gutter-cell.ace_error {
@@ -44,7 +51,6 @@
.ace_gutter-cell.ace_warning {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6QUM2OEZDQTg4RTU0MTFFMUEzM0VFRTM2RUY1M0RBMjYiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6QUM2OEZDQTk4RTU0MTFFMUEzM0VFRTM2RUY1M0RBMjYiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpBQzY4RkNBNjhFNTQxMUUxQTMzRUVFMzZFRjUzREEyNiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpBQzY4RkNBNzhFNTQxMUUxQTMzRUVFMzZFRjUzREEyNiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pgd7PfIAAAGmSURBVHjaYvr//z8DJZiJgUIANoCRkREb9gLiSVAaQx4OQM7AAkwd7XU2/v++/rOttdYGEB9dASEvOMydGKfH8Gv/p4XTkvRBfLxeQAP+1cUhXopyvzhP7P/IoSj7g7Mw09cNKO6J1QQ0L4gICPIv/veg/8W+JdFvQNLHVsW9/nmn9zk7B+cCkDwhL7gt6knSZnx9/LuCEOcvkIAMP+cvto9nfqyZmmUAksfnBUtbM60gX/3/kgyv3/xSFOL5DZT+L8vP+Yfh5cvfPvp/xUHyQHXGyAYwgpwBjZYFT3Y1OEl/OfCH4ffv3wzc4iwMvNIsDJ+f/mH4+vIPAxsb631WW0Yln6ZpQLXdMK/DXGDflh+sIv37EivD5x//Gb7+YWT4y86sl7BCCkSD+Z++/1dkvsFRl+HnD1Rvje4F8whjMXmGj58YGf5zsDMwcnAwfPvKcml62DsQDeaDxN+/Y0qwlpEHqrdB94IRNIDUgfgfKJChGK4OikEW3gTiXUB950ASLFAF54AC94A0G9QAfOnmF9DCDzABFqS08IHYDIScdijOjQABBgC+/9awBH96jwAAAABJRU5ErkJggg==");
background-repeat: no-repeat;
background-position: 2px center;
}
@@ -56,50 +62,40 @@
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpGRTk5MTVGREIxNDkxMUUxOTc5Q0FFREQyMTNGMjBFQyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpGRTk5MTVGRUIxNDkxMUUxOTc5Q0FFREQyMTNGMjBFQyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkZFOTkxNUZCQjE0OTExRTE5NzlDQUVERDIxM0YyMEVDIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkZFOTkxNUZDQjE0OTExRTE5NzlDQUVERDIxM0YyMEVDIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+SIDkjAAAAJ1JREFUeNpi/P//PwMlgImBQkB7A6qrq/+DMC55FkIGKCoq4pVnpFkgTp069f/+/fv/r1u37r+tre1/kg0A+ptn9uzZYLaRkRHpLvjw4cNXWVlZhufPnzOcO3eOdAO0tbVPAjHDmzdvGA4fPsxIsgGSkpJmv379Ynj37h2DjIyMCMkG3LhxQ/T27dsMampqDHZ2dq/pH41DxwCAAAMAFdc68dUsFZgAAAAASUVORK5CYII=");
}
.ace_editor .ace_sb {
.ace_scrollbar {
position: absolute;
overflow-x: hidden;
overflow-y: scroll;
right: 0;
}
.ace_editor .ace_sb div {
.ace_scrollbar-inner {
position: absolute;
width: 1px;
left: 0;
}
.ace_editor .ace_print_margin_layer {
z-index: 0;
position: absolute;
overflow: hidden;
margin: 0;
left: 0;
height: 100%;
width: 100%;
}
.ace_editor .ace_print_margin {
.ace_print-margin {
position: absolute;
height: 100%;
}
.ace_editor > textarea {
.ace_text-input {
position: absolute;
z-index: 0;
width: 0.5em;
height: 1em;
opacity: 0;
background: transparent;
appearance: none;
-moz-appearance: none;
appearance: none;
border: none;
resize: none;
outline: none;
overflow: hidden;
}
.ace_editor > textarea.ace_composition {
.ace_text-input.ace_composition {
background: #fff;
color: #000;
z-index: 1000;
@@ -115,17 +111,16 @@
white-space: nowrap;
height: 100%;
width: 100%;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
/* setting pointer-events: auto; on node under the mouse, which changes
during scroll, will break mouse wheel scrolling in Safari */
pointer-events: none;
}
.ace_gutter .ace_layer {
.ace_gutter-layer {
position: relative;
min-width: 40px;
width: auto;
text-align: right;
pointer-events: auto;
@@ -148,13 +143,28 @@
.ace_cursor {
z-index: 4;
position: absolute;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.ace_cursor.ace_hidden {
.ace_hidden-cursors .ace_cursor {
opacity: 0.2;
}
.ace_editor.multiselect .ace_cursor {
.ace_smooth-blinking .ace_cursor {
-moz-transition: opacity 0.18s;
-webkit-transition: opacity 0.18s;
-o-transition: opacity 0.18s;
-ms-transition: opacity 0.18s;
transition: opacity 0.18s;
}
.ace_cursor[style*="opacity: 0"]{
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
}
.ace_editor.ace_multiselect .ace_cursor {
border-left-width: 1px;
}
@@ -177,23 +187,23 @@
z-index: 6;
}
.ace_marker-layer .ace_active_line {
.ace_marker-layer .ace_active-line {
position: absolute;
z-index: 2;
}
.ace_marker-layer .ace_selected_word {
.ace_marker-layer .ace_selected-word {
position: absolute;
z-index: 4;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.ace_line .ace_fold {
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
display: inline-block;
height: 11px;
@@ -227,39 +237,55 @@
background-position: center center, top left;
}
.ace_dragging .ace_content {
.ace_editor.ace_dragging .ace_content {
cursor: move;
}
.ace_gutter-tooltip {
background-color: #FFFFD5;
border: 1px solid gray;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
color: black;
display: inline-block;
padding: 4px;
position: absolute;
z-index: 300;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
cursor: default;
white-space: pre-line;
word-wrap: break-word;
}
.ace_folding-enabled > .ace_gutter-cell {
padding-right: 13px;
}
.ace_fold-widget {
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
margin: 0 -12px 1px 1px;
margin: 0 -12px 0 1px;
display: inline-block;
height: 14px;
width: 11px;
vertical-align: text-bottom;
vertical-align: top;
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");
background-repeat: no-repeat;
background-position: center 4px;
background-position: center;
border-radius: 3px;
border: 1px solid transparent;
}
.ace_fold-widget.end {
.ace_fold-widget.ace_end {
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");
}
.ace_fold-widget.closed {
.ace_fold-widget.ace_closed {
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");
}
@@ -269,7 +295,6 @@
-moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);
-webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);
box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);
background-position: center 4px;
}
.ace_fold-widget:active {
@@ -285,10 +310,10 @@
.ace_dark .ace_fold-widget {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC");
}
.ace_dark .ace_fold-widget.end {
.ace_dark .ace_fold-widget.ace_end {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==");
}
.ace_dark .ace_fold-widget.closed {
.ace_dark .ace_fold-widget.ace_closed {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==");
}
.ace_dark .ace_fold-widget:hover {
@@ -303,7 +328,7 @@
.ace_fold-widget.invalid {
.ace_fold-widget.ace_invalid {
background-color: #FFB4B4;
border-color: #DE5555;
}
@@ -325,3 +350,19 @@
transition: opacity 0.05s ease 0.05s;
opacity:1;
}
.ace_underline {
text-decoration: underline;
}
.ace_bold {
font-weight: bold;
}
.ace_nobold .ace_bold {
font-weight: normal;
}
.ace_italic {
font-style: italic;
}
@@ -1,37 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -44,20 +37,20 @@ var Range = require("./range").Range;
var Anchor = require("./anchor").Anchor;
/**
* class Document
*
* Contains the text of the document. Documents are controlled by a single [[EditSession `EditSession`]]. At its core, `Document`s are just an array of strings, with each row in the document matching up to the array index.
* Contains the text of the document. Document can be attached to several [[EditSession `EditSession`]]s.
*
* At its core, `Document`s are just an array of strings, with each row in the document matching up to the array index.
*
* @class Document
**/
/**
* new Document([text])
* - text (String | Array): The starting text
*
* Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty.
*
* @param {String | Array} text The starting text
* @constructor
**/
var Document = function(text) {
this.$lines = [];
@@ -77,10 +70,9 @@ var Document = function(text) {
oop.implement(this, EventEmitter);
/**
* Document.setValue(text) -> Void
* - text (String): The text to use
*
* Replaces all the lines in the current `Document` with the value of `text`.
*
* @param {String} text The text to use
**/
this.setValue = function(text) {
var len = this.getLength();
@@ -89,8 +81,6 @@ var Document = function(text) {
};
/**
* Document.getValue() -> String
*
* Returns all the lines in the document as a single string, split by the new line character.
**/
this.getValue = function() {
@@ -98,23 +88,23 @@ var Document = function(text) {
};
/**
* Document.createAnchor(row, column) -> Anchor
* - row (Number): The row number to use
* - column (Number): The column number to use
*
* Creates a new `Anchor` to define a floating point in the document.
* @param {Number} row The row number to use
* @param {Number} column The column number to use
*
*
**/
this.createAnchor = function(row, column) {
return new Anchor(this, row, column);
};
/** internal, hide
* Document.$split(text) -> [String]
* - text (String): The text to work with
* + ([String]): A String array, with each index containing a piece of the original `text` string.
*
/**
* Splits a string of text on any newline (`\n`) or carriage-return ('\r') characters.
*
* @method $split
* @param {String} text The text to work with
* @returns {String} A String array, with each index containing a piece of the original `text` string.
*
*
**/
@@ -129,11 +119,7 @@ var Document = function(text) {
};
/** internal, hide
* Document.$detectNewLine(text) -> Void
*
*
**/
this.$detectNewLine = function(text) {
var match = text.match(/^.*?(\r\n|\r|\n)/m);
if (match) {
@@ -144,12 +130,11 @@ var Document = function(text) {
};
/**
* Document.getNewLineCharacter() -> String
* + (String): If `newLineMode == windows`, `\r\n` is returned.<br/>
* If `newLineMode == unix`, `\n` is returned.<br/>
* Returns the newline character that's being used, depending on the value of `newLineMode`.
* @returns {String} If `newLineMode == windows`, `\r\n` is returned.
* If `newLineMode == unix`, `\n` is returned.
* If `newLineMode == auto`, the value of `autoNewLine` is returned.
*
* Returns the newline character that's being used, depending on the value of `newLineMode`.
*
*
*
@@ -170,10 +155,10 @@ var Document = function(text) {
this.$autoNewLine = "\n";
this.$newLineMode = "auto";
/**
* Document.setNewLineMode(newLineMode) -> Void
* - newLineMode(String): [The newline mode to use; can be either `windows`, `unix`, or `auto`]{: #Document.setNewLineMode.param}
*
* [Sets the new line mode.]{: #Document.setNewLineMode.desc}
* @param {String} newLineMode [The newline mode to use; can be either `windows`, `unix`, or `auto`]{: #Document.setNewLineMode.param}
*
*
**/
this.setNewLineMode = function(newLineMode) {
if (this.$newLineMode === newLineMode)
@@ -183,20 +168,18 @@ var Document = function(text) {
};
/**
* Document.getNewLineMode() -> String
*
* [Returns the type of newlines being used; either `windows`, `unix`, or `auto`]{: #Document.getNewLineMode}
*
* @returns String
**/
this.getNewLineMode = function() {
return this.$newLineMode;
};
/**
* Document.isNewLine(text) -> Boolean
* - text (String): The text to check
*
* Returns `true` if `text` is a newline character (either `\r\n`, `\r`, or `\n`).
* @param {String} text The text to check
*
*
*
**/
this.isNewLine = function(text) {
@@ -204,10 +187,10 @@ var Document = function(text) {
};
/**
* Document.getLine(row) -> String
* - row (Number): The row index to retrieve
*
* Returns a verbatim copy of the given line as it is in the document
* @param {Number} row The row index to retrieve
*
*
*
**/
this.getLine = function(row) {
@@ -215,11 +198,11 @@ var Document = function(text) {
};
/**
* Document.getLines(firstRow, lastRow) -> [String]
* - firstRow (Number): The first row index to retrieve
* - lastRow (Number): The final row index to retrieve
*
* Returns an array of strings of the rows between `firstRow` and `lastRow`. This function is inclusive of `lastRow`.
* @param {Number} firstRow The first row index to retrieve
* @param {Number} lastRow The final row index to retrieve
*
*
*
**/
this.getLines = function(firstRow, lastRow) {
@@ -227,8 +210,6 @@ var Document = function(text) {
};
/**
* Document.getAllLines() -> [String]
*
* Returns all lines in the document as string array. Warning: The caller should not modify this array!
**/
this.getAllLines = function() {
@@ -236,8 +217,6 @@ var Document = function(text) {
};
/**
* Document.getLength() -> Number
*
* Returns the number of rows in the document.
**/
this.getLength = function() {
@@ -245,10 +224,10 @@ var Document = function(text) {
};
/**
* Document.getTextRange(range) -> String
* - range (Range): The range to work with
*
* [Given a range within the document, this function returns all the text within that range as a single string.]{: #Document.getTextRange.desc}
* @param {Range} range The range to work with
*
*
**/
this.getTextRange = function(range) {
if (range.start.row == range.end.row) {
@@ -263,11 +242,6 @@ var Document = function(text) {
}
};
/** internal, hide
* Document.$clipPosition(position) -> Number
*
*
**/
this.$clipPosition = function(position) {
var length = this.getLength();
if (position.row >= length) {
@@ -278,13 +252,11 @@ var Document = function(text) {
};
/**
* Document.insert(position, text) -> Number
* - position (Number): The position to start inserting at
* - text (String): A chunk of text to insert
* + (Number): The position of the last line of `text`. If the length of `text` is 0, this function simply returns `position`.
* Inserts a block of `text` and the indicated `position`.
* @param {Object} position The position to start inserting at
* @param {String} text A chunk of text to insert
* @returns {Object} The position ({row, column}) of the last line of `text`. If the length of `text` is 0, this function simply returns `position`.
*
*
**/
this.insert = function(position, text) {
if (!text || text.length === 0)
@@ -310,15 +282,42 @@ var Document = function(text) {
};
/**
* Document.insertLines(row, lines) -> Object
* - row (Number): The index of the row to insert at
* - lines (Array): An array of strings
* + (Object): Returns an object containing the final row and column, like this:<br/>
* ```{row: endRow, column: 0}```<br/>
* If `lines` is empty, this function returns an object containing the current row, and column, like this:<br/>
* ```{row: row, column: 0}```
*
* Fires whenever the document changes.
*
* Several methods trigger different `"change"` events. Below is a list of each action type, followed by each property that's also available:
*
* * `"insertLines"` (emitted by [[Document.insertLines]])
* * `range`: the [[Range]] of the change within the document
* * `lines`: the lines in the document that are changing
* * `"insertText"` (emitted by [[Document.insertNewLine]])
* * `range`: the [[Range]] of the change within the document
* * `text`: the text that's being added
* * `"removeLines"` (emitted by [[Document.insertLines]])
* * `range`: the [[Range]] of the change within the document
* * `lines`: the lines in the document that were removed
* * `nl`: the new line character (as defined by [[Document.getNewLineCharacter]])
* * `"removeText"` (emitted by [[Document.removeInLine]] and [[Document.removeNewLine]])
* * `range`: the [[Range]] of the change within the document
* * `text`: the text that's being removed
*
* @event change
* @param {Object} e Contains at least one property called `"action"`. `"action"` indicates the action that triggered the change. Each action also has a set of additional properties.
*
**/
/**
* Inserts the elements in `lines` into the document, starting at the row index given by `row`. This method also triggers the `'change'` event.
* @param {Number} row The index of the row to insert at
* @param {Array} lines An array of strings
* @returns {Object} Contains the final row and column, like this:
* ```
* {row: endRow, column: 0}
* ```
* If `lines` is empty, this function returns an object containing the current row, and column, like this:
* ```
* {row: row, column: 0}
* ```
*
*
*
*
**/
@@ -348,14 +347,12 @@ var Document = function(text) {
};
/**
* Document.insertNewLine(position) -> Object
* - position (String): The position to insert at
* + (Object): Returns an object containing the final row and column, like this:<br/>
* ```{row: endRow, column: 0}```
*
* Inserts a new line into the document at the current row's `position`. This method also triggers the `'change'` event.
*
*
* @param {Object} position The position to insert at
* @returns {Object} Returns an object containing the final row and column, like this:<br/>
* ```
* {row: endRow, column: 0}
* ```
*
**/
this.insertNewLine = function(position) {
@@ -381,16 +378,13 @@ var Document = function(text) {
};
/**
* Document.insertInLine(position, text) -> Object | Number
* - position (Number): The position to insert at
* - text (String): A chunk of text
* + (Object): Returns an object containing the final row and column, like this:<br/>
* ```{row: endRow, column: 0}```
* + (Number): If `text` is empty, this function returns the value of `position`
*
* Inserts `text` into the `position` at the current row. This method also triggers the `'change'` event.
*
*
* @param {Object} position The position to insert at
* @param {String} text A chunk of text
* @returns {Object} Returns an object containing the final row and column, like this:
* ```
* {row: endRow, column: 0}
* ```
*
**/
this.insertInLine = function(position, text) {
@@ -418,11 +412,9 @@ var Document = function(text) {
};
/**
* Document.remove(range) -> Object
* - range (Range): A specified Range to remove
* + (Object): Returns the new `start` property of the range, which contains `startRow` and `startColumn`. If `range` is empty, this function returns the unmodified value of `range.start`.
*
* Removes the `range` from the document.
* @param {Range} range A specified Range to remove
* @returns {Object} Returns the new `start` property of the range, which contains `startRow` and `startColumn`. If `range` is empty, this function returns the unmodified value of `range.start`.
*
*
**/
@@ -459,13 +451,11 @@ var Document = function(text) {
};
/**
* Document.removeInLine(row, startColumn, endColumn) -> Object
* - row (Number): The row to remove from
* - startColumn (Number): The column to start removing at
* - endColumn (Number): The column to stop removing at
* + (Object): Returns an object containing `startRow` and `startColumn`, indicating the new row and column values.<br/>If `startColumn` is equal to `endColumn`, this function returns nothing.
*
* Removes the specified columns from the `row`. This method also triggers the `'change'` event.
* @param {Number} row The row to remove from
* @param {Number} startColumn The column to start removing at
* @param {Number} endColumn The column to stop removing at
* @returns {Object} Returns an object containing `startRow` and `startColumn`, indicating the new row and column values.<br/>If `startColumn` is equal to `endColumn`, this function returns nothing.
*
*
**/
@@ -489,12 +479,10 @@ var Document = function(text) {
};
/**
* Document.removeLines(firstRow, lastRow) -> [String]
* - firstRow (Number): The first row to be removed
* - lastRow (Number): The last row to be removed
* + ([String]): Returns all the removed lines.
*
* Removes a range of full lines. This method also triggers the `'change'` event.
* @param {Number} firstRow The first row to be removed
* @param {Number} lastRow The last row to be removed
* @returns {[String]} Returns all the removed lines.
*
*
**/
@@ -513,10 +501,8 @@ var Document = function(text) {
};
/**
* Document.removeNewLine(row) -> Void
* - row (Number): The row to check
*
* Removes the new line between `row` and the row immediately following it. This method also triggers the `'change'` event.
* @param {Number} row The row to check
*
**/
this.removeNewLine = function(row) {
@@ -537,15 +523,14 @@ var Document = function(text) {
};
/**
* Document.replace(range, text) -> Object
* - range (Range): A specified Range to replace
* - text (String): The new text to use as a replacement
* + (Object): Returns an object containing the final row and column, like this:
* Replaces a range in the document with the new `text`.
* @param {Range} range A specified Range to replace
* @param {String} text The new text to use as a replacement
* @returns {Object} Returns an object containing the final row and column, like this:
* {row: endRow, column: 0}
* If the text and range are empty, this function returns an object containing the current `range.start` value.
* If the text is the exact same as what currently exists, this function returns an object containing the current `range.end` value.
*
* Replaces a range in the document with the new `text`.
*
**/
this.replace = function(range, text) {
@@ -569,8 +554,6 @@ var Document = function(text) {
};
/**
* Document.applyDeltas(deltas) -> Void
*
* Applies all the changes previously accumulated. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`.
**/
this.applyDeltas = function(deltas) {
@@ -590,8 +573,6 @@ var Document = function(text) {
};
/**
* Document.revertDeltas(deltas) -> Void
*
* Reverts any changes previously applied. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`.
**/
this.revertDeltas = function(deltas) {
@@ -1,38 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Julian Viereck <julian.viereck@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
File diff suppressed because it is too large Load Diff
@@ -1,38 +1,30 @@
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -42,38 +34,13 @@ define(function(require, exports, module) {
var TokenIterator = require("../token_iterator").TokenIterator;
var Range = require("../range").Range;
/**
* class BracketMatch
*
*
*
*
**/
/**
* new BracketMatch(position)
* - platform (String): Identifier for the platform; must be either `'mac'` or `'win'`
* - commands (Array): A list of commands
*
* TODO
*
*
**/
function BracketMatch() {
/**
* new findMatchingBracket(position)
* - position (Number): Identifier for the platform; must be either `'mac'` or `'win'`
* - commands (Array): A list of commands
*
* TODO
*
*
**/
this.findMatchingBracket = function(position) {
this.findMatchingBracket = function(position, char) {
if (position.column == 0) return null;
var charBeforeCursor = this.getLine(position.row).charAt(position.column-1);
var charBeforeCursor = char || this.getLine(position.row).charAt(position.column-1);
if (charBeforeCursor == "") return null;
var match = charBeforeCursor.match(/([\(\[\{])|([\)\]\}])/);
@@ -144,7 +111,7 @@ function BracketMatch() {
if (!token)
token = iterator.stepForward();
if (!token)
return
return;
if (!typeRe){
typeRe = new RegExp(
@@ -200,7 +167,7 @@ function BracketMatch() {
if (!token)
token = iterator.stepForward();
if (!token)
return
return;
if (!typeRe){
typeRe = new RegExp(
@@ -1,38 +1,30 @@
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Julian Viereck <julian DOT viereck AT gmail DOT com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -91,7 +83,7 @@ var Fold = exports.Fold = function(range, placeholder) {
var afterStart = this.subFolds[i];
if (cmp == 0)
return afterStart.addSubFold(fold)
return afterStart.addSubFold(fold);
// cmp == -1
var row = fold.range.end.row, column = fold.range.end.column;
@@ -105,11 +97,11 @@ var Fold = exports.Fold = function(range, placeholder) {
if (cmp == 0)
throw "A fold can't intersect already existing fold" + fold.range + this.range;
var consumedFolds = this.subFolds.splice(i, j - i, fold)
var consumedFolds = this.subFolds.splice(i, j - i, fold);
fold.setFoldLine(this.foldLine);
return fold;
}
};
}).call(Fold.prototype);
@@ -1,38 +1,30 @@
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Julian Viereck <julian DOT viereck AT gmail DOT com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -178,7 +170,7 @@ function FoldLine(foldData, folds) {
&& fold.start.row != row)
{
//throwing here breaks whole editor
//@todo properly handle this
//TODO: properly handle this
window.console && window.console.log(row, column, fold);
} else if (fold.start.row == row) {
folds = this.folds;
@@ -1,38 +1,30 @@
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Julian Viereck <julian DOT viereck AT gmail DOT com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -282,9 +274,6 @@ function Folding() {
var endColumn = fold.end.column;
// --- Some checking ---
if (fold.placeholder.length < 2)
throw "Placeholder has to be at least 2 characters";
if (startRow == endRow && endColumn - startColumn < 2)
throw "The range has to be at least 2 characters width";
@@ -470,9 +459,7 @@ function Folding() {
this.getRowFoldEnd = function(docRow, startFoldRow) {
var foldLine = this.getFoldLine(docRow, startFoldRow);
return (foldLine
? foldLine.end.row
: docRow);
return foldLine ? foldLine.end.row : docRow;
};
this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) {
@@ -499,7 +486,7 @@ function Folding() {
}
lastColumn = Math.max(startColumn, lastColumn);
}
if (placeholder) {
if (placeholder != null) {
textLine += placeholder;
} else {
textLine += doc.getLine(row).substring(lastColumn, column);
@@ -598,30 +585,34 @@ function Folding() {
this.addFold(placeholder, range);
};
this.getCommentFoldRange = function(row, column) {
this.getCommentFoldRange = function(row, column, dir) {
var iterator = new TokenIterator(this, row, column);
var token = iterator.getCurrentToken();
if (token && /^comment|string/.test(token.type)) {
var range = new Range();
var re = new RegExp(token.type.replace(/\..*/, "\\."));
do {
token = iterator.stepBackward();
} while(token && re.test(token.type));
iterator.stepForward();
if (dir != 1) {
do {
token = iterator.stepBackward();
} while(token && re.test(token.type));
iterator.stepForward();
}
range.start.row = iterator.getCurrentTokenRow();
range.start.column = iterator.getCurrentTokenColumn() + 2;
iterator = new TokenIterator(this, row, column);
do {
token = iterator.stepForward();
} while(token && re.test(token.type));
token = iterator.stepBackward();
if (dir != -1) {
do {
token = iterator.stepForward();
} while(token && re.test(token.type));
token = iterator.stepBackward();
} else
token = iterator.getCurrentToken();
range.end.row = iterator.getCurrentTokenRow();
range.end.column = iterator.getCurrentTokenColumn() + token.value.length;
range.end.column = iterator.getCurrentTokenColumn() + token.value.length - 2;
return range;
}
};
@@ -638,7 +629,7 @@ function Folding() {
var range = this.getFoldWidgetRange(row);
// sometimes range can be incompatible with existing fold
// wouldn't it be better for addFold to return null istead of throwing?
if (range && range.end.row < endRow) try {
if (range && range.end.row <= endRow) try {
this.addFold("...", range);
} catch(e) {}
}
@@ -693,6 +684,7 @@ function Folding() {
};
this.onFoldWidgetClick = function(row, e) {
e = e.domEvent;
var type = this.getFoldWidget(row);
var line = this.getLine(row);
var onlySubfolds = e.shiftKey;
@@ -731,7 +723,7 @@ function Folding() {
} else {
if (addSubfolds)
this.foldAll(row + 1, this.getLength());
e.target.className += " invalid"
(e.target || e.srcElement).className += " ace_invalid"
}
};
@@ -1,38 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Julian Viereck <julian DOT viereck AT gmail DOT com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -69,6 +61,13 @@ function createFoldTestSession() {
return session;
}
function assertArray(a, b) {
assert.ok(a.length == b.length);
for (var i = 0; i < a.length; i++) {
assert.equal(a[i], b[i]);
}
}
module.exports = {
"test: find matching opening bracket in Text mode" : function() {
@@ -808,13 +807,6 @@ module.exports = {
},
"test fold wrap data compution": function() {
function assertArray(a, b) {
assert.ok(a.length == b.length);
for (var i = 0; i < a.length; i++) {
assert.equal(a[i], b[i]);
}
}
function assertWrap(line0, line1, line2) {
line0 && assertArray(wrapData[0], line0);
line1 && assertArray(wrapData[1], line1);
@@ -928,7 +920,7 @@ module.exports = {
tryAddFold("foo", new Range(0, 13, 0, 18), false);
assert.equal(session.$foldData[0].folds.length, 1);
tryAddFold("f", new Range(0, 13, 0, 18), true);
tryAddFold("f", new Range(0, 13, 0, 18), false);
tryAddFold("foo", new Range(0, 18, 0, 21), false);
assert.equal(session.$foldData[0].folds.length, 2);
session.removeFold(fold);
@@ -971,6 +963,34 @@ module.exports = {
session.addFold("fold0", new Range(0, 1, 0, 5));
session.addFold("fold0", new Range(0, 6, 0, 8));
assert.equal(fold.subFolds.length, 2);
},
"test row cache": function() {
var session = createFoldTestSession();
session.screenToDocumentPosition(2,3);
assertArray(session.$docRowCache, [1,3]);
assertArray(session.$screenRowCache, [1,2]);
session.screenToDocumentPosition(5,3);
assertArray(session.$docRowCache, [1,3,4]);
assertArray(session.$screenRowCache, [1,2,3]);
session.screenToDocumentPosition(0,3);
assertArray(session.$docRowCache, [1,3,4]);
assertArray(session.$screenRowCache, [1,2,3]);
session.screenToDocumentPosition(0,0);
assertArray(session.$docRowCache, [1,3,4]);
assertArray(session.$screenRowCache, [1,2,3]);
session.screenToDocumentPosition(1,0);
assertArray(session.$docRowCache, [1,3,4]);
assertArray(session.$screenRowCache, [1,2,3]);
session.$resetRowCache();
assertArray(session.$docRowCache, []);
assertArray(session.$screenRowCache, []);
}
};
File diff suppressed because it is too large Load Diff
@@ -1,37 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -1,38 +1,30 @@
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Mihai Sucan.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Mihai Sucan <mihai.sucan@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -1,37 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -1,37 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -1,39 +1,30 @@
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jan Jongboom <fabian AT ajax DOT org>
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -70,13 +61,12 @@ exports.render = function(input, mode, theme, lineStart, disableGutter) {
var stringBuilder = [];
var length = session.getLength();
for(var ix = 0; ix < length; ix++) {
var lineTokens = session.getTokens(ix);
stringBuilder.push("<div class='ace_line'>");
if (!disableGutter)
stringBuilder.push("<span class='ace_gutter ace_gutter-cell' unselectable='on'>" + (ix + lineStart) + "</span>");
textLayer.$renderLine(stringBuilder, 0, lineTokens, true);
textLayer.$renderLine(stringBuilder, ix, true, false);
stringBuilder.push("</div>");
}
@@ -16,7 +16,8 @@ module.exports = {
"test simple snippet": function(next) {
var theme = require("../theme/tomorrow");
var snippet = "/** this is a function\n\
var snippet = "\
/** this is a function\n\
*\n\
*/\n\
function hello (a, b, c) {\n\
@@ -24,23 +25,16 @@ function hello (a, b, c) {\n\
}";
var mode = new JavaScriptMode();
var isError = false, result;
try {
result = highlighter.render(snippet, mode, theme);
}
catch (e) {
console.log(e);
isError = true;
}
// todo: write something more meaningful
assert.equal(isError, false);
var result = highlighter.render(snippet, mode, theme);
assert.equal(result.html, "<div class='ace-tomorrow'> <div class='ace_editor ace_scroller ace_text-layer'> <div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'>1</span><span class='ace_comment ace_doc'>/**&#160;this&#160;is&#160;a&#160;function</span></div><div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'>2</span><span class='ace_comment ace_doc'>*</span></div><div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'>3</span><span class='ace_comment ace_doc'>*/</span></div><div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'>4</span><span class='ace_storage ace_type'>function</span>&#160;<span class='ace_entity ace_name ace_function'>hello</span>&#160;<span class='ace_paren ace_lparen'>(</span><span class='ace_variable ace_parameter'>a</span><span class='ace_punctuation ace_operator'>,&#160;</span><span class='ace_variable ace_parameter'>b</span><span class='ace_punctuation ace_operator'>,&#160;</span><span class='ace_variable ace_parameter'>c</span><span class='ace_paren ace_rparen'>)</span>&#160;<span class='ace_paren ace_lparen'>{</span></div><div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'>5</span>&#160;&#160;&#160;&#160;<span class='ace_storage ace_type'>console</span><span class='ace_punctuation ace_operator'>.</span><span class='ace_support ace_function ace_firebug'>log</span><span class='ace_paren ace_lparen'>(</span><span class='ace_identifier'>a</span>&#160;<span class='ace_keyword ace_operator'>*</span>&#160;<span class='ace_identifier'>b</span>&#160;<span class='ace_keyword ace_operator'>+</span>&#160;<span class='ace_identifier'>c</span>&#160;<span class='ace_keyword ace_operator'>+</span>&#160;<span class='ace_string'>'sup?'</span><span class='ace_paren ace_rparen'>)</span><span class='ace_punctuation ace_operator'>;</span></div><div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'>6</span><span class='ace_paren ace_rparen'>}</span></div> </div> </div>");
assert.ok(!!result.css);
next();
},
"test css from theme is used": function(next) {
var theme = require("../theme/tomorrow");
var snippet = "/** this is a function\n\
var snippet = "\
/** this is a function\n\
*\n\
*/\n\
function hello (a, b, c) {\n\
@@ -58,7 +52,8 @@ function hello (a, b, c) {\n\
"test theme classname should be in output html": function (next) {
var theme = require("../theme/tomorrow");
var snippet = "/** this is a function\n\
var snippet = "\
/** this is a function\n\
*\n\
*/\n\
function hello (a, b, c) {\n\
@@ -1,39 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Skywriter.
*
* The Initial Developer of the Original Code is
* Mozilla.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Kevin Dangoor (kdangoor@mozilla.com)
* Julian Viereck <julian.viereck@gmail.com>
* Harutyun Amirjanyan [harutyun@c9.io]
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -45,7 +36,7 @@ var UA = require("../lib/useragent");
var net = require("../lib/net");
var ace = require("../ace");
require("ace/theme/textmate");
require("../theme/textmate");
module.exports = exports = ace;
@@ -193,7 +184,6 @@ exports.transformTextarea = function(element, loader) {
var settingOpener = document.createElement("div");
applyStyles(settingOpener, {
position: "absolute",
width: "15px",
right: "0px",
bottom: "0px",
background: "red",
@@ -1,38 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Skywriter.
*
* The Initial Developer of the Original Code is
* Mozilla.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Julian Viereck (julian.viereck@gmail.com)
* Harutyun Amirjanyan (harutyun@c9.io)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -65,6 +57,7 @@ exports.handler.attach = function(editor) {
.emacs-mode .ace_cursor{\
border: 2px rgba(50,250,50,0.8) solid!important;\
-moz-box-sizing: border-box!important;\
-webkit-box-sizing: border-box!important;\
box-sizing: border-box!important;\
background-color: rgba(0,250,0,0.9);\
opacity: 0.5;\
@@ -73,7 +66,7 @@ exports.handler.attach = function(editor) {
opacity: 1;\
background-color: transparent;\
}\
.emacs-mode .ace_cursor.ace_overwrite {\
.emacs-mode .ace_overwrite-cursors .ace_cursor {\
opacity: 1;\
background-color: transparent;\
border-width: 0 0 2px 2px !important;\
@@ -220,7 +213,8 @@ exports.emacsKeys = {
"S-C-Home" : "selecttostart",
"S-C-End" : "selecttoend",
"C-l|M-s" : "centerselection",
"C-l" : "recenterTopBottom",
"M-s" : "centerselection",
"M-g": "gotoline",
"C-x C-p": "selectall",
@@ -278,6 +272,20 @@ exports.emacsKeys = {
exports.handler.bindKeys(exports.emacsKeys);
exports.handler.addCommands({
recenterTopBottom: function(editor) {
var renderer = editor.renderer;
var pos = renderer.$cursorLayer.getPixelPosition();
var h = renderer.$size.scrollerHeight - renderer.lineHeight;
var scrollTop = renderer.scrollTop;
if (Math.abs(pos.top - scrollTop) < 2) {
scrollTop = pos.top - h;
} else if (Math.abs(pos.top - scrollTop - h * 0.5) < 2) {
scrollTop = pos.top;
} else {
scrollTop = pos.top - h * 0.5;
}
editor.session.setScrollTop(scrollTop);
},
selectRectangularRegion: function(editor) {
editor.multiSelect.toggleBlockSelection();
},
@@ -331,7 +339,7 @@ exports.handler.addCommands({
},
killRegion: function(editor) {
exports.killRing.add(editor.getCopyText());
editor.cut();
editor.commands.byName.cut.exec(editor);
},
killRingSave: function(editor) {
exports.killRing.add(editor.getCopyText());
@@ -1,38 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Skywriter.
*
* The Initial Developer of the Original Code is
* Mozilla.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Julian Viereck (julian.viereck@gmail.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -129,33 +121,34 @@ function HashHandler(config, platform) {
var key = typeof binding == "string" ? binding: binding[this.platform];
this.bindKey(key, command);
};
// accepts keys in the form ctrl+Enter or ctrl-Enter
// keys without modifiers or shift only
this.parseKeys = function(keys) {
var key;
var parts = keys.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(x){return x});
var key = parts.pop();
var keyCode = keyUtil[key];
if (keyUtil.FUNCTION_KEYS[keyCode])
key = keyUtil.FUNCTION_KEYS[keyCode].toLowerCase();
else if (!parts.length)
return {key: key, hashId: -1};
else if (parts.length == 1 && parts[0] == "shift")
return {key: key.toUpperCase(), hashId: -1};
var hashId = 0;
var parts = keys.toLowerCase().trim().split(/\s*\-\s*/);
for (var i = 0, l = parts.length; i < l; i++) {
if (keyUtil.KEY_MODS[parts[i]])
hashId = hashId | keyUtil.KEY_MODS[parts[i]];
else
key = parts[i] || "-"; //when empty, the splitSafe removed a '-'
for (var i = parts.length; i--;) {
var modifier = keyUtil.KEY_MODS[parts[i]];
if (modifier == null)
throw "invalid modifier " + parts[i] + " in " + keys;
hashId |= modifier;
}
if (parts[0] == "text" && parts.length == 2) {
hashId = -1;
key = parts[1];
}
return {
key: key,
hashId: hashId
};
return {key: key, hashId: hashId};
};
this.findKeyCommand = function findKeyCommand(hashId, keyString) {
var ckbr = this.commmandKeyBinding;
return ckbr[hashId] && ckbr[hashId][keyString.toLowerCase()];
return ckbr[hashId] && ckbr[hashId][keyString];
};
this.handleKeyboard = function(data, hashId, keyString, keyCode) {
@@ -1,39 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Julian Viereck <julian.viereck@gmail.com>
* Harutyun Amirjanyan <amirjanyan@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -1,37 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Skywriter.
*
* The Initial Developer of the Original Code is
* Mozilla.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Julian Viereck (julian.viereck@gmail.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -109,7 +102,7 @@ StateHandler.prototype = {
};
if (e) {
bufferObj.keyIdentifier = e.keyIdentifier
bufferObj.keyIdentifier = e.keyIdentifier;
}
return bufferObj;
@@ -1,39 +1,30 @@
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Mihai Sucan <mihai DOT sucan AT gmail DOT com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -46,6 +37,7 @@ var dom = require("../lib/dom");
var TextInput = function(parentNode, host) {
var text = dom.createElement("textarea");
text.className = "ace_text-input";
/*/ debug
text.style.opacity = 1
text.style.background = "rgba(0, 250, 0, 0.3)"
@@ -55,71 +47,109 @@ var TextInput = function(parentNode, host) {
if (useragent.isTouchPad)
text.setAttribute("x-palm-disable-auto-cap", true);
text.setAttribute("wrap", "off");
text.wrap = "off";
text.spellcheck = false;
text.style.top = "-2em";
parentNode.insertBefore(text, parentNode.firstChild);
var PLACEHOLDER = useragent.isIE ? "\x01" : "\x01";
sendText();
var PLACEHOLDER = useragent.isIE || useragent.isOpera ? "\x01\x01" : "\x00\x00";
var inCompostion = false;
resetValue();
if (isFocused())
host.onFocus();
// Somehow fixes problem with firing onpropertychange on first typed char
if (useragent.isOldIE) {
resetSelection();
resetValue();
setTimeout(resetSelection);
}
var cut = false
var copied = false;
var pasted = false;
var inCompostion = false;
var resetTimeout = null;
var tempStyle = '';
function reset(full) {
try {
if (full) {
function resetValue() {
text.value = PLACEHOLDER;
//http://code.google.com/p/chromium/issues/detail?id=76516
if (useragent.isWebKit && !resetTimeout)
resetTimeout = setTimeout(function(){
text.value = PLACEHOLDER;
text.selectionStart = 0;
text.selectionEnd = 1;
} else
text.select();
} catch (e) {}
}
function sendText(valueToSend) {
if (!copied) {
var value = valueToSend || text.value;
if (value) {
if (value.length > 1) {
if (value.charAt(0) == PLACEHOLDER)
value = value.substr(1);
else if (value.charAt(value.length - 1) == PLACEHOLDER)
value = value.slice(0, -1);
}
if (value && value != PLACEHOLDER) {
if (pasted)
host.onPaste(value);
else
host.onTextInput(value);
}
}
}
copied = false;
pasted = false;
// Safari doesn't fire copy events if no text is selected
reset(true);
}
var onTextInput = function(e) {
if (!inCompostion)
sendText(e.data);
setTimeout(function () {
if (!inCompostion)
reset(true);
}, 0);
resetSelection();
resetTimeout = null;
});
};
var onPropertyChange = function(e) {
setTimeout(function() {
if (!inCompostion)
sendText();
}, 0);
function resetSelection(isEmpty) {
var selectionStart = isEmpty ? 2 : 1;
var selectionEnd = 2;
// on firefox this throws if textarea is hidden
try {
if (text.setSelectionRange) {
text.setSelectionRange(selectionStart, selectionEnd);
}
// IE8 does not support setSelectionRange
else if (text.createTextRange) {
var range = text.createTextRange();
range.collapse(true);
range.moveEnd('character', selectionEnd);
range.moveStart('character', selectionStart);
range.select();
}
} catch(e){}
};
var onSelect = function(e) {
if (cut) {
cut = false;
return;
}
if (copied) {
copied = false;
return;
}
if (text.selectionStart === 0 && text.selectionEnd === text.value.length) {
host.selectAll();
resetSelection();
}
};
var onInput = function(e) {
if (inCompostion)
return;
if (pasted) {
var data = text.value;
resetValue();
if (data)
host.onPaste(data);
pasted = false;
return;
}
var data = text.value;
if (data.substring(0, 2) == PLACEHOLDER)
data = data.substr(2);
else
data = data.substr(1);
resetValue();
if (data) {
// can happen if undo in textarea isn't stopped
if (data[data.length - 1] == PLACEHOLDER[0])
data = data.slice(0, -1);
if (data)
host.onTextInput(data);
} else
host.onDelete();
};
var onCompositionStart = function(e) {
@@ -138,93 +168,130 @@ var TextInput = function(parentNode, host) {
host.onCompositionEnd();
};
var onCopy = function(e) {
copied = true;
var copyText = host.getCopyText();
if(copyText)
text.value = copyText;
else
e.preventDefault();
reset();
setTimeout(function () {
sendText();
}, 0);
var onCut = function(e) {
var data = host.getCopyText();
if (!data) {
event.preventDefault(e);
return;
}
var clipboardData = e.clipboardData || window.clipboardData;
if (clipboardData) {
// Safari 5 has clipboardData object, but does not handle setData()
var supported = clipboardData.setData("Text", data);
if (supported) {
host.onCut();
event.preventDefault(e);
}
}
if (!supported) {
cut = true;
text.value = data;
text.select();
setTimeout(function(){
cut = false;
resetValue();
resetSelection();
host.onCut();
});
}
};
var onCut = function(e) {
copied = true;
var copyText = host.getCopyText();
if(copyText) {
text.value = copyText;
host.onCut();
} else
e.preventDefault();
reset();
setTimeout(function () {
sendText();
}, 0);
var onCopy = function(e) {
var data = host.getCopyText();
if (!data) {
event.preventDefault(e);
return;
}
var clipboardData = e.clipboardData || window.clipboardData;
if (clipboardData) {
// Safari 5 has clipboardData object, but does not handle setData()
var supported = clipboardData.setData("Text", data);
if (supported) {
host.onCopy();
event.preventDefault(e);
}
}
if (!supported) {
copied = true;
text.value = data;
text.select();
setTimeout(function(){
copied = false;
resetValue();
resetSelection();
host.onCopy();
});
}
};
var onPaste = function(e) {
var clipboardData = e.clipboardData || window.clipboardData;
if (clipboardData) {
var data = clipboardData.getData("Text");
if (data)
host.onPaste(data);
event.preventDefault(e);
}
else {
text.value = "";
pasted = true;
}
};
event.addCommandKeyListener(text, host.onCommandKey.bind(host));
event.addListener(text, "input", useragent.isIE ? onPropertyChange : onTextInput);
event.addListener(text, "paste", function(e) {
// Mark that the next input text comes from past.
pasted = true;
// Some browsers support the event.clipboardData API. Use this to get
// the pasted content which increases speed if pasting a lot of lines.
if (e.clipboardData && e.clipboardData.getData) {
sendText(e.clipboardData.getData("text/plain"));
e.preventDefault();
}
else {
// If a browser doesn't support any of the things above, use the regular
// method to detect the pasted input.
onPropertyChange();
}
});
event.addListener(text, "select", onSelect);
if ("onbeforecopy" in text && typeof clipboardData !== "undefined") {
event.addListener(text, "beforecopy", function(e) {
if (tempStyle)
return; // without this text is copied when contextmenu is shown
var copyText = host.getCopyText();
if (copyText)
clipboardData.setData("Text", copyText);
else
e.preventDefault();
});
event.addListener(parentNode, "keydown", function(e) {
if (e.ctrlKey && e.keyCode == 88) {
var copyText = host.getCopyText();
if (copyText) {
clipboardData.setData("Text", copyText);
host.onCut();
}
event.preventDefault(e);
}
});
event.addListener(text, "cut", onCut); // for ie9 context menu
}
else if (useragent.isOpera) {
event.addListener(text, "input", onInput);
event.addListener(text, "cut", onCut);
event.addListener(text, "copy", onCopy);
event.addListener(text, "paste", onPaste);
// Opera has no clipboard events
if (!('oncut' in text) || !('oncopy' in text) || !('onpaste' in text)){
event.addListener(parentNode, "keydown", function(e) {
if ((useragent.isMac && !e.metaKey) || !e.ctrlKey)
return;
return;
if ((e.keyCode == 88 || e.keyCode == 67)) {
var copyText = host.getCopyText();
if (copyText) {
text.value = copyText;
text.select();
if (e.keyCode == 88)
host.onCut();
}
switch (e.keyCode) {
case 67:
onCopy(e);
break;
case 86:
onPaste(e);
break;
case 88:
onCut(e);
break;
}
});
}
else {
event.addListener(text, "copy", onCopy);
event.addListener(text, "cut", onCut);
if (useragent.isOldIE) {
event.addListener(text, "propertychange", function(e){
if (text.value != "" && text.value != PLACEHOLDER)
onInput(e);
});
var keytable = { 13:1, 27:1 };
event.addListener(text, "keyup", function (e) {
if (inCompostion && (!text.value || keytable[e.keyCode]))
setTimeout(onCompositionEnd, 0);
if ((text.value.charCodeAt(0)|0) < 129) {
return;
}
inCompostion ? onCompositionUpdate() : onCompositionStart();
});
}
event.addListener(text, "compositionstart", onCompositionStart);
@@ -242,11 +309,10 @@ var TextInput = function(parentNode, host) {
event.addListener(text, "focus", function() {
host.onFocus();
reset();
resetSelection();
});
this.focus = function() {
reset();
text.focus();
};
@@ -268,11 +334,11 @@ var TextInput = function(parentNode, host) {
tempStyle = text.style.cssText;
text.style.cssText =
"position:fixed; z-index:100000;" + //"background:rgba(250, 0, 0, 0.3); opacity:1;" +
"position:fixed; z-index:100000;" +
(useragent.isIE ? "background:rgba(0, 0, 0, 0.03); opacity:0.1;" : "") + //"background:rgba(250, 0, 0, 0.3); opacity:1;" +
"left:" + (e.clientX - 2) + "px; top:" + (e.clientY - 2) + "px;";
if (host.selection.isEmpty())
text.value = "";
resetSelection(host.selection.isEmpty());
if (e.type != "mousedown")
return;
@@ -281,7 +347,7 @@ var TextInput = function(parentNode, host) {
host.renderer.$keepTextAreaAtCursor = null;
// on windows context menu is opened after mouseup
if (useragent.isGecko && useragent.isWin)
if (useragent.isWin)
event.capture(host.container, function(e) {
text.style.left = e.clientX - 2 + "px";
text.style.top = e.clientY - 2 + "px";
@@ -294,7 +360,6 @@ var TextInput = function(parentNode, host) {
text.style.cssText = tempStyle;
tempStyle = '';
}
sendText();
if (host.renderer.$keepTextAreaAtCursor == null) {
host.renderer.$keepTextAreaAtCursor = true;
host.renderer.$moveTextAreaToCursor();
@@ -307,7 +372,7 @@ var TextInput = function(parentNode, host) {
if (!useragent.isGecko)
event.addListener(text, "contextmenu", function(e) {
host.textInput.onContextMenu(e);
onContextMenuClose()
onContextMenuClose();
});
};
@@ -1,48 +1,40 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Sergi Mansilla <sergi AT c9 DOT io>
* Harutyun Amirjanyan <harutyun AT c9 DOT io>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var keyUtil = require("../lib/keys");
var cmds = require("./vim/commands");
var coreCommands = cmds.coreCommands;
var util = require("./vim/maps/util");
var useragent = require("../lib/useragent");
var startCommands = {
"i": {
@@ -62,10 +54,32 @@ var startCommands = {
},
"ctrl-b": {
command: "gotopageup"
},
}
};
exports.handler = {
// workaround for j not repeating with `defaults write -g ApplePressAndHoldEnabled -bool true`
handleMacRepeat: function(data, hashId, key) {
if (hashId == -1) {
// record key
data.inputChar = key;
data.lastEvent = "input";
} else if (data.inputChar && data.$lastHash == hashId && data.$lastKey == key) {
// check for repeated keypress
if (data.lastEvent == "input") {
data.lastEvent = "input1";
} else if (data.lastEvent == "input1") {
// simulate textinput
return true;
}
} else {
// reset
data.$lastHash = hashId;
data.$lastKey = key;
data.lastEvent = "keypress";
}
},
handleKeyboard: function(data, hashId, key, keyCode, e) {
// ignore command keys (shift, ctrl etc.)
if (hashId != 0 && (key == "" || key == "\x00"))
@@ -73,26 +87,31 @@ exports.handler = {
if (hashId == 1)
key = "ctrl-" + key;
if (data.state == "start") {
if ((key == "esc" && hashId == 0) || key == "ctrl-[") {
return {command: coreCommands.stop};
} else if (data.state == "start") {
if (useragent.isMac && this.handleMacRepeat(data, hashId, key)) {
hashId = -1;
key = data.inputChar;
}
if (hashId == -1 || hashId == 1) {
if (cmds.inputBuffer.idle && startCommands[key])
return startCommands[key];
return { command: {
exec: function(editor) {cmds.inputBuffer.push(editor, key);}
} };
} // wait for input
else if (key.length == 1 && (hashId == 0 || hashId == 4)) { //no modifier || shift
return {
command: {
exec: function(editor) {cmds.inputBuffer.push(editor, key);}
}
};
} // if no modifier || shift: wait for input.
else if (key.length == 1 && (hashId == 0 || hashId == 4)) {
return {command: "null", passEvent: true};
} else if (key == "esc") {
} else if (key == "esc" && hashId == 0) {
return {command: coreCommands.stop};
}
} else {
if (key == "esc" || key == "ctrl-[") {
data.state = "start";
return {command: coreCommands.stop};
} else if (key == "ctrl-w") {
if (key == "ctrl-w") {
return {command: "removewordleft"};
}
}
@@ -102,6 +121,7 @@ exports.handler = {
editor.on("click", exports.onCursorMove);
if (util.currentMode !== "insert")
cmds.coreCommands.stop.exec(editor);
editor.$vimModeHandler = this;
},
detach: function(editor) {
@@ -110,7 +130,14 @@ exports.handler = {
util.currentMode = "normal";
},
actions: cmds.actions
actions: cmds.actions,
getStatusText: function() {
if (util.currentMode == "insert")
return "INSERT";
if (util.onVisualMode)
return (util.onVisualLineMode ? "VISUAL LINE " : "VISUAL ") + cmds.inputBuffer.status;
return cmds.inputBuffer.status;
}
};
@@ -1,38 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Sergi Mansilla <sergi AT c9 DOT io>
* Harutyun Amirjanyan <harutyun AT c9 DOT io>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -82,13 +74,13 @@ var actions = exports.actions = {
fn: function(editor, range, count, param) {
switch (param) {
case "z":
editor.alignCursor(null, 0.5);
editor.renderer.alignCursor(null, 0.5);
break;
case "t":
editor.alignCursor(null, 0);
editor.renderer.alignCursor(null, 0);
break;
case "b":
editor.alignCursor(null, 1);
editor.renderer.alignCursor(null, 1);
break;
}
}
@@ -304,6 +296,7 @@ var inputBuffer = exports.inputBuffer = {
currentCmd: null,
//currentMode: 0,
currentCount: "",
status: "",
// Types
operator: null,
@@ -311,73 +304,84 @@ var inputBuffer = exports.inputBuffer = {
lastInsertCommands: [],
push: function(editor, char, keyId) {
push: function(editor, ch, keyId) {
this.idle = false;
var wObj = this.waitingForParam;
if (wObj) {
this.exec(editor, wObj, char);
this.exec(editor, wObj, ch);
}
// If input is a number (that doesn't start with 0)
else if (!(char === "0" && !this.currentCount.length) &&
(char.match(/^\d+$/) && this.isAccepting(NUMBER))) {
// Assuming that char is always of type String, and not Number
this.currentCount += char;
else if (!(ch === "0" && !this.currentCount.length) &&
(ch.match(/^\d+$/) && this.isAccepting(NUMBER))) {
// Assuming that ch is always of type String, and not Number
this.currentCount += ch;
this.currentCmd = NUMBER;
this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
}
else if (!this.operator && this.isAccepting(OPERATOR) && operators[char]) {
else if (!this.operator && this.isAccepting(OPERATOR) && operators[ch]) {
this.operator = {
char: char,
ch: ch,
count: this.getCount()
};
this.currentCmd = OPERATOR;
this.accepting = [NUMBER, MOTION, ACTION];
this.exec(editor, { operator: this.operator });
}
else if (motions[char] && this.isAccepting(MOTION)) {
else if (motions[ch] && this.isAccepting(MOTION)) {
this.currentCmd = MOTION;
var ctx = {
operator: this.operator,
motion: {
char: char,
ch: ch,
count: this.getCount()
}
};
if (motions[char].param)
if (motions[ch].param)
this.waitForParam(ctx);
else
this.exec(editor, ctx);
}
else if (alias[char] && this.isAccepting(MOTION)) {
alias[char].operator.count = this.getCount();
this.exec(editor, alias[char]);
else if (alias[ch] && this.isAccepting(MOTION)) {
alias[ch].operator.count = this.getCount();
this.exec(editor, alias[ch]);
}
else if (actions[char] && this.isAccepting(ACTION)) {
else if (actions[ch] && this.isAccepting(ACTION)) {
var actionObj = {
action: {
fn: actions[char].fn,
fn: actions[ch].fn,
count: this.getCount()
}
};
if (actions[char].param) {
if (actions[ch].param) {
this.waitForParam(actionObj);
}
else {
this.exec(editor, actionObj);
}
if (actions[char].acceptsMotion)
if (actions[ch].acceptsMotion)
this.idle = false;
}
else if (this.operator) {
this.exec(editor, { operator: this.operator }, char);
this.exec(editor, { operator: this.operator }, ch);
}
else {
this.reset();
}
if (this.waitingForParam || this.motion || this.operator) {
this.status += ch;
} else if (this.currentCount) {
this.status = this.currentCount;
} else if (this.status) {
this.status = "";
} else {
return;
}
editor._emit("changeStatus");
},
waitForParam: function(cmd) {
@@ -406,18 +410,18 @@ var inputBuffer = exports.inputBuffer = {
}
if (o && !editor.selection.isEmpty()) {
if (operators[o.char].selFn) {
operators[o.char].selFn(editor, editor.getSelectionRange(), o.count, param);
if (operators[o.ch].selFn) {
operators[o.ch].selFn(editor, editor.getSelectionRange(), o.count, param);
this.reset();
}
return;
}
// There is an operator, but no motion or action. We try to pass the
// current char to the operator to see if it responds to it (an example
// current ch to the operator to see if it responds to it (an example
// of this is the 'dd' operator).
else if (!m && !a && o && param) {
operators[o.char].fn(editor, null, o.count, param);
operators[o.ch].fn(editor, null, o.count, param);
this.reset();
}
else if (m) {
@@ -430,7 +434,7 @@ var inputBuffer = exports.inputBuffer = {
}
};
var motionObj = motions[m.char];
var motionObj = motions[m.ch];
var selectable = motionObj.sel;
if (!o) {
@@ -442,7 +446,7 @@ var inputBuffer = exports.inputBuffer = {
else if (selectable) {
repeat(function() {
run(motionObj.sel);
operators[o.char].fn(editor, editor.getSelectionRange(), o.count, param);
operators[o.ch].fn(editor, editor.getSelectionRange(), o.count, param);
}, o.count || 1);
}
this.reset();
@@ -462,6 +466,7 @@ var inputBuffer = exports.inputBuffer = {
this.operator = null;
this.motion = null;
this.currentCount = "";
this.status = "";
this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
this.idle = true;
this.waitingForParam = null;
@@ -1,37 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Sergi Mansilla <sergi AT c9 DOT io>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -41,57 +34,57 @@ define(function(require, exports, module) {
module.exports = {
"x": {
operator: {
char: "d",
ch: "d",
count: 1
},
motion: {
char: "l",
ch: "l",
count: 1
}
},
"X": {
operator: {
char: "d",
ch: "d",
count: 1
},
motion: {
char: "h",
ch: "h",
count: 1
}
},
"D": {
operator: {
char: "d",
ch: "d",
count: 1
},
motion: {
char: "$",
ch: "$",
count: 1
}
},
"C": {
operator: {
char: "c",
ch: "c",
count: 1
},
motion: {
char: "$",
ch: "$",
count: 1
}
},
"s": {
operator: {
char: "c",
ch: "c",
count: 1
},
motion: {
char: "l",
ch: "l",
count: 1
}
},
"S": {
operator: {
char: "c",
ch: "c",
count: 1
},
param: "c"
@@ -1,44 +1,36 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Sergi Mansilla <sergi AT c9 DOT io>
* Harutyun Amirjanyan <harutyun AT c9 DOT io>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
"use strict"
define(function(require, exports, module) {
"use strict";
var util = require("./util");
@@ -50,42 +42,27 @@ var keepScrollPosition = function(editor, fn) {
editor.renderer.scrollToRow(editor.getCursorPosition().row - diff);
};
function Motion(getRange, type){
if (type == 'extend')
var extend = true;
else
var reverse = type;
this.nav = function(editor) {
var r = getRange(editor);
if (!r)
function Motion(m) {
if (typeof m == "function") {
var getPos = m;
m = this;
} else {
var getPos = m.getPos;
}
m.nav = function(editor, range, count, param) {
var a = getPos(editor, range, count, param, false);
if (!a)
return;
if (!r.end)
var a = r;
else if (reverse)
var a = r.start;
else
var a = r.end;
editor.clearSelection();
editor.moveCursorTo(a.row, a.column);
}
this.sel = function(editor){
var r = getRange(editor);
if (!r)
};
m.sel = function(editor, range, count, param) {
var a = getPos(editor, range, count, param, true);
if (!a)
return;
if (extend)
return editor.selection.setSelectionRange(r);
if (!r.end)
var a = r;
else if (reverse)
var a = r.start;
else
var a = r.end;
editor.selection.selectTo(a.row, a.column);
}
};
return m;
}
var nonWordRe = /[\s.\/\\()\"'-:,.;<>~!@#$%^&*|+=\[\]{}`~?]/;
@@ -98,20 +75,20 @@ var StringStream = function(editor, cursor) {
this.row = cursor.row;
this.col = cursor.column;
var line = editor.session.getLine(this.row);
var maxRow = editor.session.getLength()
this.ch = line[this.col] || '\n'
var maxRow = editor.session.getLength();
this.ch = line[this.col] || '\n';
this.skippedLines = 0;
this.next = function() {
this.ch = line[++this.col] || this.handleNewLine(1);
//this.debug()
return this.ch;
}
};
this.prev = function() {
this.ch = line[--this.col] || this.handleNewLine(-1);
//this.debug()
return this.ch;
}
};
this.peek = function(dir) {
var ch = line[this.col + dir];
if (ch)
@@ -121,7 +98,7 @@ var StringStream = function(editor, cursor) {
if (this.col == line.length - 1)
return '\n';
return editor.session.getLine(this.row + 1)[0] || '\n';
}
};
this.handleNewLine = function(dir) {
if (dir == 1){
@@ -136,7 +113,7 @@ var StringStream = function(editor, cursor) {
return line[0] || '\n';
}
if (dir == -1) {
if (this.row == 0)
if (this.row === 0)
return '';
this.row --;
line = editor.session.getLine(this.row);
@@ -144,13 +121,13 @@ var StringStream = function(editor, cursor) {
this.skippedLines--;
return '\n';
}
}
};
this.debug = function() {
console.log(line.substring(0, this.col)+'|'+this.ch+'\''+this.col+'\''+line.substr(this.col+1));
}
}
};
};
var Search = require("ace/search").Search;
var Search = require("../../../search").Search;
var search = new Search();
function find(editor, needle, dir) {
@@ -159,7 +136,7 @@ function find(editor, needle, dir) {
return search.find(editor.session);
}
var Range = require("ace/range").Range;
var Range = require("../../../range").Range;
module.exports = {
"w": new Motion(function(editor) {
@@ -187,7 +164,7 @@ module.exports = {
else
str.next();
return {column: str.col, row: str.row}
return {column: str.col, row: str.row};
}),
"b": new Motion(function(editor) {
var str = new StringStream(editor);
@@ -207,7 +184,7 @@ module.exports = {
return {column: str.col, row: str.row};
}),
"B": new Motion(function(editor) {
var str = new StringStream(editor)
var str = new StringStream(editor);
str.prev();
while(str.ch && !(!whiteRe.test(str.ch) && whiteRe.test(str.peek(-1))) && str.skippedLines > -2)
str.prev();
@@ -216,7 +193,7 @@ module.exports = {
str.next();
return {column: str.col, row: str.row};
}, true),
}),
"e": new Motion(function(editor) {
var str = new StringStream(editor);
@@ -270,6 +247,40 @@ module.exports = {
editor.selection.selectLeft();
}
},
"H": {
nav: function(editor) {
var row = editor.renderer.getScrollTopRow();
editor.moveCursorTo(row);
},
sel: function(editor) {
var row = editor.renderer.getScrollTopRow();
editor.selection.selectTo(row);
}
},
"M": {
nav: function(editor) {
var topRow = editor.renderer.getScrollTopRow();
var bottomRow = editor.renderer.getScrollBottomRow();
var row = topRow + ((bottomRow - topRow) / 2);
editor.moveCursorTo(row);
},
sel: function(editor) {
var topRow = editor.renderer.getScrollTopRow();
var bottomRow = editor.renderer.getScrollBottomRow();
var row = topRow + ((bottomRow - topRow) / 2);
editor.selection.selectTo(row);
}
},
"L": {
nav: function(editor) {
var row = editor.renderer.getScrollBottomRow();
editor.moveCursorTo(row);
},
sel: function(editor) {
var row = editor.renderer.getScrollBottomRow();
editor.selection.selectTo(row);
}
},
"k": {
nav: function(editor) {
editor.navigateUp();
@@ -363,99 +374,58 @@ module.exports = {
}
},
"f": {
"f": new Motion({
param: true,
handlesCount: true,
nav: function(editor, range, count, param) {
var ed = editor;
var cursor = ed.getCursorPosition();
getPos: function(editor, range, count, param, isSel) {
var cursor = editor.getCursorPosition();
var column = util.getRightNthChar(editor, cursor, param, count || 1);
if (typeof column === "number") {
ed.selection.clearSelection(); // Why does it select in the first place?
ed.moveCursorTo(cursor.row, column + cursor.column + 1);
}
},
sel: function(editor, range, count, param) {
var ed = editor;
var cursor = ed.getCursorPosition();
var column = util.getRightNthChar(editor, cursor, param, count || 1);
if (typeof column === "number") {
ed.moveCursorTo(cursor.row, column + cursor.column + 1);
cursor.column += column + (isSel ? 2 : 1);
return cursor;
}
}
},
"F": {
}),
"F": new Motion({
param: true,
handlesCount: true,
nav: function(editor, range, count, param) {
count = parseInt(count, 10) || 1;
var ed = editor;
var cursor = ed.getCursorPosition();
var column = util.getLeftNthChar(editor, cursor, param, count);
if (typeof column === "number") {
ed.selection.clearSelection(); // Why does it select in the first place?
ed.moveCursorTo(cursor.row, cursor.column - column - 1);
}
},
sel: function(editor, range, count, param) {
var ed = editor;
var cursor = ed.getCursorPosition();
getPos: function(editor, range, count, param, isSel) {
var cursor = editor.getCursorPosition();
var column = util.getLeftNthChar(editor, cursor, param, count || 1);
if (typeof column === "number") {
ed.moveCursorTo(cursor.row, cursor.column - column - 1);
cursor.column -= column + 1;
return cursor;
}
}
},
"t": {
}),
"t": new Motion({
param: true,
handlesCount: true,
nav: function(editor, range, count, param) {
var ed = editor;
var cursor = ed.getCursorPosition();
getPos: function(editor, range, count, param, isSel) {
var cursor = editor.getCursorPosition();
var column = util.getRightNthChar(editor, cursor, param, count || 1);
if (typeof column === "number") {
ed.selection.clearSelection(); // Why does it select in the first place?
ed.moveCursorTo(cursor.row, column + cursor.column);
}
},
sel: function(editor, range, count, param) {
var ed = editor;
var cursor = ed.getCursorPosition();
var column = util.getRightNthChar(editor, cursor, param, count || 1);
if (typeof column === "number") {
ed.moveCursorTo(cursor.row, column + cursor.column);
cursor.column += column + (isSel ? 1 : 0);
return cursor;
}
}
},
"T": {
}),
"T": new Motion({
param: true,
handlesCount: true,
nav: function(editor, range, count, param) {
var ed = editor;
var cursor = ed.getCursorPosition();
getPos: function(editor, range, count, param, isSel) {
var cursor = editor.getCursorPosition();
var column = util.getLeftNthChar(editor, cursor, param, count || 1);
if (typeof column === "number") {
ed.selection.clearSelection(); // Why does it select in the first place?
ed.moveCursorTo(cursor.row, -column + cursor.column);
}
},
sel: function(editor, range, count, param) {
var ed = editor;
var cursor = ed.getCursorPosition();
var column = util.getLeftNthChar(editor, cursor, param, count || 1);
if (typeof column === "number") {
ed.moveCursorTo(cursor.row, -column + cursor.column);
cursor.column -= column;
return cursor;
}
}
},
}),
"^": {
nav: function(editor) {
@@ -473,16 +443,9 @@ module.exports = {
editor.selection.selectLineEnd();
}
},
"0": {
nav: function(editor) {
var ed = editor;
ed.navigateTo(ed.selection.selectionLead.row, 0);
},
sel: function(editor) {
var ed = editor;
ed.selectTo(ed.selection.selectionLead.row, 0);
}
},
"0": new Motion(function(ed) {
return {row: ed.selection.lead.row, column: 0};
}),
"G": {
nav: function(editor, range, count, param) {
if (!count && count !== 0) { // Stupid JS
@@ -580,6 +543,25 @@ module.exports = {
return match;
}),
"{": new Motion(function(ed) {
var session = ed.session;
var row = session.selection.lead.row;
while(row > 0 && !/\S/.test(session.getLine(row)))
row--;
while(/\S/.test(session.getLine(row)))
row--;
return {column: 0, row: row};
}),
"}": new Motion(function(ed) {
var session = ed.session;
var l = session.getLength();
var row = session.selection.lead.row;
while(row < l && !/\S/.test(session.getLine(row)))
row++;
while(/\S/.test(session.getLine(row)))
row++;
return {column: 0, row: row};
}),
"ctrl-d": {
nav: function(editor, range, count, param) {
editor.selection.clearSelection();
@@ -598,7 +580,7 @@ module.exports = {
sel: function(editor, range, count, param) {
keepScrollPosition(editor, editor.selectPageUp);
}
},
}
};
module.exports.backspace = module.exports.left = module.exports.h;
@@ -1,37 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Sergi Mansilla <sergi AT c9 DOT io>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -63,6 +56,16 @@ module.exports = {
editor.selection.selectLine();
registers._default.text += editor.getCopyText();
var selRange = editor.getSelectionRange();
// check if end of the document was reached
if (!selRange.isMultiLine()) {
lastLineReached = true
var row = selRange.start.row - 1;
var col = editor.session.getLine(row).length
selRange.setStart(row, col);
editor.session.remove(selRange);
editor.selection.clearSelection();
break;
}
editor.session.remove(selRange);
editor.selection.clearSelection();
}
@@ -2,7 +2,7 @@ define(function(require, exports, module) {
var registers = require("../registers");
var dom = require("../../../lib/dom");
dom.importCssString('.insert-mode. ace_cursor{\
dom.importCssString('.insert-mode .ace_cursor{\
border-left: 2px solid #333333;\
}\
.ace_dark.insert-mode .ace_cursor{\
@@ -22,7 +22,7 @@ module.exports = {
editor.unsetStyle('insert-mode');
editor.unsetStyle('normal-mode');
if (editor.commands.recording)
editor.commands.toggleRecording();
editor.commands.toggleRecording(editor);
editor.setOverwrite(false);
},
insertMode: function(editor) {
@@ -43,10 +43,10 @@ module.exports = {
this.onInsertReplaySequence = null;
this.normalMode(editor);
} else {
editor._emit("vimMode", "insert");
editor._emit("changeStatus");
// Record any movements, insertions in insert mode
if(!editor.commands.recording)
editor.commands.toggleRecording();
editor.commands.toggleRecording(editor);
}
},
normalMode: function(editor) {
@@ -69,10 +69,10 @@ module.exports = {
editor.keyBinding.$data.state = "start";
this.onVisualMode = false;
this.onVisualLineMode = false;
editor._emit("changeVimMode", "normal");
editor._emit("changeStatus");
// Save recorded keystrokes
if (editor.commands.recording) {
editor.commands.toggleRecording();
editor.commands.toggleRecording(editor);
return editor.commands.macro;
}
else {
@@ -91,7 +91,7 @@ module.exports = {
editor.setStyle('insert-mode');
editor.unsetStyle('normal-mode');
editor._emit("changeVimMode", "visual");
editor._emit("changeStatus");
if (lineMode) {
this.onVisualLineMode = true;
} else {
@@ -99,24 +99,24 @@ module.exports = {
this.onVisualLineMode = false;
}
},
getRightNthChar: function(editor, cursor, char, n) {
getRightNthChar: function(editor, cursor, ch, n) {
var line = editor.getSession().getLine(cursor.row);
var matches = line.substr(cursor.column + 1).split(char);
var matches = line.substr(cursor.column + 1).split(ch);
return n < matches.length ? matches.slice(0, n).join(char).length : null;
return n < matches.length ? matches.slice(0, n).join(ch).length : null;
},
getLeftNthChar: function(editor, cursor, char, n) {
getLeftNthChar: function(editor, cursor, ch, n) {
var line = editor.getSession().getLine(cursor.row);
var matches = line.substr(0, cursor.column).split(char);
var matches = line.substr(0, cursor.column).split(ch);
return n < matches.length ? matches.slice(-1 * n).join(char).length : null;
return n < matches.length ? matches.slice(-1 * n).join(ch).length : null;
},
toRealChar: function(char) {
if (char.length === 1)
return char;
toRealChar: function(ch) {
if (ch.length === 1)
return ch;
if (/^shift-./.test(char))
return char[char.length - 1].toUpperCase();
if (/^shift-./.test(ch))
return ch[ch.length - 1].toUpperCase();
else
return "";
},
@@ -1,37 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Sergi Mansilla <sergi AT c9 DOT io>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -1,39 +1,30 @@
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Julian Viereck <julian.viereck@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -48,9 +39,13 @@ var Cursor = function(parentEl) {
parentEl.appendChild(this.element);
this.isVisible = false;
this.isBlinking = true;
this.blinkInterval = 1000;
this.smoothBlinking = false;
this.cursors = [];
this.cursor = this.addCursor();
dom.addCssClass(this.element, "ace_hidden-cursors");
};
(function() {
@@ -64,15 +59,34 @@ var Cursor = function(parentEl) {
this.session = session;
};
this.setBlinking = function(blinking) {
if (blinking != this.isBlinking){
this.isBlinking = blinking;
this.restartTimer();
}
};
this.setBlinkInterval = function(blinkInterval) {
if (blinkInterval != this.blinkInterval){
this.blinkInterval = blinkInterval;
this.restartTimer();
}
};
this.setSmoothBlinking = function(smoothBlinking) {
if (smoothBlinking != this.smoothBlinking) {
this.smoothBlinking = smoothBlinking;
if (smoothBlinking)
dom.addCssClass(this.element, "ace_smooth-blinking");
else
dom.removeCssClass(this.element, "ace_smooth-blinking");
this.restartTimer();
}
};
this.addCursor = function() {
var el = dom.createElement("div");
var className = "ace_cursor";
if (!this.isVisible)
className += " ace_hidden";
if (this.overwrite)
className += " ace_overwrite";
el.className = className;
el.className = "ace_cursor";
this.element.appendChild(el);
this.cursors.push(el);
return el;
@@ -88,112 +102,113 @@ var Cursor = function(parentEl) {
this.hideCursor = function() {
this.isVisible = false;
for (var i = this.cursors.length; i--; )
dom.addCssClass(this.cursors[i], "ace_hidden");
clearInterval(this.blinkId);
dom.addCssClass(this.element, "ace_hidden-cursors");
this.restartTimer();
};
this.showCursor = function() {
this.isVisible = true;
for (var i = this.cursors.length; i--; )
dom.removeCssClass(this.cursors[i], "ace_hidden");
this.element.style.visibility = "";
dom.removeCssClass(this.element, "ace_hidden-cursors");
this.restartTimer();
};
this.restartTimer = function() {
clearInterval(this.blinkId);
if (!this.isVisible)
clearInterval(this.intervalId);
clearTimeout(this.timeoutId);
if (this.smoothBlinking)
dom.removeCssClass(this.element, "ace_smooth-blinking");
for (var i = this.cursors.length; i--; )
this.cursors[i].style.opacity = "";
if (!this.isBlinking || !this.blinkInterval || !this.isVisible)
return;
var element = this.cursors.length == 1 ? this.cursor : this.element;
this.blinkId = setInterval(function() {
element.style.visibility = "hidden";
setTimeout(function() {
element.style.visibility = "";
}, 400);
}, 1000);
if (this.smoothBlinking)
setTimeout(function(){
dom.addCssClass(this.element, "ace_smooth-blinking");
}.bind(this));
var blink = function(){
this.timeoutId = setTimeout(function() {
for (var i = this.cursors.length; i--; ) {
this.cursors[i].style.opacity = 0;
}
}.bind(this), 0.6 * this.blinkInterval);
}.bind(this);
this.intervalId = setInterval(function() {
for (var i = this.cursors.length; i--; ) {
this.cursors[i].style.opacity = "";
}
blink();
}.bind(this), this.blinkInterval);
blink();
};
this.getPixelPosition = function(position, onScreen) {
if (!this.config || !this.session) {
return {
left : 0,
top : 0
};
}
if (!this.config || !this.session)
return {left : 0, top : 0};
if (!position)
position = this.session.selection.getCursor();
var pos = this.session.documentToScreenPosition(position);
var cursorLeft = Math.round(this.$padding +
pos.column * this.config.characterWidth);
var cursorLeft = this.$padding + pos.column * this.config.characterWidth;
var cursorTop = (pos.row - (onScreen ? this.config.firstRowScreen : 0)) *
this.config.lineHeight;
return {
left : cursorLeft,
top : cursorTop
};
return {left : cursorLeft, top : cursorTop};
};
this.update = function(config) {
this.config = config;
if (this.session.selectionMarkerCount > 0) {
var selections = this.session.$selectionMarkers;
var i = 0, sel, cursorIndex = 0;
var selections = this.session.$selectionMarkers;
var i = 0, cursorIndex = 0;
for (var i = selections.length; i--; ) {
sel = selections[i];
var pixelPos = this.getPixelPosition(sel.cursor, true);
if (selections === undefined || selections.length === 0){
selections = [{cursor: null}];
}
var style = (this.cursors[cursorIndex++] || this.addCursor()).style;
style.left = pixelPos.left + "px";
style.top = pixelPos.top + "px";
style.width = config.characterWidth + "px";
style.height = config.lineHeight + "px";
for (var i = selections.length; i--; ) {
var pixelPos = this.getPixelPosition(selections[i].cursor, true);
if ((pixelPos.top > config.height + config.offset ||
pixelPos.top < -config.offset) && i > 1) {
continue;
}
if (cursorIndex > 1)
while (this.cursors.length > cursorIndex)
this.removeCursor();
} else {
var pixelPos = this.getPixelPosition(null, true);
var style = this.cursor.style;
var style = (this.cursors[cursorIndex++] || this.addCursor()).style;
style.left = pixelPos.left + "px";
style.top = pixelPos.top + "px";
style.width = config.characterWidth + "px";
style.height = config.lineHeight + "px";
while (this.cursors.length > 1)
this.removeCursor();
}
while (this.cursors.length > cursorIndex)
this.removeCursor();
var overwrite = this.session.getOverwrite();
if (overwrite != this.overwrite)
this.$setOverite(overwrite);
this.$setOverwrite(overwrite);
// cache for textarea and gutter highlight
this.$pixelPos = pixelPos;
this.restartTimer();
};
this.$setOverite = function(overwrite) {
this.overwrite = overwrite;
for (var i = this.cursors.length; i--; ) {
this.$setOverwrite = function(overwrite) {
if (overwrite != this.overwrite) {
this.overwrite = overwrite;
if (overwrite)
dom.addCssClass(this.cursors[i], "ace_overwrite");
dom.addCssClass(this.element, "ace_overwrite-cursors");
else
dom.removeCssClass(this.cursors[i], "ace_overwrite");
dom.removeCssClass(this.element, "ace_overwrite-cursors");
}
};
this.destroy = function() {
clearInterval(this.blinkId);
}
clearInterval(this.intervalId);
clearTimeout(this.timeoutId);
};
}).call(Cursor.prototype);
@@ -1,39 +1,30 @@
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Julian Viereck <julian DOT viereck AT gmail DOT com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -42,6 +33,7 @@ define(function(require, exports, module) {
var dom = require("../lib/dom");
var oop = require("../lib/oop");
var lang = require("../lib/lang");
var EventEmitter = require("../lib/event_emitter").EventEmitter;
var Gutter = function(parentEl) {
@@ -52,60 +44,80 @@ var Gutter = function(parentEl) {
this.gutterWidth = 0;
this.$breakpoints = [];
this.$annotations = [];
this.$decorations = [];
this.$updateAnnotations = this.$updateAnnotations.bind(this);
};
(function() {
oop.implement(this, EventEmitter);
this.setSession = function(session) {
if (this.session)
this.session.removeEventListener("change", this.$updateAnnotations);
this.session = session;
session.on("change", this.$updateAnnotations);
};
this.addGutterDecoration = function(row, className){
if (!this.$decorations[row])
this.$decorations[row] = "";
this.$decorations[row] += " " + className;
if (window.console)
console.warn && console.warn("deprecated use session.addGutterDecoration");
this.session.addGutterDecoration(row, className);
};
this.removeGutterDecoration = function(row, className){
this.$decorations[row] = (this.$decorations[row] || "").replace(" " + className, "");
if (window.console)
console.warn && console.warn("deprecated use session.removeGutterDecoration");
this.session.removeGutterDecoration(row, className);
};
this.setAnnotations = function(annotations) {
// iterate over sparse array
this.$annotations = [];
for (var row in annotations) if (annotations.hasOwnProperty(row)) {
var rowAnnotations = annotations[row];
if (!rowAnnotations)
continue;
this.$annotations = []
var rowInfo, row;
for (var i = 0; i < annotations.length; i++) {
var annotation = annotations[i];
var row = annotation.row;
var rowInfo = this.$annotations[row];
if (!rowInfo)
rowInfo = this.$annotations[row] = {text: []};
var annoText = annotation.text;
annoText = annoText ? lang.escapeHTML(annoText) : annotation.html || "";
var rowInfo = this.$annotations[row] = {
text: []
};
for (var i=0; i<rowAnnotations.length; i++) {
var annotation = rowAnnotations[i];
var annoText = annotation.text.replace(/"/g, "&quot;").replace(/'/g, "&#8217;").replace(/</, "&lt;");
if (rowInfo.text.indexOf(annoText) === -1)
rowInfo.text.push(annoText);
var type = annotation.type;
if (type == "error")
rowInfo.className = "ace_error";
else if (type == "warning" && rowInfo.className != "ace_error")
rowInfo.className = "ace_warning";
else if (type == "info" && (!rowInfo.className))
rowInfo.className = "ace_info";
}
if (rowInfo.text.indexOf(annoText) === -1)
rowInfo.text.push(annoText);
var type = annotation.type;
if (type == "error")
rowInfo.className = " ace_error";
else if (type == "warning" && rowInfo.className != " ace_error")
rowInfo.className = " ace_warning";
else if (type == "info" && (!rowInfo.className))
rowInfo.className = " ace_info";
}
};
this.$updateAnnotations = function (e) {
if (!this.$annotations.length)
return;
var delta = e.data;
var range = delta.range;
var firstRow = range.start.row;
var len = range.end.row - firstRow;
if (len === 0) {
// do nothing
} else if (delta.action == "removeText" || delta.action == "removeLines") {
this.$annotations.splice(firstRow, len + 1, null);
} else {
var args = Array(len + 1);
args.unshift(firstRow, 1);
this.$annotations.splice.apply(this.$annotations, args);
}
};
this.update = function(config) {
this.$config = config;
var emptyAnno = {className: "", text: []};
var emptyAnno = {className: ""};
var html = [];
var i = config.firstRow;
var lastRow = config.lastRow;
@@ -113,6 +125,8 @@ var Gutter = function(parentEl) {
var foldStart = fold ? fold.start.row : Infinity;
var foldWidgets = this.$showFoldWidgets && this.session.foldWidgets;
var breakpoints = this.session.$breakpoints;
var decorations = this.session.$decorations;
var lastLineNumber = 0;
while (true) {
if(i > foldStart) {
@@ -124,12 +138,12 @@ var Gutter = function(parentEl) {
break;
var annotation = this.$annotations[i] || emptyAnno;
html.push("<div class='ace_gutter-cell",
this.$decorations[i] || "",
breakpoints[i] ? " ace_breakpoint " : " ",
annotation.className,
"' title='", annotation.text.join("\n"),
"' style='height:", this.session.getRowLength(i) * config.lineHeight, "px;'>", (i+1));
html.push(
"<div class='ace_gutter-cell ",
breakpoints[i] || "", decorations[i] || "", annotation.className,
"' style='height:", this.session.getRowLength(i) * config.lineHeight, "px;'>",
lastLineNumber = i + 1
);
if (foldWidgets) {
var c = foldWidgets[i];
@@ -138,8 +152,9 @@ var Gutter = function(parentEl) {
c = foldWidgets[i] = this.session.getFoldWidget(i);
if (c)
html.push(
"<span class='ace_fold-widget ", c,
c == "start" && i == foldStart && i < fold.end.row ? " closed" : " open",
"<span class='ace_fold-widget ace_", c,
c == "start" && i == foldStart && i < fold.end.row ? " ace_closed" : " ace_open",
"' style='height:", config.lineHeight, "px",
"'></span>"
);
}
@@ -149,19 +164,18 @@ var Gutter = function(parentEl) {
i++;
}
if (this.session.$useWrapMode)
html.push(
"<div class='ace_gutter-cell' style='pointer-events:none;opacity:0'>",
this.session.getLength() - 1,
"</div>"
);
this.element = dom.setInnerHtml(this.element, html.join(""));
this.element.style.height = config.minHeight + "px";
var gutterWidth = this.element.offsetWidth;
if (this.session.$useWrapMode)
lastLineNumber = this.session.getLength();
var gutterWidth = ("" + lastLineNumber).length * config.characterWidth;
var padding = this.$padding || this.$computePadding();
gutterWidth += padding.left + padding.right;
if (gutterWidth !== this.gutterWidth) {
this.gutterWidth = gutterWidth;
this.element.style.width = Math.ceil(this.gutterWidth) + "px";
this._emit("changeGutterWidth", gutterWidth);
}
};
@@ -174,12 +188,32 @@ var Gutter = function(parentEl) {
dom.removeCssClass(this.element, "ace_folding-enabled");
this.$showFoldWidgets = show;
this.$padding = null;
};
this.getShowFoldWidgets = function() {
return this.$showFoldWidgets;
};
this.$computePadding = function() {
if (!this.element.firstChild)
return {left: 0, right: 0};
var style = dom.computedStyle(this.element.firstChild);
this.$padding = {}
this.$padding.left = parseInt(style.paddingLeft) + 1;
this.$padding.right = parseInt(style.paddingRight);
return this.$padding;
};
this.getRegion = function(point) {
var padding = this.$padding || this.$computePadding();
var rect = this.element.getBoundingClientRect();
if (point.x < padding.left + rect.left)
return "markers";
if (this.$showFoldWidgets && point.x > rect.right - padding.right)
return "foldWidgets";
};
}).call(Gutter.prototype);
exports.Gutter = Gutter;
@@ -1,39 +1,30 @@
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Julian Viereck <julian.viereck@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -87,26 +78,17 @@ var Marker = function(parentEl) {
range = range.toScreenRange(this.session);
if (marker.renderer) {
var top = this.$getTop(range.start.row, config);
var left = Math.round(
this.$padding + range.start.column * config.characterWidth
);
var left = this.$padding + range.start.column * config.characterWidth;
marker.renderer(html, range, left, top, config);
}
else if (range.isMultiLine()) {
if (marker.type == "text") {
} else if (marker.type == "fullLine") {
this.drawFullLineMarker(html, range, marker.clazz, config);
} else if (range.isMultiLine()) {
if (marker.type == "text")
this.drawTextMarker(html, range, marker.clazz, config);
} else {
this.drawMultiLineMarker(
html, range, marker.clazz, config,
marker.type
);
}
}
else {
this.drawSingleLineMarker(
html, range, marker.clazz + " start", config,
null, marker.type
);
else
this.drawMultiLineMarker(html, range, marker.clazz, config);
} else {
this.drawSingleLineMarker(html, range, marker.clazz + " ace_start", config);
}
}
this.element = dom.setInnerHtml(this.element, html.join(""));
@@ -125,7 +107,7 @@ var Marker = function(parentEl) {
row, range.start.column,
row, this.session.getScreenLastRowColumn(row)
);
this.drawSingleLineMarker(stringBuilder, lineRange, clazz + " start", layerConfig, 1, "text");
this.drawSingleLineMarker(stringBuilder, lineRange, clazz + " ace_start", layerConfig, 1, "text");
// selection end
row = range.end.row;
@@ -142,14 +124,14 @@ var Marker = function(parentEl) {
// Draws a multi line marker, where lines span the full width
this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, type) {
var padding = type === "background" ? 0 : this.$padding;
// from selection start to the end of the line
var padding = this.$padding;
var height = config.lineHeight;
var top = this.$getTop(range.start.row, config);
var left = Math.round(padding + range.start.column * config.characterWidth);
var left = padding + range.start.column * config.characterWidth;
stringBuilder.push(
"<div class='", clazz, " start' style='",
"<div class='", clazz, " ace_start' style='",
"height:", height, "px;",
"right:0;",
"top:", top, "px;",
@@ -158,7 +140,7 @@ var Marker = function(parentEl) {
// from start of the last line to the selection end
top = this.$getTop(range.end.row, config);
var width = Math.round(range.end.column * config.characterWidth);
var width = range.end.column * config.characterWidth;
stringBuilder.push(
"<div class='", clazz, "' style='",
@@ -184,19 +166,12 @@ var Marker = function(parentEl) {
};
// Draws a marker which covers part or whole width of a single screen line
this.drawSingleLineMarker = function(stringBuilder, range, clazz, layerConfig, extraLength, type) {
var padding = type === "background" ? 0 : this.$padding;
var height = layerConfig.lineHeight;
this.drawSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength) {
var height = config.lineHeight;
var width = (range.end.column + (extraLength || 0) - range.start.column) * config.characterWidth;
if (type === "background")
var width = layerConfig.width;
else
width = Math.round((range.end.column + (extraLength || 0) - range.start.column) * layerConfig.characterWidth);
var top = this.$getTop(range.start.row, layerConfig);
var left = Math.round(
padding + range.start.column * layerConfig.characterWidth
);
var top = this.$getTop(range.start.row, config);
var left = this.$padding + range.start.column * config.characterWidth;
stringBuilder.push(
"<div class='", clazz, "' style='",
@@ -207,6 +182,20 @@ var Marker = function(parentEl) {
);
};
this.drawFullLineMarker = function(stringBuilder, range, clazz, config) {
var top = this.$getTop(range.start.row, config);
var height = config.lineHeight;
if (range.start.row != range.end.row)
height += this.$getTop(range.end.row, config) - top;
stringBuilder.push(
"<div class='", clazz, "' style='",
"height:", height, "px;",
"top:", top, "px;",
"left:0;right:0;'></div>"
);
}
}).call(Marker.prototype);
exports.Marker = Marker;
@@ -1,41 +1,30 @@
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Julian Viereck <julian DOT viereck AT gmail DOT com>
* Mihai Sucan <mihai.sucan@gmail.com>
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -53,7 +42,8 @@ var Text = function(parentEl) {
this.element.className = "ace_layer ace_text-layer";
parentEl.appendChild(this.element);
this.$characterSize = this.$measureSizes() || {width: 0, height: 0};
this.$characterSize = {width: 0, height: 0};
this.checkForSizeChanges();
this.$pollSizeChanges();
};
@@ -83,7 +73,11 @@ var Text = function(parentEl) {
this.checkForSizeChanges = function() {
var size = this.$measureSizes();
if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
this.$measureNode.style.fontWeight = "bold";
var boldSize = this.$measureSizes();
this.$measureNode.style.fontWeight = "";
this.$characterSize = size;
this.allowBoldFonts = boldSize && boldSize.width === size.width && boldSize.height === size.height;
this._emit("changeCharacterSize", {data: size});
}
};
@@ -196,6 +190,7 @@ var Text = function(parentEl) {
this.setSession = function(session) {
this.session = session;
this.$computeTabString();
};
this.showInvisibles = false;
@@ -204,28 +199,52 @@ var Text = function(parentEl) {
return false;
this.showInvisibles = showInvisibles;
this.$computeTabString();
return true;
};
this.displayIndentGuides = true;
this.setDisplayIndentGuides = function(display) {
if (this.displayIndentGuides == display)
return false;
this.displayIndentGuides = display;
this.$computeTabString();
return true;
};
this.$tabStrings = [];
this.onChangeTabSize =
this.$computeTabString = function() {
var tabSize = this.session.getTabSize();
this.tabSize = tabSize;
var tabStr = this.$tabStrings = [0];
for (var i = 1; i < tabSize + 1; i++) {
if (this.showInvisibles) {
tabStr.push("<span class='ace_invisible'>"
+ this.TAB_CHAR
+ new Array(i).join("&#160;")
+ Array(i).join("&#160;")
+ "</span>");
} else {
tabStr.push(new Array(i+1).join("&#160;"));
}
}
if (this.displayIndentGuides) {
this.$indentGuideRe = /\s\S| \t|\t |\s$/;
var className = "ace_indent-guide";
var content = Array(this.tabSize + 1).join("&#160;");
var tabContent = content;
if (this.showInvisibles) {
className += " ace_invisible";
tabContent = this.TAB_CHAR + content.substr(6);
}
this.$tabStrings[" "] = "<span class='" + className + "'>" + content + "</span>";
this.$tabStrings["\t"] = "<span class='" + className + "'>" + tabContent + "</span>";
}
};
this.updateLines = function(config, firstRow, lastRow) {
this.$computeTabString();
// Due to wrap line changes there can be new lines if e.g.
// the line to updated wrapped in the meantime.
if (this.config.lastRow != config.lastRow ||
@@ -253,22 +272,32 @@ var Text = function(parentEl) {
lineElementsIdx ++;
}
for (var i=first; i<=last; i++) {
var row = first;
var foldLine = this.session.getNextFoldLine(row);
var foldStart = foldLine ? foldLine.start.row : Infinity;
while (true) {
if (row > foldStart) {
row = foldLine.end.row+1;
foldLine = this.session.getNextFoldLine(row, foldLine);
foldStart = foldLine ? foldLine.start.row :Infinity;
}
if (row > last)
break;
var lineElement = lineElements[lineElementsIdx++];
if (!lineElement)
continue;
var html = [];
var tokens = this.session.getTokens(i);
this.$renderLine(html, i, tokens, !this.$useLineGroups());
lineElement = dom.setInnerHtml(lineElement, html.join(""));
i = this.session.getRowFoldEnd(i);
if (lineElement) {
var html = [];
this.$renderLine(
html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false
);
dom.setInnerHtml(lineElement, html.join(""));
}
row++;
}
};
this.scrollLines = function(config) {
this.$computeTabString();
var oldConfig = this.config;
this.config = config;
@@ -321,8 +350,7 @@ var Text = function(parentEl) {
var html = [];
// Get the tokens per line as there might be some lines in between
// beeing folded.
var tokens = this.session.getTokens(row);
this.$renderLine(html, row, tokens, false);
this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
// don't use setInnerHtml since we are working with an empty DIV
container.innerHTML = html.join("");
@@ -341,7 +369,6 @@ var Text = function(parentEl) {
};
this.update = function(config) {
this.$computeTabString();
this.config = config;
var html = [];
@@ -363,10 +390,7 @@ var Text = function(parentEl) {
if (this.$useLineGroups())
html.push("<div class='ace_line_group'>")
// Get the tokens per line as there might be some lines in between
// beeing folded.
var tokens = this.session.getTokens(row);
this.$renderLine(html, row, tokens, false);
this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
if (this.$useLineGroups())
html.push("</div>"); // end the line group
@@ -384,7 +408,7 @@ var Text = function(parentEl) {
this.$renderToken = function(stringBuilder, screenColumn, token, value) {
var self = this;
var replaceReg = /\t|&|<|( +)|([\u0000-\u0019\u00a0\u1680\u180E\u2000-\u200b\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\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;
var replaceReg = /\t|&|<|( +)|([\x00-\x1f\x80-\xa0\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\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;
var replaceFunc = function(c, a, b, tabIdx, idx4) {
if (a) {
return new Array(c.length+1).join("&#160;");
@@ -429,38 +453,44 @@ var Text = function(parentEl) {
return screenColumn + value.length;
};
this.$renderLineCore = function(stringBuilder, lastRow, tokens, splits, onlyContents) {
this.renderIndentGuide = function(stringBuilder, value) {
var cols = value.search(this.$indentGuideRe);
if (cols <= 0)
return value;
if (value[0] == " ") {
cols -= cols % this.tabSize;
stringBuilder.push(Array(cols/this.tabSize + 1).join(this.$tabStrings[" "]));
return value.substr(cols);
} else if (value[0] == "\t") {
stringBuilder.push(Array(cols + 1).join(this.$tabStrings["\t"]));
return value.substr(cols);
}
return value;
};
this.$renderWrappedLine = function(stringBuilder, tokens, splits, onlyContents) {
var chars = 0;
var split = 0;
var splitChars;
var splitChars = splits[0];
var screenColumn = 0;
var self = this;
if (!splits || splits.length == 0)
splitChars = Number.MAX_VALUE;
else
splitChars = splits[0];
if (!onlyContents) {
stringBuilder.push("<div class='ace_line' style='height:",
this.config.lineHeight, "px",
"'>"
);
}
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i];
var value = token.value;
if (i == 0 && this.displayIndentGuides) {
chars = value.length;
value = this.renderIndentGuide(stringBuilder, value);
if (!value)
continue;
chars -= value.length;
}
if (chars + value.length < splitChars) {
screenColumn = self.$renderToken(
stringBuilder, screenColumn, token, value
);
screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
chars += value.length;
}
else {
} else {
while (chars + value.length >= splitChars) {
screenColumn = self.$renderToken(
screenColumn = this.$renderToken(
stringBuilder, screenColumn,
token, value.substring(0, splitChars - chars)
);
@@ -470,8 +500,7 @@ var Text = function(parentEl) {
if (!onlyContents) {
stringBuilder.push("</div>",
"<div class='ace_line' style='height:",
this.config.lineHeight, "px",
"'>"
this.config.lineHeight, "px'>"
);
}
@@ -481,37 +510,70 @@ var Text = function(parentEl) {
}
if (value.length != 0) {
chars += value.length;
screenColumn = self.$renderToken(
screenColumn = this.$renderToken(
stringBuilder, screenColumn, token, value
);
}
}
}
};
this.$renderSimpleLine = function(stringBuilder, tokens) {
var screenColumn = 0;
var token = tokens[0];
var value = token.value;
if (this.displayIndentGuides)
value = this.renderIndentGuide(stringBuilder, value);
if (value)
screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
for (var i = 1; i < tokens.length; i++) {
token = tokens[i];
value = token.value;
screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
}
};
// row is either first row of foldline or not in fold
this.$renderLine = function(stringBuilder, row, onlyContents, foldLine) {
if (!foldLine && foldLine != false)
foldLine = this.session.getFoldLine(row);
if (foldLine)
var tokens = this.$getFoldLineTokens(row, foldLine);
else
var tokens = this.session.getTokens(row);
if (!onlyContents) {
stringBuilder.push(
"<div class='ace_line' style='height:", this.config.lineHeight, "px'>"
);
}
if (tokens.length) {
var splits = this.session.getRowSplitData(row);
if (splits && splits.length)
this.$renderWrappedLine(stringBuilder, tokens, splits, onlyContents);
else
this.$renderSimpleLine(stringBuilder, tokens);
}
if (this.showInvisibles) {
if (lastRow !== this.session.getLength() - 1)
stringBuilder.push("<span class='ace_invisible'>" + this.EOL_CHAR + "</span>");
else
stringBuilder.push("<span class='ace_invisible'>" + this.EOF_CHAR + "</span>");
if (foldLine)
row = foldLine.end.row
stringBuilder.push(
"<span class='ace_invisible'>",
row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR,
"</span>"
);
}
if (!onlyContents)
stringBuilder.push("</div>");
};
this.$renderLine = function(stringBuilder, row, tokens, onlyContents) {
// Check if the line to render is folded or not. If not, things are
// simple, otherwise, we need to fake some things...
if (!this.session.isRowFolded(row)) {
var splits = this.session.getRowSplitData(row);
this.$renderLineCore(stringBuilder, row, tokens, splits, onlyContents);
} else {
this.$renderFoldLine(stringBuilder, row, tokens, onlyContents);
}
};
this.$renderFoldLine = function(stringBuilder, row, tokens, onlyContents) {
this.$getFoldLineTokens = function(row, foldLine) {
var session = this.session;
var foldLine = session.getFoldLine(row);
var renderTokens = [];
function addTokens(tokens, from, to) {
@@ -552,8 +614,9 @@ var Text = function(parentEl) {
}
}
var tokens = session.getTokens(row);
foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) {
if (placeholder) {
if (placeholder != null) {
renderTokens.push({
type: "fold",
value: placeholder
@@ -567,9 +630,7 @@ var Text = function(parentEl) {
}
}, foldLine.end.row, this.session.getLine(foldLine.end.row).length);
// splits for foldline are stored at its' first row
var splits = this.session.$useWrapMode ? this.session.$wrapData[row] : null;
this.$renderLineCore(stringBuilder, row, renderTokens, splits, onlyContents);
return renderTokens;
};
this.$useLineGroups = function() {
@@ -1,37 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -67,35 +60,61 @@ module.exports = {
this.textLayer.$computeTabString();
// row with hard tabs
var row = 0;
var tokens = this.session.getTokens(row);
var stringBuilder = [];
this.textLayer.$renderLine(stringBuilder, row, tokens);
this.textLayer.$renderLine(stringBuilder, 0);
// row with soft tabs
row = 1;
tokens = this.session.getTokens(row);
var stringBuilder2 = [];
this.textLayer.$renderLine(stringBuilder2, row, tokens);
this.textLayer.$renderLine(stringBuilder2, 1);
assert.equal(stringBuilder.join(""), stringBuilder2.join(""));
},
"test rendering width of ideographic space (U+3000)" : function() {
this.session.setValue("\u3000");
var tokens = this.session.getTokens(0);
var stringBuilder = [];
this.textLayer.$renderLine(stringBuilder, 0, tokens, true);
this.textLayer.$renderLine(stringBuilder, 0, true);
assert.equal(stringBuilder.join(""), "<span class='ace_cjk' style='width:20px'></span>");
this.textLayer.setShowInvisibles(true);
var stringBuilder = [];
this.textLayer.$renderLine(stringBuilder, 0, tokens, true);
this.textLayer.$renderLine(stringBuilder, 0, true);
assert.equal(
stringBuilder.join(""),
"<span class='ace_cjk ace_invisible' style='width:20px'>" + this.textLayer.SPACE_CHAR + "</span>"
+ "<span class='ace_invisible'>\xB6</span>"
);
},
"test rendering of indent guides" : function() {
var textLayer = this.textLayer
var EOL = "<span class='ace_invisible'>" + textLayer.EOL_CHAR + "</span>";
var SPACE = function(i) {return Array(i+1).join("&#160;")}
var TAB = function(i) {return textLayer.TAB_CHAR + SPACE(i-1)}
function testRender(results) {
for (var i = results.length; i--; ) {
var stringBuilder = [];
textLayer.$renderLine(stringBuilder, i, true);
assert.equal(stringBuilder.join(""), results[i]);
}
}
this.session.setValue(" \n\t\tf\n ");
testRender([
"<span class='ace_indent-guide'>" + SPACE(4) + "</span>" + SPACE(2),
"<span class='ace_indent-guide'>" + SPACE(4) + "</span>" + SPACE(4) + "<span class='ace_identifier'>f</span>",
SPACE(3)
]);
this.textLayer.setShowInvisibles(true);
testRender([
"<span class='ace_indent-guide ace_invisible'>" + SPACE(4) + "</span>" + SPACE(2) + EOL,
"<span class='ace_indent-guide ace_invisible'>" + TAB(4) + "</span><span class='ace_invisible'>" + TAB(4) + "</span><span class='ace_identifier'>f</span>" + EOL,
]);
this.textLayer.setDisplayIndentGuides(false);
testRender([
SPACE(6) + EOL,
"<span class='ace_invisible'>" + TAB(4) + "</span><span class='ace_invisible'>" + TAB(4) + "</span><span class='ace_identifier'>f</span>" + EOL
]);
}
};
@@ -1,40 +1,30 @@
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
* Julian Viereck <julian.viereck@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -1,40 +1,30 @@
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Mihai Sucan <mihai AT sucan AT gmail ODT com>
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -543,10 +543,33 @@ if (!Object.getOwnPropertyNames) {
// ES5 15.2.3.5
// http://es5.github.com/#x15.2.3.5
if (!Object.create) {
var createEmpty;
if (Object.prototype.__proto__ === null) {
createEmpty = function () {
return { "__proto__": null };
};
} else {
// In old IE __proto__ can't be used to manually set `null`
createEmpty = function () {
var empty = {};
for (var i in empty)
empty[i] = null;
empty.constructor =
empty.hasOwnProperty =
empty.propertyIsEnumerable =
empty.isPrototypeOf =
empty.toLocaleString =
empty.toString =
empty.valueOf =
empty.__proto__ = null;
return empty;
}
}
Object.create = function create(prototype, properties) {
var object;
if (prototype === null) {
object = { "__proto__": null };
object = createEmpty();
} else {
if (typeof prototype != "object")
throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
@@ -1,37 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -108,11 +101,6 @@ exports.getButton = function(e) {
if (document.documentElement.setCapture) {
exports.capture = function(el, eventHandler, releaseCaptureHandler) {
function onMouseMove(e) {
eventHandler(e);
return exports.stopPropagation(e);
}
var called = false;
function onReleaseCapture(e) {
eventHandler(e);
@@ -137,22 +125,17 @@ if (document.documentElement.setCapture) {
}
else {
exports.capture = function(el, eventHandler, releaseCaptureHandler) {
function onMouseMove(e) {
eventHandler(e);
e.stopPropagation();
}
function onMouseUp(e) {
eventHandler && eventHandler(e);
releaseCaptureHandler && releaseCaptureHandler(e);
document.removeEventListener("mousemove", onMouseMove, true);
document.removeEventListener("mousemove", eventHandler, true);
document.removeEventListener("mouseup", onMouseUp, true);
e.stopPropagation();
}
document.addEventListener("mousemove", onMouseMove, true);
document.addEventListener("mousemove", eventHandler, true);
document.addEventListener("mouseup", onMouseUp, true);
};
}
@@ -193,7 +176,7 @@ exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbac
4: "quadclick"
};
var listener = function(e) {
exports.addListener(el, "mousedown", function(e) {
if (exports.getButton(e) != 0) {
clicks = 0;
} else {
@@ -219,10 +202,18 @@ exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbac
clicks = 0;
else if (clicks > 1)
return eventHandler[callbackName](eventNames[clicks], e);
};
});
exports.addListener(el, "mousedown", listener);
useragent.isOldIE && exports.addListener(el, "dblclick", listener);
if (useragent.isOldIE) {
exports.addListener(el, "dblclick", function(e) {
clicks = 2;
if (timer)
clearTimeout(timer);
timer = setTimeout(function() {timer = null}, timeouts[clicks - 1] || 600);
eventHandler[callbackName]("mousedown", e);
eventHandler[callbackName](eventNames[clicks], e);
});
}
};
function normalizeCommandKeys(callback, e, keyCode) {
@@ -292,11 +283,11 @@ exports.addCommandKeyListener = function(el, callback) {
}
};
if (window.postMessage) {
if (window.postMessage && !useragent.isOldIE) {
var postMessageId = 1;
exports.nextTick = function(callback, win) {
win = win || window;
var messageName = "zero-timeout-message-" + postMessageId;
var messageName = "zero-timeout-message-" + postMessageId;
exports.addListener(win, "message", function listener(e) {
if (e.data == messageName) {
exports.stopPropagation(e);
@@ -307,11 +298,18 @@ if (window.postMessage) {
win.postMessage(messageName, "*");
};
}
else {
exports.nextTick = function(callback, win) {
win = win || window;
window.setTimeout(callback, 0);
};
}
exports.nextFrame = window.requestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame;
if (exports.nextFrame)
exports.nextFrame = exports.nextFrame.bind(window);
else
exports.nextFrame = function(callback) {
setTimeout(callback, 17);
};
});
@@ -1,40 +1,30 @@
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
* Mike de Boer <mike AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -53,8 +43,11 @@ EventEmitter._dispatchEvent = function(eventName, e) {
if (!listeners.length && !defaultHandler)
return;
e = e || {};
e.type = eventName;
if (typeof e != "object" || !e)
e = {};
if (!e.type)
e.type = eventName;
if (!e.stopPropagation) {
e.stopPropagation = function() {
@@ -93,7 +86,7 @@ EventEmitter.addEventListener = function(eventName, callback) {
var listeners = this._eventRegistry[eventName];
if (!listeners)
var listeners = this._eventRegistry[eventName] = [];
listeners = this._eventRegistry[eventName] = [];
if (listeners.indexOf(callback) == -1)
listeners.push(callback);
@@ -1,37 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -108,7 +108,7 @@ var Keys = (function() {
// A reverse map of FUNCTION_KEYS
for (var i in ret.FUNCTION_KEYS) {
var name = ret.FUNCTION_KEYS[i].toUpperCase();
var name = ret.FUNCTION_KEYS[i].toLowerCase();
ret[name] = parseInt(i, 10);
}
@@ -118,6 +118,14 @@ var Keys = (function() {
oop.mixin(ret, ret.PRINTABLE_KEYS);
oop.mixin(ret, ret.FUNCTION_KEYS);
// aliases
ret.enter = ret["return"];
ret.escape = ret.esc;
ret.del = ret["delete"];
// workaround for firefox bug
ret[173] = '-';
return ret;
})();
oop.mixin(exports, Keys);
@@ -1,37 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -101,6 +94,14 @@ exports.arrayToMap = function(arr) {
};
exports.createMap = function(props) {
var map = Object.create(null);
for (var i in props) {
map[i] = props[i];
}
return map;
};
/*
* splice out of 'array' anything that === 'value'
*/
@@ -116,6 +117,10 @@ exports.escapeRegExp = function(str) {
return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
};
exports.escapeHTML = function(str) {
return str.replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
};
exports.getMatchOffsets = function(string, regExp) {
var matches = [];
@@ -129,7 +134,7 @@ exports.getMatchOffsets = function(string, regExp) {
return matches;
};
/* deprecated */
exports.deferredCall = function(fcn) {
var timer = null;
@@ -161,4 +166,39 @@ exports.deferredCall = function(fcn) {
return deferred;
};
exports.delayedCall = function(fcn, defaultTimeout) {
var timer = null;
var callback = function() {
timer = null;
fcn();
};
var _self = function(timeout) {
timer && clearTimeout(timer);
timer = setTimeout(callback, timeout || defaultTimeout);
};
_self.delay = delayed;
_self.schedule = function(timeout) {
if (timer == null)
timer = setTimeout(callback, timeout || 0);
};
_self.call = function() {
this.cancel();
fcn();
};
_self.cancel = function() {
timer && clearTimeout(timer);
timer = null;
};
_self.isPending = function() {
return timer;
};
return _self;
};
});
@@ -1,6 +1,6 @@
/*
* based on code from:
*
*
* @license RequireJS text 0.25.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/jrburke/requirejs for details
@@ -8,6 +8,8 @@
define(function(require, exports, module) {
"use strict";
var useragent = require("./useragent");
exports.get = function (url, callback) {
var xhr = exports.createXhr();
xhr.open('GET', url, true);
@@ -55,8 +57,13 @@ exports.loadScript = function(path, callback) {
s.src = path;
head.appendChild(s);
s.onload = callback;
if (useragent.isOldIE)
s.onreadystatechange = function () {
this.readyState == 'loaded' && callback();
};
else
s.onload = callback;
};
});
@@ -1,37 +1,30 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
@@ -98,7 +98,7 @@ define(function(require, exports, module) {
(regex.multiline ? "m" : "") +
(regex.extended ? "x" : "") + // Proposed for ES4; included in AS3
(regex.sticky ? "y" : "");
};
}
function indexOf (array, item, from) {
if (Array.prototype.indexOf) // Use the native array method if available
@@ -108,6 +108,6 @@ define(function(require, exports, module) {
return i;
}
return -1;
};
}
});
@@ -1,43 +1,66 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Distributed under the BSD license:
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
/*
* I hate doing this, but we need some way to determine if the user is on a Mac
* The reason is that users have different expectations of their key combinations.
*
* Take copy as an example, Mac people expect to use CMD or APPLE + C
* Windows folks expect to use CTRL + C
*/
exports.OS = {
LINUX: "LINUX",
MAC: "MAC",
WINDOWS: "WINDOWS"
};
/*
* Return an exports.OS constant
*/
exports.getOS = function() {
if (exports.isMac) {
return exports.OS.MAC;
} else if (exports.isLinux) {
return exports.OS.LINUX;
} else {
return exports.OS.WINDOWS;
}
};
// this can be called in non browser environments (e.g. from ace/requirejs/text)
if (typeof navigator != "object")
return;
var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase();
var ua = navigator.userAgent;
@@ -76,30 +99,4 @@ exports.isIPad = ua.indexOf("iPad") >= 0;
exports.isTouchPad = ua.indexOf("TouchPad") >= 0;
/*
* I hate doing this, but we need some way to determine if the user is on a Mac
* The reason is that users have different expectations of their key combinations.
*
* Take copy as an example, Mac people expect to use CMD or APPLE + C
* Windows folks expect to use CTRL + C
*/
exports.OS = {
LINUX: "LINUX",
MAC: "MAC",
WINDOWS: "WINDOWS"
};
/*
* Return an exports.OS constant
*/
exports.getOS = function() {
if (exports.isMac) {
return exports.OS.MAC;
} else if (exports.isLinux) {
return exports.OS.LINUX;
} else {
return exports.OS.WINDOWS;
}
};
});
@@ -0,0 +1,8 @@
{
"name": "ace-mode-creator",
"version": "0.1.0",
"dependencies": {
"connect": "",
"socket.io": ""
}
}
@@ -0,0 +1,144 @@
var fs = require("fs");
if (!fs.existsSync)
fs.existsSync = require("path").existsSync;
require("amd-loader");
var cwd = __dirname + "/";
function generateTestData() {
var root = Array(5).join("../") + "/demo/kitchen-sink/docs";
var docs = fs.readdirSync(cwd + root);
var specialDocs = fs.readdirSync(cwd);
var modes = fs.readdirSync(cwd + "../").filter(function(x){
return /^\w+_highlight_rules.js$/.test(x);
}).map(function(x) {
return x.replace(/_highlight_rules.js$/, "");
});
console.log("Docs:", docs);
console.log("Modes:", modes);
docs.forEach(function(docName) {
var p = docName.toLowerCase().split(".");
if (!p[1])
return;
var modeName;
if (modes.indexOf(p[0]) != -1)
modeName = p[0];
else if (modes.indexOf(p[1]) != -1)
modeName = p[1];
else
modeName = {"txt": "text", cpp: "c_cpp"}[p[1]];
var filePath = "text_" + modeName + ".txt";
if (specialDocs.indexOf(filePath) == -1) {
filePath = root + "/" + docName;
}
var text = fs.readFileSync(cwd + filePath, "utf8");
try {
var Mode = require("../" + modeName).Mode;
} catch(e) {
console.warn("Can't load mode :" + modeName, e);
return;
}
var tokenizer = new Mode().getTokenizer();
var state = "start";
var data = text.split(/\n|\r|\r\n/).map(function(line) {
var tokens = tokenizer.getLineTokens(line, state);
state = tokens.state;
tokens = tokens.tokens;
return {
state: state,
data: tokens.map(function(x) {return [x.type, x.value]})
};
});
var jsonStr = JSON.stringify(data, null, 1);
jsonStr = jsonStr.replace(/\n {4}/g, " ").replace(/\n {3}]/g, " ]");
fs.writeFileSync(cwd + "tokens_" + modeName + ".json", jsonStr, "utf8");
});
}
function test(startAt) {
var docs = fs.readdirSync(cwd).filter(function(x) {
return /^tokens_\w+.json$/.test(x);
});
if (startAt && startAt > 1)
docs = docs.slice(startAt - 1);
docs.forEach(function(x, i) {
var modeName = x.match(/tokens_(.*).json/)[1];
console.log(padNumber(i+1, 3) + ") testing: \u001b[33m" + modeName + "\u001b[0m");
var text = fs.readFileSync(cwd + x, "utf8");
var data = JSON.parse(text);
var Mode = require("../" + modeName).Mode;
var tokenizer = new Mode().getTokenizer();
var state = "start";
data.forEach(function(lineData) {
lineData.values = [];
lineData.types = [];
lineData.data.forEach(function(x) {
lineData.types.push(x[0]);
lineData.values.push(x[1]);
});
var line = lineData.values.join("");
var tokens = tokenizer.getLineTokens(line, state);
var values = tokens.tokens.map(function(x) {return x.value;});
var types = tokens.tokens.map(function(x) {return x.type;});
var success = true;
testEqual([
lineData.state, tokens.state,
lineData.types, types,
lineData.values, values]);
state = lineData.state;
});
});
console.log("\u001b[32m" + "all ok" + "\u001b[0m");
function testEqual(a) {
var err;
if (a[0] !== a[1]) {
console.log(a[0],a[1]);
err = 1;
}
if ( a[2] + "" !== a[3] + "" || a[4] + "" !== a[5] + "") {
arrayDiff(a[2],a[3]);
arrayDiff(a[4],a[5]);
err = 1;
}
if (err) {
throw "error";
}
}
function arrayDiff(a1, a2) {
var l = Math.max(a1.length, a2.length);
var out = [];
for (var i = 0; i < l; i++) {
out.push("\n", padNumber(i+1, 3), ") ");
if (a1[i] !== a2[i])
out.push("\u001b[31m", a1[i], " != ", a2[i], "\u001b[0m");
else
out.push(a1[i]);
}
console.log(out.join(""));
}
function padNumber(num, digits) {
return (" " + num).slice(-digits);
}
}
if (process.argv[2] == "gen")
generateTestData(process.argv.splice(3));
else
test(parseInt(process.argv[2],10) || 0);
@@ -0,0 +1,52 @@
function foo(items, nada) {
for (var i=0; i<items.length; i++) {
alert(items[i] + "juhu\n");
} // Real Tab.
}
regexp = /p|p/ // ends here
r = /d{1,2}?f{e}++r*?\d+?[]r[^r-o\f\f[\f]?r{7}+r\{7}+rr--rr$^(?:d|s)(?=a|)(?!y)[]|$?|^*/ o
a=/a/ jk = / / / / /
/************************************/
/** total mess, tricky to highlight**/
function () {
/**
* docComment
**/
r = /u\t*/
g = 1.00E^1, y = 1.2 + .2 + 052 + 0x25
t = ['d', '']
}
function () {
/* eee */
}
"s\
s\u7824sss\u1"
'\
string'
'
string'
"trailing space\
" " /not a regexp/g
/**
*doc
*/
a = {
'a': b,
'g': function(t)
gta:function(a,b)
}
foo.protoype.d = function(a, b,
c, d)
foo.d =function(a, b)
foo.d =function(a, /*****/ d"string"
@@ -0,0 +1,175 @@
[
{
"state": "start",
"data": [
[ "text", "Searching for 'var' in /workspace/configs" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "string", "configs/default.js" ],
[ "text", ":" ]
]
},
{
"state": "start",
"data": [
[ "c9searchresults.constant.numeric", " 1" ],
[ "c9searchresults.text", ": " ],
[ "c9searchresults.text", "var fs = require(\"fs\");" ]
]
},
{
"state": "start",
"data": [
[ "c9searchresults.constant.numeric", "\t2" ],
[ "c9searchresults.text", ": " ],
[ "c9searchresults.text", "var argv = require('optimist').argv;" ]
]
},
{
"state": "start",
"data": [
[ "c9searchresults.constant.numeric", "\t3" ],
[ "c9searchresults.text", ": " ],
[ "c9searchresults.text", "var path = require(\"path\");" ]
]
},
{
"state": "start",
"data": [
[ "c9searchresults.constant.numeric", "\t5" ],
[ "c9searchresults.text", ": " ],
[ "c9searchresults.text", "var clientExtensions = {};" ]
]
},
{
"state": "start",
"data": [
[ "c9searchresults.constant.numeric", "\t6" ],
[ "c9searchresults.text", ": " ],
[ "c9searchresults.text", "var clientDirs = fs.readdirSync(__dirname + \"/../plugins-client\");" ]
]
},
{
"state": "start",
"data": [
[ "c9searchresults.constant.numeric", "\t7" ],
[ "c9searchresults.text", ": " ],
[ "c9searchresults.text", "for (var i = 0; i < clientDirs.length; i++) {" ]
]
},
{
"state": "start",
"data": [
[ "c9searchresults.constant.numeric", "\t8" ],
[ "c9searchresults.text", ": " ],
[ "c9searchresults.text", "var dir = clientDirs[i];" ]
]
},
{
"state": "start",
"data": [
[ "c9searchresults.constant.numeric", "\t12" ],
[ "c9searchresults.text", ": " ],
[ "c9searchresults.text", "var name = dir.split(\".\")[1];" ]
]
},
{
"state": "start",
"data": [
[ "c9searchresults.constant.numeric", "\t16" ],
[ "c9searchresults.text", ": " ],
[ "c9searchresults.text", "var projectDir = (argv.w && path.resolve(process.cwd(), argv.w)) || process.cwd();" ]
]
},
{
"state": "start",
"data": [
[ "c9searchresults.constant.numeric", "\t17" ],
[ "c9searchresults.text", ": " ],
[ "c9searchresults.text", "var fsUrl = \"/workspace\";" ]
]
},
{
"state": "start",
"data": [
[ "c9searchresults.constant.numeric", "\t19" ],
[ "c9searchresults.text", ": " ],
[ "c9searchresults.text", "var port = argv.p || process.env.PORT || 3131;" ]
]
},
{
"state": "start",
"data": [
[ "c9searchresults.constant.numeric", "\t20" ],
[ "c9searchresults.text", ": " ],
[ "c9searchresults.text", "var host = argv.l || \"localhost\";" ]
]
},
{
"state": "start",
"data": [
[ "c9searchresults.constant.numeric", "\t22" ],
[ "c9searchresults.text", ": " ],
[ "c9searchresults.text", "var config = {" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "string", "configs/local.js" ],
[ "text", ":" ]
]
},
{
"state": "start",
"data": [
[ "c9searchresults.constant.numeric", "\t2" ],
[ "c9searchresults.text", ": " ],
[ "c9searchresults.text", "var config = require(\"./default\");" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "string", "configs/packed.js" ],
[ "text", ":" ]
]
},
{
"state": "start",
"data": [
[ "c9searchresults.constant.numeric", "\t1" ],
[ "c9searchresults.text", ": " ],
[ "c9searchresults.text", "var config = require(\"./default\");" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "text", "Found 15 matches in 3 files" ]
]
}
]
@@ -0,0 +1,124 @@
[
{
"state": "start",
"data": [
[ "comment", "// compound assignment operators" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "keyword", "#include" ],
[ "text", " " ],
[ "constant", "<iostream>" ]
]
},
{
"state": "start",
"data": [
[ "keyword.control", "using" ],
[ "text", " " ],
[ "keyword.operator", "namespace" ],
[ "text", " " ],
[ "identifier", "std" ],
[ "punctuation.operator", ";" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "storage.type", "int" ],
[ "text", " " ],
[ "entity.name.function", "main" ],
[ "text", " " ],
[ "paren.lparen", "(" ],
[ "paren.rparen", ")" ]
]
},
{
"state": "start",
"data": [
[ "paren.lparen", "{" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "storage.type", "int" ],
[ "text", " " ],
[ "identifier", "a" ],
[ "punctuation.operator", "," ],
[ "text", " " ],
[ "identifier", "b" ],
[ "keyword.operator", "=" ],
[ "constant.numeric", "3" ],
[ "punctuation.operator", ";" ],
[ "text", " " ],
[ "comment", "/*" ],
[ "comment", " foobar */" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "identifier", "a" ],
[ "text", " " ],
[ "keyword.operator", "=" ],
[ "text", " " ],
[ "identifier", "b" ],
[ "punctuation.operator", ";" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "identifier", "a" ],
[ "keyword.operator", "+" ],
[ "keyword.operator", "=" ],
[ "constant.numeric", "2" ],
[ "punctuation.operator", ";" ],
[ "text", " " ],
[ "comment", "// equivalent to a=a+2" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "identifier", "cout" ],
[ "text", " " ],
[ "keyword.operator", "<" ],
[ "keyword.operator", "<" ],
[ "text", " " ],
[ "identifier", "a" ],
[ "punctuation.operator", ";" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword.control", "return" ],
[ "text", " " ],
[ "constant.numeric", "0" ],
[ "punctuation.operator", ";" ]
]
},
{
"state": "start",
"data": [
[ "paren.rparen", "}" ]
]
}
]
@@ -0,0 +1,248 @@
[
{
"state": "start",
"data": [
[ "keyword", "(" ],
[ "support.function", "defn" ],
[ "text", " " ],
[ "identifier", "parting" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "string", "\"returns a String parting in a given language" ],
[ "string", "\"" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "(" ],
[ "keyword", "[" ],
[ "keyword", "]" ],
[ "text", " " ],
[ "keyword", "(" ],
[ "identifier", "parting" ],
[ "text", " " ],
[ "string", "\"World" ],
[ "string", "\"" ],
[ "keyword", ")" ],
[ "keyword", ")" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "(" ],
[ "keyword", "[" ],
[ "support.function", "name" ],
[ "keyword", "]" ],
[ "text", " " ],
[ "keyword", "(" ],
[ "identifier", "parting" ],
[ "text", " " ],
[ "support.function", "name" ],
[ "text", " " ],
[ "string", "\"en" ],
[ "string", "\"" ],
[ "keyword", ")" ],
[ "keyword", ")" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "(" ],
[ "keyword", "[" ],
[ "support.function", "name" ],
[ "text", " " ],
[ "identifier", "language" ],
[ "keyword", "]" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "comment", "; condp is similar to a case statement in other languages." ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "comment", "; It is described in more detail later." ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "comment", "; It is used here to take different actions based on whether the" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "comment", "; parameter \"language\" is set to \"en\", \"es\" or something else." ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "(" ],
[ "support.function", "condp" ],
[ "text", " " ],
[ "constant.language", "=" ],
[ "text", " " ],
[ "identifier", "language" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "string", "\"en" ],
[ "string", "\"" ],
[ "text", " " ],
[ "keyword", "(" ],
[ "support.function", "str" ],
[ "text", " " ],
[ "string", "\"Goodbye, " ],
[ "string", "\"" ],
[ "text", " " ],
[ "support.function", "name" ],
[ "keyword", ")" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "string", "\"es" ],
[ "string", "\"" ],
[ "text", " " ],
[ "keyword", "(" ],
[ "support.function", "str" ],
[ "text", " " ],
[ "string", "\"Adios, " ],
[ "string", "\"" ],
[ "text", " " ],
[ "support.function", "name" ],
[ "keyword", ")" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "(" ],
[ "keyword", "throw" ],
[ "text", " " ],
[ "keyword", "(" ],
[ "identifier", "IllegalArgumentException" ],
[ "text", "." ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "(" ],
[ "support.function", "str" ],
[ "text", " " ],
[ "string", "\"unsupported language " ],
[ "string", "\"" ],
[ "text", " " ],
[ "identifier", "language" ],
[ "keyword", ")" ],
[ "keyword", ")" ],
[ "keyword", ")" ],
[ "keyword", ")" ],
[ "keyword", ")" ],
[ "keyword", ")" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "keyword", "(" ],
[ "support.function", "println" ],
[ "text", " " ],
[ "keyword", "(" ],
[ "identifier", "parting" ],
[ "keyword", ")" ],
[ "keyword", ")" ],
[ "text", " " ],
[ "comment", "; -> Goodbye, World" ]
]
},
{
"state": "start",
"data": [
[ "keyword", "(" ],
[ "support.function", "println" ],
[ "text", " " ],
[ "keyword", "(" ],
[ "identifier", "parting" ],
[ "text", " " ],
[ "string", "\"Mark" ],
[ "string", "\"" ],
[ "keyword", ")" ],
[ "keyword", ")" ],
[ "text", " " ],
[ "comment", "; -> Goodbye, Mark" ]
]
},
{
"state": "start",
"data": [
[ "keyword", "(" ],
[ "support.function", "println" ],
[ "text", " " ],
[ "keyword", "(" ],
[ "identifier", "parting" ],
[ "text", " " ],
[ "string", "\"Mark" ],
[ "string", "\"" ],
[ "text", " " ],
[ "string", "\"es" ],
[ "string", "\"" ],
[ "keyword", ")" ],
[ "keyword", ")" ],
[ "text", " " ],
[ "comment", "; -> Adios, Mark" ]
]
},
{
"state": "start",
"data": [
[ "keyword", "(" ],
[ "support.function", "println" ],
[ "text", " " ],
[ "keyword", "(" ],
[ "identifier", "parting" ],
[ "text", " " ],
[ "string", "\"Mark" ],
[ "string", "\"" ],
[ "text", ", " ],
[ "string", "\"xy" ],
[ "string", "\"" ],
[ "keyword", ")" ],
[ "keyword", ")" ],
[ "text", " " ],
[ "comment", "; -> java.lang.IllegalArgumentException: unsupported language xy" ]
]
}
]
@@ -0,0 +1,188 @@
[
{
"state": "start",
"data": [
[ "comment", "#!/usr/bin/env coffee" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "keyword", "try" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "throw" ],
[ "text", " " ],
[ "language.support.class", "URIError" ],
[ "text", " " ],
[ "language.support.function", "decodeURI" ],
[ "paren.lparen", "(" ],
[ "constant.numeric", "0xC0ffee" ],
[ "text", " " ],
[ "keyword.operator", "*" ],
[ "text", " " ],
[ "constant.numeric", "123456.7e-8" ],
[ "text", " " ],
[ "keyword.operator", "/" ],
[ "text", " " ],
[ "constant.numeric", ".9" ],
[ "paren.rparen", ")" ]
]
},
{
"state": "start",
"data": [
[ "keyword", "catch" ],
[ "text", " " ],
[ "identifier", "e" ]
]
},
{
"state": "qdoc",
"data": [
[ "text", " " ],
[ "identifier", "console" ],
[ "identifier", ".log" ],
[ "text", " " ],
[ "string", "'qstring'" ],
[ "text", " " ],
[ "keyword.operator", "+" ],
[ "text", " " ],
[ "string", "\"qqstring\"" ],
[ "text", " " ],
[ "keyword.operator", "+" ],
[ "text", " " ],
[ "string", "'''" ]
]
},
{
"state": "qdoc",
"data": [
[ "string", " qdoc" ]
]
},
{
"state": "qqdoc",
"data": [
[ "string", " '''" ],
[ "text", " " ],
[ "keyword.operator", "+" ],
[ "text", " " ],
[ "string", "\"\"\"" ]
]
},
{
"state": "qqdoc",
"data": [
[ "string", " qqdoc" ]
]
},
{
"state": "start",
"data": [
[ "string", " \"\"\"" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "keyword", "do" ],
[ "text", " " ],
[ "keyword.operator", "->" ]
]
},
{
"state": "comment",
"data": [
[ "text", " " ],
[ "comment", "###" ]
]
},
{
"state": "comment",
"data": [
[ "comment", " herecomment" ]
]
},
{
"state": "start",
"data": [
[ "comment", " ###" ]
]
},
{
"state": "heregex",
"data": [
[ "text", " " ],
[ "identifier", "re" ],
[ "text", " " ],
[ "keyword.operator", "=" ],
[ "text", " " ],
[ "string.regex", "/regex/imgy" ],
[ "identifier", ".test" ],
[ "text", " " ],
[ "string.regex", "///" ]
]
},
{
"state": "heregex",
"data": [
[ "comment.regex", " " ],
[ "string.regex", "heregex" ],
[ "comment.regex", " # comment" ]
]
},
{
"state": "start",
"data": [
[ "string.regex", " ///imgy" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "this" ],
[ "text", " " ],
[ "keyword", "isnt" ],
[ "punctuation.operator", ":" ],
[ "text", " " ],
[ "string", "`just JavaScript`" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "constant.language", "undefined" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ]
]
},
{
"state": "start",
"data": [
[ "identifier", "sentence" ],
[ "text", " " ],
[ "keyword.operator", "=" ],
[ "text", " " ],
[ "string", "\"#{ 22 / 7 } is a decent approximation of π\"" ]
]
}
]
@@ -0,0 +1,41 @@
[
{
"state": "start",
"data": [
[ "comment", "<!--" ],
[ "comment", "- hello world --->" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "meta.tag", "<" ],
[ "meta.tag.tag-name", "cfset" ],
[ "text", " " ],
[ "entity.other.attribute-name", "welcome" ],
[ "keyword.operator", "=" ],
[ "string", "\"Hello World!\"" ],
[ "meta.tag", ">" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "meta.tag", "<" ],
[ "meta.tag.tag-name", "cfoutput" ],
[ "meta.tag", ">" ],
[ "text", "#welcome#" ],
[ "meta.tag", "</" ],
[ "meta.tag.tag-name", "cfoutput" ],
[ "meta.tag", ">" ]
]
}
]
@@ -0,0 +1,42 @@
[
{
"state": "start",
"data": [
[ "keyword", "public" ],
[ "text", " " ],
[ "keyword", "void" ],
[ "text", " " ],
[ "identifier", "HelloWorld" ],
[ "paren.lparen", "(" ],
[ "paren.rparen", ")" ],
[ "text", " " ],
[ "paren.lparen", "{" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "comment", "//Say Hello!" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "identifier", "Console" ],
[ "punctuation.operator", "." ],
[ "identifier", "WriteLine" ],
[ "paren.lparen", "(" ],
[ "string", "\"Hello World\"" ],
[ "paren.rparen", ")" ],
[ "punctuation.operator", ";" ]
]
},
{
"state": "start",
"data": [
[ "paren.rparen", "}" ]
]
}
]
@@ -0,0 +1,231 @@
[
{
"state": "ruleset",
"data": [
[ "variable", ".text-layer" ],
[ "text", " " ],
[ "paren.lparen", "{" ]
]
},
{
"state": "ruleset",
"data": [
[ "text", " " ],
[ "support.type", "font-family" ],
[ "text", ": Monaco, " ],
[ "string", "\"Courier New\"" ],
[ "text", ", " ],
[ "support.constant.fonts", "monospace" ],
[ "text", ";" ]
]
},
{
"state": "ruleset",
"data": [
[ "text", " " ],
[ "support.type", "font-size" ],
[ "text", ": " ],
[ "constant.numeric", "12" ],
[ "keyword", "px" ],
[ "text", ";" ]
]
},
{
"state": "ruleset",
"data": [
[ "text", " " ],
[ "support.type", "cursor" ],
[ "text", ": " ],
[ "support.constant", "text" ],
[ "text", ";" ]
]
},
{
"state": "start",
"data": [
[ "paren.rparen", "}" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "ruleset",
"data": [
[ "variable", ".blinker" ],
[ "text", " " ],
[ "paren.lparen", "{" ]
]
},
{
"state": "ruleset",
"data": [
[ "text", " " ],
[ "support.type", "animation-duration" ],
[ "text", ": " ],
[ "constant.numeric", "1" ],
[ "keyword", "s" ],
[ "text", ";" ]
]
},
{
"state": "ruleset",
"data": [
[ "text", " " ],
[ "support.type", "animation-name" ],
[ "text", ": blink;" ]
]
},
{
"state": "ruleset",
"data": [
[ "text", " " ],
[ "support.type", "animation-iteration-count" ],
[ "text", ": infinite;" ]
]
},
{
"state": "ruleset",
"data": [
[ "text", " " ],
[ "support.type", "animation-direction" ],
[ "text", ": alternate;" ]
]
},
{
"state": "ruleset",
"data": [
[ "text", " " ],
[ "support.type", "animation-timing-function" ],
[ "text", ": " ],
[ "support.constant", "linear" ],
[ "text", ";" ]
]
},
{
"state": "start",
"data": [
[ "paren.rparen", "}" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "media",
"data": [
[ "string", "@keyframes blink {" ]
]
},
{
"state": "media_ruleset",
"data": [
[ "text", " " ],
[ "constant", "0" ],
[ "text", "% " ],
[ "paren.lparen", "{" ]
]
},
{
"state": "media_ruleset",
"data": [
[ "text", " " ],
[ "support.type", "opacity" ],
[ "text", ": " ],
[ "constant.numeric", "0" ],
[ "text", ";" ]
]
},
{
"state": "media",
"data": [
[ "text", " " ],
[ "paren.rparen", "}" ]
]
},
{
"state": "media_ruleset",
"data": [
[ "text", " " ],
[ "constant", "40" ],
[ "text", "% " ],
[ "paren.lparen", "{" ]
]
},
{
"state": "media_ruleset",
"data": [
[ "text", " " ],
[ "support.type", "opacity" ],
[ "text", ": " ],
[ "constant.numeric", "0" ],
[ "text", ";" ]
]
},
{
"state": "media",
"data": [
[ "text", " " ],
[ "paren.rparen", "}" ]
]
},
{
"state": "media_ruleset",
"data": [
[ "text", " " ],
[ "constant", "40" ],
[ "variable", ".5" ],
[ "text", "% " ],
[ "paren.lparen", "{" ]
]
},
{
"state": "media_ruleset",
"data": [
[ "text", " " ],
[ "support.type", "opacity" ],
[ "text", ": " ],
[ "constant.numeric", "1" ]
]
},
{
"state": "media",
"data": [
[ "text", " " ],
[ "paren.rparen", "}" ]
]
},
{
"state": "media_ruleset",
"data": [
[ "text", " " ],
[ "constant", "100" ],
[ "text", "% " ],
[ "paren.lparen", "{" ]
]
},
{
"state": "media_ruleset",
"data": [
[ "text", " " ],
[ "support.type", "opacity" ],
[ "text", ": " ],
[ "constant.numeric", "1" ]
]
},
{
"state": "media",
"data": [
[ "text", " " ],
[ "paren.rparen", "}" ]
]
},
{
"state": "start",
"data": [
[ "string", "}" ]
]
}
]
@@ -0,0 +1,732 @@
[
{
"state": "start",
"data": [
[ "variable", "diff" ],
[ "variable", " --git" ],
[ "keyword", " a/lib/ace/edit_session.js" ],
[ "variable", " b/lib/ace/edit_session.js" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "variable", "index 23fc3fc..ed3b273 100644" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "constant.numeric", "---" ],
[ "meta.tag", " a/lib/ace/edit_session.js" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "constant.numeric", "+++" ],
[ "meta.tag", " b/lib/ace/edit_session.js" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "constant", "@@" ],
[ "constant.numeric", " -51,6 +51,7 " ],
[ "constant", "@@" ],
[ "comment.doc.tag", " var TextMode = require(\"./mode/text\").Mode;" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " var Range = require(\"./range\").Range;" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " var Document = require(\"./document\").Document;" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " var BackgroundTokenizer = require(\"./background_tokenizer\").BackgroundTokenizer;" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "support.constant", "+" ],
[ "text", "var SearchHighlight = require(\"./search_highlight\").SearchHighlight;" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " /**" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " * class EditSession" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "constant", "@@" ],
[ "constant.numeric", " -307,6 +308,13 " ],
[ "constant", "@@" ],
[ "comment.doc.tag", " var EditSession = function(text, mode) {" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " return token;" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " };" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "support.constant", "+" ],
[ "text", " this.highlight = function(re) {" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "support.constant", "+" ],
[ "text", " if (!this.$searchHighlight) {" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "support.constant", "+" ],
[ "text", " var highlight = new SearchHighlight(null, \"ace_selected-word\", \"text\");" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "support.constant", "+" ],
[ "text", " this.$searchHighlight = this.addDynamicMarker(highlight);" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "support.constant", "+" ],
[ "text", " }" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "support.constant", "+" ],
[ "text", " this.$searchHighlight.setRegexp(re);" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "support.constant", "+" ],
[ "text", " }" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " /**" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " * EditSession.setUndoManager(undoManager)" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " * - undoManager (UndoManager): The new undo manager" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "constant", "@@" ],
[ "constant.numeric", " -556,7 +564,8 " ],
[ "constant", "@@" ],
[ "comment.doc.tag", " var EditSession = function(text, mode) {" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " type : type || \"line\"," ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " renderer: typeof type == \"function\" ? type : null," ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " clazz : clazz," ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "support.function", "-" ],
[ "string", " inFront: !!inFront" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "support.constant", "+" ],
[ "text", " inFront: !!inFront," ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "support.constant", "+" ],
[ "text", " id: id" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " }" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " if (inFront) {" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "variable", "diff" ],
[ "variable", " --git" ],
[ "keyword", " a/lib/ace/editor.js" ],
[ "variable", " b/lib/ace/editor.js" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "variable", "index 834e603..b27ec73 100644" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "constant.numeric", "---" ],
[ "meta.tag", " a/lib/ace/editor.js" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "constant.numeric", "+++" ],
[ "meta.tag", " b/lib/ace/editor.js" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "constant", "@@" ],
[ "constant.numeric", " -494,7 +494,7 " ],
[ "constant", "@@" ],
[ "comment.doc.tag", " var Editor = function(renderer, session) {" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " * Emitted when a selection has changed." ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " **/" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " this.onSelectionChange = function(e) {" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "support.function", "-" ],
[ "string", " var session = this.getSession();" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "support.constant", "+" ],
[ "text", " var session = this.session;" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " if (session.$selectionMarker) {" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " session.removeMarker(session.$selectionMarker);" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "constant", "@@" ],
[ "constant.numeric", " -509,12 +509,40 " ],
[ "constant", "@@" ],
[ "comment.doc.tag", " var Editor = function(renderer, session) {" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " this.$updateHighlightActiveLine();" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " }" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "support.function", "-" ],
[ "string", " var self = this;" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "support.function", "-" ],
[ "string", " if (this.$highlightSelectedWord && !this.$wordHighlightTimer)" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "support.function", "-" ],
[ "string", " this.$wordHighlightTimer = setTimeout(function() {" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "support.function", "-" ],
[ "string", " self.session.$mode.highlightSelection(self);" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "support.function", "-" ],
[ "string", " self.$wordHighlightTimer = null;" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "support.function", "-" ],
[ "string", " }, 30, this);" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "support.constant", "+" ],
[ "text", " var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp()" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", " };" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "variable", "diff" ],
[ "variable", " --git" ],
[ "keyword", " a/lib/ace/search_highlight.js" ],
[ "variable", " b/lib/ace/search_highlight.js" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "invisible", "new file mode 100644" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "variable", "index 0000000..b2df779" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "constant.numeric", "---" ],
[ "meta.tag", " /dev/null" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "constant.numeric", "+++" ],
[ "meta.tag", " b/lib/ace/search_highlight.js" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "constant", "@@" ],
[ "constant.numeric", " -0,0 +1,3 " ],
[ "constant", "@@" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "support.constant", "+" ],
[ "text", "new" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "support.constant", "+" ],
[ "text", "empty file" ]
]
}
]
@@ -0,0 +1,185 @@
[
{
"state": "start",
"data": [
[ "keyword", "uniform" ],
[ "text", " " ],
[ "keyword", "float" ],
[ "text", " " ],
[ "identifier", "amplitude" ],
[ "punctuation.operator", ";" ]
]
},
{
"state": "start",
"data": [
[ "keyword", "attribute" ],
[ "text", " " ],
[ "keyword", "float" ],
[ "text", " " ],
[ "identifier", "displacement" ],
[ "punctuation.operator", ";" ]
]
},
{
"state": "start",
"data": [
[ "keyword", "varying" ],
[ "text", " " ],
[ "keyword", "vec3" ],
[ "text", " " ],
[ "identifier", "vNormal" ],
[ "punctuation.operator", ";" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "keyword", "void" ],
[ "text", " " ],
[ "entity.name.function", "main" ],
[ "paren.lparen", "(" ],
[ "paren.rparen", ")" ],
[ "text", " " ],
[ "paren.lparen", "{" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "identifier", "vNormal" ],
[ "text", " " ],
[ "keyword.operator", "=" ],
[ "text", " " ],
[ "identifier", "normal" ],
[ "punctuation.operator", ";" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "comment", "// multiply our displacement by the" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "comment", "// amplitude. The amp will get animated" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "comment", "// so we'll have animated displacement" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "vec3" ],
[ "text", " " ],
[ "identifier", "newPosition" ],
[ "text", " " ],
[ "keyword.operator", "=" ],
[ "text", " " ],
[ "identifier", "position" ],
[ "text", " " ],
[ "keyword.operator", "+" ],
[ "text", " " ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "identifier", "normal" ],
[ "text", " " ],
[ "keyword.operator", "*" ],
[ "text", " " ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "vec3" ],
[ "paren.lparen", "(" ],
[ "identifier", "displacement" ],
[ "text", " " ],
[ "keyword.operator", "*" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "identifier", "amplitude" ],
[ "paren.rparen", ")" ],
[ "punctuation.operator", ";" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "constant.language", "gl_Position" ],
[ "text", " " ],
[ "keyword.operator", "=" ],
[ "text", " " ],
[ "identifier", "projectionMatrix" ],
[ "text", " " ],
[ "keyword.operator", "*" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "identifier", "modelViewMatrix" ],
[ "text", " " ],
[ "keyword.operator", "*" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "vec4" ],
[ "paren.lparen", "(" ],
[ "identifier", "newPosition" ],
[ "punctuation.operator", "," ],
[ "constant.numeric", "1.0" ],
[ "paren.rparen", ")" ],
[ "punctuation.operator", ";" ]
]
},
{
"state": "start",
"data": [
[ "paren.rparen", "}" ]
]
}
]
@@ -0,0 +1,362 @@
[
{
"state": "start",
"data": [
[ "comment", "// Concurrent computation of pi." ]
]
},
{
"state": "start",
"data": [
[ "comment", "// See http://goo.gl/ZuTZM." ]
]
},
{
"state": "start",
"data": [
[ "comment", "//" ]
]
},
{
"state": "start",
"data": [
[ "comment", "// This demonstrates Go's ability to handle" ]
]
},
{
"state": "start",
"data": [
[ "comment", "// large numbers of concurrent processes." ]
]
},
{
"state": "start",
"data": [
[ "comment", "// It is an unreasonable way to calculate pi." ]
]
},
{
"state": "start",
"data": [
[ "keyword", "package" ],
[ "text", " " ],
[ "identifier", "main" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "keyword", "import" ],
[ "text", " " ],
[ "paren.lparen", "(" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "string", "\"fmt\"" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "string", "\"math\"" ]
]
},
{
"state": "start",
"data": [
[ "paren.rparen", ")" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "keyword", "func" ],
[ "text", " " ],
[ "identifier", "main" ],
[ "paren.lparen", "(" ],
[ "paren.rparen", ")" ],
[ "text", " " ],
[ "paren.lparen", "{" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "identifier", "fmt" ],
[ "punctuation.operator", "." ],
[ "identifier", "Println" ],
[ "paren.lparen", "(" ],
[ "identifier", "pi" ],
[ "paren.lparen", "(" ],
[ "constant.numeric", "5000" ],
[ "paren.rparen", ")" ],
[ "paren.rparen", ")" ]
]
},
{
"state": "start",
"data": [
[ "paren.rparen", "}" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "comment", "// pi launches n goroutines to compute an" ]
]
},
{
"state": "start",
"data": [
[ "comment", "// approximation of pi." ]
]
},
{
"state": "start",
"data": [
[ "keyword", "func" ],
[ "text", " " ],
[ "identifier", "pi" ],
[ "paren.lparen", "(" ],
[ "identifier", "n" ],
[ "text", " " ],
[ "identifier", "int" ],
[ "paren.rparen", ")" ],
[ "text", " " ],
[ "identifier", "float64" ],
[ "text", " " ],
[ "paren.lparen", "{" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "identifier", "ch" ],
[ "text", " " ],
[ "punctuation.operator", ":" ],
[ "keyword.operator", "=" ],
[ "text", " " ],
[ "identifier", "make" ],
[ "paren.lparen", "(" ],
[ "keyword", "chan" ],
[ "text", " " ],
[ "identifier", "float64" ],
[ "paren.rparen", ")" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "for" ],
[ "text", " " ],
[ "identifier", "k" ],
[ "text", " " ],
[ "punctuation.operator", ":" ],
[ "keyword.operator", "=" ],
[ "text", " " ],
[ "constant.numeric", "0" ],
[ "punctuation.operator", ";" ],
[ "text", " " ],
[ "identifier", "k" ],
[ "text", " " ],
[ "keyword.operator", "<=" ],
[ "text", " " ],
[ "identifier", "n" ],
[ "punctuation.operator", ";" ],
[ "text", " " ],
[ "identifier", "k" ],
[ "keyword.operator", "++" ],
[ "text", " " ],
[ "paren.lparen", "{" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "go" ],
[ "text", " " ],
[ "identifier", "term" ],
[ "paren.lparen", "(" ],
[ "identifier", "ch" ],
[ "punctuation.operator", "," ],
[ "text", " " ],
[ "identifier", "float64" ],
[ "paren.lparen", "(" ],
[ "identifier", "k" ],
[ "paren.rparen", ")" ],
[ "paren.rparen", ")" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "paren.rparen", "}" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "identifier", "f" ],
[ "text", " " ],
[ "punctuation.operator", ":" ],
[ "keyword.operator", "=" ],
[ "text", " " ],
[ "constant.numeric", "0.0" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "for" ],
[ "text", " " ],
[ "identifier", "k" ],
[ "text", " " ],
[ "punctuation.operator", ":" ],
[ "keyword.operator", "=" ],
[ "text", " " ],
[ "constant.numeric", "0" ],
[ "punctuation.operator", ";" ],
[ "text", " " ],
[ "identifier", "k" ],
[ "text", " " ],
[ "keyword.operator", "<=" ],
[ "text", " " ],
[ "identifier", "n" ],
[ "punctuation.operator", ";" ],
[ "text", " " ],
[ "identifier", "k" ],
[ "keyword.operator", "++" ],
[ "text", " " ],
[ "paren.lparen", "{" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "identifier", "f" ],
[ "text", " " ],
[ "keyword.operator", "+" ],
[ "keyword.operator", "=" ],
[ "text", " " ],
[ "keyword.operator", "<" ],
[ "keyword.operator", "-" ],
[ "identifier", "ch" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "paren.rparen", "}" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "return" ],
[ "text", " " ],
[ "identifier", "f" ]
]
},
{
"state": "start",
"data": [
[ "paren.rparen", "}" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "keyword", "func" ],
[ "text", " " ],
[ "identifier", "term" ],
[ "paren.lparen", "(" ],
[ "identifier", "ch" ],
[ "text", " " ],
[ "keyword", "chan" ],
[ "text", " " ],
[ "identifier", "float64" ],
[ "punctuation.operator", "," ],
[ "text", " " ],
[ "identifier", "k" ],
[ "text", " " ],
[ "identifier", "float64" ],
[ "paren.rparen", ")" ],
[ "text", " " ],
[ "paren.lparen", "{" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "identifier", "ch" ],
[ "text", " " ],
[ "keyword.operator", "<" ],
[ "keyword.operator", "-" ],
[ "text", " " ],
[ "constant.numeric", "4" ],
[ "text", " " ],
[ "keyword.operator", "*" ],
[ "text", " " ],
[ "identifier", "math" ],
[ "punctuation.operator", "." ],
[ "identifier", "Pow" ],
[ "paren.lparen", "(" ],
[ "constant.numeric", "-1" ],
[ "punctuation.operator", "," ],
[ "text", " " ],
[ "identifier", "k" ],
[ "paren.rparen", ")" ],
[ "text", " / " ],
[ "paren.lparen", "(" ],
[ "constant.numeric", "2" ],
[ "keyword.operator", "*" ],
[ "identifier", "k" ],
[ "text", " " ],
[ "keyword.operator", "+" ],
[ "text", " " ],
[ "constant.numeric", "1" ],
[ "paren.rparen", ")" ]
]
},
{
"state": "start",
"data": [
[ "paren.rparen", "}" ]
]
},
{
"state": "start",
"data": []
}
]
@@ -0,0 +1,529 @@
[
{
"state": "start",
"data": [
[ "comment", "//http://groovy.codehaus.org/Martin+Fowler%27s+closure+examples+in+Groovy" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "keyword", "class" ],
[ "text", " " ],
[ "identifier", "Employee" ],
[ "text", " " ],
[ "lparen", "{" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "def" ],
[ "text", " " ],
[ "identifier", "name" ],
[ "text", ", " ],
[ "identifier", "salary" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "boolean" ],
[ "text", " " ],
[ "identifier", "manager" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "support.function", "String" ],
[ "text", " " ],
[ "identifier", "toString" ],
[ "lparen", "(" ],
[ "rparen", ")" ],
[ "text", " " ],
[ "lparen", "{" ],
[ "text", " " ],
[ "keyword", "return" ],
[ "text", " " ],
[ "identifier", "name" ],
[ "text", " " ],
[ "rparen", "}" ]
]
},
{
"state": "start",
"data": [
[ "rparen", "}" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "keyword", "def" ],
[ "text", " " ],
[ "identifier", "emps" ],
[ "text", " " ],
[ "keyword.operator", "=" ],
[ "text", " " ],
[ "lparen", "[" ],
[ "keyword", "new" ],
[ "text", " " ],
[ "identifier", "Employee" ],
[ "lparen", "(" ],
[ "identifier", "name" ],
[ "text", ":" ],
[ "string", "'Guillaume'" ],
[ "text", ", " ],
[ "identifier", "manager" ],
[ "text", ":" ],
[ "constant.language.boolean", "true" ],
[ "text", ", " ],
[ "identifier", "salary" ],
[ "text", ":" ],
[ "constant.numeric", "200" ],
[ "rparen", ")" ],
[ "text", "," ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "new" ],
[ "text", " " ],
[ "identifier", "Employee" ],
[ "lparen", "(" ],
[ "identifier", "name" ],
[ "text", ":" ],
[ "string", "'Graeme'" ],
[ "text", ", " ],
[ "identifier", "manager" ],
[ "text", ":" ],
[ "constant.language.boolean", "true" ],
[ "text", ", " ],
[ "identifier", "salary" ],
[ "text", ":" ],
[ "constant.numeric", "200" ],
[ "rparen", ")" ],
[ "text", "," ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "new" ],
[ "text", " " ],
[ "identifier", "Employee" ],
[ "lparen", "(" ],
[ "identifier", "name" ],
[ "text", ":" ],
[ "string", "'Dierk'" ],
[ "text", ", " ],
[ "identifier", "manager" ],
[ "text", ":" ],
[ "constant.language.boolean", "false" ],
[ "text", ", " ],
[ "identifier", "salary" ],
[ "text", ":" ],
[ "constant.numeric", "151" ],
[ "rparen", ")" ],
[ "text", "," ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "new" ],
[ "text", " " ],
[ "identifier", "Employee" ],
[ "lparen", "(" ],
[ "identifier", "name" ],
[ "text", ":" ],
[ "string", "'Bernd'" ],
[ "text", ", " ],
[ "identifier", "manager" ],
[ "text", ":" ],
[ "constant.language.boolean", "false" ],
[ "text", ", " ],
[ "identifier", "salary" ],
[ "text", ":" ],
[ "constant.numeric", "50" ],
[ "rparen", ")" ],
[ "rparen", "]" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "keyword", "def" ],
[ "text", " " ],
[ "identifier", "managers" ],
[ "lparen", "(" ],
[ "identifier", "emps" ],
[ "rparen", ")" ],
[ "text", " " ],
[ "lparen", "{" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "identifier", "emps" ],
[ "text", "." ],
[ "identifier", "findAll" ],
[ "text", " " ],
[ "lparen", "{" ],
[ "text", " " ],
[ "identifier", "e" ],
[ "text", " " ],
[ "keyword.operator", "-" ],
[ "keyword.operator", ">" ],
[ "text", " " ],
[ "identifier", "e" ],
[ "text", "." ],
[ "identifier", "isManager" ],
[ "lparen", "(" ],
[ "rparen", ")" ],
[ "text", " " ],
[ "rparen", "}" ]
]
},
{
"state": "start",
"data": [
[ "rparen", "}" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "keyword", "assert" ],
[ "text", " " ],
[ "identifier", "emps" ],
[ "lparen", "[" ],
[ "constant.numeric", "0" ],
[ "text", ".." ],
[ "constant.numeric", "1" ],
[ "rparen", "]" ],
[ "text", " " ],
[ "keyword.operator", "==" ],
[ "text", " " ],
[ "identifier", "managers" ],
[ "lparen", "(" ],
[ "identifier", "emps" ],
[ "rparen", ")" ],
[ "text", " " ],
[ "comment", "// [Guillaume, Graeme]" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "keyword", "def" ],
[ "text", " " ],
[ "identifier", "highPaid" ],
[ "lparen", "(" ],
[ "identifier", "emps" ],
[ "rparen", ")" ],
[ "text", " " ],
[ "lparen", "{" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "identifier", "threshold" ],
[ "text", " " ],
[ "keyword.operator", "=" ],
[ "text", " " ],
[ "constant.numeric", "150" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "identifier", "emps" ],
[ "text", "." ],
[ "identifier", "findAll" ],
[ "text", " " ],
[ "lparen", "{" ],
[ "text", " " ],
[ "identifier", "e" ],
[ "text", " " ],
[ "keyword.operator", "-" ],
[ "keyword.operator", ">" ],
[ "text", " " ],
[ "identifier", "e" ],
[ "text", "." ],
[ "identifier", "salary" ],
[ "text", " " ],
[ "keyword.operator", ">" ],
[ "text", " " ],
[ "identifier", "threshold" ],
[ "text", " " ],
[ "rparen", "}" ]
]
},
{
"state": "start",
"data": [
[ "rparen", "}" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "keyword", "assert" ],
[ "text", " " ],
[ "identifier", "emps" ],
[ "lparen", "[" ],
[ "constant.numeric", "0" ],
[ "text", ".." ],
[ "constant.numeric", "2" ],
[ "rparen", "]" ],
[ "text", " " ],
[ "keyword.operator", "==" ],
[ "text", " " ],
[ "identifier", "highPaid" ],
[ "lparen", "(" ],
[ "identifier", "emps" ],
[ "rparen", ")" ],
[ "text", " " ],
[ "comment", "// [Guillaume, Graeme, Dierk]" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "keyword", "def" ],
[ "text", " " ],
[ "identifier", "paidMore" ],
[ "lparen", "(" ],
[ "identifier", "amount" ],
[ "rparen", ")" ],
[ "text", " " ],
[ "lparen", "{" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "lparen", "{" ],
[ "text", " " ],
[ "identifier", "e" ],
[ "text", " " ],
[ "keyword.operator", "-" ],
[ "keyword.operator", ">" ],
[ "text", " " ],
[ "identifier", "e" ],
[ "text", "." ],
[ "identifier", "salary" ],
[ "text", " " ],
[ "keyword.operator", ">" ],
[ "text", " " ],
[ "identifier", "amount" ],
[ "rparen", "}" ]
]
},
{
"state": "start",
"data": [
[ "rparen", "}" ]
]
},
{
"state": "start",
"data": [
[ "keyword", "def" ],
[ "text", " " ],
[ "identifier", "highPaid" ],
[ "text", " " ],
[ "keyword.operator", "=" ],
[ "text", " " ],
[ "identifier", "paidMore" ],
[ "lparen", "(" ],
[ "constant.numeric", "150" ],
[ "rparen", ")" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "keyword", "assert" ],
[ "text", " " ],
[ "identifier", "highPaid" ],
[ "lparen", "(" ],
[ "identifier", "emps" ],
[ "lparen", "[" ],
[ "constant.numeric", "0" ],
[ "rparen", "]" ],
[ "rparen", ")" ],
[ "text", " " ],
[ "comment", "// true" ]
]
},
{
"state": "start",
"data": [
[ "keyword", "assert" ],
[ "text", " " ],
[ "identifier", "emps" ],
[ "lparen", "[" ],
[ "constant.numeric", "0" ],
[ "text", ".." ],
[ "constant.numeric", "2" ],
[ "rparen", "]" ],
[ "text", " " ],
[ "keyword.operator", "==" ],
[ "text", " " ],
[ "identifier", "emps" ],
[ "text", "." ],
[ "identifier", "findAll" ],
[ "lparen", "(" ],
[ "identifier", "highPaid" ],
[ "rparen", ")" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "keyword", "def" ],
[ "text", " " ],
[ "identifier", "filename" ],
[ "text", " " ],
[ "keyword.operator", "=" ],
[ "text", " " ],
[ "string", "'test.txt'" ]
]
},
{
"state": "start",
"data": [
[ "keyword", "new" ],
[ "text", " " ],
[ "identifier", "File" ],
[ "lparen", "(" ],
[ "identifier", "filename" ],
[ "rparen", ")" ],
[ "text", "." ],
[ "identifier", "withReader" ],
[ "lparen", "{" ],
[ "text", " " ],
[ "identifier", "reader" ],
[ "text", " " ],
[ "keyword.operator", "-" ],
[ "keyword.operator", ">" ],
[ "text", " " ],
[ "identifier", "doSomethingWith" ],
[ "lparen", "(" ],
[ "identifier", "reader" ],
[ "rparen", ")" ],
[ "text", " " ],
[ "rparen", "}" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "keyword", "def" ],
[ "text", " " ],
[ "identifier", "readersText" ]
]
},
{
"state": "start",
"data": [
[ "keyword", "def" ],
[ "text", " " ],
[ "identifier", "doSomethingWith" ],
[ "lparen", "(" ],
[ "identifier", "reader" ],
[ "rparen", ")" ],
[ "text", " " ],
[ "lparen", "{" ],
[ "text", " " ],
[ "identifier", "readersText" ],
[ "text", " " ],
[ "keyword.operator", "=" ],
[ "text", " " ],
[ "identifier", "reader" ],
[ "text", "." ],
[ "identifier", "text" ],
[ "text", " " ],
[ "rparen", "}" ]
]
},
{
"state": "start",
"data": []
},
{
"state": "start",
"data": [
[ "keyword", "assert" ],
[ "text", " " ],
[ "keyword", "new" ],
[ "text", " " ],
[ "identifier", "File" ],
[ "lparen", "(" ],
[ "identifier", "filename" ],
[ "rparen", ")" ],
[ "text", "." ],
[ "identifier", "text" ],
[ "text", " " ],
[ "keyword.operator", "==" ],
[ "text", " " ],
[ "identifier", "readersText" ]
]
}
]
@@ -0,0 +1,195 @@
[
{
"state": "start",
"data": [
[ "keyword", "class" ],
[ "text", " " ],
[ "identifier", "Haxe" ],
[ "text", " " ]
]
},
{
"state": "start",
"data": [
[ "paren.lparen", "{" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "public" ],
[ "text", " " ],
[ "keyword", "static" ],
[ "text", " " ],
[ "keyword", "function" ],
[ "text", " " ],
[ "identifier", "main" ],
[ "paren.lparen", "(" ],
[ "paren.rparen", ")" ],
[ "text", " " ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "paren.lparen", "{" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "comment", "// Say Hello!" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "var" ],
[ "text", " " ],
[ "identifier", "greeting" ],
[ "punctuation.operator", ":" ],
[ "keyword", "String" ],
[ "text", " " ],
[ "keyword.operator", "=" ],
[ "text", " " ],
[ "string", "\"Hello World\"" ],
[ "punctuation.operator", ";" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "trace" ],
[ "paren.lparen", "(" ],
[ "identifier", "greeting" ],
[ "paren.rparen", ")" ],
[ "punctuation.operator", ";" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "var" ],
[ "text", " " ],
[ "identifier", "targets" ],
[ "punctuation.operator", ":" ],
[ "keyword", "Array" ],
[ "keyword.operator", "<" ],
[ "keyword", "String" ],
[ "keyword.operator", ">" ],
[ "text", " " ],
[ "keyword.operator", "=" ],
[ "text", " " ],
[ "paren.lparen", "[" ],
[ "string", "\"Flash\"" ],
[ "punctuation.operator", "," ],
[ "string", "\"Javascript\"" ],
[ "punctuation.operator", "," ],
[ "string", "\"PHP\"" ],
[ "punctuation.operator", "," ],
[ "string", "\"Neko\"" ],
[ "punctuation.operator", "," ],
[ "string", "\"C++\"" ],
[ "punctuation.operator", "," ],
[ "string", "\"iOS\"" ],
[ "punctuation.operator", "," ],
[ "string", "\"Android\"" ],
[ "punctuation.operator", "," ],
[ "string", "\"webOS\"" ],
[ "paren.rparen", "]" ],
[ "punctuation.operator", ";" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "trace" ],
[ "paren.lparen", "(" ],
[ "string", "\"Haxe is a great language that can target:\"" ],
[ "paren.rparen", ")" ],
[ "punctuation.operator", ";" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "for" ],
[ "text", " " ],
[ "paren.lparen", "(" ],
[ "identifier", "target" ],
[ "text", " " ],
[ "keyword", "in" ],
[ "text", " " ],
[ "identifier", "targets" ],
[ "paren.rparen", ")" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "paren.lparen", "{" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "trace" ],
[ "text", " " ],
[ "paren.lparen", "(" ],
[ "string", "\" - \"" ],
[ "text", " " ],
[ "keyword.operator", "+" ],
[ "text", " " ],
[ "identifier", "target" ],
[ "paren.rparen", ")" ],
[ "punctuation.operator", ";" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "paren.rparen", "}" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "keyword", "trace" ],
[ "paren.lparen", "(" ],
[ "string", "\"And many more!\"" ],
[ "paren.rparen", ")" ],
[ "punctuation.operator", ";" ]
]
},
{
"state": "start",
"data": [
[ "text", " " ],
[ "paren.rparen", "}" ]
]
},
{
"state": "start",
"data": [
[ "paren.rparen", "}" ]
]
}
]

Some files were not shown because too many files have changed in this diff Show More