Compare commits

..

1 commit

Author SHA1 Message Date
nightwing
902006e110 do not allow editor to scroll up automatically 2013-11-24 14:35:38 +04:00
616 changed files with 61291 additions and 152108 deletions

1
.gitignore vendored
View file

@ -2,7 +2,6 @@
.DS_Store .DS_Store
*.swp *.swp
*.tmp *.tmp
*~
# Project files that should not be in the repo # Project files that should not be in the repo
.* .*

4
.gitmodules vendored
View file

@ -1,6 +1,6 @@
[submodule "doc/wiki"] [submodule "doc/wiki"]
path = doc/wiki path = doc/wiki
url = https://github.com/ajaxorg/ace.wiki.git url = git://github.com/ajaxorg/ace.wiki.git
[submodule "build"] [submodule "build"]
path = build path = build
url = https://github.com/ajaxorg/ace-builds.git url = git://github.com/ajaxorg/ace-builds.git

View file

@ -7,9 +7,16 @@ Feel free to fork and improve/enhance Ace any way you want. If you feel that the
There are two versions of the agreement: There are two versions of the agreement:
1. [The Individual CLA](https://docs.google.com/a/c9.io/forms/d/1MfmfrxqD_PNlNsuK0lC2KSelRLxGLGfh_wEcG0ijVvo/viewform): use this version if you're working on the Cloud9 SDK or open source projects in your spare time, or can clearly claim ownership of copyright in what you'll be submitting. 1. [The Individual CLA](https://github.com/ajaxorg/ace/raw/master/doc/Contributor_License_Agreement-v2.pdf): use this version if you're working on an ajax.org in your spare time, or can clearly claim ownership of copyright in what you'll be submitting.
2. [The Corporate CLA](https://docs.google.com/a/c9.io/forms/d/1vFejn4111GdnCNuQ6BfnJDaxdsUEMD4KCo1ayovAfu0/viewform): have your corporate lawyer review and submit this if your company is going to be contributing to the Cloud9 SDK and/or open source projects. 2. [The Corporate CLA](https://github.com/ajaxorg/ace/raw/master/doc/Corporate_Contributor_License_Agreement-v2.pdf): have your corporate lawyer review and submit this if your company is going to be contributing to ajax.org projects
If you want to contribute to the Cloud9 SDK and/or open source projects please go to the online form, fill it out and submit it. If you want to contribute to an ajax.org project please print the CLA and fill it out and sign it. Then either send it by snail mail or fax to us or send it back scanned (or as a photo) by email.
Happy coding, Cloud9 Email: ace+cla@c9.io
Fax: +31 (0) 206388953
Address: Ajax.org B.V.
Keizersgracht 241
1016 EA, Amsterdam
the Netherlands

View file

@ -1,80 +1,4 @@
Version 1.2.0-pre
* New Features
- Indented soft wrap (danyaPostfactum)
* API Changes
- unified delta types `{start, end, action, lines}` (Alden Daniels https://github.com/ajaxorg/ace/pull/1745)
- "change" event listeners on session and editor get delta objects directly
2015.04.03 Version 1.1.9
- Small Enhancements and Bugfixes
2014.11.08 Version 1.1.8
* API Changes
- `editor.commands.commandKeyBinding` now contains direct map from keys to commands instead of grouping them by hashid
* New Features
- Improved autoindent for html and php modes (Adam Jimenez)
- Find All from searchbox (Colton Voege)
* new language modes
- Elixir, Elm
2014.09.21 Version 1.1.7
* Bugfixes
- fix several bugs in autocompletion
- workaround for inaccurate getBoundingClientRect on chrome 37
2014.08.17 Version 1.1.6
* Bugfixes
- fix regression in double tap to highlight
- Improved Latex Mode (Daniel Felder)
* API Changes
- editor.destroy destroys editor.session too (call editor.setSession(null) to prevent that)
* new language modes
- Praat (José Joaquín Atria)
- Eiffel (Victorien Elvinger)
- G-code (Adam Joseph Cook)
2014.07.09 Version 1.1.5
* Bugfixes
- fix regression in autocomplete popup
* new language modes
- gitignore (Devon Carew)
2014.07.01 Version 1.1.4
* New Features
- Highlight matching tags (Adam Jimenez)
- Improved jump to matching command (Adam Jimenez)
* new language modes
- AppleScript (Yaogang Lian)
- Vala
2014.03.08 Version 1.1.3
* New Features
- Allow syntax checkers to be loaded from CDN (Derk-Jan Hartman)
- Add ColdFusion behavior (Abram Adams)
- add showLineNumbers option
- Add html syntax checker (danyaPostfactum)
* new language modes
- Gherkin (Patrick Nevels)
- Smarty
2013.12.02 Version 1.1.2
* New Features * New Features
- Accessibility Theme for Ace (Peter Xiao) - Accessibility Theme for Ace (Peter Xiao)
- use snipetManager for expanding emmet snippets - use snipetManager for expanding emmet snippets
@ -86,6 +10,7 @@ Version 1.2.0-pre
- add support for autocompletion and snippets (gjtorikyan danyaPostfactum and others) - add support for autocompletion and snippets (gjtorikyan danyaPostfactum and others)
- add option to merge similar changes in undo history - add option to merge similar changes in undo history
- add scrollPastEnd option - add scrollPastEnd option
- 6a87d97 Merge pull request #1494 from danyaPostfactum/snippetcompleter
- use html5 dragndrop for text dragging (danyaPostfactum) - use html5 dragndrop for text dragging (danyaPostfactum)
* API Changes * API Changes
@ -96,8 +21,9 @@ Version 1.2.0-pre
- Protobuf (Zef Hemel) - Protobuf (Zef Hemel)
- Soy - Soy
- Handlebars - Handlebars
-
2013.06.04 Version 1.1.1 2013.06.04 Version 1.1.01
- Improved emacs keybindings (Robert Krahn) - Improved emacs keybindings (Robert Krahn)
- Added markClean, isClean methods to UndoManager (Joonsoo Jeon) - Added markClean, isClean methods to UndoManager (Joonsoo Jeon)

View file

@ -13,6 +13,7 @@ pre_build:
build: pre_build build: pre_build
./Makefile.dryice.js normal ./Makefile.dryice.js normal
./Makefile.dryice.js demo ./Makefile.dryice.js demo
./Makefile.dryice.js bm
# Minimal build: call Makefile.dryice.js only if our sources changed # Minimal build: call Makefile.dryice.js only if our sources changed
basic: build/src/ace.js basic: build/src/ace.js

File diff suppressed because it is too large Load diff

View file

@ -8,7 +8,7 @@ Ace is a standalone code editor written in JavaScript. Our goal is to create a b
Features Features
-------- --------
* Syntax highlighting for over 110 languages (TextMate/Sublime/_.tmlanguage_ files can be imported) * Syntax highlighting for over 40 languages (TextMate/Sublime/_.tmlanguage_ files can be imported)
* Over 20 themes (TextMate/Sublime/_.tmtheme_ files can be imported) * Over 20 themes (TextMate/Sublime/_.tmtheme_ files can be imported)
* Automatic indent and outdent * Automatic indent and outdent
* An optional command line * An optional command line
@ -30,7 +30,7 @@ Take Ace for a spin!
Check out the Ace live [demo](http://ace.c9.io/build/kitchen-sink.html) or get a [Cloud9 IDE account](https://c9.io/) to experience Ace while editing one of your own GitHub projects. Check out the Ace live [demo](http://ace.c9.io/build/kitchen-sink.html) or get a [Cloud9 IDE account](https://c9.io/) to experience Ace while editing one of your own GitHub projects.
If you want, you can use Ace as a textarea replacement thanks to the [Ace Bookmarklet](http://ajaxorg.github.io/ace/build/demo/bookmarklet/index.html). If you want, you can use Ace as a textarea replacement thanks to the [Ace Bookmarklet](http://ajaxorg.github.io/ace/build/textarea/editor.html).
Embedding Ace Embedding Ace
------------- -------------
@ -79,7 +79,7 @@ By default the editor only supports plain text mode; many other languages are av
The mode can then be used like this: The mode can then be used like this:
```javascript ```javascript
var JavaScriptMode = ace.require("ace/mode/javascript").Mode; var JavaScriptMode = require("ace/mode/javascript").Mode;
editor.getSession().setMode(new JavaScriptMode()); editor.getSession().setMode(new JavaScriptMode());
``` ```

View file

@ -390,8 +390,8 @@
</div> </div>
<div class="description"><p>Creates a new <code>Editor</code> object.</p> <div class="description"><p>Creates a new <code>Editor</code> object.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">renderer</td><td class="argType"><a href="virtual_renderer.html" class="" title="VirtualRenderer (class)" data-id="VirtualRenderer">VirtualRenderer</a></td><td class="argDescription "><p>Required. Associated <code>VirtualRenderer</code> that draws everything</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">renderer</td><td class="argType" "><a href="virtual_renderer.html" class="" title="VirtualRenderer (class)" data-id="VirtualRenderer">VirtualRenderer</a></td><td class="argDescription "><p>Required. Associated <code>VirtualRenderer</code> that draws everything</p>
</td></tr><tr class="argumentRow "><td class="argName ">session</td><td class="argType"><a href="edit_session.html" class="" title="EditSession (class)" data-id="EditSession">EditSession</a></td><td class="argDescription "><p>Required. The <code>EditSession</code> to refer to</p> </td></tr><tr class="argumentRow "><td class="argName ">session</td><td class="argType" "><a href="edit_session.html" class="" title="EditSession (class)" data-id="EditSession">EditSession</a></td><td class="argDescription "><p>Required. The <code>EditSession</code> to refer to</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -444,7 +444,7 @@
</div> </div>
<div class="description"><p>Emitted whenever the document is changed.</p> <div class="description"><p>Emitted whenever the document is changed.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">e</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. Contains a single property, <code>data</code>, which has the delta of changes</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">e</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. Contains a single property, <code>data</code>, which has the delta of changes</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -471,7 +471,7 @@
</div> </div>
<div class="description"><p>Emitted when the selection style changes, via <a href="#Editor.setSelectionStyle" class="link-short" title="Editor.setSelectionStyle (class method)" data-id="Editor.setSelectionStyle"><code>Editor.setSelectionStyle()</code></a>.</p> <div class="description"><p>Emitted when the selection style changes, via <a href="#Editor.setSelectionStyle" class="link-short" title="Editor.setSelectionStyle (class method)" data-id="Editor.setSelectionStyle"><code>Editor.setSelectionStyle()</code></a>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">data</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. Contains one property, <code>data</code>, which indicates the new selection style</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">data</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. Contains one property, <code>data</code>, which indicates the new selection style</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -498,7 +498,7 @@
</div> </div>
<div class="description"><p>Emitted whenever the <a href="edit_session.html" class="link-short" title="EditSession (class)" data-id="EditSession"><code>EditSession</code></a> changes.</p> <div class="description"><p>Emitted whenever the <a href="edit_session.html" class="link-short" title="EditSession (class)" data-id="EditSession"><code>EditSession</code></a> changes.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">e</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. An object with two properties, <code>oldSession</code> and <code>session</code>, that represent the old and new <a href="edit_session.html" class="link-short" title="EditSession (class)" data-id="EditSession"><code>EditSession</code></a>s.</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">e</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. An object with two properties, <code>oldSession</code> and <code>session</code>, that represent the old and new <a href="edit_session.html" class="link-short" title="EditSession (class)" data-id="EditSession"><code>EditSession</code></a>s.</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -525,7 +525,7 @@
</div> </div>
<div class="description"><p>Emitted when text is copied.</p> <div class="description"><p>Emitted when text is copied.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">text</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The copied text</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">text</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The copied text</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -564,7 +564,7 @@
<ul class="signatures"> <ul class="signatures">
<li class="signature"> <li class="signature">
<ul> <ul>
<li class="signature-call"><span class="eventObjName">Editor</span><span class="eventListenerStart">.on("</span><span id="Editor.event.paste" class="member-name eventMember methodClicker">paste</span><span class="eventListenerClose">", </span><span class="eventFunctionOpen">function(</span><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="argument methodClicker" title="Object" data-id="Object">Object</a> e<span class="eventFunctionClose">))</span></li> <li class="signature-call"><span class="eventObjName">Editor</span><span class="eventListenerStart">.on("</span><span id="Editor.event.paste" class="member-name eventMember methodClicker">paste</span><span class="eventListenerClose">", </span><span class="eventFunctionOpen">function(</span><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="argument methodClicker" title="String" data-id="String">String</a> text<span class="eventFunctionClose">))</span></li>
</ul> </ul>
<ul class="metaInfo"> <ul class="metaInfo">
</ul> </ul>
@ -577,7 +577,7 @@
</div> </div>
<div class="description"><p>Emitted when text is pasted.</p> <div class="description"><p>Emitted when text is pasted.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">e</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. An object which contains one property, <code>text</code>, that represents the text to be pasted. Editing this property will alter the text that is pasted.</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">text</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The pasted text</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -610,7 +610,7 @@
</div> </div>
<div class="description"><p>Adds the selection and cursor.</p> <div class="description"><p>Adds the selection and cursor.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">orientedRange</td><td class="argType"><a href="range.html" class="" title="Range (class)" data-id="Range">Range</a></td><td class="argDescription "><p>Required. A range containing a cursor</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">orientedRange</td><td class="argType" "><a href="range.html" class="" title="Range (class)" data-id="Range">Range</a></td><td class="argDescription "><p>Required. A range containing a cursor</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -920,9 +920,9 @@
</div> </div>
<div class="description"><p>Attempts to find <code>needle</code> within the document. For more information on <code>options</code>, see <a href="search.html" class="link-short" title="Search (class)" data-id="Search"><code>Search</code></a>.</p> <div class="description"><p>Attempts to find <code>needle</code> within the document. For more information on <code>options</code>, see <a href="search.html" class="link-short" title="Search (class)" data-id="Search"><code>Search</code></a>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">needle</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The text to search for (optional)</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">needle</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The text to search for (optional)</p>
</td></tr><tr class="argumentRow "><td class="argName ">options</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. An object defining various search properties</p> </td></tr><tr class="argumentRow "><td class="argName ">options</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. An object defining various search properties</p>
</td></tr><tr class="argumentRow "><td class="argName ">animate</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code> animate scrolling</p> </td></tr><tr class="argumentRow "><td class="argName ">animate</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code> animate scrolling</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -954,9 +954,9 @@
</div> </div>
<div class="description"><p>Finds and selects all the occurences of <code>needle</code>.</p> <div class="description"><p>Finds and selects all the occurences of <code>needle</code>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">The</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. text to find</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">The</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. text to find</p>
</td></tr><tr class="argumentRow "><td class="argName ">The</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. search options</p> </td></tr><tr class="argumentRow "><td class="argName ">The</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. search options</p>
</td></tr><tr class="argumentRow "><td class="argName ">keeps</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. </p> </td></tr><tr class="argumentRow "><td class="argName ">keeps</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. </p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -983,8 +983,8 @@
</div> </div>
<div class="description"><p>Performs another search for <code>needle</code> in the document. For more information on <code>options</code>, see <a href="search.html" class="link-short" title="Search (class)" data-id="Search"><code>Search</code></a>.</p> <div class="description"><p>Performs another search for <code>needle</code> in the document. For more information on <code>options</code>, see <a href="search.html" class="link-short" title="Search (class)" data-id="Search"><code>Search</code></a>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">options</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. search options</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">options</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. search options</p>
</td></tr><tr class="argumentRow "><td class="argName ">animate</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code> animate scrolling</p> </td></tr><tr class="argumentRow "><td class="argName ">animate</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code> animate scrolling</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -1011,8 +1011,8 @@
</div> </div>
<div class="description"><p>Performs a search for <code>needle</code> backwards. For more information on <code>options</code>, see <a href="search.html" class="link-short" title="Search (class)" data-id="Search"><code>Search</code></a>.</p> <div class="description"><p>Performs a search for <code>needle</code> backwards. For more information on <code>options</code>, see <a href="search.html" class="link-short" title="Search (class)" data-id="Search"><code>Search</code></a>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">options</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. search options</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">options</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. search options</p>
</td></tr><tr class="argumentRow "><td class="argName ">animate</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code> animate scrolling</p> </td></tr><tr class="argumentRow "><td class="argName ">animate</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code> animate scrolling</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -1064,8 +1064,8 @@
</div> </div>
<div class="description"><p>Executes a command for each selection range.</p> <div class="description"><p>Executes a command for each selection range.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">cmd</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The command to execute</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">cmd</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The command to execute</p>
</td></tr><tr class="argumentRow "><td class="argName ">args</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. Any arguments for the command</p> </td></tr><tr class="argumentRow "><td class="argName ">args</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. Any arguments for the command</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -1523,8 +1523,8 @@
</div> </div>
<div class="description"><p>Works like <a href="#nav=api&api=edit_session" class="link-short" title="EditSession.getTokenAt (class method)" data-id="EditSession.getTokenAt"><code>EditSession.getTokenAt()</code></a>, except it returns a number.</p> <div class="description"><p>Works like <a href="#nav=api&api=edit_session" class="link-short" title="EditSession.getTokenAt (class method)" data-id="EditSession.getTokenAt"><code>EditSession.getTokenAt()</code></a>, except it returns a number.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. </p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. </p>
</td></tr><tr class="argumentRow "><td class="argName ">column</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. </p> </td></tr><tr class="argumentRow "><td class="argName ">column</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. </p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -1966,9 +1966,9 @@
</div> </div>
<div class="description"><p>Moves the cursor to the specified line number, and also into the indiciated column.</p> <div class="description"><p>Moves the cursor to the specified line number, and also into the indiciated column.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">lineNumber</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The line number to go to</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">lineNumber</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The line number to go to</p>
</td></tr><tr class="argumentRow "><td class="argName ">column</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. A column number to go to</p> </td></tr><tr class="argumentRow "><td class="argName ">column</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. A column number to go to</p>
</td></tr><tr class="argumentRow "><td class="argName ">animate</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code> animates scolling</p> </td></tr><tr class="argumentRow "><td class="argName ">animate</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code> animates scolling</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -2070,7 +2070,7 @@
</div> </div>
<div class="description"><p>Inserts <code>text</code> into wherever the cursor is pointing.</p> <div class="description"><p>Inserts <code>text</code> into wherever the cursor is pointing.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">text</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The new text to add</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">text</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The new text to add</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -2132,7 +2132,7 @@
</div> </div>
<div class="description"><p>Indicates if the entire row is currently visible on the screen.</p> <div class="description"><p>Indicates if the entire row is currently visible on the screen.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The row to check</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The row to check</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -2164,7 +2164,7 @@
</div> </div>
<div class="description"><p>Indicates if the row is currently visible on the screen.</p> <div class="description"><p>Indicates if the row is currently visible on the screen.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The row to check</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The row to check</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -2191,7 +2191,7 @@
</div> </div>
<div class="description"><p>Moves the cursor&#39;s row and column to the next matching bracket.</p> <div class="description"><p>Moves the cursor&#39;s row and column to the next matching bracket.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">select</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. </p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">select</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. </p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -2218,7 +2218,7 @@
</div> </div>
<div class="description"><p>If the character before the cursor is a number, this functions changes its value by <code>amount</code>.</p> <div class="description"><p>If the character before the cursor is a number, this functions changes its value by <code>amount</code>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">amount</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The value to change the numeral by (can be negative to decrease value)</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">amount</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The value to change the numeral by (can be negative to decrease value)</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -2245,8 +2245,8 @@
</div> </div>
<div class="description"><p>Moves the cursor to the specified row and column. Note that this does not de-select the current selection.</p> <div class="description"><p>Moves the cursor to the specified row and column. Note that this does not de-select the current selection.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The new row number</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The new row number</p>
</td></tr><tr class="argumentRow "><td class="argName ">column</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The new column number</p> </td></tr><tr class="argumentRow "><td class="argName ">column</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The new column number</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -2273,7 +2273,7 @@
</div> </div>
<div class="description"><p>Moves the cursor to the position indicated by <code>pos.row</code> and <code>pos.column</code>.</p> <div class="description"><p>Moves the cursor to the position indicated by <code>pos.row</code> and <code>pos.column</code>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">pos</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. An object with two properties, row and column</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">pos</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. An object with two properties, row and column</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -2384,7 +2384,7 @@
</div> </div>
<div class="description"><p>Moves the cursor down in the document the specified number of times. Note that this does de-select the current selection.</p> <div class="description"><p>Moves the cursor down in the document the specified number of times. Note that this does de-select the current selection.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">times</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The number of times to change navigation</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">times</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The number of times to change navigation</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -2461,7 +2461,7 @@
</div> </div>
<div class="description"><p>Moves the cursor left in the document the specified number of times. Note that this does de-select the current selection.</p> <div class="description"><p>Moves the cursor left in the document the specified number of times. Note that this does de-select the current selection.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">times</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The number of times to change navigation</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">times</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The number of times to change navigation</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -2538,7 +2538,7 @@
</div> </div>
<div class="description"><p>Moves the cursor right in the document the specified number of times. Note that this does de-select the current selection.</p> <div class="description"><p>Moves the cursor right in the document the specified number of times. Note that this does de-select the current selection.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">times</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The number of times to change navigation</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">times</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The number of times to change navigation</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -2565,8 +2565,8 @@
</div> </div>
<div class="description"><p>Moves the cursor to the specified row and column. Note that this does de-select the current selection.</p> <div class="description"><p>Moves the cursor to the specified row and column. Note that this does de-select the current selection.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The new row number</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The new row number</p>
</td></tr><tr class="argumentRow "><td class="argName ">column</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The new column number</p> </td></tr><tr class="argumentRow "><td class="argName ">column</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The new column number</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -2593,7 +2593,7 @@
</div> </div>
<div class="description"><p>Moves the cursor up in the document the specified number of times. Note that this does de-select the current selection.</p> <div class="description"><p>Moves the cursor up in the document the specified number of times. Note that this does de-select the current selection.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">times</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The number of times to change navigation</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">times</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The number of times to change navigation</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -3105,7 +3105,7 @@
</div> </div>
<div class="description"><p>Called whenever a text &quot;paste&quot; happens.</p> <div class="description"><p>Called whenever a text &quot;paste&quot; happens.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">text</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The pasted text</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">text</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The pasted text</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -3277,7 +3277,7 @@
</div> </div>
<div class="description"><p>Removes words of text from the editor. A &quot;word&quot; is defined as a string of characters bookended by whitespace.</p> <div class="description"><p>Removes words of text from the editor. A &quot;word&quot; is defined as a string of characters bookended by whitespace.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">dir</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The direction of the deletion to occur, either &quot;left&quot; or &quot;right&quot;</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">dir</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The direction of the deletion to occur, either &quot;left&quot; or &quot;right&quot;</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -3329,7 +3329,7 @@
</div> </div>
<div class="description"><p>Removes the selection marker.</p> <div class="description"><p>Removes the selection marker.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">The</td><td class="argType"><a href="range.html" class="" title="Range (class)" data-id="Range">Range</a></td><td class="argDescription "><p>Required. selection range added with <a href="#nav=api&api=multi_select" class="link-short" title="Editor.addSelectionMarker (class method)" data-id="Editor.addSelectionMarker"><code>addSelectionMarker()</code></a>.</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">The</td><td class="argType" "><a href="range.html" class="" title="Range (class)" data-id="Range">Range</a></td><td class="argDescription "><p>Required. selection range added with <a href="#nav=api&api=multi_select" class="link-short" title="Editor.addSelectionMarker (class method)" data-id="Editor.addSelectionMarker"><code>addSelectionMarker()</code></a>.</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -3456,8 +3456,8 @@
</div> </div>
<div class="description"><p>Replaces the first occurance of <code>options.needle</code> with the value in <code>replacement</code>.</p> <div class="description"><p>Replaces the first occurance of <code>options.needle</code> with the value in <code>replacement</code>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">replacement</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The text to replace with</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">replacement</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The text to replace with</p>
</td></tr><tr class="argumentRow "><td class="argName ">options</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. The <a href="search.html" class="link-short" title="Search (class)" data-id="Search"><code>Search</code></a> options to use</p> </td></tr><tr class="argumentRow "><td class="argName ">options</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. The <a href="search.html" class="link-short" title="Search (class)" data-id="Search"><code>Search</code></a> options to use</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -3484,8 +3484,8 @@
</div> </div>
<div class="description"><p>Replaces all occurances of <code>options.needle</code> with the value in <code>replacement</code>.</p> <div class="description"><p>Replaces all occurances of <code>options.needle</code> with the value in <code>replacement</code>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">replacement</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The text to replace with</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">replacement</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The text to replace with</p>
</td></tr><tr class="argumentRow "><td class="argName ">options</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. The <a href="search.html" class="link-short" title="Search (class)" data-id="Search"><code>Search</code></a> options to use</p> </td></tr><tr class="argumentRow "><td class="argName ">options</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. The <a href="search.html" class="link-short" title="Search (class)" data-id="Search"><code>Search</code></a> options to use</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -3512,7 +3512,7 @@
</div> </div>
<div class="description"><p>Triggers a resize of the editor.</p> <div class="description"><p>Triggers a resize of the editor.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">force</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code>, recomputes the size, even if the height and width haven&#39;t changed</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">force</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code>, recomputes the size, even if the height and width haven&#39;t changed</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -3613,10 +3613,10 @@
</div> </div>
<div class="description"><p>Scrolls to a line. If <code>center</code> is <code>true</code>, it puts the line in middle of screen (or attempts to).</p> <div class="description"><p>Scrolls to a line. If <code>center</code> is <code>true</code>, it puts the line in middle of screen (or attempts to).</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">line</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The line to scroll to</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">line</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The line to scroll to</p>
</td></tr><tr class="argumentRow "><td class="argName ">center</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code></p> </td></tr><tr class="argumentRow "><td class="argName ">center</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code></p>
</td></tr><tr class="argumentRow "><td class="argName ">animate</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code> animates scrolling</p> </td></tr><tr class="argumentRow "><td class="argName ">animate</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code> animates scrolling</p>
</td></tr><tr class="argumentRow "><td class="argName ">callback</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function" class="" title="Function" data-id="Function">Function</a></td><td class="argDescription "><p>Required. Function to be called when the animation has finished</p> </td></tr><tr class="argumentRow "><td class="argName ">callback</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function" class="" title="Function" data-id="Function">Function</a></td><td class="argDescription "><p>Required. Function to be called when the animation has finished</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -3643,7 +3643,7 @@
</div> </div>
<div class="description"><p>Moves the editor to the specified row.</p> <div class="description"><p>Moves the editor to the specified row.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. </p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. </p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -3695,8 +3695,8 @@
</div> </div>
<div class="description"><p>Finds the next occurence of text in an active selection and adds it to the selections.</p> <div class="description"><p>Finds the next occurence of text in an active selection and adds it to the selections.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">dir</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The direction of lines to select: -1 for up, 1 for down</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">dir</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The direction of lines to select: -1 for up, 1 for down</p>
</td></tr><tr class="argumentRow "><td class="argName ">skip</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code>, removes the active selection range</p> </td></tr><tr class="argumentRow "><td class="argName ">skip</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code>, removes the active selection range</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -3723,8 +3723,8 @@
</div> </div>
<div class="description"><p>Adds a cursor above or below the active cursor.</p> <div class="description"><p>Adds a cursor above or below the active cursor.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">dir</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The direction of lines to select: -1 for up, 1 for down</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">dir</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The direction of lines to select: -1 for up, 1 for down</p>
</td></tr><tr class="argumentRow "><td class="argName ">skip</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code>, removes the active selection range</p> </td></tr><tr class="argumentRow "><td class="argName ">skip</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. If <code>true</code>, removes the active selection range</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -3825,7 +3825,7 @@
</div> </div>
<div class="description"><p>Specifies whether to use behaviors or not. &quot;Behaviors&quot; in this case is the auto-pairing of special characters, like quotation marks, parenthesis, or brackets.</p> <div class="description"><p>Specifies whether to use behaviors or not. &quot;Behaviors&quot; in this case is the auto-pairing of special characters, like quotation marks, parenthesis, or brackets.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">enabled</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Enables or disables behaviors</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">enabled</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Enables or disables behaviors</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -3876,7 +3876,7 @@
</div> </div>
<div class="description"><p>Sets the delay (in milliseconds) of the mouse drag.</p> <div class="description"><p>Sets the delay (in milliseconds) of the mouse drag.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">dragDelay</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. A value indicating the new delay</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">dragDelay</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. A value indicating the new delay</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -3927,7 +3927,7 @@
</div> </div>
<div class="description"><p>Set a new font size (in pixels) for the editor text.</p> <div class="description"><p>Set a new font size (in pixels) for the editor text.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">size</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. A font size</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">size</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. A font size</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -3954,7 +3954,7 @@
</div> </div>
<div class="description"><p>Determines whether or not the current line should be highlighted.</p> <div class="description"><p>Determines whether or not the current line should be highlighted.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">shouldHighlight</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Set to <code>true</code> to highlight the current line</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">shouldHighlight</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Set to <code>true</code> to highlight the current line</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -4005,7 +4005,7 @@
</div> </div>
<div class="description"><p>Determines if the currently selected word should be highlighted.</p> <div class="description"><p>Determines if the currently selected word should be highlighted.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">shouldHighlight</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Set to <code>true</code> to highlight the currently selected word</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">shouldHighlight</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Set to <code>true</code> to highlight the currently selected word</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -4032,7 +4032,7 @@
</div> </div>
<div class="description"><p>Sets a new key handler, such as &quot;vim&quot; or &quot;windows&quot;.</p> <div class="description"><p>Sets a new key handler, such as &quot;vim&quot; or &quot;windows&quot;.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">keyboardHandler</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The new key handler</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">keyboardHandler</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The new key handler</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -4059,7 +4059,7 @@
</div> </div>
<div class="description"><p>Pass in <code>true</code> to enable overwrites in your session, or <code>false</code> to disable. If overwrites is enabled, any text you enter will type over any text after it. If the value of <code>overwrite</code> changes, this function also emites the <code>changeOverwrite</code> event.</p> <div class="description"><p>Pass in <code>true</code> to enable overwrites in your session, or <code>false</code> to disable. If overwrites is enabled, any text you enter will type over any text after it. If the value of <code>overwrite</code> changes, this function also emites the <code>changeOverwrite</code> event.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">overwrite</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Defines wheter or not to set overwrites</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">overwrite</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Defines wheter or not to set overwrites</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -4086,7 +4086,7 @@
</div> </div>
<div class="description"><p>Sets the column defining where the print margin should be.</p> <div class="description"><p>Sets the column defining where the print margin should be.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">showPrintMargin</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. Specifies the new print margin</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">showPrintMargin</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. Specifies the new print margin</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -4113,7 +4113,7 @@
</div> </div>
<div class="description"><p>If <code>readOnly</code> is true, then the editor is set to read-only mode, and none of the content can change.</p> <div class="description"><p>If <code>readOnly</code> is true, then the editor is set to read-only mode, and none of the content can change.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">readOnly</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Specifies whether the editor can be modified or not</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">readOnly</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Specifies whether the editor can be modified or not</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -4140,7 +4140,7 @@
</div> </div>
<div class="description"><p>Sets how fast the mouse scrolling should do.</p> <div class="description"><p>Sets how fast the mouse scrolling should do.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">speed</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. A value indicating the new speed (in milliseconds)</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">speed</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. A value indicating the new speed (in milliseconds)</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -4170,7 +4170,7 @@
although this code change in the future.</p> although this code change in the future.</p>
<p>This function also emits the <code>&#39;changeSelectionStyle&#39;</code> event.</p> <p>This function also emits the <code>&#39;changeSelectionStyle&#39;</code> event.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">style</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The new selection style</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">style</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The new selection style</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -4197,7 +4197,7 @@ although this code change in the future.</p>
</div> </div>
<div class="description"><p>Sets a new editsession to use. This method also emits the <code>&#39;changeSession&#39;</code> event.</p> <div class="description"><p>Sets a new editsession to use. This method also emits the <code>&#39;changeSession&#39;</code> event.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">session</td><td class="argType"><a href="edit_session.html" class="" title="EditSession (class)" data-id="EditSession">EditSession</a></td><td class="argDescription "><p>Required. The new session to use</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">session</td><td class="argType" "><a href="edit_session.html" class="" title="EditSession (class)" data-id="EditSession">EditSession</a></td><td class="argDescription "><p>Required. The new session to use</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -4224,7 +4224,7 @@ although this code change in the future.</p>
</div> </div>
<div class="description"><p>Indicates whether the fold widgets are shown or not.</p> <div class="description"><p>Indicates whether the fold widgets are shown or not.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">show</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Specifies whether the fold widgets are shown</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">show</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Specifies whether the fold widgets are shown</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -4251,7 +4251,7 @@ although this code change in the future.</p>
</div> </div>
<div class="description"><p>If <code>showInvisibles</code> is set to <code>true</code>, invisible characters&mdash;like spaces or new lines&mdash;are show in the editor.</p> <div class="description"><p>If <code>showInvisibles</code> is set to <code>true</code>, invisible characters&mdash;like spaces or new lines&mdash;are show in the editor.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">showInvisibles</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Specifies whether or not to show invisible characters</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">showInvisibles</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Specifies whether or not to show invisible characters</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -4278,7 +4278,7 @@ although this code change in the future.</p>
</div> </div>
<div class="description"><p>If <code>showPrintMargin</code> is set to <code>true</code>, the print margin is shown in the editor.</p> <div class="description"><p>If <code>showPrintMargin</code> is set to <code>true</code>, the print margin is shown in the editor.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">showPrintMargin</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Specifies whether or not to show the print margin</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">showPrintMargin</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Specifies whether or not to show the print margin</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -4305,7 +4305,7 @@ although this code change in the future.</p>
</div> </div>
<div class="description"><p>Adds a new class, <code>style</code>, to the editor.</p> <div class="description"><p>Adds a new class, <code>style</code>, to the editor.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">style</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. A class name</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">style</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. A class name</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -4332,7 +4332,7 @@ although this code change in the future.</p>
</div> </div>
<div class="description"><p>Sets a new theme for the editor. <code>theme</code> should exist, and be a directory path, like <code>ace/theme/textmate</code>.</p> <div class="description"><p>Sets a new theme for the editor. <code>theme</code> should exist, and be a directory path, like <code>ace/theme/textmate</code>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">theme</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The path to a theme</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">theme</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The path to a theme</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -4364,8 +4364,8 @@ although this code change in the future.</p>
</div> </div>
<div class="description"><p>Sets the current document to <code>val</code>.</p> <div class="description"><p>Sets the current document to <code>val</code>.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">val</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The new value to set for the document</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">val</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The new value to set for the document</p>
</td></tr><tr class="argumentRow "><td class="argName ">cursorPos</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. Where to set the new value. <code>undefined</code> or 0 is selectAll, -1 is at the document start, and 1 is at the end</p> </td></tr><tr class="argumentRow "><td class="argName ">cursorPos</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. Where to set the new value. <code>undefined</code> or 0 is selectAll, -1 is at the document start, and 1 is at the end</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -4394,7 +4394,7 @@ when such a character is typed in.</p>
<div class="description"><p>Specifies whether to use wrapping behaviors or not, i.e. automatically wrapping the selection with characters such as brackets <div class="description"><p>Specifies whether to use wrapping behaviors or not, i.e. automatically wrapping the selection with characters such as brackets
when such a character is typed in.</p> when such a character is typed in.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">enabled</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Enables or disables wrapping behaviors</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">enabled</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Boolean" class="" title="Boolean" data-id="Boolean">Boolean</a></td><td class="argDescription "><p>Required. Enables or disables wrapping behaviors</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -4595,7 +4595,7 @@ when such a character is typed in.</p>
</div> </div>
<div class="description"><p>Transposes the selected ranges.</p> <div class="description"><p>Transposes the selected ranges.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">dir</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The direction to rotate selections</p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">dir</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Number" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The direction to rotate selections</p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>
@ -4647,7 +4647,7 @@ when such a character is typed in.</p>
</div> </div>
<div class="description"><p>Removes the class <code>style</code> from the editor.</p> <div class="description"><p>Removes the class <code>style</code> from the editor.</p>
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">style</td><td class="argType"><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. </p> <h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">style</td><td class="argType" "><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object" class="" title="Object" data-id="Object">Object</a></td><td class="argDescription "><p>Required. </p>
</td></tr></table> </td></tr></table>
</div> </div>
</div> </div>

View file

@ -163,7 +163,7 @@
<article id="Selection" data-title="Selection (class)" class="article"> <article id="Selection" data-title="Selection (class)" class="article">
<div class="section description"> <div class="section description">
<div class="memberContent"><p>Contains the cursor position and the text selection of an edit session.</p> <div class="memberContent"><p>Contains the cursor position and the text selection of an edit session.</p>
<p>The row/columns used in the selection are in document coordinates representing the coordinates as they appear in the document before applying soft wrap and folding.</p> <p>The row/columns used in the selection are in document coordinates representing ths coordinates as thez appear in the document before applying soft wrap and folding.</p>
</div> </div>
</div> </div>
@ -1778,4 +1778,4 @@
<script defer src="./resources/javascripts/disqus-ext.js"></script> <script defer src="./resources/javascripts/disqus-ext.js"></script>
<script defer src="./resources/javascripts/ga.js"></script> <script defer src="./resources/javascripts/ga.js"></script>
<div id="disqus_thread"></div> <div id="disqus_thread"></div>
</div> </div>

2
build

@ -1 +1 @@
Subproject commit a4e495d8901876c6bafe3870a35cb8e32c827e97 Subproject commit 995de31e6513ddfd5e9f66b8216f5b316fcd2253

View file

@ -8,8 +8,8 @@
body { body {
overflow: hidden; overflow: hidden;
} }
#editor { #editor {
margin: 0; margin: 0;
position: absolute; position: absolute;
top: 0; top: 0;
@ -27,7 +27,7 @@
alert("Ace Rocks " + items[i]); alert("Ace Rocks " + items[i]);
} }
}</pre> }</pre>
<script src="src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script> <script src="src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script> <script>
var editor = ace.edit("editor"); var editor = ace.edit("editor");

View file

@ -20,7 +20,7 @@ function foo() {
var bar = true; var bar = true;
}</textarea><br> }</textarea><br>
SourceUrl: <br> SourceUrl: <br>
<input id="srcURL" style="width:300px" value="http://ajaxorg.github.com/ace-builds/src-noconflict"></input><br> <input id="srcURL" style="width:300px" value="http://ajaxorg.github.com/ace-builds/textarea/src/"></input><br>
<button id="buBuild">Build Link</button> <br> <a href="#"></a> <button id="buBuild">Build Link</button> <br> <a href="#"></a>
<a href="https://github.com/ajaxorg/ace/"> <a href="https://github.com/ajaxorg/ace/">
<div class="fork_on_github" ></div> <div class="fork_on_github" ></div>
@ -49,60 +49,63 @@ function foo() {
<script> <script>
function inject(options, callback) { function inject(callback) {
var baseUrl = options.baseUrl || "../../src-noconflict"; var baseUrl = "src/";
var load = function(path, callback) { var load = window.__ace_loader__ = function(path, module, callback) {
var head = document.getElementsByTagName('head')[0]; var head = document.getElementsByTagName('head')[0];
var s = document.createElement('script'); var s = document.createElement('script');
s.src = baseUrl + "/" + path; s.src = baseUrl + path;
head.appendChild(s); head.appendChild(s);
s.onload = s.onreadystatechange = function(_, isAbort) { s.onload = function() {
if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") { window.__ace_shadowed__.require([module], callback);
s = s.onload = s.onreadystatechange = null;
if (!isAbort)
callback();
}
}; };
}; };
load("ace.js", function() { load('ace-bookmarklet.js', "ace/ext/textarea", function() {
ace.config.loadModule("ace/ext/textarea", function() { var ace = window.__ace_shadowed__;
var event = ace.require("ace/lib/event");
var areas = document.getElementsByTagName("textarea"); ace.options.mode = "javascript";
for (var i = 0; i < areas.length; i++) { var Event = ace.require("ace/lib/event");
event.addListener(areas[i], "click", function(e) { var areas = document.getElementsByTagName("textarea");
if (e.detail == 3) { for (var i = 0; i < areas.length; i++) {
ace.transformTextarea(e.target, options.ace); Event.addListener(areas[i], "click", function(e) {
} if (e.detail == 3) {
}); ace.transformTextarea(e.target, load);
} }
callback && callback(); });
}); }
callback && callback();
}); });
} }
// Call the inject function to load the ace files. // Call the inject function to load the ace files.
var textAce; var textAce;
inject({}, function () { inject(function () {
// Transform the textarea on the page into an ace editor. // Transform the textarea on the page into an ace editor.
var ace = window.__ace_shadowed__;
var t = document.querySelector("textarea"); var t = document.querySelector("textarea");
textAce = ace.require("ace/ext/textarea").transformTextarea(t); textAce = ace.transformTextarea(t, window.__ace_loader__);
setTimeout(function(){textAce.setDisplaySettings(true)}); setTimeout(function(){textAce.setDisplaySettings(true)});
}); });
document.getElementById("buBuild").onclick = function() { document.getElementById("buBuild").onclick = function() {
var injectSrc = inject.toString().split("\n").join(""); var injectSrc = inject.toString().split("\n").join("");
injectSrc = injectSrc.replace('baseUrl = "src/"', 'baseUrl="' + document.getElementById("srcURL").value + '"');
var aceOptions = textAce.getOptions();
var opt = [];
for (var option in aceOptions) {
opt.push(option + ":'" + aceOptions[option] + "'");
}
injectSrc = injectSrc.replace('ace.options.mode = "javascript"', 'ace.options = { ' + opt.join(",") + ' }');
injectSrc = injectSrc.replace(/\s+/g, " "); injectSrc = injectSrc.replace(/\s+/g, " ");
var options = textAce.getOptions();
options.baseUrl = document.getElementById("srcURL").value;
var a = document.querySelector("a"); var a = document.querySelector("a");
a.href = "javascript:(" + injectSrc + ")(" + JSON.stringify(options) + ")"; a.href = "javascript:(" + injectSrc + ")()";
a.innerHTML = "Ace Bookmarklet Link"; a.innerHTML = "Ace Bookmarklet Link";
} }

View file

@ -3,7 +3,7 @@
* *
* Copyright (c) 2010, Ajax.org B.V. * Copyright (c) 2010, Ajax.org B.V.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright * * Redistributions of source code must retain the above copyright
@ -14,7 +14,7 @@
* * Neither the name of Ajax.org B.V. nor the * * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * 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 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@ -38,62 +38,69 @@
var ACE_NAMESPACE = ""; var ACE_NAMESPACE = "";
var global = (function() { return this; })(); var global = (function() {
if (!global && typeof window != "undefined") global = window; // strict mode return this;
})();
if (!ACE_NAMESPACE && typeof requirejs !== "undefined") if (!ACE_NAMESPACE && typeof requirejs !== "undefined")
return; return;
var define = function(module, deps, payload) { var _define = function(module, deps, payload) {
if (typeof module !== "string") { if (typeof module !== 'string') {
if (define.original) if (_define.original)
define.original.apply(this, arguments); _define.original.apply(window, arguments);
else { else {
console.error("dropping module because define wasn\'t a string."); console.error('dropping module because define wasn\'t a string.');
console.trace(); console.trace();
} }
return; return;
} }
if (arguments.length == 2) if (arguments.length == 2)
payload = deps; payload = deps;
if (!define.modules[module]) {
define.payloads[module] = payload;
define.modules[module] = null;
}
};
define.modules = {}; if (!_define.modules) {
define.payloads = {}; _define.modules = {};
_define.payloads = {};
}
_define.payloads[module] = payload;
_define.modules[module] = null;
};
/** /**
* Get at functionality define()ed using the function above * Get at functionality define()ed using the function above
*/ */
var _require = function(parentId, module, callback) { var _require = function(parentId, module, callback) {
if (typeof module === "string") { if (Object.prototype.toString.call(module) === "[object Array]") {
var payload = lookup(parentId, module);
if (payload != undefined) {
callback && callback();
return payload;
}
} else if (Object.prototype.toString.call(module) === "[object Array]") {
var params = []; var params = [];
for (var i = 0, l = module.length; i < l; ++i) { for (var i = 0, l = module.length; i < l; ++i) {
var dep = lookup(parentId, module[i]); var dep = lookup(parentId, module[i]);
if (dep == undefined && require.original) if (!dep && _require.original)
return; return _require.original.apply(window, arguments);
params.push(dep); params.push(dep);
} }
return callback && callback.apply(null, params) || true; if (callback) {
callback.apply(null, params);
}
} }
}; else if (typeof module === 'string') {
var payload = lookup(parentId, module);
if (!payload && _require.original)
return _require.original.apply(window, arguments);
var require = function(module, callback) { if (callback) {
var packagedModule = _require("", module, callback); callback();
if (packagedModule == undefined && require.original) }
return require.original.apply(this, arguments);
return packagedModule; return payload;
}
else {
if (_require.original)
return _require.original.apply(window, arguments);
}
}; };
var normalizeModule = function(parentId, moduleName) { var normalizeModule = function(parentId, moduleName) {
@ -112,6 +119,7 @@ var normalizeModule = function(parentId, moduleName) {
moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, ""); moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
} }
} }
return moduleName; return moduleName;
}; };
@ -120,11 +128,12 @@ var normalizeModule = function(parentId, moduleName) {
* definition function if needed. * definition function if needed.
*/ */
var lookup = function(parentId, moduleName) { var lookup = function(parentId, moduleName) {
moduleName = normalizeModule(parentId, moduleName); moduleName = normalizeModule(parentId, moduleName);
var module = define.modules[moduleName]; var module = _define.modules[moduleName];
if (!module) { if (!module) {
module = define.payloads[moduleName]; module = _define.payloads[moduleName];
if (typeof module === 'function') { if (typeof module === 'function') {
var exports = {}; var exports = {};
var mod = { var mod = {
@ -140,15 +149,19 @@ var lookup = function(parentId, moduleName) {
var returnValue = module(req, exports, mod); var returnValue = module(req, exports, mod);
exports = returnValue || mod.exports; exports = returnValue || mod.exports;
define.modules[moduleName] = exports; _define.modules[moduleName] = exports;
delete define.payloads[moduleName]; delete _define.payloads[moduleName];
} }
module = define.modules[moduleName] = exports || module; module = _define.modules[moduleName] = exports || module;
} }
return module; return module;
}; };
function exportAce(ns) { function exportAce(ns) {
var require = function(module, callback) {
return _require("", module, callback);
};
var root = global; var root = global;
if (ns) { if (ns) {
if (!global[ns]) if (!global[ns])
@ -157,13 +170,13 @@ function exportAce(ns) {
} }
if (!root.define || !root.define.packaged) { if (!root.define || !root.define.packaged) {
define.original = root.define; _define.original = root.define;
root.define = define; root.define = _define;
root.define.packaged = true; root.define.packaged = true;
} }
if (!root.require || !root.require.packaged) { if (!root.require || !root.require.packaged) {
require.original = root.require; _require.original = root.require;
root.require = require; root.require = require;
root.require.packaged = true; root.require.packaged = true;
} }

View file

@ -4,7 +4,7 @@ body {
margin:0; margin:0;
padding:0; padding:0;
background-color:#e6f5fc; background-color:#e6f5fc;
} }
H2, H3, H4 { H2, H3, H4 {
@ -58,7 +58,7 @@ PRE{
position:relative; position:relative;
overflow:hidden; overflow:hidden;
background: url(images/background.png) repeat-x 0 0; background: url(images/background.png) repeat-x 0 0;
border-bottom:1px solid #c9e8fa; border-bottom:1px solid #c9e8fa;
} }
#header .content .signature { #header .content .signature {
@ -224,3 +224,7 @@ UL.menu-footer LI A {
UL.menu-footer LI A:hover { UL.menu-footer LI A:hover {
text-decoration:underline; text-decoration:underline;
} }

View file

@ -35,8 +35,7 @@
// enable autocompletion and snippets // enable autocompletion and snippets
editor.setOptions({ editor.setOptions({
enableBasicAutocompletion: true, enableBasicAutocompletion: true,
enableSnippets: true, enableSnippets: true
enableLiveAutocompletion: false
}); });
</script> </script>

View file

@ -7,62 +7,42 @@
<style type="text/css" media="screen"> <style type="text/css" media="screen">
.ace_editor { .ace_editor {
position: relative !important;
border: 1px solid lightgray; border: 1px solid lightgray;
margin: auto; margin: auto;
height: 200px; height: 200px;
width: 80%; width: 80%;
} }
.scrollmargin { .scrollmargin {
height: 80px; height: 100px;
text-align: center; text-align: center;
} }
</style> </style>
</head> </head>
<body> <body>
<pre id="editor1">autoresizing editor</pre> <pre id="editor">autoresizing editor</pre>
<div class="scrollmargin"></div> <div class="scrollmargin"></div>
<pre id="editor2">minHeight = 2 lines</pre> <pre id="editor2">minHeight = 2 lines</pre>
<div class="scrollmargin"></div>
<pre id="editor3" style="width: 40%;"></pre>
<div class="scrollmargin"></div>
<pre id="editor"></pre>
<script src="kitchen-sink/require.js"></script> <script src="../build/src/ace.js"></script>
<script> <script>
// setup paths
require.config({paths: { "ace" : "../lib/ace"}});
// load ace and extensions
require(["ace/ace"], function(ace) {
var editor1 = ace.edit("editor1"); // create first editor
editor1.setTheme("ace/theme/tomorrow_night_eighties"); var editor = ace.edit("editor");
editor1.session.setMode("ace/mode/html"); editor.setTheme("ace/theme/tomorrow");
editor1.setAutoScrollEditorIntoView(true); editor.session.setMode("ace/mode/html");
editor1.setOption("maxLines", 30); editor.setAutoScrollEditorIntoView();
editor.setOption("maxLines", 100);
var editor2 = ace.edit("editor2");
editor2.setTheme("ace/theme/tomorrow_night_blue");
editor2.session.setMode("ace/mode/html");
editor2.setAutoScrollEditorIntoView();
editor2.setOption("maxLines", 30);
editor2.setOption("minLines", 2);
var editor2 = ace.edit("editor2");
editor2.setTheme("ace/theme/tomorrow_night_blue");
editor2.session.setMode("ace/mode/html");
editor2.setAutoScrollEditorIntoView(true);
editor2.setOption("maxLines", 30);
editor2.setOption("minLines", 2);
var editor = ace.edit("editor3");
editor.setOptions({
autoScrollEditorIntoView: true,
maxLines: 8
});
editor.renderer.setScrollMargin(10, 10, 10, 10);
var editor = ace.edit("editor");
editor.setTheme("ace/theme/tomorrow");
editor.session.setMode("ace/mode/html");
editor.setAutoScrollEditorIntoView(true);
editor.setOption("maxLines", 100);
});
</script> </script>
<script src="./show_own_source.js"></script>
</body> </body>
</html> </html>

View file

@ -22,20 +22,19 @@
<pre id="editor"></pre> <pre id="editor"></pre>
<!-- load emmet code and snippets compiled for browser --> <!-- load ace -->
<script src="https://cloud9ide.github.io/emmet-core/emmet.js"></script> <script src="../build/src-noconflict/ace.js"></script>
<!-- load ace emmet extension -->
<script src="kitchen-sink/require.js"></script> <script src="../build/src-noconflict/ext-emmet.js"></script>
<!-- load core emmet files -->
<script src="http://nightwing.github.io/emmet-core/emmet.js"></script>
<script> <script>
// setup paths // trigger extension
require.config({paths: { "ace" : "../lib/ace"}}); ace.require("ace/ext/emmet");
// load ace and extensions
require(["ace/ace", "ace/ext/emmet"], function(ace) {
var editor = ace.edit("editor"); var editor = ace.edit("editor");
editor.session.setMode("ace/mode/html"); editor.session.setMode("ace/mode/html");
// enable emmet on the current editor // enable emmet on the current editor
editor.setOption("enableEmmet", true); editor.setOption("enableEmmet", true);
});
</script> </script>
<script src="./show_own_source.js"></script> <script src="./show_own_source.js"></script>

View file

@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>ACE Editor StatusBar Demo</title> <title>ACE Editor StatusBar Demo</title>
<style type="text/css" media="screen"> <style type="text/css" media="screen">
/*!important without this top: 0; bottom: 0 doesn't work on old ie */ /*!important without this top: 0; bottom: 0 doesn't work */
body, html { body, html {
position: absolute; position: absolute;
top: 0px; bottom: 0; left: 0; right: 0; top: 0px; bottom: 0; left: 0; right: 0;

View file

@ -22,11 +22,8 @@
<pre id="editor"></pre> <pre id="editor"></pre>
<script src="kitchen-sink/require.js"></script> <script src="../build/src-noconflict/ace.js"></script>
<script> <script>
// setup paths
require.config({paths: { "ace" : "../lib/ace"}});
require(["ace/ace"], function(ace) {
var editor = ace.edit("editor") var editor = ace.edit("editor")
editor.setTheme("ace/theme/twilight") editor.setTheme("ace/theme/twilight")
editor.session.setMode("ace/mode/html") editor.session.setMode("ace/mode/html")
@ -42,8 +39,6 @@ require(["ace/ace"], function(ace) {
}) })
} }
}) })
editor.execCommand("showKeyboardShortcuts")
})
</script> </script>
<script src="./show_own_source.js"></script> <script src="./show_own_source.js"></script>

View file

@ -65,7 +65,6 @@ var whitespace = require("ace/ext/whitespace");
var doclist = require("./doclist"); var doclist = require("./doclist");
var modelist = require("ace/ext/modelist"); var modelist = require("ace/ext/modelist");
var themelist = require("ace/ext/themelist");
var layout = require("./layout"); var layout = require("./layout");
var TokenTooltip = require("./token_tooltip").TokenTooltip; var TokenTooltip = require("./token_tooltip").TokenTooltip;
var util = require("./util"); var util = require("./util");
@ -184,21 +183,21 @@ env.editor.commands.addCommands([{
} }
}, { }, {
name: "increaseFontSize", name: "increaseFontSize",
bindKey: "Ctrl-=|Ctrl-+", bindKey: "Ctrl-+",
exec: function(editor) { exec: function(editor) {
var size = parseInt(editor.getFontSize(), 10) || 12; var size = parseInt(editor.getFontSize(), 10) || 12;
editor.setFontSize(size + 1); editor.setFontSize(size + 1);
} }
}, { }, {
name: "decreaseFontSize", name: "decreaseFontSize",
bindKey: "Ctrl+-|Ctrl-_", bindKey: "Ctrl+-",
exec: function(editor) { exec: function(editor) {
var size = parseInt(editor.getFontSize(), 10) || 12; var size = parseInt(editor.getFontSize(), 10) || 12;
editor.setFontSize(Math.max(size - 1 || 1)); editor.setFontSize(Math.max(size - 1 || 1));
} }
}, { }, {
name: "resetFontSize", name: "resetFontSize",
bindKey: "Ctrl+0|Ctrl-Numpad0", bindKey: "Ctrl+0",
exec: function(editor) { exec: function(editor) {
editor.setFontSize(12); editor.setFontSize(12);
} }
@ -251,7 +250,7 @@ commands.addCommand({
} }
}); });
var keybindings = { var keybindings = {
ace: null, // Null = use "default" keymapping ace: null, // Null = use "default" keymapping
vim: require("ace/keyboard/vim").handler, vim: require("ace/keyboard/vim").handler,
emacs: "ace/keyboard/emacs", emacs: "ace/keyboard/emacs",
@ -317,7 +316,7 @@ doclist.history.index = 0;
doclist.cycleOpen = function(editor, dir) { doclist.cycleOpen = function(editor, dir) {
var h = this.history; var h = this.history;
h.index += dir; h.index += dir;
if (h.index >= h.length) if (h.index >= h.length)
h.index = 0; h.index = 0;
else if (h.index <= 0) else if (h.index <= 0)
h.index = h.length - 1; h.index = h.length - 1;
@ -371,12 +370,6 @@ function updateUIEditorOptions() {
saveOption(behavioursEl, editor.getBehavioursEnabled()); saveOption(behavioursEl, editor.getBehavioursEnabled());
} }
themelist.themes.forEach(function(x){ x.value = x.theme });
fillDropdown(themeEl, {
Bright: themelist.themes.filter(function(x){return !x.isDark}),
Dark: themelist.themes.filter(function(x){return x.isDark}),
});
event.addListener(themeEl, "mouseover", function(e){ event.addListener(themeEl, "mouseover", function(e){
themeEl.desiredValue = e.target.value; themeEl.desiredValue = e.target.value;
if (!themeEl.$timer) if (!themeEl.$timer)
@ -390,7 +383,7 @@ event.addListener(themeEl, "mouseout", function(e){
}); });
themeEl.updateTheme = function(){ themeEl.updateTheme = function(){
env.split.setTheme((themeEl.desiredValue || themeEl.selectedValue)); env.split.setTheme(themeEl.desiredValue || themeEl.selectedValue);
themeEl.$timer = null; themeEl.$timer = null;
}; };
@ -415,11 +408,28 @@ bindDropdown("folding", function(value) {
}); });
bindDropdown("soft_wrap", function(value) { bindDropdown("soft_wrap", function(value) {
env.editor.setOption("wrap", value); var session = env.editor.session;
var renderer = env.editor.renderer;
switch (value) {
case "off":
session.setUseWrapMode(false);
renderer.setPrintMarginColumn(80);
break;
case "free":
session.setUseWrapMode(true);
session.setWrapLimitRange(null, null);
renderer.setPrintMarginColumn(80);
break;
default:
session.setUseWrapMode(true);
var col = parseInt(value, 10);
session.setWrapLimitRange(col, col);
renderer.setPrintMarginColumn(col);
}
}); });
bindCheckbox("select_style", function(checked) { bindCheckbox("select_style", function(checked) {
env.editor.setOption("selectionStyle", checked ? "line" : "text"); env.editor.setSelectionStyle(checked ? "line" : "text");
}); });
bindCheckbox("highlight_active", function(checked) { bindCheckbox("highlight_active", function(checked) {
@ -482,7 +492,7 @@ bindDropdown("split", function(value) {
sp.setSplits(1); sp.setSplits(1);
} else { } else {
var newEditor = (sp.getSplits() == 1); var newEditor = (sp.getSplits() == 1);
sp.setOrientation(value == "below" ? sp.BELOW : sp.BESIDE); sp.setOrientation(value == "below" ? sp.BELOW : sp.BESIDE);
sp.setSplits(2); sp.setSplits(2);
if (newEditor) { if (newEditor) {
@ -531,7 +541,7 @@ new StatusBar(env.editor, cmdLine.container);
var Emmet = require("ace/ext/emmet"); var Emmet = require("ace/ext/emmet");
net.loadScript("https://cloud9ide.github.io/emmet-core/emmet.js", function() { net.loadScript("http://nightwing.github.io/emmet-core/emmet.js", function() {
Emmet.setCore(window.emmet); Emmet.setCore(window.emmet);
env.editor.setOption("enableEmmet", true); env.editor.setOption("enableEmmet", true);
}); });
@ -575,11 +585,7 @@ env.editSnippets = function() {
require("ace/ext/language_tools"); require("ace/ext/language_tools");
env.editor.setOptions({ env.editor.setOptions({
enableBasicAutocompletion: true, enableBasicAutocompletion: true,
enableLiveAutocompletion: false,
enableSnippets: true enableSnippets: true
}); });
var beautify = require("ace/ext/beautify"); });
env.editor.commands.addCommands(beautify.commands);
});

View file

@ -29,33 +29,25 @@
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) { define(function(require, exports, module) {
var dom = require("ace/lib/dom"); // allow easy access to ace in console, but not in ace code which uses strict
var Range = require("ace/range").Range; function isStrict() {
try { return !arguments.callee.caller.caller.caller}
catch(e){ return true }
}
function warn() { function warn() {
var s = (new Error()).stack || ""; if (isStrict()) {
s = s.split("\n");
if (s[1] == "Error") s.shift(); // remove error description on chrome
s.shift(); // remove warn
s.shift(); // remove the getter
s = s.join("\n");
// allow easy access to ace in console, but not in ace code
if (!/at Object.InjectedScript.|@debugger eval|snippets:\/{3}|\(<anonymous>:\d+:\d+\)/.test(s)) {
console.error("trying to access to global variable"); console.error("trying to access to global variable");
} }
} }
function def(o, key, get) { function def(o, key, get) {
try { Object.defineProperty(o, key, {
Object.defineProperty(o, key, { configurable: true,
configurable: true, get: get,
get: get, set: function(val) {
set: function(val) { delete o[key];
delete o[key]; o[key] = val;
o[key] = val; }
} });
});
} catch(e) {
console.error(e);
}
} }
def(window, "ace", function(){ warn(); return window.env.editor }); def(window, "ace", function(){ warn(); return window.env.editor });
def(window, "editor", function(){ warn(); return window.env.editor }); def(window, "editor", function(){ warn(); return window.env.editor });
@ -63,155 +55,21 @@ def(window, "session", function(){ warn(); return window.env.editor.session });
def(window, "split", function(){ warn(); return window.env.split }); def(window, "split", function(){ warn(); return window.env.split });
def(window, "devUtil", function(){ warn(); return exports }); /* for textinput debuggging
exports.showTextArea = function(argument) { dom.importCssString("\
dom.importCssString("\ .ace_text-input {\
.ace_text-input {\ position: absolute;\
position: absolute;\ z-index: 10!important;\
z-index: 10!important;\ width: 6em!important;\
width: 6em!important;\ height: 1em;\
height: 1em;\ opacity: 1!important;\
opacity: 1!important;\ background: rgba(0, 92, 255, 0.11);\
background: rgba(0, 92, 255, 0.11);\ border: none;\
border: none;\ font: inherit;\
font: inherit;\ padding: 0 1px;\
padding: 0 1px;\ margin: 0 -1px;\
margin: 0 -1px;\ text-indent: 0em;\
text-indent: 0em;\ }\
}\ ")*/
");
};
exports.addGlobals = function() {
window.oop = require("ace/lib/oop");
window.dom = require("ace/lib/dom");
window.Range = require("ace/range").Range;
window.Editor = require("ace/editor").Editor;
window.assert = require("ace/test/asyncjs/assert");
window.asyncjs = require("ace/test/asyncjs/async");
window.UndoManager = require("ace/undomanager").UndoManager;
window.EditSession = require("ace/edit_session").EditSession;
window.MockRenderer = require("ace/test/mockrenderer").MockRenderer;
window.EventEmitter = require("ace/lib/event_emitter").EventEmitter;
window.getSelection = getSelection;
window.setSelection = setSelection;
window.testSelection = testSelection;
};
function getSelection(editor) {
var data = editor.multiSelect.toJSON();
if (!data.length) data = [data];
data = data.map(function(x) {
var a, c;
if (x.isBackwards) {
a = x.end;
c = x.start;
} else {
c = x.end;
a = x.start;
}
return Range.comparePoints(a, c)
? [a.row, a.column, c.row, c.column]
: [a.row, a.column];
});
return data.length > 1 ? data : data[0];
}
function setSelection(editor, data) {
if (typeof data[0] == "number")
data = [data];
editor.selection.fromJSON(data.map(function(x) {
var start = {row: x[0], column: x[1]};
var end = x.length == 2 ? start : {row: x[2], column: x[3]};
var isBackwards = Range.comparePoints(start, end) > 0;
return isBackwards ? {
start: end,
end: start,
isBackwards: true
} : {
start: start,
end: end,
isBackwards: true
};
}));
}
function testSelection(editor, data) {
assert.equal(getSelection(editor) + "", data + "");
}
exports.recordTestCase = function() {
exports.addGlobals();
var editor = window.editor;
var testcase = window.testcase = [];
var assert;
testcase.push({
type: "setValue",
data: editor.getValue()
}, {
type: "setSelection",
data: getSelection(editor)
});
editor.commands.on("afterExec", function(e) {
testcase.push({
type: "exec",
data: e
});
testcase.push({
type: "value",
data: editor.getValue()
});
testcase.push({
type: "selection",
data: getSelection(editor)
});
});
editor.on("mouseup", function() {
testcase.push({
type: "setSelection",
data: getSelection(editor)
});
});
testcase.toString = function() {
var lastValue = "";
// var lastSelection = ""
var str = this.map(function(x) {
var data = x.data;
switch (x.type) {
case "exec":
return 'editor.execCommand("'
+ data.command.name
+ (data.args ? '", ' + JSON.stringify(data.args) : '"')
+ ')';
case "setSelection":
return 'setSelection(editor, ' + JSON.stringify(data) + ')';
case "setValue":
if (lastValue != data) {
lastValue = data;
return 'editor.setValue(' + JSON.stringify(data) + ', -1)';
}
return;
case "selection":
return 'testSelection(editor, ' + JSON.stringify(data) + ')';
case "value":
if (lastValue != data) {
lastValue = data;
return 'assert.equal('
+ 'editor.getValue(),'
+ JSON.stringify(data)
+ ')';
}
return;
}
}).filter(Boolean).join("\n");
return getSelection + "\n"
+ testSelection + "\n"
+ setSelection + "\n"
+ "\n" + str + "\n";
};
};
}); });

View file

@ -78,7 +78,6 @@ var docs = {
"docs/textile.textile": {name: "Textile", wrapped: true}, "docs/textile.textile": {name: "Textile", wrapped: true},
"docs/c9search.c9search_results": "C9 Search Results", "docs/c9search.c9search_results": "C9 Search Results",
"docs/mel.mel": "MEL",
"docs/Nix.nix": "Nix" "docs/Nix.nix": "Nix"
}; };
@ -86,12 +85,9 @@ var ownSource = {
/* filled from require*/ /* filled from require*/
}; };
var hugeDocs = require.toUrl ? { var hugeDocs = {
"build/src/ace.js": "", "build/src/ace.js": "",
"build/src-min/ace.js": "" "build/src-min/ace.js": ""
} : {
"src/ace.js": "",
"src-min/ace.js": ""
}; };
modelist.modes.forEach(function(m) { modelist.modes.forEach(function(m) {
@ -169,44 +165,13 @@ function loadDoc(name, callback) {
}); });
} }
function saveDoc(name, callback) {
var doc = fileCache[name] || name;
if (!doc || !doc.session)
return callback("Unknown document: " + name);
var path = doc.path;
var parts = path.split("/");
if (parts[0] == "docs")
path = "demo/kitchen-sink/" + path;
else if (parts[0] == "ace")
path = "lib/" + path;
upload(path, doc.session.getValue(), callback);
}
function upload(url, data, callback) {
url = net.qualifyURL(url);
if (!/https?:/.test(url))
return callback(new Error("Unsupported url scheme"));
var xhr = new XMLHttpRequest();
xhr.open("PUT", url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
callback(!/^2../.test(xhr.status));
}
};
xhr.send(data);
};
module.exports = { module.exports = {
fileCache: fileCache, fileCache: fileCache,
docs: sort(prepareDocList(docs)), docs: sort(prepareDocList(docs)),
ownSource: prepareDocList(ownSource), ownSource: prepareDocList(ownSource),
hugeDocs: prepareDocList(hugeDocs), hugeDocs: prepareDocList(hugeDocs),
initDoc: initDoc, initDoc: initDoc,
loadDoc: loadDoc, loadDoc: loadDoc
saveDoc: saveDoc,
}; };
module.exports.all = { module.exports.all = {
"Mode Examples": module.exports.docs, "Mode Examples": module.exports.docs,

View file

@ -1,11 +0,0 @@
# A sample .gitignore file.
.buildlog
.DS_Store
.svn
# Negated patterns:
!foo.bar
# Also ignore user settings...
/.settings

View file

@ -1,53 +0,0 @@
#
# example Dockerfile for http://docs.docker.io/en/latest/examples/postgresql_service/
#
FROM ubuntu
MAINTAINER SvenDowideit@docker.com
# Add the PostgreSQL PGP key to verify their Debian packages.
# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
# Add PostgreSQL's repository. It contains the most recent stable release
# of PostgreSQL, ``9.3``.
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
# Update the Ubuntu and PostgreSQL repository indexes
RUN apt-get update
# Install ``python-software-properties``, ``software-properties-common`` and PostgreSQL 9.3
# There are some warnings (in red) that show up during the build. You can hide
# them by prefixing each apt-get statement with DEBIAN_FRONTEND=noninteractive
RUN apt-get -y -q install python-software-properties software-properties-common
RUN apt-get -y -q install postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3
# Note: The official Debian and Ubuntu images automatically ``apt-get clean``
# after each ``apt-get``
# Run the rest of the commands as the ``postgres`` user created by the ``postgres-9.3`` package when it was ``apt-get installed``
USER postgres
# Create a PostgreSQL role named ``docker`` with ``docker`` as the password and
# then create a database `docker` owned by the ``docker`` role.
# Note: here we use ``&&\`` to run commands one after the other - the ``\``
# allows the RUN command to span multiple lines.
RUN /etc/init.d/postgresql start &&\
psql --command "CREATE USER docker WITH SUPERUSER PASSWORD 'docker';" &&\
createdb -O docker docker
# Adjust PostgreSQL configuration so that remote connections to the
# database are possible.
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.3/main/pg_hba.conf
# And add ``listen_addresses`` to ``/etc/postgresql/9.3/main/postgresql.conf``
RUN echo "listen_addresses='*'" >> /etc/postgresql/9.3/main/postgresql.conf
# Expose the PostgreSQL port
EXPOSE 5432
# Add VOLUMEs to allow backup of config, logs and databases
VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
# Set the default command to run when starting the container
CMD ["/usr/lib/postgresql/9.3/bin/postgres", "-D", "/var/lib/postgresql/9.3/main", "-c", "config_file=/etc/postgresql/9.3/main/postgresql.conf"]

View file

@ -1,171 +0,0 @@
%abc-2.1
H:This file contains some example English tunes
% note that the comments (like this one) are to highlight usages
% and would not normally be included in such detail
O:England % the origin of all tunes is England
X:1 % tune no 1
T:Dusty Miller, The % title
T:Binny's Jig % an alternative title
C:Trad. % traditional
R:DH % double hornpipe
M:3/4 % meter
K:G % key
B>cd BAG|FA Ac BA|B>cd BAG|DG GB AG:|
Bdd gfg|aA Ac BA|Bdd gfa|gG GB AG:|
BG G/2G/2G BG|FA Ac BA|BG G/2G/2G BG|DG GB AG:|
W:Hey, the dusty miller, and his dusty coat;
W:He will win a shilling, or he spend a groat.
W:Dusty was the coat, dusty was the colour;
W:Dusty was the kiss, that I got frae the miller.
X:2
T:Old Sir Simon the King
C:Trad.
S:Offord MSS % from Offord manuscript
N:see also Playford % reference note
M:9/8
R:SJ % slip jig
N:originally in C % transcription note
K:G
D|GFG GAG G2D|GFG GAG F2D|EFE EFE EFG|A2G F2E D2:|
D|GAG GAB d2D|GAG GAB c2D|[1 EFE EFE EFG|[A2G] F2E D2:|\ % no line-break in score
M:12/8 % change of meter
[2 E2E EFE E2E EFG|\ % no line-break in score
M:9/8 % change of meter
A2G F2E D2|]
X:3
T:William and Nancy
T:New Mown Hay
T:Legacy, The
C:Trad.
O:England; Gloucs; Bledington % place of origin
B:Sussex Tune Book % can be found in these books
B:Mally's Cotswold Morris vol.1 2
D:Morris On % can be heard on this record
P:(AB)2(AC)2A % play the parts in this order
M:6/8
K:G
[P:A] D|"G"G2G GBd|"C"e2e "G"dBG|"D7"A2d "G"BAG|"C"E2"D7"F "G"G2:|
[P:B] d|"G"e2d B2d|"C"gfe "G"d2d| "G"e2d B2d|"C"gfe "D7"d2c|
"G"B2B Bcd|"C"e2e "G"dBG|"D7"A2d "G"BAG|"C"E2"D7"F "G"G2:|
% changes of meter, using inline fields
[T:Slows][M:4/4][L:1/4][P:C]"G"d2|"C"e2 "G"d2|B2 d2|"Em"gf "A7"e2|"D7"d2 "G"d2|\
"C"e2 "G"d2|[M:3/8][L:1/8] "G"B2 d |[M:6/8] "C"gfe "D7"d2c|
"G"B2B Bcd|"C"e2e "G"dBG|"D7"A2d "G"BAG|"C"E2"D7"F "G"G2:|
X:4
T:South Downs Jig
R:jig
S:Robert Harbron
M:6/8
L:1/8
K:G
|: d | dcA G3 | EFG AFE | DEF GAB | cde d2d |
dcA G3 | EFG AFE | DEF GAB | cAF G2 :|
B | Bcd e2c | d2B c2A | Bcd e2c | [M:9/8]d2B c2B A3 |
[M:6/8]DGF E3 | cBA FED | DEF GAB |1 cAF G2 :|2 cAF G3 |]
X:5
T:Atholl Brose
% in this example, which reproduces Highland Bagpipe gracing,
% the large number of grace notes mean that it is more convenient to be specific about
% score line-breaks (using the $ symbol), rather than using code line breaks to indicate them
I:linebreak $
K:D
{gcd}c<{e}A {gAGAG}A2 {gef}e>A {gAGAG}Ad|
{gcd}c<{e}A {gAGAG}A>e {ag}a>f {gef}e>d|
{gcd}c<{e}A {gAGAG}A2 {gef}e>A {gAGAG}Ad|
{g}c/d/e {g}G>{d}B {gf}gG {dc}d>B:|$
{g}c<e {gf}g>e {ag}a>e {gf}g>e|
{g}c<e {gf}g>e {ag}a2 {GdG}a>d|
{g}c<e {gf}g>e {ag}a>e {gf}g>f|
{gef}e>d {gf}g>d {gBd}B<{e}G {dc}d>B|
{g}c<e {gf}g>e {ag}a>e {gf}g>e|
{g}c<e {gf}g>e {ag}a2 {GdG}ad|
{g}c<{GdG}e {gf}ga {f}g>e {g}f>d|
{g}e/f/g {Gdc}d>c {gBd}B<{e}G {dc}d2|]
X:6
T:Untitled Reel
C:Trad.
K:D
eg|a2ab ageg|agbg agef|g2g2 fgag|f2d2 d2:|\
ed|cecA B2ed|cAcA E2ed|cecA B2ed|c2A2 A2:|
K:G
AB|cdec BcdB|ABAF GFE2|cdec BcdB|c2A2 A2:|
X:7
T:Kitchen Girl
C:Trad.
K:D
[c4a4] [B4g4]|efed c2cd|e2f2 gaba|g2e2 e2fg|
a4 g4|efed cdef|g2d2 efed|c2A2 A4:|
K:G
ABcA BAGB|ABAG EDEG|A2AB c2d2|e3f edcB|ABcA BAGB|
ABAG EGAB|cBAc BAG2|A4 A4:|
%abc-2.1
%%pagewidth 21cm
%%pageheight 29.7cm
%%topspace 0.5cm
%%topmargin 1cm
%%botmargin 0cm
%%leftmargin 1cm
%%rightmargin 1cm
%%titlespace 0cm
%%titlefont Times-Bold 32
%%subtitlefont Times-Bold 24
%%composerfont Times 16
%%vocalfont Times-Roman 14
%%staffsep 60pt
%%sysstaffsep 20pt
%%musicspace 1cm
%%vocalspace 5pt
%%measurenb 0
%%barsperstaff 5
%%scale 0.7
X: 1
T: Canzonetta a tre voci
C: Claudio Monteverdi (1567-1643)
M: C
L: 1/4
Q: "Andante mosso" 1/4 = 110
%%score [1 2 3]
V: 1 clef=treble name="Soprano"sname="A"
V: 2 clef=treble name="Alto" sname="T"
V: 3 clef=bass middle=d name="Tenor" sname="B"
%%MIDI program 1 75 % recorder
%%MIDI program 2 75
%%MIDI program 3 75
K: Eb
% 1 - 4
[V: 1] |:z4 |z4 |f2ec |_ddcc |
w: Son que-sti~i cre-spi cri-ni~e
w: Que-sti son gli~oc-chi che mi-
[V: 2] |:c2BG|AAGc|(F/G/A/B/)c=A|B2AA |
w: Son que-sti~i cre-spi cri-ni~e que - - - - sto~il vi-so e
w: Que-sti son~gli oc-chi che mi-ran - - - - do fi-so mi-
[V: 3] |:z4 |f2ec|_ddcf |(B/c/_d/e/)ff|
w: Son que-sti~i cre-spi cri-ni~e que - - - - sto~il
w: Que-sti son~gli oc-chi che mi-ran - - - - do
% 5 - 9
[V: 1] cAB2 |cAAA |c3B|G2!fermata!Gz ::e4|
w: que-sto~il vi-so ond' io ri-man-go~uc-ci-so. Deh,
w: ran-do fi-so, tut-to re-stai con-qui-so.
[V: 2] AAG2 |AFFF |A3F|=E2!fermata!Ez::c4|
w: que-sto~il vi-so ond' io ri-man-go~uc-ci-so. Deh,
w: ran-do fi-so tut-to re-stai con-qui-so.
[V: 3] (ag/f/e2)|A_ddd|A3B|c2!fermata!cz ::A4|
w: vi - - - so ond' io ti-man-go~uc-ci-so. Deh,
w: fi - - - so tut-to re-stai con-qui-so.
% 10 - 15
[V: 1] f_dec |B2c2|zAGF |\
w: dim-me-lo ben mi-o, che que-sto\
=EFG2 |1F2z2:|2F8|] % more notes
w: sol de-si-o_. % more lyrics
[V: 2] ABGA |G2AA|GF=EF |(GF3/2=E//D//E)|1F2z2:|2F8|]
w: dim-me-lo ben mi-o, che que-sto sol de-si - - - - o_.
[V: 3] _dBc>d|e2AF|=EFc_d|c4 |1F2z2:|2F8|]
w: dim-me-lo ben mi-o, che que-sto sol de-si-o_.

View file

@ -1,42 +0,0 @@
-- https://github.com/Cirru/cirru-gopher/blob/master/code/scope.cr,
set a (int 2)
print (self)
set c (child)
under c
under parent
print a
print $ get c a
set c x (int 3)
print $ get c x
set just-print $ code
print a
print just-print
eval (self) just-print
eval just-print
print (string "string with space")
print (string "escapes \n \"\\")
brackets ((((()))))
"eval" $ string "eval"
print (add $ (int 1) (int 2))
print $ unwrap $
map (a $ int 1) (b $ int 2)
print a
int 1
, b c
int 2
, d

View file

@ -1,18 +1,28 @@
.text-layer { .text-layer {
font: 12px Monaco, "Courier New", monospace; font-family: Monaco, "Courier New", monospace;
font-size: 12pX;
cursor: text; cursor: text;
} }
.blinker { .blinker {
animation: blink 1s linear infinite alternate; animation-duration: 1s;
animation-name: blink;
animation-iteration-count: infinite;
animation-direction: alternate;
animation-timing-function: linear;
} }
@keyframes blink { @keyframes blink {
0%, 40% { 0% {
opacity: 0; opacity: 0;
} }
40% {
40.5%, 100% { opacity: 0;
}
40.5% {
opacity: 1
}
100% {
opacity: 1 opacity: 1
} }
} }

View file

@ -1,30 +0,0 @@
note
description: "Represents a person."
class
PERSON
create
make, make_unknown
feature {NONE} -- Creation
make (a_name: like name)
-- Create a person with `a_name' as `name'.
do
name := a_name
ensure
name = a_name
end
make_unknown
do ensure
name = Void
end
feature -- Access
name: detachable STRING
-- Full name or Void if unknown.
end

View file

@ -1,31 +1 @@
<!DOCTYPE html> TODO
<html>
<head>
<title>Cloud9 Rocks!</title>
</head>
<body>
<table class="table">
<tr>
<th>Name</th>
<th>Size</th>
</tr>
<% if (!isRoot) { %>
<tr>
<td><a href="..">..</a></td>
<td></td></td>
</tr>
<% } %>
<% entries.forEach(function(entry) { %>
<tr>
<td>
<span class="glyphicon <%= entry.mime == 'directory' ? 'folder': 'file'%>"></span>
<a href="<%= entry.name %>"><%= entry.name %></a>
</td>
<td><%= entry.size %></td>
</tr>
<% }) %>
</table>
</body>
</html>

View file

@ -1,42 +0,0 @@
defmodule HelloModule do
@moduledoc """
This is supposed to be `markdown`.
__Yes__ this is [mark](http://down.format)
# Truly
## marked
* with lists
* more
* and more
Even.with(code)
blocks |> with |> samples
_Docs are first class citizens in Elixir_ (Jose Valim)
"""
# A "Hello world" function
def some_fun do
IO.puts "Juhu Kinners!"
end
# A private function
defp priv do
is_regex ~r"""
This is a regex
spanning several
lines.
"""
x = elem({ :a, :b, :c }, 0) #=> :a
end
end
test_fun = fn(x) ->
cond do
x > 10 ->
:greater_than_ten
true ->
:maybe_ten
end
end

View file

@ -1,12 +0,0 @@
{- Ace {- 4 -} Elm -}
main = lift clock (every second)
clock t = collage 400 400 [ filled lightGrey (ngon 12 110)
, outlined (solid grey) (ngon 12 110)
, hand orange 100 t
, hand charcoal 100 (t/60)
, hand charcoal 60 (t/720) ]
hand clr len time =
let angle = degrees (90 - 6 * inSeconds time)
in traced (solid clr) <| segment (0,0) (len * cos angle, len * sin angle)

View file

@ -1,31 +0,0 @@
O003 (DIAMOND SQUARE)
N2 G54 G90 G49 G80
N3 M6 T1 (1.ENDMILL)
N4 M3 S1800
N5 G0 X-.6 Y2.050
N6 G43 H1 Z.1
N7 G1 Z-.3 F50.
N8 G41 D1 Y1.45
N9 G1 X0 F20.
N10 G2 J-1.45
(CUTTER COMP CANCEL)
N11 G1 Z-.2 F50.
N12 Y-.990
N13 G40
N14 G0 X-.6 Y1.590
N15 G0 Z.1
N16 M5 G49 G28 G91 Z0
N17 CALL O9456
N18 #500=0.004
N19 #503=[#500+#501]
N20 VC45=0.0006
VS4=0.0007
N21 G90 G10 L20 P3 X5.Y4. Z6.567
N22 G0 X5000
N23 IF [#1 LT 0.370] GOTO 49
N24 X-0.678 Y+.990
N25 G84.3 X-0.1
N26 #4=#5*COS[45]
N27 #4=#5*SIN[45]
N28 VZOFZ=652.9658
%

View file

@ -1,28 +0,0 @@
@these @are @tags
Feature: Serve coffee
Coffee should not be served until paid for
Coffee should not be served until the button has been pressed
If there is no coffee left then money should be refunded
Scenario Outline: Eating
Given there are <start> cucumbers
When I eat <eat> cucumbers
Then I should have <left> cucumbers
Examples:
| start | eat | left |
| 12 | 5 | 7 |
| 20 | 5 | 15 |
Scenario: Buy last coffee
Given there are 1 coffees left in the machine
And I have deposited 1$
When I press the coffee button
Then I should be served a "coffee"
# this a comment
"""
this is a
pystring
"""

View file

@ -3,6 +3,6 @@
<div id="comments"> <div id="comments">
{{#each comments}} {{#each comments}}
<h2><a href="/posts/{{../permalink}}#{{id}}">{{title}}</a></h2> <h2><a href="/posts/{{../permalink}}#{{id}}">{{title}}</a></h2>
<div>{{{body}}}</div> <div>{{body}}</div>
{{/each}} {{/each}}
</div> </div>

View file

@ -1,10 +0,0 @@
Redirect /linux http://www.linux.org
Redirect 301 /kernel http://www.linux.org
# comment
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^Mozilla.*
RewriteRule ^/$ /homepage.max.html [L]
RewriteRule ^/$ /homepage.std.html [L]

View file

@ -1,4 +1 @@
[.ShellClassInfo] TODO
IconResource=..\logo.png
[ViewState]
FolderType=Generic

View file

@ -1,6 +0,0 @@
// computes factorial of a number
factorial := method(n,
if(n == 0, return 1)
res := 1
Range 1 to(n) foreach(i, res = res * i)
)

View file

@ -2,7 +2,7 @@ for op = (:+, :*, :&, :|, :$)
@eval ($op)(a,b,c) = ($op)(($op)(a,b),c) @eval ($op)(a,b,c) = ($op)(($op)(a,b),c)
end end
v = α';
function g(x,y) function g(x,y)
return x * y return x * y
x + y x + y

View file

@ -1,9 +0,0 @@
import logic
section
variables (A : Type) (p q : A Prop)
example : (x : A, p x q x) y : A, p y :=
assume H : x : A, p x q x,
take y : A,
show p y, from and.elim_left (H y)
end

View file

@ -8,7 +8,7 @@ integer someIntNormal = 3672;
integer someIntHex = 0x00000000; integer someIntHex = 0x00000000;
integer someIntMath = PI_BY_TWO; integer someIntMath = PI_BY_TWO;
integer event = 5673; // invalid.illegal integer event = 5673; // unimplemented reserved keyword!
key someKeyTexture = TEXTURE_DEFAULT; key someKeyTexture = TEXTURE_DEFAULT;
string someStringSpecial = EOF; string someStringSpecial = EOF;
@ -53,12 +53,12 @@ default
someIntHex = 0x00000000; someIntHex = 0x00000000;
someIntMath = PI_BY_TWO; someIntMath = PI_BY_TWO;
event = 5673; // invalid.illegal event = 5673; // unimplemented reserved keyword!
someKeyTexture = TEXTURE_DEFAULT; someKeyTexture = TEXTURE_DEFAULT;
someStringSpecial = EOF; someStringSpecial = EOF;
llSetInventoryPermMask("some item", MASK_NEXT, PERM_ALL); // reserved.godmode llCloud(ZERO_VECTOR); // invalid deprecated function!
llWhisper(PUBLIC_CHANNEL, "Leaving \"default\" now..."); llWhisper(PUBLIC_CHANNEL, "Leaving \"default\" now...");
state other; state other;

View file

@ -1,52 +0,0 @@
/* Mask Syntax Demo */
div > ' Test ~[name]';
define :userProfile {
header {
h4 > @title;
button.close;
}
}
:userProfile {
@title > ' Hello ~[: username.toUpperCase()]'
}
style {
html, body {
background: url('name.png') 0 0 no-repeat;
}
}
button {
event click (e) {
this.textContent = `name ${e.clientX} !`;
}
}
md > """
- div
- span
Hello
[one](http://google.com)
""";
header .foo > 'Heading'
button .baz x-signal='click: test' disabled > "
Hello,
world
\"Buddy\"
"
var a = {
name: `name ${window.innerWidth}`
};
span .foo > "~[bind: a.name]"

View file

@ -1,17 +1 @@
%{ TODO
%{
Ace Matlab demo
%}
%}
classdef hello
methods
function greet(this)
disp('Hello!') % say hi
end
end
end
% transpose
a = [ 'x''y', "x\n\
y", 1' ]' + 2'

View file

@ -1,33 +0,0 @@
// animated duplicates, instances script
proc animatedDuplication (int $rangeStart, int $rangeEnd, int $numOfDuplicates, int $duplicateOrInstance)
{
int $range_start = $rangeStart;
int $range_end = $rangeEnd;
int $num_of_duplicates = $numOfDuplicates;
int $step_size = ($range_end - $range_start) / $num_of_duplicates;
int $i = 0;
int $temp;
currentTime $range_start; // set to range start
string $selectedObjects[]; // to store selected objects
$selectedObjects = `ls -sl`; // store selected objects
select $selectedObjects;
while ($i <= $num_of_duplicates)
{
$temp = $range_start + ($step_size * $i);
currentTime ($temp);
// seleced the objects to duplicate or instance
select $selectedObjects;
if($duplicateOrInstance == 0)
{
duplicate;
}
else
{
instance;
}
$i++;
}
}

View file

@ -41,8 +41,8 @@ SELECT city, temp_lo, temp_hi, prcp, "date", location
/** /**
* Dollar quotes starting at the end of the line are colored as SQL unless * Dollar quotes starting at the end of the line are colored as SQL unless
* a special language tag is used. Dollar quote syntax coloring is implemented * a special language tag is used. Pearl and Python are currently implemented
* for Perl, Python, JavaScript, and Json. * but lots of others are possible.
*/ */
create or replace function blob_content_chunked( create or replace function blob_content_chunked(
in p_data bytea, in p_data bytea,
@ -82,24 +82,6 @@ CREATE FUNCTION usesavedplan() RETURNS trigger AS $python$
SD["plan"] = plan SD["plan"] = plan
$python$ LANGUAGE plpythonu; $python$ LANGUAGE plpythonu;
-- pl/v8 (javascript)
CREATE FUNCTION plv8_test(keys text[], vals text[]) RETURNS text AS $javascript$
var o = {};
for(var i=0; i<keys.length; i++){
o[keys[i]] = vals[i];
}
return JSON.stringify(o);
$javascript$ LANGUAGE plv8 IMMUTABLE STRICT;
-- json
select * from json_object_keys($json$
{
"f1": 5,
"f2": "test",
"f3": {}
}
$json$);
-- psql commands -- psql commands
\df cash* \df cash*

View file

@ -1,148 +0,0 @@
form Highlighter test
sentence My_sentence This should all be a string
text My_text This should also all be a string
word My_word Only the first word is a string, the rest is invalid
boolean Binary 1
boolean Text no
boolean Quoted "yes"
comment This should be a string
real left_Range -123.6
positive right_Range_max 3.3
integer Int 4
natural Nat 4
endform
# External scripts
include /path/to/file
runScript: "/path/to/file"
execute /path/to/file
stopwatch
# old-style procedure call
call oldStyle "quoted" 2 unquoted string
assert oldStyle.local = 1
# New-style procedure call with parens
@newStyle("quoted", 2, "quoted string")
if praatVersion >= 5364
# New-style procedure call with colon
@newStyle: "quoted", 2, "quoted string"
endif
# if-block with built-in variables
if windows
# We are on Windows
elsif unix = 1 or !macintosh
exitScript: "We are on Linux"
else macintosh == 1
exit We are on Mac
endif
# inline if with inline comment
var = if macintosh = 1 then 0 else 1 fi ; This is an inline comment
# for-loop with explicit from using local variable
# and paren-style function calls and variable interpolation
n = numberOfSelected("Sound")
for i from newStyle.local to n
sound'i' = selected("Sound", i)
sound[i] = sound'i'
endfor
for i from 1 to n
# Different styles of object selection
select sound'i'
sound = selected()
sound$ = selected$("Sound")
select Sound 'sound$'
selectObject(sound[i])
selectObject: sound
# Pause commands
beginPause("Viewing " + sound$)
if i > 1
button = endPause("Stop", "Previous",
...if i = total_sounds then "Finish" else "Next" fi,
...3, 1)
else
button = endPause("Stop",
...if i = total_sounds then "Finish" else "Next" fi,
...2, 1)
endif
editor_name$ = if total_textgrids then "TextGrid " else "Sound " fi + name$
nocheck editor 'editor_name$'
nocheck Close
nocheck endeditor
# New-style standalone command call
Rename: "SomeName"
# Command call with assignment
duration = Get total duration
# Multi-line command with modifier
pitch = noprogress To Pitch (ac): 0, 75, 15, "no",
...0.03, 0.45, 0.01, 0.35, 0.14, 600
# do-style command with assignment
minimum = do("Get minimum...", 0, 0, "Hertz", "Parabolic")
# New-style multi-line command call with broken strings
table = Create Table with column names: "table", 0,
..."file subject speaker
...f0 f1 f2 f3 " +
..."duration response"
removeObject: pitch, table
# Picture window commands
selectObject: sound
# do-style command
do("Select inner viewport...", 1, 6, 0.5, 1.5)
Black
Draw... 0 0 0 0 "no" Curve
Draw inner box
Text bottom: "yes", sound$
Erase all
# Demo window commands
demo Erase all
demo Select inner viewport... 0 100 0 100
demo Axes... 0 100 0 100
demo Paint rectangle... white 0 100 0 100
demo Text... 50 centre 50 half Click to finish
demoWaitForInput ( )
demo Erase all
demo Text: 50, "centre", 50, "half", "Finished"
endfor
# An old-style sendpraat block
sendpraat Praat
...'newline$' Create Sound as pure tone... "tone" 1 0 0.4 44100 440 0.2 0.01 0.01
...'newline$' Play
...'newline$' Remove
# A new-style sendpraat block
beginSendPraat: "Praat"
Create Sound as pure tone: "tone", 1, 0, 0.4, 44100, 440, 0.2, 0.01, 0.01
duration = Get total duration
Remove
endSendPraat: "duration"
appendInfoLine: "The generated sound lasted for ", duration, "seconds"
time = stopwatch
clearinfo
echo This script took
print 'time' seconds to
printline execute.
# Old-style procedure declaration
procedure oldStyle .str1$ .num .str2$
.local = 1
endproc
# New-style procedure declaration
procedure newStyle (.str1$, .num, .str2$)
.local = 1
endproc

View file

@ -20,7 +20,7 @@ class Range
end end
end end
{:id => ?", :key => "value"} {:id => 34, :key => "value"}
herDocs = [<<'FOO', <<BAR, <<-BAZ, <<-`EXEC`] #comment herDocs = [<<'FOO', <<BAR, <<-BAZ, <<-`EXEC`] #comment

View file

@ -2,9 +2,9 @@
# Script to open a browser to current branch # Script to open a browser to current branch
# Repo formats: # Repo formats:
# ssh git@github.com:richo/gh_pr.git # ssh git@github.com:richoH/gh_pr.git
# http https://richoH@github.com/richo/gh_pr.git # http https://richoH@github.com/richoH/gh_pr.git
# git git://github.com/richo/gh_pr.git # git git://github.com/richoH/gh_pr.git
username=`git config --get github.user` username=`git config --get github.user`

View file

@ -1,7 +0,0 @@
{foreach $foo as $bar}
<a href="{$bar.zig}">{$bar.zag}</a>
<a href="{$bar.zig2}">{$bar.zag2}</a>
<a href="{$bar.zig3}">{$bar.zag3}</a>
{foreachelse}
There were no rows found.
{/foreach}

View file

@ -1,72 +0,0 @@
-- =============================================
-- Author: Morgan Yarbrough
-- Create date: 4/27/2015
-- Description: Test procedure that shows off language features.
-- Includes non-standard folding with region comments using either
-- line comments or block comments (both are demonstrated below).
-- This mode imitates SSMS and it designed to be used with SQL Server theme.
-- =============================================
CREATE PROCEDURE dbo.TestProcedure
--#region parameters
@vint INT = 1
,@vdate DATE = NULL
,@vdatetime DATETIME = DATEADD(dd, 1, GETDATE())
,@vvarchar VARCHAR(MAX) = ''
--#endregion
AS
BEGIN
/*#region set statements */
SET NOCOUNT ON;
SET XACT_ABORT ON;
SET QUOTED_IDENTIFIER ON;
/*#endregion*/
/**
* These comments will produce a fold widget
*/
-- folding demonstration
SET @vint = CASE
WHEN @vdate IS NULL
THEN 1
ELSE 2
END
-- another folding demonstration
IF @vint = 1
BEGIN
SET @vvarchar = 'one'
SET @vint = DATEDIFF(dd, @vdate, @vdatetime)
END
-- this mode handles strings properly
DECLARE @sql NVARCHAR(4000) = N'SELECT TOP(1) OrderID
FROM Orders
WHERE @OrderDate > GETDATE()'
-- this mode is aware of built in stored procedures
EXECUTE sp_executesql @sql
-- demonstrating some syntax highlighting
SELECT Orders.OrderID
,Customers.CompanyName
,DATEFROMPARTS(YEAR(GETDATE()), 1, 1) AS FirstDayOfYear
FROM Orders
INNER JOIN Customers
ON Orders.CustomerID = Customers.CustomerID
WHERE CompanyName NOT LIKE '%something'
OR CompanyName IS NULL
OR CompanyName IN ('bla', 'nothing')
-- this mode includes snippets
-- place your cusor at the end of the line below and trigger auto complete (Ctrl+Space)
createpr
-- SQL Server allows using keywords as object names (not recommended) as long as they are wrapped in brackets
DATABASE -- keyword
[DATABASE] -- not a keyword
END

View file

@ -1,21 +0,0 @@
using Gtk;
int main (string[] args) {
Gtk.init (ref args);
var foo = new MyFoo<string[](), MyBar<string, int>>();
var window = new Window();
window.title = "Hello, World!";
window.border_width = 10;
window.window_position = WindowPosition.CENTER;
window.set_default_size(350, 70);
window.destroy.connect(Gtk.main_quit);
var label = new Label("Hello, World!");
window.add(label);
window.show_all();
Gtk.main();
return 0;
}

View file

@ -53,16 +53,16 @@ require("ace/commands/default_commands").commands.push({
return; return;
} }
var rowCount = 10; var rowCount = 10;
var w = { var w = {
row: row, row: row,
// rowCount: rowCount, // rowCount: rowCount,
fixedWidth: true, fixedWidth: true,
el: dom.createElement("div"), el: dom.createElement("div"),
editor: inlineEditor editor: editor
}; };
var el = w.el; var el = w.el;
el.appendChild(inlineEditor.container); el.appendChild(inlineEditor.container);
if (!editor.session.widgetManager) { if (!editor.session.widgetManager) {
editor.session.widgetManager = new LineWidgets(editor.session); editor.session.widgetManager = new LineWidgets(editor.session);
@ -96,6 +96,9 @@ require("ace/commands/default_commands").commands.push({
editor.keyBinding.addKeyboardHandler(kb); editor.keyBinding.addKeyboardHandler(kb);
inlineEditor.keyBinding.addKeyboardHandler(kb); inlineEditor.keyBinding.addKeyboardHandler(kb);
editor.on("changeSession", function(e) {
w.el.parentNode && w.el.parentNode.removeChild(w.el);
});
inlineEditor.setTheme("ace/theme/solarized_light"); inlineEditor.setTheme("ace/theme/solarized_light");
} }
}); });

View file

@ -116,6 +116,7 @@ exports.singleLineEditor = function(el) {
renderer.setStyle("ace_one-line"); renderer.setStyle("ace_one-line");
var editor = new Editor(renderer); var editor = new Editor(renderer);
new MultiSelect(editor);
editor.session.setUndoManager(new UndoManager()); editor.session.setUndoManager(new UndoManager());
editor.setShowPrintMargin(false); editor.setShowPrintMargin(false);

View file

@ -1,5 +1,5 @@
/** vim: et:ts=4:sw=4:sts=4 /** vim: et:ts=4:sw=4:sts=4
* @license RequireJS 2.1.11+ Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved. * @license RequireJS 2.1.8+ Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license. * Available via the MIT or new BSD license.
* see: http://github.com/jrburke/requirejs for details * see: http://github.com/jrburke/requirejs for details
*/ */
@ -12,7 +12,7 @@ var requirejs, require, define;
(function (global) { (function (global) {
var req, s, head, baseElement, dataMain, src, var req, s, head, baseElement, dataMain, src,
interactiveScript, currentlyAddingScript, mainScript, subPath, interactiveScript, currentlyAddingScript, mainScript, subPath,
version = '2.1.11+', version = '2.1.8+',
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
jsSuffixRegExp = /\.js$/, jsSuffixRegExp = /\.js$/,
@ -22,7 +22,7 @@ var requirejs, require, define;
hasOwn = op.hasOwnProperty, hasOwn = op.hasOwnProperty,
ap = Array.prototype, ap = Array.prototype,
apsp = ap.splice, apsp = ap.splice,
isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document), isBrowser = !!(typeof window !== 'undefined' && navigator && window.document),
isWebWorker = !isBrowser && typeof importScripts !== 'undefined', isWebWorker = !isBrowser && typeof importScripts !== 'undefined',
//PS3 indicates loaded and complete, but need to wait for complete //PS3 indicates loaded and complete, but need to wait for complete
//specifically. Sequence is 'loading', 'loaded', execution, //specifically. Sequence is 'loading', 'loaded', execution,
@ -108,10 +108,7 @@ var requirejs, require, define;
if (source) { if (source) {
eachProp(source, function (value, prop) { eachProp(source, function (value, prop) {
if (force || !hasProp(target, prop)) { if (force || !hasProp(target, prop)) {
if (deepStringMixin && typeof value === 'object' && value && if (deepStringMixin && typeof value !== 'string') {
!isArray(value) && !isFunction(value) &&
!(value instanceof RegExp)) {
if (!target[prop]) { if (!target[prop]) {
target[prop] = {}; target[prop] = {};
} }
@ -141,7 +138,7 @@ var requirejs, require, define;
throw err; throw err;
} }
//Allow getting a global that is expressed in //Allow getting a global that expressed in
//dot notation, like 'a.b.c'. //dot notation, like 'a.b.c'.
function getGlobal(value) { function getGlobal(value) {
if (!value) { if (!value) {
@ -180,7 +177,7 @@ var requirejs, require, define;
if (typeof requirejs !== 'undefined') { if (typeof requirejs !== 'undefined') {
if (isFunction(requirejs)) { if (isFunction(requirejs)) {
//Do not overwrite an existing requirejs instance. //Do not overwrite and existing requirejs instance.
return; return;
} }
cfg = requirejs; cfg = requirejs;
@ -204,7 +201,6 @@ var requirejs, require, define;
waitSeconds: 7, waitSeconds: 7,
baseUrl: './', baseUrl: './',
paths: {}, paths: {},
bundles: {},
pkgs: {}, pkgs: {},
shim: {}, shim: {},
config: {} config: {}
@ -218,7 +214,6 @@ var requirejs, require, define;
defQueue = [], defQueue = [],
defined = {}, defined = {},
urlFetched = {}, urlFetched = {},
bundlesMap = {},
requireCounter = 1, requireCounter = 1,
unnormalizedCounter = 1; unnormalizedCounter = 1;
@ -232,8 +227,8 @@ var requirejs, require, define;
* @param {Array} ary the array of path segments. * @param {Array} ary the array of path segments.
*/ */
function trimDots(ary) { function trimDots(ary) {
var i, part, length = ary.length; var i, part;
for (i = 0; i < length; i++) { for (i = 0; ary[i]; i += 1) {
part = ary[i]; part = ary[i];
if (part === '.') { if (part === '.') {
ary.splice(i, 1); ary.splice(i, 1);
@ -266,7 +261,7 @@ var requirejs, require, define;
* @returns {String} normalized name * @returns {String} normalized name
*/ */
function normalize(name, baseName, applyMap) { function normalize(name, baseName, applyMap) {
var pkgMain, mapValue, nameParts, i, j, nameSegment, lastIndex, var pkgName, pkgConfig, mapValue, nameParts, i, j, nameSegment,
foundMap, foundI, foundStarMap, starI, foundMap, foundI, foundStarMap, starI,
baseParts = baseName && baseName.split('/'), baseParts = baseName && baseName.split('/'),
normalizedBaseParts = baseParts, normalizedBaseParts = baseParts,
@ -279,26 +274,29 @@ var requirejs, require, define;
//otherwise, assume it is a top-level require that will //otherwise, assume it is a top-level require that will
//be relative to baseUrl in the end. //be relative to baseUrl in the end.
if (baseName) { if (baseName) {
//Convert baseName to array, and lop off the last part, if (getOwn(config.pkgs, baseName)) {
//so that . matches that 'directory' and not name of the baseName's //If the baseName is a package name, then just treat it as one
//module. For instance, baseName of 'one/two/three', maps to //name to concat the name with.
//'one/two/three.js', but we want the directory, 'one/two' for normalizedBaseParts = baseParts = [baseName];
//this normalization. } else {
normalizedBaseParts = baseParts.slice(0, baseParts.length - 1); //Convert baseName to array, and lop off the last part,
name = name.split('/'); //so that . matches that 'directory' and not name of the baseName's
lastIndex = name.length - 1; //module. For instance, baseName of 'one/two/three', maps to
//'one/two/three.js', but we want the directory, 'one/two' for
// If wanting node ID compatibility, strip .js from end //this normalization.
// of IDs. Have to do this here, and not in nameToUrl normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
// because node allows either .js or non .js to map
// to same file.
if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
} }
name = normalizedBaseParts.concat(name); name = normalizedBaseParts.concat(name.split('/'));
trimDots(name); trimDots(name);
//Some use of packages may use a . path to reference the
//'main' module name, so normalize for that.
pkgConfig = getOwn(config.pkgs, (pkgName = name[0]));
name = name.join('/'); name = name.join('/');
if (pkgConfig && name === pkgName + '/' + pkgConfig.main) {
name = pkgName;
}
} else if (name.indexOf('./') === 0) { } else if (name.indexOf('./') === 0) {
// No baseName, so this is ID is resolved relative // No baseName, so this is ID is resolved relative
// to baseUrl, pull off the leading dot. // to baseUrl, pull off the leading dot.
@ -310,7 +308,7 @@ var requirejs, require, define;
if (applyMap && map && (baseParts || starMap)) { if (applyMap && map && (baseParts || starMap)) {
nameParts = name.split('/'); nameParts = name.split('/');
outerLoop: for (i = nameParts.length; i > 0; i -= 1) { for (i = nameParts.length; i > 0; i -= 1) {
nameSegment = nameParts.slice(0, i).join('/'); nameSegment = nameParts.slice(0, i).join('/');
if (baseParts) { if (baseParts) {
@ -327,12 +325,16 @@ var requirejs, require, define;
//Match, update name to the new value. //Match, update name to the new value.
foundMap = mapValue; foundMap = mapValue;
foundI = i; foundI = i;
break outerLoop; break;
} }
} }
} }
} }
if (foundMap) {
break;
}
//Check for a star map match, but just hold on to it, //Check for a star map match, but just hold on to it,
//if there is a shorter segment match later in a matching //if there is a shorter segment match later in a matching
//config, then favor over this star map. //config, then favor over this star map.
@ -353,11 +355,7 @@ var requirejs, require, define;
} }
} }
// If the name points to a package's name, use return name;
// the package main instead.
pkgMain = getOwn(config.pkgs, name);
return pkgMain ? pkgMain : name;
} }
function removeScript(name) { function removeScript(name) {
@ -375,17 +373,12 @@ var requirejs, require, define;
function hasPathFallback(id) { function hasPathFallback(id) {
var pathConfig = getOwn(config.paths, id); var pathConfig = getOwn(config.paths, id);
if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) { if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) {
removeScript(id);
//Pop off the first array value, since it failed, and //Pop off the first array value, since it failed, and
//retry //retry
pathConfig.shift(); pathConfig.shift();
context.require.undef(id); context.require.undef(id);
context.require([id]);
//Custom require that does not do map translation, since
//ID is "absolute", already mapped/resolved.
context.makeRequire(null, {
skipMap: true
})([id]);
return true; return true;
} }
} }
@ -556,7 +549,7 @@ var requirejs, require, define;
//local var ref to defQueue, so cannot just reassign the one //local var ref to defQueue, so cannot just reassign the one
//on context. //on context.
apsp.apply(defQueue, apsp.apply(defQueue,
[defQueue.length, 0].concat(globalDefQueue)); [defQueue.length - 1, 0].concat(globalDefQueue));
globalDefQueue = []; globalDefQueue = [];
} }
} }
@ -573,7 +566,7 @@ var requirejs, require, define;
mod.usingExports = true; mod.usingExports = true;
if (mod.map.isDefine) { if (mod.map.isDefine) {
if (mod.exports) { if (mod.exports) {
return (defined[mod.map.id] = mod.exports); return mod.exports;
} else { } else {
return (mod.exports = defined[mod.map.id] = {}); return (mod.exports = defined[mod.map.id] = {});
} }
@ -587,9 +580,15 @@ var requirejs, require, define;
id: mod.map.id, id: mod.map.id,
uri: mod.map.url, uri: mod.map.url,
config: function () { config: function () {
return getOwn(config.config, mod.map.id) || {}; var c,
pkg = getOwn(config.pkgs, mod.map.id);
// For packages, only support config targeted
// at the main module.
c = pkg ? getOwn(config.config, mod.map.id + '/' + pkg.main) :
getOwn(config.config, mod.map.id);
return c || {};
}, },
exports: mod.exports || (mod.exports = {}) exports: defined[mod.map.id]
}); });
} }
} }
@ -630,7 +629,7 @@ var requirejs, require, define;
} }
function checkLoaded() { function checkLoaded() {
var err, usingPathFallback, var map, modId, err, usingPathFallback,
waitInterval = config.waitSeconds * 1000, waitInterval = config.waitSeconds * 1000,
//It is possible to disable the wait interval by using waitSeconds of 0. //It is possible to disable the wait interval by using waitSeconds of 0.
expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(), expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
@ -648,8 +647,8 @@ var requirejs, require, define;
//Figure out the state of all the modules. //Figure out the state of all the modules.
eachProp(enabledRegistry, function (mod) { eachProp(enabledRegistry, function (mod) {
var map = mod.map, map = mod.map;
modId = map.id; modId = map.id;
//Skip things that are not enabled or in error state. //Skip things that are not enabled or in error state.
if (!mod.enabled) { if (!mod.enabled) {
@ -872,14 +871,17 @@ var requirejs, require, define;
exports = context.execCb(id, factory, depExports, exports); exports = context.execCb(id, factory, depExports, exports);
} }
// Favor return value over exports. If node/cjs in play, if (this.map.isDefine) {
// then will not have a return value anyway. Favor //If setting exports via 'module' is in play,
// module.exports assignment over exports object. //favor that over return value and exports. After that,
if (this.map.isDefine && exports === undefined) { //favor a non-undefined return value over exports use.
cjsModule = this.module; cjsModule = this.module;
if (cjsModule) { if (cjsModule &&
cjsModule.exports !== undefined &&
//Make sure it is not already the exports value
cjsModule.exports !== this.exports) {
exports = cjsModule.exports; exports = cjsModule.exports;
} else if (this.usingExports) { } else if (exports === undefined && this.usingExports) {
//exports already set the defined value. //exports already set the defined value.
exports = this.exports; exports = this.exports;
} }
@ -939,7 +941,6 @@ var requirejs, require, define;
on(pluginMap, 'defined', bind(this, function (plugin) { on(pluginMap, 'defined', bind(this, function (plugin) {
var load, normalizedMap, normalizedMod, var load, normalizedMap, normalizedMod,
bundleId = getOwn(bundlesMap, this.map.id),
name = this.map.name, name = this.map.name,
parentName = this.map.parentMap ? this.map.parentMap.name : null, parentName = this.map.parentMap ? this.map.parentMap.name : null,
localRequire = context.makeRequire(map.parentMap, { localRequire = context.makeRequire(map.parentMap, {
@ -985,14 +986,6 @@ var requirejs, require, define;
return; return;
} }
//If a paths config, then just load that file instead to
//resolve the plugin, as it is built into that paths layer.
if (bundleId) {
this.map.url = context.nameToUrl(bundleId);
this.load();
return;
}
load = bind(this, function (value) { load = bind(this, function (value) {
this.init([], function () { return value; }, null, { this.init([], function () { return value; }, null, {
enabled: true enabled: true
@ -1257,38 +1250,31 @@ var requirejs, require, define;
} }
} }
//Save off the paths since they require special processing, //Save off the paths and packages since they require special processing,
//they are additive. //they are additive.
var shim = config.shim, var pkgs = config.pkgs,
shim = config.shim,
objs = { objs = {
paths: true, paths: true,
bundles: true,
config: true, config: true,
map: true map: true
}; };
eachProp(cfg, function (value, prop) { eachProp(cfg, function (value, prop) {
if (objs[prop]) { if (objs[prop]) {
if (!config[prop]) { if (prop === 'map') {
config[prop] = {}; if (!config.map) {
config.map = {};
}
mixin(config[prop], value, true, true);
} else {
mixin(config[prop], value, true);
} }
mixin(config[prop], value, true, true);
} else { } else {
config[prop] = value; config[prop] = value;
} }
}); });
//Reverse map the bundles
if (cfg.bundles) {
eachProp(cfg.bundles, function (value, prop) {
each(value, function (v) {
if (v !== prop) {
bundlesMap[v] = prop;
}
});
});
}
//Merge shim //Merge shim
if (cfg.shim) { if (cfg.shim) {
eachProp(cfg.shim, function (value, id) { eachProp(cfg.shim, function (value, id) {
@ -1309,25 +1295,29 @@ var requirejs, require, define;
//Adjust packages if necessary. //Adjust packages if necessary.
if (cfg.packages) { if (cfg.packages) {
each(cfg.packages, function (pkgObj) { each(cfg.packages, function (pkgObj) {
var location, name; var location;
pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj; pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj;
name = pkgObj.name;
location = pkgObj.location; location = pkgObj.location;
if (location) {
config.paths[name] = pkgObj.location;
}
//Save pointer to main module ID for pkg name. //Create a brand new object on pkgs, since currentPackages can
//Remove leading dot in main, so main paths are normalized, //be passed in again, and config.pkgs is the internal transformed
//and remove any trailing .js, since different package //state for all package configs.
//envs have different conventions: some use a module name, pkgs[pkgObj.name] = {
//some use a file name. name: pkgObj.name,
config.pkgs[name] = pkgObj.name + '/' + (pkgObj.main || 'main') location: location || pkgObj.name,
.replace(currDirRegExp, '') //Remove leading dot in main, so main paths are normalized,
.replace(jsSuffixRegExp, ''); //and remove any trailing .js, since different package
//envs have different conventions: some use a module name,
//some use a file name.
main: (pkgObj.main || 'main')
.replace(currDirRegExp, '')
.replace(jsSuffixRegExp, '')
};
}); });
//Done with modifications, assing packages back to context config
config.pkgs = pkgs;
} }
//If there are any "waiting to execute" modules in the registry, //If there are any "waiting to execute" modules in the registry,
@ -1474,21 +1464,10 @@ var requirejs, require, define;
var map = makeModuleMap(id, relMap, true), var map = makeModuleMap(id, relMap, true),
mod = getOwn(registry, id); mod = getOwn(registry, id);
removeScript(id);
delete defined[id]; delete defined[id];
delete urlFetched[map.url]; delete urlFetched[map.url];
delete undefEvents[id]; delete undefEvents[id];
//Clean queued defines too. Go backwards
//in array so that the splices do not
//mess up the iteration.
eachReverse(defQueue, function(args, i) {
if(args[0] === id) {
defQueue.splice(i, 1);
}
});
if (mod) { if (mod) {
//Hold on to listeners in case the //Hold on to listeners in case the
//module will be attempted to be reloaded //module will be attempted to be reloaded
@ -1508,7 +1487,7 @@ var requirejs, require, define;
/** /**
* Called to enable a module if it is still in the registry * Called to enable a module if it is still in the registry
* awaiting enablement. A second arg, parent, the parent module, * awaiting enablement. A second arg, parent, the parent module,
* is passed in for context, when this method is overridden by * is passed in for context, when this method is overriden by
* the optimizer. Not shown here to keep code compact. * the optimizer. Not shown here to keep code compact.
*/ */
enable: function (depMap) { enable: function (depMap) {
@ -1582,19 +1561,8 @@ var requirejs, require, define;
* internal API, not a public one. Use toUrl for the public API. * internal API, not a public one. Use toUrl for the public API.
*/ */
nameToUrl: function (moduleName, ext, skipExt) { nameToUrl: function (moduleName, ext, skipExt) {
var paths, syms, i, parentModule, url, var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url,
parentPath, bundleId, parentPath;
pkgMain = getOwn(config.pkgs, moduleName);
if (pkgMain) {
moduleName = pkgMain;
}
bundleId = getOwn(bundlesMap, moduleName);
if (bundleId) {
return context.nameToUrl(bundleId, ext, skipExt);
}
//If a colon is in the URL, it indicates a protocol is used and it is just //If a colon is in the URL, it indicates a protocol is used and it is just
//an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?) //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)
@ -1608,6 +1576,7 @@ var requirejs, require, define;
} else { } else {
//A module that needs to be converted to a path. //A module that needs to be converted to a path.
paths = config.paths; paths = config.paths;
pkgs = config.pkgs;
syms = moduleName.split('/'); syms = moduleName.split('/');
//For each module name segment, see if there is a path //For each module name segment, see if there is a path
@ -1615,7 +1584,7 @@ var requirejs, require, define;
//and work up from it. //and work up from it.
for (i = syms.length; i > 0; i -= 1) { for (i = syms.length; i > 0; i -= 1) {
parentModule = syms.slice(0, i).join('/'); parentModule = syms.slice(0, i).join('/');
pkg = getOwn(pkgs, parentModule);
parentPath = getOwn(paths, parentModule); parentPath = getOwn(paths, parentModule);
if (parentPath) { if (parentPath) {
//If an array, it means there are a few choices, //If an array, it means there are a few choices,
@ -1625,6 +1594,16 @@ var requirejs, require, define;
} }
syms.splice(0, i, parentPath); syms.splice(0, i, parentPath);
break; break;
} else if (pkg) {
//If module name is just the package name, then looking
//for the main module.
if (moduleName === pkg.name) {
pkgPath = pkg.location + '/' + pkg.main;
} else {
pkgPath = pkg.location;
}
syms.splice(0, i, pkgPath);
break;
} }
} }
@ -1939,7 +1918,7 @@ var requirejs, require, define;
} }
//Look for a data-main script attribute, which could also adjust the baseUrl. //Look for a data-main script attribute, which could also adjust the baseUrl.
if (isBrowser && !cfg.skipDataMain) { if (isBrowser) {
//Figure out baseUrl. Get it from the script tag with require.js in it. //Figure out baseUrl. Get it from the script tag with require.js in it.
eachReverse(scripts(), function (script) { eachReverse(scripts(), function (script) {
//Set the 'head' where we can append children by //Set the 'head' where we can append children by

View file

@ -46,10 +46,4 @@ body {
position: absolute; position: absolute;
right: 0; right: 0;
border-left: 1px solid; border-left: 1px solid;
} }
/* .ace_text-input {
z-index: 10!important;
opacity: 1!important;
background: rgb(84, 0, 255)!important;
}*/

View file

@ -32,26 +32,25 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var dom = require("ace/lib/dom"); var dom = require("ace/lib/dom");
var oop = require("ace/lib/oop");
var event = require("ace/lib/event"); var event = require("ace/lib/event");
var Range = require("ace/range").Range; var Range = require("ace/range").Range;
var Tooltip = require("ace/tooltip").Tooltip;
function TokenTooltip (editor) { var tooltipNode;
var TokenTooltip = function(editor) {
if (editor.tokenTooltip) if (editor.tokenTooltip)
return; return;
Tooltip.call(this, editor.container); editor.tokenTooltip = this;
editor.tokenTooltip = this;
this.editor = editor; this.editor = editor;
editor.tooltip = tooltipNode || this.$init();
this.update = this.update.bind(this); this.update = this.update.bind(this);
this.onMouseMove = this.onMouseMove.bind(this); this.onMouseMove = this.onMouseMove.bind(this);
this.onMouseOut = this.onMouseOut.bind(this); this.onMouseOut = this.onMouseOut.bind(this);
event.addListener(editor.renderer.scroller, "mousemove", this.onMouseMove); event.addListener(editor.renderer.scroller, "mousemove", this.onMouseMove);
event.addListener(editor.renderer.content, "mouseout", this.onMouseOut); event.addListener(editor.renderer.content, "mouseout", this.onMouseOut);
} };
oop.inherits(TokenTooltip, Tooltip);
(function(){ (function(){
this.token = {}; this.token = {};
@ -87,10 +86,15 @@ oop.inherits(TokenTooltip, Tooltip);
} }
if (!token) { if (!token) {
session.removeMarker(this.marker); session.removeMarker(this.marker);
this.hide(); tooltipNode.style.display = "none";
this.isOpen = false;
return; return;
} }
if (!this.isOpen) {
tooltipNode.style.display = "";
this.isOpen = true;
}
var tokenText = token.type; var tokenText = token.type;
if (token.state) if (token.state)
tokenText += "|" + token.state; tokenText += "|" + token.state;
@ -98,15 +102,15 @@ oop.inherits(TokenTooltip, Tooltip);
tokenText += "\n merge"; tokenText += "\n merge";
if (token.stateTransitions) if (token.stateTransitions)
tokenText += "\n " + token.stateTransitions.join("\n "); tokenText += "\n " + token.stateTransitions.join("\n ");
if (this.tokenText != tokenText) { if (this.tokenText != tokenText) {
this.setText(tokenText); tooltipNode.textContent = tokenText;
this.width = this.getWidth(); this.tooltipWidth = tooltipNode.offsetWidth;
this.height = this.getHeight(); this.tooltipHeight = tooltipNode.offsetHeight;
this.tokenText = tokenText; this.tokenText = tokenText;
} }
this.show(null, this.x, this.y); this.updateTooltipPosition(this.x, this.y);
this.token = token; this.token = token;
session.removeMarker(this.marker); session.removeMarker(this.marker);
@ -119,34 +123,56 @@ oop.inherits(TokenTooltip, Tooltip);
this.y = e.clientY; this.y = e.clientY;
if (this.isOpen) { if (this.isOpen) {
this.lastT = e.timeStamp; this.lastT = e.timeStamp;
this.setPosition(this.x, this.y); this.updateTooltipPosition(this.x, this.y);
} }
if (!this.$timer) if (!this.$timer)
this.$timer = setTimeout(this.update, 100); this.$timer = setTimeout(this.update, 100);
}; };
this.onMouseOut = function(e) { this.onMouseOut = function(e) {
if (e && e.currentTarget.contains(e.relatedTarget)) var t = e && e.relatedTarget;
return; var ct = e && e.currentTarget;
this.hide(); while(t && (t = t.parentNode)) {
if (t == ct)
return;
}
tooltipNode.style.display = "none";
this.editor.session.removeMarker(this.marker); this.editor.session.removeMarker(this.marker);
this.$timer = clearTimeout(this.$timer); this.$timer = clearTimeout(this.$timer);
this.isOpen = false;
};
this.updateTooltipPosition = function(x, y) {
var st = tooltipNode.style;
if (x + 10 + this.tooltipWidth > this.maxWidth)
x = window.innerWidth - this.tooltipWidth - 10;
if (y > window.innerHeight * 0.75 || y + 20 + this.tooltipHeight > this.maxHeight)
y = y - this.tooltipHeight - 30;
st.left = x + 10 + "px";
st.top = y + 20 + "px";
}; };
this.setPosition = function(x, y) { this.$init = function() {
if (x + 10 + this.width > this.maxWidth) tooltipNode = document.documentElement.appendChild(dom.createElement("div"));
x = window.innerWidth - this.width - 10; var st = tooltipNode.style;
if (y > window.innerHeight * 0.75 || y + 20 + this.height > this.maxHeight) st.position = "fixed";
y = y - this.height - 30; st.display = "none";
st.background = "lightyellow";
Tooltip.prototype.setPosition.call(this, x + 10, y + 20); st.borderRadius = "";
st.border = "1px solid gray";
st.padding = "1px";
st.zIndex = 1000;
st.fontFamily = "monospace";
st.whiteSpace = "pre-line";
return tooltipNode;
}; };
this.destroy = function() { this.destroy = function() {
this.onMouseOut(); this.onMouseOut();
event.removeListener(this.editor.renderer.scroller, "mousemove", this.onMouseMove); event.removeListener(this.editor.renderer.scroller, "mousemove", this.onMouseMove);
event.removeListener(this.editor.renderer.content, "mouseout", this.onMouseOut); event.removeListener(this.editor.renderer.content, "mouseout", this.onMouseOut);
delete this.editor.tokenTooltip; delete this.editor.tokenTooltip;
}; };
}).call(TokenTooltip.prototype); }).call(TokenTooltip.prototype);
@ -154,3 +180,4 @@ oop.inherits(TokenTooltip, Tooltip);
exports.TokenTooltip = TokenTooltip; exports.TokenTooltip = TokenTooltip;
}); });

View file

@ -218,7 +218,7 @@ function optgroup(values) {
return values.map(function(item) { return values.map(function(item) {
if (typeof item == "string") if (typeof item == "string")
item = {name: item, caption: item}; item = {name: item, caption: item};
return elt("option", {value: item.value || item.name}, item.caption || item.desc); return elt("option", {value: item.name}, item.caption || item.desc);
}); });
} }

View file

@ -23,27 +23,24 @@
<pre id="editor"></pre> <pre id="editor"></pre>
<script src="kitchen-sink/require.js"></script> <script src="../build/src-noconflict/ace.js"></script>
<script src="../build/src-noconflict/ext-modelist.js"></script>
<script> <script>
// setup paths
require.config({paths: { "ace" : "../lib/ace"}});
// load ace and extensions
require(["ace/ace", "ace/ext/modelist"], function(ace) {
var editor = ace.edit("editor"); var editor = ace.edit("editor");
editor.setTheme("ace/theme/twilight"); editor.setTheme("ace/theme/twilight");
(function () { (function () {
var modelist = ace.require("ace/ext/modelist"); var modelist = ace.require('ace/ext/modelist');
// the file path could come from an xmlhttp request, a drop event, // the file path could come from an xmlhttp request, a drop event,
// or any other scriptable file loading process. // or any other scriptable file loading process.
// Extensions could consume the modelist and use it to dynamically // Extensions could consume the modelist and use it to dynamically
// set the editor mode. Webmasters could use it in their scripts // set the editor mode. Webmasters could use it in their scripts
// for site specific purposes as well. // for site specific purposes as well.
var filePath = "blahblah/weee/some.js"; var filePath = 'blahblah/weee/some.js';
var mode = modelist.getModeForPath(filePath).mode; var mode = modelist.getModeForPath(filePath).mode;
console.log(mode); console.log(mode);
editor.session.setMode(mode); editor.session.setMode(mode);
}()); }());
})
</script> </script>
<script src="./show_own_source.js"></script> <script src="./show_own_source.js"></script>

View file

@ -1,20 +0,0 @@
({
optimize: "none",
preserveLicenseComments: false,
name: "node_modules/almond/almond",
baseUrl: "../../",
paths: {
ace : "lib/ace",
demo: "demo/kitchen-sink"
},
packages: [
],
include: [
"ace/ace"
],
exclude: [
],
out: "./packed.js",
useStrict: true,
wrap: false
})

View file

@ -1,36 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Editor</title>
<link rel="stylesheet" href="../kitchen-sink/styles.css" type="text/css" media="screen" charset="utf-8">
</head>
<body>
<div id="optionsPanel" style="position:absolute;height:100%;width:260px">
<a href="http://c9.io" title="Cloud9 IDE | Your code anywhere, anytime">
<img id="c9-logo" src="../kitchen-sink/logo.png" style="width: 172px;margin: -9px 30px -12px 51px;">
</a>
</div>
<pre id="editor-container">
<div style="color:black; padding: 10px">
demo showing Ace usage with r.js:
install r.js and almond
and run `<code>r.js -o demo/r.js/build.js</code>`
note that you also need ace/build/src to lazy load modes and themes
require("ace/config").set("basePath", "../../build/src");
require("ace/config").set("packaged", true);
<div>
</pre>
<script src="./packed.js" data-ace-base="src" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
require("ace/config").set("basePath", "../../build/src")
require("ace/config").set("packaged", true)
var editor = require("ace/ace").edit("editor-container");
editor.session.setMode("ace/mode/javascript");
// editor.session.setValue("var editor = Ace!")
</script>
</body>
</html>

View file

@ -29,20 +29,14 @@
}</pre> }</pre>
<script src="../demo/kitchen-sink/require.js"></script> <script src="../demo/kitchen-sink/require.js"></script>
<script src="../build/src/ace.js" charset="utf-8"></script>
<script> <script>
require.config({paths: {ace: "../build/src"}}) var editor = ace.edit("editor");
define('testace', ['ace/ace'], editor.setTheme("ace/theme/twilight");
function(ace, langtools) { editor.session.setMode("ace/mode/javascript");
console.log("This is the testace module"); require(["ace/requirejs/text!src/ace"], function(e){
var editor = ace.edit("editor"); editor.setValue(e);
editor.setTheme("ace/theme/twilight"); })
editor.session.setMode("ace/mode/javascript");
require(["ace/requirejs/text!src/ace"], function(e){
editor.setValue(e);
})
}
);
require(['testace'])
</script> </script>
</body> </body>

View file

@ -5,18 +5,19 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Editor</title> <title>Editor</title>
<style type="text/css" media="screen"> <style type="text/css" media="screen">
.ace_editor {
position: relative !important; .ace_editor {
border: 1px solid lightgray; position: relative !important;
margin: auto; border: 1px solid lightgray;
height: 200px; margin: auto;
width: 80%; height: 200px;
} width: 80%;
}
.ace_editor.fullScreen { .ace_editor.fullScreen {
height: auto; height: auto;
width: auto; width: auto;
border: 0; border: 0;
margin: 0; margin: 0;
position: fixed !important; position: fixed !important;
top: 0; top: 0;
@ -24,16 +25,17 @@
left: 0; left: 0;
right: 0; right: 0;
z-index: 10; z-index: 10;
background: white;
} }
.fullScreen { .fullScreen {
overflow: hidden overflow: hidden
} }
.scrollmargin { .scrollmargin {
height: 500px; height: 500px;
text-align: center; text-align: center;
} }
.large-button { .large-button {
color: lightblue; color: lightblue;
@ -54,7 +56,7 @@
<body> <body>
<div class="scrollmargin"> <div class="scrollmargin">
<span onclick="scroll()" class="large-button"> <span onclick="scroll()" class="large-button">
scroll down &dArr; scroll down &dArr;
</span> </span>
</div> </div>
<pre id="editor">function foo(items) { <pre id="editor">function foo(items) {
@ -74,35 +76,28 @@
</div> </div>
<script src="kitchen-sink/require.js"></script> <script src="../build/src/ace.js"></script>
<script> <script>
require.config({paths: { "ace" : "../lib/ace"}});
require(["ace/ace", "ace/ext/themelist"], function(ace) {
var $ = document.getElementById.bind(document); var $ = document.getElementById.bind(document);
var dom = require("ace/lib/dom"); var dom = require("ace/lib/dom");
//add command to all new editor instaces //add command to all new editor instaces
require("ace/commands/default_commands").commands.push({ require("ace/commands/default_commands").commands.push({
name: "Toggle Fullscreen", name: "Toggle Fullscreen",
bindKey: "F11", bindKey: "F11",
exec: function(editor) { exec: function(editor) {
var fullScreen = dom.toggleCssClass(document.body, "fullScreen") dom.toggleCssClass(document.body, "fullScreen")
dom.setCssClass(editor.container, "fullScreen", fullScreen) dom.toggleCssClass(editor.container, "fullScreen")
editor.setAutoScrollEditorIntoView(!fullScreen) editor.setAutoScrollEditorIntoView()
editor.resize() editor.resize()
} }
}) })
// create first editor // create first editor
var editor = ace.edit("editor"); var editor = ace.edit("editor");
editor.setTheme("ace/theme/twilight"); editor.setTheme("ace/theme/twilight");
editor.session.setMode("ace/mode/javascript"); editor.session.setMode("ace/mode/javascript");
editor.renderer.setScrollMargin(10, 10); editor.setAutoScrollEditorIntoView();
editor.setOptions({
// "scrollPastEnd": 0.8,
autoScrollEditorIntoView: true
});
var count = 1; var count = 1;
function add() { function add() {
@ -115,13 +110,12 @@ function add() {
oldEl.parentNode.insertBefore(el, pad.nextSibling) oldEl.parentNode.insertBefore(el, pad.nextSibling)
count++ count++
var theme = themes[Math.floor(themes.length * Math.random() - 1e-5)] var theme = "ace/theme/" + themes[Math.floor(themes.length * Math.random() - 1e-5)]
editor = ace.edit(el) editor = ace.edit(el)
editor.setOptions({ editor.setTheme(theme)
mode: "ace/mode/javascript", editor.session.setMode("ace/mode/javascript")
theme: theme,
autoScrollEditorIntoView: true editor.setAutoScrollEditorIntoView()
})
editor.setValue([ editor.setValue([
"this is editor number: ", count, "\n", "this is editor number: ", count, "\n",
@ -132,6 +126,7 @@ function add() {
scroll() scroll()
} }
function scroll(speed) { function scroll(speed) {
var top = editor.container.getBoundingClientRect().top var top = editor.container.getBoundingClientRect().top
speed = speed || 10 speed = speed || 10
@ -144,11 +139,14 @@ function scroll(speed) {
} }
} }
var themes = require("ace/ext/themelist").themes.map(function(t){return t.theme}); var themes = {
bright: [ "chrome", "clouds", "crimson_editor", "dawn", "dreamweaver", "eclipse", "github",
window.add = add; "solarized_light", "textmate", "tomorrow"],
window.scroll = scroll; dark: [ "clouds_midnight", "cobalt", "idle_fingers", "kr_theme", "merbivore", "merbivore_soft",
}); "mono_industrial", "monokai", "pastel_on_dark", "solarized_dark", "terminal", "tomorrow_night",
"tomorrow_night_blue", "tomorrow_night_bright", "tomorrow_night_eighties", "twilight", "vibrant_ink"]
}
themes = [].concat(themes.bright, themes.dark);
</script> </script>
</body> </body>

View file

@ -23,12 +23,9 @@
<pre id="editor"></pre> <pre id="editor"></pre>
<script src="kitchen-sink/require.js"></script> <script src="../build/src-noconflict/ace.js"></script>
<script src="../build/src-noconflict/ext-settings_menu.js"></script>
<script> <script>
// setup paths
require.config({paths: { "ace" : "../lib/ace"}});
// load ace and extensions
require(["ace/ace", "ace/ext/settings_menu"], function(ace) {
var editor = ace.edit("editor"); var editor = ace.edit("editor");
ace.require('ace/ext/settings_menu').init(editor); ace.require('ace/ext/settings_menu').init(editor);
editor.setTheme("ace/theme/twilight"); editor.setTheme("ace/theme/twilight");
@ -41,7 +38,6 @@ require(["ace/ace", "ace/ext/settings_menu"], function(ace) {
}, },
readOnly: true readOnly: true
}]); }]);
})
</script> </script>
<script src="./show_own_source.js"></script> <script src="./show_own_source.js"></script>

View file

@ -1,16 +1,3 @@
if (typeof ace == "undefined" && typeof require == "undefined") { ace.require("ace/lib/net").get(document.baseURI, function(t){
document.body.innerHTML = "<p style='padding: 20px 50px;'>couldn't find ace.js file, <br>" editor.setValue(t, 1);
+ "to build it run <code>node Makefile.dryice.js full<code>" })
} else if (typeof ace == "undefined" && typeof require != "undefined") {
require(["ace/ace"], setValue)
} else {
require = ace.require;
setValue()
}
function setValue() {
require("ace/lib/net").get(document.baseURI, function(t){
var el = document.getElementById("editor");
el.env.editor.setValue(t, 1);
})
}

View file

@ -1,83 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Static Code highlighter using Ace</title>
<meta name="author" content="Matthew Kastor">
<style type="text/css">
.code {
width: 50%;
white-space: pre-wrap;
border: solid lightgrey 1px
}
</style>
</head>
<body>
<h2>Client Side Syntax Highlighting</h2>
<p>Syntax highlighting using Ace language modes and themes.</p>
<div class="code" ace-mode="ace/mode/css" ace-theme="ace/theme/chrome" ace-gutter="true">
.code {
width: 50%;
white-space: pre-wrap;
border: solid lightgrey 1px
}
</div>
<pre class="code" ace-mode="ace/mode/javascript" ace-theme="ace/theme/twilight">
function wobble (flam) {
return flam.wobbled = true;
}
</pre>
<div class="code" ace-mode="ace/mode/lua" ace-theme="ace/theme/chrome" ace-gutter="true" style="width: 30em;">
--[[--
num_args takes in 5.1 byte code and extracts the number of arguments from its function header.
--]]--
function int(t)
return t:byte(1) + t:byte(2) * 0x100 + t:byte(3) * 0x10000 + t:byte(4) * 0x1000000
end
function num_args(func)
local dump = string.dump(func)
local offset, cursor = int(dump:sub(13)), offset + 26
--Get the params and var flag (whether there's a ... in the param)
return dump:sub(cursor):byte(), dump:sub(cursor+1):byte()
end
</div>
<script src="kitchen-sink/require.js"></script>
<script>
require.config({paths: { "ace" : "../lib/ace"}});
require(["ace/ace", "ace/ext/static_highlight"], function(ace) {
var highlight = ace.require("ace/ext/static_highlight")
var dom = ace.require("ace/lib/dom")
function qsa(sel) {
return Array.apply(null, document.querySelectorAll(sel));
}
qsa(".code").forEach(function (codeEl) {
highlight(codeEl, {
mode: codeEl.getAttribute("ace-mode"),
theme: codeEl.getAttribute("ace-theme"),
startLineNumber: 1,
showGutter: codeEl.getAttribute("ace-gutter"),
trim: true
}, function (highlighted) {
});
});
})
</script>
</body>
</html>

View file

@ -0,0 +1,64 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Static Code highlighter using Ace</title>
<meta name="author" content="Matthew Kastor">
<style type="text/css">
.code {
width: 50%;
position: relative;
white-space: pre-wrap;
}
</style>
</head>
<body>
<h2>Client Side Syntax Highlighting</h2>
<p>Syntax highlighting using Ace language modes and themes.</p>
<div class="code" ace-mode="ace/mode/css" ace-theme="ace/theme/chrome" ace-gutter="true">
.code {
width: 50%;
position: relative;
white-space: pre-wrap;
}
</div>
<pre class="code" ace-mode="ace/mode/javascript" ace-theme="ace/theme/twilight">
function wobble (flam) {
return flam.wobbled = true;
}
// the scrollbars are from overflow auto on .ace_editor.
</pre>
<script src="../../build/src-noconflict/ace.js"></script>
<script src="../../build/src-noconflict/ext-static_highlight.js"></script>
<script>
var highlight = ace.require("ace/ext/static_highlight")
var dom = ace.require("ace/lib/dom")
function qsa(sel) {
return [].slice.call(document.querySelectorAll(sel));
}
qsa(".code").forEach(function (codeEl) {
highlight(codeEl, {
mode: codeEl.getAttribute('ace-mode'),
theme: codeEl.getAttribute('ace-theme'),
startLineNumber: 1,
showGutter: codeEl.getAttribute("ace-gutter"),
trim: true
}, function (highlighted) {
});
});
</script>
</body>
</html>

View file

@ -2,13 +2,15 @@
* Simple node.js server, which generates the synax highlighted version of itself * Simple node.js server, which generates the synax highlighted version of itself
* using the Ace modes and themes on the server and serving a static web page. * using the Ace modes and themes on the server and serving a static web page.
*/ */
// $'
// include ace search path and modules // include ace search path and modules
require("amd-loader"); require("amd-loader");
// load jsdom, which is required by Ace
require("../../lib/ace/test/mockdom");
var http = require("http"); var http = require("http");
var fs = require("fs"); var fs = require("fs");
var resolve = require("path").resolve;
// load the highlighter and the desired mode and theme // load the highlighter and the desired mode and theme
var highlighter = require("../../lib/ace/ext/static_highlight"); var highlighter = require("../../lib/ace/ext/static_highlight");
@ -18,22 +20,15 @@ var theme = require("../../lib/ace/theme/twilight");
var port = process.env.PORT || 2222; var port = process.env.PORT || 2222;
http.createServer(function(req, res) { http.createServer(function(req, res) {
var url = req.url;
var path = /[^#?\x00]*/.exec(url)[0];
var root = resolve(__dirname + "/../../").replace(/\\/g, "/");
path = resolve(root + "/" + path).replace(/\\/g, "/");
if (path.indexOf(root + "/") != 0)
path = __filename;
res.writeHead(200, {"Content-Type": "text/html; charset=utf-8"}); res.writeHead(200, {"Content-Type": "text/html; charset=utf-8"});
fs.readFile(path, "utf8", function(err, data) { fs.readFile(__filename, "utf8", function(err, data) {
if (err) data = err.message;
var highlighted = highlighter.render(data, new JavaScriptMode(), theme); var highlighted = highlighter.render(data, new JavaScriptMode(), theme);
res.end( res.end(
'<html><body>\n' + '<html><body>\n' +
'<style type="text/css" media="screen">\n' + '<style type="text/css" media="screen">\n' +
highlighted.css + highlighted.css +
'</style>\n' + '</style>\n' +
highlighted.html + highlighted.html +
'</body></html>' '</body></html>'
); );
}); });

View file

@ -41,19 +41,15 @@
<pre id="editor"></pre> <pre id="editor"></pre>
<div id="statusBar">ace rocks!</div> <div id="statusBar">ace rocks!</div>
<script src="kitchen-sink/require.js"></script> <script src="../build/src-noconflict/ace.js"></script>
<script src="../build/src-noconflict/ext-statusbar.js"></script>
<script> <script>
// setup paths
require.config({paths: { "ace" : "../lib/ace"}});
// load ace and extensions
require(["ace/ace", "ace/ext/statusbar"], function(ace) {
var editor = ace.edit("editor"); var editor = ace.edit("editor");
var StatusBar = ace.require("ace/ext/statusbar").StatusBar; var StatusBar = ace.require('ace/ext/statusbar').StatusBar;
// create a simple selection status indicator // create a simple selection status indicator
var statusBar = new StatusBar(editor, document.getElementById("statusBar")); var statusBar = new StatusBar(editor, document.getElementById('statusBar'));
editor.setTheme("ace/theme/dawn"); editor.setTheme("ace/theme/dawn");
editor.session.setMode("ace/mode/html"); editor.session.setMode("ace/mode/html");
});
</script> </script>
<script src="./show_own_source.js"></script> <script src="./show_own_source.js"></script>

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View file

@ -1,62 +1,52 @@
var editor; var editor;
var embedded_editor; var embedded_editor;
$(function() { $(function() {
if (typeof ace !== "undefined") { ace.config.set("workerPath", "build/src-min");
ace.config.set("workerPath", "build/src-min"); editor = ace.edit("ace_editor_demo");
editor = ace.edit("ace_editor_demo"); editor.container.style.opacity = "";
editor.container.style.opacity = ""; embedded_editor = ace.edit("embedded_ace_code");
embedded_editor = ace.edit("embedded_ace_code"); embedded_editor.container.style.opacity = "";
embedded_editor.container.style.opacity = ""; editor.session.setMode("ace/mode/javascript");
embedded_editor.session.setMode("ace/mode/html"); embedded_editor.session.setMode("ace/mode/html");
embedded_editor.setAutoScrollEditorIntoView(true);
embedded_editor.setOption("maxLines", 40); editor.setOptions({
maxLines: 30
editor.setOptions({ })
maxLines: 30,
mode: "ace/mode/javascript", ace.config.loadModule("ace/ext/emmet", function() {
autoScrollEditorIntoView: true ace.require("ace/lib/net").loadScript("http://nightwing.github.io/emmet-core/emmet.js", function() {
embedded_editor.setOption("enableEmmet", true);
editor.setOption("enableEmmet", true);
}); });
ace.config.loadModule("ace/ext/emmet", function() { embedded_editor.setOptions({
ace.require("ace/lib/net").loadScript("http://cloud9ide.github.io/emmet-core/emmet.js", function() { enableSnippets: true,
embedded_editor.setOption("enableEmmet", true); enableBasicAutocompletion: true
editor.setOption("enableEmmet", true);
});
}); });
ace.config.loadModule("ace/ext/language_tools", function() {
embedded_editor.setOptions({
enableSnippets: true,
enableBasicAutocompletion: true
});
editor.setOptions({
enableSnippets: true,
enableBasicAutocompletion: true
});
});
} else {
document.body.insertAdjacentHTML("afterbegin", '<div class="bs-docs-example">\
<div class="alert alert-error">\
<button type="button" class="close" data-dismiss="alert">\xd7</button>\
<strong>Oh No!</strong> Couldn\'t load <code>build/src/ace.js</code>.<br>\
You can build it by running <code>node Makefile.dryice.js</code><br>\
Or download older version by running <code>git submodule update --init --recursive</code><br>\
</div>\
</div>');
}
$("ul.menu-list").mousedown(function(e) {
if (e.button === 1) {
e.preventDefault();
}
}); });
ace.config.loadModule("ace/ext/language_tools", function() {
embedded_editor.setOptions({
enableSnippets: true,
enableBasicAutocompletion: true
});
editor.setOptions({
enableSnippets: true,
enableBasicAutocompletion: true
});
});
embedded_editor.setAutoScrollEditorIntoView(true);
editor.setAutoScrollEditorIntoView(true);
$("ul.menu-list li").click(function(e) { $("ul.menu-list li").click(function(e) {
if (e.target.tagName !== "A") { if (e.target.tagName === "LI") {
var href = $(this).find("a").attr("href"); console.log($(this).find("a"));
if (e.button == 1) window.location = $(this).find("a").attr("href");
window.open(href, "_blank"); }
else else if (e.target.tagName === "P" || e.target.tagName === "IMG") {
window.location = href; var anchor = $(e.target).siblings();
window.location = anchor.attr("href");
} }
}); });
@ -147,22 +137,22 @@ $(function() {
}); });
}); });
$(window).on("hashchange", function(e) { $(window).on("hashchange", function(e) {
_gaq.push(['_trackPageview',location.pathname + location.search + location.hash]); _gaq.push(['_trackPageview',location.pathname + location.search + location.hash]);
tabs.each(function() { tabs.each(function() {
var idx = $.bbq.getState("nav") || "about"; var idx = $.bbq.getState("nav") || "about";
var section = e.fragment.split("&")[1] || ""; var section = e.fragment.split("&")[1] || "";
$(this).find(tab_a_selector + "[href='#" + idx + "']").triggerHandler('click'); $(this).find(tab_a_selector + "[href='#" + idx + "']").triggerHandler('click');
// handles dropping in from new link // handles dropping in from new link
var api = $.bbq.getState("api"); var api = $.bbq.getState("api");
if (api) { if (api) {
$(tab_a_selector + "[href='./api/" + api + ".html']").triggerHandler('click'); $(tab_a_selector + "[href='./api/" + api + ".html']").triggerHandler('click');
} }
}); });
}).trigger("hashchange"); }).trigger("hashchange");
highlight(); highlight();
}); });
@ -171,11 +161,7 @@ function highlight() {
var highlighter = ace.require("ace/ext/static_highlight") var highlighter = ace.require("ace/ext/static_highlight")
var dom = ace.require("ace/lib/dom") var dom = ace.require("ace/lib/dom")
function qsa(sel) { function qsa(sel) {
var els = document.querySelectorAll(sel); return [].slice.call(document.querySelectorAll(sel));
var result = [];
for (var i = 0, l = els.length; i < l; i++)
result[i] = els[i];
return result;
} }
qsa("code[class]").forEach(function(el) { qsa("code[class]").forEach(function(el) {

View file

@ -1,59 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="../demo/kitchen-sink/require.js"></script>
<script type="text/javascript">
require.config({
paths: { ace: "../lib/ace" },
waitSeconds: 0
});
</script>
</head>
<body>
<p><button onclick="toggleEditor()">Toggle editor</button></p>
<div id="container"></div>
<script>
var editor;
var counter = 0
function toggleEditor() {
if (!editor) {
var root = document.createElement("div");
root.style.height = "100px";
root.setAttribute("id", "editor");
root.textContent = "function foo(items) {\nvar x = 'All this is syntax highlighted';\nreturn x;\n}";
document.getElementById("container").appendChild(root);
editor = ace.edit(root);
if (counter++ % 2)
editor.setTheme("ace/theme/monokai");
else
editor.setTheme("ace/theme/clouds");
editor.session.setMode("ace/mode/javascript");
} else {
editor.destroy();
var el = editor.container;
el.parentNode.removeChild(el);
editor.container = null
editor.renderer = null
editor = null;
var root = document.getElementById("editor")
if (root)
root.parentNode.removeChild(root);
}
}
require(["ace/ace"], function(ace) {
window.ace = ace;
toggleEditor();
})
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

View file

@ -11,10 +11,16 @@
commit %commit% commit %commit%
--> -->
<link rel="stylesheet" href="demo/kitchen-sink/styles.css" type="text/css" media="screen" charset="utf-8"> <!--DEVEL-->
<script async="true" src="https://use.edgefonts.net/source-code-pro.js"></script> <link rel="stylesheet" href="demo/kitchen-sink/styles.css" type="text/css" media="screen" charset="utf-8">
<script async="true" src="http://use.edgefonts.net/source-code-pro.js"></script>
<!--DEVEL-->
<link href="./doc/site/images/favicon.ico" rel="icon" type="image/x-icon"> <link href="./doc/site/images/favicon.ico" rel="icon" type="image/x-icon">
<!--PACKAGE
<link rel="stylesheet" href="kitchen-sink/styles.css" type="text/css" media="screen" charset="utf-8">
<script async="true" src="http://use.edgefonts.net/source-code-pro.js"></script>
PACKAGE-->
</head> </head>
<body> <body>
<div id="optionsPanel" style="position:absolute;height:100%;width:260px"> <div id="optionsPanel" style="position:absolute;height:100%;width:260px">
@ -57,7 +63,40 @@
<label for="theme">Theme</label> <label for="theme">Theme</label>
</td><td> </td><td>
<select id="theme" size="1"> <select id="theme" size="1">
<optgroup label="Bright">
<option value="ace/theme/chrome">Chrome</option>
<option value="ace/theme/clouds">Clouds</option>
<option value="ace/theme/crimson_editor">Crimson Editor</option>
<option value="ace/theme/dawn">Dawn</option>
<option value="ace/theme/dreamweaver">Dreamweaver</option>
<option value="ace/theme/eclipse">Eclipse</option>
<option value="ace/theme/github">GitHub</option>
<option value="ace/theme/solarized_light">Solarized Light</option>
<option value="ace/theme/textmate" selected="selected">TextMate</option>
<option value="ace/theme/tomorrow">Tomorrow</option>
<option value="ace/theme/xcode">XCode</option>
</optgroup>
<optgroup label="Dark">
<option value="ace/theme/ambiance">Ambiance</option>
<option value="ace/theme/chaos">Chaos</option>
<option value="ace/theme/clouds_midnight">Clouds Midnight</option>
<option value="ace/theme/cobalt">Cobalt</option>
<option value="ace/theme/idle_fingers">idleFingers</option>
<option value="ace/theme/kr_theme">krTheme</option>
<option value="ace/theme/merbivore">Merbivore</option>
<option value="ace/theme/merbivore_soft">Merbivore Soft</option>
<option value="ace/theme/mono_industrial">Mono Industrial</option>
<option value="ace/theme/monokai">Monokai</option>
<option value="ace/theme/pastel_on_dark">Pastel on dark</option>
<option value="ace/theme/solarized_dark">Solarized Dark</option>
<option value="ace/theme/terminal">Terminal</option>
<option value="ace/theme/tomorrow_night">Tomorrow Night</option>
<option value="ace/theme/tomorrow_night_blue">Tomorrow Night Blue</option>
<option value="ace/theme/tomorrow_night_bright">Tomorrow Night Bright</option>
<option value="ace/theme/tomorrow_night_eighties">Tomorrow Night 80s</option>
<option value="ace/theme/twilight">Twilight</option>
<option value="ace/theme/vibrant_ink">Vibrant Ink</option>
</optgroup>
</select> </select>
</td> </td>
</tr> </tr>
@ -257,9 +296,7 @@
<a href="http://ace.c9.io"> <a href="http://ace.c9.io">
<img id="ace-logo" src="doc/site/images/ace-logo.png" style="width: 134px;margin: 46px 0px 4px 66px;"> <img id="ace-logo" src="doc/site/images/ace-logo.png" style="width: 134px;margin: 46px 0px 4px 66px;">
</a> </a>
<div><a target="_test" href="./lib/ace/test/tests.html"
style="color: whitesmoke; text-align: left; padding: 1em;">tests</a>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -283,7 +320,7 @@
<script src="src/ace.js" data-ace-base="src" type="text/javascript" charset="utf-8"></script> <script src="src/ace.js" data-ace-base="src" type="text/javascript" charset="utf-8"></script>
<script src="src/keybinding-vim.js"></script> <script src="src/keybinding-vim.js"></script>
<script src="src/keybinding-emacs.js"></script> <script src="src/keybinding-emacs.js"></script>
<script src="demo/kitchen-sink/demo.js"></script> <script src="kitchen-sink/demo.js"></script>
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
require("kitchen-sink/demo"); require("kitchen-sink/demo");
</script> </script>

View file

@ -46,15 +46,14 @@ var Editor = require("./editor").Editor;
var EditSession = require("./edit_session").EditSession; var EditSession = require("./edit_session").EditSession;
var UndoManager = require("./undomanager").UndoManager; var UndoManager = require("./undomanager").UndoManager;
var Renderer = require("./virtual_renderer").VirtualRenderer; var Renderer = require("./virtual_renderer").VirtualRenderer;
var MultiSelect = require("./multi_select").MultiSelect;
// The following require()s are for inclusion in the built ace file // The following require()s are for inclusion in the built ace file
require("./worker/worker_client"); require("./worker/worker_client");
require("./keyboard/hash_handler"); require("./keyboard/hash_handler");
require("./placeholder"); require("./placeholder");
require("./multi_select");
require("./mode/folding/fold_mode"); require("./mode/folding/fold_mode");
require("./theme/textmate"); require("./theme/textmate");
require("./ext/error_marker");
exports.config = require("./config"); exports.config = require("./config");
@ -74,28 +73,19 @@ exports.require = require;
exports.edit = function(el) { exports.edit = function(el) {
if (typeof(el) == "string") { if (typeof(el) == "string") {
var _id = el; var _id = el;
el = document.getElementById(_id); var el = document.getElementById(_id);
if (!el) if (!el)
throw new Error("ace.edit can't find div #" + _id); throw new Error("ace.edit can't find div #" + _id);
} }
if (el && el.env && el.env.editor instanceof Editor) if (el.env && el.env.editor instanceof Editor)
return el.env.editor; return el.env.editor;
var value = ""; var doc = exports.createEditSession(dom.getInnerText(el));
if (el && /input|textarea/i.test(el.tagName)) { el.innerHTML = '';
var oldNode = el;
value = oldNode.value;
el = dom.createElement("pre");
oldNode.parentNode.replaceChild(el, oldNode);
} else {
value = dom.getInnerText(el);
el.innerHTML = '';
}
var doc = exports.createEditSession(value);
var editor = new Editor(new Renderer(el)); var editor = new Editor(new Renderer(el));
new MultiSelect(editor);
editor.setSession(doc); editor.setSession(doc);
var env = { var env = {
@ -103,13 +93,11 @@ exports.edit = function(el) {
editor: editor, editor: editor,
onResize: editor.resize.bind(editor, null) onResize: editor.resize.bind(editor, null)
}; };
if (oldNode) env.textarea = oldNode;
event.addListener(window, "resize", env.onResize); event.addListener(window, "resize", env.onResize);
editor.on("destroy", function() { editor.on("destroy", function() {
event.removeListener(window, "resize", env.onResize); event.removeListener(window, "resize", env.onResize);
env.editor.container.env = null; // prevent memory leak on old ie
}); });
editor.container.env = editor.env = env; el.env = editor.env = env;
return editor; return editor;
}; };

View file

@ -36,7 +36,7 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter;
/** /**
* *
* Defines a floating pointer in the document. Whenever text is inserted or deleted before the cursor, the position of the anchor 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 * @class Anchor
**/ **/
@ -99,54 +99,69 @@ var Anchor = exports.Anchor = function(doc, row, column) {
* - `value`: An object describing the new Anchor position * - `value`: An object describing the new Anchor position
* *
**/ **/
this.onChange = function(delta) { this.onChange = function(e) {
if (delta.start.row == delta.end.row && delta.start.row != this.row) var delta = e.data;
var range = delta.range;
if (range.start.row == range.end.row && range.start.row != this.row)
return; return;
if (delta.start.row > this.row) if (range.start.row > this.row)
return; return;
var point = $getTransformedPoint(delta, {row: this.row, column: this.column}, this.$insertRight); if (range.start.row == this.row && range.start.column > this.column)
this.setPosition(point.row, point.column, true); return;
var row = this.row;
var column = this.column;
var start = range.start;
var end = range.end;
if (delta.action === "insertText") {
if (start.row === row && start.column <= column) {
if (start.column === column && this.$insertRight) {
// do nothing
} else if (start.row === end.row) {
column += end.column - start.column;
} else {
column -= start.column;
row += end.row - start.row;
}
} else if (start.row !== end.row && start.row < row) {
row += end.row - start.row;
}
} else if (delta.action === "insertLines") {
if (start.row <= row) {
row += end.row - start.row;
}
} else if (delta.action === "removeText") {
if (start.row === row && start.column < column) {
if (end.column >= column)
column = start.column;
else
column = Math.max(0, column - (end.column - start.column));
} else if (start.row !== end.row && start.row < row) {
if (end.row === row)
column = Math.max(0, column - end.column) + start.column;
row -= (end.row - start.row);
} else if (end.row === row) {
row -= end.row - start.row;
column = Math.max(0, column - end.column) + start.column;
}
} else if (delta.action == "removeLines") {
if (start.row <= row) {
if (end.row <= row)
row -= end.row - start.row;
else {
row = start.row;
column = 0;
}
}
}
this.setPosition(row, column, true);
}; };
function $pointsInOrder(point1, point2, equalPointsInOrder) {
var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
}
function $getTransformedPoint(delta, point, moveIfEqual) {
// Get delta info.
var deltaIsInsert = delta.action == "insert";
var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row);
var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
var deltaStart = delta.start;
var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
// DELTA AFTER POINT: No change needed.
if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
return {
row: point.row,
column: point.column
};
}
// DELTA BEFORE POINT: Move point by delta shift.
if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
return {
row: point.row + deltaRowShift,
column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
};
}
// DELTA ENVELOPS POINT (delete only): Move point to delta start.
// TODO warn if delta.action != "remove" ?
return {
row: deltaStart.row,
column: deltaStart.column
};
}
/** /**
* Sets the anchor position to the specified row and column. If `noClip` is `true`, the position is not clipped. * Sets the anchor position to the specified row and column. If `noClip` is `true`, the position is not clipped.
@ -176,14 +191,14 @@ var Anchor = exports.Anchor = function(doc, row, column) {
this.row = pos.row; this.row = pos.row;
this.column = pos.column; this.column = pos.column;
this._signal("change", { this._emit("change", {
old: old, old: old,
value: pos value: pos
}); });
}; };
/** /**
* When called, the `"change"` event listener is removed. * When called, the `'change'` event listener is removed.
* *
**/ **/
this.detach = function() { this.detach = function() {

View file

@ -57,55 +57,20 @@ module.exports = {
doc.insert({row: 1, column: 1}, "123"); doc.insert({row: 1, column: 1}, "123");
assert.position(anchor.getPosition(), 1, 7); assert.position(anchor.getPosition(), 1, 7);
}, },
"test insert text at anchor should not move anchor when insertRight is true": function() {
var doc = new Document("juhu\nkinners");
var anchor = new Anchor(doc, 1, 4);
anchor.$insertRight = true;
doc.insert({row: 1, column: 4}, "123");
assert.position(anchor.getPosition(), 1, 4);
},
"test insert lines before cursor should move anchor row": function() { "test insert lines before cursor should move anchor row": function() {
var doc = new Document("juhu\nkinners"); var doc = new Document("juhu\nkinners");
var anchor = new Anchor(doc, 1, 4); var anchor = new Anchor(doc, 1, 4);
doc.insertFullLines(1, ["123", "456"]); doc.insertLines(1, ["123", "456"]);
assert.position(anchor.getPosition(), 3, 4); assert.position(anchor.getPosition(), 3, 4);
}, },
"test insert lines at anchor position should move anchor down": function() {
var doc = new Document("juhu\nkinners");
var anchor = new Anchor(doc, 1, 0);
doc.insertLines(1, ["line"]);
assert.position(anchor.getPosition(), 2, 0);
},
"test insert lines at anchor position should not move anchor down when insertRight is true and column is 0": function() {
var doc = new Document("juhu\nkinners");
var anchor = new Anchor(doc, 1, 0);
anchor.$insertRight = true;
doc.insertLines(1, ["line"]);
assert.position(anchor.getPosition(), 1, 0);
},
"test insert lines at anchor row should move anchor down when column > 0": function() {
var doc = new Document("juhu\nkinners");
var anchor = new Anchor(doc, 1, 2);
anchor.$insertRight = true;
doc.insertLines(1, ["line"]);
assert.position(anchor.getPosition(), 2, 2);
},
"test insert new line before cursor should move anchor column": function() { "test insert new line before cursor should move anchor column": function() {
var doc = new Document("juhu\nkinners"); var doc = new Document("juhu\nkinners");
var anchor = new Anchor(doc, 1, 4); var anchor = new Anchor(doc, 1, 4);
doc.insertMergedLines({row: 0, column: 0}, ['', '']); doc.insertNewLine({row: 0, column: 0});
assert.position(anchor.getPosition(), 2, 4); assert.position(anchor.getPosition(), 2, 4);
}, },
@ -113,7 +78,7 @@ module.exports = {
var doc = new Document("juhu\nkinners"); var doc = new Document("juhu\nkinners");
var anchor = new Anchor(doc, 1, 4); var anchor = new Anchor(doc, 1, 4);
doc.insertMergedLines({row: 1, column: 2}, ['', '']); doc.insertNewLine({row: 1, column: 2});
assert.position(anchor.getPosition(), 2, 2); assert.position(anchor.getPosition(), 2, 2);
}, },
@ -145,7 +110,7 @@ module.exports = {
var doc = new Document("juhu\n1\n2\nkinners"); var doc = new Document("juhu\n1\n2\nkinners");
var anchor = new Anchor(doc, 3, 4); var anchor = new Anchor(doc, 3, 4);
doc.removeFullLines(1, 2); doc.removeLines(1, 2);
assert.position(anchor.getPosition(), 1, 4); assert.position(anchor.getPosition(), 1, 4);
}, },
@ -169,7 +134,7 @@ module.exports = {
var doc = new Document("juhu\nkinners\n123"); var doc = new Document("juhu\nkinners\n123");
var anchor = new Anchor(doc, 1, 5); var anchor = new Anchor(doc, 1, 5);
doc.removeFullLines(1, 1); doc.removeLines(1, 1);
assert.position(anchor.getPosition(), 1, 0); assert.position(anchor.getPosition(), 1, 0);
}, },
@ -208,9 +173,9 @@ module.exports = {
var doc = new Document("juhu\nkinners\n123"); var doc = new Document("juhu\nkinners\n123");
var anchor = new Anchor(doc, 2, 4); var anchor = new Anchor(doc, 2, 4);
doc.removeFullLines(0, 3); doc.removeLines(0, 3);
assert.position(anchor.getPosition(), 0, 0); assert.position(anchor.getPosition(), 0, 0);
doc.insertFullLines(0, ["a", "b", "c"]); doc.insertLines(0, ["a", "b", "c"]);
assert.position(anchor.getPosition(), 3, 0); assert.position(anchor.getPosition(), 3, 0);
assert.equal(doc.getValue(), "a\nb\nc\n"); assert.equal(doc.getValue(), "a\nb\nc\n");
} }

View file

@ -1,108 +0,0 @@
/* ***** 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 ***** */
define(function(require, exports, module) {
"use strict";
function throwDeltaError(delta, errorText){
console.log("Invalid Delta:", delta);
throw "Invalid Delta: " + errorText;
}
function positionInDocument(docLines, position) {
return position.row >= 0 && position.row < docLines.length &&
position.column >= 0 && position.column <= docLines[position.row].length;
}
function validateDelta(docLines, delta) {
// Validate action string.
if (delta.action != "insert" && delta.action != "remove")
throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
// Validate lines type.
if (!(delta.lines instanceof Array))
throwDeltaError(delta, "delta.lines must be an Array");
// Validate range type.
if (!delta.start || !delta.end)
throwDeltaError(delta, "delta.start/end must be an present");
// Validate that the start point is contained in the document.
var start = delta.start;
if (!positionInDocument(docLines, delta.start))
throwDeltaError(delta, "delta.start must be contained in document");
// Validate that the end point is contained in the document (remove deltas only).
var end = delta.end;
if (delta.action == "remove" && !positionInDocument(docLines, end))
throwDeltaError(delta, "delta.end must contained in document for 'remove' actions");
// Validate that the .range size matches the .lines size.
var numRangeRows = end.row - start.row;
var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0));
if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars)
throwDeltaError(delta, "delta.range must match delta lines");
}
exports.applyDelta = function(docLines, delta, doNotValidate) {
// disabled validation since it breaks autocompletion popup
// if (!doNotValidate)
// validateDelta(docLines, delta);
var row = delta.start.row;
var startColumn = delta.start.column;
var line = docLines[row] || "";
switch (delta.action) {
case "insert":
var lines = delta.lines;
if (lines.length === 1) {
docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
} else {
var args = [row, 1].concat(delta.lines);
docLines.splice.apply(docLines, args);
docLines[row] = line.substring(0, startColumn) + docLines[row];
docLines[row + delta.lines.length - 1] += line.substring(startColumn);
}
break;
case "remove":
var endColumn = delta.end.column;
var endRow = delta.end.row;
if (row === endRow) {
docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
} else {
docLines.splice(
row, endRow - row + 1,
line.substring(0, startColumn) + docLines[endRow].substring(endColumn)
);
}
break;
}
}
});

View file

@ -36,14 +36,9 @@ var AcePopup = require("./autocomplete/popup").AcePopup;
var util = require("./autocomplete/util"); var util = require("./autocomplete/util");
var event = require("./lib/event"); var event = require("./lib/event");
var lang = require("./lib/lang"); var lang = require("./lib/lang");
var dom = require("./lib/dom");
var snippetManager = require("./snippets").snippetManager; var snippetManager = require("./snippets").snippetManager;
var Autocomplete = function() { var Autocomplete = function() {
this.autoInsert = false;
this.autoSelect = true;
this.exactMatch = false;
this.gatherCompletionsId = 0;
this.keyboardHandler = new HashHandler(); this.keyboardHandler = new HashHandler();
this.keyboardHandler.bindKeys(this.commands); this.keyboardHandler.bindKeys(this.commands);
@ -51,31 +46,19 @@ var Autocomplete = function() {
this.changeListener = this.changeListener.bind(this); this.changeListener = this.changeListener.bind(this);
this.mousedownListener = this.mousedownListener.bind(this); this.mousedownListener = this.mousedownListener.bind(this);
this.mousewheelListener = this.mousewheelListener.bind(this); this.mousewheelListener = this.mousewheelListener.bind(this);
this.changeTimer = lang.delayedCall(function() { this.changeTimer = lang.delayedCall(function() {
this.updateCompletions(true); this.updateCompletions(true);
}.bind(this)); }.bind(this))
this.tooltipTimer = lang.delayedCall(this.updateDocTooltip.bind(this), 50);
}; };
(function() { (function() {
this.$init = function() { this.$init = function() {
this.popup = new AcePopup(document.body || document.documentElement); this.popup = new AcePopup(document.body || document.documentElement);
this.popup.on("click", function(e) { this.popup.on("click", function(e) {
this.insertMatch(); this.insertMatch();
e.stop(); e.stop();
}.bind(this)); }.bind(this));
this.popup.focus = this.editor.focus.bind(this.editor);
this.popup.on("show", this.tooltipTimer.bind(null, null));
this.popup.on("select", this.tooltipTimer.bind(null, null));
this.popup.on("changeHoverMarker", this.tooltipTimer.bind(null, null));
return this.popup;
};
this.getPopup = function() {
return this.popup || this.$init();
}; };
this.openPopup = function(editor, prefix, keepPopupPosition) { this.openPopup = function(editor, prefix, keepPopupPosition) {
@ -84,45 +67,35 @@ var Autocomplete = function() {
this.popup.setData(this.completions.filtered); this.popup.setData(this.completions.filtered);
editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
var renderer = editor.renderer; var renderer = editor.renderer;
this.popup.setRow(this.autoSelect ? 0 : -1);
if (!keepPopupPosition) { if (!keepPopupPosition) {
this.popup.setTheme(editor.getTheme());
this.popup.setFontSize(editor.getFontSize()); this.popup.setFontSize(editor.getFontSize());
var lineHeight = renderer.layerConfig.lineHeight; var lineHeight = renderer.layerConfig.lineHeight;
var pos = renderer.$cursorLayer.getPixelPosition(this.base, true); var pos = renderer.$cursorLayer.getPixelPosition(this.base, true);
pos.left -= this.popup.getTextLeftOffset(); pos.left -= this.popup.getTextLeftOffset();
var rect = editor.container.getBoundingClientRect(); var rect = editor.container.getBoundingClientRect();
pos.top += rect.top - renderer.layerConfig.offset; pos.top += rect.top - renderer.layerConfig.offset;
pos.left += rect.left - editor.renderer.scrollLeft; pos.left += rect.left;
pos.left += renderer.gutterWidth; pos.left += renderer.$gutterLayer.gutterWidth;
this.popup.show(pos, lineHeight); this.popup.show(pos, lineHeight);
} else if (keepPopupPosition && !prefix) {
this.detach();
} }
}; };
this.detach = function() { this.detach = function() {
this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler); this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler);
this.editor.off("changeSelection", this.changeListener); this.editor.off("changeSelection", this.changeListener);
this.editor.off("blur", this.blurListener); this.editor.off("blur", this.changeListener);
this.editor.off("mousedown", this.mousedownListener); this.editor.off("mousedown", this.mousedownListener);
this.editor.off("mousewheel", this.mousewheelListener); this.editor.off("mousewheel", this.mousewheelListener);
this.changeTimer.cancel(); this.changeTimer.cancel();
this.hideDocTooltip();
if (this.popup)
this.gatherCompletionsId += 1;
if (this.popup && this.popup.isOpen)
this.popup.hide(); this.popup.hide();
if (this.base)
this.base.detach();
this.activated = false; this.activated = false;
this.completions = this.base = null; this.completions = this.base = null;
}; };
@ -138,18 +111,9 @@ var Autocomplete = function() {
this.detach(); this.detach();
}; };
this.blurListener = function(e) { this.blurListener = function() {
// we have to check if activeElement is a child of popup because if (document.activeElement != this.editor.textInput.getElement())
// on IE preventDefault doesn't stop scrollbar from being focussed
var el = document.activeElement;
var text = this.editor.textInput.getElement();
var fromTooltip = e.relatedTarget && e.relatedTarget == this.tooltipNode;
var container = this.popup && this.popup.container;
if (el != text && el.parentNode != container && !fromTooltip
&& el != this.tooltipNode && e.relatedTarget != text
) {
this.detach(); this.detach();
}
}; };
this.mousedownListener = function(e) { this.mousedownListener = function(e) {
@ -165,7 +129,7 @@ var Autocomplete = function() {
var max = this.popup.session.getLength() - 1; var max = this.popup.session.getLength() - 1;
switch(where) { switch(where) {
case "up": row = row <= 0 ? max : row - 1; break; case "up": row = row < 0 ? max : row - 1; break;
case "down": row = row >= max ? -1 : row + 1; break; case "down": row = row >= max ? -1 : row + 1; break;
case "start": row = 0; break; case "start": row = 0; break;
case "end": row = max; break; case "end": row = max; break;
@ -179,9 +143,8 @@ var Autocomplete = function() {
data = this.popup.getData(this.popup.getRow()); data = this.popup.getData(this.popup.getRow());
if (!data) if (!data)
return false; return false;
if (data.completer && data.completer.insertMatch) { if (data.completer && data.completer.insertMatch) {
data.completer.insertMatch(this.editor, data); data.completer.insertMatch(this.editor);
} else { } else {
if (this.completions.filterText) { if (this.completions.filterText) {
var ranges = this.editor.selection.getAllRanges(); var ranges = this.editor.selection.getAllRanges();
@ -198,7 +161,6 @@ var Autocomplete = function() {
this.detach(); this.detach();
}; };
this.commands = { this.commands = {
"Up": function(editor) { editor.completer.goTo("up"); }, "Up": function(editor) { editor.completer.goTo("up"); },
"Down": function(editor) { editor.completer.goTo("down"); }, "Down": function(editor) { editor.completer.goTo("down"); },
@ -206,15 +168,10 @@ var Autocomplete = function() {
"Ctrl-Down|Ctrl-End": function(editor) { editor.completer.goTo("end"); }, "Ctrl-Down|Ctrl-End": function(editor) { editor.completer.goTo("end"); },
"Esc": function(editor) { editor.completer.detach(); }, "Esc": function(editor) { editor.completer.detach(); },
"Return": function(editor) { return editor.completer.insertMatch(); }, "Space": function(editor) { editor.completer.detach(); editor.insert(" ");},
"Return": function(editor) { editor.completer.insertMatch(); },
"Shift-Return": function(editor) { editor.completer.insertMatch(true); }, "Shift-Return": function(editor) { editor.completer.insertMatch(true); },
"Tab": function(editor) { "Tab": function(editor) { editor.completer.insertMatch(); },
var result = editor.completer.insertMatch();
if (!result && !editor.tabstopManager)
editor.completer.goTo("down");
else
return result;
},
"PageUp": function(editor) { editor.completer.popup.gotoPageUp(); }, "PageUp": function(editor) { editor.completer.popup.gotoPageUp(); },
"PageDown": function(editor) { editor.completer.popup.gotoPageDown(); } "PageDown": function(editor) { editor.completer.popup.gotoPageDown(); }
@ -223,27 +180,24 @@ var Autocomplete = function() {
this.gatherCompletions = function(editor, callback) { this.gatherCompletions = function(editor, callback) {
var session = editor.getSession(); var session = editor.getSession();
var pos = editor.getCursorPosition(); var pos = editor.getCursorPosition();
var line = session.getLine(pos.row); var line = session.getLine(pos.row);
var prefix = util.retrievePrecedingIdentifier(line, pos.column); var prefix = util.retrievePrecedingIdentifier(line, pos.column);
this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length); this.base = editor.getCursorPosition();
this.base.$insertRight = true; this.base.column -= prefix.length;
var matches = []; var matches = [];
var total = editor.completers.length; util.parForEach(editor.completers, function(completer, next) {
editor.completers.forEach(function(completer, i) {
completer.getCompletions(editor, session, pos, prefix, function(err, results) { completer.getCompletions(editor, session, pos, prefix, function(err, results) {
if (!err) if (!err)
matches = matches.concat(results); matches = matches.concat(results);
// Fetch prefix again, because they may have changed by now next();
var pos = editor.getCursorPosition(); });
var line = session.getLine(pos.row); }, function() {
callback(null, { callback(null, {
prefix: util.retrievePrecedingIdentifier(line, pos.column, results[0] && results[0].identifierRegex), prefix: prefix,
matches: matches, matches: matches
finished: (--total === 0)
});
}); });
}); });
return true; return true;
@ -252,7 +206,7 @@ var Autocomplete = function() {
this.showPopup = function(editor) { this.showPopup = function(editor) {
if (this.editor) if (this.editor)
this.detach(); this.detach();
this.activated = true; this.activated = true;
this.editor = editor; this.editor = editor;
@ -262,14 +216,15 @@ var Autocomplete = function() {
editor.completer = this; editor.completer = this;
} }
editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
editor.on("changeSelection", this.changeListener); editor.on("changeSelection", this.changeListener);
editor.on("blur", this.blurListener); editor.on("blur", this.blurListener);
editor.on("mousedown", this.mousedownListener); editor.on("mousedown", this.mousedownListener);
editor.on("mousewheel", this.mousewheelListener); editor.on("mousewheel", this.mousewheelListener);
this.updateCompletions(); this.updateCompletions();
}; };
this.updateCompletions = function(keepPopupPosition) { this.updateCompletions = function(keepPopupPosition) {
if (keepPopupPosition && this.base && this.completions) { if (keepPopupPosition && this.base && this.completions) {
var pos = this.editor.getCursorPosition(); var pos = this.editor.getCursorPosition();
@ -279,126 +234,33 @@ var Autocomplete = function() {
this.completions.setFilter(prefix); this.completions.setFilter(prefix);
if (!this.completions.filtered.length) if (!this.completions.filtered.length)
return this.detach(); return this.detach();
if (this.completions.filtered.length == 1
&& this.completions.filtered[0].value == prefix
&& !this.completions.filtered[0].snippet)
return this.detach();
this.openPopup(this.editor, prefix, keepPopupPosition); this.openPopup(this.editor, prefix, keepPopupPosition);
return; return;
} }
// Save current gatherCompletions session, session is close when a match is insert
var _id = this.gatherCompletionsId;
this.gatherCompletions(this.editor, function(err, results) { this.gatherCompletions(this.editor, function(err, results) {
// Only detach if result gathering is finished
var detachIfFinished = function() {
if (!results.finished) return;
return this.detach();
}.bind(this);
var prefix = results.prefix;
var matches = results && results.matches; var matches = results && results.matches;
if (!matches || !matches.length) if (!matches || !matches.length)
return detachIfFinished(); return this.detach();
// TODO reenable this when we have proper change tracking
// Wrong prefix or wrong session -> ignore // if (matches.length == 1)
if (prefix.indexOf(results.prefix) !== 0 || _id != this.gatherCompletionsId) // return this.insertMatch(matches[0]);
return;
this.completions = new FilteredList(matches); this.completions = new FilteredList(matches);
this.completions.setFilter(results.prefix);
if (this.exactMatch) if (!this.completions.filtered.length)
this.completions.exactMatch = true; return this.detach();
this.openPopup(this.editor, results.prefix, keepPopupPosition);
this.completions.setFilter(prefix);
var filtered = this.completions.filtered;
// No results
if (!filtered.length)
return detachIfFinished();
// One result equals to the prefix
if (filtered.length == 1 && filtered[0].value == prefix && !filtered[0].snippet)
return detachIfFinished();
// Autoinsert if one result
if (this.autoInsert && filtered.length == 1 && results.finished)
return this.insertMatch(filtered[0]);
this.openPopup(this.editor, prefix, keepPopupPosition);
}.bind(this)); }.bind(this));
}; };
this.cancelContextMenu = function() { this.cancelContextMenu = function() {
this.editor.$mouseHandler.cancelContextMenu(); var stop = function(e) {
}; this.editor.off("nativecontextmenu", stop);
if (e && e.domEvent)
this.updateDocTooltip = function() { event.stopEvent(e.domEvent);
var popup = this.popup; }.bind(this);
var all = popup.data; setTimeout(stop, 10);
var selected = all && (all[popup.getHoveredRow()] || all[popup.getRow()]); this.editor.on("nativecontextmenu", stop);
var doc = null;
if (!selected || !this.editor || !this.popup.isOpen)
return this.hideDocTooltip();
this.editor.completers.some(function(completer) {
if (completer.getDocTooltip)
doc = completer.getDocTooltip(selected);
return doc;
});
if (!doc)
doc = selected;
if (typeof doc == "string")
doc = {docText: doc};
if (!doc || !(doc.docHTML || doc.docText))
return this.hideDocTooltip();
this.showDocTooltip(doc);
};
this.showDocTooltip = function(item) {
if (!this.tooltipNode) {
this.tooltipNode = dom.createElement("div");
this.tooltipNode.className = "ace_tooltip ace_doc-tooltip";
this.tooltipNode.style.margin = 0;
this.tooltipNode.style.pointerEvents = "auto";
this.tooltipNode.tabIndex = -1;
this.tooltipNode.onblur = this.blurListener.bind(this);
}
var tooltipNode = this.tooltipNode;
if (item.docHTML) {
tooltipNode.innerHTML = item.docHTML;
} else if (item.docText) {
tooltipNode.textContent = item.docText;
}
if (!tooltipNode.parentNode)
document.body.appendChild(tooltipNode);
var popup = this.popup;
var rect = popup.container.getBoundingClientRect();
tooltipNode.style.top = popup.container.style.top;
tooltipNode.style.bottom = popup.container.style.bottom;
if (window.innerWidth - rect.right < 320) {
tooltipNode.style.right = window.innerWidth - rect.left + "px";
tooltipNode.style.left = "";
} else {
tooltipNode.style.left = (rect.right + 1) + "px";
tooltipNode.style.right = "";
}
tooltipNode.style.display = "block";
};
this.hideDocTooltip = function() {
this.tooltipTimer.cancel();
if (!this.tooltipNode) return;
var el = this.tooltipNode;
if (!this.editor.isFocused() && document.activeElement == el)
this.editor.focus();
this.tooltipNode = null;
if (el.parentNode)
el.parentNode.removeChild(el);
}; };
}).call(Autocomplete.prototype); }).call(Autocomplete.prototype);
@ -408,20 +270,17 @@ Autocomplete.startCommand = {
exec: function(editor) { exec: function(editor) {
if (!editor.completer) if (!editor.completer)
editor.completer = new Autocomplete(); editor.completer = new Autocomplete();
editor.completer.autoInsert = false;
editor.completer.autoSelect = true;
editor.completer.showPopup(editor); editor.completer.showPopup(editor);
// prevent ctrl-space opening context menu on firefox on mac // needed for firefox on mac
editor.completer.cancelContextMenu(); editor.completer.cancelContextMenu();
}, },
bindKey: "Ctrl-Space|Ctrl-Shift-Space|Alt-Space" bindKey: "Ctrl-Space|Ctrl-Shift-Space|Alt-Space"
}; };
var FilteredList = function(array, filterText) { var FilteredList = function(array, filterText, mutateData) {
this.all = array; this.all = array;
this.filtered = array; this.filtered = array;
this.filterText = filterText || ""; this.filterText = filterText || "";
this.exactMatch = false;
}; };
(function(){ (function(){
this.setFilter = function(str) { this.setFilter = function(str) {
@ -435,16 +294,16 @@ var FilteredList = function(array, filterText) {
matches = matches.sort(function(a, b) { matches = matches.sort(function(a, b) {
return b.exactMatch - a.exactMatch || b.score - a.score; return b.exactMatch - a.exactMatch || b.score - a.score;
}); });
// make unique // make unique
var prev = null; var prev = null;
matches = matches.filter(function(item){ matches = matches.filter(function(item){
var caption = item.snippet || item.caption || item.value; var caption = item.value || item.caption || item.snippet;
if (caption === prev) return false; if (caption === prev) return false;
prev = caption; prev = caption;
return true; return true;
}); });
this.filtered = matches; this.filtered = matches;
}; };
this.filterCompletions = function(items, needle) { this.filterCompletions = function(items, needle) {
@ -458,29 +317,23 @@ var FilteredList = function(array, filterText) {
var matchMask = 0; var matchMask = 0;
var penalty = 0; var penalty = 0;
var index, distance; var index, distance;
// caption char iteration is faster in Chrome but slower in Firefox, so lets use indexOf
if (this.exactMatch) { for (var j = 0; j < needle.length; j++) {
if (needle !== caption.substr(0, needle.length)) // TODO add penalty on case mismatch
var i1 = caption.indexOf(lower[j], lastIndex + 1);
var i2 = caption.indexOf(upper[j], lastIndex + 1);
index = (i1 >= 0) ? ((i2 < 0 || i1 < i2) ? i1 : i2) : i2;
if (index < 0)
continue loop; continue loop;
}else{ distance = index - lastIndex - 1;
// caption char iteration is faster in Chrome but slower in Firefox, so lets use indexOf if (distance > 0) {
for (var j = 0; j < needle.length; j++) { // first char mismatch should be more sensitive
// TODO add penalty on case mismatch if (lastIndex === -1)
var i1 = caption.indexOf(lower[j], lastIndex + 1); penalty += 10;
var i2 = caption.indexOf(upper[j], lastIndex + 1); penalty += distance;
index = (i1 >= 0) ? ((i2 < 0 || i1 < i2) ? i1 : i2) : i2;
if (index < 0)
continue loop;
distance = index - lastIndex - 1;
if (distance > 0) {
// first char mismatch should be more sensitive
if (lastIndex === -1)
penalty += 10;
penalty += distance;
}
matchMask = matchMask | (1 << index);
lastIndex = index;
} }
matchMask = matchMask | (1 << index);
lastIndex = index;
} }
item.matchMask = matchMask; item.matchMask = matchMask;
item.exactMatch = penalty ? 0 : 1; item.exactMatch = penalty ? 0 : 1;

View file

@ -31,6 +31,7 @@
define(function(require, exports, module) { define(function(require, exports, module) {
"use strict"; "use strict";
var EditSession = require("../edit_session").EditSession;
var Renderer = require("../virtual_renderer").VirtualRenderer; var Renderer = require("../virtual_renderer").VirtualRenderer;
var Editor = require("../editor").Editor; var Editor = require("../editor").Editor;
var Range = require("../range").Range; var Range = require("../range").Range;
@ -42,7 +43,7 @@ var $singleLineEditor = function(el) {
var renderer = new Renderer(el); var renderer = new Renderer(el);
renderer.$maxLines = 4; renderer.$maxLines = 4;
var editor = new Editor(renderer); var editor = new Editor(renderer);
editor.setHighlightActiveLine(false); editor.setHighlightActiveLine(false);
@ -51,7 +52,6 @@ var $singleLineEditor = function(el) {
editor.renderer.setHighlightGutterLine(false); editor.renderer.setHighlightGutterLine(false);
editor.$mouseHandler.$focusWaitTimout = 0; editor.$mouseHandler.$focusWaitTimout = 0;
editor.$highlightTagPending = true;
return editor; return editor;
}; };
@ -59,15 +59,14 @@ var $singleLineEditor = function(el) {
var AcePopup = function(parentNode) { var AcePopup = function(parentNode) {
var el = dom.createElement("div"); var el = dom.createElement("div");
var popup = new $singleLineEditor(el); var popup = new $singleLineEditor(el);
if (parentNode) if (parentNode)
parentNode.appendChild(el); parentNode.appendChild(el);
el.style.display = "none"; el.style.display = "none";
popup.renderer.content.style.cursor = "default"; popup.renderer.content.style.cursor = "default";
popup.renderer.setStyle("ace_autocomplete"); popup.renderer.setStyle("ace_autocomplete");
popup.setOption("displayIndentGuides", false); popup.setOption("displayIndentGuides", false);
popup.setOption("dragDelay", 150);
var noop = function(){}; var noop = function(){};
@ -87,7 +86,8 @@ var AcePopup = function(parentNode) {
popup.on("mousedown", function(e) { popup.on("mousedown", function(e) {
var pos = e.getDocumentPosition(); var pos = e.getDocumentPosition();
popup.selection.moveToPosition(pos); popup.moveCursorToPosition(pos);
popup.selection.clearSelection();
selectionMarker.start.row = selectionMarker.end.row = pos.row; selectionMarker.start.row = selectionMarker.end.row = pos.row;
e.stop(); e.stop();
}); });
@ -103,7 +103,7 @@ var AcePopup = function(parentNode) {
popup.session.removeMarker(hoverMarker.id); popup.session.removeMarker(hoverMarker.id);
hoverMarker.id = null; hoverMarker.id = null;
} }
}; }
popup.setSelectOnHover(false); popup.setSelectOnHover(false);
popup.on("mousemove", function(e) { popup.on("mousemove", function(e) {
if (!lastMouseEvent) { if (!lastMouseEvent) {
@ -155,11 +155,11 @@ var AcePopup = function(parentNode) {
popup.getHoveredRow = function() { popup.getHoveredRow = function() {
return hoverMarker.start.row; return hoverMarker.start.row;
}; };
event.addListener(popup.container, "mouseout", hideHoverMarker); event.addListener(popup.container, "mouseout", hideHoverMarker);
popup.on("hide", hideHoverMarker); popup.on("hide", hideHoverMarker);
popup.on("changeSelection", hideHoverMarker); popup.on("changeSelection", hideHoverMarker);
popup.session.doc.getLength = function() { popup.session.doc.getLength = function() {
return popup.data.length; return popup.data.length;
}; };
@ -171,15 +171,15 @@ var AcePopup = function(parentNode) {
}; };
var bgTokenizer = popup.session.bgTokenizer; var bgTokenizer = popup.session.bgTokenizer;
bgTokenizer.$tokenizeRow = function(row) { bgTokenizer.$tokenizeRow = function(i) {
var data = popup.data[row]; var data = popup.data[i];
var tokens = []; var tokens = [];
if (!data) if (!data)
return tokens; return tokens;
if (typeof data == "string") if (typeof data == "string")
data = {value: data}; data = {value: data};
if (!data.caption) if (!data.caption)
data.caption = data.value || data.name; data.caption = data.value;
var last = -1; var last = -1;
var flag, c; var flag, c;
@ -196,32 +196,26 @@ var AcePopup = function(parentNode) {
if (data.meta) { if (data.meta) {
var maxW = popup.renderer.$size.scrollerWidth / popup.renderer.layerConfig.characterWidth; var maxW = popup.renderer.$size.scrollerWidth / popup.renderer.layerConfig.characterWidth;
var metaData = data.meta; if (data.meta.length + data.caption.length < maxW - 2)
if (metaData.length + data.caption.length > maxW - 2) { tokens.push({type: "rightAlignedText", value: data.meta});
// trim meta to fit this popup and add ellipsis
metaData = metaData.substr(0, maxW - data.caption.length - 3) + "\u2026"
}
tokens.push({type: "rightAlignedText", value: metaData});
} }
return tokens; return tokens;
}; };
bgTokenizer.$updateOnChange = noop; bgTokenizer.$updateOnChange = noop;
bgTokenizer.start = noop; bgTokenizer.start = noop;
popup.session.$computeWidth = function() { popup.session.$computeWidth = function() {
return this.screenWidth = 0; return this.screenWidth = 0;
}; }
popup.$blockScrolling = Infinity;
// public // public
popup.isOpen = false; popup.isOpen = false;
popup.isTopdown = false; popup.isTopdown = false;
popup.data = []; popup.data = [];
popup.setData = function(list) { popup.setData = function(list) {
popup.setValue(lang.stringRepeat("\n", list.length), -1);
popup.data = list || []; popup.data = list || [];
popup.setValue(lang.stringRepeat("\n", list.length), -1);
popup.setRow(0); popup.setRow(0);
}; };
popup.getData = function(row) { popup.getData = function(row) {
@ -242,11 +236,10 @@ var AcePopup = function(parentNode) {
popup._signal("select"); popup._signal("select");
} }
}; };
popup.on("changeSelection", function() { popup.on("changeSelection", function() {
if (popup.isOpen) if (popup.isOpen)
popup.setRow(popup.selection.lead.row); popup.setRow(popup.selection.lead.row);
popup.renderer.scrollCursorIntoView();
}); });
popup.hide = function() { popup.hide = function() {
@ -257,7 +250,6 @@ var AcePopup = function(parentNode) {
popup.show = function(pos, lineHeight, topdownOnly) { popup.show = function(pos, lineHeight, topdownOnly) {
var el = this.container; var el = this.container;
var screenHeight = window.innerHeight; var screenHeight = window.innerHeight;
var screenWidth = window.innerWidth;
var renderer = this.renderer; var renderer = this.renderer;
// var maxLines = Math.min(renderer.$maxLines, this.session.getLength()); // var maxLines = Math.min(renderer.$maxLines, this.session.getLength());
var maxH = renderer.$maxLines * lineHeight * 1.4; var maxH = renderer.$maxLines * lineHeight * 1.4;
@ -273,24 +265,19 @@ var AcePopup = function(parentNode) {
popup.isTopdown = true; popup.isTopdown = true;
} }
el.style.left = pos.left + "px";
el.style.display = ""; el.style.display = "";
this.renderer.$textLayer.checkForSizeChanges(); this.renderer.$textLayer.checkForSizeChanges();
var left = pos.left;
if (left + el.offsetWidth > screenWidth)
left = screenWidth - el.offsetWidth;
el.style.left = left + "px";
this._signal("show"); this._signal("show");
lastMouseEvent = null; lastMouseEvent = null;
popup.isOpen = true; popup.isOpen = true;
}; };
popup.getTextLeftOffset = function() { popup.getTextLeftOffset = function() {
return this.$borderSize + this.renderer.$padding + this.$imageSize; return this.$borderSize + this.renderer.$padding + this.$imageSize;
}; };
popup.$imageSize = 0; popup.$imageSize = 0;
popup.$borderSize = 1; popup.$borderSize = 1;
@ -298,24 +285,19 @@ var AcePopup = function(parentNode) {
}; };
dom.importCssString("\ dom.importCssString("\
.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\ .ace_autocomplete.ace-tm .ace_marker-layer .ace_active-line {\
background-color: #CAD6FA;\ background-color: #CAD6FA;\
z-index: 1;\ z-index: 1;\
}\ }\
.ace_editor.ace_autocomplete .ace_line-hover {\ .ace_autocomplete.ace-tm .ace_line-hover {\
border: 1px solid #abbffe;\ border: 1px solid #abbffe;\
margin-top: -1px;\ margin-top: -1px;\
background: rgba(233,233,253,0.4);\ background: rgba(233,233,253,0.4);\
}\ }\
.ace_editor.ace_autocomplete .ace_line-hover {\ .ace_autocomplete .ace_line-hover {\
position: absolute;\ position: absolute;\
z-index: 2;\ z-index: 2;\
}\ }\
.ace_editor.ace_autocomplete .ace_scroller {\
background: none;\
border: none;\
box-shadow: none;\
}\
.ace_rightAlignedText {\ .ace_rightAlignedText {\
color: gray;\ color: gray;\
display: inline-block;\ display: inline-block;\
@ -324,11 +306,11 @@ dom.importCssString("\
text-align: right;\ text-align: right;\
z-index: -1;\ z-index: -1;\
}\ }\
.ace_editor.ace_autocomplete .ace_completion-highlight{\ .ace_autocomplete .ace_completion-highlight{\
color: #000;\ color: #000;\
text-shadow: 0 0 0.01em;\ text-shadow: 0 0 0.01em;\
}\ }\
.ace_editor.ace_autocomplete {\ .ace_autocomplete {\
width: 280px;\ width: 280px;\
z-index: 200000;\ z-index: 200000;\
background: #fbfbfb;\ background: #fbfbfb;\
@ -341,4 +323,4 @@ dom.importCssString("\
exports.AcePopup = AcePopup; exports.AcePopup = AcePopup;
}); });

View file

@ -29,9 +29,9 @@
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) { define(function(require, exports, module) {
var Range = require("../range").Range; var Range = require("ace/range").Range;
var splitRegex = /[^a-zA-Z_0-9\$\-\u00C0-\u1FFF\u2C00-\uD7FF\w]+/; var splitRegex = /[^a-zA-Z_0-9\$\-]+/;
function getWordIndex(doc, pos) { function getWordIndex(doc, pos) {
var textBefore = doc.getTextRange(Range.fromPoints({row: 0, column:0}, pos)); var textBefore = doc.getTextRange(Range.fromPoints({row: 0, column:0}, pos));
@ -68,11 +68,11 @@ define(function(require, exports, module) {
var wordList = Object.keys(wordScore); var wordList = Object.keys(wordScore);
callback(null, wordList.map(function(word) { callback(null, wordList.map(function(word) {
return { return {
caption: word, name: word,
value: word, value: word,
score: wordScore[word], score: wordScore[word],
meta: "local" meta: "local"
}; };
})); }));
}; };
}); });

View file

@ -43,9 +43,9 @@ exports.parForEach = function(array, fn, callback) {
callback(result, err); callback(result, err);
}); });
} }
}; }
var ID_REGEX = /[a-zA-Z_0-9\$\-\u00A2-\uFFFF]/; var ID_REGEX = /[a-zA-Z_0-9\$-]/;
exports.retrievePrecedingIdentifier = function(text, pos, regex) { exports.retrievePrecedingIdentifier = function(text, pos, regex) {
regex = regex || ID_REGEX; regex = regex || ID_REGEX;
@ -57,7 +57,7 @@ exports.retrievePrecedingIdentifier = function(text, pos, regex) {
break; break;
} }
return buf.reverse().join(""); return buf.reverse().join("");
}; }
exports.retrieveFollowingIdentifier = function(text, pos, regex) { exports.retrieveFollowingIdentifier = function(text, pos, regex) {
regex = regex || ID_REGEX; regex = regex || ID_REGEX;
@ -69,6 +69,6 @@ exports.retrieveFollowingIdentifier = function(text, pos, regex) {
break; break;
} }
return buf; return buf;
}; }
}); });

View file

@ -36,6 +36,8 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter;
/** /**
*
*
* Tokenizes the current [[Document `Document`]] in the background, and caches the tokenized rows for future use. * 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. * If a certain row is changed, everything below that row is re-tokenized.
@ -48,6 +50,8 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter;
* @param {Tokenizer} tokenizer The tokenizer to use * @param {Tokenizer} tokenizer The tokenizer to use
* @param {Editor} editor The editor to associate with * @param {Editor} editor The editor to associate with
* *
*
*
* @constructor * @constructor
**/ **/
@ -68,10 +72,11 @@ var BackgroundTokenizer = function(tokenizer, editor) {
var endLine = -1; var endLine = -1;
var doc = self.doc; var doc = self.doc;
var startLine = currentLine;
while (self.lines[currentLine]) while (self.lines[currentLine])
currentLine++; currentLine++;
var startLine = currentLine;
var len = doc.getLength(); var len = doc.getLength();
var processedLines = 0; var processedLines = 0;
self.running = false; self.running = false;
@ -84,9 +89,10 @@ var BackgroundTokenizer = function(tokenizer, editor) {
// only check every 5 lines // only check every 5 lines
processedLines ++; processedLines ++;
if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) { if ((processedLines % 5 == 0) && (new Date() - workerStart) > 20) {
self.running = setTimeout(self.$worker, 20); self.running = setTimeout(self.$worker, 20);
break; self.currentLine = currentLine;
return;
} }
} }
self.currentLine = currentLine; self.currentLine = currentLine;
@ -144,7 +150,7 @@ var BackgroundTokenizer = function(tokenizer, editor) {
first: firstRow, first: firstRow,
last: lastRow last: lastRow
}; };
this._signal("update", {data: data}); this._emit("update", {data: data});
}; };
/** /**
@ -171,12 +177,13 @@ var BackgroundTokenizer = function(tokenizer, editor) {
} }
this.$updateOnChange = function(delta) { this.$updateOnChange = function(delta) {
var startRow = delta.start.row; var range = delta.range;
var len = delta.end.row - startRow; var startRow = range.start.row;
var len = range.end.row - startRow;
if (len === 0) { if (len === 0) {
this.lines[startRow] = null; this.lines[startRow] = null;
} else if (delta.action == "remove") { } else if (delta.action == "removeText" || delta.action == "removeLines") {
this.lines.splice(startRow, len + 1, null); this.lines.splice(startRow, len + 1, null);
this.states.splice(startRow, len + 1, null); this.states.splice(startRow, len + 1, null);
} else { } else {

View file

@ -75,49 +75,6 @@ module.exports = {
forceTokenize(doc) forceTokenize(doc)
testStates(doc, ["comment_regex_allowed", "start", "no_regex"]) testStates(doc, ["comment_regex_allowed", "start", "no_regex"])
},
"test background tokenizer sends update event" : function() {
var doc = new EditSession([
"/*",
"var",
"juhu",
"*/"
]);
doc.setMode("./mode/javascript");
var updateEvent = null;
doc.bgTokenizer.on("update", function(e) {
updateEvent = e.data;
});
function checkEvent(first, last) {
assert.ok(!updateEvent, "unneccessary update event");
doc.bgTokenizer.running = 1;
doc.bgTokenizer.$worker();
assert.ok(updateEvent);
assert.equal([first, last] + "",
[updateEvent.first, updateEvent.last] + "")
updateEvent = null;
}
forceTokenize(doc);
var comment = "comment_regex_allowed";
testStates(doc, [comment, comment, comment, "start"]);
doc.remove(new Range(0,0,0,2));
testStates(doc, [comment, comment, comment, "start"]);
checkEvent(0, 3);
testStates(doc, ["start", "no_regex", "no_regex", "regex"]);
// insert /* and and press down several times quickly
doc.insert({row:0, column:0}, "/*");
doc.getTokens(0);
doc.getTokens(1);
doc.getTokens(2);
checkEvent(0, 3);
forceTokenize(doc);
testStates(doc, [comment, comment, comment, "start"]);
} }
}; };

View file

@ -2,44 +2,38 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var MultiHashHandler = require("../keyboard/hash_handler").MultiHashHandler; var HashHandler = require("../keyboard/hash_handler").HashHandler;
var EventEmitter = require("../lib/event_emitter").EventEmitter; var EventEmitter = require("../lib/event_emitter").EventEmitter;
/** /**
* @class CommandManager * @class CommandManager
* *
*
**/ **/
/** /**
* new CommandManager(platform, commands) * new CommandManager(platform, commands)
* @param {String} platform Identifier for the platform; must be either `"mac"` or `"win"` * @param {String} platform Identifier for the platform; must be either `'mac'` or `'win'`
* @param {Array} commands A list of commands * @param {Array} commands A list of commands
* *
**/ **/
var CommandManager = function(platform, commands) { var CommandManager = function(platform, commands) {
MultiHashHandler.call(this, commands, platform); HashHandler.call(this, commands, platform);
this.byName = this.commands; this.byName = this.commands;
this.setDefaultHandler("exec", function(e) { this.setDefaultHandler("exec", function(e) {
return e.command.exec(e.editor, e.args || {}); return e.command.exec(e.editor, e.args || {});
}); });
}; };
oop.inherits(CommandManager, MultiHashHandler); oop.inherits(CommandManager, HashHandler);
(function() { (function() {
oop.implement(this, EventEmitter); oop.implement(this, EventEmitter);
this.exec = function(command, editor, args) { this.exec = function(command, editor, args) {
if (Array.isArray(command)) { if (typeof command === 'string')
for (var i = command.length; i--; ) {
if (this.exec(command[i], editor, args)) return true;
}
return false;
}
if (typeof command === "string")
command = this.commands[command]; command = this.commands[command];
if (!command) if (!command)
@ -49,10 +43,10 @@ oop.inherits(CommandManager, MultiHashHandler);
return false; return false;
var e = {editor: editor, command: command, args: args}; var e = {editor: editor, command: command, args: args};
e.returnValue = this._emit("exec", e); var retvalue = this._emit("exec", e);
this._signal("afterExec", e); this._signal("afterExec", e);
return e.returnValue === false ? false : true; return retvalue === false ? false : true;
}; };
this.toggleRecording = function(editor) { this.toggleRecording = function(editor) {

View file

@ -188,7 +188,7 @@ module.exports = {
assert.equal(command, "cm2"); assert.equal(command, "cm2");
var command = this.cm.findKeyCommand(0, "return"); var command = this.cm.findKeyCommand(0, "return");
assert.equal(command + "", ["cm4", "cm3"] + ""); assert.equal(command, "cm3");
} }
}; };

View file

@ -33,7 +33,6 @@ define(function(require, exports, module) {
var lang = require("../lib/lang"); var lang = require("../lib/lang");
var config = require("../config"); var config = require("../config");
var Range = require("../range").Range;
function bindKey(win, mac) { function bindKey(win, mac) {
return {win: win, mac: mac}; return {win: win, mac: mac};
@ -53,26 +52,6 @@ exports.commands = [{
}); });
}, },
readOnly: true readOnly: true
}, {
name: "goToNextError",
bindKey: bindKey("Alt-E", "Ctrl-E"),
exec: function(editor) {
config.loadModule("ace/ext/error_marker", function(module) {
module.showErrorMarker(editor, 1);
});
},
scrollIntoView: "animate",
readOnly: true
}, {
name: "goToPreviousError",
bindKey: bindKey("Alt-Shift-E", "Ctrl-Shift-E"),
exec: function(editor) {
config.loadModule("ace/ext/error_marker", function(module) {
module.showErrorMarker(editor, -1);
});
},
scrollIntoView: "animate",
readOnly: true
}, { }, {
name: "selectall", name: "selectall",
bindKey: bindKey("Ctrl-A", "Command-A"), bindKey: bindKey("Ctrl-A", "Command-A"),
@ -97,33 +76,29 @@ exports.commands = [{
name: "fold", name: "fold",
bindKey: bindKey("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"), bindKey: bindKey("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"),
exec: function(editor) { editor.session.toggleFold(false); }, exec: function(editor) { editor.session.toggleFold(false); },
multiSelectAction: "forEach",
scrollIntoView: "center", scrollIntoView: "center",
readOnly: true readOnly: true
}, { }, {
name: "unfold", name: "unfold",
bindKey: bindKey("Alt-Shift-L|Ctrl-Shift-F1", "Command-Alt-Shift-L|Command-Shift-F1"), bindKey: bindKey("Alt-Shift-L|Ctrl-Shift-F1", "Command-Alt-Shift-L|Command-Shift-F1"),
exec: function(editor) { editor.session.toggleFold(true); }, exec: function(editor) { editor.session.toggleFold(true); },
multiSelectAction: "forEach",
scrollIntoView: "center", scrollIntoView: "center",
readOnly: true readOnly: true
}, { }, {
name: "toggleFoldWidget", name: "toggleFoldWidget",
bindKey: bindKey("F2", "F2"), bindKey: bindKey("F2", "F2"),
exec: function(editor) { editor.session.toggleFoldWidget(); }, exec: function(editor) { editor.session.toggleFoldWidget(); },
multiSelectAction: "forEach",
scrollIntoView: "center", scrollIntoView: "center",
readOnly: true readOnly: true
}, { }, {
name: "toggleParentFoldWidget", name: "toggleParentFoldWidget",
bindKey: bindKey("Alt-F2", "Alt-F2"), bindKey: bindKey("Alt-F2", "Alt-F2"),
exec: function(editor) { editor.session.toggleFoldWidget(true); }, exec: function(editor) { editor.session.toggleFoldWidget(true); },
multiSelectAction: "forEach",
scrollIntoView: "center", scrollIntoView: "center",
readOnly: true readOnly: true
}, { }, {
name: "foldall", name: "foldall",
bindKey: bindKey(null, "Ctrl-Command-Option-0"), bindKey: bindKey("Ctrl-Alt-0", "Ctrl-Command-Option-0"),
exec: function(editor) { editor.session.foldAll(); }, exec: function(editor) { editor.session.foldAll(); },
scrollIntoView: "center", scrollIntoView: "center",
readOnly: true readOnly: true
@ -146,35 +121,11 @@ exports.commands = [{
name: "findnext", name: "findnext",
bindKey: bindKey("Ctrl-K", "Command-G"), bindKey: bindKey("Ctrl-K", "Command-G"),
exec: function(editor) { editor.findNext(); }, exec: function(editor) { editor.findNext(); },
multiSelectAction: "forEach",
scrollIntoView: "center",
readOnly: true readOnly: true
}, { }, {
name: "findprevious", name: "findprevious",
bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"), bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
exec: function(editor) { editor.findPrevious(); }, exec: function(editor) { editor.findPrevious(); },
multiSelectAction: "forEach",
scrollIntoView: "center",
readOnly: true
}, {
name: "selectOrFindNext",
bindKey: bindKey("Alt-K", "Ctrl-G"),
exec: function(editor) {
if (editor.selection.isEmpty())
editor.selection.selectWord();
else
editor.findNext();
},
readOnly: true
}, {
name: "selectOrFindPrevious",
bindKey: bindKey("Alt-Shift-K", "Ctrl-Shift-G"),
exec: function(editor) {
if (editor.selection.isEmpty())
editor.selection.selectWord();
else
editor.findPrevious();
},
readOnly: true readOnly: true
}, { }, {
name: "find", name: "find",
@ -194,29 +145,25 @@ exports.commands = [{
exec: function(editor) { editor.getSelection().selectFileStart(); }, exec: function(editor) { editor.getSelection().selectFileStart(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
readOnly: true, readOnly: true,
scrollIntoView: "animate", group: "fileJump"
aceCommandGroup: "fileJump"
}, { }, {
name: "gotostart", name: "gotostart",
bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"), bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"),
exec: function(editor) { editor.navigateFileStart(); }, exec: function(editor) { editor.navigateFileStart(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
readOnly: true, readOnly: true,
scrollIntoView: "animate", group: "fileJump"
aceCommandGroup: "fileJump"
}, { }, {
name: "selectup", name: "selectup",
bindKey: bindKey("Shift-Up", "Shift-Up"), bindKey: bindKey("Shift-Up", "Shift-Up"),
exec: function(editor) { editor.getSelection().selectUp(); }, exec: function(editor) { editor.getSelection().selectUp(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true readOnly: true
}, { }, {
name: "golineup", name: "golineup",
bindKey: bindKey("Up", "Up|Ctrl-P"), bindKey: bindKey("Up", "Up|Ctrl-P"),
exec: function(editor, args) { editor.navigateUp(args.times); }, exec: function(editor, args) { editor.navigateUp(args.times); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true readOnly: true
}, { }, {
name: "selecttoend", name: "selecttoend",
@ -224,113 +171,97 @@ exports.commands = [{
exec: function(editor) { editor.getSelection().selectFileEnd(); }, exec: function(editor) { editor.getSelection().selectFileEnd(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
readOnly: true, readOnly: true,
scrollIntoView: "animate", group: "fileJump"
aceCommandGroup: "fileJump"
}, { }, {
name: "gotoend", name: "gotoend",
bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"), bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"),
exec: function(editor) { editor.navigateFileEnd(); }, exec: function(editor) { editor.navigateFileEnd(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
readOnly: true, readOnly: true,
scrollIntoView: "animate", group: "fileJump"
aceCommandGroup: "fileJump"
}, { }, {
name: "selectdown", name: "selectdown",
bindKey: bindKey("Shift-Down", "Shift-Down"), bindKey: bindKey("Shift-Down", "Shift-Down"),
exec: function(editor) { editor.getSelection().selectDown(); }, exec: function(editor) { editor.getSelection().selectDown(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true readOnly: true
}, { }, {
name: "golinedown", name: "golinedown",
bindKey: bindKey("Down", "Down|Ctrl-N"), bindKey: bindKey("Down", "Down|Ctrl-N"),
exec: function(editor, args) { editor.navigateDown(args.times); }, exec: function(editor, args) { editor.navigateDown(args.times); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true readOnly: true
}, { }, {
name: "selectwordleft", name: "selectwordleft",
bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"), bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"),
exec: function(editor) { editor.getSelection().selectWordLeft(); }, exec: function(editor) { editor.getSelection().selectWordLeft(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true readOnly: true
}, { }, {
name: "gotowordleft", name: "gotowordleft",
bindKey: bindKey("Ctrl-Left", "Option-Left"), bindKey: bindKey("Ctrl-Left", "Option-Left"),
exec: function(editor) { editor.navigateWordLeft(); }, exec: function(editor) { editor.navigateWordLeft(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true readOnly: true
}, { }, {
name: "selecttolinestart", name: "selecttolinestart",
bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"), bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"),
exec: function(editor) { editor.getSelection().selectLineStart(); }, exec: function(editor) { editor.getSelection().selectLineStart(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true readOnly: true
}, { }, {
name: "gotolinestart", name: "gotolinestart",
bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"), bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"),
exec: function(editor) { editor.navigateLineStart(); }, exec: function(editor) { editor.navigateLineStart(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true readOnly: true
}, { }, {
name: "selectleft", name: "selectleft",
bindKey: bindKey("Shift-Left", "Shift-Left"), bindKey: bindKey("Shift-Left", "Shift-Left"),
exec: function(editor) { editor.getSelection().selectLeft(); }, exec: function(editor) { editor.getSelection().selectLeft(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true readOnly: true
}, { }, {
name: "gotoleft", name: "gotoleft",
bindKey: bindKey("Left", "Left|Ctrl-B"), bindKey: bindKey("Left", "Left|Ctrl-B"),
exec: function(editor, args) { editor.navigateLeft(args.times); }, exec: function(editor, args) { editor.navigateLeft(args.times); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true readOnly: true
}, { }, {
name: "selectwordright", name: "selectwordright",
bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"), bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"),
exec: function(editor) { editor.getSelection().selectWordRight(); }, exec: function(editor) { editor.getSelection().selectWordRight(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true readOnly: true
}, { }, {
name: "gotowordright", name: "gotowordright",
bindKey: bindKey("Ctrl-Right", "Option-Right"), bindKey: bindKey("Ctrl-Right", "Option-Right"),
exec: function(editor) { editor.navigateWordRight(); }, exec: function(editor) { editor.navigateWordRight(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true readOnly: true
}, { }, {
name: "selecttolineend", name: "selecttolineend",
bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"), bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"),
exec: function(editor) { editor.getSelection().selectLineEnd(); }, exec: function(editor) { editor.getSelection().selectLineEnd(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true readOnly: true
}, { }, {
name: "gotolineend", name: "gotolineend",
bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"), bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"),
exec: function(editor) { editor.navigateLineEnd(); }, exec: function(editor) { editor.navigateLineEnd(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true readOnly: true
}, { }, {
name: "selectright", name: "selectright",
bindKey: bindKey("Shift-Right", "Shift-Right"), bindKey: bindKey("Shift-Right", "Shift-Right"),
exec: function(editor) { editor.getSelection().selectRight(); }, exec: function(editor) { editor.getSelection().selectRight(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true readOnly: true
}, { }, {
name: "gotoright", name: "gotoright",
bindKey: bindKey("Right", "Right|Ctrl-F"), bindKey: bindKey("Right", "Right|Ctrl-F"),
exec: function(editor, args) { editor.navigateRight(args.times); }, exec: function(editor, args) { editor.navigateRight(args.times); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true readOnly: true
}, { }, {
name: "selectpagedown", name: "selectpagedown",
@ -377,14 +308,12 @@ exports.commands = [{
bindKey: "Shift-Home", bindKey: "Shift-Home",
exec: function(editor) { editor.getSelection().selectLineStart(); }, exec: function(editor) { editor.getSelection().selectLineStart(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true readOnly: true
}, { }, {
name: "selectlineend", name: "selectlineend",
bindKey: "Shift-End", bindKey: "Shift-End",
exec: function(editor) { editor.getSelection().selectLineEnd(); }, exec: function(editor) { editor.getSelection().selectLineEnd(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true readOnly: true
}, { }, {
name: "togglerecording", name: "togglerecording",
@ -398,38 +327,17 @@ exports.commands = [{
readOnly: true readOnly: true
}, { }, {
name: "jumptomatching", name: "jumptomatching",
bindKey: bindKey("Ctrl-P", "Ctrl-P"), bindKey: bindKey("Ctrl-P", "Ctrl-Shift-P"),
exec: function(editor) { editor.jumpToMatching(); }, exec: function(editor) { editor.jumpToMatching(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
scrollIntoView: "animate",
readOnly: true readOnly: true
}, { }, {
name: "selecttomatching", name: "selecttomatching",
bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"), bindKey: bindKey("Ctrl-Shift-P", null),
exec: function(editor) { editor.jumpToMatching(true); }, exec: function(editor) { editor.jumpToMatching(true); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
scrollIntoView: "animate",
readOnly: true readOnly: true
}, { },
name: "expandToMatching",
bindKey: bindKey("Ctrl-Shift-M", "Ctrl-Shift-M"),
exec: function(editor) { editor.jumpToMatching(true, true); },
multiSelectAction: "forEach",
scrollIntoView: "animate",
readOnly: true
}, {
name: "passKeysToBrowser",
bindKey: bindKey(null, null),
exec: function() {},
passEvent: true,
readOnly: true
}, {
name: "copy",
exec: function(editor) {
// placeholder for replay macro
},
readOnly: true
},
// commands disabled in readOnly mode // commands disabled in readOnly mode
{ {
@ -443,31 +351,21 @@ exports.commands = [{
editor.clearSelection(); editor.clearSelection();
} }
}, },
scrollIntoView: "cursor",
multiSelectAction: "forEach" multiSelectAction: "forEach"
}, {
name: "paste",
exec: function(editor, args) {
editor.$handlePaste(args);
},
scrollIntoView: "cursor"
}, { }, {
name: "removeline", name: "removeline",
bindKey: bindKey("Ctrl-D", "Command-D"), bindKey: bindKey("Ctrl-D", "Command-D"),
exec: function(editor) { editor.removeLines(); }, exec: function(editor) { editor.removeLines(); },
scrollIntoView: "cursor",
multiSelectAction: "forEachLine" multiSelectAction: "forEachLine"
}, { }, {
name: "duplicateSelection", name: "duplicateSelection",
bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"), bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"),
exec: function(editor) { editor.duplicateSelection(); }, exec: function(editor) { editor.duplicateSelection(); },
scrollIntoView: "cursor",
multiSelectAction: "forEach" multiSelectAction: "forEach"
}, { }, {
name: "sortlines", name: "sortlines",
bindKey: bindKey("Ctrl-Alt-S", "Command-Alt-S"), bindKey: bindKey("Ctrl-Alt-S", "Command-Alt-S"),
exec: function(editor) { editor.sortLines(); }, exec: function(editor) { editor.sortLines(); },
scrollIntoView: "selection",
multiSelectAction: "forEachLine" multiSelectAction: "forEachLine"
}, { }, {
name: "togglecomment", name: "togglecomment",
@ -479,19 +377,16 @@ exports.commands = [{
name: "toggleBlockComment", name: "toggleBlockComment",
bindKey: bindKey("Ctrl-Shift-/", "Command-Shift-/"), bindKey: bindKey("Ctrl-Shift-/", "Command-Shift-/"),
exec: function(editor) { editor.toggleBlockComment(); }, exec: function(editor) { editor.toggleBlockComment(); },
multiSelectAction: "forEach", multiSelectAction: "forEach"
scrollIntoView: "selectionPart"
}, { }, {
name: "modifyNumberUp", name: "modifyNumberUp",
bindKey: bindKey("Ctrl-Shift-Up", "Alt-Shift-Up"), bindKey: bindKey("Ctrl-Shift-Up", "Alt-Shift-Up"),
exec: function(editor) { editor.modifyNumber(1); }, exec: function(editor) { editor.modifyNumber(1); },
scrollIntoView: "cursor",
multiSelectAction: "forEach" multiSelectAction: "forEach"
}, { }, {
name: "modifyNumberDown", name: "modifyNumberDown",
bindKey: bindKey("Ctrl-Shift-Down", "Alt-Shift-Down"), bindKey: bindKey("Ctrl-Shift-Down", "Alt-Shift-Down"),
exec: function(editor) { editor.modifyNumber(-1); }, exec: function(editor) { editor.modifyNumber(-1); },
scrollIntoView: "cursor",
multiSelectAction: "forEach" multiSelectAction: "forEach"
}, { }, {
name: "replace", name: "replace",
@ -510,29 +405,24 @@ exports.commands = [{
}, { }, {
name: "copylinesup", name: "copylinesup",
bindKey: bindKey("Alt-Shift-Up", "Command-Option-Up"), bindKey: bindKey("Alt-Shift-Up", "Command-Option-Up"),
exec: function(editor) { editor.copyLinesUp(); }, exec: function(editor) { editor.copyLinesUp(); }
scrollIntoView: "cursor"
}, { }, {
name: "movelinesup", name: "movelinesup",
bindKey: bindKey("Alt-Up", "Option-Up"), bindKey: bindKey("Alt-Up", "Option-Up"),
exec: function(editor) { editor.moveLinesUp(); }, exec: function(editor) { editor.moveLinesUp(); }
scrollIntoView: "cursor"
}, { }, {
name: "copylinesdown", name: "copylinesdown",
bindKey: bindKey("Alt-Shift-Down", "Command-Option-Down"), bindKey: bindKey("Alt-Shift-Down", "Command-Option-Down"),
exec: function(editor) { editor.copyLinesDown(); }, exec: function(editor) { editor.copyLinesDown(); }
scrollIntoView: "cursor"
}, { }, {
name: "movelinesdown", name: "movelinesdown",
bindKey: bindKey("Alt-Down", "Option-Down"), bindKey: bindKey("Alt-Down", "Option-Down"),
exec: function(editor) { editor.moveLinesDown(); }, exec: function(editor) { editor.moveLinesDown(); }
scrollIntoView: "cursor"
}, { }, {
name: "del", name: "del",
bindKey: bindKey("Delete", "Delete|Ctrl-D|Shift-Delete"), bindKey: bindKey("Delete", "Delete|Ctrl-D|Shift-Delete"),
exec: function(editor) { editor.remove("right"); }, exec: function(editor) { editor.remove("right"); },
multiSelectAction: "forEach", multiSelectAction: "forEach"
scrollIntoView: "cursor"
}, { }, {
name: "backspace", name: "backspace",
bindKey: bindKey( bindKey: bindKey(
@ -540,8 +430,7 @@ exports.commands = [{
"Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H" "Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H"
), ),
exec: function(editor) { editor.remove("left"); }, exec: function(editor) { editor.remove("left"); },
multiSelectAction: "forEach", multiSelectAction: "forEach"
scrollIntoView: "cursor"
}, { }, {
name: "cut_or_delete", name: "cut_or_delete",
bindKey: bindKey("Shift-Delete", null), bindKey: bindKey("Shift-Delete", null),
@ -552,32 +441,27 @@ exports.commands = [{
return false; return false;
} }
}, },
multiSelectAction: "forEach", multiSelectAction: "forEach"
scrollIntoView: "cursor"
}, { }, {
name: "removetolinestart", name: "removetolinestart",
bindKey: bindKey("Alt-Backspace", "Command-Backspace"), bindKey: bindKey("Alt-Backspace", "Command-Backspace"),
exec: function(editor) { editor.removeToLineStart(); }, exec: function(editor) { editor.removeToLineStart(); },
multiSelectAction: "forEach", multiSelectAction: "forEach"
scrollIntoView: "cursor"
}, { }, {
name: "removetolineend", name: "removetolineend",
bindKey: bindKey("Alt-Delete", "Ctrl-K"), bindKey: bindKey("Alt-Delete", "Ctrl-K"),
exec: function(editor) { editor.removeToLineEnd(); }, exec: function(editor) { editor.removeToLineEnd(); },
multiSelectAction: "forEach", multiSelectAction: "forEach"
scrollIntoView: "cursor"
}, { }, {
name: "removewordleft", name: "removewordleft",
bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"), bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"),
exec: function(editor) { editor.removeWordLeft(); }, exec: function(editor) { editor.removeWordLeft(); },
multiSelectAction: "forEach", multiSelectAction: "forEach"
scrollIntoView: "cursor"
}, { }, {
name: "removewordright", name: "removewordright",
bindKey: bindKey("Ctrl-Delete", "Alt-Delete"), bindKey: bindKey("Ctrl-Delete", "Alt-Delete"),
exec: function(editor) { editor.removeWordRight(); }, exec: function(editor) { editor.removeWordRight(); },
multiSelectAction: "forEach", multiSelectAction: "forEach"
scrollIntoView: "cursor"
}, { }, {
name: "outdent", name: "outdent",
bindKey: bindKey("Shift-Tab", "Shift-Tab"), bindKey: bindKey("Shift-Tab", "Shift-Tab"),
@ -612,126 +496,27 @@ exports.commands = [{
exec: function(editor, args) { exec: function(editor, args) {
editor.insert(lang.stringRepeat(args.text || "", args.times || 1)); editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
}, },
multiSelectAction: "forEach", multiSelectAction: "forEach"
scrollIntoView: "cursor"
}, { }, {
name: "splitline", name: "splitline",
bindKey: bindKey(null, "Ctrl-O"), bindKey: bindKey(null, "Ctrl-O"),
exec: function(editor) { editor.splitLine(); }, exec: function(editor) { editor.splitLine(); },
multiSelectAction: "forEach", multiSelectAction: "forEach"
scrollIntoView: "cursor"
}, { }, {
name: "transposeletters", name: "transposeletters",
bindKey: bindKey("Ctrl-T", "Ctrl-T"), bindKey: bindKey("Ctrl-T", "Ctrl-T"),
exec: function(editor) { editor.transposeLetters(); }, exec: function(editor) { editor.transposeLetters(); },
multiSelectAction: function(editor) {editor.transposeSelections(1); }, multiSelectAction: function(editor) {editor.transposeSelections(1); }
scrollIntoView: "cursor"
}, { }, {
name: "touppercase", name: "touppercase",
bindKey: bindKey("Ctrl-U", "Ctrl-U"), bindKey: bindKey("Ctrl-U", "Ctrl-U"),
exec: function(editor) { editor.toUpperCase(); }, exec: function(editor) { editor.toUpperCase(); },
multiSelectAction: "forEach", multiSelectAction: "forEach"
scrollIntoView: "cursor"
}, { }, {
name: "tolowercase", name: "tolowercase",
bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"), bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"),
exec: function(editor) { editor.toLowerCase(); }, exec: function(editor) { editor.toLowerCase(); },
multiSelectAction: "forEach", multiSelectAction: "forEach"
scrollIntoView: "cursor"
}, {
name: "expandtoline",
bindKey: bindKey("Ctrl-Shift-L", "Command-Shift-L"),
exec: function(editor) {
var range = editor.selection.getRange();
range.start.column = range.end.column = 0;
range.end.row++;
editor.selection.setRange(range, false);
},
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "joinlines",
bindKey: bindKey(null, null),
exec: function(editor) {
var isBackwards = editor.selection.isBackwards();
var selectionStart = isBackwards ? editor.selection.getSelectionLead() : editor.selection.getSelectionAnchor();
var selectionEnd = isBackwards ? editor.selection.getSelectionAnchor() : editor.selection.getSelectionLead();
var firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length;
var selectedText = editor.session.doc.getTextRange(editor.selection.getRange());
var selectedCount = selectedText.replace(/\n\s*/, " ").length;
var insertLine = editor.session.doc.getLine(selectionStart.row);
for (var i = selectionStart.row + 1; i <= selectionEnd.row + 1; i++) {
var curLine = lang.stringTrimLeft(lang.stringTrimRight(editor.session.doc.getLine(i)));
if (curLine.length !== 0) {
curLine = " " + curLine;
}
insertLine += curLine;
}
if (selectionEnd.row + 1 < (editor.session.doc.getLength() - 1)) {
// Don't insert a newline at the end of the document
insertLine += editor.session.doc.getNewLineCharacter();
}
editor.clearSelection();
editor.session.doc.replace(new Range(selectionStart.row, 0, selectionEnd.row + 2, 0), insertLine);
if (selectedCount > 0) {
// Select the text that was previously selected
editor.selection.moveCursorTo(selectionStart.row, selectionStart.column);
editor.selection.selectTo(selectionStart.row, selectionStart.column + selectedCount);
} else {
// If the joined line had something in it, start the cursor at that something
firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length > firstLineEndCol ? (firstLineEndCol + 1) : firstLineEndCol;
editor.selection.moveCursorTo(selectionStart.row, firstLineEndCol);
}
},
multiSelectAction: "forEach",
readOnly: true
}, {
name: "invertSelection",
bindKey: bindKey(null, null),
exec: function(editor) {
var endRow = editor.session.doc.getLength() - 1;
var endCol = editor.session.doc.getLine(endRow).length;
var ranges = editor.selection.rangeList.ranges;
var newRanges = [];
// If multiple selections don't exist, rangeList will return 0 so replace with single range
if (ranges.length < 1) {
ranges = [editor.selection.getRange()];
}
for (var i = 0; i < ranges.length; i++) {
if (i == (ranges.length - 1)) {
// The last selection must connect to the end of the document, unless it already does
if (!(ranges[i].end.row === endRow && ranges[i].end.column === endCol)) {
newRanges.push(new Range(ranges[i].end.row, ranges[i].end.column, endRow, endCol));
}
}
if (i === 0) {
// The first selection must connect to the start of the document, unless it already does
if (!(ranges[i].start.row === 0 && ranges[i].start.column === 0)) {
newRanges.push(new Range(0, 0, ranges[i].start.row, ranges[i].start.column));
}
} else {
newRanges.push(new Range(ranges[i-1].end.row, ranges[i-1].end.column, ranges[i].start.row, ranges[i].start.column));
}
}
editor.exitMultiSelectMode();
editor.clearSelection();
for(var i = 0; i < newRanges.length; i++) {
editor.selection.addRange(newRanges[i], false);
}
},
readOnly: true,
scrollIntoView: "none"
}]; }];
}); });

View file

@ -69,14 +69,18 @@ exports.iSearchCommands = [{
bindKey: {win: "Ctrl-F", mac: "Command-F"}, bindKey: {win: "Ctrl-F", mac: "Command-F"},
exec: function(iSearch) { exec: function(iSearch) {
iSearch.cancelSearch(true); iSearch.cancelSearch(true);
} },
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: "searchForward", name: "searchForward",
bindKey: {win: "Ctrl-S|Ctrl-K", mac: "Ctrl-S|Command-G"}, bindKey: {win: "Ctrl-S|Ctrl-K", mac: "Ctrl-S|Command-G"},
exec: function(iSearch, options) { exec: function(iSearch, options) {
options.useCurrentOrPrevSearch = true; options.useCurrentOrPrevSearch = true;
iSearch.next(options); iSearch.next(options);
} },
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: "searchBackward", name: "searchBackward",
bindKey: {win: "Ctrl-R|Ctrl-Shift-K", mac: "Ctrl-R|Command-Shift-G"}, bindKey: {win: "Ctrl-R|Ctrl-Shift-K", mac: "Ctrl-R|Command-Shift-G"},
@ -84,30 +88,42 @@ exports.iSearchCommands = [{
options.useCurrentOrPrevSearch = true; options.useCurrentOrPrevSearch = true;
options.backwards = true; options.backwards = true;
iSearch.next(options); iSearch.next(options);
} },
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: "extendSearchTerm", name: "extendSearchTerm",
exec: function(iSearch, string) { exec: function(iSearch, string) {
iSearch.addString(string); iSearch.addChar(string);
} },
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: "extendSearchTermSpace", name: "extendSearchTermSpace",
bindKey: "space", bindKey: "space",
exec: function(iSearch) { iSearch.addString(' '); } exec: function(iSearch) { iSearch.addChar(' '); },
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: "shrinkSearchTerm", name: "shrinkSearchTerm",
bindKey: "backspace", bindKey: "backspace",
exec: function(iSearch) { exec: function(iSearch) {
iSearch.removeChar(); iSearch.removeChar();
} },
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: 'confirmSearch', name: 'confirmSearch',
bindKey: 'return', bindKey: 'return',
exec: function(iSearch) { iSearch.deactivate(); } exec: function(iSearch) { iSearch.deactivate(); },
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: 'cancelSearch', name: 'cancelSearch',
bindKey: 'esc|Ctrl-G', bindKey: 'esc|Ctrl-G',
exec: function(iSearch) { iSearch.deactivate(true); } exec: function(iSearch) { iSearch.deactivate(true); },
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: 'occurisearch', name: 'occurisearch',
bindKey: 'Ctrl-O', bindKey: 'Ctrl-O',
@ -115,53 +131,10 @@ exports.iSearchCommands = [{
var options = oop.mixin({}, iSearch.$options); var options = oop.mixin({}, iSearch.$options);
iSearch.deactivate(); iSearch.deactivate();
occurStartCommand.exec(iSearch.$editor, options); occurStartCommand.exec(iSearch.$editor, options);
} },
}, { readOnly: true,
name: "yankNextWord", isIncrementalSearchCommand: true
bindKey: "Ctrl-w", }];
exec: function(iSearch) {
var ed = iSearch.$editor,
range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorWordRight(); }),
string = ed.session.getTextRange(range);
iSearch.addString(string);
}
}, {
name: "yankNextChar",
bindKey: "Ctrl-Alt-y",
exec: function(iSearch) {
var ed = iSearch.$editor,
range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorRight(); }),
string = ed.session.getTextRange(range);
iSearch.addString(string);
}
}, {
name: 'recenterTopBottom',
bindKey: 'Ctrl-l',
exec: function(iSearch) { iSearch.$editor.execCommand('recenterTopBottom'); }
}, {
name: 'selectAllMatches',
bindKey: 'Ctrl-space',
exec: function(iSearch) {
var ed = iSearch.$editor,
hl = ed.session.$isearchHighlight,
ranges = hl && hl.cache ? hl.cache
.reduce(function(ranges, ea) {
return ranges.concat(ea ? ea : []); }, []) : [];
iSearch.deactivate(false);
ranges.forEach(ed.selection.addRange.bind(ed.selection));
}
}, {
name: 'searchAsRegExp',
bindKey: 'Alt-r',
exec: function(iSearch) {
iSearch.convertNeedleToRegExp();
}
}].map(function(cmd) {
cmd.readOnly = true;
cmd.isIncrementalSearchCommand = true;
cmd.scrollIntoView = "animate-cursor";
return cmd;
});
function IncrementalSearchKeyboardHandler(iSearch) { function IncrementalSearchKeyboardHandler(iSearch) {
this.$iSearch = iSearch; this.$iSearch = iSearch;
@ -169,7 +142,7 @@ function IncrementalSearchKeyboardHandler(iSearch) {
oop.inherits(IncrementalSearchKeyboardHandler, HashHandler); oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
(function() { ;(function() {
this.attach = function(editor) { this.attach = function(editor) {
var iSearch = this.$iSearch; var iSearch = this.$iSearch;
@ -178,24 +151,18 @@ oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
if (!e.command.isIncrementalSearchCommand) return undefined; if (!e.command.isIncrementalSearchCommand) return undefined;
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
var scrollTop = editor.session.getScrollTop(); return e.command.exec(iSearch, e.args || {});
var result = e.command.exec(iSearch, e.args || {});
editor.renderer.scrollCursorIntoView(null, 0.5);
editor.renderer.animateScrolling(scrollTop);
return result;
}); });
}; }
this.detach = function(editor) { this.detach = function(editor) {
if (!this.$commandExecHandler) return; if (!this.$commandExecHandler) return;
editor.commands.removeEventListener('exec', this.$commandExecHandler); editor.commands.removeEventListener('exec', this.$commandExecHandler);
delete this.$commandExecHandler; delete this.$commandExecHandler;
}; }
var handleKeyboard$super = this.handleKeyboard; var handleKeyboard$super = this.handleKeyboard;
this.handleKeyboard = function(data, hashId, key, keyCode) { this.handleKeyboard = function(data, hashId, key, keyCode) {
if (((hashId === 1/*ctrl*/ || hashId === 8/*command*/) && key === 'v')
|| (hashId === 1/*ctrl*/ && key === 'y')) return null;
var cmd = handleKeyboard$super.call(this, data, hashId, key, keyCode); var cmd = handleKeyboard$super.call(this, data, hashId, key, keyCode);
if (cmd.command) { return cmd; } if (cmd.command) { return cmd; }
if (hashId == -1) { if (hashId == -1) {
@ -203,7 +170,7 @@ oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
if (extendCmd) { return {command: extendCmd, args: key}; } if (extendCmd) { return {command: extendCmd, args: key}; }
} }
return {command: "null", passEvent: hashId == 0 || hashId == 4}; return {command: "null", passEvent: hashId == 0 || hashId == 4};
}; }
}).call(IncrementalSearchKeyboardHandler.prototype); }).call(IncrementalSearchKeyboardHandler.prototype);

View file

@ -35,49 +35,41 @@ exports.defaultCommands = [{
name: "addCursorAbove", name: "addCursorAbove",
exec: function(editor) { editor.selectMoreLines(-1); }, exec: function(editor) { editor.selectMoreLines(-1); },
bindKey: {win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up"}, bindKey: {win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up"},
scrollIntoView: "cursor",
readonly: true readonly: true
}, { }, {
name: "addCursorBelow", name: "addCursorBelow",
exec: function(editor) { editor.selectMoreLines(1); }, exec: function(editor) { editor.selectMoreLines(1); },
bindKey: {win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down"}, bindKey: {win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down"},
scrollIntoView: "cursor",
readonly: true readonly: true
}, { }, {
name: "addCursorAboveSkipCurrent", name: "addCursorAboveSkipCurrent",
exec: function(editor) { editor.selectMoreLines(-1, true); }, exec: function(editor) { editor.selectMoreLines(-1, true); },
bindKey: {win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up"}, bindKey: {win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up"},
scrollIntoView: "cursor",
readonly: true readonly: true
}, { }, {
name: "addCursorBelowSkipCurrent", name: "addCursorBelowSkipCurrent",
exec: function(editor) { editor.selectMoreLines(1, true); }, exec: function(editor) { editor.selectMoreLines(1, true); },
bindKey: {win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down"}, bindKey: {win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down"},
scrollIntoView: "cursor",
readonly: true readonly: true
}, { }, {
name: "selectMoreBefore", name: "selectMoreBefore",
exec: function(editor) { editor.selectMore(-1); }, exec: function(editor) { editor.selectMore(-1); },
bindKey: {win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left"}, bindKey: {win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left"},
scrollIntoView: "cursor",
readonly: true readonly: true
}, { }, {
name: "selectMoreAfter", name: "selectMoreAfter",
exec: function(editor) { editor.selectMore(1); }, exec: function(editor) { editor.selectMore(1); },
bindKey: {win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right"}, bindKey: {win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right"},
scrollIntoView: "cursor",
readonly: true readonly: true
}, { }, {
name: "selectNextBefore", name: "selectNextBefore",
exec: function(editor) { editor.selectMore(-1, true); }, exec: function(editor) { editor.selectMore(-1, true); },
bindKey: {win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left"}, bindKey: {win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left"},
scrollIntoView: "cursor",
readonly: true readonly: true
}, { }, {
name: "selectNextAfter", name: "selectNextAfter",
exec: function(editor) { editor.selectMore(1, true); }, exec: function(editor) { editor.selectMore(1, true); },
bindKey: {win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right"}, bindKey: {win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right"},
scrollIntoView: "cursor",
readonly: true readonly: true
}, { }, {
name: "splitIntoLines", name: "splitIntoLines",
@ -87,14 +79,7 @@ exports.defaultCommands = [{
}, { }, {
name: "alignCursors", name: "alignCursors",
exec: function(editor) { editor.alignCursors(); }, exec: function(editor) { editor.alignCursors(); },
bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"}, bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"}
scrollIntoView: "cursor"
}, {
name: "findAll",
exec: function(editor) { editor.findAll(); },
bindKey: {win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G"},
scrollIntoView: "cursor",
readonly: true
}]; }];
// commands active only in multiselect mode // commands active only in multiselect mode
@ -102,7 +87,6 @@ exports.multiSelectCommands = [{
name: "singleSelection", name: "singleSelection",
bindKey: "esc", bindKey: "esc",
exec: function(editor) { editor.exitMultiSelectMode(); }, exec: function(editor) { editor.exitMultiSelectMode(); },
scrollIntoView: "cursor",
readonly: true, readonly: true,
isAvailable: function(editor) {return editor && editor.inMultiSelectMode} isAvailable: function(editor) {return editor && editor.inMultiSelectMode}
}]; }];

View file

@ -34,12 +34,10 @@ define(function(require, exports, module) {
var lang = require("./lib/lang"); var lang = require("./lib/lang");
var oop = require("./lib/oop"); var oop = require("./lib/oop");
var net = require("./lib/net"); var net = require("./lib/net");
var AppConfig = require("./lib/app_config").AppConfig; var EventEmitter = require("./lib/event_emitter").EventEmitter;
module.exports = exports = new AppConfig();
var global = (function() { var global = (function() {
return this || typeof window != "undefined" && window; return this;
})(); })();
var options = { var options = {
@ -71,6 +69,8 @@ exports.all = function() {
}; };
// module loading // module loading
oop.implement(exports, EventEmitter);
exports.moduleUrl = function(name, component) { exports.moduleUrl = function(name, component) {
if (options.$moduleUrls[name]) if (options.$moduleUrls[name])
return options.$moduleUrls[name]; return options.$moduleUrls[name];
@ -80,8 +80,8 @@ exports.moduleUrl = function(name, component) {
// todo make this configurable or get rid of '-' // todo make this configurable or get rid of '-'
var sep = component == "snippets" ? "/" : "-"; var sep = component == "snippets" ? "/" : "-";
var base = parts[parts.length - 1]; var base = parts[parts.length - 1];
if (component == "worker" && sep == "-") { if (sep == "-") {
var re = new RegExp("^" + component + "[\\-_]|[\\-_]" + component + "$", "g"); var re = new RegExp("^" + component + "[\\-_]|[\\-_]" + component + "$", "g");
base = base.replace(re, ""); base = base.replace(re, "");
} }
@ -142,9 +142,10 @@ exports.loadModule = function(moduleName, onLoad) {
net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad); net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad);
}; };
// initialization // initialization
function init(packaged) { exports.init = function() {
options.packaged = packaged || require.packaged || module.packaged || (global.define && define.packaged); options.packaged = require.packaged || module.packaged || (global.define && define.packaged);
if (!global.document) if (!global.document)
return ""; return "";
@ -152,11 +153,7 @@ function init(packaged) {
var scriptOptions = {}; var scriptOptions = {};
var scriptUrl = ""; var scriptUrl = "";
// Use currentScript.ownerDocument in case this file was loaded from imported document. (HTML Imports) var scripts = document.getElementsByTagName("script");
var currentScript = (document.currentScript || document._currentScript ); // native or polyfill
var currentDocument = currentScript && currentScript.ownerDocument || document;
var scripts = currentDocument.getElementsByTagName("script");
for (var i=0; i<scripts.length; i++) { for (var i=0; i<scripts.length; i++) {
var script = scripts[i]; var script = scripts[i];
@ -193,10 +190,106 @@ function init(packaged) {
exports.set(key, scriptOptions[key]); exports.set(key, scriptOptions[key]);
}; };
exports.init = init;
function deHyphenate(str) { function deHyphenate(str) {
return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); }); return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); });
} }
var optionsProvider = {
setOptions: function(optList) {
Object.keys(optList).forEach(function(key) {
this.setOption(key, optList[key]);
}, this);
},
getOptions: function(optionNames) {
var result = {};
if (!optionNames) {
optionNames = Object.keys(this.$options);
} else if (!Array.isArray(optionNames)) {
result = optionNames;
optionNames = Object.keys(result);
}
optionNames.forEach(function(key) {
result[key] = this.getOption(key);
}, this);
return result;
},
setOption: function(name, value) {
if (this["$" + name] === value)
return;
var opt = this.$options[name];
if (!opt) {
if (typeof console != "undefined" && console.warn)
console.warn('misspelled option "' + name + '"');
return undefined;
}
if (opt.forwardTo)
return this[opt.forwardTo] && this[opt.forwardTo].setOption(name, value);
if (!opt.handlesSet)
this["$" + name] = value;
if (opt && opt.set)
opt.set.call(this, value);
},
getOption: function(name) {
var opt = this.$options[name];
if (!opt) {
if (typeof console != "undefined" && console.warn)
console.warn('misspelled option "' + name + '"');
return undefined;
}
if (opt.forwardTo)
return this[opt.forwardTo] && this[opt.forwardTo].getOption(name);
return opt && opt.get ? opt.get.call(this) : this["$" + name];
}
};
var defaultOptions = {};
/*
* option {name, value, initialValue, setterName, set, get }
*/
exports.defineOptions = function(obj, path, options) {
if (!obj.$options)
defaultOptions[path] = obj.$options = {};
Object.keys(options).forEach(function(key) {
var opt = options[key];
if (typeof opt == "string")
opt = {forwardTo: opt};
opt.name || (opt.name = key);
obj.$options[opt.name] = opt;
if ("initialValue" in opt)
obj["$" + opt.name] = opt.initialValue;
});
// implement option provider interface
oop.implement(obj, optionsProvider);
return this;
};
exports.resetOptions = function(obj) {
Object.keys(obj.$options).forEach(function(key) {
var opt = obj.$options[key];
if ("value" in opt)
obj.setOption(key, opt.value);
});
};
exports.setDefaultValue = function(path, name, value) {
var opts = defaultOptions[path] || (defaultOptions[path] = {});
if (opts[name]) {
if (opts.forwardTo)
exports.setDefaultValue(opts.forwardTo, name, value);
else
opts[name].value = value;
}
};
exports.setDefaultValues = function(path, optionHash) {
Object.keys(optionHash).forEach(function(key) {
exports.setDefaultValue(path, key, optionHash[key]);
});
};
}); });

View file

@ -43,7 +43,7 @@ module.exports = {
"test: path resolution" : function() { "test: path resolution" : function() {
config.set("packaged", "true"); config.set("packaged", "true");
var url = config.moduleUrl("kr_theme", "theme"); var url = config.moduleUrl("kr_theme", "theme");
assert.equal(url, "theme-kr_theme.js"); assert.equal(url, "theme-kr.js");
config.set("basePath", "a/b"); config.set("basePath", "a/b");
url = config.moduleUrl("m/theme", "theme"); url = config.moduleUrl("m/theme", "theme");
@ -117,19 +117,12 @@ module.exports = {
assert.equal(o.getOption("initialValue"), 8); assert.equal(o.getOption("initialValue"), 8);
o.setOption("initialValue", 7); o.setOption("initialValue", 7);
assert.equal(o.getOption("opt2"), 7); assert.equal(o.getOption("opt2"), 7);
config.setDefaultValues("test_object", {
opt1: 1,
forwarded: 2
});
config.resetOptions(o);
assert.equal(o.getOption("opt1"), 1);
assert.equal(o.getOption("forwarded"), 2);
} }
}; };
}); });
if (typeof module !== "undefined" && module === require.main) { if (typeof module !== "undefined" && module === require.main) {
require("asyncjs").test.testcase(module.exports).exec(); require("asyncjs").test.testcase(module.exports).exec()
} }

View file

@ -1,8 +1,14 @@
.ace_editor { .ace_editor {
position: relative; position: relative;
overflow: hidden; overflow: hidden;
font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace; font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
direction: ltr; font-size: 12px;
line-height: normal;
color: black;
-ms-user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
user-select: none;
} }
.ace_scroller { .ace_scroller {
@ -11,11 +17,6 @@
top: 0; top: 0;
bottom: 0; bottom: 0;
background-color: inherit; background-color: inherit;
-ms-user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
user-select: none;
cursor: text;
} }
.ace_content { .ace_content {
@ -23,7 +24,11 @@
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
min-width: 100%; cursor: text;
}
.ace_dragging, .ace_dragging * {
cursor: move !important;
} }
.ace_dragging .ace_scroller:before{ .ace_dragging .ace_scroller:before{
@ -53,10 +58,6 @@
left: 0; left: 0;
cursor: default; cursor: default;
z-index: 4; z-index: 4;
-ms-user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
user-select: none;
} }
.ace_gutter-active-line { .ace_gutter-active-line {
@ -76,27 +77,30 @@
} }
.ace_gutter-cell.ace_error { .ace_gutter-cell.ace_error {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAABOFBMVEX/////////QRswFAb/Ui4wFAYwFAYwFAaWGAfDRymzOSH/PxswFAb/SiUwFAYwFAbUPRvjQiDllog5HhHdRybsTi3/Tyv9Tir+Syj/UC3////XurebMBIwFAb/RSHbPx/gUzfdwL3kzMivKBAwFAbbvbnhPx66NhowFAYwFAaZJg8wFAaxKBDZurf/RB6mMxb/SCMwFAYwFAbxQB3+RB4wFAb/Qhy4Oh+4QifbNRcwFAYwFAYwFAb/QRzdNhgwFAYwFAbav7v/Uy7oaE68MBK5LxLewr/r2NXewLswFAaxJw4wFAbkPRy2PyYwFAaxKhLm1tMwFAazPiQwFAaUGAb/QBrfOx3bvrv/VC/maE4wFAbRPBq6MRO8Qynew8Dp2tjfwb0wFAbx6eju5+by6uns4uH9/f36+vr/GkHjAAAAYnRSTlMAGt+64rnWu/bo8eAA4InH3+DwoN7j4eLi4xP99Nfg4+b+/u9B/eDs1MD1mO7+4PHg2MXa347g7vDizMLN4eG+Pv7i5evs/v79yu7S3/DV7/498Yv24eH+4ufQ3Ozu/v7+y13sRqwAAADLSURBVHjaZc/XDsFgGIBhtDrshlitmk2IrbHFqL2pvXf/+78DPokj7+Fz9qpU/9UXJIlhmPaTaQ6QPaz0mm+5gwkgovcV6GZzd5JtCQwgsxoHOvJO15kleRLAnMgHFIESUEPmawB9ngmelTtipwwfASilxOLyiV5UVUyVAfbG0cCPHig+GBkzAENHS0AstVF6bacZIOzgLmxsHbt2OecNgJC83JERmePUYq8ARGkJx6XtFsdddBQgZE2nPR6CICZhawjA4Fb/chv+399kfR+MMMDGOQAAAABJRU5ErkJggg=="); background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6QUM2OEZDQTQ4RTU0MTFFMUEzM0VFRTM2RUY1M0RBMjYiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6QUM2OEZDQTU4RTU0MTFFMUEzM0VFRTM2RUY1M0RBMjYiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpBQzY4RkNBMjhFNTQxMUUxQTMzRUVFMzZFRjUzREEyNiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpBQzY4RkNBMzhFNTQxMUUxQTMzRUVFMzZFRjUzREEyNiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PkgXxbAAAAJbSURBVHjapFNNaBNBFH4zs5vdZLP5sQmNpT82QY209heh1ioWisaDRcSKF0WKJ0GQnrzrxasHsR6EnlrwD0TagxJabaVEpFYxLWlLSS822tr87m66ccfd2GKyVhA6MMybgfe97/vmPUQphd0sZjto9XIn9OOsvlu2nkqRzVU+6vvlzPf8W6bk8dxQ0NPbxAALgCgg2JkaQuhzQau/El0zbmUA7U0Es8v2CiYmKQJHGO1QICCLoqilMhkmurDAyapKgqItezi/USRdJqEYY4D5jCy03ht2yMkkvL91jTTX10qzyyu2hruPRN7jgbH+EOsXcMLgYiThEgAMhABW85oqy1DXdRIdvP1AHJ2acQXvDIrVHcdQNrEKNYSVMSZGMjEzIIAwDXIo+6G/FxcGnzkC3T2oMhLjre49sBB+RRcHLqdafK6sYdE/GGBwU1VpFNj0aN8pJbe+BkZyevUrvLl6Xmm0W9IuTc0DxrDNAJd5oEvI/KRsNC3bQyNjPO9yQ1YHcfj2QvfQc/5TUhJTBc2iM0U7AWDQtc1nJHvD/cfO2s7jaGkiTEfa/Ep8coLu7zmNmh8+dc5lZDuUeFAGUNA/OY6JVaypQ0vjr7XYjUvJM37vt+j1vuTK5DgVfVUoTjVe+y3/LxMxY2GgU+CSLy4cpfsYorRXuXIOi0Vt40h67uZFTdIo6nLaZcwUJWAzwNS0tBnqqKzQDnjdG/iPyZxo46HaKUpbvYkj8qYRTZsBhge+JHhZyh0x9b95JqjVJkT084kZIPwu/mPWqPgfQ5jXh2+92Ay7HedfAgwA6KDWafb4w3cAAAAASUVORK5CYII=");
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: 2px center; background-position: 2px center;
} }
.ace_gutter-cell.ace_warning { .ace_gutter-cell.ace_warning {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAmVBMVEX///8AAAD///8AAAAAAABPSzb/5sAAAAB/blH/73z/ulkAAAAAAAD85pkAAAAAAAACAgP/vGz/rkDerGbGrV7/pkQICAf////e0IsAAAD/oED/qTvhrnUAAAD/yHD/njcAAADuv2r/nz//oTj/p064oGf/zHAAAAA9Nir/tFIAAAD/tlTiuWf/tkIAAACynXEAAAAAAAAtIRW7zBpBAAAAM3RSTlMAABR1m7RXO8Ln31Z36zT+neXe5OzooRDfn+TZ4p3h2hTf4t3k3ucyrN1K5+Xaks52Sfs9CXgrAAAAjklEQVR42o3PbQ+CIBQFYEwboPhSYgoYunIqqLn6/z8uYdH8Vmdnu9vz4WwXgN/xTPRD2+sgOcZjsge/whXZgUaYYvT8QnuJaUrjrHUQreGczuEafQCO/SJTufTbroWsPgsllVhq3wJEk2jUSzX3CUEDJC84707djRc5MTAQxoLgupWRwW6UB5fS++NV8AbOZgnsC7BpEAAAAABJRU5ErkJggg=="); 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-position: 2px center; background-position: 2px center;
} }
.ace_gutter-cell.ace_info { .ace_gutter-cell.ace_info {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII="); background-image: url("data:image/gif;base64,R0lGODlhEAAQAMQAAAAAAEFBQVJSUl5eXmRkZGtra39/f4WFhYmJiZGRkaampry8vMPDw8zMzNXV1dzc3OTk5Orq6vDw8P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABQALAAAAAAQABAAAAUuICWOZGmeaBml5XGwFCQSBGyXRSAwtqQIiRuiwIM5BoYVbEFIyGCQoeJGrVptIQA7");
background-position: 2px center; background-position: 2px center;
} }
.ace_dark .ace_gutter-cell.ace_info { .ace_dark .ace_gutter-cell.ace_info {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC"); 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_scrollbar { .ace_scrollbar {
position: absolute; position: absolute;
overflow-x: hidden;
overflow-y: auto;
right: 0; right: 0;
top: 0;
bottom: 0; bottom: 0;
z-index: 6; z-index: 6;
} }
@ -108,16 +112,14 @@
top: 0; top: 0;
} }
.ace_scrollbar-v{
overflow-x: hidden;
overflow-y: scroll;
top: 0;
}
.ace_scrollbar-h { .ace_scrollbar-h {
overflow-x: scroll; position: absolute;
overflow-x: auto;
overflow-y: hidden; overflow-y: hidden;
right: 0;
left: 0; left: 0;
bottom: 0;
z-index: 6;
} }
.ace_print-margin { .ace_print-margin {
@ -149,8 +151,8 @@
} }
.ace_text-input.ace_composition { .ace_text-input.ace_composition {
background: inherit; background: #f8f8f8;
color: inherit; color: #111;
z-index: 1000; z-index: 1000;
opacity: 1; opacity: 1;
text-indent: 0; text-indent: 0;
@ -160,8 +162,6 @@
z-index: 1; z-index: 1;
position: absolute; position: absolute;
overflow: hidden; overflow: hidden;
/* workaround for chrome bug https://github.com/ajaxorg/ace/issues/2312*/
word-wrap: normal;
white-space: pre; white-space: pre;
height: 100%; height: 100%;
width: 100%; width: 100%;
@ -207,7 +207,7 @@
} }
.ace_overwrite-cursors .ace_cursor { .ace_overwrite-cursors .ace_cursor {
border-left-width: 0; border-left-width: 0px;
border-bottom: 1px solid; border-bottom: 1px solid;
} }
@ -216,10 +216,17 @@
} }
.ace_smooth-blinking .ace_cursor { .ace_smooth-blinking .ace_cursor {
-moz-transition: opacity 0.18s;
-webkit-transition: opacity 0.18s; -webkit-transition: opacity 0.18s;
-o-transition: opacity 0.18s;
-ms-transition: opacity 0.18s;
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 { .ace_editor.ace_multiselect .ace_cursor {
border-left-width: 1px; border-left-width: 1px;
} }
@ -263,13 +270,15 @@
vertical-align: middle; vertical-align: middle;
background-image: background-image:
url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII="), url("data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%11%00%00%00%09%08%06%00%00%00%D4%E8%C7%0C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%00%B5IDAT(%15%A5%91%3D%0E%02!%10%85ac%E1%05%D6%CE%D6%C6%CE%D2%E8%ED%CD%DE%C0%C6%D6N.%E0V%F8%3D%9Ca%891XH%C2%BE%D9y%3F%90!%E6%9C%C3%BFk%E5%011%C6-%F5%C8N%04%DF%BD%FF%89%DFt%83DN%60%3E%F3%AB%A0%DE%1A%5Dg%BE%10Q%97%1B%40%9C%A8o%10%8F%5E%828%B4%1B%60%87%F6%02%26%85%1Ch%1E%C1%2B%5Bk%FF%86%EE%B7j%09%9A%DA%9B%ACe%A3%F9%EC%DA!9%B4%D5%A6%81%86%86%98%CC%3C%5B%40%FA%81%B3%E9%CB%23%94%C16Azo%05%D4%E1%C1%95a%3B%8A'%A0%E8%CC%17%22%85%1D%BA%00%A2%FA%DC%0A%94%D1%D1%8D%8B%3A%84%17B%C7%60%1A%25Z%FC%8D%00%00%00%00IEND%AEB%60%82"),
url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII="); url("data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%007%08%06%00%00%00%C4%DD%80C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%00%3AIDAT8%11c%FC%FF%FF%7F%18%03%1A%60%01%F2%3F%A0%891%80%04%FF%11-%F8%17%9BJ%E2%05%B1ZD%81v%26t%E7%80%F8%A3%82h%A12%1A%20%A3%01%02%0F%01%BA%25%06%00%19%C0%0D%AEF%D5%3ES%00%00%00%00IEND%AEB%60%82");
background-repeat: no-repeat, repeat-x; background-repeat: no-repeat, repeat-x;
background-position: center center, top left; background-position: center center, top left;
color: transparent; color: transparent;
border: 1px solid black; border: 1px solid black;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px; border-radius: 2px;
cursor: pointer; cursor: pointer;
@ -281,11 +290,13 @@
.ace_fold:hover{ .ace_fold:hover{
background-image: background-image:
url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII="), url("data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%11%00%00%00%09%08%06%00%00%00%D4%E8%C7%0C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%00%B5IDAT(%15%A5%91%3D%0E%02!%10%85ac%E1%05%D6%CE%D6%C6%CE%D2%E8%ED%CD%DE%C0%C6%D6N.%E0V%F8%3D%9Ca%891XH%C2%BE%D9y%3F%90!%E6%9C%C3%BFk%E5%011%C6-%F5%C8N%04%DF%BD%FF%89%DFt%83DN%60%3E%F3%AB%A0%DE%1A%5Dg%BE%10Q%97%1B%40%9C%A8o%10%8F%5E%828%B4%1B%60%87%F6%02%26%85%1Ch%1E%C1%2B%5Bk%FF%86%EE%B7j%09%9A%DA%9B%ACe%A3%F9%EC%DA!9%B4%D5%A6%81%86%86%98%CC%3C%5B%40%FA%81%B3%E9%CB%23%94%C16Azo%05%D4%E1%C1%95a%3B%8A'%A0%E8%CC%17%22%85%1D%BA%00%A2%FA%DC%0A%94%D1%D1%8D%8B%3A%84%17B%C7%60%1A%25Z%FC%8D%00%00%00%00IEND%AEB%60%82"),
url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC"); url("data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%007%08%06%00%00%00%C4%DD%80C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%003IDAT8%11c%FC%FF%FF%7F%3E%03%1A%60%01%F2%3F%A3%891%80%04%FFQ%26%F8w%C0%B43%A1%DB%0C%E2%8F%0A%A2%85%CAh%80%8C%06%08%3C%04%E8%96%18%00%A3S%0D%CD%CF%D8%C1%9D%00%00%00%00IEND%AEB%60%82");
background-repeat: no-repeat, repeat-x;
background-position: center center, top left;
} }
.ace_tooltip { .ace_gutter-tooltip {
background-color: #FFF; background-color: #FFF;
background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1)); background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1));
background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1)); background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));
@ -293,21 +304,21 @@
border-radius: 1px; border-radius: 1px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
color: black; color: black;
max-width: 100%; display: inline-block;
padding: 3px 4px; max-width: 500px;
padding: 4px;
position: fixed; position: fixed;
z-index: 999999; z-index: 999999;
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
cursor: default; cursor: default;
white-space: pre; white-space: pre-line;
word-wrap: break-word; word-wrap: break-word;
line-height: normal; line-height: normal;
font-style: normal; font-style: normal;
font-weight: normal; font-weight: normal;
letter-spacing: normal; letter-spacing: normal;
pointer-events: none;
} }
.ace_folding-enabled > .ace_gutter-cell { .ace_folding-enabled > .ace_gutter-cell {
@ -324,7 +335,7 @@
width: 11px; width: 11px;
vertical-align: top; vertical-align: top;
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg=="); 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-repeat: no-repeat;
background-position: center; background-position: center;
@ -339,22 +350,26 @@
} }
.ace_fold-widget.ace_end { .ace_fold-widget.ace_end {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg=="); 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.ace_closed { .ace_fold-widget.ace_closed {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA=="); 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");
} }
.ace_fold-widget:hover { .ace_fold-widget:hover {
border: 1px solid rgba(0, 0, 0, 0.3); border: 1px solid rgba(0, 0, 0, 0.3);
background-color: rgba(255, 255, 255, 0.2); background-color: rgba(255, 255, 255, 0.2);
-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); box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);
} }
.ace_fold-widget:active { .ace_fold-widget:active {
border: 1px solid rgba(0, 0, 0, 0.4); border: 1px solid rgba(0, 0, 0, 0.4);
background-color: rgba(0, 0, 0, 0.05); background-color: rgba(0, 0, 0, 0.05);
-moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
-webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8); box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
} }
/** /**
@ -374,6 +389,8 @@
background-color: rgba(255, 255, 255, 0.1); background-color: rgba(255, 255, 255, 0.1);
} }
.ace_dark .ace_fold-widget:active { .ace_dark .ace_fold-widget:active {
-moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);
-webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);
box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2); box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);
} }
@ -383,13 +400,19 @@
} }
.ace_fade-fold-widgets .ace_fold-widget { .ace_fade-fold-widgets .ace_fold-widget {
-moz-transition: opacity 0.4s ease 0.05s;
-webkit-transition: opacity 0.4s ease 0.05s; -webkit-transition: opacity 0.4s ease 0.05s;
-o-transition: opacity 0.4s ease 0.05s;
-ms-transition: opacity 0.4s ease 0.05s;
transition: opacity 0.4s ease 0.05s; transition: opacity 0.4s ease 0.05s;
opacity: 0; opacity: 0;
} }
.ace_fade-fold-widgets:hover .ace_fold-widget { .ace_fade-fold-widgets:hover .ace_fold-widget {
-moz-transition: opacity 0.05s ease 0.05s;
-webkit-transition: opacity 0.05s ease 0.05s; -webkit-transition: opacity 0.05s ease 0.05s;
-o-transition: opacity 0.05s ease 0.05s;
-ms-transition: opacity 0.05s ease 0.05s;
transition: opacity 0.05s ease 0.05s; transition: opacity 0.05s ease 0.05s;
opacity:1; opacity:1;
} }
@ -422,30 +445,3 @@
position: absolute; position: absolute;
z-index: 8; z-index: 8;
} }
/*
styles = []
for (var i = 1; i < 16; i++) {
styles.push(".ace_br" + i + "{" + (
["top-left", "top-right", "bottom-right", "bottom-left"]
).map(function(x, j) {
return i & (1<<j) ? "border-" + x + "-radius: 3px;" : ""
}).filter(Boolean).join(" ") + "}")
}
styles.join("\n")
*/
.ace_br1 {border-top-left-radius : 3px;}
.ace_br2 {border-top-right-radius : 3px;}
.ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}
.ace_br4 {border-bottom-right-radius: 3px;}
.ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}
.ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}
.ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}
.ace_br8 {border-bottom-left-radius : 3px;}
.ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}
.ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}
.ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}
.ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}
.ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}
.ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}
.ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}

View file

@ -32,36 +32,36 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var oop = require("./lib/oop"); var oop = require("./lib/oop");
var applyDelta = require("./apply_delta").applyDelta;
var EventEmitter = require("./lib/event_emitter").EventEmitter; var EventEmitter = require("./lib/event_emitter").EventEmitter;
var Range = require("./range").Range; var Range = require("./range").Range;
var Anchor = require("./anchor").Anchor; var Anchor = require("./anchor").Anchor;
/** /**
* Contains the text of the document. Document can be attached to several [[EditSession `EditSession`]]s. * 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. * 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 * @class Document
**/ **/
/** /**
* *
* Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty. * Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty.
* @param {String | Array} text The starting text * @param {String | Array} text The starting text
* @constructor * @constructor
**/ **/
var Document = function(textOrLines) { var Document = function(text) {
this.$lines = [""]; this.$lines = [];
// There has to be one line at least in the document. If you pass an empty // There has to be one line at least in the document. If you pass an empty
// string to the insert function, nothing will happen. Workaround. // string to the insert function, nothing will happen. Workaround.
if (textOrLines.length === 0) { if (text.length == 0) {
this.$lines = [""]; this.$lines = [""];
} else if (Array.isArray(textOrLines)) { } else if (Array.isArray(text)) {
this.insertMergedLines({row: 0, column: 0}, textOrLines); this._insertLines(0, text);
} else { } else {
this.insert({row: 0, column:0}, textOrLines); this.insert({row: 0, column:0}, text);
} }
}; };
@ -75,9 +75,9 @@ var Document = function(textOrLines) {
* @param {String} text The text to use * @param {String} text The text to use
**/ **/
this.setValue = function(text) { this.setValue = function(text) {
var len = this.getLength() - 1; var len = this.getLength();
this.remove(new Range(0, 0, len, this.getLine(len).length)); this.remove(new Range(0, 0, len, this.getLine(len-1).length));
this.insert({row: 0, column: 0}, text); this.insert({row: 0, column:0}, text);
}; };
/** /**
@ -98,7 +98,7 @@ var Document = function(textOrLines) {
}; };
/** /**
* Splits a string of text on any newline (`\n`) or carriage-return (`\r`) characters. * Splits a string of text on any newline (`\n`) or carriage-return ('\r') characters.
* *
* @method $split * @method $split
* @param {String} text The text to work with * @param {String} text The text to work with
@ -107,21 +107,19 @@ var Document = function(textOrLines) {
**/ **/
// check for IE split bug // check for IE split bug
if ("aaa".split(/a/).length === 0) { if ("aaa".split(/a/).length == 0)
this.$split = function(text) { this.$split = function(text) {
return text.replace(/\r\n|\r/g, "\n").split("\n"); return text.replace(/\r\n|\r/g, "\n").split("\n");
}; }
} else { else
this.$split = function(text) { this.$split = function(text) {
return text.split(/\r\n|\r|\n/); return text.split(/\r\n|\r|\n/);
}; };
}
this.$detectNewLine = function(text) { this.$detectNewLine = function(text) {
var match = text.match(/^.*?(\r\n|\r|\n)/m); var match = text.match(/^.*?(\r\n|\r|\n)/m);
this.$autoNewLine = match ? match[1] : "\n"; this.$autoNewLine = match ? match[1] : "\n";
this._signal("changeNewLineMode");
}; };
/** /**
@ -138,11 +136,11 @@ var Document = function(textOrLines) {
case "unix": case "unix":
return "\n"; return "\n";
default: default:
return this.$autoNewLine || "\n"; return this.$autoNewLine;
} }
}; };
this.$autoNewLine = ""; this.$autoNewLine = "\n";
this.$newLineMode = "auto"; this.$newLineMode = "auto";
/** /**
* [Sets the new line mode.]{: #Document.setNewLineMode.desc} * [Sets the new line mode.]{: #Document.setNewLineMode.desc}
@ -154,7 +152,6 @@ var Document = function(textOrLines) {
return; return;
this.$newLineMode = newLineMode; this.$newLineMode = newLineMode;
this._signal("changeNewLineMode");
}; };
/** /**
@ -208,49 +205,32 @@ var Document = function(textOrLines) {
}; };
/** /**
* Returns all the text within `range` as a single string. * [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. * @param {Range} range The range to work with
* *
* @returns {String} * @returns {String}
**/ **/
this.getTextRange = function(range) { this.getTextRange = function(range) {
return this.getLinesForRange(range).join(this.getNewLineCharacter()); if (range.start.row == range.end.row) {
}; return this.getLine(range.start.row)
.substring(range.start.column, range.end.column);
/**
* Returns all the text within `range` as an array of lines.
* @param {Range} range The range to work with.
*
* @returns {Array}
**/
this.getLinesForRange = function(range) {
var lines;
if (range.start.row === range.end.row) {
// Handle a single-line range.
lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
} else {
// Handle a multi-line range.
lines = this.getLines(range.start.row, range.end.row);
lines[0] = (lines[0] || "").substring(range.start.column);
var l = lines.length - 1;
if (range.end.row - range.start.row == l)
lines[l] = lines[l].substring(0, range.end.column);
} }
return lines; var lines = this.getLines(range.start.row, range.end.row);
lines[0] = (lines[0] || "").substring(range.start.column);
var l = lines.length - 1;
if (range.end.row - range.start.row == l)
lines[l] = lines[l].substring(0, range.end.column);
return lines.join(this.getNewLineCharacter());
}; };
// Deprecated methods retained for backwards compatibility. this.$clipPosition = function(position) {
this.insertLines = function(row, lines) { var length = this.getLength();
console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead."); if (position.row >= length) {
return this.insertFullLines(row, lines); position.row = Math.max(0, length - 1);
}; position.column = this.getLine(length-1).length;
this.removeLines = function(firstRow, lastRow) { } else if (position.row < 0)
console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead."); position.row = 0;
return this.removeFullLines(firstRow, lastRow); return position;
};
this.insertNewLine = function(position) {
console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, [\'\', \'\']) instead.");
return this.insertMergedLines(position, ["", ""]);
}; };
/** /**
@ -261,160 +241,158 @@ var Document = function(textOrLines) {
* *
**/ **/
this.insert = function(position, text) { this.insert = function(position, text) {
// Only detect new lines if the document has no line break yet. if (!text || text.length === 0)
return position;
position = this.$clipPosition(position);
// only detect new lines if the document has no line break yet
if (this.getLength() <= 1) if (this.getLength() <= 1)
this.$detectNewLine(text); this.$detectNewLine(text);
return this.insertMergedLines(position, this.$split(text)); var lines = this.$split(text);
var firstLine = lines.splice(0, 1)[0];
var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0];
position = this.insertInLine(position, firstLine);
if (lastLine !== null) {
position = this.insertNewLine(position); // terminate first line
position = this._insertLines(position.row, lines);
position = this.insertInLine(position, lastLine || "");
}
return position;
}; };
/** /**
* Inserts `text` into the `position` at the current row. This method also triggers the `"change"` event. * Fires whenever the document changes.
* *
* This differs from the `insert` method in two ways: * Several methods trigger different `"change"` events. Below is a list of each action type, followed by each property that's also available:
* 1. This does NOT handle newline characters (single-line text only). *
* 2. This is faster than the `insert` method for single-line text insertions. * * `"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}
* ```
*
**/
this.insertLines = function(row, lines) {
if (row >= this.getLength())
return this.insert({row: row, column: 0}, "\n" + lines.join("\n"));
return this._insertLines(Math.max(row, 0), lines);
};
this._insertLines = function(row, lines) {
if (lines.length == 0)
return {row: row, column: 0};
// apply doesn't work for big arrays (smallest threshold is on safari 0xFFFF)
// to circumvent that we have to break huge inserts into smaller chunks here
if (lines.length > 0xFFFF) {
var end = this._insertLines(row, lines.slice(0xFFFF));
lines = lines.slice(0, 0xFFFF);
}
var args = [row, 0];
args.push.apply(args, lines);
this.$lines.splice.apply(this.$lines, args);
var range = new Range(row, 0, row + lines.length, 0);
var delta = {
action: "insertLines",
range: range,
lines: lines
};
this._emit("change", { data: delta });
return end || range.end;
};
/**
* 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) {
position = this.$clipPosition(position);
var line = this.$lines[position.row] || "";
this.$lines[position.row] = line.substring(0, position.column);
this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length));
var end = {
row : position.row + 1,
column : 0
};
var delta = {
action: "insertText",
range: Range.fromPoints(position, end),
text: this.getNewLineCharacter()
};
this._emit("change", { data: delta });
return end;
};
/**
* Inserts `text` into the `position` at the current row. This method also triggers the `'change'` event.
* @param {Object} position The position to insert at; it's an object that looks like `{ row: row, column: column}` * @param {Object} position The position to insert at; it's an object that looks like `{ row: row, column: column}`
* @param {String} text A chunk of text * @param {String} text A chunk of text
* @returns {Object} Returns an object containing the final row and column, like this: * @returns {Object} Returns an object containing the final row and column, like this:
* ``` * ```
* {row: endRow, column: 0} * {row: endRow, column: 0}
* ``` * ```
*
**/ **/
this.insertInLine = function(position, text) { this.insertInLine = function(position, text) {
var start = this.clippedPos(position.row, position.column); if (text.length == 0)
var end = this.pos(position.row, position.column + text.length); return position;
this.applyDelta({
start: start,
end: end,
action: "insert",
lines: [text]
}, true);
return this.clonePos(end);
};
this.clippedPos = function(row, column) {
var length = this.getLength();
if (row === undefined) {
row = length;
} else if (row < 0) {
row = 0;
} else if (row >= length) {
row = length - 1;
column = undefined;
}
var line = this.getLine(row);
if (column == undefined)
column = line.length;
column = Math.min(Math.max(column, 0), line.length);
return {row: row, column: column};
};
this.clonePos = function(pos) {
return {row: pos.row, column: pos.column};
};
this.pos = function(row, column) {
return {row: row, column: column};
};
this.$clipPosition = function(position) {
var length = this.getLength();
if (position.row >= length) {
position.row = Math.max(0, length - 1);
position.column = this.getLine(length - 1).length;
} else {
position.row = Math.max(0, position.row);
position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
}
return position;
};
/** var line = this.$lines[position.row] || "";
* Fires whenever the document changes.
* this.$lines[position.row] = line.substring(0, position.column) + text
* Several methods trigger different `"change"` events. Below is a list of each action type, followed by each property that's also available: + line.substring(position.column);
*
* * `"insert"`
* * `range`: the [[Range]] of the change within the document
* * `lines`: the lines being added
* * `"remove"`
* * `range`: the [[Range]] of the change within the document
* * `lines`: the lines 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 as full lines (does not merge with existing line), 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}
* ```
*
**/
this.insertFullLines = function(row, lines) {
// Clip to document.
// Allow one past the document end.
row = Math.min(Math.max(row, 0), this.getLength());
// Calculate insertion point.
var column = 0;
if (row < this.getLength()) {
// Insert before the specified row.
lines = lines.concat([""]);
column = 0;
} else {
// Insert after the last row in the document.
lines = [""].concat(lines);
row--;
column = this.$lines[row].length;
}
// Insert.
this.insertMergedLines({row: row, column: column}, lines);
};
/**
* Inserts the elements in `lines` into the document, starting at the position 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}
* ```
*
**/
this.insertMergedLines = function(position, lines) {
var start = this.clippedPos(position.row, position.column);
var end = { var end = {
row: start.row + lines.length - 1, row : position.row,
column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length column : position.column + text.length
}; };
this.applyDelta({ var delta = {
start: start, action: "insertText",
end: end, range: Range.fromPoints(position, end),
action: "insert", text: text
lines: lines };
}); this._emit("change", { data: delta });
return this.clonePos(end); return end;
}; };
/** /**
@ -424,90 +402,113 @@ var Document = function(textOrLines) {
* *
**/ **/
this.remove = function(range) { this.remove = function(range) {
var start = this.clippedPos(range.start.row, range.start.column); if (!range instanceof Range)
var end = this.clippedPos(range.end.row, range.end.column); range = Range.fromPoints(range.start, range.end);
this.applyDelta({ // clip to document
start: start, range.start = this.$clipPosition(range.start);
end: end, range.end = this.$clipPosition(range.end);
action: "remove",
lines: this.getLinesForRange({start: start, end: end}) if (range.isEmpty())
}); return range.start;
return this.clonePos(start);
var firstRow = range.start.row;
var lastRow = range.end.row;
if (range.isMultiLine()) {
var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1;
var lastFullRow = lastRow - 1;
if (range.end.column > 0)
this.removeInLine(lastRow, 0, range.end.column);
if (lastFullRow >= firstFullRow)
this._removeLines(firstFullRow, lastFullRow);
if (firstFullRow != firstRow) {
this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length);
this.removeNewLine(range.start.row);
}
}
else {
this.removeInLine(firstRow, range.start.column, range.end.column);
}
return range.start;
}; };
/** /**
* Removes the specified columns from the `row`. This method also triggers a `"change"` event. * Removes the specified columns from the `row`. This method also triggers the `'change'` event.
* @param {Number} row The row to remove from * @param {Number} row The row to remove from
* @param {Number} startColumn The column to start removing at * @param {Number} startColumn The column to start removing at
* @param {Number} endColumn The column to stop 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. * @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.
* *
**/ **/
this.removeInLine = function(row, startColumn, endColumn) { this.removeInLine = function(row, startColumn, endColumn) {
var start = this.clippedPos(row, startColumn); if (startColumn == endColumn)
var end = this.clippedPos(row, endColumn); return;
this.applyDelta({ var range = new Range(row, startColumn, row, endColumn);
start: start, var line = this.getLine(row);
end: end, var removed = line.substring(startColumn, endColumn);
action: "remove", var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length);
lines: this.getLinesForRange({start: start, end: end}) this.$lines.splice(row, 1, newLine);
}, true);
var delta = {
return this.clonePos(start); action: "removeText",
range: range,
text: removed
};
this._emit("change", { data: delta });
return range.start;
}; };
/** /**
* Removes a range of full lines. This method also triggers the `"change"` event. * Removes a range of full lines. This method also triggers the `'change'` event.
* @param {Number} firstRow The first row to be removed * @param {Number} firstRow The first row to be removed
* @param {Number} lastRow The last row to be removed * @param {Number} lastRow The last row to be removed
* @returns {[String]} Returns all the removed lines. * @returns {[String]} Returns all the removed lines.
* *
**/ **/
this.removeFullLines = function(firstRow, lastRow) { this.removeLines = function(firstRow, lastRow) {
// Clip to document. if (firstRow < 0 || lastRow >= this.getLength())
firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1); return this.remove(new Range(firstRow, 0, lastRow + 1, 0));
lastRow = Math.min(Math.max(0, lastRow ), this.getLength() - 1); return this._removeLines(firstRow, lastRow);
};
// Calculate deletion range.
// Delete the ending new line unless we're at the end of the document. this._removeLines = function(firstRow, lastRow) {
// If we're at the end of the document, delete the starting new line. var range = new Range(firstRow, 0, lastRow + 1, 0);
var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0; var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1);
var deleteLastNewLine = lastRow < this.getLength() - 1;
var startRow = ( deleteFirstNewLine ? firstRow - 1 : firstRow ); var delta = {
var startCol = ( deleteFirstNewLine ? this.getLine(startRow).length : 0 ); action: "removeLines",
var endRow = ( deleteLastNewLine ? lastRow + 1 : lastRow ); range: range,
var endCol = ( deleteLastNewLine ? 0 : this.getLine(endRow).length ); nl: this.getNewLineCharacter(),
var range = new Range(startRow, startCol, endRow, endCol); lines: removed
};
// Store delelted lines with bounding newlines ommitted (maintains previous behavior). this._emit("change", { data: delta });
var deletedLines = this.$lines.slice(firstRow, lastRow + 1); return removed;
this.applyDelta({
start: range.start,
end: range.end,
action: "remove",
lines: this.getLinesForRange(range)
});
// Return the deleted lines.
return deletedLines;
}; };
/** /**
* Removes the new line between `row` and the row immediately following it. This method also triggers the `"change"` event. * 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 * @param {Number} row The row to check
* *
**/ **/
this.removeNewLine = function(row) { this.removeNewLine = function(row) {
if (row < this.getLength() - 1 && row >= 0) { var firstLine = this.getLine(row);
this.applyDelta({ var secondLine = this.getLine(row+1);
start: this.pos(row, this.getLine(row).length),
end: this.pos(row + 1, 0), var range = new Range(row, firstLine.length, row+1, 0);
action: "remove", var line = firstLine + secondLine;
lines: ["", ""]
}); this.$lines.splice(row, 2, line);
}
var delta = {
action: "removeText",
range: range,
text: this.getNewLineCharacter()
};
this._emit("change", { data: delta });
}; };
/** /**
@ -523,7 +524,7 @@ var Document = function(textOrLines) {
this.replace = function(range, text) { this.replace = function(range, text) {
if (!range instanceof Range) if (!range instanceof Range)
range = Range.fromPoints(range.start, range.end); range = Range.fromPoints(range.start, range.end);
if (text.length === 0 && range.isEmpty()) if (text.length == 0 && range.isEmpty())
return range.start; return range.start;
// Shortcut: If the text we want to insert is the same as it is already // Shortcut: If the text we want to insert is the same as it is already
@ -532,106 +533,55 @@ var Document = function(textOrLines) {
return range.end; return range.end;
this.remove(range); this.remove(range);
var end;
if (text) { if (text) {
end = this.insert(range.start, text); var end = this.insert(range.start, text);
} }
else { else {
end = range.start; end = range.start;
} }
return end; return end;
}; };
/** /**
* Applies all changes in `deltas` to the document. * Applies all the changes previously accumulated. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`.
* @param {Array} deltas An array of delta objects (can include "insert" and "remove" actions)
**/ **/
this.applyDeltas = function(deltas) { this.applyDeltas = function(deltas) {
for (var i=0; i<deltas.length; i++) { for (var i=0; i<deltas.length; i++) {
this.applyDelta(deltas[i]); var delta = deltas[i];
var range = Range.fromPoints(delta.range.start, delta.range.end);
if (delta.action == "insertLines")
this.insertLines(range.start.row, delta.lines);
else if (delta.action == "insertText")
this.insert(range.start, delta.text);
else if (delta.action == "removeLines")
this._removeLines(range.start.row, range.end.row - 1);
else if (delta.action == "removeText")
this.remove(range);
} }
}; };
/** /**
* Reverts all changes in `deltas` from the document. * Reverts any changes previously applied. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`.
* @param {Array} deltas An array of delta objects (can include "insert" and "remove" actions)
**/ **/
this.revertDeltas = function(deltas) { this.revertDeltas = function(deltas) {
for (var i=deltas.length-1; i>=0; i--) { for (var i=deltas.length-1; i>=0; i--) {
this.revertDelta(deltas[i]); var delta = deltas[i];
var range = Range.fromPoints(delta.range.start, delta.range.end);
if (delta.action == "insertLines")
this._removeLines(range.start.row, range.end.row - 1);
else if (delta.action == "insertText")
this.remove(range);
else if (delta.action == "removeLines")
this._insertLines(range.start.row, delta.lines);
else if (delta.action == "removeText")
this.insert(range.start, delta.text);
} }
}; };
/**
* Applies `delta` to the document.
* @param {Object} delta A delta object (can include "insert" and "remove" actions)
**/
this.applyDelta = function(delta, doNotValidate) {
var isInsert = delta.action == "insert";
// An empty range is a NOOP.
if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
: !Range.comparePoints(delta.start, delta.end)) {
return;
}
if (isInsert && delta.lines.length > 20000)
this.$splitAndapplyLargeDelta(delta, 20000);
// Apply.
applyDelta(this.$lines, delta, doNotValidate);
this._signal("change", delta);
};
this.$splitAndapplyLargeDelta = function(delta, MAX) {
// Split large insert deltas. This is necessary because:
// 1. We need to support splicing delta lines into the document via $lines.splice.apply(...)
// 2. fn.apply() doesn't work for a large number of params. The smallest threshold is on chrome 40 ~42000.
// we use 20000 to leave some space for actual stack
//
// To Do: Ideally we'd be consistent and also split 'delete' deltas. We don't do this now, because delete
// delta handling is too slow. If we make delete delta handling faster we can split all large deltas
// as shown in https://gist.github.com/aldendaniels/8367109#file-document-snippet-js
// If we do this, update validateDelta() to limit the number of lines in a delete delta.
var lines = delta.lines;
var l = lines.length;
var row = delta.start.row;
var column = delta.start.column;
var from = 0, to = 0;
do {
from = to;
to += MAX - 1;
var chunk = lines.slice(from, to);
if (to > l) {
// Update remaining delta.
delta.lines = chunk;
delta.start.row = row + from;
delta.start.column = column;
break;
}
chunk.push("");
this.applyDelta({
start: this.pos(row + from, column),
end: this.pos(row + to, column = 0),
action: delta.action,
lines: chunk
}, true);
} while(true);
};
/**
* Reverts `delta` from the document.
* @param {Object} delta A delta object (can include "insert" and "remove" actions)
**/
this.revertDelta = function(delta) {
this.applyDelta({
start: this.clonePos(delta.start),
end: this.clonePos(delta.end),
action: (delta.action == "insert" ? "remove" : "insert"),
lines: delta.lines.slice()
});
};
/** /**
* Converts an index position in a document to a `{row, column}` object. * Converts an index position in a document to a `{row, column}` object.
* *

View file

@ -46,7 +46,7 @@ module.exports = {
var doc = new Document(["12", "34"]); var doc = new Document(["12", "34"]);
var deltas = []; var deltas = [];
doc.on("change", function(e) { deltas.push(e); }); doc.on("change", function(e) { deltas.push(e.data); });
doc.insert({row: 0, column: 1}, "juhu"); doc.insert({row: 0, column: 1}, "juhu");
assert.equal(doc.getValue(), ["1juhu2", "34"].join("\n")); assert.equal(doc.getValue(), ["1juhu2", "34"].join("\n"));
@ -63,9 +63,9 @@ module.exports = {
var doc = new Document(["12", "34"]); var doc = new Document(["12", "34"]);
var deltas = []; var deltas = [];
doc.on("change", function(e) { deltas.push(e); }); doc.on("change", function(e) { deltas.push(e.data); });
doc.insertMergedLines({row: 0, column: 1}, ['', '']); doc.insertNewLine({row: 0, column: 1});
assert.equal(doc.getValue(), ["1", "2", "34"].join("\n")); assert.equal(doc.getValue(), ["1", "2", "34"].join("\n"));
var d = deltas.concat(); var d = deltas.concat();
@ -80,9 +80,9 @@ module.exports = {
var doc = new Document(["12", "34"]); var doc = new Document(["12", "34"]);
var deltas = []; var deltas = [];
doc.on("change", function(e) { deltas.push(e); }); doc.on("change", function(e) { deltas.push(e.data); });
doc.insertFullLines(0, ["aa", "bb"]); doc.insertLines(0, ["aa", "bb"]);
assert.equal(doc.getValue(), ["aa", "bb", "12", "34"].join("\n")); assert.equal(doc.getValue(), ["aa", "bb", "12", "34"].join("\n"));
var d = deltas.concat(); var d = deltas.concat();
@ -97,9 +97,9 @@ module.exports = {
var doc = new Document(["12", "34"]); var doc = new Document(["12", "34"]);
var deltas = []; var deltas = [];
doc.on("change", function(e) { deltas.push(e); }); doc.on("change", function(e) { deltas.push(e.data); });
doc.insertFullLines(2, ["aa", "bb"]); doc.insertLines(2, ["aa", "bb"]);
assert.equal(doc.getValue(), ["12", "34", "aa", "bb"].join("\n")); assert.equal(doc.getValue(), ["12", "34", "aa", "bb"].join("\n"));
}, },
@ -107,9 +107,9 @@ module.exports = {
var doc = new Document(["12", "34"]); var doc = new Document(["12", "34"]);
var deltas = []; var deltas = [];
doc.on("change", function(e) { deltas.push(e); }); doc.on("change", function(e) { deltas.push(e.data); });
doc.insertFullLines(1, ["aa", "bb"]); doc.insertLines(1, ["aa", "bb"]);
assert.equal(doc.getValue(), ["12", "aa", "bb", "34"].join("\n")); assert.equal(doc.getValue(), ["12", "aa", "bb", "34"].join("\n"));
var d = deltas.concat(); var d = deltas.concat();
@ -124,7 +124,7 @@ module.exports = {
var doc = new Document(["12", "34"]); var doc = new Document(["12", "34"]);
var deltas = []; var deltas = [];
doc.on("change", function(e) { deltas.push(e); }); doc.on("change", function(e) { deltas.push(e.data); });
doc.insert({row: 0, column: 0}, "aa\nbb\ncc"); doc.insert({row: 0, column: 0}, "aa\nbb\ncc");
assert.equal(doc.getValue(), ["aa", "bb", "cc12", "34"].join("\n")); assert.equal(doc.getValue(), ["aa", "bb", "cc12", "34"].join("\n"));
@ -141,9 +141,9 @@ module.exports = {
var doc = new Document(["12", "34"]); var doc = new Document(["12", "34"]);
var deltas = []; var deltas = [];
doc.on("change", function(e) { deltas.push(e); }); doc.on("change", function(e) { deltas.push(e.data); });
doc.insert({row: 1, column: 2}, "aa\nbb\ncc"); doc.insert({row: 2, column: 0}, "aa\nbb\ncc");
assert.equal(doc.getValue(), ["12", "34aa", "bb", "cc"].join("\n")); assert.equal(doc.getValue(), ["12", "34aa", "bb", "cc"].join("\n"));
var d = deltas.concat(); var d = deltas.concat();
@ -158,7 +158,7 @@ module.exports = {
var doc = new Document(["12", "34"]); var doc = new Document(["12", "34"]);
var deltas = []; var deltas = [];
doc.on("change", function(e) { deltas.push(e); }); doc.on("change", function(e) { deltas.push(e.data); });
doc.insert({row: 0, column: 1}, "aa\nbb\ncc"); doc.insert({row: 0, column: 1}, "aa\nbb\ncc");
assert.equal(doc.getValue(), ["1aa", "bb", "cc2", "34"].join("\n")); assert.equal(doc.getValue(), ["1aa", "bb", "cc2", "34"].join("\n"));
@ -175,7 +175,7 @@ module.exports = {
var doc = new Document(["1234", "5678"]); var doc = new Document(["1234", "5678"]);
var deltas = []; var deltas = [];
doc.on("change", function(e) { deltas.push(e); }); doc.on("change", function(e) { deltas.push(e.data); });
doc.remove(new Range(0, 1, 0, 3)); doc.remove(new Range(0, 1, 0, 3));
assert.equal(doc.getValue(), ["14", "5678"].join("\n")); assert.equal(doc.getValue(), ["14", "5678"].join("\n"));
@ -192,7 +192,7 @@ module.exports = {
var doc = new Document(["1234", "5678"]); var doc = new Document(["1234", "5678"]);
var deltas = []; var deltas = [];
doc.on("change", function(e) { deltas.push(e); }); doc.on("change", function(e) { deltas.push(e.data); });
doc.remove(new Range(0, 4, 1, 0)); doc.remove(new Range(0, 4, 1, 0));
assert.equal(doc.getValue(), ["12345678"].join("\n")); assert.equal(doc.getValue(), ["12345678"].join("\n"));
@ -209,7 +209,7 @@ module.exports = {
var doc = new Document(["1234", "5678", "abcd"]); var doc = new Document(["1234", "5678", "abcd"]);
var deltas = []; var deltas = [];
doc.on("change", function(e) { deltas.push(e); }); doc.on("change", function(e) { deltas.push(e.data); });
doc.remove(new Range(0, 2, 2, 2)); doc.remove(new Range(0, 2, 2, 2));
assert.equal(doc.getValue(), ["12cd"].join("\n")); assert.equal(doc.getValue(), ["12cd"].join("\n"));
@ -226,7 +226,7 @@ module.exports = {
var doc = new Document(["1234", "5678", "abcd"]); var doc = new Document(["1234", "5678", "abcd"]);
var deltas = []; var deltas = [];
doc.on("change", function(e) { deltas.push(e); }); doc.on("change", function(e) { deltas.push(e.data); });
doc.remove(new Range(1, 0, 3, 0)); doc.remove(new Range(1, 0, 3, 0));
assert.equal(doc.getValue(), ["1234", ""].join("\n")); assert.equal(doc.getValue(), ["1234", ""].join("\n"));
@ -235,7 +235,7 @@ module.exports = {
"test: remove lines should return the removed lines" : function() { "test: remove lines should return the removed lines" : function() {
var doc = new Document(["1234", "5678", "abcd"]); var doc = new Document(["1234", "5678", "abcd"]);
var removed = doc.removeFullLines(1, 2); var removed = doc.removeLines(1, 2);
assert.equal(removed.join("\n"), ["5678", "abcd"].join("\n")); assert.equal(removed.join("\n"), ["5678", "abcd"].join("\n"));
}, },
@ -296,35 +296,6 @@ module.exports = {
"test: empty document has to contain one line": function() { "test: empty document has to contain one line": function() {
var doc = new Document(""); var doc = new Document("");
assert.equal(doc.$lines.length, 1); assert.equal(doc.$lines.length, 1);
},
"test: ignore empty delta": function() {
var doc = new Document("");
doc.on("change", function() {
throw "should ignore empty delta";
})
doc.insert({row: 0, column: 0}, "");
doc.insert({row: 1, column: 1}, "");
doc.remove({start: {row: 1, column: 1}, end: {row: 1, column: 1}});
},
"test: inserting huge delta": function() {
var doc = new Document("");
var val = "";
var MAX = 0xF000;
for (var i = 0; i < 10 * MAX; i++) {
val += i + "\n"
}
doc.setValue(val);
assert.equal(doc.getValue(), val);
for (var i = 3 * MAX + 2; i >= 3 * MAX - 2; i--) {
val = doc.getLines(0, i).join("\n");
doc.setValue("\nab");
assert.equal(doc.getValue(), "\nab");
doc.insert({row: 1, column: 1}, val);
assert.equal(doc.getValue(), "\na" + val + "b");
}
} }
}; };

View file

@ -151,7 +151,7 @@ var EditSession = function(text, mode) {
this.$foldData = []; this.$foldData = [];
this.$foldData.toString = function() { this.$foldData.toString = function() {
return this.join("\n"); return this.join("\n");
}; }
this.on("changeFold", this.onChangeFold.bind(this)); this.on("changeFold", this.onChangeFold.bind(this));
this.$onChange = this.onChange.bind(this); this.$onChange = this.onChange.bind(this);
@ -163,7 +163,7 @@ var EditSession = function(text, mode) {
config.resetOptions(this); config.resetOptions(this);
this.setMode(mode); this.setMode(mode);
config._signal("session", this); config._emit("session", this);
}; };
@ -249,12 +249,13 @@ var EditSession = function(text, mode) {
this.$resetRowCache(fold.start.row); this.$resetRowCache(fold.start.row);
}; };
this.onChange = function(delta) { this.onChange = function(e) {
var delta = e.data;
this.$modified = true; this.$modified = true;
this.$resetRowCache(delta.start.row); this.$resetRowCache(delta.range.start.row);
var removedFolds = this.$updateInternalDataOnChange(delta); var removedFolds = this.$updateInternalDataOnChange(e);
if (!this.$fromUndo && this.$undoManager && !delta.ignore) { if (!this.$fromUndo && this.$undoManager && !delta.ignore) {
this.$deltasDoc.push(delta); this.$deltasDoc.push(delta);
if (removedFolds && removedFolds.length != 0) { if (removedFolds && removedFolds.length != 0) {
@ -267,24 +268,26 @@ var EditSession = function(text, mode) {
this.$informUndoManager.schedule(); this.$informUndoManager.schedule();
} }
this.bgTokenizer && this.bgTokenizer.$updateOnChange(delta); this.bgTokenizer.$updateOnChange(delta);
this._signal("change", delta); this._emit("change", e);
}; };
/** /**
* Sets the session text. * Sets the session text.
* @param {String} text The new text to place * @param {String} text The new text to place
* *
*
*
**/ **/
this.setValue = function(text) { this.setValue = function(text) {
this.doc.setValue(text); this.doc.setValue(text);
this.selection.moveTo(0, 0); this.selection.moveCursorTo(0, 0);
this.selection.clearSelection();
this.$resetRowCache(0); this.$resetRowCache(0);
this.$deltas = []; this.$deltas = [];
this.$deltasDoc = []; this.$deltasDoc = [];
this.$deltasFold = []; this.$deltasFold = [];
this.setUndoManager(this.$undoManager);
this.getUndoManager().reset(); this.getUndoManager().reset();
}; };
@ -409,7 +412,7 @@ var EditSession = function(text, mode) {
} }
self.mergeUndoDeltas = false; self.mergeUndoDeltas = false;
self.$deltas = []; self.$deltas = [];
}; }
this.$informUndoManager = lang.delayedCall(this.$syncInformUndoManager); this.$informUndoManager = lang.delayedCall(this.$syncInformUndoManager);
} }
}; };
@ -467,7 +470,7 @@ var EditSession = function(text, mode) {
* @param {Number} tabSize The new tab size * @param {Number} tabSize The new tab size
**/ **/
this.setTabSize = function(tabSize) { this.setTabSize = function(tabSize) {
this.setOption("tabSize", tabSize); this.setOption("tabSize", tabSize)
}; };
/** /**
* Returns the current tab size. * Returns the current tab size.
@ -483,7 +486,7 @@ var EditSession = function(text, mode) {
* *
**/ **/
this.isTabStop = function(position) { this.isTabStop = function(position) {
return this.$useSoftTabs && (position.column % this.$tabSize === 0); return this.$useSoftTabs && (position.column % this.$tabSize == 0);
}; };
this.$overwrite = false; this.$overwrite = false;
@ -497,7 +500,7 @@ var EditSession = function(text, mode) {
* *
**/ **/
this.setOverwrite = function(overwrite) { this.setOverwrite = function(overwrite) {
this.setOption("overwrite", overwrite); this.setOption("overwrite", overwrite)
}; };
/** /**
@ -525,7 +528,7 @@ var EditSession = function(text, mode) {
if (!this.$decorations[row]) if (!this.$decorations[row])
this.$decorations[row] = ""; this.$decorations[row] = "";
this.$decorations[row] += " " + className; this.$decorations[row] += " " + className;
this._signal("changeBreakpoint", {}); this._emit("changeBreakpoint", {});
}; };
/** /**
@ -537,7 +540,7 @@ var EditSession = function(text, mode) {
**/ **/
this.removeGutterDecoration = function(row, className) { this.removeGutterDecoration = function(row, className) {
this.$decorations[row] = (this.$decorations[row] || "").replace(" " + className, ""); this.$decorations[row] = (this.$decorations[row] || "").replace(" " + className, "");
this._signal("changeBreakpoint", {}); this._emit("changeBreakpoint", {});
}; };
/** /**
@ -560,7 +563,7 @@ var EditSession = function(text, mode) {
for (var i=0; i<rows.length; i++) { for (var i=0; i<rows.length; i++) {
this.$breakpoints[rows[i]] = "ace_breakpoint"; this.$breakpoints[rows[i]] = "ace_breakpoint";
} }
this._signal("changeBreakpoint", {}); this._emit("changeBreakpoint", {});
}; };
/** /**
@ -568,7 +571,7 @@ var EditSession = function(text, mode) {
**/ **/
this.clearBreakpoints = function() { this.clearBreakpoints = function() {
this.$breakpoints = []; this.$breakpoints = [];
this._signal("changeBreakpoint", {}); this._emit("changeBreakpoint", {});
}; };
/** /**
@ -585,7 +588,7 @@ var EditSession = function(text, mode) {
this.$breakpoints[row] = className; this.$breakpoints[row] = className;
else else
delete this.$breakpoints[row]; delete this.$breakpoints[row];
this._signal("changeBreakpoint", {}); this._emit("changeBreakpoint", {});
}; };
/** /**
@ -596,7 +599,7 @@ var EditSession = function(text, mode) {
**/ **/
this.clearBreakpoint = function(row) { this.clearBreakpoint = function(row) {
delete this.$breakpoints[row]; delete this.$breakpoints[row];
this._signal("changeBreakpoint", {}); this._emit("changeBreakpoint", {});
}; };
/** /**
@ -619,14 +622,14 @@ var EditSession = function(text, mode) {
clazz : clazz, clazz : clazz,
inFront: !!inFront, inFront: !!inFront,
id: id id: id
}; }
if (inFront) { if (inFront) {
this.$frontMarkers[id] = marker; this.$frontMarkers[id] = marker;
this._signal("changeFrontMarker"); this._emit("changeFrontMarker")
} else { } else {
this.$backMarkers[id] = marker; this.$backMarkers[id] = marker;
this._signal("changeBackMarker"); this._emit("changeBackMarker")
} }
return id; return id;
@ -649,10 +652,10 @@ var EditSession = function(text, mode) {
if (inFront) { if (inFront) {
this.$frontMarkers[id] = marker; this.$frontMarkers[id] = marker;
this._signal("changeFrontMarker"); this._emit("changeFrontMarker")
} else { } else {
this.$backMarkers[id] = marker; this.$backMarkers[id] = marker;
this._signal("changeBackMarker"); this._emit("changeBackMarker")
} }
return marker; return marker;
@ -673,15 +676,15 @@ var EditSession = function(text, mode) {
var markers = marker.inFront ? this.$frontMarkers : this.$backMarkers; var markers = marker.inFront ? this.$frontMarkers : this.$backMarkers;
if (marker) { if (marker) {
delete (markers[markerId]); delete (markers[markerId]);
this._signal(marker.inFront ? "changeFrontMarker" : "changeBackMarker"); this._emit(marker.inFront ? "changeFrontMarker" : "changeBackMarker");
} }
}; };
/** /**
* Returns an object containing all of the markers, either front or back. * Returns an array containing the IDs of all the markers, either front or back.
* @param {Boolean} inFront If `true`, indicates you only want front markers; `false` indicates only back markers * @param {Boolean} inFront If `true`, indicates you only want front markers; `false` indicates only back markers
* *
* @returns {Object} * @returns {Array}
**/ **/
this.getMarkers = function(inFront) { this.getMarkers = function(inFront) {
return inFront ? this.$frontMarkers : this.$backMarkers; return inFront ? this.$frontMarkers : this.$backMarkers;
@ -693,7 +696,7 @@ var EditSession = function(text, mode) {
this.$searchHighlight = this.addDynamicMarker(highlight); this.$searchHighlight = this.addDynamicMarker(highlight);
} }
this.$searchHighlight.setRegexp(re); this.$searchHighlight.setRegexp(re);
}; }
// experimental // experimental
this.highlightLines = function(startRow, endRow, clazz, inFront) { this.highlightLines = function(startRow, endRow, clazz, inFront) {
@ -725,7 +728,7 @@ var EditSession = function(text, mode) {
**/ **/
this.setAnnotations = function(annotations) { this.setAnnotations = function(annotations) {
this.$annotations = annotations; this.$annotations = annotations;
this._signal("changeAnnotation", {}); this._emit("changeAnnotation", {});
}; };
/** /**
@ -855,7 +858,7 @@ var EditSession = function(text, mode) {
this.onReloadTokenizer = function(e) { this.onReloadTokenizer = function(e) {
var rows = e.data; var rows = e.data;
this.bgTokenizer.start(rows.first); this.bgTokenizer.start(rows.first);
this._signal("tokenizerUpdate", e); this._emit("tokenizerUpdate", e);
}; };
this.$modes = {}; this.$modes = {};
@ -892,17 +895,17 @@ var EditSession = function(text, mode) {
config.loadModule(["mode", path], function(m) { config.loadModule(["mode", path], function(m) {
if (this.$modeId !== path) if (this.$modeId !== path)
return cb && cb(); return cb && cb();
if (this.$modes[path] && !options) { if (this.$modes[path] && !options)
this.$onChangeMode(this.$modes[path]); return this.$onChangeMode(this.$modes[path]);
} else if (m && m.Mode) { if (m && m.Mode) {
m = new m.Mode(options); m = new m.Mode(options);
if (!options) { if (!options) {
this.$modes[path] = m; this.$modes[path] = m;
m.$id = path; m.$id = path;
} }
this.$onChangeMode(m); this.$onChangeMode(m);
cb && cb();
} }
cb && cb();
}.bind(this)); }.bind(this));
// set mode to text until loading is finished // set mode to text until loading is finished
@ -934,7 +937,7 @@ var EditSession = function(text, mode) {
this.bgTokenizer = new BackgroundTokenizer(tokenizer); this.bgTokenizer = new BackgroundTokenizer(tokenizer);
var _self = this; var _self = this;
this.bgTokenizer.addEventListener("update", function(e) { this.bgTokenizer.addEventListener("update", function(e) {
_self._signal("tokenizerUpdate", e); _self._emit("tokenizerUpdate", e);
}); });
} else { } else {
this.bgTokenizer.setTokenizer(tokenizer); this.bgTokenizer.setTokenizer(tokenizer);
@ -947,30 +950,33 @@ var EditSession = function(text, mode) {
if (!$isPlaceholder) { if (!$isPlaceholder) {
// experimental method, used by c9 findiniles
if (mode.attachToSession)
mode.attachToSession(this);
this.$options.wrapMethod.set.call(this, this.$wrapMethod); this.$options.wrapMethod.set.call(this, this.$wrapMethod);
this.$setFolding(mode.foldingRules); this.$setFolding(mode.foldingRules);
this.bgTokenizer.start(0);
this._emit("changeMode"); this._emit("changeMode");
this.bgTokenizer.start(0);
} }
}; };
this.$stopWorker = function() { this.$stopWorker = function() {
if (this.$worker) { if (this.$worker)
this.$worker.terminate(); this.$worker.terminate();
this.$worker = null;
} this.$worker = null;
}; };
this.$startWorker = function() { this.$startWorker = function() {
try { if (typeof Worker !== "undefined" && !require.noWorker) {
this.$worker = this.$mode.createWorker(this); try {
} catch (e) { this.$worker = this.$mode.createWorker(this);
config.warn("Could not load worker", e); } catch (e) {
this.$worker = null; console.log("Could not load worker");
console.log(e);
this.$worker = null;
}
} }
else
this.$worker = null;
}; };
/** /**
@ -1037,14 +1043,14 @@ var EditSession = function(text, mode) {
}; };
this.getLineWidgetMaxWidth = function() { this.getLineWidgetMaxWidth = function() {
if (this.lineWidgetsWidth != null) return this.lineWidgetsWidth; if (this.lineWidgetsWidth != null) return this.lineWidgetsWidth
var width = 0; var width = 0;
this.lineWidgets.forEach(function(w) { this.lineWidgets.forEach(function(w) {
if (w && w.screenWidth > width) if (w && w.screenWidth > width)
width = w.screenWidth; width = w.screenWidth;
}); });
return this.lineWidgetWidth = width; return this.lineWidgetWidth = width;
}; }
this.$computeWidth = function(force) { this.$computeWidth = function(force) {
if (this.$modified || force) { if (this.$modified || force) {
@ -1145,19 +1151,6 @@ var EditSession = function(text, mode) {
this.remove = function(range) { this.remove = function(range) {
return this.doc.remove(range); return this.doc.remove(range);
}; };
/**
* 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.
*
* @related Document.removeFullLines
*
**/
this.removeFullLines = function(firstRow, lastRow){
return this.doc.removeFullLines(firstRow, lastRow);
};
/** /**
* Reverts previous changes to your document. * Reverts previous changes to your document.
@ -1234,36 +1227,39 @@ var EditSession = function(text, mode) {
this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) { this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
function isInsert(delta) { function isInsert(delta) {
return isUndo ? delta.action !== "insert" : delta.action === "insert"; var insert =
delta.action === "insertText" || delta.action === "insertLines";
return isUndo ? !insert : insert;
} }
var delta = deltas[0]; var delta = deltas[0];
var range, point; var range, point;
var lastDeltaIsInsert = false; var lastDeltaIsInsert = false;
if (isInsert(delta)) { if (isInsert(delta)) {
range = Range.fromPoints(delta.start, delta.end); range = Range.fromPoints(delta.range.start, delta.range.end);
lastDeltaIsInsert = true; lastDeltaIsInsert = true;
} else { } else {
range = Range.fromPoints(delta.start, delta.start); range = Range.fromPoints(delta.range.start, delta.range.start);
lastDeltaIsInsert = false; lastDeltaIsInsert = false;
} }
for (var i = 1; i < deltas.length; i++) { for (var i = 1; i < deltas.length; i++) {
delta = deltas[i]; delta = deltas[i];
if (isInsert(delta)) { if (isInsert(delta)) {
point = delta.start; point = delta.range.start;
if (range.compare(point.row, point.column) == -1) { if (range.compare(point.row, point.column) == -1) {
range.setStart(point); range.setStart(delta.range.start);
} }
point = delta.end; point = delta.range.end;
if (range.compare(point.row, point.column) == 1) { if (range.compare(point.row, point.column) == 1) {
range.setEnd(point); range.setEnd(delta.range.end);
} }
lastDeltaIsInsert = true; lastDeltaIsInsert = true;
} else { } else {
point = delta.start; point = delta.range.start;
if (range.compare(point.row, point.column) == -1) { if (range.compare(point.row, point.column) == -1) {
range = Range.fromPoints(delta.start, delta.start); range =
Range.fromPoints(delta.range.start, delta.range.start);
} }
lastDeltaIsInsert = false; lastDeltaIsInsert = false;
} }
@ -1272,7 +1268,7 @@ var EditSession = function(text, mode) {
// Check if this range and the last undo range has something in common. // Check if this range and the last undo range has something in common.
// If true, merge the ranges. // If true, merge the ranges.
if (lastUndoRange != null) { if (lastUndoRange != null) {
if (Range.comparePoints(lastUndoRange.start, range.start) === 0) { if (Range.comparePoints(lastUndoRange.start, range.start) == 0) {
lastUndoRange.start.column += range.end.column - range.start.column; lastUndoRange.start.column += range.end.column - range.start.column;
lastUndoRange.end.column += range.end.column - range.start.column; lastUndoRange.end.column += range.end.column - range.start.column;
} }
@ -1377,7 +1373,7 @@ var EditSession = function(text, mode) {
this.indentRows = function(startRow, endRow, indentString) { this.indentRows = function(startRow, endRow, indentString) {
indentString = indentString.replace(/\t/g, this.getTabString()); indentString = indentString.replace(/\t/g, this.getTabString());
for (var row=startRow; row<=endRow; row++) for (var row=startRow; row<=endRow; row++)
this.doc.insertInLine({row: row, column: 0}, indentString); this.insert({row: row, column:0}, indentString);
}; };
/** /**
@ -1434,11 +1430,11 @@ var EditSession = function(text, mode) {
x.end.row += diff; x.end.row += diff;
return x; return x;
}); });
var lines = dir == 0 var lines = dir == 0
? this.doc.getLines(firstRow, lastRow) ? this.doc.getLines(firstRow, lastRow)
: this.doc.removeFullLines(firstRow, lastRow); : this.doc.removeLines(firstRow, lastRow);
this.doc.insertFullLines(firstRow+diff, lines); this.doc.insertLines(firstRow+diff, lines);
folds.length && this.addFolds(folds); folds.length && this.addFolds(folds);
return diff; return diff;
}; };
@ -1448,6 +1444,8 @@ var EditSession = function(text, mode) {
* @param {Number} lastRow The final row to move up * @param {Number} lastRow The final row to move up
* @returns {Number} If `firstRow` is less-than or equal to 0, this function returns 0. Otherwise, on success, it returns -1. * @returns {Number} If `firstRow` is less-than or equal to 0, this function returns 0. Otherwise, on success, it returns -1.
* *
* @related Document.insertLines
*
**/ **/
this.moveLinesUp = function(firstRow, lastRow) { this.moveLinesUp = function(firstRow, lastRow) {
return this.$moveLines(firstRow, lastRow, -1); return this.$moveLines(firstRow, lastRow, -1);
@ -1458,6 +1456,8 @@ var EditSession = function(text, mode) {
* @param {Number} firstRow The starting row to move down * @param {Number} firstRow The starting row to move down
* @param {Number} lastRow The final row to move down * @param {Number} lastRow The final row to move down
* @returns {Number} If `firstRow` is less-than or equal to 0, this function returns 0. Otherwise, on success, it returns -1. * @returns {Number} If `firstRow` is less-than or equal to 0, this function returns 0. Otherwise, on success, it returns -1.
*
* @related Document.insertLines
**/ **/
this.moveLinesDown = function(firstRow, lastRow) { this.moveLinesDown = function(firstRow, lastRow) {
return this.$moveLines(firstRow, lastRow, 1); return this.$moveLines(firstRow, lastRow, 1);
@ -1556,11 +1556,14 @@ var EditSession = function(text, mode) {
// If wrapMode is activaed, the wrapData array has to be initialized. // If wrapMode is activaed, the wrapData array has to be initialized.
if (useWrapMode) { if (useWrapMode) {
var len = this.getLength(); var len = this.getLength();
this.$wrapData = Array(len); this.$wrapData = [];
for (var i = 0; i < len; i++) {
this.$wrapData.push([]);
}
this.$updateWrapData(0, len - 1); this.$updateWrapData(0, len - 1);
} }
this._signal("changeWrapMode"); this._emit("changeWrapMode");
} }
}; };
@ -1585,11 +1588,13 @@ var EditSession = function(text, mode) {
**/ **/
this.setWrapLimitRange = function(min, max) { this.setWrapLimitRange = function(min, max) {
if (this.$wrapLimitRange.min !== min || this.$wrapLimitRange.max !== max) { if (this.$wrapLimitRange.min !== min || this.$wrapLimitRange.max !== max) {
this.$wrapLimitRange = { min: min, max: max }; this.$wrapLimitRange = {
min: min,
max: max
};
this.$modified = true; this.$modified = true;
// This will force a recalculation of the wrap limit // This will force a recalculation of the wrap limit
if (this.$useWrapMode) this._emit("changeWrapMode");
this._signal("changeWrapMode");
} }
}; };
@ -1601,7 +1606,7 @@ var EditSession = function(text, mode) {
* @private * @private
**/ **/
this.adjustWrapLimit = function(desiredLimit, $printMargin) { this.adjustWrapLimit = function(desiredLimit, $printMargin) {
var limits = this.$wrapLimitRange; var limits = this.$wrapLimitRange
if (limits.max < 0) if (limits.max < 0)
limits = {min: $printMargin, max: $printMargin}; limits = {min: $printMargin, max: $printMargin};
var wrapLimit = this.$constrainWrapLimit(desiredLimit, limits.min, limits.max); var wrapLimit = this.$constrainWrapLimit(desiredLimit, limits.min, limits.max);
@ -1611,7 +1616,7 @@ var EditSession = function(text, mode) {
if (this.$useWrapMode) { if (this.$useWrapMode) {
this.$updateWrapData(0, this.getLength() - 1); this.$updateWrapData(0, this.getLength() - 1);
this.$resetRowCache(0); this.$resetRowCache(0);
this._signal("changeWrapLimit"); this._emit("changeWrapLimit");
} }
return true; return true;
} }
@ -1661,23 +1666,34 @@ var EditSession = function(text, mode) {
}; };
}; };
this.$updateInternalDataOnChange = function(delta) { this.$updateInternalDataOnChange = function(e) {
var useWrapMode = this.$useWrapMode; var useWrapMode = this.$useWrapMode;
var action = delta.action; var len;
var start = delta.start; var action = e.data.action;
var end = delta.end; var firstRow = e.data.range.start.row;
var firstRow = start.row; var lastRow = e.data.range.end.row;
var lastRow = end.row; var start = e.data.range.start;
var len = lastRow - firstRow; var end = e.data.range.end;
var removedFolds = null; var removedFolds = null;
if (action.indexOf("Lines") != -1) {
if (action == "insertLines") {
lastRow = firstRow + (e.data.lines.length);
} else {
lastRow = firstRow;
}
len = e.data.lines ? e.data.lines.length : lastRow - firstRow;
} else {
len = lastRow - firstRow;
}
this.$updating = true; this.$updating = true;
if (len != 0) { if (len != 0) {
if (action === "remove") { if (action.indexOf("remove") != -1) {
this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len); this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len);
var foldLines = this.$foldData; var foldLines = this.$foldData;
removedFolds = this.getFoldsInRange(delta); removedFolds = this.getFoldsInRange(e.data.range);
this.removeFolds(removedFolds); this.removeFolds(removedFolds);
var foldLine = this.getFoldLine(end.row); var foldLine = this.getFoldLine(end.row);
@ -1703,10 +1719,16 @@ var EditSession = function(text, mode) {
lastRow = firstRow; lastRow = firstRow;
} else { } else {
var args = Array(len); var args;
args.unshift(firstRow, 0); if (useWrapMode) {
var arr = useWrapMode ? this.$wrapData : this.$rowLengthCache args = [firstRow, 0];
arr.splice.apply(arr, args); for (var i = 0; i < len; i++) args.push([]);
this.$wrapData.splice.apply(this.$wrapData, args);
} else {
args = Array(len);
args.unshift(firstRow, 0);
this.$rowLengthCache.splice.apply(this.$rowLengthCache, args);
}
// If some new line is added inside of a foldLine, then split // If some new line is added inside of a foldLine, then split
// the fold line up. // the fold line up.
@ -1714,14 +1736,13 @@ var EditSession = function(text, mode) {
var foldLine = this.getFoldLine(firstRow); var foldLine = this.getFoldLine(firstRow);
var idx = 0; var idx = 0;
if (foldLine) { if (foldLine) {
var cmp = foldLine.range.compareInside(start.row, start.column); var cmp = foldLine.range.compareInside(start.row, start.column)
// Inside of the foldLine range. Need to split stuff up. // Inside of the foldLine range. Need to split stuff up.
if (cmp == 0) { if (cmp == 0) {
foldLine = foldLine.split(start.row, start.column); foldLine = foldLine.split(start.row, start.column);
if (foldLine) { foldLine.shiftRow(len);
foldLine.shiftRow(len); foldLine.addRemoveChars(
foldLine.addRemoveChars(lastRow, 0, end.column - start.column); lastRow, 0, end.column - start.column);
}
} else } else
// Infront of the foldLine but same row. Need to shift column. // Infront of the foldLine but same row. Need to shift column.
if (cmp == -1) { if (cmp == -1) {
@ -1742,10 +1763,10 @@ var EditSession = function(text, mode) {
} else { } else {
// Realign folds. E.g. if you add some new chars before a fold, the // Realign folds. E.g. if you add some new chars before a fold, the
// fold should "move" to the right. // fold should "move" to the right.
len = Math.abs(delta.start.column - delta.end.column); len = Math.abs(e.data.range.start.column - e.data.range.end.column);
if (action === "remove") { if (action.indexOf("remove") != -1) {
// Get all the folds in the change range and remove them. // Get all the folds in the change range and remove them.
removedFolds = this.getFoldsInRange(delta); removedFolds = this.getFoldsInRange(e.data.range);
this.removeFolds(removedFolds); this.removeFolds(removedFolds);
len = -len; len = -len;
@ -1812,7 +1833,8 @@ var EditSession = function(text, mode) {
lines[foldLine.end.row].length + 1 lines[foldLine.end.row].length + 1
); );
wrapData[foldLine.start.row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize); wrapData[foldLine.start.row]
= this.$computeWrapSplits(tokens, wrapLimit, tabSize);
row = foldLine.end.row + 1; row = foldLine.end.row + 1;
} }
} }
@ -1829,7 +1851,7 @@ var EditSession = function(text, mode) {
TAB_SPACE = 12; TAB_SPACE = 12;
this.$computeWrapSplits = function(tokens, wrapLimit, tabSize) { this.$computeWrapSplits = function(tokens, wrapLimit) {
if (tokens.length == 0) { if (tokens.length == 0) {
return []; return [];
} }
@ -1840,31 +1862,6 @@ var EditSession = function(text, mode) {
var isCode = this.$wrapAsCode; var isCode = this.$wrapAsCode;
var indentedSoftWrap = this.$indentedSoftWrap;
var maxIndent = wrapLimit <= Math.max(2 * tabSize, 8)
|| indentedSoftWrap === false ? 0 : Math.floor(wrapLimit / 2);
function getWrapIndent() {
var indentation = 0;
if (maxIndent === 0)
return indentation;
if (indentedSoftWrap) {
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i];
if (token == SPACE)
indentation += 1;
else if (token == TAB)
indentation += tabSize;
else if (token == TAB_SPACE)
continue;
else
break;
}
}
if (isCode && indentedSoftWrap !== false)
indentation += tabSize;
return Math.min(indentation, maxIndent);
}
function addSplit(screenPos) { function addSplit(screenPos) {
var displayed = tokens.slice(lastSplit, screenPos); var displayed = tokens.slice(lastSplit, screenPos);
@ -1881,18 +1878,14 @@ var EditSession = function(text, mode) {
len -= 1; len -= 1;
}); });
if (!splits.length) {
indent = getWrapIndent();
splits.indent = indent;
}
lastDocSplit += len; lastDocSplit += len;
splits.push(lastDocSplit); splits.push(lastDocSplit);
lastSplit = screenPos; lastSplit = screenPos;
} }
var indent = 0;
while (displayLength - lastSplit > wrapLimit - indent) { while (displayLength - lastSplit > wrapLimit) {
// This is, where the split should be. // This is, where the split should be.
var split = lastSplit + wrapLimit - indent; var split = lastSplit + wrapLimit;
// If there is a space or tab at this split position, then making // If there is a space or tab at this split position, then making
// a split is simple. // a split is simple.
@ -1952,7 +1945,7 @@ var EditSession = function(text, mode) {
// === ELSE === // === ELSE ===
// Search for the first non space/tab/placeholder/punctuation token backwards. // Search for the first non space/tab/placeholder/punctuation token backwards.
var minSplit = Math.max(split - (wrapLimit -(wrapLimit>>2)), lastSplit - 1); var minSplit = Math.max(split - (isCode ? 10 : wrapLimit-(wrapLimit>>2)), lastSplit - 1);
while (split > minSplit && tokens[split] < PLACEHOLDER_START) { while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
split --; split --;
} }
@ -1978,9 +1971,7 @@ var EditSession = function(text, mode) {
split = lastSplit + wrapLimit; split = lastSplit + wrapLimit;
// The split is inside of a CHAR or CHAR_EXT token and no space // The split is inside of a CHAR or CHAR_EXT token and no space
// around -> force a split. // around -> force a split.
if (tokens[split] == CHAR_EXT) addSplit(split);
split--;
addSplit(split - indent);
} }
return splits; return splits;
}; };
@ -2032,6 +2023,9 @@ var EditSession = function(text, mode) {
* The first position indicates the number of columns for `str` on screen.<br/> * The first position indicates the number of columns for `str` on screen.<br/>
* The second value contains the position of the document column that this function read until. * The second value contains the position of the document column that this function read until.
* *
*
*
*
**/ **/
this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) { this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) {
if (maxScreenColumn == 0) if (maxScreenColumn == 0)
@ -2087,16 +2081,6 @@ var EditSession = function(text, mode) {
} }
}; };
this.getRowWrapIndent = function(screenRow) {
if (this.$useWrapMode) {
var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE);
var splits = this.$wrapData[pos.row];
return splits.length && splits[0] < pos.column ? splits.indent : 0;
} else {
return 0;
}
}
/** /**
* Returns the position (on screen) for the last character in the provided screen row. * Returns the position (on screen) for the last character in the provided screen row.
* @param {Number} screenRow The screen row to check * @param {Number} screenRow The screen row to check
@ -2229,26 +2213,25 @@ var EditSession = function(text, mode) {
return { return {
row: maxRow, row: maxRow,
column: this.getLine(maxRow).length column: this.getLine(maxRow).length
}; }
} else { } else {
line = this.getLine(docRow); line = this.getLine(docRow);
foldLine = null; foldLine = null;
} }
var wrapIndent = 0;
if (this.$useWrapMode) { if (this.$useWrapMode) {
var splits = this.$wrapData[docRow]; var splits = this.$wrapData[docRow];
if (splits) { if (splits) {
var splitIndex = Math.floor(screenRow - row); var splitIndex = Math.floor(screenRow - row);
column = splits[splitIndex]; column = splits[splitIndex];
if(splitIndex > 0 && splits.length) { if(splitIndex > 0 && splits.length) {
wrapIndent = splits.indent;
docColumn = splits[splitIndex - 1] || splits[splits.length - 1]; docColumn = splits[splitIndex - 1] || splits[splits.length - 1];
line = line.substring(docColumn); line = line.substring(docColumn);
} }
} }
} }
docColumn += this.$getStringScreenWidth(line, screenColumn - wrapIndent)[1]; docColumn += this.$getStringScreenWidth(line, screenColumn)[1];
// We remove one character at the end so that the docColumn // We remove one character at the end so that the docColumn
// position returned is not associated to the next row on the screen. // position returned is not associated to the next row on the screen.
@ -2340,26 +2323,22 @@ var EditSession = function(text, mode) {
textLine = this.getLine(docRow).substring(0, docColumn); textLine = this.getLine(docRow).substring(0, docColumn);
foldStartRow = docRow; foldStartRow = docRow;
} }
var wrapIndent = 0;
// Clamp textLine if in wrapMode. // Clamp textLine if in wrapMode.
if (this.$useWrapMode) { if (this.$useWrapMode) {
var wrapRow = this.$wrapData[foldStartRow]; var wrapRow = this.$wrapData[foldStartRow];
if (wrapRow) { var screenRowOffset = 0;
var screenRowOffset = 0; while (textLine.length >= wrapRow[screenRowOffset]) {
while (textLine.length >= wrapRow[screenRowOffset]) { screenRow ++;
screenRow ++; screenRowOffset++;
screenRowOffset++;
}
textLine = textLine.substring(
wrapRow[screenRowOffset - 1] || 0, textLine.length
);
wrapIndent = screenRowOffset > 0 ? wrapRow.indent : 0;
} }
textLine = textLine.substring(
wrapRow[screenRowOffset - 1] || 0, textLine.length
);
} }
return { return {
row: screenRow, row: screenRow,
column: wrapIndent + this.$getStringScreenWidth(textLine)[0] column: this.$getStringScreenWidth(textLine)[0]
}; };
}; };
@ -2408,8 +2387,7 @@ var EditSession = function(text, mode) {
var foldStart = fold ? fold.start.row :Infinity; var foldStart = fold ? fold.start.row :Infinity;
while (row < lastRow) { while (row < lastRow) {
var splits = this.$wrapData[row]; screenRows += this.$wrapData[row].length + 1;
screenRows += splits ? splits.length + 1 : 1;
row ++; row ++;
if (row > foldStart) { if (row > foldStart) {
row = fold.end.row+1; row = fold.end.row+1;
@ -2425,25 +2403,14 @@ var EditSession = function(text, mode) {
return screenRows; return screenRows;
}; };
// For every keystroke this gets called once per char in the whole doc!!
// Wouldn't hurt to make it a bit faster for c >= 0x1100
/** /**
* @private * @private
* *
*/ */
this.$setFontMetrics = function(fm) {
// todo
};
this.destroy = function() {
if (this.bgTokenizer) {
this.bgTokenizer.setDocument(null);
this.bgTokenizer = null;
}
this.$stopWorker();
};
// For every keystroke this gets called once per char in the whole doc!!
// Wouldn't hurt to make it a bit faster for c >= 0x1100
function isFullWidth(c) { function isFullWidth(c) {
if (c < 0x1100) if (c < 0x1100)
return false; return false;
@ -2501,7 +2468,6 @@ config.defineOptions(EditSession.prototype, "session", {
if (this.$wrap == value) if (this.$wrap == value)
return; return;
this.$wrap = value;
if (!value) { if (!value) {
this.setUseWrapMode(false); this.setUseWrapMode(false);
} else { } else {
@ -2509,16 +2475,10 @@ config.defineOptions(EditSession.prototype, "session", {
this.setWrapLimitRange(col, col); this.setWrapLimitRange(col, col);
this.setUseWrapMode(true); this.setUseWrapMode(true);
} }
this.$wrap = value;
}, },
get: function() { get: function() {
if (this.getUseWrapMode()) { return this.getUseWrapMode() ? this.getWrapLimitRange().min || "free" : "off";
if (this.$wrap == -1)
return "printMargin";
if (!this.getWrapLimitRange().min)
return "free";
return this.$wrap;
}
return "off";
}, },
handlesSet: true handlesSet: true
}, },
@ -2539,9 +2499,8 @@ config.defineOptions(EditSession.prototype, "session", {
}, },
initialValue: "auto" initialValue: "auto"
}, },
indentedSoftWrap: { initialValue: true },
firstLineNumber: { firstLineNumber: {
set: function() {this._signal("changeBreakpoint");}, set: function() {this._emit("changeBreakpoint");},
initialValue: 1 initialValue: 1
}, },
useWorker: { useWorker: {
@ -2562,23 +2521,19 @@ config.defineOptions(EditSession.prototype, "session", {
this.$modified = true; this.$modified = true;
this.$rowLengthCache = []; this.$rowLengthCache = [];
this.$tabSize = tabSize; this.$tabSize = tabSize;
this._signal("changeTabSize"); this._emit("changeTabSize");
}, },
initialValue: 4, initialValue: 4,
handlesSet: true handlesSet: true
}, },
overwrite: { overwrite: {
set: function(val) {this._signal("changeOverwrite");}, set: function(val) {this._emit("changeOverwrite");},
initialValue: false initialValue: false
}, },
newLineMode: { newLineMode: {
set: function(val) {this.doc.setNewLineMode(val)}, set: function(val) {this.doc.setNewLineMode(val)},
get: function() {return this.doc.getNewLineMode()}, get: function() {return this.doc.getNewLineMode()},
handlesSet: true handlesSet: true
},
mode: {
set: function(val) { this.setMode(val) },
get: function() { return this.$modeId }
} }
}); });

View file

@ -117,7 +117,6 @@ function BracketMatch() {
typeRe = new RegExp( typeRe = new RegExp(
"(\\.?" + "(\\.?" +
token.type.replace(".", "\\.").replace("rparen", ".paren") token.type.replace(".", "\\.").replace("rparen", ".paren")
.replace(/\b(?:end)\b/, "(?:start|begin|end)")
+ ")+" + ")+"
); );
} }
@ -174,7 +173,6 @@ function BracketMatch() {
typeRe = new RegExp( typeRe = new RegExp(
"(\\.?" + "(\\.?" +
token.type.replace(".", "\\.").replace("lparen", ".paren") token.type.replace(".", "\\.").replace("lparen", ".paren")
.replace(/\b(?:start|begin)\b/, "(?:start|begin|end)")
+ ")+" + ")+"
); );
} }

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